mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-14 16:13:54 +00:00
Fix some bugs in multi-currency reports.
This commit is contained in:
@@ -408,7 +408,7 @@ class BudgetController extends Controller
|
|||||||
$cache->addProperty($currency->id);
|
$cache->addProperty($currency->id);
|
||||||
$cache->addProperty('chart.budget.period');
|
$cache->addProperty('chart.budget.period');
|
||||||
if ($cache->has()) {
|
if ($cache->has()) {
|
||||||
return response()->json($cache->get()); // @codeCoverageIgnore
|
// return response()->json($cache->get()); // @codeCoverageIgnore
|
||||||
}
|
}
|
||||||
$titleFormat = app('navigation')->preferredCarbonLocalizedFormat($start, $end);
|
$titleFormat = app('navigation')->preferredCarbonLocalizedFormat($start, $end);
|
||||||
$preferredRange = app('navigation')->preferredRangeFormat($start, $end);
|
$preferredRange = app('navigation')->preferredRangeFormat($start, $end);
|
||||||
@@ -427,16 +427,17 @@ class BudgetController extends Controller
|
|||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
$currentStart = clone $start;
|
$currentStart = clone $start;
|
||||||
while ($currentStart <= $end) {
|
while ($currentStart <= $end) {
|
||||||
|
$currentStart= app('navigation')->startOfPeriod($currentStart, $preferredRange);
|
||||||
$title = $currentStart->formatLocalized($titleFormat);
|
$title = $currentStart->formatLocalized($titleFormat);
|
||||||
$currentEnd = app('navigation')->endOfPeriod($currentStart, $preferredRange);
|
$currentEnd = app('navigation')->endOfPeriod($currentStart, $preferredRange);
|
||||||
|
|
||||||
// default limit is no limit:
|
// default limit is no limit:
|
||||||
$chartData[0]['entries'][$title] = 0;
|
$chartData[0]['entries'][$title] = 0;
|
||||||
$chartData[1]['entries'][$title] = 0;
|
|
||||||
|
|
||||||
|
// default spent is not spent at all.
|
||||||
|
$chartData[1]['entries'][$title] = 0;
|
||||||
|
|
||||||
// get budget limit in this period for this currency.
|
// get budget limit in this period for this currency.
|
||||||
$limit = $this->blRepository->find($budget, $currency, $currentStart, $currentEnd);
|
$limit = $this->blRepository->find($budget, $currency, $currentStart, $currentEnd);
|
||||||
@@ -449,7 +450,8 @@ class BudgetController extends Controller
|
|||||||
$amount = app('steam')->positive($sum[$currency->id]['sum'] ?? '0');
|
$amount = app('steam')->positive($sum[$currency->id]['sum'] ?? '0');
|
||||||
$chartData[0]['entries'][$title] = round($amount, $currency->decimal_places);
|
$chartData[0]['entries'][$title] = round($amount, $currency->decimal_places);
|
||||||
|
|
||||||
$currentStart = app('navigation')->addPeriod($currentStart, $preferredRange, 0);
|
$currentStart = clone $currentEnd;
|
||||||
|
$currentStart->addDay()->startOfDay();
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = $this->generator->multiSet($chartData);
|
$data = $this->generator->multiSet($chartData);
|
||||||
|
@@ -112,8 +112,11 @@ class BudgetController extends Controller
|
|||||||
$periods = app('navigation')->listOfPeriods($start, $end);
|
$periods = app('navigation')->listOfPeriods($start, $end);
|
||||||
$keyFormat = app('navigation')->preferredCarbonFormat($start, $end);
|
$keyFormat = app('navigation')->preferredCarbonFormat($start, $end);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// list expenses for budgets in account(s)
|
// list expenses for budgets in account(s)
|
||||||
$expenses = $opsRepository->listExpenses($start, $end, $accounts);
|
$expenses = $opsRepository->listExpenses($start, $end, $accounts);
|
||||||
|
|
||||||
$report = [];
|
$report = [];
|
||||||
foreach ($expenses as $currency) {
|
foreach ($expenses as $currency) {
|
||||||
foreach ($currency['budgets'] as $budget) {
|
foreach ($currency['budgets'] as $budget) {
|
||||||
|
@@ -222,7 +222,7 @@ class OperationsRepository implements OperationsRepositoryInterface
|
|||||||
|
|
||||||
// catch "no category" entries.
|
// catch "no category" entries.
|
||||||
if (0 === $budgetId) {
|
if (0 === $budgetId) {
|
||||||
$budgetName = (string)trans('firefly.no_budget');
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// info about the currency:
|
// info about the currency:
|
||||||
|
Reference in New Issue
Block a user