mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Fix #3321
This commit is contained in:
parent
9d9053d828
commit
c561f99de6
@ -142,6 +142,9 @@ trait ModifiesPiggyBanks
|
||||
*/
|
||||
public function createEvent(PiggyBank $piggyBank, string $amount): PiggyBankEvent
|
||||
{
|
||||
if (0 === bccomp('0', $amount)) {
|
||||
return new PiggyBankEvent;
|
||||
}
|
||||
/** @var PiggyBankEvent $event */
|
||||
$event = PiggyBankEvent::create(['date' => Carbon::now(), 'amount' => $amount, 'piggy_bank_id' => $piggyBank->id]);
|
||||
|
||||
@ -219,11 +222,12 @@ trait ModifiesPiggyBanks
|
||||
if (1 === bccomp($amount, $max)) {
|
||||
$amount = $max;
|
||||
}
|
||||
$difference = bcsub($amount, $repetition->currentamount);
|
||||
$repetition->currentamount = $amount;
|
||||
$repetition->save();
|
||||
|
||||
// create event
|
||||
$this->createEvent($piggyBank, $amount);
|
||||
$this->createEvent($piggyBank, $difference);
|
||||
|
||||
return $piggyBank;
|
||||
}
|
||||
@ -343,4 +347,4 @@ trait ModifiesPiggyBanks
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user