mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Fix for #2451
This commit is contained in:
@@ -82,13 +82,15 @@ class BudgetReportHelper implements BudgetReportHelperInterface
|
|||||||
'rows' => [],
|
'rows' => [],
|
||||||
];
|
];
|
||||||
// get multi currency expenses first:
|
// get multi currency expenses first:
|
||||||
$budgetLimits = $this->repository->getBudgetLimits($budget, $start, $end);
|
$budgetLimits = $this->repository->getBudgetLimits($budget, $start, $end);
|
||||||
$expenses = $this->repository->spentInPeriodMc(new Collection([$budget]), $accounts, $start, $end);
|
$expenses = $this->repository->spentInPeriodMc(new Collection([$budget]), $accounts, $start, $end);
|
||||||
|
$defaultCurrency = app('amount')->getDefaultCurrencyByUser($budget->user);
|
||||||
if (0 === count($expenses)) {
|
if (0 === count($expenses)) {
|
||||||
// list the budget limits, basic amounts.
|
// list the budget limits, basic amounts.
|
||||||
/** @var BudgetLimit $limit */
|
/** @var BudgetLimit $limit */
|
||||||
foreach ($budgetLimits as $limit) {
|
foreach ($budgetLimits as $limit) {
|
||||||
$row = [
|
$currency = $limit->transactionCurrency ?? $defaultCurrency;
|
||||||
|
$row = [
|
||||||
'limit_id' => $limit->id,
|
'limit_id' => $limit->id,
|
||||||
'start_date' => $limit->start_date,
|
'start_date' => $limit->start_date,
|
||||||
'end_date' => $limit->end_date,
|
'end_date' => $limit->end_date,
|
||||||
@@ -96,11 +98,11 @@ class BudgetReportHelper implements BudgetReportHelperInterface
|
|||||||
'spent' => '0',
|
'spent' => '0',
|
||||||
'left' => $limit->amount,
|
'left' => $limit->amount,
|
||||||
'overspent' => null,
|
'overspent' => null,
|
||||||
'currency_id' => $limit->transactionCurrency->id,
|
'currency_id' => $currency->id,
|
||||||
'currency_code' => $limit->transactionCurrency->code,
|
'currency_code' => $currency->code,
|
||||||
'currency_name' => $limit->transactionCurrency->name,
|
'currency_name' => $currency->name,
|
||||||
'currency_symbol' => $limit->transactionCurrency->symbol,
|
'currency_symbol' => $currency->symbol,
|
||||||
'currency_decimal_places' => $limit->transactionCurrency->decimal_places,
|
'currency_decimal_places' => $currency\->decimal_places,
|
||||||
];
|
];
|
||||||
|
|
||||||
$entry['rows'][] = $row;
|
$entry['rows'][] = $row;
|
||||||
@@ -169,8 +171,8 @@ class BudgetReportHelper implements BudgetReportHelperInterface
|
|||||||
foreach ($array['budgets'] as $budget) {
|
foreach ($array['budgets'] as $budget) {
|
||||||
/** @var array $row */
|
/** @var array $row */
|
||||||
foreach ($budget['rows'] as $row) {
|
foreach ($budget['rows'] as $row) {
|
||||||
$currencyId = $row['currency_id'];
|
$currencyId = $row['currency_id'];
|
||||||
$array['sums'][$currencyId] = $array['sums'][$currencyId] ?? [
|
$array['sums'][$currencyId] = $array['sums'][$currencyId] ?? [
|
||||||
'currency_id' => $row['currency_id'],
|
'currency_id' => $row['currency_id'],
|
||||||
'currency_code' => $row['currency_code'],
|
'currency_code' => $row['currency_code'],
|
||||||
'currency_name' => $row['currency_name'],
|
'currency_name' => $row['currency_name'],
|
||||||
@@ -181,12 +183,13 @@ class BudgetReportHelper implements BudgetReportHelperInterface
|
|||||||
'left' => '0',
|
'left' => '0',
|
||||||
'overspent' => '0',
|
'overspent' => '0',
|
||||||
];
|
];
|
||||||
$array['sums'][$currencyId]['budgeted'] = bcadd($array['sums'][$currencyId]['budgeted'], $row['budgeted'] ?? '0');
|
$array['sums'][$currencyId]['budgeted'] = bcadd($array['sums'][$currencyId]['budgeted'], $row['budgeted'] ?? '0');
|
||||||
$array['sums'][$currencyId]['spent'] = bcadd($array['sums'][$currencyId]['spent'], $row['spent'] ?? '0');
|
$array['sums'][$currencyId]['spent'] = bcadd($array['sums'][$currencyId]['spent'], $row['spent'] ?? '0');
|
||||||
$array['sums'][$currencyId]['left'] = bcadd($array['sums'][$currencyId]['left'], $row['left'] ?? '0');
|
$array['sums'][$currencyId]['left'] = bcadd($array['sums'][$currencyId]['left'], $row['left'] ?? '0');
|
||||||
$array['sums'][$currencyId]['overspent'] = bcadd($array['sums'][$currencyId]['overspent'], $row['overspent'] ?? '0');
|
$array['sums'][$currencyId]['overspent'] = bcadd($array['sums'][$currencyId]['overspent'], $row['overspent'] ?? '0');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $array;
|
return $array;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user