Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Fix https://github.com/firefly-iii/firefly-iii/issues/8041
James Cole0c841a12d288
diff --git a/app/Http/Controllers/Chart/AccountController.php b/app/Http/Controllers/Chart/AccountController.phpindex 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.twigindex 56d9738485..5553f2b362 100644--- a/resources/views/layout/default.twig+++ b/resources/views/layout/default.twig@@ -217,7 +217,7 @@{# Moment JS #}<script src="v1/js/lib/moment.min.js?v={{ FF_VERSION }}" type="text/javascript" nonce="{{ JS_NONCE }}"></script>-<script src="v1/js/lib/moment/{{ language }}.js?v={{ FF_VERSION }}" type="text/javascript"+<script src="v1/js/lib/moment/{{ language|replace({'-':'_'}) }}.js?v={{ FF_VERSION }}" type="text/javascript"nonce="{{ JS_NONCE }}"></script>{# All kinds of variables. #}