Fixed a bug where transfers away from a piggy bank's account would not properly reflect the piggy bank.

This commit is contained in:
James Cole 2015-04-24 12:06:13 +02:00
parent 59e23b89f2
commit 40d8e7d1ad

View File

@ -65,6 +65,22 @@ class ConnectJournalToPiggyBank
}
Log::debug('Found rep! ' . $repetition->id);
/*
* Add amount when
*/
/** @var Transaction $transaction */
foreach ($journal->transactions()->get() as $transaction) {
if ($transaction->account_id == $piggyBank->account_id) {
if ($transaction->amount < 0) {
$amount = $amount * -1;
Log::debug('Transaction is away from piggy, so amount becomes ' . $amount);
} else {
Log::debug('Transaction is to from piggy, so amount stays ' . $amount);
}
}
}
$repetition->currentamount += $amount;
$repetition->save();