Skip to content

Commit

Permalink
Add support for LHV_LHVBEE22
Browse files Browse the repository at this point in the history
  • Loading branch information
lnagel committed Jan 8, 2025
1 parent 0637b1d commit 2779640
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/app-gocardless/bank-factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -58,6 +59,7 @@ export const banks = [
IngPlIngbplpw,
IsyBankItbbitmm,
KBCkredbebb,
LhvLhvbee22,
MbankRetailBrexplpw,
NationwideNaiaGB21,
NbgEthngraaxxx,
Expand Down
32 changes: 32 additions & 0 deletions src/app-gocardless/banks/lhv-lhvbee22.js
Original file line number Diff line number Diff line change
@@ -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);
},
};

0 comments on commit 2779640

Please sign in to comment.