This commit is contained in:
James Cole 2017-04-08 19:05:37 +02:00
parent 852ce3e32f
commit 6cafb91680
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E

View File

@ -9,7 +9,8 @@
* See the LICENSE file for details.
*/
declare(strict_types = 1);
declare(strict_types=1);
namespace FireflyIII\Http\Controllers;
use Amount;
@ -220,7 +221,9 @@ class PiggyBankController extends Controller
* Fill account information:
*/
$account = $piggyBank->account;
$new = false;
if (!isset($accounts[$account->id])) {
$new = true;
$accounts[$account->id] = [
'name' => $account->name,
'balance' => Steam::balanceIgnoreVirtual($account, $end),
@ -230,7 +233,7 @@ class PiggyBankController extends Controller
'leftToSave' => $piggyBank->leftToSave,
];
}
if (isset($accounts[$account->id])) {
if (isset($accounts[$account->id]) && $new === false) {
$accounts[$account->id]['sumOfSaved'] = bcadd($accounts[$account->id]['sumOfSaved'], strval($piggyBank->savedSoFar));
$accounts[$account->id]['sumOfTargets'] = bcadd($accounts[$account->id]['sumOfTargets'], $piggyBank->targetamount);
$accounts[$account->id]['leftToSave'] = bcadd($accounts[$account->id]['leftToSave'], $piggyBank->leftToSave);
@ -308,12 +311,7 @@ class PiggyBankController extends Controller
return redirect(route('piggy-banks.index'));
}
$amount = strval(round($request->get('amount'), 12));
$savedSoFar = $piggyBank->currentRelevantRep()->currentamount;
if (bccomp($amount, $savedSoFar) <= 0) {
}
$amount = strval(round($request->get('amount'), 12));
Session::flash('error', strval(trans('firefly.cannot_remove_from_piggy', ['amount' => Amount::format($amount, false), 'name' => e($piggyBank->name)])));