diff --git a/app/Repositories/Journal/JournalRepository.php b/app/Repositories/Journal/JournalRepository.php index 1f9930519c..8bf49ad731 100644 --- a/app/Repositories/Journal/JournalRepository.php +++ b/app/Repositories/Journal/JournalRepository.php @@ -267,13 +267,15 @@ class JournalRepository implements JournalRepositoryInterface // update the from and to transaction. /** @var Transaction $transaction */ foreach ($journal->transactions()->get() as $transaction) { - if ($transaction->account_id === $from->id) { + if (floatval($transaction->amount) < 0) { // this is the from transaction, negative amount: - $transaction->amount = $data['amount'] * -1; + $transaction->amount = $data['amount'] * -1; + $transaction->account_id = $from->id; $transaction->save(); } - if ($transaction->account_id === $to->id) { + if (floatval($transaction->amount) > 0) { $transaction->amount = $data['amount']; + $transaction->account_id = $to->id; $transaction->save(); } }