mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-01-07 14:41:20 +00:00
Allow account endpoint to be filtered on various fields.
This commit is contained in:
@@ -30,63 +30,62 @@ use FireflyIII\Models\AccountType;
|
||||
*/
|
||||
trait AccountFilter
|
||||
{
|
||||
protected array $types = [
|
||||
'all' => [
|
||||
AccountType::DEFAULT,
|
||||
AccountType::CASH,
|
||||
AccountType::ASSET,
|
||||
AccountType::EXPENSE,
|
||||
AccountType::REVENUE,
|
||||
AccountType::INITIAL_BALANCE,
|
||||
AccountType::BENEFICIARY,
|
||||
AccountType::IMPORT,
|
||||
AccountType::RECONCILIATION,
|
||||
AccountType::LOAN,
|
||||
AccountType::DEBT,
|
||||
AccountType::MORTGAGE,
|
||||
],
|
||||
'asset' => [AccountType::DEFAULT, AccountType::ASSET],
|
||||
'cash' => [AccountType::CASH],
|
||||
'expense' => [AccountType::EXPENSE, AccountType::BENEFICIARY],
|
||||
'revenue' => [AccountType::REVENUE],
|
||||
'special' => [AccountType::CASH, AccountType::INITIAL_BALANCE, AccountType::IMPORT, AccountType::RECONCILIATION],
|
||||
'hidden' => [AccountType::INITIAL_BALANCE, AccountType::IMPORT, AccountType::RECONCILIATION],
|
||||
'liability' => [AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE, AccountType::CREDITCARD],
|
||||
'liabilities' => [AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE, AccountType::CREDITCARD],
|
||||
AccountType::DEFAULT => [AccountType::DEFAULT],
|
||||
AccountType::CASH => [AccountType::CASH],
|
||||
AccountType::ASSET => [AccountType::ASSET],
|
||||
AccountType::EXPENSE => [AccountType::EXPENSE],
|
||||
AccountType::REVENUE => [AccountType::REVENUE],
|
||||
AccountType::INITIAL_BALANCE => [AccountType::INITIAL_BALANCE],
|
||||
AccountType::BENEFICIARY => [AccountType::BENEFICIARY],
|
||||
AccountType::IMPORT => [AccountType::IMPORT],
|
||||
AccountType::RECONCILIATION => [AccountType::RECONCILIATION],
|
||||
AccountType::LOAN => [AccountType::LOAN],
|
||||
AccountType::MORTGAGE => [AccountType::MORTGAGE],
|
||||
AccountType::DEBT => [AccountType::DEBT],
|
||||
AccountType::CREDITCARD => [AccountType::CREDITCARD],
|
||||
'default account' => [AccountType::DEFAULT],
|
||||
'cash account' => [AccountType::CASH],
|
||||
'asset account' => [AccountType::ASSET],
|
||||
'expense account' => [AccountType::EXPENSE],
|
||||
'revenue account' => [AccountType::REVENUE],
|
||||
'initial balance account' => [AccountType::INITIAL_BALANCE],
|
||||
'reconciliation' => [AccountType::RECONCILIATION],
|
||||
'loan' => [AccountType::LOAN],
|
||||
'mortgage' => [AccountType::MORTGAGE],
|
||||
'debt' => [AccountType::DEBT],
|
||||
'credit card' => [AccountType::CREDITCARD],
|
||||
'credit-card' => [AccountType::CREDITCARD],
|
||||
'creditcard' => [AccountType::CREDITCARD],
|
||||
'cc' => [AccountType::CREDITCARD],
|
||||
];
|
||||
/**
|
||||
* All the available types.
|
||||
*/
|
||||
protected function mapAccountTypes(string $type): array
|
||||
{
|
||||
$types = [
|
||||
'all' => [
|
||||
AccountType::DEFAULT,
|
||||
AccountType::CASH,
|
||||
AccountType::ASSET,
|
||||
AccountType::EXPENSE,
|
||||
AccountType::REVENUE,
|
||||
AccountType::INITIAL_BALANCE,
|
||||
AccountType::BENEFICIARY,
|
||||
AccountType::IMPORT,
|
||||
AccountType::RECONCILIATION,
|
||||
AccountType::LOAN,
|
||||
AccountType::DEBT,
|
||||
AccountType::MORTGAGE,
|
||||
],
|
||||
'asset' => [AccountType::DEFAULT, AccountType::ASSET],
|
||||
'cash' => [AccountType::CASH],
|
||||
'expense' => [AccountType::EXPENSE, AccountType::BENEFICIARY],
|
||||
'revenue' => [AccountType::REVENUE],
|
||||
'special' => [AccountType::CASH, AccountType::INITIAL_BALANCE, AccountType::IMPORT, AccountType::RECONCILIATION],
|
||||
'hidden' => [AccountType::INITIAL_BALANCE, AccountType::IMPORT, AccountType::RECONCILIATION],
|
||||
'liability' => [AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE, AccountType::CREDITCARD],
|
||||
'liabilities' => [AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE, AccountType::CREDITCARD],
|
||||
AccountType::DEFAULT => [AccountType::DEFAULT],
|
||||
AccountType::CASH => [AccountType::CASH],
|
||||
AccountType::ASSET => [AccountType::ASSET],
|
||||
AccountType::EXPENSE => [AccountType::EXPENSE],
|
||||
AccountType::REVENUE => [AccountType::REVENUE],
|
||||
AccountType::INITIAL_BALANCE => [AccountType::INITIAL_BALANCE],
|
||||
AccountType::BENEFICIARY => [AccountType::BENEFICIARY],
|
||||
AccountType::IMPORT => [AccountType::IMPORT],
|
||||
AccountType::RECONCILIATION => [AccountType::RECONCILIATION],
|
||||
AccountType::LOAN => [AccountType::LOAN],
|
||||
AccountType::MORTGAGE => [AccountType::MORTGAGE],
|
||||
AccountType::DEBT => [AccountType::DEBT],
|
||||
AccountType::CREDITCARD => [AccountType::CREDITCARD],
|
||||
'default account' => [AccountType::DEFAULT],
|
||||
'cash account' => [AccountType::CASH],
|
||||
'asset account' => [AccountType::ASSET],
|
||||
'expense account' => [AccountType::EXPENSE],
|
||||
'revenue account' => [AccountType::REVENUE],
|
||||
'initial balance account' => [AccountType::INITIAL_BALANCE],
|
||||
'reconciliation' => [AccountType::RECONCILIATION],
|
||||
'loan' => [AccountType::LOAN],
|
||||
'mortgage' => [AccountType::MORTGAGE],
|
||||
'debt' => [AccountType::DEBT],
|
||||
'credit card' => [AccountType::CREDITCARD],
|
||||
'credit-card' => [AccountType::CREDITCARD],
|
||||
'creditcard' => [AccountType::CREDITCARD],
|
||||
'cc' => [AccountType::CREDITCARD],
|
||||
];
|
||||
|
||||
return $types[$type] ?? $types['all'];
|
||||
return $this->types[$type] ?? $this->types['all'];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user