mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
This fixes #629
This commit is contained in:
parent
852ce3e32f
commit
6cafb91680
@ -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)])));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user