mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-11-26 02:40:43 -06:00
Fix #251
This commit is contained in:
parent
0ef5eeeb55
commit
3972882a33
@ -175,6 +175,7 @@ class PiggyBankController extends Controller
|
||||
$piggyBank->savedSoFar = round($piggyBank->currentRelevantRep()->currentamount, 2);
|
||||
$piggyBank->percentage = $piggyBank->savedSoFar != 0 ? intval($piggyBank->savedSoFar / $piggyBank->targetamount * 100) : 0;
|
||||
$piggyBank->leftToSave = bcsub($piggyBank->targetamount, $piggyBank->savedSoFar);
|
||||
$piggyBank->percentage = $piggyBank->percentage > 100 ? 100 : $piggyBank->percentage;
|
||||
|
||||
/*
|
||||
* Fill account information:
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user