mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +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',
|
||||
|
@@ -67,7 +67,7 @@ class SetSourceAccount implements ActionInterface
|
||||
|
||||
// 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);
|
||||
if ((TransactionTypeEnum::WITHDRAWAL->value === $type || TransactionTypeEnum::TRANSFER->value === $type) && null === $newAccount) {
|
||||
if ((TransactionTypeEnum::WITHDRAWAL->value === $type || TransactionTypeEnum::TRANSFER->value === $type) && !$newAccount instanceof Account) {
|
||||
app('log')->error(
|
||||
sprintf('Cant change source account of journal #%d because no asset account with name "%s" exists.', $object->id, $accountName)
|
||||
);
|
||||
@@ -92,7 +92,7 @@ class SetSourceAccount implements ActionInterface
|
||||
|
||||
return false;
|
||||
}
|
||||
if (null !== $newAccount && $newAccount->id === $destination->account_id) {
|
||||
if ($newAccount instanceof Account && $newAccount->id === $destination->account_id) {
|
||||
app('log')->error(
|
||||
sprintf(
|
||||
'New source account ID #%d and current destination account ID #%d are the same. Do nothing.',
|
||||
@@ -141,7 +141,7 @@ class SetSourceAccount implements ActionInterface
|
||||
{
|
||||
$allowed = config('firefly.expected_source_types.source.Deposit');
|
||||
$account = $this->repository->findByName($accountName, $allowed);
|
||||
if (null === $account) {
|
||||
if (!$account instanceof Account) {
|
||||
// create new revenue account with this name:
|
||||
$data = [
|
||||
'name' => $accountName,
|
||||
|
@@ -56,7 +56,7 @@ class UpdatePiggyBank implements ActionInterface
|
||||
$journalObj = $user->transactionJournals()->find($journal['transaction_journal_id']);
|
||||
|
||||
$piggyBank = $this->findPiggyBank($user, $actionValue);
|
||||
if (null === $piggyBank) {
|
||||
if (!$piggyBank instanceof PiggyBank) {
|
||||
Log::info(
|
||||
sprintf('No piggy bank named "%s", cant execute action #%d of rule #%d', $actionValue, $this->action->id, $this->action->rule_id)
|
||||
);
|
||||
@@ -150,7 +150,7 @@ class UpdatePiggyBank implements ActionInterface
|
||||
|
||||
private function isConnected(PiggyBank $piggyBank, ?Account $link): bool
|
||||
{
|
||||
if (null === $link) {
|
||||
if (!$link instanceof Account) {
|
||||
return false;
|
||||
}
|
||||
foreach ($piggyBank->accounts as $account) {
|
||||
|
@@ -135,7 +135,7 @@ class ActionExpression
|
||||
|
||||
public function isValid(): bool
|
||||
{
|
||||
return null === $this->validationError;
|
||||
return !$this->validationError instanceof SyntaxError;
|
||||
}
|
||||
|
||||
private function evaluateExpression(string $expr, array $journal): string
|
||||
|
Reference in New Issue
Block a user