diff --git a/app/Api/V1/Controllers/Insight/Transfer/PeriodController.php b/app/Api/V1/Controllers/Insight/Transfer/PeriodController.php
index e86a98a748..d3cc3a6264 100644
--- a/app/Api/V1/Controllers/Insight/Transfer/PeriodController.php
+++ b/app/Api/V1/Controllers/Insight/Transfer/PeriodController.php
@@ -26,6 +26,7 @@ namespace FireflyIII\Api\V1\Controllers\Insight\Transfer;
use FireflyIII\Api\V1\Controllers\Controller;
use FireflyIII\Api\V1\Requests\Insight\GenericRequest;
+use FireflyIII\Enums\TransactionTypeEnum;
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Models\TransactionType;
use FireflyIII\Support\Facades\Amount;
@@ -51,7 +52,7 @@ class PeriodController extends Controller
// collect all expenses in this period (regardless of type)
$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();
foreach ($genericSet as $journal) {
// currency
diff --git a/app/Console/Commands/Correction/CorrectsAccountTypes.php b/app/Console/Commands/Correction/CorrectsAccountTypes.php
index 3dcd1c47c8..c9fac6cb5e 100644
--- a/app/Console/Commands/Correction/CorrectsAccountTypes.php
+++ b/app/Console/Commands/Correction/CorrectsAccountTypes.php
@@ -246,7 +246,7 @@ class CorrectsAccountTypes extends Command
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
@@ -269,7 +269,7 @@ class CorrectsAccountTypes extends Command
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
diff --git a/app/Console/Commands/Correction/CorrectsUnevenAmount.php b/app/Console/Commands/Correction/CorrectsUnevenAmount.php
index c97d384462..75d0bcffe8 100644
--- a/app/Console/Commands/Correction/CorrectsUnevenAmount.php
+++ b/app/Console/Commands/Correction/CorrectsUnevenAmount.php
@@ -84,7 +84,7 @@ class CorrectsUnevenAmount extends Command
continue;
}
// 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.');
continue;
@@ -228,7 +228,7 @@ class CorrectsUnevenAmount extends Command
private function isForeignCurrencyTransfer(TransactionJournal $journal): bool
{
- if (TransactionType::TRANSFER !== $journal->transactionType->type) {
+ if (TransactionTypeEnum::TRANSFER->value !== $journal->transactionType->type) {
return false;
}
diff --git a/app/Console/Commands/Upgrade/UpgradesTransferCurrencies.php b/app/Console/Commands/Upgrade/UpgradesTransferCurrencies.php
index a16fe46351..a48bad8c89 100644
--- a/app/Console/Commands/Upgrade/UpgradesTransferCurrencies.php
+++ b/app/Console/Commands/Upgrade/UpgradesTransferCurrencies.php
@@ -25,6 +25,7 @@ declare(strict_types=1);
namespace FireflyIII\Console\Commands\Upgrade;
use FireflyIII\Console\Commands\ShowsFriendlyMessages;
+use FireflyIII\Enums\TransactionTypeEnum;
use FireflyIII\Models\Account;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionCurrency;
@@ -122,7 +123,7 @@ class UpgradesTransferCurrencies extends Command
*/
private function startUpdateRoutine(): void
{
- $set = $this->cliRepos->getAllJournals([TransactionType::TRANSFER]);
+ $set = $this->cliRepos->getAllJournals([TransactionTypeEnum::TRANSFER->value]);
/** @var TransactionJournal $journal */
foreach ($set as $journal) {
diff --git a/app/Factory/TransactionJournalFactory.php b/app/Factory/TransactionJournalFactory.php
index c027955476..9148c69261 100644
--- a/app/Factory/TransactionJournalFactory.php
+++ b/app/Factory/TransactionJournalFactory.php
@@ -279,7 +279,7 @@ class TransactionJournalFactory
$amount = (string) $row['amount'];
$foreignAmount = (string) $row['foreign_amount'];
if (null !== $foreignCurrency && $foreignCurrency->id !== $currency->id
- && TransactionType::TRANSFER === $type->type
+ && TransactionTypeEnum::TRANSFER->value === $type->type
) {
$transactionFactory->setCurrency($foreignCurrency);
$transactionFactory->setForeignCurrency($currency);
@@ -495,7 +495,7 @@ class TransactionJournalFactory
*/
private function getForeignByAccount(string $type, ?TransactionCurrency $foreignCurrency, Account $destination): ?TransactionCurrency
{
- if (TransactionType::TRANSFER === $type) {
+ if (TransactionTypeEnum::TRANSFER->value === $type) {
return $this->getCurrency($foreignCurrency, $destination);
}
diff --git a/app/Generator/Report/Category/MonthReportGenerator.php b/app/Generator/Report/Category/MonthReportGenerator.php
index df1dd253eb..5550dcd150 100644
--- a/app/Generator/Report/Category/MonthReportGenerator.php
+++ b/app/Generator/Report/Category/MonthReportGenerator.php
@@ -139,7 +139,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
/** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class);
$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()
;
@@ -182,7 +182,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
$collector = app(GroupCollectorInterface::class);
$collector->setAccounts($this->accounts)->setRange($this->start, $this->end)
- ->setTypes([TransactionType::DEPOSIT, TransactionType::TRANSFER])
+ ->setTypes([TransactionType::DEPOSIT, TransactionTypeEnum::TRANSFER->value])
->setCategories($this->categories)->withAccountInformation()
;
diff --git a/app/Handlers/Events/UpdatedGroupEventHandler.php b/app/Handlers/Events/UpdatedGroupEventHandler.php
index 36502d655d..81fa48395c 100644
--- a/app/Handlers/Events/UpdatedGroupEventHandler.php
+++ b/app/Handlers/Events/UpdatedGroupEventHandler.php
@@ -143,13 +143,13 @@ class UpdatedGroupEventHandler
$destAccount = $first->transactions()->where('amount', '>', '0')->first()->account;
$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:
Transaction::whereIn('transaction_journal_id', $all)
->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:
Transaction::whereIn('transaction_journal_id', $all)
->where('amount', '>', 0)->update(['account_id' => $destAccount->id])
diff --git a/app/Helpers/Report/PopupReport.php b/app/Helpers/Report/PopupReport.php
index ced345197f..85a1f8c3cc 100644
--- a/app/Helpers/Report/PopupReport.php
+++ b/app/Helpers/Report/PopupReport.php
@@ -143,7 +143,7 @@ class PopupReport implements PopupReportInterface
$collector = app(GroupCollectorInterface::class);
$collector->setAccounts($attributes['accounts'])
- ->setTypes([TransactionTypeEnum::WITHDRAWAL->value, TransactionType::TRANSFER, TransactionType::DEPOSIT])
+ ->setTypes([TransactionTypeEnum::WITHDRAWAL->value, TransactionTypeEnum::TRANSFER->value, TransactionType::DEPOSIT])
->withAccountInformation()
->withBudgetInformation()
->withCategoryInformation()
@@ -197,7 +197,7 @@ class PopupReport implements PopupReportInterface
->withAccountInformation()
->withBudgetInformation()
->withCategoryInformation()
- ->setTypes([TransactionTypeEnum::WITHDRAWAL->value, TransactionType::TRANSFER])
+ ->setTypes([TransactionTypeEnum::WITHDRAWAL->value, TransactionTypeEnum::TRANSFER->value])
;
if (null !== $currency) {
@@ -222,7 +222,7 @@ class PopupReport implements PopupReportInterface
->setSourceAccounts(new Collection([$account]))
->setDestinationAccounts($attributes['accounts'])
->setRange($attributes['startDate'], $attributes['endDate'])
- ->setTypes([TransactionType::DEPOSIT, TransactionType::TRANSFER])
+ ->setTypes([TransactionType::DEPOSIT, TransactionTypeEnum::TRANSFER->value])
->withAccountInformation()
->withBudgetInformation()
->withCategoryInformation()
diff --git a/app/Http/Controllers/Category/NoCategoryController.php b/app/Http/Controllers/Category/NoCategoryController.php
index a69318cd67..11e63f03d5 100644
--- a/app/Http/Controllers/Category/NoCategoryController.php
+++ b/app/Http/Controllers/Category/NoCategoryController.php
@@ -95,7 +95,7 @@ class NoCategoryController extends Controller
$collector->setRange($start, $end)
->setLimit($pageSize)->setPage($page)->withoutCategory()
->withAccountInformation()->withBudgetInformation()
- ->setTypes([TransactionTypeEnum::WITHDRAWAL->value, TransactionType::DEPOSIT, TransactionType::TRANSFER])
+ ->setTypes([TransactionTypeEnum::WITHDRAWAL->value, TransactionType::DEPOSIT, TransactionTypeEnum::TRANSFER->value])
;
$groups = $collector->getPaginatedGroups();
$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->setRange($start, $end)->setLimit($pageSize)->setPage($page)->withoutCategory()
->withAccountInformation()->withBudgetInformation()
- ->setTypes([TransactionTypeEnum::WITHDRAWAL->value, TransactionType::DEPOSIT, TransactionType::TRANSFER])
+ ->setTypes([TransactionTypeEnum::WITHDRAWAL->value, TransactionType::DEPOSIT, TransactionTypeEnum::TRANSFER->value])
;
$groups = $collector->getPaginatedGroups();
$groups->setPath(route('categories.no-category.all'));
diff --git a/app/Http/Controllers/Chart/TransactionController.php b/app/Http/Controllers/Chart/TransactionController.php
index 3b5421e162..5f05926c46 100644
--- a/app/Http/Controllers/Chart/TransactionController.php
+++ b/app/Http/Controllers/Chart/TransactionController.php
@@ -116,7 +116,7 @@ class TransactionController extends Controller
$collector->setTypes([TransactionType::DEPOSIT]);
}
if ('transfer' === $objectType || 'transfers' === $objectType) {
- $collector->setTypes([TransactionType::TRANSFER]);
+ $collector->setTypes([TransactionTypeEnum::TRANSFER->value]);
}
$result = $collector->getExtractedJournals();
@@ -166,7 +166,7 @@ class TransactionController extends Controller
$collector->setTypes([TransactionType::DEPOSIT]);
}
if ('transfer' === $objectType || 'transfers' === $objectType) {
- $collector->setTypes([TransactionType::TRANSFER]);
+ $collector->setTypes([TransactionTypeEnum::TRANSFER->value]);
}
$result = $collector->getExtractedJournals();
@@ -216,7 +216,7 @@ class TransactionController extends Controller
$collector->setTypes([TransactionType::DEPOSIT]);
}
if ('transfer' === $objectType || 'transfers' === $objectType) {
- $collector->setTypes([TransactionType::TRANSFER]);
+ $collector->setTypes([TransactionTypeEnum::TRANSFER->value]);
}
$result = $collector->getExtractedJournals();
diff --git a/app/Http/Controllers/Json/ReconcileController.php b/app/Http/Controllers/Json/ReconcileController.php
index 38c29896f3..b1987512a7 100644
--- a/app/Http/Controllers/Json/ReconcileController.php
+++ b/app/Http/Controllers/Json/ReconcileController.php
@@ -25,6 +25,7 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Json;
use Carbon\Carbon;
+use FireflyIII\Enums\TransactionTypeEnum;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Http\Controllers\Controller;
@@ -245,7 +246,7 @@ class ReconcileController extends Controller
$inverse = true;
}
// 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;
}
diff --git a/app/Http/Controllers/Transaction/ConvertController.php b/app/Http/Controllers/Transaction/ConvertController.php
index b7cd58506c..567a60f7ec 100644
--- a/app/Http/Controllers/Transaction/ConvertController.php
+++ b/app/Http/Controllers/Transaction/ConvertController.php
@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Transaction;
use Exception;
+use FireflyIII\Enums\TransactionTypeEnum;
use FireflyIII\Events\UpdatedTransactionGroup;
use FireflyIII\Exceptions\FireflyException;
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.
- 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);
$sourceCurrency = $this->accountRepository->getAccountCurrency($source);
$dest = $this->accountRepository->find((int) $destinationId);
diff --git a/app/Http/Requests/RecurrenceFormRequest.php b/app/Http/Requests/RecurrenceFormRequest.php
index 81e012e4e0..ebf53aa466 100644
--- a/app/Http/Requests/RecurrenceFormRequest.php
+++ b/app/Http/Requests/RecurrenceFormRequest.php
@@ -252,7 +252,7 @@ class RecurrenceFormRequest extends FormRequest
$rules['source_name'] = 'min:1|max:255|nullable';
$rules['destination_id'] = 'required|exists:accounts,id|belongsToUser:accounts';
}
- if (strtolower(TransactionType::TRANSFER) === $type) {
+ if (strtolower(TransactionTypeEnum::TRANSFER->value) === $type) {
// this may not work:
$rules['source_id'] = 'required|exists:accounts,id|belongsToUser:accounts|different:destination_id';
$rules['destination_id'] = 'required|exists:accounts,id|belongsToUser:accounts|different:source_id';
diff --git a/app/Models/TransactionJournal.php b/app/Models/TransactionJournal.php
index 01f49bd228..edbd2c4360 100644
--- a/app/Models/TransactionJournal.php
+++ b/app/Models/TransactionJournal.php
@@ -25,6 +25,7 @@ namespace FireflyIII\Models;
use Carbon\Carbon;
use FireflyIII\Casts\SeparateTimezoneCaster;
+use FireflyIII\Enums\TransactionTypeEnum;
use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
use FireflyIII\Support\Models\ReturnsIntegerUserIdTrait;
use FireflyIII\User;
@@ -143,7 +144,7 @@ class TransactionJournal extends Model
public function isTransfer(): bool
{
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();
diff --git a/app/Repositories/Account/AccountTasker.php b/app/Repositories/Account/AccountTasker.php
index 65a3138e14..fabf36eb54 100644
--- a/app/Repositories/Account/AccountTasker.php
+++ b/app/Repositories/Account/AccountTasker.php
@@ -122,7 +122,7 @@ class AccountTasker implements AccountTaskerInterface
$collector->setSourceAccounts($accounts)->setRange($start, $end);
$collector->excludeDestinationAccounts($accounts);
- $collector->setTypes([TransactionTypeEnum::WITHDRAWAL->value, TransactionType::TRANSFER])->withAccountInformation();
+ $collector->setTypes([TransactionTypeEnum::WITHDRAWAL->value, TransactionTypeEnum::TRANSFER->value])->withAccountInformation();
$journals = $collector->getExtractedJournals();
$report = $this->groupExpenseByDestination($journals);
@@ -212,7 +212,7 @@ class AccountTasker implements AccountTaskerInterface
$collector = app(GroupCollectorInterface::class);
$collector->setDestinationAccounts($accounts)->setRange($start, $end);
$collector->excludeSourceAccounts($accounts);
- $collector->setTypes([TransactionType::DEPOSIT, TransactionType::TRANSFER])->withAccountInformation();
+ $collector->setTypes([TransactionType::DEPOSIT, TransactionTypeEnum::TRANSFER->value])->withAccountInformation();
$report = $this->groupIncomeBySource($collector->getExtractedJournals());
// sort the result
diff --git a/app/Repositories/Category/NoCategoryRepository.php b/app/Repositories/Category/NoCategoryRepository.php
index 91dd8e1eb2..9717277f1b 100644
--- a/app/Repositories/Category/NoCategoryRepository.php
+++ b/app/Repositories/Category/NoCategoryRepository.php
@@ -192,7 +192,7 @@ class NoCategoryRepository implements NoCategoryRepositoryInterface
{
/** @var GroupCollectorInterface $collector */
$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) {
$collector->setAccounts($accounts);
diff --git a/app/Repositories/Category/OperationsRepository.php b/app/Repositories/Category/OperationsRepository.php
index 1fea7b9813..78641dff2c 100644
--- a/app/Repositories/Category/OperationsRepository.php
+++ b/app/Repositories/Category/OperationsRepository.php
@@ -200,7 +200,7 @@ class OperationsRepository implements OperationsRepositoryInterface
{
/** @var GroupCollectorInterface $collector */
$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)
;
if (null !== $categories && $categories->count() > 0) {
@@ -263,7 +263,7 @@ class OperationsRepository implements OperationsRepositoryInterface
{
/** @var GroupCollectorInterface $collector */
$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)
;
if (null !== $categories && $categories->count() > 0) {
@@ -422,7 +422,7 @@ class OperationsRepository implements OperationsRepositoryInterface
/** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class);
$collector->setUser($this->user)->setRange($start, $end)
- ->setTypes([TransactionType::TRANSFER])
+ ->setTypes([TransactionTypeEnum::TRANSFER->value])
;
if (null !== $accounts && $accounts->count() > 0) {
diff --git a/app/Repositories/Tag/TagRepository.php b/app/Repositories/Tag/TagRepository.php
index 3f6af13c8a..e1539f840e 100644
--- a/app/Repositories/Tag/TagRepository.php
+++ b/app/Repositories/Tag/TagRepository.php
@@ -268,7 +268,7 @@ class TagRepository implements TagRepositoryInterface
'currency_decimal_places' => $journal['currency_decimal_places'],
TransactionTypeEnum::WITHDRAWAL->value => '0',
TransactionType::DEPOSIT => '0',
- TransactionType::TRANSFER => '0',
+ TransactionTypeEnum::TRANSFER->value => '0',
TransactionType::RECONCILIATION => '0',
TransactionType::OPENING_BALANCE => '0',
];
@@ -290,7 +290,7 @@ class TagRepository implements TagRepositoryInterface
'currency_decimal_places' => $journal['foreign_currency_decimal_places'],
TransactionTypeEnum::WITHDRAWAL->value => '0',
TransactionType::DEPOSIT => '0',
- TransactionType::TRANSFER => '0',
+ TransactionTypeEnum::TRANSFER->value => '0',
TransactionType::RECONCILIATION => '0',
TransactionType::OPENING_BALANCE => '0',
];
@@ -325,7 +325,7 @@ class TagRepository implements TagRepositoryInterface
/** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class);
$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();
}
diff --git a/app/Rules/IsTransferAccount.php b/app/Rules/IsTransferAccount.php
index 8c255d5405..8a825ebd02 100644
--- a/app/Rules/IsTransferAccount.php
+++ b/app/Rules/IsTransferAccount.php
@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Rules;
+use FireflyIII\Enums\TransactionTypeEnum;
use FireflyIII\Models\TransactionType;
use FireflyIII\Validation\AccountValidator;
use Illuminate\Contracts\Validation\ValidationRule;
@@ -42,7 +43,7 @@ class IsTransferAccount implements ValidationRule
/** @var AccountValidator $validator */
$validator = app(AccountValidator::class);
- $validator->setTransactionType(TransactionType::TRANSFER);
+ $validator->setTransactionType(TransactionTypeEnum::TRANSFER->value);
$validator->setUser(auth()->user());
$validAccount = $validator->validateSource(['name' => (string) $value]);
diff --git a/app/Services/Internal/Support/CreditRecalculateService.php b/app/Services/Internal/Support/CreditRecalculateService.php
index c6aba98736..f4635d839a 100644
--- a/app/Services/Internal/Support/CreditRecalculateService.php
+++ b/app/Services/Internal/Support/CreditRecalculateService.php
@@ -343,7 +343,7 @@ class CreditRecalculateService
}
// 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);
return bcadd($leftOfDebt, $usedAmount);
@@ -437,7 +437,7 @@ class CreditRecalculateService
*/
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
{
- return TransactionType::TRANSFER === $transactionType && -1 === bccomp($amount, '0');
+ return TransactionTypeEnum::TRANSFER->value === $transactionType && -1 === bccomp($amount, '0');
}
public function setAccount(?Account $account): void
diff --git a/app/Services/Internal/Update/JournalUpdateService.php b/app/Services/Internal/Update/JournalUpdateService.php
index 391f36e29f..cacf78be5a 100644
--- a/app/Services/Internal/Update/JournalUpdateService.php
+++ b/app/Services/Internal/Update/JournalUpdateService.php
@@ -533,7 +533,7 @@ class JournalUpdateService
$this->storeBudget($this->transactionJournal, new NullArrayObject($this->data));
}
// is transfer? remove budget
- if (TransactionType::TRANSFER === $this->transactionJournal->transactionType->type) {
+ if (TransactionTypeEnum::TRANSFER->value === $this->transactionJournal->transactionType->type) {
$this->transactionJournal->budgets()->sync([]);
}
}
diff --git a/app/Support/Binder/JournalList.php b/app/Support/Binder/JournalList.php
index 9273da95d6..3b79c72bb1 100644
--- a/app/Support/Binder/JournalList.php
+++ b/app/Support/Binder/JournalList.php
@@ -45,7 +45,7 @@ class JournalList implements BinderInterface
// get the journals by using the collector.
/** @var GroupCollectorInterface $collector */
$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->setJournalIds($list);
$result = $collector->getExtractedJournals();
diff --git a/app/Support/Http/Api/AccountBalanceGrouped.php b/app/Support/Http/Api/AccountBalanceGrouped.php
index b1c97d0883..165d747878 100644
--- a/app/Support/Http/Api/AccountBalanceGrouped.php
+++ b/app/Support/Http/Api/AccountBalanceGrouped.php
@@ -25,6 +25,7 @@ declare(strict_types=1);
namespace FireflyIII\Support\Http\Api;
use Carbon\Carbon;
+use FireflyIII\Enums\TransactionTypeEnum;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\TransactionCurrency;
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::OPENING_BALANCE === $journal['transaction_type_type']
)
diff --git a/app/Support/Http/Api/TransactionFilter.php b/app/Support/Http/Api/TransactionFilter.php
index 75fff67756..06ea12a40f 100644
--- a/app/Support/Http/Api/TransactionFilter.php
+++ b/app/Support/Http/Api/TransactionFilter.php
@@ -41,7 +41,7 @@ trait TransactionFilter
'all' => [
TransactionTypeEnum::WITHDRAWAL->value,
TransactionType::DEPOSIT,
- TransactionType::TRANSFER,
+ TransactionTypeEnum::TRANSFER->value,
TransactionType::OPENING_BALANCE,
TransactionType::RECONCILIATION,
],
@@ -52,14 +52,14 @@ trait TransactionFilter
'income' => [TransactionType::DEPOSIT],
'deposit' => [TransactionType::DEPOSIT],
'deposits' => [TransactionType::DEPOSIT],
- 'transfer' => [TransactionType::TRANSFER],
- 'transfers' => [TransactionType::TRANSFER],
+ 'transfer' => [TransactionTypeEnum::TRANSFER->value],
+ 'transfers' => [TransactionTypeEnum::TRANSFER->value],
'opening_balance' => [TransactionType::OPENING_BALANCE],
'reconciliation' => [TransactionType::RECONCILIATION],
'reconciliations' => [TransactionType::RECONCILIATION],
'special' => [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 = [];
$parts = explode(',', $type);
diff --git a/app/Support/Http/Controllers/PeriodOverview.php b/app/Support/Http/Controllers/PeriodOverview.php
index d6aead03b7..33797ca496 100644
--- a/app/Support/Http/Controllers/PeriodOverview.php
+++ b/app/Support/Http/Controllers/PeriodOverview.php
@@ -114,7 +114,7 @@ trait PeriodOverview
$collector = app(GroupCollectorInterface::class);
$collector->setAccounts(new Collection([$account]));
$collector->setRange($start, $end);
- $collector->setTypes([TransactionType::TRANSFER]);
+ $collector->setTypes([TransactionTypeEnum::TRANSFER->value]);
$transferSet = $collector->getExtractedJournals();
// loop dates
@@ -288,7 +288,7 @@ trait PeriodOverview
$collector = app(GroupCollectorInterface::class);
$collector->setCategory($category);
$collector->setRange($start, $end);
- $collector->setTypes([TransactionType::TRANSFER]);
+ $collector->setTypes([TransactionTypeEnum::TRANSFER->value]);
$transferSet = $collector->getExtractedJournals();
foreach ($dates as $currentDate) {
$spent = $this->filterJournalsByDate($spentSet, $currentDate['start'], $currentDate['end']);
@@ -410,7 +410,7 @@ trait PeriodOverview
$collector = app(GroupCollectorInterface::class);
$collector->withoutCategory();
$collector->setRange($start, $end);
- $collector->setTypes([TransactionType::TRANSFER]);
+ $collector->setTypes([TransactionTypeEnum::TRANSFER->value]);
$transferSet = $collector->getExtractedJournals();
/** @var array $currentDate */
@@ -479,7 +479,7 @@ trait PeriodOverview
$collector = app(GroupCollectorInterface::class);
$collector->setTag($tag);
$collector->setRange($start, $end);
- $collector->setTypes([TransactionType::TRANSFER]);
+ $collector->setTypes([TransactionTypeEnum::TRANSFER->value]);
$transferSet = $collector->getExtractedJournals();
// filer all of them:
diff --git a/app/Support/Http/Controllers/TransactionCalculation.php b/app/Support/Http/Controllers/TransactionCalculation.php
index 6de7a01bf2..e869a0608f 100644
--- a/app/Support/Http/Controllers/TransactionCalculation.php
+++ b/app/Support/Http/Controllers/TransactionCalculation.php
@@ -61,7 +61,7 @@ trait TransactionCalculation
/** @var GroupCollectorInterface $collector */
$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()
;
@@ -75,7 +75,7 @@ trait TransactionCalculation
{
/** @var GroupCollectorInterface $collector */
$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()
;
@@ -92,7 +92,7 @@ trait TransactionCalculation
$collector
->setAccounts($accounts)
->setRange($start, $end)
- ->setTypes([TransactionTypeEnum::WITHDRAWAL->value, TransactionType::TRANSFER])
+ ->setTypes([TransactionTypeEnum::WITHDRAWAL->value, TransactionTypeEnum::TRANSFER->value])
->setCategories($categories)
->withAccountInformation()
;
@@ -107,7 +107,7 @@ trait TransactionCalculation
{
/** @var GroupCollectorInterface $collector */
$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()
;
@@ -135,7 +135,7 @@ trait TransactionCalculation
{
/** @var GroupCollectorInterface $collector */
$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()
;
diff --git a/app/Support/Http/Controllers/UserNavigation.php b/app/Support/Http/Controllers/UserNavigation.php
index 8a9c4c7d78..9eb9a0dbd8 100644
--- a/app/Support/Http/Controllers/UserNavigation.php
+++ b/app/Support/Http/Controllers/UserNavigation.php
@@ -75,7 +75,7 @@ trait UserNavigation
return false;
}
$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);
}
diff --git a/app/Support/Twig/TransactionGroupTwig.php b/app/Support/Twig/TransactionGroupTwig.php
index 7a2ce23415..c00b5b1a67 100644
--- a/app/Support/Twig/TransactionGroupTwig.php
+++ b/app/Support/Twig/TransactionGroupTwig.php
@@ -83,12 +83,12 @@ class TransactionGroupTwig extends AbstractExtension
$sourceType = $array['source_account_type'] ?? 'invalid';
$amount = $this->signAmount($amount, $type, $sourceType);
- if (TransactionType::TRANSFER === $type) {
+ if (TransactionTypeEnum::TRANSFER->value === $type) {
$colored = false;
}
$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('%s', $result);
}
@@ -127,11 +127,11 @@ class TransactionGroupTwig extends AbstractExtension
$sourceType = $array['source_account_type'] ?? 'invalid';
$amount = $this->signAmount($amount, $type, $sourceType);
- if (TransactionType::TRANSFER === $type) {
+ if (TransactionTypeEnum::TRANSFER->value === $type) {
$colored = false;
}
$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('%s', $result);
}
@@ -173,11 +173,11 @@ class TransactionGroupTwig extends AbstractExtension
$amount = $this->signAmount($amount, $type, $sourceType);
- if (TransactionType::TRANSFER === $type) {
+ if (TransactionTypeEnum::TRANSFER->value === $type) {
$colored = false;
}
$result = app('amount')->formatFlat($currency->symbol, $currency->decimal_places, $amount, $colored);
- if (TransactionType::TRANSFER === $type) {
+ if (TransactionTypeEnum::TRANSFER->value === $type) {
$result = sprintf('%s', $result);
}
@@ -208,11 +208,11 @@ class TransactionGroupTwig extends AbstractExtension
$amount = $this->signAmount($amount, $type, $sourceType);
- if (TransactionType::TRANSFER === $type) {
+ if (TransactionTypeEnum::TRANSFER->value === $type) {
$colored = false;
}
$result = app('amount')->formatFlat($currency->symbol, $currency->decimal_places, $amount, $colored);
- if (TransactionType::TRANSFER === $type) {
+ if (TransactionTypeEnum::TRANSFER->value === $type) {
$result = sprintf('%s', $result);
}
diff --git a/app/TransactionRules/Actions/ConvertToDeposit.php b/app/TransactionRules/Actions/ConvertToDeposit.php
index 18b5fe88fb..21ec9accce 100644
--- a/app/TransactionRules/Actions/ConvertToDeposit.php
+++ b/app/TransactionRules/Actions/ConvertToDeposit.php
@@ -99,7 +99,7 @@ class ConvertToDeposit implements ActionInterface
return $res;
}
- if (TransactionType::TRANSFER === $type) {
+ if (TransactionTypeEnum::TRANSFER->value === $type) {
app('log')->debug('Going to transform a transfer to a deposit.');
try {
@@ -111,7 +111,7 @@ class ConvertToDeposit implements ActionInterface
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;
}
diff --git a/app/TransactionRules/Actions/ConvertToTransfer.php b/app/TransactionRules/Actions/ConvertToTransfer.php
index 05799d127c..ac32deda33 100644
--- a/app/TransactionRules/Actions/ConvertToTransfer.php
+++ b/app/TransactionRules/Actions/ConvertToTransfer.php
@@ -79,7 +79,7 @@ class ConvertToTransfer implements ActionInterface
$type = $object->transactionType->type;
$user = $object->user;
$journalId = $object->id;
- if (TransactionType::TRANSFER === $type) {
+ if (TransactionTypeEnum::TRANSFER->value === $type) {
app('log')->error(
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;
}
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;
@@ -154,7 +154,7 @@ class ConvertToTransfer implements ActionInterface
return false;
}
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;
@@ -216,7 +216,7 @@ class ConvertToTransfer implements ActionInterface
;
// change transaction type of journal:
- $newType = TransactionType::whereType(TransactionType::TRANSFER)->first();
+ $newType = TransactionType::whereType(TransactionTypeEnum::TRANSFER->value)->first();
\DB::table('transaction_journals')
->where('id', '=', $journal->id)
@@ -271,7 +271,7 @@ class ConvertToTransfer implements ActionInterface
;
// change transaction type of journal:
- $newType = TransactionType::whereType(TransactionType::TRANSFER)->first();
+ $newType = TransactionType::whereType(TransactionTypeEnum::TRANSFER->value)->first();
\DB::table('transaction_journals')
->where('id', '=', $journal->id)
diff --git a/app/TransactionRules/Actions/ConvertToWithdrawal.php b/app/TransactionRules/Actions/ConvertToWithdrawal.php
index f8d417906c..56d1736334 100644
--- a/app/TransactionRules/Actions/ConvertToWithdrawal.php
+++ b/app/TransactionRules/Actions/ConvertToWithdrawal.php
@@ -80,7 +80,7 @@ class ConvertToWithdrawal implements ActionInterface
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])));
return false;
@@ -113,7 +113,7 @@ class ConvertToWithdrawal implements ActionInterface
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;
}
diff --git a/app/TransactionRules/Actions/SetDestinationAccount.php b/app/TransactionRules/Actions/SetDestinationAccount.php
index 8a78661d91..3cf936a9df 100644
--- a/app/TransactionRules/Actions/SetDestinationAccount.php
+++ b/app/TransactionRules/Actions/SetDestinationAccount.php
@@ -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:
$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(
sprintf(
'Cant change destination account of journal #%d because no asset account with name "%s" exists.',
diff --git a/app/TransactionRules/Actions/SetSourceAccount.php b/app/TransactionRules/Actions/SetSourceAccount.php
index 830518db90..f5c0e58b88 100644
--- a/app/TransactionRules/Actions/SetSourceAccount.php
+++ b/app/TransactionRules/Actions/SetSourceAccount.php
@@ -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:
$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(
sprintf('Cant change source account of journal #%d because no asset account with name "%s" exists.', $object->id, $accountName)
);
diff --git a/app/TransactionRules/Actions/SwitchAccounts.php b/app/TransactionRules/Actions/SwitchAccounts.php
index e9928d7108..4ec66d0d06 100644
--- a/app/TransactionRules/Actions/SwitchAccounts.php
+++ b/app/TransactionRules/Actions/SwitchAccounts.php
@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\TransactionRules\Actions;
+use FireflyIII\Enums\TransactionTypeEnum;
use FireflyIII\Events\Model\Rule\RuleActionFailedOnArray;
use FireflyIII\Events\TriggeredAuditLog;
use FireflyIII\Models\RuleAction;
@@ -66,7 +67,7 @@ class SwitchAccounts implements ActionInterface
}
$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));
event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.is_not_transfer')));
diff --git a/app/Validation/AccountValidator.php b/app/Validation/AccountValidator.php
index b14b7d665a..267564b5ea 100644
--- a/app/Validation/AccountValidator.php
+++ b/app/Validation/AccountValidator.php
@@ -151,7 +151,7 @@ class AccountValidator
break;
- case TransactionType::TRANSFER:
+ case TransactionTypeEnum::TRANSFER->value:
$result = $this->validateTransferDestination($array);
break;
@@ -196,7 +196,7 @@ class AccountValidator
break;
- case TransactionType::TRANSFER:
+ case TransactionTypeEnum::TRANSFER->value:
$result = $this->validateTransferSource($array);
break;
diff --git a/app/Validation/TransactionValidation.php b/app/Validation/TransactionValidation.php
index 0822b5c0f0..9e1a66774f 100644
--- a/app/Validation/TransactionValidation.php
+++ b/app/Validation/TransactionValidation.php
@@ -260,7 +260,7 @@ trait TransactionValidation
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));
// use case: withdrawal from asset account to a liability account.
// the foreign amount must be in the currency of the destination