Fix and undo some enums

This commit is contained in:
James Cole 2024-11-06 19:32:32 +01:00
parent 8c5f114339
commit ed842c2b42
No known key found for this signature in database
GPG Key ID: B49A324B7EAD6D80
9 changed files with 64 additions and 48 deletions

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
/*
* AddTimezonesToDates.php
* Copyright (c) 2024 james@firefly-iii.org.
@ -60,7 +62,7 @@ class AddTimezonesToDates extends Command
/**
* Execute the console command.
*/
public function handle()
public function handle(): void
{
$models = [
AccountBalance::class => ['date'], // done
@ -90,9 +92,10 @@ class AddTimezonesToDates extends Command
private function addTimezoneToModelField(string $model, string $field): void
{
$shortModel = str_replace('FireflyIII\\Models\\','', $model);
$shortModel = str_replace('FireflyIII\Models\\', '', $model);
$timezoneField = sprintf('%s_tz', $field);
$items = new Collection();
try {
$items = $model::whereNull($timezoneField)->get();
} catch (QueryException $e) {
@ -101,6 +104,7 @@ class AddTimezonesToDates extends Command
}
if (0 === $items->count()) {
$this->friendlyPositive(sprintf('Timezone is present in field "%s" of model "%s".', $field, $shortModel));
return;
}
$this->friendlyInfo(sprintf('Adding timezone to field "%s" of model "%s".', $field, $shortModel));

View File

@ -35,19 +35,33 @@ class AccountType extends Model
{
use ReturnsIntegerIdTrait;
/** @deprecated */
public const string ASSET = 'Asset account';
/** @deprecated */
public const string BENEFICIARY = 'Beneficiary account';
/** @deprecated */
public const string CASH = 'Cash account';
/** @deprecated */
public const string CREDITCARD = 'Credit card';
/** @deprecated */
public const string DEBT = 'Debt';
/** @deprecated */
public const string DEFAULT = 'Default account';
/** @deprecated */
public const string EXPENSE = 'Expense account';
/** @deprecated */
public const string IMPORT = 'Import account';
/** @deprecated */
public const string INITIAL_BALANCE = 'Initial balance account';
/** @deprecated */
public const string LIABILITY_CREDIT = 'Liability credit account';
/** @deprecated */
public const string LOAN = 'Loan';
/** @deprecated */
public const string MORTGAGE = 'Mortgage';
/** @deprecated */
public const string RECONCILIATION = 'Reconciliation account';
/** @deprecated */
public const string REVENUE = 'Revenue account';
protected $casts

View File

@ -24,7 +24,6 @@ declare(strict_types=1);
namespace FireflyIII\Models;
use FireflyIII\Enums\AccountTypeEnum;
use FireflyIII\Enums\AutoBudgetType;
use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
use Illuminate\Database\Eloquent\Casts\Attribute;

View File

@ -23,7 +23,6 @@ declare(strict_types=1);
namespace FireflyIII\Models;
use FireflyIII\Enums\AccountTypeEnum;
use FireflyIII\Enums\RecurrenceRepetitionWeekend;
use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
use Illuminate\Database\Eloquent\Casts\Attribute;

View File

@ -54,7 +54,6 @@ class TransactionType extends Model
];
protected $fillable = ['type'];
protected function casts(): array
{
return [
@ -62,7 +61,6 @@ class TransactionType extends Model
];
}
/**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
*

View File

@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Support\Http\Api;
use FireflyIII\Enums\AccountTypeEnum;
use FireflyIII\Models\AccountType;
/**
@ -32,7 +33,7 @@ trait AccountFilter
{
protected array $types = [
'all' => [
AccountType::DEFAULT,
AccountTypeEnum::DEFAULT->value,
AccountType::CASH,
AccountType::ASSET,
AccountType::EXPENSE,

View File

@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Support\Http\Controllers;
use FireflyIII\Enums\AccountTypeEnum;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\AccountType;
use FireflyIII\Models\Bill;
@ -84,9 +85,9 @@ trait ModelInformation
/** @var AccountType $mortgage */
$mortgage = $repository->getAccountTypeByType(AccountType::MORTGAGE);
$liabilityTypes = [
$debt->id => (string)trans(sprintf('firefly.account_type_%s', AccountType::DEBT)),
$loan->id => (string)trans(sprintf('firefly.account_type_%s', AccountType::LOAN)),
$mortgage->id => (string)trans(sprintf('firefly.account_type_%s', AccountType::MORTGAGE)),
$debt->id => (string)trans(sprintf('firefly.account_type_%s', AccountTypeEnum::DEBT->value)),
$loan->id => (string)trans(sprintf('firefly.account_type_%s', AccountTypeEnum::LOAN->value)),
$mortgage->id => (string)trans(sprintf('firefly.account_type_%s', AccountTypeEnum::MORTGAGE->value)),
];
asort($liabilityTypes);