mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-18 18:44:16 +00:00
Small fix for opening balance issues in reports.
This commit is contained in:
@@ -126,13 +126,15 @@ class AccountTasker implements AccountTaskerInterface
|
||||
];
|
||||
|
||||
// get first journal date:
|
||||
$first = $repository->oldestJournal($account);
|
||||
$first = $repository->oldestJournal($account);
|
||||
Log::debug(sprintf('Date of first journal for %s is %s', $account->name, $first->date->format('Y-m-d')));
|
||||
$entry['start_balance'] = $startSet[$account->id] ?? '0';
|
||||
$entry['end_balance'] = $endSet[$account->id] ?? '0';
|
||||
if (!is_null($first->id) && $yesterday < $first->date && $end >= $first->date) {
|
||||
// something about balance?
|
||||
|
||||
// first journal exists, and is on start, then this is the actual opening balance:
|
||||
if (!is_null($first->id) && $first->date->isSameDay($start)) {
|
||||
$entry['start_balance'] = $first->transactions()->where('account_id', $account->id)->first()->amount;
|
||||
Log::debug(sprintf('Account was opened before %s, so opening balance is %f', $yesterday->format('Y-m-d'), $entry['start_balance']));
|
||||
Log::debug(sprintf('Account %s was opened on %s, so opening balance is %f', $account->name, $start->format('Y-m-d'), $entry['start_balance']));
|
||||
}
|
||||
$return['start'] = bcadd($return['start'], $entry['start_balance']);
|
||||
$return['end'] = bcadd($return['end'], $entry['end_balance']);
|
||||
|
Reference in New Issue
Block a user