Replace enum

This commit is contained in:
James Cole
2025-01-03 09:05:56 +01:00
parent 44eafeeae5
commit d009ce31ca
36 changed files with 85 additions and 77 deletions

View File

@@ -26,6 +26,7 @@ namespace FireflyIII\Api\V1\Controllers\Insight\Transfer;
use FireflyIII\Api\V1\Controllers\Controller; use FireflyIII\Api\V1\Controllers\Controller;
use FireflyIII\Api\V1\Requests\Insight\GenericRequest; use FireflyIII\Api\V1\Requests\Insight\GenericRequest;
use FireflyIII\Enums\TransactionTypeEnum;
use FireflyIII\Helpers\Collector\GroupCollectorInterface; use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Models\TransactionType; use FireflyIII\Models\TransactionType;
use FireflyIII\Support\Facades\Amount; use FireflyIII\Support\Facades\Amount;
@@ -51,7 +52,7 @@ class PeriodController extends Controller
// collect all expenses in this period (regardless of type) // collect all expenses in this period (regardless of type)
$collector = app(GroupCollectorInterface::class); $collector = app(GroupCollectorInterface::class);
$collector->setTypes([TransactionType::TRANSFER])->setRange($start, $end)->setDestinationAccounts($accounts); $collector->setTypes([TransactionTypeEnum::TRANSFER->value])->setRange($start, $end)->setDestinationAccounts($accounts);
$genericSet = $collector->getExtractedJournals(); $genericSet = $collector->getExtractedJournals();
foreach ($genericSet as $journal) { foreach ($genericSet as $journal) {
// currency // currency

View File

@@ -246,7 +246,7 @@ class CorrectsAccountTypes extends Command
private function shouldBeTransfer(string $transactionType, string $sourceType, string $destinationType): bool private function shouldBeTransfer(string $transactionType, string $sourceType, string $destinationType): bool
{ {
return TransactionType::TRANSFER === $transactionType && AccountType::ASSET === $sourceType && $this->isLiability($destinationType); return TransactionTypeEnum::TRANSFER->value === $transactionType && AccountType::ASSET === $sourceType && $this->isLiability($destinationType);
} }
private function isLiability(string $destinationType): bool private function isLiability(string $destinationType): bool
@@ -269,7 +269,7 @@ class CorrectsAccountTypes extends Command
private function shouldBeDeposit(string $transactionType, string $sourceType, string $destinationType): bool private function shouldBeDeposit(string $transactionType, string $sourceType, string $destinationType): bool
{ {
return TransactionType::TRANSFER === $transactionType && $this->isLiability($sourceType) && AccountType::ASSET === $destinationType; return TransactionTypeEnum::TRANSFER->value === $transactionType && $this->isLiability($sourceType) && AccountType::ASSET === $destinationType;
} }
private function makeDeposit(TransactionJournal $journal): void private function makeDeposit(TransactionJournal $journal): void

View File

@@ -84,7 +84,7 @@ class CorrectsUnevenAmount extends Command
continue; continue;
} }
// needs to be a transfer. // needs to be a transfer.
if (TransactionType::TRANSFER !== $journal->transactionType->type) { if (TransactionTypeEnum::TRANSFER->value !== $journal->transactionType->type) {
Log::debug('Must be a transfer, continue.'); Log::debug('Must be a transfer, continue.');
continue; continue;
@@ -228,7 +228,7 @@ class CorrectsUnevenAmount extends Command
private function isForeignCurrencyTransfer(TransactionJournal $journal): bool private function isForeignCurrencyTransfer(TransactionJournal $journal): bool
{ {
if (TransactionType::TRANSFER !== $journal->transactionType->type) { if (TransactionTypeEnum::TRANSFER->value !== $journal->transactionType->type) {
return false; return false;
} }

View File

@@ -25,6 +25,7 @@ declare(strict_types=1);
namespace FireflyIII\Console\Commands\Upgrade; namespace FireflyIII\Console\Commands\Upgrade;
use FireflyIII\Console\Commands\ShowsFriendlyMessages; use FireflyIII\Console\Commands\ShowsFriendlyMessages;
use FireflyIII\Enums\TransactionTypeEnum;
use FireflyIII\Models\Account; use FireflyIII\Models\Account;
use FireflyIII\Models\Transaction; use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionCurrency; use FireflyIII\Models\TransactionCurrency;
@@ -122,7 +123,7 @@ class UpgradesTransferCurrencies extends Command
*/ */
private function startUpdateRoutine(): void private function startUpdateRoutine(): void
{ {
$set = $this->cliRepos->getAllJournals([TransactionType::TRANSFER]); $set = $this->cliRepos->getAllJournals([TransactionTypeEnum::TRANSFER->value]);
/** @var TransactionJournal $journal */ /** @var TransactionJournal $journal */
foreach ($set as $journal) { foreach ($set as $journal) {

View File

@@ -279,7 +279,7 @@ class TransactionJournalFactory
$amount = (string) $row['amount']; $amount = (string) $row['amount'];
$foreignAmount = (string) $row['foreign_amount']; $foreignAmount = (string) $row['foreign_amount'];
if (null !== $foreignCurrency && $foreignCurrency->id !== $currency->id if (null !== $foreignCurrency && $foreignCurrency->id !== $currency->id
&& TransactionType::TRANSFER === $type->type && TransactionTypeEnum::TRANSFER->value === $type->type
) { ) {
$transactionFactory->setCurrency($foreignCurrency); $transactionFactory->setCurrency($foreignCurrency);
$transactionFactory->setForeignCurrency($currency); $transactionFactory->setForeignCurrency($currency);
@@ -495,7 +495,7 @@ class TransactionJournalFactory
*/ */
private function getForeignByAccount(string $type, ?TransactionCurrency $foreignCurrency, Account $destination): ?TransactionCurrency private function getForeignByAccount(string $type, ?TransactionCurrency $foreignCurrency, Account $destination): ?TransactionCurrency
{ {
if (TransactionType::TRANSFER === $type) { if (TransactionTypeEnum::TRANSFER->value === $type) {
return $this->getCurrency($foreignCurrency, $destination); return $this->getCurrency($foreignCurrency, $destination);
} }

View File

@@ -139,7 +139,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
/** @var GroupCollectorInterface $collector */ /** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class); $collector = app(GroupCollectorInterface::class);
$collector->setAccounts($this->accounts)->setRange($this->start, $this->end) $collector->setAccounts($this->accounts)->setRange($this->start, $this->end)
->setTypes([TransactionTypeEnum::WITHDRAWAL->value, TransactionType::TRANSFER]) ->setTypes([TransactionTypeEnum::WITHDRAWAL->value, TransactionTypeEnum::TRANSFER->value])
->setCategories($this->categories)->withAccountInformation() ->setCategories($this->categories)->withAccountInformation()
; ;
@@ -182,7 +182,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
$collector = app(GroupCollectorInterface::class); $collector = app(GroupCollectorInterface::class);
$collector->setAccounts($this->accounts)->setRange($this->start, $this->end) $collector->setAccounts($this->accounts)->setRange($this->start, $this->end)
->setTypes([TransactionType::DEPOSIT, TransactionType::TRANSFER]) ->setTypes([TransactionType::DEPOSIT, TransactionTypeEnum::TRANSFER->value])
->setCategories($this->categories)->withAccountInformation() ->setCategories($this->categories)->withAccountInformation()
; ;

View File

@@ -143,13 +143,13 @@ class UpdatedGroupEventHandler
$destAccount = $first->transactions()->where('amount', '>', '0')->first()->account; $destAccount = $first->transactions()->where('amount', '>', '0')->first()->account;
$type = $first->transactionType->type; $type = $first->transactionType->type;
if (TransactionType::TRANSFER === $type || TransactionTypeEnum::WITHDRAWAL->value === $type) { if (TransactionTypeEnum::TRANSFER->value === $type || TransactionTypeEnum::WITHDRAWAL->value === $type) {
// set all source transactions to source account: // set all source transactions to source account:
Transaction::whereIn('transaction_journal_id', $all) Transaction::whereIn('transaction_journal_id', $all)
->where('amount', '<', 0)->update(['account_id' => $sourceAccount->id]) ->where('amount', '<', 0)->update(['account_id' => $sourceAccount->id])
; ;
} }
if (TransactionType::TRANSFER === $type || TransactionType::DEPOSIT === $type) { if (TransactionTypeEnum::TRANSFER->value === $type || TransactionType::DEPOSIT === $type) {
// set all destination transactions to destination account: // set all destination transactions to destination account:
Transaction::whereIn('transaction_journal_id', $all) Transaction::whereIn('transaction_journal_id', $all)
->where('amount', '>', 0)->update(['account_id' => $destAccount->id]) ->where('amount', '>', 0)->update(['account_id' => $destAccount->id])

View File

@@ -143,7 +143,7 @@ class PopupReport implements PopupReportInterface
$collector = app(GroupCollectorInterface::class); $collector = app(GroupCollectorInterface::class);
$collector->setAccounts($attributes['accounts']) $collector->setAccounts($attributes['accounts'])
->setTypes([TransactionTypeEnum::WITHDRAWAL->value, TransactionType::TRANSFER, TransactionType::DEPOSIT]) ->setTypes([TransactionTypeEnum::WITHDRAWAL->value, TransactionTypeEnum::TRANSFER->value, TransactionType::DEPOSIT])
->withAccountInformation() ->withAccountInformation()
->withBudgetInformation() ->withBudgetInformation()
->withCategoryInformation() ->withCategoryInformation()
@@ -197,7 +197,7 @@ class PopupReport implements PopupReportInterface
->withAccountInformation() ->withAccountInformation()
->withBudgetInformation() ->withBudgetInformation()
->withCategoryInformation() ->withCategoryInformation()
->setTypes([TransactionTypeEnum::WITHDRAWAL->value, TransactionType::TRANSFER]) ->setTypes([TransactionTypeEnum::WITHDRAWAL->value, TransactionTypeEnum::TRANSFER->value])
; ;
if (null !== $currency) { if (null !== $currency) {
@@ -222,7 +222,7 @@ class PopupReport implements PopupReportInterface
->setSourceAccounts(new Collection([$account])) ->setSourceAccounts(new Collection([$account]))
->setDestinationAccounts($attributes['accounts']) ->setDestinationAccounts($attributes['accounts'])
->setRange($attributes['startDate'], $attributes['endDate']) ->setRange($attributes['startDate'], $attributes['endDate'])
->setTypes([TransactionType::DEPOSIT, TransactionType::TRANSFER]) ->setTypes([TransactionType::DEPOSIT, TransactionTypeEnum::TRANSFER->value])
->withAccountInformation() ->withAccountInformation()
->withBudgetInformation() ->withBudgetInformation()
->withCategoryInformation() ->withCategoryInformation()

View File

@@ -95,7 +95,7 @@ class NoCategoryController extends Controller
$collector->setRange($start, $end) $collector->setRange($start, $end)
->setLimit($pageSize)->setPage($page)->withoutCategory() ->setLimit($pageSize)->setPage($page)->withoutCategory()
->withAccountInformation()->withBudgetInformation() ->withAccountInformation()->withBudgetInformation()
->setTypes([TransactionTypeEnum::WITHDRAWAL->value, TransactionType::DEPOSIT, TransactionType::TRANSFER]) ->setTypes([TransactionTypeEnum::WITHDRAWAL->value, TransactionType::DEPOSIT, TransactionTypeEnum::TRANSFER->value])
; ;
$groups = $collector->getPaginatedGroups(); $groups = $collector->getPaginatedGroups();
$groups->setPath(route('categories.no-category', [$start->format('Y-m-d'), $end->format('Y-m-d')])); $groups->setPath(route('categories.no-category', [$start->format('Y-m-d'), $end->format('Y-m-d')]));
@@ -128,7 +128,7 @@ class NoCategoryController extends Controller
$collector = app(GroupCollectorInterface::class); $collector = app(GroupCollectorInterface::class);
$collector->setRange($start, $end)->setLimit($pageSize)->setPage($page)->withoutCategory() $collector->setRange($start, $end)->setLimit($pageSize)->setPage($page)->withoutCategory()
->withAccountInformation()->withBudgetInformation() ->withAccountInformation()->withBudgetInformation()
->setTypes([TransactionTypeEnum::WITHDRAWAL->value, TransactionType::DEPOSIT, TransactionType::TRANSFER]) ->setTypes([TransactionTypeEnum::WITHDRAWAL->value, TransactionType::DEPOSIT, TransactionTypeEnum::TRANSFER->value])
; ;
$groups = $collector->getPaginatedGroups(); $groups = $collector->getPaginatedGroups();
$groups->setPath(route('categories.no-category.all')); $groups->setPath(route('categories.no-category.all'));

View File

@@ -116,7 +116,7 @@ class TransactionController extends Controller
$collector->setTypes([TransactionType::DEPOSIT]); $collector->setTypes([TransactionType::DEPOSIT]);
} }
if ('transfer' === $objectType || 'transfers' === $objectType) { if ('transfer' === $objectType || 'transfers' === $objectType) {
$collector->setTypes([TransactionType::TRANSFER]); $collector->setTypes([TransactionTypeEnum::TRANSFER->value]);
} }
$result = $collector->getExtractedJournals(); $result = $collector->getExtractedJournals();
@@ -166,7 +166,7 @@ class TransactionController extends Controller
$collector->setTypes([TransactionType::DEPOSIT]); $collector->setTypes([TransactionType::DEPOSIT]);
} }
if ('transfer' === $objectType || 'transfers' === $objectType) { if ('transfer' === $objectType || 'transfers' === $objectType) {
$collector->setTypes([TransactionType::TRANSFER]); $collector->setTypes([TransactionTypeEnum::TRANSFER->value]);
} }
$result = $collector->getExtractedJournals(); $result = $collector->getExtractedJournals();
@@ -216,7 +216,7 @@ class TransactionController extends Controller
$collector->setTypes([TransactionType::DEPOSIT]); $collector->setTypes([TransactionType::DEPOSIT]);
} }
if ('transfer' === $objectType || 'transfers' === $objectType) { if ('transfer' === $objectType || 'transfers' === $objectType) {
$collector->setTypes([TransactionType::TRANSFER]); $collector->setTypes([TransactionTypeEnum::TRANSFER->value]);
} }
$result = $collector->getExtractedJournals(); $result = $collector->getExtractedJournals();

View File

@@ -25,6 +25,7 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Json; namespace FireflyIII\Http\Controllers\Json;
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\Enums\TransactionTypeEnum;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Helpers\Collector\GroupCollectorInterface; use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Http\Controllers\Controller; use FireflyIII\Http\Controllers\Controller;
@@ -245,7 +246,7 @@ class ReconcileController extends Controller
$inverse = true; $inverse = true;
} }
// transfer to this account? then positive amount: // transfer to this account? then positive amount:
if (TransactionType::TRANSFER === $journal['transaction_type_type'] && $account->id === $journal['destination_account_id']) { if (TransactionTypeEnum::TRANSFER->value === $journal['transaction_type_type'] && $account->id === $journal['destination_account_id']) {
$inverse = true; $inverse = true;
} }

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Transaction; namespace FireflyIII\Http\Controllers\Transaction;
use Exception; use Exception;
use FireflyIII\Enums\TransactionTypeEnum;
use FireflyIII\Events\UpdatedTransactionGroup; use FireflyIII\Events\UpdatedTransactionGroup;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Http\Controllers\Controller; use FireflyIII\Http\Controllers\Controller;
@@ -331,7 +332,7 @@ class ConvertController extends Controller
]; ];
// also set the currency to the currency of the source account, in case you're converting a deposit into a transfer. // also set the currency to the currency of the source account, in case you're converting a deposit into a transfer.
if (TransactionType::TRANSFER === $transactionType->type && TransactionType::DEPOSIT === $journal->transactionType->type) { if (TransactionTypeEnum::TRANSFER->value === $transactionType->type && TransactionType::DEPOSIT === $journal->transactionType->type) {
$source = $this->accountRepository->find((int) $sourceId); $source = $this->accountRepository->find((int) $sourceId);
$sourceCurrency = $this->accountRepository->getAccountCurrency($source); $sourceCurrency = $this->accountRepository->getAccountCurrency($source);
$dest = $this->accountRepository->find((int) $destinationId); $dest = $this->accountRepository->find((int) $destinationId);

View File

@@ -252,7 +252,7 @@ class RecurrenceFormRequest extends FormRequest
$rules['source_name'] = 'min:1|max:255|nullable'; $rules['source_name'] = 'min:1|max:255|nullable';
$rules['destination_id'] = 'required|exists:accounts,id|belongsToUser:accounts'; $rules['destination_id'] = 'required|exists:accounts,id|belongsToUser:accounts';
} }
if (strtolower(TransactionType::TRANSFER) === $type) { if (strtolower(TransactionTypeEnum::TRANSFER->value) === $type) {
// this may not work: // this may not work:
$rules['source_id'] = 'required|exists:accounts,id|belongsToUser:accounts|different:destination_id'; $rules['source_id'] = 'required|exists:accounts,id|belongsToUser:accounts|different:destination_id';
$rules['destination_id'] = 'required|exists:accounts,id|belongsToUser:accounts|different:source_id'; $rules['destination_id'] = 'required|exists:accounts,id|belongsToUser:accounts|different:source_id';

View File

@@ -25,6 +25,7 @@ namespace FireflyIII\Models;
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\Casts\SeparateTimezoneCaster; use FireflyIII\Casts\SeparateTimezoneCaster;
use FireflyIII\Enums\TransactionTypeEnum;
use FireflyIII\Support\Models\ReturnsIntegerIdTrait; use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
use FireflyIII\Support\Models\ReturnsIntegerUserIdTrait; use FireflyIII\Support\Models\ReturnsIntegerUserIdTrait;
use FireflyIII\User; use FireflyIII\User;
@@ -143,7 +144,7 @@ class TransactionJournal extends Model
public function isTransfer(): bool public function isTransfer(): bool
{ {
if (null !== $this->transaction_type_type) { if (null !== $this->transaction_type_type) {
return TransactionType::TRANSFER === $this->transaction_type_type; return TransactionTypeEnum::TRANSFER->value === $this->transaction_type_type;
} }
return $this->transactionType->isTransfer(); return $this->transactionType->isTransfer();

View File

@@ -122,7 +122,7 @@ class AccountTasker implements AccountTaskerInterface
$collector->setSourceAccounts($accounts)->setRange($start, $end); $collector->setSourceAccounts($accounts)->setRange($start, $end);
$collector->excludeDestinationAccounts($accounts); $collector->excludeDestinationAccounts($accounts);
$collector->setTypes([TransactionTypeEnum::WITHDRAWAL->value, TransactionType::TRANSFER])->withAccountInformation(); $collector->setTypes([TransactionTypeEnum::WITHDRAWAL->value, TransactionTypeEnum::TRANSFER->value])->withAccountInformation();
$journals = $collector->getExtractedJournals(); $journals = $collector->getExtractedJournals();
$report = $this->groupExpenseByDestination($journals); $report = $this->groupExpenseByDestination($journals);
@@ -212,7 +212,7 @@ class AccountTasker implements AccountTaskerInterface
$collector = app(GroupCollectorInterface::class); $collector = app(GroupCollectorInterface::class);
$collector->setDestinationAccounts($accounts)->setRange($start, $end); $collector->setDestinationAccounts($accounts)->setRange($start, $end);
$collector->excludeSourceAccounts($accounts); $collector->excludeSourceAccounts($accounts);
$collector->setTypes([TransactionType::DEPOSIT, TransactionType::TRANSFER])->withAccountInformation(); $collector->setTypes([TransactionType::DEPOSIT, TransactionTypeEnum::TRANSFER->value])->withAccountInformation();
$report = $this->groupIncomeBySource($collector->getExtractedJournals()); $report = $this->groupIncomeBySource($collector->getExtractedJournals());
// sort the result // sort the result

View File

@@ -192,7 +192,7 @@ class NoCategoryRepository implements NoCategoryRepositoryInterface
{ {
/** @var GroupCollectorInterface $collector */ /** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class); $collector = app(GroupCollectorInterface::class);
$collector->setUser($this->user)->setRange($start, $end)->setTypes([TransactionType::TRANSFER])->withoutCategory(); $collector->setUser($this->user)->setRange($start, $end)->setTypes([TransactionTypeEnum::TRANSFER->value])->withoutCategory();
if (null !== $accounts && $accounts->count() > 0) { if (null !== $accounts && $accounts->count() > 0) {
$collector->setAccounts($accounts); $collector->setAccounts($accounts);

View File

@@ -200,7 +200,7 @@ class OperationsRepository implements OperationsRepositoryInterface
{ {
/** @var GroupCollectorInterface $collector */ /** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class); $collector = app(GroupCollectorInterface::class);
$collector->setUser($this->user)->setRange($start, $end)->setTypes([TransactionType::TRANSFER]) $collector->setUser($this->user)->setRange($start, $end)->setTypes([TransactionTypeEnum::TRANSFER->value])
->setDestinationAccounts($accounts)->excludeSourceAccounts($accounts) ->setDestinationAccounts($accounts)->excludeSourceAccounts($accounts)
; ;
if (null !== $categories && $categories->count() > 0) { if (null !== $categories && $categories->count() > 0) {
@@ -263,7 +263,7 @@ class OperationsRepository implements OperationsRepositoryInterface
{ {
/** @var GroupCollectorInterface $collector */ /** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class); $collector = app(GroupCollectorInterface::class);
$collector->setUser($this->user)->setRange($start, $end)->setTypes([TransactionType::TRANSFER]) $collector->setUser($this->user)->setRange($start, $end)->setTypes([TransactionTypeEnum::TRANSFER->value])
->setSourceAccounts($accounts)->excludeDestinationAccounts($accounts) ->setSourceAccounts($accounts)->excludeDestinationAccounts($accounts)
; ;
if (null !== $categories && $categories->count() > 0) { if (null !== $categories && $categories->count() > 0) {
@@ -422,7 +422,7 @@ class OperationsRepository implements OperationsRepositoryInterface
/** @var GroupCollectorInterface $collector */ /** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class); $collector = app(GroupCollectorInterface::class);
$collector->setUser($this->user)->setRange($start, $end) $collector->setUser($this->user)->setRange($start, $end)
->setTypes([TransactionType::TRANSFER]) ->setTypes([TransactionTypeEnum::TRANSFER->value])
; ;
if (null !== $accounts && $accounts->count() > 0) { if (null !== $accounts && $accounts->count() > 0) {

View File

@@ -268,7 +268,7 @@ class TagRepository implements TagRepositoryInterface
'currency_decimal_places' => $journal['currency_decimal_places'], 'currency_decimal_places' => $journal['currency_decimal_places'],
TransactionTypeEnum::WITHDRAWAL->value => '0', TransactionTypeEnum::WITHDRAWAL->value => '0',
TransactionType::DEPOSIT => '0', TransactionType::DEPOSIT => '0',
TransactionType::TRANSFER => '0', TransactionTypeEnum::TRANSFER->value => '0',
TransactionType::RECONCILIATION => '0', TransactionType::RECONCILIATION => '0',
TransactionType::OPENING_BALANCE => '0', TransactionType::OPENING_BALANCE => '0',
]; ];
@@ -290,7 +290,7 @@ class TagRepository implements TagRepositoryInterface
'currency_decimal_places' => $journal['foreign_currency_decimal_places'], 'currency_decimal_places' => $journal['foreign_currency_decimal_places'],
TransactionTypeEnum::WITHDRAWAL->value => '0', TransactionTypeEnum::WITHDRAWAL->value => '0',
TransactionType::DEPOSIT => '0', TransactionType::DEPOSIT => '0',
TransactionType::TRANSFER => '0', TransactionTypeEnum::TRANSFER->value => '0',
TransactionType::RECONCILIATION => '0', TransactionType::RECONCILIATION => '0',
TransactionType::OPENING_BALANCE => '0', TransactionType::OPENING_BALANCE => '0',
]; ];
@@ -325,7 +325,7 @@ class TagRepository implements TagRepositoryInterface
/** @var GroupCollectorInterface $collector */ /** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class); $collector = app(GroupCollectorInterface::class);
$collector->setUser($this->user); $collector->setUser($this->user);
$collector->setRange($start, $end)->setTypes([TransactionType::TRANSFER])->setTag($tag); $collector->setRange($start, $end)->setTypes([TransactionTypeEnum::TRANSFER->value])->setTag($tag);
return $collector->getExtractedJournals(); return $collector->getExtractedJournals();
} }

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Rules; namespace FireflyIII\Rules;
use FireflyIII\Enums\TransactionTypeEnum;
use FireflyIII\Models\TransactionType; use FireflyIII\Models\TransactionType;
use FireflyIII\Validation\AccountValidator; use FireflyIII\Validation\AccountValidator;
use Illuminate\Contracts\Validation\ValidationRule; use Illuminate\Contracts\Validation\ValidationRule;
@@ -42,7 +43,7 @@ class IsTransferAccount implements ValidationRule
/** @var AccountValidator $validator */ /** @var AccountValidator $validator */
$validator = app(AccountValidator::class); $validator = app(AccountValidator::class);
$validator->setTransactionType(TransactionType::TRANSFER); $validator->setTransactionType(TransactionTypeEnum::TRANSFER->value);
$validator->setUser(auth()->user()); $validator->setUser(auth()->user());
$validAccount = $validator->validateSource(['name' => (string) $value]); $validAccount = $validator->validateSource(['name' => (string) $value]);

View File

@@ -343,7 +343,7 @@ class CreditRecalculateService
} }
// in any other case, remove amount from left of debt. // in any other case, remove amount from left of debt.
if (in_array($type, [TransactionTypeEnum::WITHDRAWAL->value, TransactionType::DEPOSIT, TransactionType::TRANSFER], true)) { if (in_array($type, [TransactionTypeEnum::WITHDRAWAL->value, TransactionType::DEPOSIT, TransactionTypeEnum::TRANSFER->value], true)) {
$usedAmount = app('steam')->negative($usedAmount); $usedAmount = app('steam')->negative($usedAmount);
return bcadd($leftOfDebt, $usedAmount); return bcadd($leftOfDebt, $usedAmount);
@@ -437,7 +437,7 @@ class CreditRecalculateService
*/ */
private function isTransferIn(string $amount, string $transactionType): bool private function isTransferIn(string $amount, string $transactionType): bool
{ {
return TransactionType::TRANSFER === $transactionType && 1 === bccomp($amount, '0'); return TransactionTypeEnum::TRANSFER->value === $transactionType && 1 === bccomp($amount, '0');
} }
/** /**
@@ -449,7 +449,7 @@ class CreditRecalculateService
*/ */
private function isTransferOut(string $amount, string $transactionType): bool private function isTransferOut(string $amount, string $transactionType): bool
{ {
return TransactionType::TRANSFER === $transactionType && -1 === bccomp($amount, '0'); return TransactionTypeEnum::TRANSFER->value === $transactionType && -1 === bccomp($amount, '0');
} }
public function setAccount(?Account $account): void public function setAccount(?Account $account): void

View File

@@ -533,7 +533,7 @@ class JournalUpdateService
$this->storeBudget($this->transactionJournal, new NullArrayObject($this->data)); $this->storeBudget($this->transactionJournal, new NullArrayObject($this->data));
} }
// is transfer? remove budget // is transfer? remove budget
if (TransactionType::TRANSFER === $this->transactionJournal->transactionType->type) { if (TransactionTypeEnum::TRANSFER->value === $this->transactionJournal->transactionType->type) {
$this->transactionJournal->budgets()->sync([]); $this->transactionJournal->budgets()->sync([]);
} }
} }

View File

@@ -45,7 +45,7 @@ class JournalList implements BinderInterface
// get the journals by using the collector. // get the journals by using the collector.
/** @var GroupCollectorInterface $collector */ /** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class); $collector = app(GroupCollectorInterface::class);
$collector->setTypes([TransactionTypeEnum::WITHDRAWAL->value, TransactionType::DEPOSIT, TransactionType::TRANSFER, TransactionType::RECONCILIATION]); $collector->setTypes([TransactionTypeEnum::WITHDRAWAL->value, TransactionType::DEPOSIT, TransactionTypeEnum::TRANSFER->value, TransactionType::RECONCILIATION]);
$collector->withCategoryInformation()->withBudgetInformation()->withTagInformation()->withAccountInformation(); $collector->withCategoryInformation()->withBudgetInformation()->withTagInformation()->withAccountInformation();
$collector->setJournalIds($list); $collector->setJournalIds($list);
$result = $collector->getExtractedJournals(); $result = $collector->getExtractedJournals();

View File

@@ -25,6 +25,7 @@ declare(strict_types=1);
namespace FireflyIII\Support\Http\Api; namespace FireflyIII\Support\Http\Api;
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\Enums\TransactionTypeEnum;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\TransactionCurrency; use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Models\TransactionType; use FireflyIII\Models\TransactionType;
@@ -223,7 +224,7 @@ class AccountBalanceGrouped
|| ( || (
( (
TransactionType::TRANSFER === $journal['transaction_type_type'] TransactionTypeEnum::TRANSFER->value === $journal['transaction_type_type']
|| TransactionType::RECONCILIATION === $journal['transaction_type_type'] || TransactionType::RECONCILIATION === $journal['transaction_type_type']
|| TransactionType::OPENING_BALANCE === $journal['transaction_type_type'] || TransactionType::OPENING_BALANCE === $journal['transaction_type_type']
) )

View File

@@ -41,7 +41,7 @@ trait TransactionFilter
'all' => [ 'all' => [
TransactionTypeEnum::WITHDRAWAL->value, TransactionTypeEnum::WITHDRAWAL->value,
TransactionType::DEPOSIT, TransactionType::DEPOSIT,
TransactionType::TRANSFER, TransactionTypeEnum::TRANSFER->value,
TransactionType::OPENING_BALANCE, TransactionType::OPENING_BALANCE,
TransactionType::RECONCILIATION, TransactionType::RECONCILIATION,
], ],
@@ -52,14 +52,14 @@ trait TransactionFilter
'income' => [TransactionType::DEPOSIT], 'income' => [TransactionType::DEPOSIT],
'deposit' => [TransactionType::DEPOSIT], 'deposit' => [TransactionType::DEPOSIT],
'deposits' => [TransactionType::DEPOSIT], 'deposits' => [TransactionType::DEPOSIT],
'transfer' => [TransactionType::TRANSFER], 'transfer' => [TransactionTypeEnum::TRANSFER->value],
'transfers' => [TransactionType::TRANSFER], 'transfers' => [TransactionTypeEnum::TRANSFER->value],
'opening_balance' => [TransactionType::OPENING_BALANCE], 'opening_balance' => [TransactionType::OPENING_BALANCE],
'reconciliation' => [TransactionType::RECONCILIATION], 'reconciliation' => [TransactionType::RECONCILIATION],
'reconciliations' => [TransactionType::RECONCILIATION], 'reconciliations' => [TransactionType::RECONCILIATION],
'special' => [TransactionType::OPENING_BALANCE, TransactionType::RECONCILIATION], 'special' => [TransactionType::OPENING_BALANCE, TransactionType::RECONCILIATION],
'specials' => [TransactionType::OPENING_BALANCE, TransactionType::RECONCILIATION], 'specials' => [TransactionType::OPENING_BALANCE, TransactionType::RECONCILIATION],
'default' => [TransactionTypeEnum::WITHDRAWAL->value, TransactionType::DEPOSIT, TransactionType::TRANSFER], 'default' => [TransactionTypeEnum::WITHDRAWAL->value, TransactionType::DEPOSIT, TransactionTypeEnum::TRANSFER->value],
]; ];
$return = []; $return = [];
$parts = explode(',', $type); $parts = explode(',', $type);

View File

@@ -114,7 +114,7 @@ trait PeriodOverview
$collector = app(GroupCollectorInterface::class); $collector = app(GroupCollectorInterface::class);
$collector->setAccounts(new Collection([$account])); $collector->setAccounts(new Collection([$account]));
$collector->setRange($start, $end); $collector->setRange($start, $end);
$collector->setTypes([TransactionType::TRANSFER]); $collector->setTypes([TransactionTypeEnum::TRANSFER->value]);
$transferSet = $collector->getExtractedJournals(); $transferSet = $collector->getExtractedJournals();
// loop dates // loop dates
@@ -288,7 +288,7 @@ trait PeriodOverview
$collector = app(GroupCollectorInterface::class); $collector = app(GroupCollectorInterface::class);
$collector->setCategory($category); $collector->setCategory($category);
$collector->setRange($start, $end); $collector->setRange($start, $end);
$collector->setTypes([TransactionType::TRANSFER]); $collector->setTypes([TransactionTypeEnum::TRANSFER->value]);
$transferSet = $collector->getExtractedJournals(); $transferSet = $collector->getExtractedJournals();
foreach ($dates as $currentDate) { foreach ($dates as $currentDate) {
$spent = $this->filterJournalsByDate($spentSet, $currentDate['start'], $currentDate['end']); $spent = $this->filterJournalsByDate($spentSet, $currentDate['start'], $currentDate['end']);
@@ -410,7 +410,7 @@ trait PeriodOverview
$collector = app(GroupCollectorInterface::class); $collector = app(GroupCollectorInterface::class);
$collector->withoutCategory(); $collector->withoutCategory();
$collector->setRange($start, $end); $collector->setRange($start, $end);
$collector->setTypes([TransactionType::TRANSFER]); $collector->setTypes([TransactionTypeEnum::TRANSFER->value]);
$transferSet = $collector->getExtractedJournals(); $transferSet = $collector->getExtractedJournals();
/** @var array $currentDate */ /** @var array $currentDate */
@@ -479,7 +479,7 @@ trait PeriodOverview
$collector = app(GroupCollectorInterface::class); $collector = app(GroupCollectorInterface::class);
$collector->setTag($tag); $collector->setTag($tag);
$collector->setRange($start, $end); $collector->setRange($start, $end);
$collector->setTypes([TransactionType::TRANSFER]); $collector->setTypes([TransactionTypeEnum::TRANSFER->value]);
$transferSet = $collector->getExtractedJournals(); $transferSet = $collector->getExtractedJournals();
// filer all of them: // filer all of them:

View File

@@ -61,7 +61,7 @@ trait TransactionCalculation
/** @var GroupCollectorInterface $collector */ /** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class); $collector = app(GroupCollectorInterface::class);
$collector->setAccounts($accounts)->setRange($start, $end)->setTypes([TransactionTypeEnum::WITHDRAWAL->value, TransactionType::TRANSFER]) $collector->setAccounts($accounts)->setRange($start, $end)->setTypes([TransactionTypeEnum::WITHDRAWAL->value, TransactionTypeEnum::TRANSFER->value])
->setTags($tags)->withAccountInformation() ->setTags($tags)->withAccountInformation()
; ;
@@ -75,7 +75,7 @@ trait TransactionCalculation
{ {
/** @var GroupCollectorInterface $collector */ /** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class); $collector = app(GroupCollectorInterface::class);
$collector->setAccounts($accounts)->setRange($start, $end)->setTypes([TransactionTypeEnum::WITHDRAWAL->value, TransactionType::TRANSFER]) $collector->setAccounts($accounts)->setRange($start, $end)->setTypes([TransactionTypeEnum::WITHDRAWAL->value, TransactionTypeEnum::TRANSFER->value])
->setBudgets($budgets)->withAccountInformation() ->setBudgets($budgets)->withAccountInformation()
; ;
@@ -92,7 +92,7 @@ trait TransactionCalculation
$collector $collector
->setAccounts($accounts) ->setAccounts($accounts)
->setRange($start, $end) ->setRange($start, $end)
->setTypes([TransactionTypeEnum::WITHDRAWAL->value, TransactionType::TRANSFER]) ->setTypes([TransactionTypeEnum::WITHDRAWAL->value, TransactionTypeEnum::TRANSFER->value])
->setCategories($categories) ->setCategories($categories)
->withAccountInformation() ->withAccountInformation()
; ;
@@ -107,7 +107,7 @@ trait TransactionCalculation
{ {
/** @var GroupCollectorInterface $collector */ /** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class); $collector = app(GroupCollectorInterface::class);
$collector->setAccounts($accounts)->setRange($start, $end)->setTypes([TransactionType::DEPOSIT, TransactionType::TRANSFER]) $collector->setAccounts($accounts)->setRange($start, $end)->setTypes([TransactionType::DEPOSIT, TransactionTypeEnum::TRANSFER->value])
->setCategories($categories)->withAccountInformation() ->setCategories($categories)->withAccountInformation()
; ;
@@ -135,7 +135,7 @@ trait TransactionCalculation
{ {
/** @var GroupCollectorInterface $collector */ /** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class); $collector = app(GroupCollectorInterface::class);
$collector->setAccounts($accounts)->setRange($start, $end)->setTypes([TransactionType::DEPOSIT, TransactionType::TRANSFER]) $collector->setAccounts($accounts)->setRange($start, $end)->setTypes([TransactionType::DEPOSIT, TransactionTypeEnum::TRANSFER->value])
->setTags($tags)->withAccountInformation() ->setTags($tags)->withAccountInformation()
; ;

View File

@@ -75,7 +75,7 @@ trait UserNavigation
return false; return false;
} }
$type = $journal->transactionType->type; $type = $journal->transactionType->type;
$editable = [TransactionTypeEnum::WITHDRAWAL->value, TransactionType::TRANSFER, TransactionType::DEPOSIT, TransactionType::RECONCILIATION]; $editable = [TransactionTypeEnum::WITHDRAWAL->value, TransactionTypeEnum::TRANSFER->value, TransactionType::DEPOSIT, TransactionType::RECONCILIATION];
return in_array($type, $editable, true); return in_array($type, $editable, true);
} }

View File

@@ -83,12 +83,12 @@ class TransactionGroupTwig extends AbstractExtension
$sourceType = $array['source_account_type'] ?? 'invalid'; $sourceType = $array['source_account_type'] ?? 'invalid';
$amount = $this->signAmount($amount, $type, $sourceType); $amount = $this->signAmount($amount, $type, $sourceType);
if (TransactionType::TRANSFER === $type) { if (TransactionTypeEnum::TRANSFER->value === $type) {
$colored = false; $colored = false;
} }
$result = app('amount')->formatFlat($array['currency_symbol'], (int) $array['currency_decimal_places'], $amount, $colored); $result = app('amount')->formatFlat($array['currency_symbol'], (int) $array['currency_decimal_places'], $amount, $colored);
if (TransactionType::TRANSFER === $type) { if (TransactionTypeEnum::TRANSFER->value === $type) {
$result = sprintf('<span class="text-info money-transfer">%s</span>', $result); $result = sprintf('<span class="text-info money-transfer">%s</span>', $result);
} }
@@ -127,11 +127,11 @@ class TransactionGroupTwig extends AbstractExtension
$sourceType = $array['source_account_type'] ?? 'invalid'; $sourceType = $array['source_account_type'] ?? 'invalid';
$amount = $this->signAmount($amount, $type, $sourceType); $amount = $this->signAmount($amount, $type, $sourceType);
if (TransactionType::TRANSFER === $type) { if (TransactionTypeEnum::TRANSFER->value === $type) {
$colored = false; $colored = false;
} }
$result = app('amount')->formatFlat($array['foreign_currency_symbol'], (int) $array['foreign_currency_decimal_places'], $amount, $colored); $result = app('amount')->formatFlat($array['foreign_currency_symbol'], (int) $array['foreign_currency_decimal_places'], $amount, $colored);
if (TransactionType::TRANSFER === $type) { if (TransactionTypeEnum::TRANSFER->value === $type) {
$result = sprintf('<span class="text-info money-transfer">%s</span>', $result); $result = sprintf('<span class="text-info money-transfer">%s</span>', $result);
} }
@@ -173,11 +173,11 @@ class TransactionGroupTwig extends AbstractExtension
$amount = $this->signAmount($amount, $type, $sourceType); $amount = $this->signAmount($amount, $type, $sourceType);
if (TransactionType::TRANSFER === $type) { if (TransactionTypeEnum::TRANSFER->value === $type) {
$colored = false; $colored = false;
} }
$result = app('amount')->formatFlat($currency->symbol, $currency->decimal_places, $amount, $colored); $result = app('amount')->formatFlat($currency->symbol, $currency->decimal_places, $amount, $colored);
if (TransactionType::TRANSFER === $type) { if (TransactionTypeEnum::TRANSFER->value === $type) {
$result = sprintf('<span class="text-info money-transfer">%s</span>', $result); $result = sprintf('<span class="text-info money-transfer">%s</span>', $result);
} }
@@ -208,11 +208,11 @@ class TransactionGroupTwig extends AbstractExtension
$amount = $this->signAmount($amount, $type, $sourceType); $amount = $this->signAmount($amount, $type, $sourceType);
if (TransactionType::TRANSFER === $type) { if (TransactionTypeEnum::TRANSFER->value === $type) {
$colored = false; $colored = false;
} }
$result = app('amount')->formatFlat($currency->symbol, $currency->decimal_places, $amount, $colored); $result = app('amount')->formatFlat($currency->symbol, $currency->decimal_places, $amount, $colored);
if (TransactionType::TRANSFER === $type) { if (TransactionTypeEnum::TRANSFER->value === $type) {
$result = sprintf('<span class="text-info money-transfer">%s</span>', $result); $result = sprintf('<span class="text-info money-transfer">%s</span>', $result);
} }

View File

@@ -99,7 +99,7 @@ class ConvertToDeposit implements ActionInterface
return $res; return $res;
} }
if (TransactionType::TRANSFER === $type) { if (TransactionTypeEnum::TRANSFER->value === $type) {
app('log')->debug('Going to transform a transfer to a deposit.'); app('log')->debug('Going to transform a transfer to a deposit.');
try { try {
@@ -111,7 +111,7 @@ class ConvertToDeposit implements ActionInterface
return false; return false;
} }
event(new TriggeredAuditLog($this->action->rule, $object, 'update_transaction_type', TransactionType::TRANSFER, TransactionType::DEPOSIT)); event(new TriggeredAuditLog($this->action->rule, $object, 'update_transaction_type', TransactionTypeEnum::TRANSFER->value, TransactionType::DEPOSIT));
return $res; return $res;
} }

View File

@@ -79,7 +79,7 @@ class ConvertToTransfer implements ActionInterface
$type = $object->transactionType->type; $type = $object->transactionType->type;
$user = $object->user; $user = $object->user;
$journalId = $object->id; $journalId = $object->id;
if (TransactionType::TRANSFER === $type) { if (TransactionTypeEnum::TRANSFER->value === $type) {
app('log')->error( app('log')->error(
sprintf('Journal #%d is already a transfer so cannot be converted (rule #%d).', $object->id, $this->action->rule_id) sprintf('Journal #%d is already a transfer so cannot be converted (rule #%d).', $object->id, $this->action->rule_id)
); );
@@ -136,7 +136,7 @@ class ConvertToTransfer implements ActionInterface
return false; return false;
} }
if (false !== $res) { if (false !== $res) {
event(new TriggeredAuditLog($this->action->rule, $object, 'update_transaction_type', TransactionTypeEnum::WITHDRAWAL->value, TransactionType::TRANSFER)); event(new TriggeredAuditLog($this->action->rule, $object, 'update_transaction_type', TransactionTypeEnum::WITHDRAWAL->value, TransactionTypeEnum::TRANSFER->value));
} }
return $res; return $res;
@@ -154,7 +154,7 @@ class ConvertToTransfer implements ActionInterface
return false; return false;
} }
if (false !== $res) { if (false !== $res) {
event(new TriggeredAuditLog($this->action->rule, $object, 'update_transaction_type', TransactionType::DEPOSIT, TransactionType::TRANSFER)); event(new TriggeredAuditLog($this->action->rule, $object, 'update_transaction_type', TransactionType::DEPOSIT, TransactionTypeEnum::TRANSFER->value));
} }
return $res; return $res;
@@ -216,7 +216,7 @@ class ConvertToTransfer implements ActionInterface
; ;
// change transaction type of journal: // change transaction type of journal:
$newType = TransactionType::whereType(TransactionType::TRANSFER)->first(); $newType = TransactionType::whereType(TransactionTypeEnum::TRANSFER->value)->first();
\DB::table('transaction_journals') \DB::table('transaction_journals')
->where('id', '=', $journal->id) ->where('id', '=', $journal->id)
@@ -271,7 +271,7 @@ class ConvertToTransfer implements ActionInterface
; ;
// change transaction type of journal: // change transaction type of journal:
$newType = TransactionType::whereType(TransactionType::TRANSFER)->first(); $newType = TransactionType::whereType(TransactionTypeEnum::TRANSFER->value)->first();
\DB::table('transaction_journals') \DB::table('transaction_journals')
->where('id', '=', $journal->id) ->where('id', '=', $journal->id)

View File

@@ -80,7 +80,7 @@ class ConvertToWithdrawal implements ActionInterface
return false; return false;
} }
if (TransactionType::DEPOSIT !== $type && TransactionType::TRANSFER !== $type) { if (TransactionType::DEPOSIT !== $type && TransactionTypeEnum::TRANSFER->value !== $type) {
event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.unsupported_transaction_type_withdrawal', ['type' => $type]))); event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.unsupported_transaction_type_withdrawal', ['type' => $type])));
return false; return false;
@@ -113,7 +113,7 @@ class ConvertToWithdrawal implements ActionInterface
return false; return false;
} }
event(new TriggeredAuditLog($this->action->rule, $object, 'update_transaction_type', TransactionType::TRANSFER, TransactionTypeEnum::WITHDRAWAL->value)); event(new TriggeredAuditLog($this->action->rule, $object, 'update_transaction_type', TransactionTypeEnum::TRANSFER->value, TransactionTypeEnum::WITHDRAWAL->value));
return $res; return $res;
} }

View File

@@ -72,7 +72,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: // 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); $newAccount = $this->findAssetAccount($type, $accountName);
if ((TransactionType::DEPOSIT === $type || TransactionType::TRANSFER === $type) && null === $newAccount) { if ((TransactionType::DEPOSIT === $type || TransactionTypeEnum::TRANSFER->value === $type) && null === $newAccount) {
app('log')->error( app('log')->error(
sprintf( sprintf(
'Cant change destination account of journal #%d because no asset account with name "%s" exists.', 'Cant change destination account of journal #%d because no asset account with name "%s" exists.',

View File

@@ -71,7 +71,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: // 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 || TransactionType::TRANSFER === $type) && null === $newAccount) { if ((TransactionTypeEnum::WITHDRAWAL->value === $type || TransactionTypeEnum::TRANSFER->value === $type) && null === $newAccount) {
app('log')->error( app('log')->error(
sprintf('Cant change source account of journal #%d because no asset account with name "%s" exists.', $object->id, $accountName) sprintf('Cant change source account of journal #%d because no asset account with name "%s" exists.', $object->id, $accountName)
); );

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\TransactionRules\Actions; namespace FireflyIII\TransactionRules\Actions;
use FireflyIII\Enums\TransactionTypeEnum;
use FireflyIII\Events\Model\Rule\RuleActionFailedOnArray; use FireflyIII\Events\Model\Rule\RuleActionFailedOnArray;
use FireflyIII\Events\TriggeredAuditLog; use FireflyIII\Events\TriggeredAuditLog;
use FireflyIII\Models\RuleAction; use FireflyIII\Models\RuleAction;
@@ -66,7 +67,7 @@ class SwitchAccounts implements ActionInterface
} }
$type = $object->transactionType->type; $type = $object->transactionType->type;
if (TransactionType::TRANSFER !== $type) { if (TransactionTypeEnum::TRANSFER->value !== $type) {
app('log')->error(sprintf('Journal #%d is NOT a transfer (rule #%d), cannot switch accounts.', $journal['transaction_journal_id'], $this->action->rule_id)); app('log')->error(sprintf('Journal #%d is NOT a transfer (rule #%d), cannot switch accounts.', $journal['transaction_journal_id'], $this->action->rule_id));
event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.is_not_transfer'))); event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.is_not_transfer')));

View File

@@ -151,7 +151,7 @@ class AccountValidator
break; break;
case TransactionType::TRANSFER: case TransactionTypeEnum::TRANSFER->value:
$result = $this->validateTransferDestination($array); $result = $this->validateTransferDestination($array);
break; break;
@@ -196,7 +196,7 @@ class AccountValidator
break; break;
case TransactionType::TRANSFER: case TransactionTypeEnum::TRANSFER->value:
$result = $this->validateTransferSource($array); $result = $this->validateTransferSource($array);
break; break;

View File

@@ -260,7 +260,7 @@ trait TransactionValidation
return; return;
} }
} }
if (TransactionType::TRANSFER === ucfirst($transactionType) || TransactionTypeEnum::WITHDRAWAL->value === ucfirst($transactionType)) { if (TransactionTypeEnum::TRANSFER->value === ucfirst($transactionType) || TransactionTypeEnum::WITHDRAWAL->value === ucfirst($transactionType)) {
app('log')->debug(sprintf('Processing as a "%s"', $transactionType)); app('log')->debug(sprintf('Processing as a "%s"', $transactionType));
// use case: withdrawal from asset account to a liability account. // use case: withdrawal from asset account to a liability account.
// the foreign amount must be in the currency of the destination // the foreign amount must be in the currency of the destination