From 277964018446298a06176b8841583f4ce2c3f7cd Mon Sep 17 00:00:00 2001 From: Lenno Nagel Date: Wed, 8 Jan 2025 09:41:45 +0200 Subject: [PATCH] Add support for LHV_LHVBEE22 --- src/app-gocardless/bank-factory.js | 2 ++ src/app-gocardless/banks/lhv-lhvbee22.js | 32 ++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 src/app-gocardless/banks/lhv-lhvbee22.js diff --git a/src/app-gocardless/bank-factory.js b/src/app-gocardless/bank-factory.js index 1f2e3068..d3612fdd 100644 --- a/src/app-gocardless/bank-factory.js +++ b/src/app-gocardless/bank-factory.js @@ -20,6 +20,7 @@ import IngPlIngbplpw from './banks/ing-pl-ingbplpw.js'; import IntegrationBank from './banks/integration-bank.js'; import IsyBankItbbitmm from './banks/isybank-itbbitmm.js'; import KBCkredbebb from './banks/kbc_kredbebb.js'; +import LhvLhvbee22 from './banks/lhv-lhvbee22.js'; import MbankRetailBrexplpw from './banks/mbank-retail-brexplpw.js'; import NationwideNaiaGB21 from './banks/nationwide-naiagb21.js'; import NbgEthngraaxxx from './banks/nbg_ethngraaxxx.js'; @@ -58,6 +59,7 @@ export const banks = [ IngPlIngbplpw, IsyBankItbbitmm, KBCkredbebb, + LhvLhvbee22, MbankRetailBrexplpw, NationwideNaiaGB21, NbgEthngraaxxx, diff --git a/src/app-gocardless/banks/lhv-lhvbee22.js b/src/app-gocardless/banks/lhv-lhvbee22.js new file mode 100644 index 00000000..188872cb --- /dev/null +++ b/src/app-gocardless/banks/lhv-lhvbee22.js @@ -0,0 +1,32 @@ +import Fallback from './integration-bank.js'; + +/** @type {import('./bank.interface.js').IBank} */ +export default { + ...Fallback, + + institutionIds: ['LHV_LHVBEE22'], + + accessValidForDays: 90, + + normalizeTransaction(transaction, booked) { + // extract bookingDate and creditorName for card transactions, e.g. + // (..1234) 2025-01-02 09:32 CrustumOU\Poordi 3\Tallinn\10156 ESTEST + // bookingDate: 2025-01-02 + // creditorName: CrustumOU + const cardTxRegex = + /^\(\.\.(\d{4})\) (\d{4}-\d{2}-\d{2}) (\d{2}:\d{2}) (.+)$/g; + const cardTxMatch = cardTxRegex.exec( + transaction?.remittanceInformationUnstructured, + ); + + if (cardTxMatch) { + transaction = { + ...transaction, + bookingDate: cardTxMatch[2], + creditorName: cardTxMatch[4].split('\\')[0].trim(), + }; + } + + return Fallback.normalizeTransaction(transaction, booked); + }, +};