diff --git a/app/Handlers/Events/ConnectJournalToPiggyBank.php b/app/Handlers/Events/ConnectJournalToPiggyBank.php index 83089674cc..2dfb333629 100644 --- a/app/Handlers/Events/ConnectJournalToPiggyBank.php +++ b/app/Handlers/Events/ConnectJournalToPiggyBank.php @@ -44,7 +44,8 @@ class ConnectJournalToPiggyBank $amount = TransactionJournal::amountPositive($journal); // if piggy account matches source account, the amount is positive - if ($piggyBank->account_id == TransactionJournal::sourceAccount($journal)->id) { + $sources = TransactionJournal::sourceAccountList($journal)->pluck('id')->toArray(); + if (in_array($piggyBank->account_id, $sources)) { $amount = bcmul($amount, '-1'); } diff --git a/app/Support/Models/TransactionJournalSupport.php b/app/Support/Models/TransactionJournalSupport.php index ec7aac7dc1..1f4d3c7d90 100644 --- a/app/Support/Models/TransactionJournalSupport.php +++ b/app/Support/Models/TransactionJournalSupport.php @@ -131,33 +131,6 @@ class TransactionJournalSupport extends Model } - /** - * @deprecated - * - * @param TransactionJournal $journal - * - * @return Account - */ - public static function destinationAccount(TransactionJournal $journal): Account - { - $cache = new CacheProperties; - $cache->addProperty($journal->id); - $cache->addProperty('transaction-journal'); - $cache->addProperty('destination-account'); - if ($cache->has()) { - return $cache->get(); - } - $transaction = $journal->transactions()->where('amount', '>', 0)->first(); - if (!is_null($transaction)) { - $account = $transaction->account; - $cache->store($account); - } else { - $account = new Account; - } - - return $account; - } - /** * @param TransactionJournal $journal * @@ -183,31 +156,6 @@ class TransactionJournalSupport extends Model return $list; } - /** - * @deprecated - * - * @param TransactionJournal $journal - * - * @return string - */ - public static function destinationAccountTypeStr(TransactionJournal $journal): string - { - $cache = new CacheProperties; - $cache->addProperty($journal->id); - $cache->addProperty('transaction-journal'); - $cache->addProperty('destination-account-type-str'); - if ($cache->has()) { - return $cache->get(); - } - - - $account = self::destinationAccount($journal); - $type = $account->accountType ? $account->accountType->type : '(unknown)'; - $cache->store($type); - - return $type; - } - /** * @param TransactionJournal $journal * @@ -275,33 +223,6 @@ class TransactionJournalSupport extends Model ]; } - /** - * @deprecated - * - * @param TransactionJournal $journal - * - * @return Account - */ - public static function sourceAccount(TransactionJournal $journal): Account - { - $cache = new CacheProperties; - $cache->addProperty($journal->id); - $cache->addProperty('transaction-journal'); - $cache->addProperty('source-account'); - if ($cache->has()) { - return $cache->get(); - } - $transaction = $journal->transactions()->where('amount', '<', 0)->first(); - if (!is_null($transaction)) { - $account = $transaction->account; - $cache->store($account); - } else { - $account = new Account; - } - - return $account; - } - /** * @param TransactionJournal $journal * @@ -327,30 +248,6 @@ class TransactionJournalSupport extends Model return $list; } - /** - * @deprecated - * - * @param TransactionJournal $journal - * - * @return string - */ - public static function sourceAccountTypeStr(TransactionJournal $journal): string - { - $cache = new CacheProperties; - $cache->addProperty($journal->id); - $cache->addProperty('transaction-journal'); - $cache->addProperty('source-account-type-str'); - if ($cache->has()) { - return $cache->get(); - } - - $account = self::sourceAccount($journal); - $type = $account->accountType ? $account->accountType->type : '(unknown)'; - $cache->store($type); - - return $type; - } - /** * @param TransactionJournal $journal *