Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Fix https://github.com/firefly-iii/firefly-iii/issues/9736
James Coled11c23217158
diff --git a/app/Api/V1/Controllers/Autocomplete/AccountController.php b/app/Api/V1/Controllers/Autocomplete/AccountController.phpindex 70ded8ad44..295b8456f2 100644--- a/app/Api/V1/Controllers/Autocomplete/AccountController.php+++ b/app/Api/V1/Controllers/Autocomplete/AccountController.php@@ -83,6 +83,9 @@ class AccountController extends Controller$return = [];$result = $this->repository->searchAccount((string) $query, $types, $this->parameters->get('limit'));+ // set date to end-of-day for account balance.+ $date->endOfDay();+/** @var Account $account */foreach ($result as $account) {$nameWithBalance = $account->name;diff --git a/app/Api/V1/Controllers/Chart/AccountController.php b/app/Api/V1/Controllers/Chart/AccountController.phpindex 68292d36a2..e6ceb7d015 100644--- a/app/Api/V1/Controllers/Chart/AccountController.php+++ b/app/Api/V1/Controllers/Chart/AccountController.php@@ -32,6 +32,7 @@ use FireflyIII\Exceptions\FireflyException;use FireflyIII\Models\Account;use FireflyIII\Models\Preference;use FireflyIII\Repositories\Account\AccountRepositoryInterface;+use FireflyIII\Support\Facades\Steam;use FireflyIII\Support\Http\Api\ApiSupport;use FireflyIII\User;use Illuminate\Http\JsonResponse;@@ -80,6 +81,10 @@ class AccountController extends Controller/** @var Carbon $end */$end = $dates['end'];+ // set dates to end of day + start of day:+ $start->startOfDay();+ $end->endOfDay();+// user's preferences$defaultSet = $this->repository->getAccountsByType([AccountTypeEnum::ASSET->value])->pluck('id')->toArray();@@ -113,7 +118,7 @@ class AccountController extends Controller];// TODO this code is also present in the V2 chart account controller so this method is due to be deprecated.$currentStart = clone $start;- $range = app('steam')->finalAccountBalanceInRange($account, $start, clone $end, $this->convertToNative);+ $range = Steam::finalAccountBalanceInRange($account, $start, clone $end, $this->convertToNative);$previous = array_values($range)[0][$field];while ($currentStart <= $end) {$format = $currentStart->format('Y-m-d');diff --git a/app/Api/V2/Controllers/Chart/AccountController.php b/app/Api/V2/Controllers/Chart/AccountController.phpindex 699774cf02..e27f49dfe9 100644--- a/app/Api/V2/Controllers/Chart/AccountController.php+++ b/app/Api/V2/Controllers/Chart/AccountController.php@@ -31,6 +31,7 @@ use FireflyIII\Models\Account;use FireflyIII\Models\TransactionCurrency;use FireflyIII\Repositories\UserGroups\Account\AccountRepositoryInterface;use FireflyIII\Support\Chart\ChartData;+use FireflyIII\Support\Facades\Steam;use FireflyIII\Support\Http\Api\CleansChartData;use FireflyIII\Support\Http\Api\CollectsAccountsFromFilter;use FireflyIII\Support\Http\Api\ValidatesUserGroupTrait;@@ -118,7 +119,7 @@ class AccountController extends Controller'native_entries' => [],];$currentStart = clone $params['start'];- $range = app('steam')->finalAccountBalanceInRange($account, $params['start'], clone $params['end'], $this->convertToNative);+ $range = Steam::finalAccountBalanceInRange($account, $params['start'], clone $params['end'], $this->convertToNative);$previous = array_values($range)[0]['balance'];$previousNative = array_values($range)[0]['native_balance'];diff --git a/app/Generator/Report/Audit/MonthReportGenerator.php b/app/Generator/Report/Audit/MonthReportGenerator.phpindex 08e0ea8e1f..2a4eb211b9 100644--- a/app/Generator/Report/Audit/MonthReportGenerator.php+++ b/app/Generator/Report/Audit/MonthReportGenerator.php@@ -54,6 +54,9 @@ class MonthReportGenerator implements ReportGeneratorInterface$dayBefore = clone $this->start;$dayBefore->subDay();+ // move to end of day+ $dayBefore->endOfDay();+/** @var Account $account */foreach ($this->accounts as $account) {// balance the day before:diff --git a/app/Http/Controllers/Account/ReconcileController.php b/app/Http/Controllers/Account/ReconcileController.phpindex 4e523bca6f..a49b1b0c1a 100644--- a/app/Http/Controllers/Account/ReconcileController.php+++ b/app/Http/Controllers/Account/ReconcileController.php@@ -108,6 +108,9 @@ class ReconcileController extends Controllerif ($end->lt($start)) {[$start, $end] = [$end, $start];}+ // move dates to end of day and start of day:+ $start->startOfDay();+ $end->endOfDay();$startDate = clone $start;$startDate->subDay();diff --git a/app/Http/Controllers/Account/ShowController.php b/app/Http/Controllers/Account/ShowController.phpindex 50c7ee56c9..12b1e24b94 100644--- a/app/Http/Controllers/Account/ShowController.php+++ b/app/Http/Controllers/Account/ShowController.php@@ -93,6 +93,11 @@ class ShowController extends Controllerif ($end->lt($start)) {[$start, $end] = [$end, $start];}++ // make sure dates are end of day and start of day:+ $start->startOfDay();+ $end->endOfDay();+$location = $this->repository->getLocation($account);$attachments = $this->repository->getAttachments($account);$today = today(config('app.timezone'));@@ -181,6 +186,8 @@ class ShowController extends Controller$subTitle = (string) trans('firefly.all_journals_for_account', ['name' => $account->name]);$periods = new Collection();+ $end->endOfDay();+/** @var GroupCollectorInterface $collector */$collector = app(GroupCollectorInterface::class);$collector->setAccounts(new Collection([$account]))->setLimit($pageSize)->setPage($page)->withAccountInformation()->withCategoryInformation();diff --git a/app/Http/Controllers/Chart/AccountController.php b/app/Http/Controllers/Chart/AccountController.phpindex a559bfa26f..3f986547ab 100644--- a/app/Http/Controllers/Chart/AccountController.php+++ b/app/Http/Controllers/Chart/AccountController.php@@ -416,6 +416,8 @@ class AccountController extends Controller*/public function period(Account $account, Carbon $start, Carbon $end): JsonResponse{+ $start->startOfDay();+ $end->endOfDay();Log::debug(sprintf('Now in period("%s", "%s")', $start->format('Y-m-d'), $end->format('Y-m-d')));$chartData = [];$cache = new CacheProperties();@@ -442,11 +444,8 @@ class AccountController extends Controller$format = (string) trans('config.month_and_day_js', [], $locale);$accountCurrency = $this->accountRepository->getAccountCurrency($account);- Log::debug('One');$range = Steam::finalAccountBalanceInRange($account, $start, $end, $this->convertToNative);- Log::debug('Two');$range = Steam::filterAccountBalances($range, $account, $this->convertToNative, $accountCurrency);- Log::debug('Three');// temp, get end balance.Log::debug('temp get end balance');diff --git a/app/Http/Controllers/Json/ReconcileController.php b/app/Http/Controllers/Json/ReconcileController.phpindex 12c694fe34..7037e7428a 100644--- a/app/Http/Controllers/Json/ReconcileController.php+++ b/app/Http/Controllers/Json/ReconcileController.php@@ -189,9 +189,10 @@ class ReconcileController extends Controllerif ($end->lt($start)) {[$end, $start] = [$start, $end];}+ $start->startOfDay();+ $end->endOfDay();$startDate = clone $start;$startDate->subDay();- $end->endOfDay();$currency = $this->accountRepos->getAccountCurrency($account) ?? $this->defaultCurrency;$startBalance = Steam::finalAccountBalance($account, $startDate)['balance'];diff --git a/app/Http/Controllers/ReportController.php b/app/Http/Controllers/ReportController.phpindex d153861248..dccca78354 100644--- a/app/Http/Controllers/ReportController.php+++ b/app/Http/Controllers/ReportController.php@@ -83,6 +83,8 @@ class ReportController extends Controllerreturn view('error')->with('message', (string) trans('firefly.end_after_start_date'));}$this->repository->cleanupBudgets();+ $start->startOfDay();+ $end->endOfDay();app('view')->share('subTitle',@@ -114,6 +116,8 @@ class ReportController extends Controllerreturn view('error')->with('message', (string) trans('firefly.end_after_start_date'));}$this->repository->cleanupBudgets();+ $start->startOfDay();+ $end->endOfDay();app('view')->share('subTitle',@@ -146,6 +150,8 @@ class ReportController extends Controllerreturn view('error')->with('message', (string) trans('firefly.end_after_start_date'));}$this->repository->cleanupBudgets();+ $start->startOfDay();+ $end->endOfDay();app('view')->share('subTitle',@@ -179,6 +185,8 @@ class ReportController extends Controller}$this->repository->cleanupBudgets();+ $start->startOfDay();+ $end->endOfDay();app('view')->share('subTitle',@@ -211,6 +219,8 @@ class ReportController extends Controller}$this->repository->cleanupBudgets();+ $start->startOfDay();+ $end->endOfDay();app('view')->share('subTitle',@@ -367,6 +377,8 @@ class ReportController extends Controllerreturn view('error')->with('message', (string) trans('firefly.end_after_start_date'));}$this->repository->cleanupBudgets();+ $start->startOfDay();+ $end->endOfDay();app('view')->share('subTitle',