🤖 Auto commit for release 'develop' on 2026-01-23

This commit is contained in:
JC5
2026-01-23 15:14:29 +01:00
parent 8f15a32bd6
commit eeeba86d38
888 changed files with 10732 additions and 10387 deletions

View File

@@ -51,13 +51,13 @@ class SetSourceAccount implements ActionInterface
public function actOnArray(array $journal): bool
{
$accountName = $this->action->getValue($journal);
$accountName = $this->action->getValue($journal);
/** @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']);
$object = $user->transactionJournals()->find((int) $journal['transaction_journal_id']);
$this->repository = app(AccountRepositoryInterface::class);
if (null === $object) {
Log::error('Could not find journal.');
@@ -65,11 +65,11 @@ class SetSourceAccount implements ActionInterface
return false;
}
$type = $object->transactionType->type;
$type = $object->transactionType->type;
$this->repository->setUser($user);
// if this is a transfer or a withdrawal, the new source account must be an asset account or a default account, and it MUST exist:
$newAccount = $this->findAssetAccount($type, $accountName);
$newAccount = $this->findAssetAccount($type, $accountName);
if ((TransactionTypeEnum::WITHDRAWAL->value === $type || TransactionTypeEnum::TRANSFER->value === $type) && !$newAccount instanceof Account) {
Log::error(sprintf('Cant change source account of journal #%d because no asset account with name "%s" exists.', $object->id, $accountName));
event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.cannot_find_asset', ['name' => $accountName])));
@@ -79,7 +79,7 @@ class SetSourceAccount implements ActionInterface
// new source account must be different from the current destination account:
/** @var null|Transaction $destination */
$destination = $object->transactions()->where('amount', '>', 0)->first();
$destination = $object->transactions()->where('amount', '>', 0)->first();
if (null === $destination) {
Log::error('Could not find destination transaction.');
event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.cannot_find_destination_transaction')));
@@ -116,7 +116,8 @@ class SetSourceAccount implements ActionInterface
DB::table('transactions')
->where('transaction_journal_id', '=', $object->id)
->where('amount', '<', 0)
->update(['account_id' => $newAccount->id]);
->update(['account_id' => $newAccount->id])
;
event(new TriggeredAuditLog($this->action->rule, $object, 'set_source', null, $newAccount->name));
@@ -125,7 +126,7 @@ class SetSourceAccount implements ActionInterface
return true;
}
private function findAssetAccount(string $type, string $accountName): null|Account
private function findAssetAccount(string $type, string $accountName): ?Account
{
// switch on type:
$allowed = config(sprintf('firefly.expected_source_types.source.%s', $type));
@@ -147,7 +148,7 @@ class SetSourceAccount implements ActionInterface
'account_type_id' => null,
'virtual_balance' => 0,
'active' => true,
'iban' => null
'iban' => null,
];
$account = $this->repository->store($data);
}