This commit is contained in:
James Cole
2019-08-21 18:07:15 +02:00
parent 24a2238134
commit 6f75e0df3c

View File

@@ -84,10 +84,12 @@ class BudgetReportHelper implements BudgetReportHelperInterface
// get multi currency expenses first:
$budgetLimits = $this->repository->getBudgetLimits($budget, $start, $end);
$expenses = $this->repository->spentInPeriodMc(new Collection([$budget]), $accounts, $start, $end);
$defaultCurrency = app('amount')->getDefaultCurrencyByUser($budget->user);
if (0 === count($expenses)) {
// list the budget limits, basic amounts.
/** @var BudgetLimit $limit */
foreach ($budgetLimits as $limit) {
$currency = $limit->transactionCurrency ?? $defaultCurrency;
$row = [
'limit_id' => $limit->id,
'start_date' => $limit->start_date,
@@ -96,11 +98,11 @@ class BudgetReportHelper implements BudgetReportHelperInterface
'spent' => '0',
'left' => $limit->amount,
'overspent' => null,
'currency_id' => $limit->transactionCurrency->id,
'currency_code' => $limit->transactionCurrency->code,
'currency_name' => $limit->transactionCurrency->name,
'currency_symbol' => $limit->transactionCurrency->symbol,
'currency_decimal_places' => $limit->transactionCurrency->decimal_places,
'currency_id' => $currency->id,
'currency_code' => $currency->code,
'currency_name' => $currency->name,
'currency_symbol' => $currency->symbol,
'currency_decimal_places' => $currency\->decimal_places,
];
$entry['rows'][] = $row;
@@ -187,6 +189,7 @@ class BudgetReportHelper implements BudgetReportHelperInterface
$array['sums'][$currencyId]['overspent'] = bcadd($array['sums'][$currencyId]['overspent'], $row['overspent'] ?? '0');
}
}
return $array;
}