mirror of
				https://github.com/firefly-iii/firefly-iii.git
				synced 2025-11-03 20:55:05 +00:00 
			
		
		
		
	Replace enum
This commit is contained in:
		@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -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) {
 | 
			
		||||
 
 | 
			
		||||
@@ -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);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -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()
 | 
			
		||||
        ;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -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])
 | 
			
		||||
 
 | 
			
		||||
@@ -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()
 | 
			
		||||
 
 | 
			
		||||
@@ -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'));
 | 
			
		||||
 
 | 
			
		||||
@@ -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();
 | 
			
		||||
 
 | 
			
		||||
@@ -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;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -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);
 | 
			
		||||
 
 | 
			
		||||
@@ -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';
 | 
			
		||||
 
 | 
			
		||||
@@ -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();
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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);
 | 
			
		||||
 
 | 
			
		||||
@@ -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) {
 | 
			
		||||
 
 | 
			
		||||
@@ -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();
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -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]);
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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([]);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -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();
 | 
			
		||||
 
 | 
			
		||||
@@ -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']
 | 
			
		||||
                )
 | 
			
		||||
 
 | 
			
		||||
@@ -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);
 | 
			
		||||
 
 | 
			
		||||
@@ -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:
 | 
			
		||||
 
 | 
			
		||||
@@ -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()
 | 
			
		||||
        ;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -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);
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -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('<span class="text-info money-transfer">%s</span>', $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('<span class="text-info money-transfer">%s</span>', $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('<span class="text-info money-transfer">%s</span>', $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('<span class="text-info money-transfer">%s</span>', $result);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -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;
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -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)
 | 
			
		||||
 
 | 
			
		||||
@@ -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;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -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.',
 | 
			
		||||
 
 | 
			
		||||
@@ -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)
 | 
			
		||||
            );
 | 
			
		||||
 
 | 
			
		||||
@@ -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')));
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -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;
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user