mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Multi account piggy banks.
This commit is contained in:
@@ -26,6 +26,7 @@ namespace FireflyIII\TransactionRules\Actions;
|
||||
|
||||
use FireflyIII\Events\Model\Rule\RuleActionFailedOnArray;
|
||||
use FireflyIII\Events\TriggeredAuditLog;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\PiggyBank;
|
||||
use FireflyIII\Models\RuleAction;
|
||||
use FireflyIII\Models\Transaction;
|
||||
@@ -81,6 +82,7 @@ class UpdatePiggybank implements ActionInterface
|
||||
|
||||
if ($source->account_id === $piggyBank->account_id) {
|
||||
app('log')->debug('Piggy bank account is linked to source, so remove amount from piggy bank.');
|
||||
throw new FireflyException('Reference the correct account here.');
|
||||
$this->removeAmount($piggyBank, $journal, $journalObj, $destination->amount);
|
||||
|
||||
event(
|
||||
@@ -161,6 +163,7 @@ class UpdatePiggybank implements ActionInterface
|
||||
}
|
||||
|
||||
// make sure we can remove amount:
|
||||
throw new FireflyException('Reference the correct account here.');
|
||||
if (false === $repository->canRemoveAmount($piggyBank, $amount)) {
|
||||
app('log')->warning(sprintf('Cannot remove %s from piggy bank.', $amount));
|
||||
event(new RuleActionFailedOnArray($this->action, $array, trans('rules.cannot_remove_from_piggy', ['amount' => $amount, 'name' => $piggyBank->name])));
|
||||
@@ -169,6 +172,7 @@ class UpdatePiggybank implements ActionInterface
|
||||
}
|
||||
app('log')->debug(sprintf('Will now remove %s from piggy bank.', $amount));
|
||||
|
||||
throw new FireflyException('Reference the correct account here.');
|
||||
$repository->removeAmount($piggyBank, $amount, $journal);
|
||||
}
|
||||
|
||||
@@ -199,6 +203,7 @@ class UpdatePiggybank implements ActionInterface
|
||||
}
|
||||
|
||||
// make sure we can add amount:
|
||||
throw new FireflyException('Reference the correct account here.');
|
||||
if (false === $repository->canAddAmount($piggyBank, $amount)) {
|
||||
app('log')->warning(sprintf('Cannot add %s to piggy bank.', $amount));
|
||||
event(new RuleActionFailedOnArray($this->action, $array, trans('rules.cannot_add_to_piggy', ['amount' => $amount, 'name' => $piggyBank->name])));
|
||||
|
Reference in New Issue
Block a user