mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-29 18:20:01 +00:00
This fixes #629
This commit is contained in:
@@ -9,7 +9,8 @@
|
|||||||
* See the LICENSE file for details.
|
* See the LICENSE file for details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types = 1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace FireflyIII\Http\Controllers;
|
namespace FireflyIII\Http\Controllers;
|
||||||
|
|
||||||
use Amount;
|
use Amount;
|
||||||
@@ -220,7 +221,9 @@ class PiggyBankController extends Controller
|
|||||||
* Fill account information:
|
* Fill account information:
|
||||||
*/
|
*/
|
||||||
$account = $piggyBank->account;
|
$account = $piggyBank->account;
|
||||||
|
$new = false;
|
||||||
if (!isset($accounts[$account->id])) {
|
if (!isset($accounts[$account->id])) {
|
||||||
|
$new = true;
|
||||||
$accounts[$account->id] = [
|
$accounts[$account->id] = [
|
||||||
'name' => $account->name,
|
'name' => $account->name,
|
||||||
'balance' => Steam::balanceIgnoreVirtual($account, $end),
|
'balance' => Steam::balanceIgnoreVirtual($account, $end),
|
||||||
@@ -230,7 +233,7 @@ class PiggyBankController extends Controller
|
|||||||
'leftToSave' => $piggyBank->leftToSave,
|
'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]['sumOfSaved'] = bcadd($accounts[$account->id]['sumOfSaved'], strval($piggyBank->savedSoFar));
|
||||||
$accounts[$account->id]['sumOfTargets'] = bcadd($accounts[$account->id]['sumOfTargets'], $piggyBank->targetamount);
|
$accounts[$account->id]['sumOfTargets'] = bcadd($accounts[$account->id]['sumOfTargets'], $piggyBank->targetamount);
|
||||||
$accounts[$account->id]['leftToSave'] = bcadd($accounts[$account->id]['leftToSave'], $piggyBank->leftToSave);
|
$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'));
|
return redirect(route('piggy-banks.index'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$amount = strval(round($request->get('amount'), 12));
|
||||||
$amount = strval(round($request->get('amount'), 12));
|
|
||||||
$savedSoFar = $piggyBank->currentRelevantRep()->currentamount;
|
|
||||||
|
|
||||||
if (bccomp($amount, $savedSoFar) <= 0) {
|
|
||||||
}
|
|
||||||
|
|
||||||
Session::flash('error', strval(trans('firefly.cannot_remove_from_piggy', ['amount' => Amount::format($amount, false), 'name' => e($piggyBank->name)])));
|
Session::flash('error', strval(trans('firefly.cannot_remove_from_piggy', ['amount' => Amount::format($amount, false), 'name' => e($piggyBank->name)])));
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user