Skip to content

Firefly III: a personal finances manager

Restore enums, replace one to enforce php 8.1 compatibility.

James Colecfcf860438e3
diff --git a/app/Models/AccountType.php b/app/Models/AccountType.php
index 1f3abaf1b9..00031a46fe 100644
--- a/app/Models/AccountType.php
+++ b/app/Models/AccountType.php
@@ -49,6 +49,22 @@ use Illuminate\Support\Carbon;
*/
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.
*
diff --git a/app/Models/AutoBudget.php b/app/Models/AutoBudget.php
index 767f00373f..6f8fe78df8 100644
--- a/app/Models/AutoBudget.php
+++ b/app/Models/AutoBudget.php
@@ -64,6 +64,9 @@ use Illuminate\Support\Carbon;
*/
class AutoBudget extends Model
{
+ public const AUTO_BUDGET_RESET = 1;
+ public const AUTO_BUDGET_ROLLOVER = 2;
+
use SoftDeletes;
/**
diff --git a/app/Models/RecurrenceRepetition.php b/app/Models/RecurrenceRepetition.php
index 519ef28b14..91330e975d 100644
--- a/app/Models/RecurrenceRepetition.php
+++ b/app/Models/RecurrenceRepetition.php
@@ -62,6 +62,12 @@ use Illuminate\Support\Carbon;
*/
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;
/**
diff --git a/app/Models/TransactionType.php b/app/Models/TransactionType.php
index b013e1f794..5cf42db0f7 100644
--- a/app/Models/TransactionType.php
+++ b/app/Models/TransactionType.php
@@ -56,10 +56,17 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
*/
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;
protected $casts
- = [
+ = [
'created_at' => 'datetime',
'updated_at' => 'datetime',
'deleted_at' => 'datetime',
diff --git a/app/Models/UserRole.php b/app/Models/UserRole.php
index fdb24f05ec..07551978d9 100644
--- a/app/Models/UserRole.php
+++ b/app/Models/UserRole.php
@@ -53,6 +53,16 @@ use Illuminate\Support\Carbon;
*/
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'];
/**
diff --git a/app/Models/Webhook.php b/app/Models/Webhook.php
index b16ec4ef30..e41686fb39 100644
--- a/app/Models/Webhook.php
+++ b/app/Models/Webhook.php
@@ -76,7 +76,19 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
*/
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;
+
protected $casts
= [
'active' => 'boolean',
diff --git a/config/firefly.php b/config/firefly.php
index 40e9053efe..0aea6e008c 100644
--- a/config/firefly.php
+++ b/config/firefly.php
@@ -22,6 +22,7 @@
declare(strict_types=1);
+use FireflyIII\Enums\TransactionTypeEnum;
use FireflyIII\Models\Account;
use FireflyIII\Models\AccountType;
use FireflyIII\Models\Attachment;
@@ -82,6 +83,7 @@ use FireflyIII\TransactionRules\Actions\SetSourceAccount;
use FireflyIII\TransactionRules\Actions\UpdatePiggybank;
use FireflyIII\User;
+
/*
* DO NOT EDIT THIS FILE. IT IS AUTO GENERATED.
*
@@ -496,7 +498,7 @@ return [
'expected_source_types' => [
'source' => [
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::OPENING_BALANCE => [AccountType::INITIAL_BALANCE, AccountType::ASSET, AccountType::LOAN, AccountType::DEBT,
AccountType::MORTGAGE,],
@@ -515,7 +517,7 @@ return [
'destination' => [
TransactionTypeModel::WITHDRAWAL => [AccountType::EXPENSE, AccountType::CASH, AccountType::LOAN, AccountType::DEBT,
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::OPENING_BALANCE => [AccountType::INITIAL_BALANCE, AccountType::ASSET, AccountType::LOAN, AccountType::DEBT,
AccountType::MORTGAGE,],
@@ -564,27 +566,27 @@ return [
AccountType::ASSET => [TransactionTypeModel::WITHDRAWAL, TransactionTypeModel::TRANSFER, TransactionTypeModel::OPENING_BALANCE,
TransactionTypeModel::RECONCILIATION,],
AccountType::EXPENSE => [], // is not allowed as a source.
- AccountType::REVENUE => [TransactionTypeModel::DEPOSIT],
- AccountType::LOAN => [TransactionTypeModel::WITHDRAWAL, TransactionTypeModel::DEPOSIT, TransactionTypeModel::TRANSFER,
+ AccountType::REVENUE => [TransactionTypeEnum::DEPOSIT->value],
+ AccountType::LOAN => [TransactionTypeModel::WITHDRAWAL, TransactionTypeEnum::DEPOSIT->value, TransactionTypeModel::TRANSFER,
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],
- AccountType::MORTGAGE => [TransactionTypeModel::WITHDRAWAL, TransactionTypeModel::DEPOSIT, TransactionTypeModel::TRANSFER,
+ AccountType::MORTGAGE => [TransactionTypeModel::WITHDRAWAL, TransactionTypeEnum::DEPOSIT->value, TransactionTypeModel::TRANSFER,
TransactionTypeModel::OPENING_BALANCE, TransactionTypeModel::LIABILITY_CREDIT],
AccountType::INITIAL_BALANCE => [TransactionTypeModel::OPENING_BALANCE],
AccountType::RECONCILIATION => [TransactionTypeModel::RECONCILIATION],
AccountType::LIABILITY_CREDIT => [TransactionTypeModel::LIABILITY_CREDIT],
],
'destination' => [
- AccountType::ASSET => [TransactionTypeModel::DEPOSIT, TransactionTypeModel::TRANSFER, TransactionTypeModel::OPENING_BALANCE,
+ AccountType::ASSET => [TransactionTypeEnum::DEPOSIT->value, TransactionTypeModel::TRANSFER, TransactionTypeModel::OPENING_BALANCE,
TransactionTypeModel::RECONCILIATION,],
AccountType::EXPENSE => [TransactionTypeModel::WITHDRAWAL],
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,],
- AccountType::DEBT => [TransactionTypeModel::WITHDRAWAL, TransactionTypeModel::DEPOSIT, TransactionTypeModel::TRANSFER,
+ AccountType::DEBT => [TransactionTypeModel::WITHDRAWAL, TransactionTypeEnum::DEPOSIT->value, TransactionTypeModel::TRANSFER,
TransactionTypeModel::OPENING_BALANCE,],
- AccountType::MORTGAGE => [TransactionTypeModel::WITHDRAWAL, TransactionTypeModel::DEPOSIT, TransactionTypeModel::TRANSFER,
+ AccountType::MORTGAGE => [TransactionTypeModel::WITHDRAWAL, TransactionTypeEnum::DEPOSIT->value, TransactionTypeModel::TRANSFER,
TransactionTypeModel::OPENING_BALANCE,],
AccountType::INITIAL_BALANCE => [TransactionTypeModel::OPENING_BALANCE],
AccountType::RECONCILIATION => [TransactionTypeModel::RECONCILIATION],
@@ -606,10 +608,10 @@ return [
AccountType::RECONCILIATION => TransactionTypeModel::RECONCILIATION,
],
AccountType::CASH => [
- AccountType::ASSET => TransactionTypeModel::DEPOSIT,
+ AccountType::ASSET => TransactionTypeEnum::DEPOSIT->value,
],
AccountType::DEBT => [
- AccountType::ASSET => TransactionTypeModel::DEPOSIT,
+ AccountType::ASSET => TransactionTypeEnum::DEPOSIT->value,
AccountType::DEBT => TransactionTypeModel::TRANSFER,
AccountType::EXPENSE => TransactionTypeModel::WITHDRAWAL,
AccountType::INITIAL_BALANCE => TransactionTypeModel::OPENING_BALANCE,
@@ -623,7 +625,7 @@ return [
AccountType::MORTGAGE => TransactionTypeModel::OPENING_BALANCE,
],
AccountType::LOAN => [
- AccountType::ASSET => TransactionTypeModel::DEPOSIT,
+ AccountType::ASSET => TransactionTypeEnum::DEPOSIT->value,
AccountType::DEBT => TransactionTypeModel::TRANSFER,
AccountType::EXPENSE => TransactionTypeModel::WITHDRAWAL,
AccountType::INITIAL_BALANCE => TransactionTypeModel::OPENING_BALANCE,
@@ -631,7 +633,7 @@ return [
AccountType::MORTGAGE => TransactionTypeModel::TRANSFER,
],
AccountType::MORTGAGE => [
- AccountType::ASSET => TransactionTypeModel::DEPOSIT,
+ AccountType::ASSET => TransactionTypeEnum::DEPOSIT->value,
AccountType::DEBT => TransactionTypeModel::TRANSFER,
AccountType::EXPENSE => TransactionTypeModel::WITHDRAWAL,
AccountType::INITIAL_BALANCE => TransactionTypeModel::OPENING_BALANCE,
@@ -642,10 +644,10 @@ return [
AccountType::ASSET => TransactionTypeModel::RECONCILIATION,
],
AccountType::REVENUE => [
- AccountType::ASSET => TransactionTypeModel::DEPOSIT,
- AccountType::DEBT => TransactionTypeModel::DEPOSIT,
- AccountType::LOAN => TransactionTypeModel::DEPOSIT,
- AccountType::MORTGAGE => TransactionTypeModel::DEPOSIT,
+ AccountType::ASSET => TransactionTypeEnum::DEPOSIT->value,
+ AccountType::DEBT => TransactionTypeEnum::DEPOSIT->value,
+ AccountType::LOAN => TransactionTypeEnum::DEPOSIT->value,
+ AccountType::MORTGAGE => TransactionTypeEnum::DEPOSIT->value,
],
AccountType::LIABILITY_CREDIT => [
AccountType::DEBT => TransactionTypeModel::LIABILITY_CREDIT,
@@ -663,7 +665,7 @@ return [
AccountType::DEBT => [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::CASH => [AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE],
AccountType::LOAN => [AccountType::ASSET],