Implement custom trigger for recurring transactions

This commit is contained in:
James Cole
2022-12-29 15:42:02 +01:00
parent 85a2a87806
commit 8c320fd199
16 changed files with 604 additions and 234 deletions

View File

@@ -156,7 +156,7 @@ return [
'languages' => [
// currently enabled languages
'bg_BG' => ['name_locale' => 'Български', 'name_english' => 'Bulgarian'],
// 'ca_ES' => ['name_locale' => 'Catalan', 'name_english' => 'Catalan'],
// 'ca_ES' => ['name_locale' => 'Catalan', 'name_english' => 'Catalan'],
'cs_CZ' => ['name_locale' => 'Czech', 'name_english' => 'Czech'],
'da_DK' => ['name_locale' => 'Danish', 'name_english' => 'Danish'],
'de_DE' => ['name_locale' => 'Deutsch', 'name_english' => 'German'],
@@ -164,17 +164,17 @@ return [
'en_GB' => ['name_locale' => 'English (GB)', 'name_english' => 'English (GB)'],
'en_US' => ['name_locale' => 'English (US)', 'name_english' => 'English (US)'],
'es_ES' => ['name_locale' => 'Español', 'name_english' => 'Spanish'],
// 'et_EE' => ['name_locale' => 'Estonian', 'name_english' => 'Estonian'],
// 'fa_IR' => ['name_locale' => 'فارسی', 'name_english' => 'Persian'],
// 'et_EE' => ['name_locale' => 'Estonian', 'name_english' => 'Estonian'],
// 'fa_IR' => ['name_locale' => 'فارسی', 'name_english' => 'Persian'],
'fi_FI' => ['name_locale' => 'Suomi', 'name_english' => 'Finnish'],
'fr_FR' => ['name_locale' => 'Français', 'name_english' => 'French'],
// 'he_IL' => ['name_locale' => 'Hebrew', 'name_english' => 'Hebrew'],
// 'he_IL' => ['name_locale' => 'Hebrew', 'name_english' => 'Hebrew'],
'hu_HU' => ['name_locale' => 'Hungarian', 'name_english' => 'Hungarian'],
'id_ID' => ['name_locale' => 'Bahasa Indonesia', 'name_english' => 'Indonesian'],
// 'is_IS' => ['name_locale' => 'Icelandic', 'name_english' => 'Icelandic'],
// 'is_IS' => ['name_locale' => 'Icelandic', 'name_english' => 'Icelandic'],
'it_IT' => ['name_locale' => 'Italiano', 'name_english' => 'Italian'],
'ja_JP' => ['name_locale' => 'Japanese', 'name_english' => 'Japanese'],
// 'lt_LT' => ['name_locale' => 'Lietuvių', 'name_english' => 'Lithuanian'],
// 'lt_LT' => ['name_locale' => 'Lietuvių', 'name_english' => 'Lithuanian'],
'nb_NO' => ['name_locale' => 'Norsk', 'name_english' => 'Norwegian'],
'nl_NL' => ['name_locale' => 'Nederlands', 'name_english' => 'Dutch'],
'pl_PL' => ['name_locale' => 'Polski', 'name_english' => 'Polish'],
@@ -182,12 +182,12 @@ return [
'pt_PT' => ['name_locale' => 'Português', 'name_english' => 'Portuguese'],
'ro_RO' => ['name_locale' => 'Română', 'name_english' => 'Romanian'],
'ru_RU' => ['name_locale' => 'Русский', 'name_english' => 'Russian'],
// 'si_LK' => ['name_locale' => 'සිංහල', 'name_english' => 'Sinhala (Sri Lanka)'],
// 'si_LK' => ['name_locale' => 'සිංහල', 'name_english' => 'Sinhala (Sri Lanka)'],
'sk_SK' => ['name_locale' => 'Slovenčina', 'name_english' => 'Slovak'],
'sl_SI' => ['name_locale' => 'Slovenian', 'name_english' => 'Slovenian'],
//// 'sr_CS' => ['name_locale' => 'Serbian (Latin)', 'name_english' => 'Serbian (Latin)'],
//// 'sr_CS' => ['name_locale' => 'Serbian (Latin)', 'name_english' => 'Serbian (Latin)'],
'sv_SE' => ['name_locale' => 'Svenska', 'name_english' => 'Swedish'],
// // 'tlh_AA' => ['name_locale' => 'tlhIngan Hol', 'name_english' => 'Klingon'],
// // 'tlh_AA' => ['name_locale' => 'tlhIngan Hol', 'name_english' => 'Klingon'],
'tr_TR' => ['name_locale' => 'Türkçe', 'name_english' => 'Turkish'],
'uk_UA' => ['name_locale' => 'Ukranian', 'name_english' => 'Ukranian'],
'vi_VN' => ['name_locale' => 'Tiếng Việt', 'name_english' => 'Vietnamese'],
@@ -221,9 +221,14 @@ return [
// account types that may have or set a currency
'valid_currency_account_types' => [
AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE,
AccountType::CASH, AccountType::INITIAL_BALANCE, AccountType::LIABILITY_CREDIT,
AccountType::RECONCILIATION
AccountType::ASSET,
AccountType::LOAN,
AccountType::DEBT,
AccountType::MORTGAGE,
AccountType::CASH,
AccountType::INITIAL_BALANCE,
AccountType::LIABILITY_CREDIT,
AccountType::RECONCILIATION,
],
// "value must be in this list" values
@@ -528,8 +533,13 @@ return [
TransactionTypeModel::WITHDRAWAL => [AccountType::ASSET, 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,],
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, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE],
// in case no transaction type is known yet, it could be anything.
@@ -543,46 +553,111 @@ return [
],
],
'destination' => [
TransactionTypeModel::WITHDRAWAL => [AccountType::EXPENSE, AccountType::CASH, AccountType::LOAN, AccountType::DEBT,
AccountType::MORTGAGE,],
TransactionTypeModel::WITHDRAWAL => [
AccountType::EXPENSE,
AccountType::CASH,
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,],
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, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE],
],
],
'allowed_opposing_types' => [
'source' => [
AccountType::ASSET => [AccountType::ASSET, AccountType::CASH, AccountType::DEBT, AccountType::EXPENSE, AccountType::INITIAL_BALANCE,
AccountType::LOAN, AccountType::RECONCILIATION, AccountType::MORTGAGE],
AccountType::ASSET => [
AccountType::ASSET,
AccountType::CASH,
AccountType::DEBT,
AccountType::EXPENSE,
AccountType::INITIAL_BALANCE,
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::LIABILITY_CREDIT],
AccountType::DEBT => [
AccountType::ASSET,
AccountType::DEBT,
AccountType::EXPENSE,
AccountType::INITIAL_BALANCE,
AccountType::LOAN,
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::LIABILITY_CREDIT],
AccountType::MORTGAGE => [AccountType::ASSET, AccountType::DEBT, AccountType::EXPENSE, AccountType::INITIAL_BALANCE, AccountType::LOAN,
AccountType::MORTGAGE, AccountType::LIABILITY_CREDIT],
AccountType::LOAN => [
AccountType::ASSET,
AccountType::DEBT,
AccountType::EXPENSE,
AccountType::INITIAL_BALANCE,
AccountType::LOAN,
AccountType::MORTGAGE,
AccountType::LIABILITY_CREDIT,
],
AccountType::MORTGAGE => [
AccountType::ASSET,
AccountType::DEBT,
AccountType::EXPENSE,
AccountType::INITIAL_BALANCE,
AccountType::LOAN,
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' => [
AccountType::ASSET => [AccountType::ASSET, AccountType::CASH, AccountType::DEBT, AccountType::INITIAL_BALANCE, AccountType::LOAN,
AccountType::MORTGAGE, AccountType::RECONCILIATION, AccountType::REVENUE,],
AccountType::ASSET => [
AccountType::ASSET,
AccountType::CASH,
AccountType::DEBT,
AccountType::INITIAL_BALANCE,
AccountType::LOAN,
AccountType::MORTGAGE,
AccountType::RECONCILIATION,
AccountType::REVENUE,
],
AccountType::CASH => [AccountType::ASSET],
AccountType::DEBT => [AccountType::ASSET, AccountType::DEBT, AccountType::INITIAL_BALANCE, AccountType::LOAN, AccountType::MORTGAGE,
AccountType::REVENUE,],
AccountType::DEBT => [
AccountType::ASSET,
AccountType::DEBT,
AccountType::INITIAL_BALANCE,
AccountType::LOAN,
AccountType::MORTGAGE,
AccountType::REVENUE,
],
AccountType::EXPENSE => [AccountType::ASSET, AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE],
AccountType::INITIAL_BALANCE => [AccountType::ASSET, AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE],
AccountType::LOAN => [AccountType::ASSET, AccountType::DEBT, AccountType::INITIAL_BALANCE, AccountType::LOAN, AccountType::MORTGAGE,
AccountType::REVENUE,],
AccountType::MORTGAGE => [AccountType::ASSET, AccountType::DEBT, AccountType::INITIAL_BALANCE, AccountType::LOAN, AccountType::MORTGAGE,
AccountType::REVENUE,],
AccountType::LOAN => [
AccountType::ASSET,
AccountType::DEBT,
AccountType::INITIAL_BALANCE,
AccountType::LOAN,
AccountType::MORTGAGE,
AccountType::REVENUE,
],
AccountType::MORTGAGE => [
AccountType::ASSET,
AccountType::DEBT,
AccountType::INITIAL_BALANCE,
AccountType::LOAN,
AccountType::MORTGAGE,
AccountType::REVENUE,
],
AccountType::RECONCILIATION => [AccountType::ASSET],
AccountType::REVENUE => [], // is not allowed as a destination
AccountType::LIABILITY_CREDIT => [],// is not allowed as a destination
@@ -591,31 +666,66 @@ return [
// depending on the account type, return the allowed transaction types:
'allowed_transaction_types' => [
'source' => [
AccountType::ASSET => [TransactionTypeModel::WITHDRAWAL, TransactionTypeModel::TRANSFER, TransactionTypeModel::OPENING_BALANCE,
TransactionTypeModel::RECONCILIATION,],
AccountType::ASSET => [
TransactionTypeModel::WITHDRAWAL,
TransactionTypeModel::TRANSFER,
TransactionTypeModel::OPENING_BALANCE,
TransactionTypeModel::RECONCILIATION,
],
AccountType::EXPENSE => [], // is not allowed as a source.
AccountType::REVENUE => [TransactionTypeEnum::DEPOSIT->value],
AccountType::LOAN => [TransactionTypeModel::WITHDRAWAL, TransactionTypeEnum::DEPOSIT->value, TransactionTypeModel::TRANSFER,
TransactionTypeModel::OPENING_BALANCE, TransactionTypeModel::LIABILITY_CREDIT],
AccountType::DEBT => [TransactionTypeModel::WITHDRAWAL, TransactionTypeEnum::DEPOSIT->value, TransactionTypeModel::TRANSFER,
TransactionTypeModel::OPENING_BALANCE, TransactionTypeModel::LIABILITY_CREDIT],
AccountType::MORTGAGE => [TransactionTypeModel::WITHDRAWAL, TransactionTypeEnum::DEPOSIT->value, TransactionTypeModel::TRANSFER,
TransactionTypeModel::OPENING_BALANCE, TransactionTypeModel::LIABILITY_CREDIT],
AccountType::LOAN => [
TransactionTypeModel::WITHDRAWAL,
TransactionTypeEnum::DEPOSIT->value,
TransactionTypeModel::TRANSFER,
TransactionTypeModel::OPENING_BALANCE,
TransactionTypeModel::LIABILITY_CREDIT,
],
AccountType::DEBT => [
TransactionTypeModel::WITHDRAWAL,
TransactionTypeEnum::DEPOSIT->value,
TransactionTypeModel::TRANSFER,
TransactionTypeModel::OPENING_BALANCE,
TransactionTypeModel::LIABILITY_CREDIT,
],
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 => [TransactionTypeEnum::DEPOSIT->value, TransactionTypeModel::TRANSFER, TransactionTypeModel::OPENING_BALANCE,
TransactionTypeModel::RECONCILIATION,],
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, TransactionTypeEnum::DEPOSIT->value, TransactionTypeModel::TRANSFER,
TransactionTypeModel::OPENING_BALANCE,],
AccountType::DEBT => [TransactionTypeModel::WITHDRAWAL, TransactionTypeEnum::DEPOSIT->value, TransactionTypeModel::TRANSFER,
TransactionTypeModel::OPENING_BALANCE,],
AccountType::MORTGAGE => [TransactionTypeModel::WITHDRAWAL, TransactionTypeEnum::DEPOSIT->value, TransactionTypeModel::TRANSFER,
TransactionTypeModel::OPENING_BALANCE,],
AccountType::LOAN => [
TransactionTypeModel::WITHDRAWAL,
TransactionTypeEnum::DEPOSIT->value,
TransactionTypeModel::TRANSFER,
TransactionTypeModel::OPENING_BALANCE,
],
AccountType::DEBT => [
TransactionTypeModel::WITHDRAWAL,
TransactionTypeEnum::DEPOSIT->value,
TransactionTypeModel::TRANSFER,
TransactionTypeModel::OPENING_BALANCE,
],
AccountType::MORTGAGE => [
TransactionTypeModel::WITHDRAWAL,
TransactionTypeEnum::DEPOSIT->value,
TransactionTypeModel::TRANSFER,
TransactionTypeModel::OPENING_BALANCE,
],
AccountType::INITIAL_BALANCE => [TransactionTypeModel::OPENING_BALANCE],
AccountType::RECONCILIATION => [TransactionTypeModel::RECONCILIATION],
AccountType::LIABILITY_CREDIT => [], // is not allowed as a destination
@@ -727,23 +837,40 @@ return [
AccountType::LIABILITY_CREDIT => [AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE],
],
],
// if you add fields to this array, dont forget to update the export routine (ExportDataGenerator).
// if you add fields to this array, don't forget to update the export routine (ExportDataGenerator).
'journal_meta_fields' => [
// sepa
'sepa_cc', 'sepa_ct_op', 'sepa_ct_id',
'sepa_db', 'sepa_country', 'sepa_ep',
'sepa_ci', 'sepa_batch_id', 'external_url',
'sepa_cc',
'sepa_ct_op',
'sepa_ct_id',
'sepa_db',
'sepa_country',
'sepa_ep',
'sepa_ci',
'sepa_batch_id',
'external_url',
// dates
'interest_date', 'book_date', 'process_date',
'due_date', 'payment_date', 'invoice_date',
'interest_date',
'book_date',
'process_date',
'due_date',
'payment_date',
'invoice_date',
// others
'recurrence_id', 'internal_reference', 'bunq_payment_id',
'import_hash', 'import_hash_v2', 'external_id', 'original_source',
'recurrence_id',
'internal_reference',
'bunq_payment_id',
'import_hash',
'import_hash_v2',
'external_id',
'original_source',
// recurring transactions
'recurrence_total', 'recurrence_count',
'recurrence_total',
'recurrence_count',
'recurrence_date',
],
'webhooks' => [
'max_attempts' => env('WEBHOOK_MAX_ATTEMPTS', 3),