New account and transaction types

This commit is contained in:
James Cole
2021-04-10 17:25:17 +02:00
parent 36fa7ae97e
commit 41d1ef27b5
3 changed files with 92 additions and 72 deletions

View File

@@ -635,6 +635,7 @@ return [
TransactionTypeModel::OPENING_BALANCE => [AccountType::INITIAL_BALANCE, AccountType::ASSET, AccountType::LOAN, AccountType::DEBT,
AccountType::MORTGAGE,],
TransactionTypeModel::RECONCILIATION => [AccountType::RECONCILIATION, AccountType::ASSET],
TransactionTypeModel::LIABILITY_CREDIT => [AccountType::LIABILITY_CREDIT,],
// in case no transaction type is known yet, it could be anything.
'none' => [
AccountType::ASSET,
@@ -653,6 +654,7 @@ return [
TransactionTypeModel::OPENING_BALANCE => [AccountType::INITIAL_BALANCE, AccountType::ASSET, AccountType::LOAN, AccountType::DEBT,
AccountType::MORTGAGE,],
TransactionTypeModel::RECONCILIATION => [AccountType::RECONCILIATION, AccountType::ASSET],
TransactionTypeModel::LIABILITY_CREDIT => [AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE],
],
],
'allowed_opposing_types' => [
@@ -661,15 +663,16 @@ return [
AccountType::LOAN, AccountType::RECONCILIATION, AccountType::MORTGAGE],
AccountType::CASH => [AccountType::ASSET],
AccountType::DEBT => [AccountType::ASSET, AccountType::DEBT, AccountType::EXPENSE, AccountType::INITIAL_BALANCE, AccountType::LOAN,
AccountType::MORTGAGE,],
AccountType::MORTGAGE, AccountType::LIABILITY_CREDIT],
AccountType::EXPENSE => [], // is not allowed as a source.
AccountType::INITIAL_BALANCE => [AccountType::ASSET, AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE],
AccountType::LOAN => [AccountType::ASSET, AccountType::DEBT, AccountType::EXPENSE, AccountType::INITIAL_BALANCE, AccountType::LOAN,
AccountType::MORTGAGE,],
AccountType::MORTGAGE, AccountType::LIABILITY_CREDIT],
AccountType::MORTGAGE => [AccountType::ASSET, AccountType::DEBT, AccountType::EXPENSE, AccountType::INITIAL_BALANCE, AccountType::LOAN,
AccountType::MORTGAGE,],
AccountType::MORTGAGE, AccountType::LIABILITY_CREDIT],
AccountType::RECONCILIATION => [AccountType::ASSET],
AccountType::REVENUE => [AccountType::ASSET, AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE],
AccountType::LIABILITY_CREDIT => [AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE],
],
'destination' => [
@@ -686,6 +689,7 @@ return [
AccountType::REVENUE,],
AccountType::RECONCILIATION => [AccountType::ASSET],
AccountType::REVENUE => [], // is not allowed as a destination
AccountType::LIABILITY_CREDIT => [],// is not allowed as a destination
],
],
// depending on the account type, return the allowed transaction types:
@@ -696,13 +700,14 @@ return [
AccountType::EXPENSE => [], // is not allowed as a source.
AccountType::REVENUE => [TransactionTypeModel::DEPOSIT],
AccountType::LOAN => [TransactionTypeModel::WITHDRAWAL, TransactionTypeModel::DEPOSIT, TransactionTypeModel::TRANSFER,
TransactionTypeModel::OPENING_BALANCE,],
TransactionTypeModel::OPENING_BALANCE, TransactionTypeModel::LIABILITY_CREDIT],
AccountType::DEBT => [TransactionTypeModel::WITHDRAWAL, TransactionTypeModel::DEPOSIT, TransactionTypeModel::TRANSFER,
TransactionTypeModel::OPENING_BALANCE,],
TransactionTypeModel::OPENING_BALANCE, TransactionTypeModel::LIABILITY_CREDIT],
AccountType::MORTGAGE => [TransactionTypeModel::WITHDRAWAL, TransactionTypeModel::DEPOSIT, TransactionTypeModel::TRANSFER,
TransactionTypeModel::OPENING_BALANCE,],
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,
@@ -717,6 +722,7 @@ return [
TransactionTypeModel::OPENING_BALANCE,],
AccountType::INITIAL_BALANCE => [TransactionTypeModel::OPENING_BALANCE],
AccountType::RECONCILIATION => [TransactionTypeModel::RECONCILIATION],
AccountType::LIABILITY_CREDIT => [], // is not allowed as a destination
],
],
@@ -775,6 +781,12 @@ return [
AccountType::LOAN => TransactionTypeModel::DEPOSIT,
AccountType::MORTGAGE => TransactionTypeModel::DEPOSIT,
],
AccountType::LIABILITY_CREDIT => [
AccountType::DEBT => TransactionTypeModel::LIABILITY_CREDIT,
AccountType::LOAN => TransactionTypeModel::LIABILITY_CREDIT,
AccountType::MORTGAGE => TransactionTypeModel::LIABILITY_CREDIT,
],
// AccountType::EXPENSE unlisted because it cant be a source
],
// allowed source -> destination accounts.
@@ -809,6 +821,11 @@ return [
AccountType::RECONCILIATION => [AccountType::ASSET],
AccountType::ASSET => [AccountType::RECONCILIATION],
],
TransactionTypeModel::LIABILITY_CREDIT => [
AccountType::LOAN => [AccountType::LIABILITY_CREDIT],
AccountType::DEBT => [AccountType::LIABILITY_CREDIT],
AccountType::MORTGAGE => [AccountType::LIABILITY_CREDIT],
],
],
// if you add fields to this array, dont forget to update the export routine (ExportDataGenerator).
'journal_meta_fields' => [
@@ -844,8 +861,9 @@ return [
Webhook::DELIVERY_JSON => 'DELIVERY_JSON',
],
],
'can_have_virtual_amounts' => [AccountType::ASSET, AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE, AccountType::CREDITCARD],
'can_have_virtual_amounts' => [AccountType::ASSET],
'can_have_opening_balance' => [AccountType::ASSET, AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE, AccountType::CREDITCARD],
'valid_asset_fields' => ['account_role', 'account_number', 'currency_id', 'BIC', 'include_net_worth'],
'valid_cc_fields' => ['account_role', 'cc_monthly_payment_date', 'cc_type', 'account_number', 'currency_id', 'BIC', 'include_net_worth'],
'valid_account_fields' => ['account_number', 'currency_id', 'BIC', 'interest', 'interest_period', 'include_net_worth'],
'valid_account_fields' => ['account_number', 'currency_id', 'BIC', 'interest', 'interest_period', 'include_net_worth', 'liability_direction'],
];

View File

@@ -46,6 +46,7 @@ class AccountTypeSeeder extends Seeder
AccountType::RECONCILIATION,
AccountType::DEBT,
AccountType::MORTGAGE,
AccountType::LIABILITY_CREDIT
];
foreach ($types as $type) {
try {

View File

@@ -40,6 +40,7 @@ class TransactionTypeSeeder extends Seeder
TransactionType::OPENING_BALANCE,
TransactionType::RECONCILIATION,
TransactionType::INVALID,
TransactionType::LIABILITY_CREDIT
];
foreach ($types as $type) {