Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend bank adapter for SEB Kort #350

Merged
merged 3 commits into from
May 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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