From 33c204dedbe9bc1e4eafb6d7f846a6c44170c72a Mon Sep 17 00:00:00 2001 From: Jakob Lover Date: Sat, 4 May 2024 12:41:26 +0200 Subject: [PATCH] Extend bank adapter for SEB Kort (#350) --- src/app-gocardless/banks/seb-kort-bank-ab.js | 12 ++++++++---- upcoming-release-notes/350.md | 6 ++++++ 2 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 upcoming-release-notes/350.md diff --git a/src/app-gocardless/banks/seb-kort-bank-ab.js b/src/app-gocardless/banks/seb-kort-bank-ab.js index 7eae5bc81..d53e81772 100644 --- a/src/app-gocardless/banks/seb-kort-bank-ab.js +++ b/src/app-gocardless/banks/seb-kort-bank-ab.js @@ -6,7 +6,7 @@ import { /** @type {import('./bank.interface.js').IBank} */ export default { - institutionIds: ['SEB_KORT_AB_SE_SKHSFI21'], + institutionIds: ['SEB_KORT_AB_NO_SKHSFI21', 'SEB_KORT_AB_SE_SKHSFI21'], accessValidForDays: 180, @@ -44,11 +44,11 @@ export default { }, /** - * For SEB_KORT_AB_SE_SKHSFI21 we don't know what balance was + * For SEB_KORT_AB_NO_SKHSFI21 and SEB_KORT_AB_SE_SKHSFI21 we don't know what balance was * after each transaction so we have to calculate it by getting * current balance from the account and subtract all the transactions * - * As a current balance we use `expected` balance type because it + * As a current balance we use `expected` and `nonInvoiced` balance types because it * corresponds to the current running balance, whereas `interimAvailable` * holds the remaining credit limit. */ @@ -57,8 +57,12 @@ export default { (balance) => 'expected' === balance.balanceType, ); + const nonInvoiced = balances.find( + (balance) => 'nonInvoiced' === balance.balanceType, + ); + return sortedTransactions.reduce((total, trans) => { return total - amountToInteger(trans.transactionAmount.amount); - }, -amountToInteger(currentBalance.balanceAmount.amount)); + }, -amountToInteger(currentBalance.balanceAmount.amount) + amountToInteger(nonInvoiced.balanceAmount.amount)); }, }; diff --git a/upcoming-release-notes/350.md b/upcoming-release-notes/350.md new file mode 100644 index 000000000..c235def04 --- /dev/null +++ b/upcoming-release-notes/350.md @@ -0,0 +1,6 @@ +--- +category: Enhancements +authors: [jakoblover] +--- + +Extended bank adapter for SEB to support SEB_KORT_AB_NO_SKHSFI21