From 1af5ab09e92954235cc3efff74c274c10fb4a2e9 Mon Sep 17 00:00:00 2001 From: daca11 Date: Sat, 8 Jun 2024 15:09:05 +0200 Subject: [PATCH] Grab payee name for Abanca gocardless integration (#359) --- src/app-gocardless/bank-factory.js | 2 ++ src/app-gocardless/banks/abanca-caglesmm.js | 20 +++++++++++++++ .../banks/tests/abanca-caglesmm.spec.js | 25 +++++++++++++++++++ upcoming-release-notes/359.md | 6 +++++ 4 files changed, 53 insertions(+) create mode 100644 src/app-gocardless/banks/abanca-caglesmm.js create mode 100644 src/app-gocardless/banks/tests/abanca-caglesmm.spec.js create mode 100644 upcoming-release-notes/359.md diff --git a/src/app-gocardless/bank-factory.js b/src/app-gocardless/bank-factory.js index c39e03ad2..c1665d64a 100644 --- a/src/app-gocardless/bank-factory.js +++ b/src/app-gocardless/bank-factory.js @@ -1,3 +1,4 @@ +import AbancaCaglesmm from './banks/abanca-caglesmm.js'; import AmericanExpressAesudef1 from './banks/american-express-aesudef1.js'; import BankinterBkbkesmm from './banks/bankinter-bkbkesmm.js'; import Belfius from './banks/belfius_gkccbebb.js'; @@ -16,6 +17,7 @@ import SpkMarburgBiedenkopfHeladef1mar from './banks/spk-marburg-biedenkopf-hela import SpkKarlsruhekarsde66 from './banks/spk-karlsruhe-karsde66.js'; export const banks = [ + AbancaCaglesmm, AmericanExpressAesudef1, BankinterBkbkesmm, Belfius, diff --git a/src/app-gocardless/banks/abanca-caglesmm.js b/src/app-gocardless/banks/abanca-caglesmm.js new file mode 100644 index 000000000..1cf3c6fc9 --- /dev/null +++ b/src/app-gocardless/banks/abanca-caglesmm.js @@ -0,0 +1,20 @@ +import Fallback from './integration-bank.js'; + +/** @type {import('./bank.interface.js').IBank} */ +export default { + ...Fallback, + + institutionIds: ['ABANCA_CAGLESMM'], + + accessValidForDays: 180, + + // Abanca transactions doesn't get the creditorName/debtorName properly + normalizeTransaction(transaction, _booked) { + return { + ...transaction, + creditorName: transaction.remittanceInformationStructured, + debtorName: transaction.remittanceInformationStructured, + date: transaction.bookingDate || transaction.valueDate, + }; + }, +}; diff --git a/src/app-gocardless/banks/tests/abanca-caglesmm.spec.js b/src/app-gocardless/banks/tests/abanca-caglesmm.spec.js new file mode 100644 index 000000000..c57961375 --- /dev/null +++ b/src/app-gocardless/banks/tests/abanca-caglesmm.spec.js @@ -0,0 +1,25 @@ +import Abanca from '../abanca-caglesmm.js'; +import { mockTransactionAmount } from '../../services/tests/fixtures.js'; + +describe('Abanca', () => { + describe('#normalizeTransaction', () => { + it('returns the creditorName and debtorName as remittanceInformationStructured', () => { + const transaction = { + transactionId: 'non-unique-id', + internalTransactionId: 'D202301180000003', + transactionAmount: mockTransactionAmount, + remittanceInformationStructured: 'some-creditor-name', + }; + const normalizedTransaction = Abanca.normalizeTransaction( + transaction, + true, + ); + expect(normalizedTransaction.creditorName).toEqual( + transaction.remittanceInformationStructured, + ); + expect(normalizedTransaction.debtorName).toEqual( + transaction.remittanceInformationStructured, + ); + }); + }); +}); diff --git a/upcoming-release-notes/359.md b/upcoming-release-notes/359.md new file mode 100644 index 000000000..afc234dd4 --- /dev/null +++ b/upcoming-release-notes/359.md @@ -0,0 +1,6 @@ +--- +category: Enhancements +authors: [daca11] +--- + +Get creditorName and debtorName from remittanceInformationStructured for ABANCA_CAGLESMM \ No newline at end of file