mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-29 18:20:01 +00:00
Fix #251
This commit is contained in:
@@ -175,6 +175,7 @@ class PiggyBankController extends Controller
|
|||||||
$piggyBank->savedSoFar = round($piggyBank->currentRelevantRep()->currentamount, 2);
|
$piggyBank->savedSoFar = round($piggyBank->currentRelevantRep()->currentamount, 2);
|
||||||
$piggyBank->percentage = $piggyBank->savedSoFar != 0 ? intval($piggyBank->savedSoFar / $piggyBank->targetamount * 100) : 0;
|
$piggyBank->percentage = $piggyBank->savedSoFar != 0 ? intval($piggyBank->savedSoFar / $piggyBank->targetamount * 100) : 0;
|
||||||
$piggyBank->leftToSave = bcsub($piggyBank->targetamount, $piggyBank->savedSoFar);
|
$piggyBank->leftToSave = bcsub($piggyBank->targetamount, $piggyBank->savedSoFar);
|
||||||
|
$piggyBank->percentage = $piggyBank->percentage > 100 ? 100 : $piggyBank->percentage;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Fill account information:
|
* Fill account information:
|
||||||
|
@@ -169,6 +169,14 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
|
|||||||
|
|
||||||
$piggyBank->save();
|
$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;
|
return $piggyBank;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user