Fixed a bug where the associated total amount for a bar would be too high.

This commit is contained in:
James Cole 2014-11-24 18:08:20 +01:00
parent 743deb4227
commit fd6e7fc1ab

View File

@ -95,9 +95,12 @@ class RepeatedExpense implements CUD, CommonDatabaseCalls, PiggybankInterface
$amountPerBar = floatval($piggyBank->targetamount) / $parts; $amountPerBar = floatval($piggyBank->targetamount) / $parts;
$cumulative = $amountPerBar; $cumulative = $amountPerBar;
/** @var PiggybankPart $bar */ /** @var PiggybankPart $bar */
foreach ($bars as $bar) { foreach ($bars as $index => $bar) {
$bar->setAmountPerBar($amountPerBar); $bar->setAmountPerBar($amountPerBar);
$bar->setCumulativeAmount($cumulative); $bar->setCumulativeAmount($cumulative);
if($parts -1 == $index) {
$bar->setCumulativeAmount($piggyBank->targetamount);
}
$reminder = $piggyBank->reminders() $reminder = $piggyBank->reminders()
->where('startdate', $bar->getStartdate()->format('Y-m-d')) ->where('startdate', $bar->getStartdate()->format('Y-m-d'))