mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-01-05 21:51:17 +00:00
First code for #2723
This commit is contained in:
@@ -23,6 +23,7 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Repositories\Journal;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\Note;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionGroup;
|
||||
@@ -377,4 +378,26 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getSourceAccount(TransactionJournal $journal): Account
|
||||
{
|
||||
/** @var Transaction $transaction */
|
||||
$transaction = $journal->transactions()->with('account')->where('amount', '<', 0)->first();
|
||||
|
||||
return $transaction->account;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getDestinationAccount(TransactionJournal $journal): Account
|
||||
{
|
||||
/** @var Transaction $transaction */
|
||||
$transaction = $journal->transactions()->with('account')->where('amount', '>', 0)->first();
|
||||
|
||||
return $transaction->account;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user