From e0c4a30acad216944d65ffdd1ed68a4c67d86260 Mon Sep 17 00:00:00 2001 From: DirgoSalga Date: Sat, 14 Sep 2024 19:38:26 +0200 Subject: [PATCH 01/11] Add custom handler for the German bank Rheinhessen Sparkasse to the GoCardless app. Following the guide and using the template added the code, similar to other handlers, that should match the transaction as seen in the logs when syncing my bank through Actual. The only thing that had to be added was the notes about the transaction are stored under remittanceInformationStructured and not under remittanceInformationUnstructured. Testing still pending. --- src/app-gocardless/bank-factory.js | 2 + .../banks/spk_worms_alzey_ried_malade51wor.js | 66 +++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 src/app-gocardless/banks/spk_worms_alzey_ried_malade51wor.js diff --git a/src/app-gocardless/bank-factory.js b/src/app-gocardless/bank-factory.js index 3b36193c0..1e084a2cc 100644 --- a/src/app-gocardless/bank-factory.js +++ b/src/app-gocardless/bank-factory.js @@ -22,6 +22,7 @@ import SandboxfinanceSfin0000 from './banks/sandboxfinance-sfin0000.js'; import SparNordSpNoDK22 from './banks/sparnord-spnodk22.js'; import SpkKarlsruhekarsde66 from './banks/spk-karlsruhe-karsde66.js'; import SpkMarburgBiedenkopfHeladef1mar from './banks/spk-marburg-biedenkopf-heladef1mar.js'; +import spk_worms_alzey_ried_malade51wor from './banks/spk_worms_alzey_ried_malade51wor.js'; import VirginNrnbgb22 from './banks/virgin_nrnbgb22.js'; export const banks = [ @@ -48,6 +49,7 @@ export const banks = [ SparNordSpNoDK22, SpkKarlsruhekarsde66, SpkMarburgBiedenkopfHeladef1mar, + spk_worms_alzey_ried_malade51wor, VirginNrnbgb22, ]; diff --git a/src/app-gocardless/banks/spk_worms_alzey_ried_malade51wor.js b/src/app-gocardless/banks/spk_worms_alzey_ried_malade51wor.js new file mode 100644 index 000000000..8f6c7972f --- /dev/null +++ b/src/app-gocardless/banks/spk_worms_alzey_ried_malade51wor.js @@ -0,0 +1,66 @@ +import Fallback from './integration-bank.js'; + +import { printIban, amountToInteger } from '../utils.js'; +import { formatPayeeName } from '../../util/payee-name.js'; + +/** @type {import('./bank.interface.js').IBank} */ +export default { + ...Fallback, + + institutionIds: ['SPK_WORMS_ALZEY_RIED_MALADE51WOR'], + + accessValidForDays: 90, + + normalizeAccount(account) { + return { + account_id: account.id, + institution: account.institution, + mask: account.iban.slice(-4), + iban: account.iban, + name: [account.name, printIban(account)].join(' '), + official_name: account.product, + type: 'checking', + }; + }, + + normalizeTransaction(transaction, _booked) { + const date = + transaction.bookingDate || + transaction.valueDate; + if (!date) { + return null; + } + + let remittanceInformationUnstructured; + + if (transaction.remittanceInformationUnstructured) { + remittanceInformationUnstructured = + transaction.remittanceInformationUnstructured; + } else if (transaction.remittanceInformationStructured) { + remittanceInformationUnstructured = + transaction.remittanceInformationUnstructured; + } else if (transaction.remittanceInformationStructuredArray?.length > 0) { + remittanceInformationUnstructured = + transaction.remittanceInformationStructuredArray?.join(' '); + } + + transaction.remittanceInformationUnstructured = + remittanceInformationUnstructured; + return { + ...transaction, + payeeName: formatPayeeName(transaction), + date: transaction.bookingDate || transaction.valueDate, + }; + }, + + + calculateStartingBalance(sortedTransactions = [], balances = []) { + const currentBalance = balances.find( + (balance) => 'interimAvailable' === balance.balanceType, + ); + + return sortedTransactions.reduce((total, trans) => { + return total - amountToInteger(trans.transactionAmount.amount); + }, amountToInteger(currentBalance.balanceAmount.amount)); + }, +}; From 9ee4421d5c52dbd53301a9ccde2d903420dab6a2 Mon Sep 17 00:00:00 2001 From: DirgoSalga Date: Sun, 15 Sep 2024 21:39:58 +0200 Subject: [PATCH 02/11] FIx linting errors and add release notes Replaced the indentation from 4 spaces to 2, to fix linting error as recommended by the yarn test. Added the release notes file 454.md. --- .../banks/spk_worms_alzey_ried_malade51wor.js | 96 +++++++++---------- upcoming-release-notes/454.md | 6 ++ 2 files changed, 54 insertions(+), 48 deletions(-) create mode 100644 upcoming-release-notes/454.md diff --git a/src/app-gocardless/banks/spk_worms_alzey_ried_malade51wor.js b/src/app-gocardless/banks/spk_worms_alzey_ried_malade51wor.js index 8f6c7972f..b7ce02e28 100644 --- a/src/app-gocardless/banks/spk_worms_alzey_ried_malade51wor.js +++ b/src/app-gocardless/banks/spk_worms_alzey_ried_malade51wor.js @@ -5,62 +5,62 @@ import { formatPayeeName } from '../../util/payee-name.js'; /** @type {import('./bank.interface.js').IBank} */ export default { - ...Fallback, + ...Fallback, - institutionIds: ['SPK_WORMS_ALZEY_RIED_MALADE51WOR'], + institutionIds: ['SPK_WORMS_ALZEY_RIED_MALADE51WOR'], - accessValidForDays: 90, + accessValidForDays: 90, - normalizeAccount(account) { - return { - account_id: account.id, - institution: account.institution, - mask: account.iban.slice(-4), - iban: account.iban, - name: [account.name, printIban(account)].join(' '), - official_name: account.product, - type: 'checking', - }; - }, + normalizeAccount(account) { + return { + account_id: account.id, + institution: account.institution, + mask: account.iban.slice(-4), + iban: account.iban, + name: [account.name, printIban(account)].join(' '), + official_name: account.product, + type: 'checking', + }; + }, - normalizeTransaction(transaction, _booked) { - const date = - transaction.bookingDate || - transaction.valueDate; - if (!date) { - return null; - } + normalizeTransaction(transaction, _booked) { + const date = + transaction.bookingDate || + transaction.valueDate; + if (!date) { + return null; + } - let remittanceInformationUnstructured; + let remittanceInformationUnstructured; - if (transaction.remittanceInformationUnstructured) { - remittanceInformationUnstructured = - transaction.remittanceInformationUnstructured; - } else if (transaction.remittanceInformationStructured) { - remittanceInformationUnstructured = - transaction.remittanceInformationUnstructured; - } else if (transaction.remittanceInformationStructuredArray?.length > 0) { - remittanceInformationUnstructured = - transaction.remittanceInformationStructuredArray?.join(' '); - } + if (transaction.remittanceInformationUnstructured) { + remittanceInformationUnstructured = + transaction.remittanceInformationUnstructured; + } else if (transaction.remittanceInformationStructured) { + remittanceInformationUnstructured = + transaction.remittanceInformationUnstructured; + } else if (transaction.remittanceInformationStructuredArray?.length > 0) { + remittanceInformationUnstructured = + transaction.remittanceInformationStructuredArray?.join(' '); + } - transaction.remittanceInformationUnstructured = - remittanceInformationUnstructured; - return { - ...transaction, - payeeName: formatPayeeName(transaction), - date: transaction.bookingDate || transaction.valueDate, - }; - }, + transaction.remittanceInformationUnstructured = + remittanceInformationUnstructured; + return { + ...transaction, + payeeName: formatPayeeName(transaction), + date: transaction.bookingDate || transaction.valueDate, + }; + }, - calculateStartingBalance(sortedTransactions = [], balances = []) { - const currentBalance = balances.find( - (balance) => 'interimAvailable' === balance.balanceType, - ); + calculateStartingBalance(sortedTransactions = [], balances = []) { + const currentBalance = balances.find( + (balance) => 'interimAvailable' === balance.balanceType, + ); - return sortedTransactions.reduce((total, trans) => { - return total - amountToInteger(trans.transactionAmount.amount); - }, amountToInteger(currentBalance.balanceAmount.amount)); - }, + return sortedTransactions.reduce((total, trans) => { + return total - amountToInteger(trans.transactionAmount.amount); + }, amountToInteger(currentBalance.balanceAmount.amount)); + }, }; diff --git a/upcoming-release-notes/454.md b/upcoming-release-notes/454.md new file mode 100644 index 000000000..d7148b62a --- /dev/null +++ b/upcoming-release-notes/454.md @@ -0,0 +1,6 @@ +--- +category: Enhancements +authors: DirgoSalga +--- + +Add integration of Rheinhessen Sparkasse (SPK_WORMS_ALZEY_RIED_MALADE51WOR) to the GoCardless app \ No newline at end of file From be81684eb82d48561493e0e38a0bb863c785449e Mon Sep 17 00:00:00 2001 From: DirgoSalga Date: Sun, 15 Sep 2024 21:43:46 +0200 Subject: [PATCH 03/11] FIx linting errors (second try) and fix error in the release notes --- src/app-gocardless/banks/spk_worms_alzey_ried_malade51wor.js | 4 +--- upcoming-release-notes/454.md | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/app-gocardless/banks/spk_worms_alzey_ried_malade51wor.js b/src/app-gocardless/banks/spk_worms_alzey_ried_malade51wor.js index b7ce02e28..f29858158 100644 --- a/src/app-gocardless/banks/spk_worms_alzey_ried_malade51wor.js +++ b/src/app-gocardless/banks/spk_worms_alzey_ried_malade51wor.js @@ -24,8 +24,7 @@ export default { }, normalizeTransaction(transaction, _booked) { - const date = - transaction.bookingDate || + const date = transaction.bookingDate || transaction.valueDate; if (!date) { return null; @@ -53,7 +52,6 @@ export default { }; }, - calculateStartingBalance(sortedTransactions = [], balances = []) { const currentBalance = balances.find( (balance) => 'interimAvailable' === balance.balanceType, diff --git a/upcoming-release-notes/454.md b/upcoming-release-notes/454.md index d7148b62a..9075a1e13 100644 --- a/upcoming-release-notes/454.md +++ b/upcoming-release-notes/454.md @@ -1,6 +1,6 @@ --- category: Enhancements -authors: DirgoSalga +authors: [DirgoSalga] --- Add integration of Rheinhessen Sparkasse (SPK_WORMS_ALZEY_RIED_MALADE51WOR) to the GoCardless app \ No newline at end of file From 5b53bf7b2e144c1ad2f3f866210eb64a48601aea Mon Sep 17 00:00:00 2001 From: DirgoSalga Date: Sun, 15 Sep 2024 21:45:29 +0200 Subject: [PATCH 04/11] Fix linting errors --- src/app-gocardless/banks/spk_worms_alzey_ried_malade51wor.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/app-gocardless/banks/spk_worms_alzey_ried_malade51wor.js b/src/app-gocardless/banks/spk_worms_alzey_ried_malade51wor.js index f29858158..bf9041399 100644 --- a/src/app-gocardless/banks/spk_worms_alzey_ried_malade51wor.js +++ b/src/app-gocardless/banks/spk_worms_alzey_ried_malade51wor.js @@ -24,8 +24,7 @@ export default { }, normalizeTransaction(transaction, _booked) { - const date = transaction.bookingDate || - transaction.valueDate; + const date = transaction.bookingDate || transaction.valueDate; if (!date) { return null; } From 42b60536cb29afb15b5e1c645c7f6c33e6e3d86d Mon Sep 17 00:00:00 2001 From: DirgoSalga Date: Sat, 21 Sep 2024 00:12:08 +0200 Subject: [PATCH 05/11] Update src/app-gocardless/bank-factory.js Co-authored-by: Matt Fiddaman --- src/app-gocardless/bank-factory.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app-gocardless/bank-factory.js b/src/app-gocardless/bank-factory.js index debeeef0e..f459c70ab 100644 --- a/src/app-gocardless/bank-factory.js +++ b/src/app-gocardless/bank-factory.js @@ -23,7 +23,7 @@ import SandboxfinanceSfin0000 from './banks/sandboxfinance-sfin0000.js'; import SparNordSpNoDK22 from './banks/sparnord-spnodk22.js'; import SpkKarlsruhekarsde66 from './banks/spk-karlsruhe-karsde66.js'; import SpkMarburgBiedenkopfHeladef1mar from './banks/spk-marburg-biedenkopf-heladef1mar.js'; -import spk_worms_alzey_ried_malade51wor from './banks/spk_worms_alzey_ried_malade51wor.js'; +import SpkWormsAlzeyRiedMalade51wor from './banks/spk-worms-alzey-ried-malade51wor.js'; import VirginNrnbgb22 from './banks/virgin_nrnbgb22.js'; import NbgEthngraaxxx from './banks/nbg_ethngraaxxx.js'; From 2a995779adbc759bc22a9d2b00888a8f73839555 Mon Sep 17 00:00:00 2001 From: DirgoSalga Date: Sat, 21 Sep 2024 00:12:20 +0200 Subject: [PATCH 06/11] Update src/app-gocardless/bank-factory.js Co-authored-by: Matt Fiddaman --- src/app-gocardless/bank-factory.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app-gocardless/bank-factory.js b/src/app-gocardless/bank-factory.js index f459c70ab..0528a535b 100644 --- a/src/app-gocardless/bank-factory.js +++ b/src/app-gocardless/bank-factory.js @@ -52,7 +52,7 @@ export const banks = [ SparNordSpNoDK22, SpkKarlsruhekarsde66, SpkMarburgBiedenkopfHeladef1mar, - spk_worms_alzey_ried_malade51wor, + SpkWormsAlzeyRiedMalade51wor, VirginNrnbgb22, NbgEthngraaxxx, ]; From ca314e2e1b4c97761678d9be0736474cd92c66a2 Mon Sep 17 00:00:00 2001 From: DirgoSalga Date: Sat, 21 Sep 2024 00:12:28 +0200 Subject: [PATCH 07/11] Update src/app-gocardless/banks/spk_worms_alzey_ried_malade51wor.js Co-authored-by: Matt Fiddaman --- .../banks/spk_worms_alzey_ried_malade51wor.js | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/src/app-gocardless/banks/spk_worms_alzey_ried_malade51wor.js b/src/app-gocardless/banks/spk_worms_alzey_ried_malade51wor.js index bf9041399..130b4a6d9 100644 --- a/src/app-gocardless/banks/spk_worms_alzey_ried_malade51wor.js +++ b/src/app-gocardless/banks/spk_worms_alzey_ried_malade51wor.js @@ -29,21 +29,10 @@ export default { return null; } - let remittanceInformationUnstructured; - - if (transaction.remittanceInformationUnstructured) { - remittanceInformationUnstructured = - transaction.remittanceInformationUnstructured; - } else if (transaction.remittanceInformationStructured) { - remittanceInformationUnstructured = - transaction.remittanceInformationUnstructured; - } else if (transaction.remittanceInformationStructuredArray?.length > 0) { - remittanceInformationUnstructured = - transaction.remittanceInformationStructuredArray?.join(' '); - } - transaction.remittanceInformationUnstructured = - remittanceInformationUnstructured; + transaction.remittanceInformationUnstructured ?? + transaction.remittanceInformationStructured ?? + transaction.remittanceInformationStructuredArray?.join(' '); return { ...transaction, payeeName: formatPayeeName(transaction), From ebc0e5c3b0e836d04043c04bc902ba4057cecbcf Mon Sep 17 00:00:00 2001 From: DirgoSalga Date: Sat, 21 Sep 2024 00:13:47 +0200 Subject: [PATCH 08/11] Update upcoming-release-notes/454.md Co-authored-by: Matt Fiddaman --- upcoming-release-notes/454.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/upcoming-release-notes/454.md b/upcoming-release-notes/454.md index 9075a1e13..283b35faa 100644 --- a/upcoming-release-notes/454.md +++ b/upcoming-release-notes/454.md @@ -3,4 +3,4 @@ category: Enhancements authors: [DirgoSalga] --- -Add integration of Rheinhessen Sparkasse (SPK_WORMS_ALZEY_RIED_MALADE51WOR) to the GoCardless app \ No newline at end of file +Add integration of Rheinhessen Sparkasse (`SPK_WORMS_ALZEY_RIED_MALADE51WOR`) to the GoCardless app \ No newline at end of file From 94f67b62b8cd068f5d4a807379cfdcd0dad86c33 Mon Sep 17 00:00:00 2001 From: DirgoSalga Date: Sat, 21 Sep 2024 00:17:24 +0200 Subject: [PATCH 09/11] Rename file "spk-worms-alzey-ried-malade51wor.js" --- ...ey_ried_malade51wor.js => spk-worms-alzey-ried-malade51wor.js} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/app-gocardless/banks/{spk_worms_alzey_ried_malade51wor.js => spk-worms-alzey-ried-malade51wor.js} (100%) diff --git a/src/app-gocardless/banks/spk_worms_alzey_ried_malade51wor.js b/src/app-gocardless/banks/spk-worms-alzey-ried-malade51wor.js similarity index 100% rename from src/app-gocardless/banks/spk_worms_alzey_ried_malade51wor.js rename to src/app-gocardless/banks/spk-worms-alzey-ried-malade51wor.js From 5a84b18a4aefb1df7ad5d12bcaed16927f701fc9 Mon Sep 17 00:00:00 2001 From: DirgoSalga Date: Thu, 26 Sep 2024 01:49:31 +0200 Subject: [PATCH 10/11] Remove functions normalizeAccount and CalculateStartingBalance Since no changes were made to the default functions, they should be deleted from this specific bank (SPK_WORMS_ALZEY_RIED_MALADE51WOR). --- .../banks/spk-worms-alzey-ried-malade51wor.js | 22 ------------------- 1 file changed, 22 deletions(-) diff --git a/src/app-gocardless/banks/spk-worms-alzey-ried-malade51wor.js b/src/app-gocardless/banks/spk-worms-alzey-ried-malade51wor.js index 130b4a6d9..1ab0d224e 100644 --- a/src/app-gocardless/banks/spk-worms-alzey-ried-malade51wor.js +++ b/src/app-gocardless/banks/spk-worms-alzey-ried-malade51wor.js @@ -11,18 +11,6 @@ export default { accessValidForDays: 90, - normalizeAccount(account) { - return { - account_id: account.id, - institution: account.institution, - mask: account.iban.slice(-4), - iban: account.iban, - name: [account.name, printIban(account)].join(' '), - official_name: account.product, - type: 'checking', - }; - }, - normalizeTransaction(transaction, _booked) { const date = transaction.bookingDate || transaction.valueDate; if (!date) { @@ -39,14 +27,4 @@ export default { date: transaction.bookingDate || transaction.valueDate, }; }, - - calculateStartingBalance(sortedTransactions = [], balances = []) { - const currentBalance = balances.find( - (balance) => 'interimAvailable' === balance.balanceType, - ); - - return sortedTransactions.reduce((total, trans) => { - return total - amountToInteger(trans.transactionAmount.amount); - }, amountToInteger(currentBalance.balanceAmount.amount)); - }, }; From 87b2080f11136d8564bb1aeaf1aa6becca02f90e Mon Sep 17 00:00:00 2001 From: DirgoSalga Date: Thu, 26 Sep 2024 01:53:23 +0200 Subject: [PATCH 11/11] Correct linting error Remove import of unsed variables. --- src/app-gocardless/banks/spk-worms-alzey-ried-malade51wor.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/app-gocardless/banks/spk-worms-alzey-ried-malade51wor.js b/src/app-gocardless/banks/spk-worms-alzey-ried-malade51wor.js index 1ab0d224e..fb45cee0d 100644 --- a/src/app-gocardless/banks/spk-worms-alzey-ried-malade51wor.js +++ b/src/app-gocardless/banks/spk-worms-alzey-ried-malade51wor.js @@ -1,6 +1,5 @@ import Fallback from './integration-bank.js'; -import { printIban, amountToInteger } from '../utils.js'; import { formatPayeeName } from '../../util/payee-name.js'; /** @type {import('./bank.interface.js').IBank} */