mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Possible fix for issue reported over email.
This commit is contained in:
parent
ee625a9c3f
commit
8ee1b08c57
@ -289,8 +289,8 @@ class BudgetController extends Controller
|
|||||||
|
|
||||||
// loop again to get percentages.
|
// loop again to get percentages.
|
||||||
foreach ($report as $budgetId => $data) {
|
foreach ($report as $budgetId => $data) {
|
||||||
foreach ($data['currencies'] as $currencyId => $data) {
|
foreach ($data['currencies'] as $currencyId => $dataX) {
|
||||||
$sum = $data['sum'] ?? '0';
|
$sum = $dataX['sum'] ?? '0';
|
||||||
$total = $sums[$currencyId]['sum'] ?? '0';
|
$total = $sums[$currencyId]['sum'] ?? '0';
|
||||||
$pct = '0';
|
$pct = '0';
|
||||||
if (0 !== bccomp($sum, '0') && 0 !== bccomp($total, '9')) {
|
if (0 !== bccomp($sum, '0') && 0 !== bccomp($total, '9')) {
|
||||||
@ -361,7 +361,8 @@ class BudgetController extends Controller
|
|||||||
];
|
];
|
||||||
|
|
||||||
// make sum information:
|
// make sum information:
|
||||||
$report['sums'][$currency->id] = $report['sums'][$currency->id] ?? [
|
$report['sums'][$currency->id]
|
||||||
|
= $report['sums'][$currency->id] ?? [
|
||||||
'budgeted' => '0',
|
'budgeted' => '0',
|
||||||
'spent' => '0',
|
'spent' => '0',
|
||||||
'left' => '0',
|
'left' => '0',
|
||||||
@ -411,15 +412,13 @@ class BudgetController extends Controller
|
|||||||
// make percentages based on total amount.
|
// make percentages based on total amount.
|
||||||
foreach ($report['budgets'] as $budgetId => $data) {
|
foreach ($report['budgets'] as $budgetId => $data) {
|
||||||
foreach ($data['budget_limits'] as $limitId => $entry) {
|
foreach ($data['budget_limits'] as $limitId => $entry) {
|
||||||
$currencyId = $entry['currency_id'];
|
$currencyId = $entry['currency_id'];
|
||||||
|
$spent = $entry['spent'];
|
||||||
$spent = $entry['spent'];
|
$totalSpent = $report['sums'][$currencyId]['spent'] ?? '0';
|
||||||
$totalSpent = $report['sums'][$currencyId]['spent'] ?? '0';
|
$spentPct = '0';
|
||||||
$spentPct = '0';
|
|
||||||
|
|
||||||
$budgeted = $entry['budgeted'];
|
$budgeted = $entry['budgeted'];
|
||||||
$totalBudgeted = $report['sums'][$currencyId]['budgeted'] ?? '0';;
|
$totalBudgeted = $report['sums'][$currencyId]['budgeted'] ?? '0';
|
||||||
$budgetedPct = '0';
|
$budgetedPct = '0';
|
||||||
|
|
||||||
if (0 !== bccomp($spent, '0') && 0 !== bccomp($totalSpent, '0')) {
|
if (0 !== bccomp($spent, '0') && 0 !== bccomp($totalSpent, '0')) {
|
||||||
$spentPct = round(bcmul(bcdiv($spent, $totalSpent), '100'));
|
$spentPct = round(bcmul(bcdiv($spent, $totalSpent), '100'));
|
||||||
@ -427,28 +426,13 @@ class BudgetController extends Controller
|
|||||||
if (0 !== bccomp($budgeted, '0') && 0 !== bccomp($totalBudgeted, '0')) {
|
if (0 !== bccomp($budgeted, '0') && 0 !== bccomp($totalBudgeted, '0')) {
|
||||||
$budgetedPct = round(bcmul(bcdiv($budgeted, $totalBudgeted), '100'));
|
$budgetedPct = round(bcmul(bcdiv($budgeted, $totalBudgeted), '100'));
|
||||||
}
|
}
|
||||||
|
$report['sums'][$currencyId]['budgeted'] = $report['sums'][$currencyId]['budgeted'] ?? '0';
|
||||||
$report['budgets'][$budgetId]['budget_limits'][$limitId]['spent_pct'] = $spentPct;
|
$report['budgets'][$budgetId]['budget_limits'][$limitId]['spent_pct'] = $spentPct;
|
||||||
$report['budgets'][$budgetId]['budget_limits'][$limitId]['budgeted_pct'] = $budgetedPct;
|
$report['budgets'][$budgetId]['budget_limits'][$limitId]['budgeted_pct'] = $budgetedPct;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// var_dump($noBudget);
|
return view('reports.partials.budgets', compact('report'))->render();
|
||||||
//
|
|
||||||
//
|
|
||||||
// echo '<pre>';
|
|
||||||
// print_r($report);
|
|
||||||
// exit;
|
|
||||||
// try {
|
|
||||||
$result = view('reports.partials.budgets', compact('report'))->render();
|
|
||||||
// @codeCoverageIgnoreStart
|
|
||||||
// } catch (Throwable $e) {
|
|
||||||
// Log::debug(sprintf('Could not render reports.partials.budgets: %s', $e->getMessage()));
|
|
||||||
// $result = 'Could not render view.';
|
|
||||||
// }
|
|
||||||
|
|
||||||
// @codeCoverageIgnoreEnd
|
|
||||||
|
|
||||||
return $result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user