mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Replace enum
This commit is contained in:
@@ -82,7 +82,7 @@ class ConvertsDatesToUTC extends Command
|
||||
* @var string $model
|
||||
* @var array $fields
|
||||
*/
|
||||
foreach (AddTimezonesToDates::$models as $model => $fields) {
|
||||
foreach (CorrectsTimezoneInformation::$models as $model => $fields) {
|
||||
$this->ConvertModeltoUTC($model, $fields);
|
||||
}
|
||||
// tell the system we are now in UTC mode.
|
||||
|
@@ -26,6 +26,7 @@ namespace FireflyIII\Console\Commands\Correction;
|
||||
|
||||
use FireflyIII\Console\Commands\ShowsFriendlyMessages;
|
||||
use FireflyIII\Enums\AccountTypeEnum;
|
||||
use FireflyIII\Enums\TransactionTypeEnum;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Factory\AccountFactory;
|
||||
use FireflyIII\Models\AccountType;
|
||||
@@ -256,7 +257,7 @@ class CorrectsAccountTypes extends Command
|
||||
private function makeTransfer(TransactionJournal $journal): void
|
||||
{
|
||||
// from an asset to a liability should be a withdrawal:
|
||||
$withdrawal = TransactionType::whereType(TransactionType::WITHDRAWAL)->first();
|
||||
$withdrawal = TransactionType::whereType(TransactionTypeEnum::WITHDRAWAL->value)->first();
|
||||
$journal->transactionType()->associate($withdrawal);
|
||||
$journal->save();
|
||||
$message = sprintf('Converted transaction #%d from a transfer to a withdrawal.', $journal->id);
|
||||
@@ -286,7 +287,7 @@ class CorrectsAccountTypes extends Command
|
||||
|
||||
private function shouldGoToExpenseAccount(string $transactionType, string $sourceType, string $destinationType): bool
|
||||
{
|
||||
return TransactionType::WITHDRAWAL === $transactionType && AccountType::ASSET === $sourceType && AccountType::REVENUE === $destinationType;
|
||||
return TransactionTypeEnum::WITHDRAWAL->value === $transactionType && AccountType::ASSET === $sourceType && AccountType::REVENUE === $destinationType;
|
||||
}
|
||||
|
||||
private function makeExpenseDestination(TransactionJournal $journal, Transaction $destination): void
|
||||
|
@@ -25,6 +25,7 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Console\Commands\Correction;
|
||||
|
||||
use FireflyIII\Console\Commands\ShowsFriendlyMessages;
|
||||
use FireflyIII\Enums\TransactionTypeEnum;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Models\TransactionType;
|
||||
use Illuminate\Console\Command;
|
||||
@@ -44,7 +45,7 @@ class CorrectsTransferBudgets extends Command
|
||||
$set = TransactionJournal::distinct()
|
||||
->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id')
|
||||
->leftJoin('budget_transaction_journal', 'transaction_journals.id', '=', 'budget_transaction_journal.transaction_journal_id')
|
||||
->whereNotIn('transaction_types.type', [TransactionType::WITHDRAWAL])
|
||||
->whereNotIn('transaction_types.type', [TransactionTypeEnum::WITHDRAWAL->value])
|
||||
->whereNotNull('budget_transaction_journal.budget_id')->get(['transaction_journals.*'])
|
||||
;
|
||||
$count = 0;
|
||||
|
@@ -25,6 +25,7 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Console\Commands\Correction;
|
||||
|
||||
use FireflyIII\Console\Commands\ShowsFriendlyMessages;
|
||||
use FireflyIII\Enums\TransactionTypeEnum;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Models\TransactionType;
|
||||
use Illuminate\Console\Command;
|
||||
@@ -42,7 +43,7 @@ class RemovesBills extends Command
|
||||
public function handle(): int
|
||||
{
|
||||
/** @var null|TransactionType $withdrawal */
|
||||
$withdrawal = TransactionType::where('type', TransactionType::WITHDRAWAL)->first();
|
||||
$withdrawal = TransactionType::where('type', TransactionTypeEnum::WITHDRAWAL->value)->first();
|
||||
if (null === $withdrawal) {
|
||||
return 0;
|
||||
}
|
||||
|
@@ -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\AccountType;
|
||||
use FireflyIII\Models\Transaction;
|
||||
@@ -103,7 +104,7 @@ class UpgradesVariousCurrencyInformation extends Command
|
||||
private function updateOtherJournalsCurrencies(): void
|
||||
{
|
||||
$set = $this->cliRepos->getAllJournals(
|
||||
[TransactionType::WITHDRAWAL, TransactionType::DEPOSIT, TransactionType::OPENING_BALANCE, TransactionType::RECONCILIATION]
|
||||
[TransactionTypeEnum::WITHDRAWAL->value, TransactionType::DEPOSIT, TransactionType::OPENING_BALANCE, TransactionType::RECONCILIATION]
|
||||
);
|
||||
|
||||
/** @var TransactionJournal $journal */
|
||||
@@ -180,7 +181,7 @@ class UpgradesVariousCurrencyInformation extends Command
|
||||
default:
|
||||
break;
|
||||
|
||||
case TransactionType::WITHDRAWAL:
|
||||
case TransactionTypeEnum::WITHDRAWAL->value:
|
||||
$lead = $journal->transactions()->where('amount', '<', 0)->first();
|
||||
|
||||
break;
|
||||
|
Reference in New Issue
Block a user