Math fixes. Not bugs.

This commit is contained in:
James Cole 2015-07-06 18:06:31 +02:00
parent 93b6c68938
commit f38d38f139

View File

@ -259,12 +259,13 @@ class PiggyBankController extends Controller
public function postRemove(PiggyBankRepositoryInterface $repository, PiggyBank $piggyBank)
{
$amount = floatval(Input::get('amount'));
bcscale(2);
$savedSoFar = $piggyBank->currentRelevantRep()->currentamount;
if ($amount <= $savedSoFar) {
$repetition = $piggyBank->currentRelevantRep();
$repetition->currentamount -= $amount;
$repetition = $piggyBank->currentRelevantRep();
$repetition->currentamount = bcsub($repetition->currentamount, $amount);
$repetition->save();
// create event