From ae1245abec17d688178fa2c84f2e4ad602f5cd08 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 1 Mar 2015 19:31:00 +0100 Subject: [PATCH] Fixed update transactions. --- app/Repositories/Journal/JournalRepository.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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(); } }