Skip to content

Commit

Permalink
Extend bank adapter for SEB Kort (#350)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakoblover authored May 4, 2024
1 parent 41a34d0 commit 33c204d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/app-gocardless/banks/seb-kort-bank-ab.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand Down Expand Up @@ -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.
*/
Expand All @@ -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));
},
};
6 changes: 6 additions & 0 deletions upcoming-release-notes/350.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Enhancements
authors: [jakoblover]
---

Extended bank adapter for SEB to support SEB_KORT_AB_NO_SKHSFI21

0 comments on commit 33c204d

Please sign in to comment.