Add some slack notifications and a todo to fix the rest

This commit is contained in:
James Cole
2023-08-12 20:57:51 +02:00
parent 53f1b0218c
commit 610bc108e7
26 changed files with 346 additions and 41 deletions

View File

@@ -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;