diff --git a/app/Http/Controllers/Chart/AccountController.php b/app/Http/Controllers/Chart/AccountController.php
index b57bee22d8..00c6a5c661 100644
--- a/app/Http/Controllers/Chart/AccountController.php
+++ b/app/Http/Controllers/Chart/AccountController.php
@@ -472,6 +472,7 @@ class AccountController extends Controller
*/
private function periodByCurrency(Carbon $start, Carbon $end, Account $account, TransactionCurrency $currency): array
{
+ app('log')->debug(sprintf('Now in periodByCurrency("%s", "%s", %s, "%s")', $start->format('Y-m-d'), $end->format('Y-m-d'), $account->id, $currency->code));
$locale = app('steam')->getLocale();
$step = $this->calculateStep($start, $end);
$result = [
@@ -481,6 +482,13 @@ class AccountController extends Controller
];
$entries = [];
$current = clone $start;
+ app('log')->debug(sprintf('Step is %s', $step));
+
+ // fix for issue https://github.com/firefly-iii/firefly-iii/issues/8041
+ // have to make sure this chart is always based on the balance at the END of the period.
+ // This period depends on the size of the chart
+ $current = app('navigation')->endOfX($current, $step, null);
+ app('log')->debug(sprintf('$current date is %s', $current->format('Y-m-d')));
if ('1D' === $step) {
// per day the entire period, balance for every day.
$format = (string)trans('config.month_and_day_js', [], $locale);
@@ -497,10 +505,13 @@ class AccountController extends Controller
}
if ('1W' === $step || '1M' === $step || '1Y' === $step) {
while ($end >= $current) {
+ app('log')->debug(sprintf('Current is: %s', $current->format('Y-m-d')));
$balance = (float)app('steam')->balance($account, $current, $currency);
$label = app('navigation')->periodShow($current, $step);
$entries[$label] = $balance;
$current = app('navigation')->addPeriod($current, $step, 0);
+ // here too, to fix #8041, the data is corrected to the end of the period.
+ $current = app('navigation')->endOfX($current, $step, null);
}
}
$result['entries'] = $entries;
diff --git a/resources/views/layout/default.twig b/resources/views/layout/default.twig
index 56d9738485..5553f2b362 100644
--- a/resources/views/layout/default.twig
+++ b/resources/views/layout/default.twig
@@ -217,7 +217,7 @@
{# Moment JS #}
-
{# All kinds of variables. #}