Removed some foreach() routines that are no longer necessary now that getAmountAttribute() exists.

This commit is contained in:
James Cole
2015-04-09 20:58:57 +02:00
parent 5124ce0302
commit 587b94153d
4 changed files with 4 additions and 38 deletions

View File

@@ -51,14 +51,7 @@ class ConnectJournalToPiggyBank
return;
}
Log::debug('Found a piggy bank');
$amount = 0;
/** @var Transaction $transaction */
foreach ($journal->transactions()->get() as $transaction) {
if ($transaction->account_id === $piggyBank->account_id) {
// this transaction is the relevant one.
$amount = floatval($transaction->amount);
}
}
$amount = $journal->amount;
Log::debug('Amount: ' . $amount);
if ($amount == 0) {
return;

View File

@@ -45,17 +45,8 @@ class UpdateJournalConnection
if (is_null($repetition)) {
return;
}
$amount = 0;
/** @var Transaction $transaction */
foreach ($journal->transactions()->get() as $transaction) {
if ($transaction->account_id === $piggyBank->account_id) {
// this transaction is the relevant one.
$amount = floatval($transaction->amount);
}
}
// update current repetition:
$diff = $amount - $event->amount;
$amount = $journal->amount;
$diff = $amount - $event->amount;// update current repetition
$repetition->currentamount += $diff;
$repetition->save();