mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-08 02:38:09 +00:00
Fix #2609
This commit is contained in:
@@ -349,13 +349,12 @@ class SummaryController extends Controller
|
|||||||
$today = new Carbon;
|
$today = new Carbon;
|
||||||
$available = $this->abRepository->getAvailableBudgetWithCurrency($start, $end);
|
$available = $this->abRepository->getAvailableBudgetWithCurrency($start, $end);
|
||||||
$budgets = $this->budgetRepository->getActiveBudgets();
|
$budgets = $this->budgetRepository->getActiveBudgets();
|
||||||
$spentInfo = $this->opsRepository->spentInPeriodMc($budgets, new Collection, $start, $end);
|
$spent = $this->opsRepository->sumExpenses($start, $end, null, $budgets);
|
||||||
foreach ($available as $currencyId => $amount) {
|
|
||||||
$currency = $this->currencyRepos->findNull($currencyId);
|
foreach ($spent as $row) {
|
||||||
if (null === $currency) {
|
// either an amount was budgeted or 0 is available.
|
||||||
continue;
|
$amount = $available[$row['currency_id']] ?? '0';
|
||||||
}
|
$spentInCurrency = $row['sum'];
|
||||||
$spentInCurrency = (string)$this->findInSpentArray($spentInfo, $currency);
|
|
||||||
$leftToSpend = bcadd($amount, $spentInCurrency);
|
$leftToSpend = bcadd($amount, $spentInCurrency);
|
||||||
|
|
||||||
$days = $today->diffInDays($end) + 1;
|
$days = $today->diffInDays($end) + 1;
|
||||||
@@ -365,19 +364,23 @@ class SummaryController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
$return[] = [
|
$return[] = [
|
||||||
'key' => sprintf('left-to-spend-in-%s', $currency->code),
|
'key' => sprintf('left-to-spend-in-%s', $row['currency_code']),
|
||||||
'title' => trans('firefly.box_left_to_spend_in_currency', ['currency' => $currency->symbol]),
|
'title' => trans('firefly.box_left_to_spend_in_currency', ['currency' => $row['currency_symbol']]),
|
||||||
'monetary_value' => round($leftToSpend, $currency->decimal_places),
|
'monetary_value' => round($leftToSpend, $row['currency_decimal_places']),
|
||||||
'currency_id' => $currency->id,
|
'currency_id' => $row['currency_id'],
|
||||||
'currency_code' => $currency->code,
|
'currency_code' => $row['currency_code'],
|
||||||
'currency_symbol' => $currency->symbol,
|
'currency_symbol' => $row['currency_symbol'],
|
||||||
'currency_decimal_places' => $currency->decimal_places,
|
'currency_decimal_places' => $row['currency_decimal_places'],
|
||||||
'value_parsed' => app('amount')->formatAnything($currency, $leftToSpend, false),
|
'value_parsed' => app('amount')->formatFlat($row['currency_symbol'], $row['currency_decimal_places'], $leftToSpend, false),
|
||||||
'local_icon' => 'money',
|
'local_icon' => 'money',
|
||||||
'sub_title' => (string)trans('firefly.box_spend_per_day', ['amount' => app('amount')->formatAnything($currency, $perDay, false)]),
|
'sub_title' => (string)trans(
|
||||||
|
'firefly.box_spend_per_day', ['amount' => app('amount')->formatFlat(
|
||||||
|
$row['currency_symbol'], $row['currency_decimal_places'], $perDay, false
|
||||||
|
)]
|
||||||
|
),
|
||||||
];
|
];
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -138,8 +138,8 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface
|
|||||||
{
|
{
|
||||||
$return = [];
|
$return = [];
|
||||||
$availableBudgets = $this->user->availableBudgets()
|
$availableBudgets = $this->user->availableBudgets()
|
||||||
->where('start_date', $start->format('Y-m-d 00:00:00'))
|
->where('start_date', $start->format('Y-m-d'))
|
||||||
->where('end_date', $end->format('Y-m-d 00:00:00'))->get();
|
->where('end_date', $end->format('Y-m-d'))->get();
|
||||||
/** @var AvailableBudget $availableBudget */
|
/** @var AvailableBudget $availableBudget */
|
||||||
foreach ($availableBudgets as $availableBudget) {
|
foreach ($availableBudgets as $availableBudget) {
|
||||||
$return[$availableBudget->transaction_currency_id] = $availableBudget->amount;
|
$return[$availableBudget->transaction_currency_id] = $availableBudget->amount;
|
||||||
|
|||||||
Reference in New Issue
Block a user