Restore enums, replace one to enforce php 8.1 compatibility.

This commit is contained in:
James Cole
2022-04-13 16:27:01 +02:00
parent 71d53fbda4
commit cfcf860438
7 changed files with 76 additions and 20 deletions

View File

@@ -49,6 +49,22 @@ use Illuminate\Support\Carbon;
*/ */
class AccountType extends Model class AccountType extends Model
{ {
public const ASSET = 'Asset account';
public const BENEFICIARY = 'Beneficiary account';
public const CASH = 'Cash account';
public const CREDITCARD = 'Credit card';
public const DEBT = 'Debt';
public const DEFAULT = 'Default account';
public const EXPENSE = 'Expense account';
public const IMPORT = 'Import account';
public const INITIAL_BALANCE = 'Initial balance account';
public const LIABILITY_CREDIT = 'Liability credit account';
public const LOAN = 'Loan';
public const MORTGAGE = 'Mortgage';
public const RECONCILIATION = 'Reconciliation account';
public const REVENUE = 'Revenue account';
/** /**
* The attributes that should be casted to native types. * The attributes that should be casted to native types.
* *

View File

@@ -64,6 +64,9 @@ use Illuminate\Support\Carbon;
*/ */
class AutoBudget extends Model class AutoBudget extends Model
{ {
public const AUTO_BUDGET_RESET = 1;
public const AUTO_BUDGET_ROLLOVER = 2;
use SoftDeletes; use SoftDeletes;
/** /**

View File

@@ -62,6 +62,12 @@ use Illuminate\Support\Carbon;
*/ */
class RecurrenceRepetition extends Model class RecurrenceRepetition extends Model
{ {
public const WEEKEND_DO_NOTHING = 1;
public const WEEKEND_SKIP_CREATION = 2;
public const WEEKEND_TO_FRIDAY = 3;
public const WEEKEND_TO_MONDAY = 4;
use SoftDeletes; use SoftDeletes;
/** /**

View File

@@ -56,6 +56,13 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
*/ */
class TransactionType extends Model class TransactionType extends Model
{ {
public const DEPOSIT = 'Deposit';
public const INVALID = 'Invalid';
public const LIABILITY_CREDIT = 'Liability credit';
public const OPENING_BALANCE = 'Opening balance';
public const RECONCILIATION = 'Reconciliation';
public const TRANSFER = 'Transfer';
public const WITHDRAWAL = 'Withdrawal';
use SoftDeletes; use SoftDeletes;
protected $casts protected $casts

View File

@@ -53,6 +53,16 @@ use Illuminate\Support\Carbon;
*/ */
class UserRole extends Model class UserRole extends Model
{ {
public const CHANGE_PIGGY_BANKS = 'change_piggies';
public const CHANGE_REPETITIONS = 'change_reps';
public const CHANGE_RULES = 'change_rules';
public const CHANGE_TRANSACTIONS = 'change_tx';
public const FULL = 'full';
public const OWNER = 'owner';
public const READ_ONLY = 'ro';
public const VIEW_REPORTS = 'view_reports';
protected $fillable = ['title']; protected $fillable = ['title'];
/** /**

View File

@@ -76,7 +76,19 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
*/ */
class Webhook extends Model class Webhook extends Model
{ {
// dont forget to update the config in firefly.php
public const DELIVERY_JSON = 300;
public const RESPONSE_ACCOUNTS = 210;
public const RESPONSE_NONE = 220;
public const RESPONSE_TRANSACTIONS = 200;
public const TRIGGER_DESTROY_TRANSACTION = 120;
public const TRIGGER_STORE_TRANSACTION = 100;
public const TRIGGER_UPDATE_TRANSACTION = 110;
use SoftDeletes; use SoftDeletes;
protected $casts protected $casts
= [ = [
'active' => 'boolean', 'active' => 'boolean',

View File

@@ -22,6 +22,7 @@
declare(strict_types=1); declare(strict_types=1);
use FireflyIII\Enums\TransactionTypeEnum;
use FireflyIII\Models\Account; use FireflyIII\Models\Account;
use FireflyIII\Models\AccountType; use FireflyIII\Models\AccountType;
use FireflyIII\Models\Attachment; use FireflyIII\Models\Attachment;
@@ -82,6 +83,7 @@ use FireflyIII\TransactionRules\Actions\SetSourceAccount;
use FireflyIII\TransactionRules\Actions\UpdatePiggybank; use FireflyIII\TransactionRules\Actions\UpdatePiggybank;
use FireflyIII\User; use FireflyIII\User;
/* /*
* DO NOT EDIT THIS FILE. IT IS AUTO GENERATED. * DO NOT EDIT THIS FILE. IT IS AUTO GENERATED.
* *
@@ -496,7 +498,7 @@ return [
'expected_source_types' => [ 'expected_source_types' => [
'source' => [ 'source' => [
TransactionTypeModel::WITHDRAWAL => [AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE], TransactionTypeModel::WITHDRAWAL => [AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE],
TransactionTypeModel::DEPOSIT => [AccountType::REVENUE, AccountType::CASH, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE], TransactionTypeEnum::DEPOSIT->value => [AccountType::REVENUE, AccountType::CASH, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE],
TransactionTypeModel::TRANSFER => [AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE], TransactionTypeModel::TRANSFER => [AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE],
TransactionTypeModel::OPENING_BALANCE => [AccountType::INITIAL_BALANCE, AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, TransactionTypeModel::OPENING_BALANCE => [AccountType::INITIAL_BALANCE, AccountType::ASSET, AccountType::LOAN, AccountType::DEBT,
AccountType::MORTGAGE,], AccountType::MORTGAGE,],
@@ -515,7 +517,7 @@ return [
'destination' => [ 'destination' => [
TransactionTypeModel::WITHDRAWAL => [AccountType::EXPENSE, AccountType::CASH, AccountType::LOAN, AccountType::DEBT, TransactionTypeModel::WITHDRAWAL => [AccountType::EXPENSE, AccountType::CASH, AccountType::LOAN, AccountType::DEBT,
AccountType::MORTGAGE,], AccountType::MORTGAGE,],
TransactionTypeModel::DEPOSIT => [AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE], TransactionTypeEnum::DEPOSIT->value => [AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE],
TransactionTypeModel::TRANSFER => [AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE], TransactionTypeModel::TRANSFER => [AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE],
TransactionTypeModel::OPENING_BALANCE => [AccountType::INITIAL_BALANCE, AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, TransactionTypeModel::OPENING_BALANCE => [AccountType::INITIAL_BALANCE, AccountType::ASSET, AccountType::LOAN, AccountType::DEBT,
AccountType::MORTGAGE,], AccountType::MORTGAGE,],
@@ -564,27 +566,27 @@ return [
AccountType::ASSET => [TransactionTypeModel::WITHDRAWAL, TransactionTypeModel::TRANSFER, TransactionTypeModel::OPENING_BALANCE, AccountType::ASSET => [TransactionTypeModel::WITHDRAWAL, TransactionTypeModel::TRANSFER, TransactionTypeModel::OPENING_BALANCE,
TransactionTypeModel::RECONCILIATION,], TransactionTypeModel::RECONCILIATION,],
AccountType::EXPENSE => [], // is not allowed as a source. AccountType::EXPENSE => [], // is not allowed as a source.
AccountType::REVENUE => [TransactionTypeModel::DEPOSIT], AccountType::REVENUE => [TransactionTypeEnum::DEPOSIT->value],
AccountType::LOAN => [TransactionTypeModel::WITHDRAWAL, TransactionTypeModel::DEPOSIT, TransactionTypeModel::TRANSFER, AccountType::LOAN => [TransactionTypeModel::WITHDRAWAL, TransactionTypeEnum::DEPOSIT->value, TransactionTypeModel::TRANSFER,
TransactionTypeModel::OPENING_BALANCE, TransactionTypeModel::LIABILITY_CREDIT], TransactionTypeModel::OPENING_BALANCE, TransactionTypeModel::LIABILITY_CREDIT],
AccountType::DEBT => [TransactionTypeModel::WITHDRAWAL, TransactionTypeModel::DEPOSIT, TransactionTypeModel::TRANSFER, AccountType::DEBT => [TransactionTypeModel::WITHDRAWAL, TransactionTypeEnum::DEPOSIT->value, TransactionTypeModel::TRANSFER,
TransactionTypeModel::OPENING_BALANCE, TransactionTypeModel::LIABILITY_CREDIT], TransactionTypeModel::OPENING_BALANCE, TransactionTypeModel::LIABILITY_CREDIT],
AccountType::MORTGAGE => [TransactionTypeModel::WITHDRAWAL, TransactionTypeModel::DEPOSIT, TransactionTypeModel::TRANSFER, AccountType::MORTGAGE => [TransactionTypeModel::WITHDRAWAL, TransactionTypeEnum::DEPOSIT->value, TransactionTypeModel::TRANSFER,
TransactionTypeModel::OPENING_BALANCE, TransactionTypeModel::LIABILITY_CREDIT], TransactionTypeModel::OPENING_BALANCE, TransactionTypeModel::LIABILITY_CREDIT],
AccountType::INITIAL_BALANCE => [TransactionTypeModel::OPENING_BALANCE], AccountType::INITIAL_BALANCE => [TransactionTypeModel::OPENING_BALANCE],
AccountType::RECONCILIATION => [TransactionTypeModel::RECONCILIATION], AccountType::RECONCILIATION => [TransactionTypeModel::RECONCILIATION],
AccountType::LIABILITY_CREDIT => [TransactionTypeModel::LIABILITY_CREDIT], AccountType::LIABILITY_CREDIT => [TransactionTypeModel::LIABILITY_CREDIT],
], ],
'destination' => [ 'destination' => [
AccountType::ASSET => [TransactionTypeModel::DEPOSIT, TransactionTypeModel::TRANSFER, TransactionTypeModel::OPENING_BALANCE, AccountType::ASSET => [TransactionTypeEnum::DEPOSIT->value, TransactionTypeModel::TRANSFER, TransactionTypeModel::OPENING_BALANCE,
TransactionTypeModel::RECONCILIATION,], TransactionTypeModel::RECONCILIATION,],
AccountType::EXPENSE => [TransactionTypeModel::WITHDRAWAL], AccountType::EXPENSE => [TransactionTypeModel::WITHDRAWAL],
AccountType::REVENUE => [], // is not allowed as destination. AccountType::REVENUE => [], // is not allowed as destination.
AccountType::LOAN => [TransactionTypeModel::WITHDRAWAL, TransactionTypeModel::DEPOSIT, TransactionTypeModel::TRANSFER, AccountType::LOAN => [TransactionTypeModel::WITHDRAWAL, TransactionTypeEnum::DEPOSIT->value, TransactionTypeModel::TRANSFER,
TransactionTypeModel::OPENING_BALANCE,], TransactionTypeModel::OPENING_BALANCE,],
AccountType::DEBT => [TransactionTypeModel::WITHDRAWAL, TransactionTypeModel::DEPOSIT, TransactionTypeModel::TRANSFER, AccountType::DEBT => [TransactionTypeModel::WITHDRAWAL, TransactionTypeEnum::DEPOSIT->value, TransactionTypeModel::TRANSFER,
TransactionTypeModel::OPENING_BALANCE,], TransactionTypeModel::OPENING_BALANCE,],
AccountType::MORTGAGE => [TransactionTypeModel::WITHDRAWAL, TransactionTypeModel::DEPOSIT, TransactionTypeModel::TRANSFER, AccountType::MORTGAGE => [TransactionTypeModel::WITHDRAWAL, TransactionTypeEnum::DEPOSIT->value, TransactionTypeModel::TRANSFER,
TransactionTypeModel::OPENING_BALANCE,], TransactionTypeModel::OPENING_BALANCE,],
AccountType::INITIAL_BALANCE => [TransactionTypeModel::OPENING_BALANCE], AccountType::INITIAL_BALANCE => [TransactionTypeModel::OPENING_BALANCE],
AccountType::RECONCILIATION => [TransactionTypeModel::RECONCILIATION], AccountType::RECONCILIATION => [TransactionTypeModel::RECONCILIATION],
@@ -606,10 +608,10 @@ return [
AccountType::RECONCILIATION => TransactionTypeModel::RECONCILIATION, AccountType::RECONCILIATION => TransactionTypeModel::RECONCILIATION,
], ],
AccountType::CASH => [ AccountType::CASH => [
AccountType::ASSET => TransactionTypeModel::DEPOSIT, AccountType::ASSET => TransactionTypeEnum::DEPOSIT->value,
], ],
AccountType::DEBT => [ AccountType::DEBT => [
AccountType::ASSET => TransactionTypeModel::DEPOSIT, AccountType::ASSET => TransactionTypeEnum::DEPOSIT->value,
AccountType::DEBT => TransactionTypeModel::TRANSFER, AccountType::DEBT => TransactionTypeModel::TRANSFER,
AccountType::EXPENSE => TransactionTypeModel::WITHDRAWAL, AccountType::EXPENSE => TransactionTypeModel::WITHDRAWAL,
AccountType::INITIAL_BALANCE => TransactionTypeModel::OPENING_BALANCE, AccountType::INITIAL_BALANCE => TransactionTypeModel::OPENING_BALANCE,
@@ -623,7 +625,7 @@ return [
AccountType::MORTGAGE => TransactionTypeModel::OPENING_BALANCE, AccountType::MORTGAGE => TransactionTypeModel::OPENING_BALANCE,
], ],
AccountType::LOAN => [ AccountType::LOAN => [
AccountType::ASSET => TransactionTypeModel::DEPOSIT, AccountType::ASSET => TransactionTypeEnum::DEPOSIT->value,
AccountType::DEBT => TransactionTypeModel::TRANSFER, AccountType::DEBT => TransactionTypeModel::TRANSFER,
AccountType::EXPENSE => TransactionTypeModel::WITHDRAWAL, AccountType::EXPENSE => TransactionTypeModel::WITHDRAWAL,
AccountType::INITIAL_BALANCE => TransactionTypeModel::OPENING_BALANCE, AccountType::INITIAL_BALANCE => TransactionTypeModel::OPENING_BALANCE,
@@ -631,7 +633,7 @@ return [
AccountType::MORTGAGE => TransactionTypeModel::TRANSFER, AccountType::MORTGAGE => TransactionTypeModel::TRANSFER,
], ],
AccountType::MORTGAGE => [ AccountType::MORTGAGE => [
AccountType::ASSET => TransactionTypeModel::DEPOSIT, AccountType::ASSET => TransactionTypeEnum::DEPOSIT->value,
AccountType::DEBT => TransactionTypeModel::TRANSFER, AccountType::DEBT => TransactionTypeModel::TRANSFER,
AccountType::EXPENSE => TransactionTypeModel::WITHDRAWAL, AccountType::EXPENSE => TransactionTypeModel::WITHDRAWAL,
AccountType::INITIAL_BALANCE => TransactionTypeModel::OPENING_BALANCE, AccountType::INITIAL_BALANCE => TransactionTypeModel::OPENING_BALANCE,
@@ -642,10 +644,10 @@ return [
AccountType::ASSET => TransactionTypeModel::RECONCILIATION, AccountType::ASSET => TransactionTypeModel::RECONCILIATION,
], ],
AccountType::REVENUE => [ AccountType::REVENUE => [
AccountType::ASSET => TransactionTypeModel::DEPOSIT, AccountType::ASSET => TransactionTypeEnum::DEPOSIT->value,
AccountType::DEBT => TransactionTypeModel::DEPOSIT, AccountType::DEBT => TransactionTypeEnum::DEPOSIT->value,
AccountType::LOAN => TransactionTypeModel::DEPOSIT, AccountType::LOAN => TransactionTypeEnum::DEPOSIT->value,
AccountType::MORTGAGE => TransactionTypeModel::DEPOSIT, AccountType::MORTGAGE => TransactionTypeEnum::DEPOSIT->value,
], ],
AccountType::LIABILITY_CREDIT => [ AccountType::LIABILITY_CREDIT => [
AccountType::DEBT => TransactionTypeModel::LIABILITY_CREDIT, AccountType::DEBT => TransactionTypeModel::LIABILITY_CREDIT,
@@ -663,7 +665,7 @@ return [
AccountType::DEBT => [AccountType::EXPENSE, AccountType::CASH], AccountType::DEBT => [AccountType::EXPENSE, AccountType::CASH],
AccountType::MORTGAGE => [AccountType::EXPENSE, AccountType::CASH], AccountType::MORTGAGE => [AccountType::EXPENSE, AccountType::CASH],
], ],
TransactionTypeModel::DEPOSIT => [ TransactionTypeEnum::DEPOSIT->value => [
AccountType::REVENUE => [AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE], AccountType::REVENUE => [AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE],
AccountType::CASH => [AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE], AccountType::CASH => [AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE],
AccountType::LOAN => [AccountType::ASSET], AccountType::LOAN => [AccountType::ASSET],