This commit is contained in:
James Cole
2016-04-21 11:03:04 +02:00
parent 0ef5eeeb55
commit 3972882a33
2 changed files with 9 additions and 0 deletions

View File

@@ -169,6 +169,14 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
$piggyBank->save();
// if the piggy bank is now smaller than the current relevant rep,
// remove money from the rep.
$repetition = $piggyBank->currentRelevantRep();
if ($repetition->currentamount > $piggyBank->targetamount) {
$repetition->currentamount = $piggyBank->targetamount;
$repetition->save();
}
return $piggyBank;
}
}