mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-01-06 22:21:42 +00:00
Fixed some issues with the monthly report and missing amounts.
This commit is contained in:
@@ -283,6 +283,29 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
return $last;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the date of the very first transaction in this account.
|
||||
*
|
||||
* @param Account $account
|
||||
*
|
||||
* @return TransactionJournal
|
||||
*/
|
||||
public function oldestJournal(Account $account): TransactionJournal
|
||||
{
|
||||
$first = $account->transactions()
|
||||
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
||||
->orderBy('transaction_journals.date', 'ASC')
|
||||
->orderBy('transaction_journals.order', 'DESC')
|
||||
->where('transaction_journals.user_id', $this->user->id)
|
||||
->orderBy('transaction_journals.id', 'ASC')
|
||||
->first(['transaction_journals.id']);
|
||||
if (!is_null($first)) {
|
||||
return TransactionJournal::find(intval($first->id));
|
||||
}
|
||||
|
||||
return new TransactionJournal();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the date of the very first transaction in this account.
|
||||
*
|
||||
@@ -292,18 +315,12 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
*/
|
||||
public function oldestJournalDate(Account $account): Carbon
|
||||
{
|
||||
$first = new Carbon;
|
||||
$date = $account->transactions()
|
||||
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
||||
->orderBy('transaction_journals.date', 'ASC')
|
||||
->orderBy('transaction_journals.order', 'DESC')
|
||||
->orderBy('transaction_journals.id', 'ASC')
|
||||
->first(['transaction_journals.date']);
|
||||
if (!is_null($date)) {
|
||||
$first = new Carbon($date->date);
|
||||
$journal = $this->oldestJournal($account);
|
||||
if (is_null($journal->id)) {
|
||||
return new Carbon;
|
||||
}
|
||||
|
||||
return $first;
|
||||
return $journal->date;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user