This commit is contained in:
James Cole 2022-12-26 06:17:22 +01:00
parent a4f3be5397
commit bdf7d3978f
No known key found for this signature in database
GPG Key ID: B49A324B7EAD6D80

View File

@ -88,13 +88,13 @@ class UpdatePiggybank implements ActionInterface
if ((int)$source->account_id === (int)$piggyBank->account_id) { if ((int)$source->account_id === (int)$piggyBank->account_id) {
Log::debug('Piggy bank account is linked to source, so remove amount from piggy bank.'); Log::debug('Piggy bank account is linked to source, so remove amount from piggy bank.');
$this->removeAmount($journal, $piggyBank, $destination->amount); $this->removeAmount($piggyBank, $journalObj, $destination->amount);
return true; return true;
} }
if ((int)$destination->account_id === (int)$piggyBank->account_id) { if ((int)$destination->account_id === (int)$piggyBank->account_id) {
Log::debug('Piggy bank account is linked to source, so add amount to piggy bank.'); Log::debug('Piggy bank account is linked to source, so add amount to piggy bank.');
$this->addAmount($journal, $piggyBank, $destination->amount); $this->addAmount($piggyBank, $journalObj, $destination->amount);
return true; return true;
} }
@ -106,7 +106,7 @@ class UpdatePiggybank implements ActionInterface
) )
); );
return true; return false;
} }
/** /**
@ -140,14 +140,14 @@ class UpdatePiggybank implements ActionInterface
// if amount is zero, stop. // if amount is zero, stop.
if (0 === bccomp('0', $amount)) { if (0 === bccomp('0', $amount)) {
Log::warning('Amount left is zero, stop.'); app('log')->warning('Amount left is zero, stop.');
return; return;
} }
// make sure we can remove amount: // make sure we can remove amount:
if (false === $repository->canRemoveAmount($piggyBank, $amount)) { if (false === $repository->canRemoveAmount($piggyBank, $amount)) {
Log::warning(sprintf('Cannot remove %s from piggy bank.', $amount)); app('log')->warning(sprintf('Cannot remove %s from piggy bank.', $amount));
return; return;
} }
@ -177,14 +177,14 @@ class UpdatePiggybank implements ActionInterface
// if amount is zero, stop. // if amount is zero, stop.
if (0 === bccomp('0', $amount)) { if (0 === bccomp('0', $amount)) {
Log::warning('Amount left is zero, stop.'); app('log')->warning('Amount left is zero, stop.');
return; return;
} }
// make sure we can add amount: // make sure we can add amount:
if (false === $repository->canAddAmount($piggyBank, $amount)) { if (false === $repository->canAddAmount($piggyBank, $amount)) {
Log::warning(sprintf('Cannot add %s to piggy bank.', $amount)); app('log')->warning(sprintf('Cannot add %s to piggy bank.', $amount));
return; return;
} }