Skip to content

Firefly III: a personal finances manager

Another fix for #11054

James Cole55cf9247947b
diff --git a/app/Factory/TransactionJournalFactory.php b/app/Factory/TransactionJournalFactory.php
index f7dfa70f5c..ed9249f72b 100644
--- a/app/Factory/TransactionJournalFactory.php
+++ b/app/Factory/TransactionJournalFactory.php
@@ -221,8 +221,19 @@ class TransactionJournalFactory
];
Log::debug('Source info:', $sourceInfo);
Log::debug('Destination info:', $destInfo);
- $sourceAccount = $this->getAccount($type->type, 'source', $sourceInfo);
- $destinationAccount = $this->getAccount($type->type, 'destination', $destInfo, $sourceAccount);
+ $destinationAccount = null;
+ $sourceAccount = null;
+ if(TransactionTypeEnum::DEPOSIT->value === $type->type) {
+ Log::debug(sprintf('Transaction type is deposit, start with destination first.'));
+ $destinationAccount = $this->getAccount($type->type, 'destination', $destInfo);
+ $sourceAccount = $this->getAccount($type->type, 'source', $sourceInfo, $destinationAccount);
+ }
+ if(TransactionTypeEnum::DEPOSIT->value !== $type->type) {
+ Log::debug(sprintf('Transaction type is not deposit, start with source first.'));
+ $sourceAccount = $this->getAccount($type->type, 'source', $sourceInfo);
+ $destinationAccount = $this->getAccount($type->type, 'destination', $destInfo, $sourceAccount);
+ }
+
Log::debug('Done with getAccount(2x)');
// there is a safety catch here. If either account is NULL, they will be replaced with the cash account.