mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-05-04 13:16:31 +00:00
Autoformat lol
This commit is contained in:
@@ -24,7 +24,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\TransactionRules\Actions;
|
||||
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use FireflyIII\Enums\TransactionTypeEnum;
|
||||
use FireflyIII\Events\Model\Rule\RuleActionFailedOnArray;
|
||||
use FireflyIII\Events\TriggeredAuditLog;
|
||||
@@ -34,6 +33,7 @@ use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Class SetSourceToCashAccount
|
||||
@@ -43,16 +43,18 @@ class SetSourceToCashAccount implements ActionInterface
|
||||
/**
|
||||
* TriggerInterface constructor.
|
||||
*/
|
||||
public function __construct(private readonly RuleAction $action) {}
|
||||
public function __construct(
|
||||
private readonly RuleAction $action
|
||||
) {}
|
||||
|
||||
public function actOnArray(array $journal): bool
|
||||
{
|
||||
/** @var User $user */
|
||||
$user = User::find($journal['user_id']);
|
||||
$user = User::find($journal['user_id']);
|
||||
|
||||
/** @var null|TransactionJournal $object */
|
||||
$object = $user->transactionJournals()->find((int) $journal['transaction_journal_id']);
|
||||
$repository = app(AccountRepositoryInterface::class);
|
||||
$object = $user->transactionJournals()->find((int) $journal['transaction_journal_id']);
|
||||
$repository = app(AccountRepositoryInterface::class);
|
||||
|
||||
if (null === $object) {
|
||||
Log::error('Could not find journal.');
|
||||
@@ -60,7 +62,7 @@ class SetSourceToCashAccount implements ActionInterface
|
||||
|
||||
return false;
|
||||
}
|
||||
$type = $object->transactionType->type;
|
||||
$type = $object->transactionType->type;
|
||||
if (TransactionTypeEnum::DEPOSIT->value !== $type) {
|
||||
Log::error('Transaction must be deposit.');
|
||||
event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.not_deposit')));
|
||||
@@ -89,13 +91,11 @@ class SetSourceToCashAccount implements ActionInterface
|
||||
return false;
|
||||
}
|
||||
if ($cashAccount->id === $destination->account_id) {
|
||||
Log::error(
|
||||
sprintf(
|
||||
'New source account ID #%d and current destination account ID #%d are the same. Do nothing.',
|
||||
$cashAccount->id,
|
||||
$destination->account_id
|
||||
)
|
||||
);
|
||||
Log::error(sprintf(
|
||||
'New source account ID #%d and current destination account ID #%d are the same. Do nothing.',
|
||||
$cashAccount->id,
|
||||
$destination->account_id
|
||||
));
|
||||
|
||||
event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.already_has_source', ['name' => $cashAccount->name])));
|
||||
|
||||
@@ -108,8 +108,7 @@ class SetSourceToCashAccount implements ActionInterface
|
||||
DB::table('transactions')
|
||||
->where('transaction_journal_id', '=', $object->id)
|
||||
->where('amount', '<', 0)
|
||||
->update(['account_id' => $cashAccount->id])
|
||||
;
|
||||
->update(['account_id' => $cashAccount->id]);
|
||||
|
||||
Log::debug(sprintf('Updated journal #%d (group #%d) and gave it new source account ID.', $object->id, $object->transaction_group_id));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user