mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-01-03 20:14:31 +00:00
Fix various code.
This commit is contained in:
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user