mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-15 16:57:09 +00:00
Add some slack notifications and a todo to fix the rest
This commit is contained in:
@@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\TransactionRules\Actions;
|
||||
|
||||
use DB;
|
||||
use FireflyIII\Events\Model\Rule\RuleActionFailedOnArray;
|
||||
use FireflyIII\Events\TriggeredAuditLog;
|
||||
use FireflyIII\Factory\TagFactory;
|
||||
use FireflyIII\Models\RuleAction;
|
||||
@@ -61,7 +62,7 @@ class AddTag implements ActionInterface
|
||||
|
||||
if (null === $tag) {
|
||||
// could not find, could not create tag.
|
||||
Log::error(sprintf('RuleAction AddTag. Could not find or create tag "%s"', $this->action->action_value));
|
||||
event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.find_or_create_tag_failed', ['tag' => $this->action->action_value])));
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -78,12 +79,12 @@ class AddTag implements ActionInterface
|
||||
|
||||
// event for audit log entry
|
||||
event(new TriggeredAuditLog($this->action->rule, $object, 'add_tag', null, $tag->tag));
|
||||
|
||||
return true;
|
||||
}
|
||||
Log::debug(
|
||||
sprintf('RuleAction AddTag fired but tag %d ("%s") was already added to journal %d.', $tag->id, $tag->tag, $journal['transaction_journal_id'])
|
||||
);
|
||||
event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.tag_already_added', ['tag' => $this->action->action_value])));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\TransactionRules\Actions;
|
||||
|
||||
use FireflyIII\Events\Model\Rule\RuleActionFailedOnArray;
|
||||
use FireflyIII\Events\TriggeredAuditLog;
|
||||
use FireflyIII\Models\Note;
|
||||
use FireflyIII\Models\RuleAction;
|
||||
@@ -56,6 +57,7 @@ class AppendDescriptionToNotes implements ActionInterface
|
||||
$object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);
|
||||
if (null === $object) {
|
||||
Log::error(sprintf('No journal #%d belongs to user #%d.', $journal['transaction_journal_id'], $journal['user_id']));
|
||||
event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.journal_other_user')));
|
||||
return false;
|
||||
}
|
||||
$note = $object->notes()->first();
|
||||
|
@@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\TransactionRules\Actions;
|
||||
|
||||
use FireflyIII\Events\Model\Rule\RuleActionFailedOnArray;
|
||||
use FireflyIII\Events\TriggeredAuditLog;
|
||||
use FireflyIII\Models\Note;
|
||||
use FireflyIII\Models\RuleAction;
|
||||
@@ -60,6 +61,7 @@ class AppendNotesToDescription implements ActionInterface
|
||||
$object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);
|
||||
if (null === $object) {
|
||||
Log::error(sprintf('No journal #%d belongs to user #%d.', $journal['transaction_journal_id'], $journal['user_id']));
|
||||
event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.journal_other_user')));
|
||||
return false;
|
||||
}
|
||||
$note = $object->notes()->first();
|
||||
@@ -80,6 +82,7 @@ class AppendNotesToDescription implements ActionInterface
|
||||
|
||||
return true;
|
||||
}
|
||||
// TODO introduce error
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\TransactionRules\Actions;
|
||||
|
||||
use DB;
|
||||
use FireflyIII\Events\Model\Rule\RuleActionFailedOnArray;
|
||||
use FireflyIII\Events\TriggeredAuditLog;
|
||||
use FireflyIII\Models\RuleAction;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
@@ -56,6 +57,7 @@ class ClearBudget implements ActionInterface
|
||||
$budget = $object->budgets()->first();
|
||||
if (null === $budget) {
|
||||
Log::debug(sprintf('RuleAction ClearBudget, no budget in journal #%d.', $journal['transaction_journal_id']));
|
||||
event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.journal_already_no_budget')));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\TransactionRules\Actions;
|
||||
|
||||
use DB;
|
||||
use FireflyIII\Events\Model\Rule\RuleActionFailedOnArray;
|
||||
use FireflyIII\Events\TriggeredAuditLog;
|
||||
use FireflyIII\Models\RuleAction;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
@@ -56,6 +57,7 @@ class ClearCategory implements ActionInterface
|
||||
$category = $object->categories()->first();
|
||||
if (null === $category) {
|
||||
Log::debug(sprintf('RuleAction ClearCategory, no category in journal #%d.', $journal['transaction_journal_id']));
|
||||
event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.journal_already_no_category')));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\TransactionRules\Actions;
|
||||
|
||||
use DB;
|
||||
use FireflyIII\Events\Model\Rule\RuleActionFailedOnArray;
|
||||
use FireflyIII\Events\TriggeredAuditLog;
|
||||
use FireflyIII\Models\RuleAction;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
@@ -55,6 +56,7 @@ class ClearNotes implements ActionInterface
|
||||
$notes = $object->notes()->first();
|
||||
if (null === $notes) {
|
||||
Log::debug(sprintf('RuleAction ClearNotes, journal #%d has no notes.', $journal['transaction_journal_id']));
|
||||
event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.journal_already_no_notes')));
|
||||
return false;
|
||||
}
|
||||
$before = $notes->text;
|
||||
|
@@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\TransactionRules\Actions;
|
||||
|
||||
use DB;
|
||||
use FireflyIII\Events\Model\Rule\RuleActionFailedOnArray;
|
||||
use FireflyIII\Events\TriggeredAuditLog;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Factory\AccountFactory;
|
||||
@@ -65,11 +66,13 @@ class ConvertToDeposit implements ActionInterface
|
||||
$object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);
|
||||
if (null === $object) {
|
||||
Log::error(sprintf('Cannot find journal #%d, cannot convert to deposit.', $journal['transaction_journal_id']));
|
||||
event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.journal_not_found')));
|
||||
return false;
|
||||
}
|
||||
$groupCount = TransactionJournal::where('transaction_group_id', $journal['transaction_group_id'])->count();
|
||||
if ($groupCount > 1) {
|
||||
Log::error(sprintf('Group #%d has more than one transaction in it, cannot convert to deposit.', $journal['transaction_group_id']));
|
||||
event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.split_group')));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -77,7 +80,7 @@ class ConvertToDeposit implements ActionInterface
|
||||
$type = $object->transactionType->type;
|
||||
if (TransactionType::DEPOSIT === $type) {
|
||||
Log::error(sprintf('Journal #%d is already a deposit (rule #%d).', $journal['transaction_journal_id'], $this->action->rule_id));
|
||||
|
||||
event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.is_already_deposit')));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -89,6 +92,7 @@ class ConvertToDeposit implements ActionInterface
|
||||
} catch (JsonException | FireflyException $e) {
|
||||
Log::debug('Could not convert withdrawal to deposit.');
|
||||
Log::error($e->getMessage());
|
||||
event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.complex_error')));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -104,13 +108,14 @@ class ConvertToDeposit implements ActionInterface
|
||||
} catch (JsonException | FireflyException $e) {
|
||||
Log::debug('Could not convert transfer to deposit.');
|
||||
Log::error($e->getMessage());
|
||||
event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.complex_error')));
|
||||
return false;
|
||||
}
|
||||
event(new TriggeredAuditLog($this->action->rule, $object, 'update_transaction_type', TransactionType::TRANSFER, TransactionType::DEPOSIT));
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
// TODO introduce error
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\TransactionRules\Actions;
|
||||
|
||||
use DB;
|
||||
use FireflyIII\Events\Model\Rule\RuleActionFailedOnArray;
|
||||
use FireflyIII\Events\TriggeredAuditLog;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\Account;
|
||||
@@ -62,11 +63,13 @@ class ConvertToTransfer implements ActionInterface
|
||||
$object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);
|
||||
if (null === $object) {
|
||||
Log::error(sprintf('Cannot find journal #%d, cannot convert to transfer.', $journal['transaction_journal_id']));
|
||||
event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.journal_not_found')));
|
||||
return false;
|
||||
}
|
||||
$groupCount = TransactionJournal::where('transaction_group_id', $journal['transaction_group_id'])->count();
|
||||
if ($groupCount > 1) {
|
||||
Log::error(sprintf('Group #%d has more than one transaction in it, cannot convert to transfer.', $journal['transaction_group_id']));
|
||||
event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.split_group')));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -77,6 +80,7 @@ class ConvertToTransfer implements ActionInterface
|
||||
Log::error(
|
||||
sprintf('Journal #%d is already a transfer so cannot be converted (rule #%d).', $object->id, $this->action->rule_id)
|
||||
);
|
||||
event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.is_already_transfer')));
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -107,6 +111,7 @@ class ConvertToTransfer implements ActionInterface
|
||||
$this->action->rule_id
|
||||
)
|
||||
);
|
||||
event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.no_valid_opposing', ['name' => $this->action->action_value])));
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -118,6 +123,7 @@ class ConvertToTransfer implements ActionInterface
|
||||
} catch (FireflyException $e) {
|
||||
Log::debug('Could not convert withdrawal to transfer.');
|
||||
Log::error($e->getMessage());
|
||||
event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.complex_error')));
|
||||
return false;
|
||||
}
|
||||
event(new TriggeredAuditLog($this->action->rule, $object, 'update_transaction_type', TransactionType::WITHDRAWAL, TransactionType::TRANSFER));
|
||||
@@ -130,12 +136,13 @@ class ConvertToTransfer implements ActionInterface
|
||||
} catch (FireflyException $e) {
|
||||
Log::debug('Could not convert deposit to transfer.');
|
||||
Log::error($e->getMessage());
|
||||
event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.complex_error')));
|
||||
return false;
|
||||
}
|
||||
event(new TriggeredAuditLog($this->action->rule, $object, 'update_transaction_type', TransactionType::DEPOSIT, TransactionType::TRANSFER));
|
||||
return $res;
|
||||
}
|
||||
|
||||
// TODO introduce error
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -166,6 +173,7 @@ class ConvertToTransfer implements ActionInterface
|
||||
$journal = TransactionJournal::find($journalId);
|
||||
if (null === $journal) {
|
||||
Log::error(sprintf('Journal #%d does not exist. Cannot convert to transfer.', $journalId));
|
||||
// TODO introduce error
|
||||
return '';
|
||||
}
|
||||
return (string)$journal->transactions()->where('amount', '>', 0)->first()?->account?->accountType?->type;
|
||||
@@ -192,6 +200,7 @@ class ConvertToTransfer implements ActionInterface
|
||||
[$journal->id, $opposing->name, $this->action->rule_id]
|
||||
)
|
||||
);
|
||||
// TODO introduce error
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -250,6 +259,7 @@ class ConvertToTransfer implements ActionInterface
|
||||
[$journal->id, $opposing->name, $this->action->rule_id]
|
||||
)
|
||||
);
|
||||
// TODO introduce error
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@@ -65,18 +65,20 @@ class ConvertToWithdrawal implements ActionInterface
|
||||
$object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);
|
||||
if (null === $object) {
|
||||
Log::error(sprintf('Cannot find journal #%d, cannot convert to withdrawal.', $journal['transaction_journal_id']));
|
||||
// TODO introduce error
|
||||
return false;
|
||||
}
|
||||
$groupCount = TransactionJournal::where('transaction_group_id', $journal['transaction_group_id'])->count();
|
||||
if ($groupCount > 1) {
|
||||
Log::error(sprintf('Group #%d has more than one transaction in it, cannot convert to withdrawal.', $journal['transaction_group_id']));
|
||||
// TODO introduce error
|
||||
return false;
|
||||
}
|
||||
|
||||
$type = $object->transactionType->type;
|
||||
if (TransactionType::WITHDRAWAL === $type) {
|
||||
Log::error(sprintf('Journal #%d is already a withdrawal (rule #%d).', $journal['transaction_journal_id'], $this->action->rule_id));
|
||||
|
||||
// TODO introduce error
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -87,6 +89,7 @@ class ConvertToWithdrawal implements ActionInterface
|
||||
} catch (JsonException | FireflyException $e) {
|
||||
Log::debug('Could not convert transfer to deposit.');
|
||||
Log::error($e->getMessage());
|
||||
// TODO introduce error
|
||||
return false;
|
||||
}
|
||||
event(new TriggeredAuditLog($this->action->rule, $object, 'update_transaction_type', TransactionType::DEPOSIT, TransactionType::WITHDRAWAL));
|
||||
@@ -101,13 +104,14 @@ class ConvertToWithdrawal implements ActionInterface
|
||||
} catch (JsonException | FireflyException $e) {
|
||||
Log::debug('Could not convert transfer to deposit.');
|
||||
Log::error($e->getMessage());
|
||||
// TODO introduce error
|
||||
return false;
|
||||
}
|
||||
event(new TriggeredAuditLog($this->action->rule, $object, 'update_transaction_type', TransactionType::TRANSFER, TransactionType::WITHDRAWAL));
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
// TODO introduce error
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@@ -73,6 +73,7 @@ class LinkToBill implements ActionInterface
|
||||
$billName
|
||||
)
|
||||
);
|
||||
// TODO introduce error
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -97,7 +98,7 @@ class LinkToBill implements ActionInterface
|
||||
$billName
|
||||
)
|
||||
);
|
||||
|
||||
// TODO introduce error
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@@ -57,6 +57,7 @@ class MoveDescriptionToNotes implements ActionInterface
|
||||
$object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);
|
||||
if (null === $object) {
|
||||
Log::error(sprintf('No journal #%d belongs to user #%d.', $journal['transaction_journal_id'], $journal['user_id']));
|
||||
// TODO introduce error
|
||||
return false;
|
||||
}
|
||||
$note = $object->notes()->first();
|
||||
|
@@ -63,16 +63,19 @@ class MoveNotesToDescription implements ActionInterface
|
||||
$object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);
|
||||
if (null === $object) {
|
||||
Log::error(sprintf('No journal #%d belongs to user #%d.', $journal['transaction_journal_id'], $journal['user_id']));
|
||||
// TODO introduce error
|
||||
return false;
|
||||
}
|
||||
$note = $object->notes()->first();
|
||||
if (null === $note) {
|
||||
// nothing to move, return null
|
||||
// TODO introduce error
|
||||
return false;
|
||||
}
|
||||
if ('' === $note->text) {
|
||||
// nothing to move, return null
|
||||
$note->delete();
|
||||
// TODO introduce error
|
||||
return false;
|
||||
}
|
||||
$before = $object->description;
|
||||
|
@@ -55,6 +55,7 @@ class RemoveAllTags implements ActionInterface
|
||||
$count = DB::table('tag_transaction_journal')->where('transaction_journal_id', $journal['transaction_journal_id'])->count();
|
||||
if (0 === $count) {
|
||||
Log::debug(sprintf('RuleAction RemoveAllTags, journal #%d has no tags.', $journal['transaction_journal_id']));
|
||||
// TODO introduce error
|
||||
return false;
|
||||
}
|
||||
Log::debug(sprintf('RuleAction RemoveAllTags removed all tags from journal %d.', $journal['transaction_journal_id']));
|
||||
|
@@ -61,6 +61,7 @@ class RemoveTag implements ActionInterface
|
||||
Log::debug(
|
||||
sprintf('RuleAction RemoveTag tried to remove tag "%s" from journal #%d but no such tag exists.', $name, $journal['transaction_journal_id'])
|
||||
);
|
||||
// TODO introduce error
|
||||
return false;
|
||||
}
|
||||
$count = DB::table('tag_transaction_journal')->where('transaction_journal_id', $journal['transaction_journal_id'])->where('tag_id', $tag->id)->count();
|
||||
@@ -68,6 +69,7 @@ class RemoveTag implements ActionInterface
|
||||
Log::debug(
|
||||
sprintf('RuleAction RemoveTag tried to remove tag "%s" from journal #%d but no such tag is linked.', $name, $journal['transaction_journal_id'])
|
||||
);
|
||||
// TODO introduce error
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@@ -65,7 +65,7 @@ class SetBudget implements ActionInterface
|
||||
$search
|
||||
)
|
||||
);
|
||||
|
||||
// TODO introduce error
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ class SetBudget implements ActionInterface
|
||||
$journal['transaction_type_type']
|
||||
)
|
||||
);
|
||||
|
||||
// TODO introduce error
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@@ -57,7 +57,7 @@ class SetCategory implements ActionInterface
|
||||
$search = $this->action->action_value;
|
||||
if (null === $user) {
|
||||
Log::error(sprintf('Journal has no valid user ID so action SetCategory("%s") cannot be applied', $search), $journal);
|
||||
|
||||
// TODO introduce error
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ class SetCategory implements ActionInterface
|
||||
$search
|
||||
)
|
||||
);
|
||||
|
||||
// TODO introduce error
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@@ -65,7 +65,7 @@ class SetDestinationAccount implements ActionInterface
|
||||
|
||||
if (null === $object) {
|
||||
Log::error('Could not find journal.');
|
||||
|
||||
// TODO introduce error
|
||||
return false;
|
||||
}
|
||||
$type = $object->transactionType->type;
|
||||
@@ -81,7 +81,7 @@ class SetDestinationAccount implements ActionInterface
|
||||
$this->action->action_value
|
||||
)
|
||||
);
|
||||
|
||||
// TODO introduce error
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -90,13 +90,13 @@ class SetDestinationAccount implements ActionInterface
|
||||
$source = $object->transactions()->where('amount', '<', 0)->first();
|
||||
if (null === $source) {
|
||||
Log::error('Could not find source transaction.');
|
||||
|
||||
// TODO introduce error
|
||||
return false;
|
||||
}
|
||||
// account must not be deleted (in the meantime):
|
||||
if (null === $source->account) {
|
||||
Log::error('Could not find source transaction account.');
|
||||
|
||||
// TODO introduce error
|
||||
return false;
|
||||
}
|
||||
if (null !== $newAccount && (int)$newAccount->id === (int)$source->account_id) {
|
||||
@@ -107,7 +107,7 @@ class SetDestinationAccount implements ActionInterface
|
||||
$source->account_id
|
||||
)
|
||||
);
|
||||
|
||||
// TODO introduce error
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@@ -64,7 +64,7 @@ class SetSourceAccount implements ActionInterface
|
||||
$this->repository = app(AccountRepositoryInterface::class);
|
||||
if (null === $object) {
|
||||
Log::error('Could not find journal.');
|
||||
|
||||
// TODO introduce error
|
||||
return false;
|
||||
}
|
||||
$type = $object->transactionType->type;
|
||||
@@ -76,7 +76,7 @@ class SetSourceAccount implements ActionInterface
|
||||
Log::error(
|
||||
sprintf('Cant change source account of journal #%d because no asset account with name "%s" exists.', $object->id, $this->action->action_value)
|
||||
);
|
||||
|
||||
// TODO introduce error
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -85,13 +85,13 @@ class SetSourceAccount implements ActionInterface
|
||||
$destination = $object->transactions()->where('amount', '>', 0)->first();
|
||||
if (null === $destination) {
|
||||
Log::error('Could not find destination transaction.');
|
||||
|
||||
// TODO introduce error
|
||||
return false;
|
||||
}
|
||||
// account must not be deleted (in the meantime):
|
||||
if (null === $destination->account) {
|
||||
Log::error('Could not find destination transaction account.');
|
||||
|
||||
// TODO introduce error
|
||||
return false;
|
||||
}
|
||||
if (null !== $newAccount && (int)$newAccount->id === (int)$destination->account_id) {
|
||||
@@ -102,7 +102,7 @@ class SetSourceAccount implements ActionInterface
|
||||
$destination->account_id
|
||||
)
|
||||
);
|
||||
|
||||
// TODO introduce error
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@@ -59,18 +59,20 @@ class SwitchAccounts implements ActionInterface
|
||||
$object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);
|
||||
if (null === $object) {
|
||||
Log::error(sprintf('Cannot find journal #%d, cannot switch accounts.', $journal['transaction_journal_id']));
|
||||
// TODO introduce error
|
||||
return false;
|
||||
}
|
||||
$groupCount = TransactionJournal::where('transaction_group_id', $journal['transaction_group_id'])->count();
|
||||
if ($groupCount > 1) {
|
||||
Log::error(sprintf('Group #%d has more than one transaction in it, cannot switch accounts.', $journal['transaction_group_id']));
|
||||
// TODO introduce error
|
||||
return false;
|
||||
}
|
||||
|
||||
$type = $object->transactionType->type;
|
||||
if (TransactionType::TRANSFER !== $type) {
|
||||
Log::error(sprintf('Journal #%d is NOT a transfer (rule #%d), cannot switch accounts.', $journal['transaction_journal_id'], $this->action->rule_id));
|
||||
|
||||
// TODO introduce error
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -80,7 +82,7 @@ class SwitchAccounts implements ActionInterface
|
||||
$destTransaction = $object->transactions()->where('amount', '>', 0)->first();
|
||||
if (null === $sourceTransaction || null === $destTransaction) {
|
||||
Log::error(sprintf('Journal #%d has no source or destination transaction (rule #%d), cannot switch accounts.', $journal['transaction_journal_id'], $this->action->rule_id));
|
||||
|
||||
// TODO introduce error
|
||||
return false;
|
||||
}
|
||||
$sourceAccountId = (int)$sourceTransaction->account_id;
|
||||
|
@@ -70,7 +70,7 @@ class UpdatePiggybank implements ActionInterface
|
||||
Log::info(
|
||||
sprintf('No piggy bank named "%s", cant execute action #%d of rule #%d', $this->action->action_value, $this->action->id, $this->action->rule_id)
|
||||
);
|
||||
|
||||
// TODO introduce error
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ class UpdatePiggybank implements ActionInterface
|
||||
$destination->account_id
|
||||
)
|
||||
);
|
||||
|
||||
// TODO introduce error
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user