Fix various code.

This commit is contained in:
James Cole
2025-05-27 17:06:15 +02:00
parent d8f512ca3a
commit 2cb14f6b72
123 changed files with 581 additions and 500 deletions

View File

@@ -68,7 +68,7 @@ class SetDestinationAccount implements ActionInterface
// if this is a transfer or a deposit, the new destination account must be an asset account or a default account, and it MUST exist:
$newAccount = $this->findAssetAccount($type, $accountName);
if ((TransactionTypeEnum::DEPOSIT->value === $type || TransactionTypeEnum::TRANSFER->value === $type) && null === $newAccount) {
if ((TransactionTypeEnum::DEPOSIT->value === $type || TransactionTypeEnum::TRANSFER->value === $type) && !$newAccount instanceof Account) {
app('log')->error(
sprintf(
'Cant change destination account of journal #%d because no asset account with name "%s" exists.',
@@ -97,7 +97,7 @@ class SetDestinationAccount implements ActionInterface
return false;
}
if (null !== $newAccount && $newAccount->id === $source->account_id) {
if ($newAccount instanceof Account && $newAccount->id === $source->account_id) {
app('log')->error(
sprintf(
'New destination account ID #%d and current source account ID #%d are the same. Do nothing.',
@@ -116,7 +116,7 @@ class SetDestinationAccount implements ActionInterface
if (TransactionTypeEnum::WITHDRAWAL->value === $type) {
$newAccount = $this->findWithdrawalDestinationAccount($accountName);
}
if (null === $newAccount) {
if (!$newAccount instanceof Account) {
app('log')->error(
sprintf(
'No destination account found for name "%s".',
@@ -159,7 +159,7 @@ class SetDestinationAccount implements ActionInterface
{
$allowed = config('firefly.expected_source_types.destination.Withdrawal');
$account = $this->repository->findByName($accountName, $allowed);
if (null === $account) {
if (!$account instanceof Account) {
$data = [
'name' => $accountName,
'account_type_name' => 'expense',