fix revenu
This commit is contained in:
@@ -328,12 +328,16 @@ foreach ($allExpenses as $exp) {
|
|||||||
$cat = $exp['category'];
|
$cat = $exp['category'];
|
||||||
if (!isset($totals[$cat])) $cat = 'Autres';
|
if (!isset($totals[$cat])) $cat = 'Autres';
|
||||||
|
|
||||||
|
|
||||||
|
if ($cat === 'Income') {
|
||||||
|
$totals[$cat] += abs($exp['amount']);
|
||||||
|
} else {
|
||||||
if ($exp['amount'] < 0) {
|
if ($exp['amount'] < 0) {
|
||||||
if ($cat === 'Income') $totals[$cat] += abs($exp['amount']);
|
$categoriesConfig[$cat]['budget'] += abs($exp['amount']);
|
||||||
else $categoriesConfig[$cat]['budget'] += abs($exp['amount']);
|
|
||||||
} else {
|
} else {
|
||||||
$totals[$cat] += $exp['amount'];
|
$totals[$cat] += $exp['amount'];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$expensesByCategory[$cat][] = $exp;
|
$expensesByCategory[$cat][] = $exp;
|
||||||
}
|
}
|
||||||
@@ -343,10 +347,17 @@ $globalBudget = array_sum(array_column($categoriesConfig, 'budget'));
|
|||||||
|
|
||||||
function getDisplayLogic($spent, $bg, $type) {
|
function getDisplayLogic($spent, $bg, $type) {
|
||||||
if ($type === 'credit') {
|
if ($type === 'credit') {
|
||||||
$pct = ($bg > 0) ? max(0, min(100, ($spent / $bg) * 100)) : 0;
|
// Pour les revenus : $spent = revenu perçu, $bg = revenu prévu
|
||||||
$isOver = false;
|
$pct = ($bg > 0) ? min(100, ($spent / $bg) * 100) : ($spent > 0 ? 100 : 0);
|
||||||
|
$isOver = false; // On n'est jamais "dans le rouge" avec les revenus !
|
||||||
|
|
||||||
|
if ($bg > 0) {
|
||||||
$text = number_format(ceil($spent), 0, ',', ' ') . ' / ' . number_format(ceil($bg), 0, ',', ' ') . ' €';
|
$text = number_format(ceil($spent), 0, ',', ' ') . ' / ' . number_format(ceil($bg), 0, ',', ' ') . ' €';
|
||||||
} else {
|
} else {
|
||||||
|
$text = number_format(ceil($spent), 0, ',', ' ') . ' €';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Pour les dépenses
|
||||||
$pct = ($bg > 0) ? min(100, ($spent / $bg) * 100) : ($spent > 0 ? 100 : 0);
|
$pct = ($bg > 0) ? min(100, ($spent / $bg) * 100) : ($spent > 0 ? 100 : 0);
|
||||||
$isOver = ($spent > $bg && $bg > 0);
|
$isOver = ($spent > $bg && $bg > 0);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user