Skip to content
This repository was archived by the owner on Feb 10, 2025. It is now read-only.

Commit 6e9edde

Browse files
authored
feat: add SEB Privat bank (#316)
1 parent b926af2 commit 6e9edde

File tree

3 files changed

+75
-0
lines changed

3 files changed

+75
-0
lines changed

src/app-gocardless/bank-factory.js

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import DanskeBankDabNO22 from './banks/danskebank-dabno22.js';
1010
import SparNordSpNoDK22 from './banks/sparnord-spnodk22.js';
1111
import Belfius from './banks/belfius_gkccbebb.js';
1212
import SpkMarburgBiedenkopfHeladef1mar from './banks/spk-marburg-biedenkopf-heladef1mar.js';
13+
import SEBPrivat from './banks/seb-privat.js';
1314

1415
const banks = [
1516
AmericanExpressAesudef1,
@@ -23,6 +24,7 @@ const banks = [
2324
SparNordSpNoDK22,
2425
Belfius,
2526
SpkMarburgBiedenkopfHeladef1mar,
27+
SEBPrivat,
2628
];
2729

2830
export default (institutionId) =>
+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import * as d from 'date-fns';
2+
import {
3+
sortByBookingDateOrValueDate,
4+
amountToInteger,
5+
printIban,
6+
} from '../utils.js';
7+
8+
/** @type {import('./bank.interface.js').IBank} */
9+
export default {
10+
institutionIds: ['SEB_ESSESESS_PRIVATE'],
11+
normalizeAccount(account) {
12+
console.log(
13+
'Available account properties for new institution integration',
14+
{ account: JSON.stringify(account) },
15+
);
16+
17+
return {
18+
account_id: account.id,
19+
institution: account.institution,
20+
mask: (account?.iban || '0000').slice(-4),
21+
iban: account?.iban || null,
22+
name: [account.name, printIban(account), account.currency]
23+
.filter(Boolean)
24+
.join(' '),
25+
official_name: `integration-${account.institution_id}`,
26+
type: 'checking',
27+
};
28+
},
29+
30+
normalizeTransaction(transaction, _booked) {
31+
const date =
32+
transaction.bookingDate ||
33+
transaction.bookingDateTime ||
34+
transaction.valueDate ||
35+
transaction.valueDateTime;
36+
// If we couldn't find a valid date field we filter out this transaction
37+
// and hope that we will import it again once the bank has processed the
38+
// transaction further.
39+
if (!date) {
40+
return null;
41+
}
42+
return {
43+
...transaction,
44+
// Creditor name is stored in additionInformation for SEB
45+
creditorName: transaction.additionalInformation,
46+
date: d.format(d.parseISO(date), 'yyyy-MM-dd'),
47+
};
48+
},
49+
50+
sortTransactions(transactions = []) {
51+
console.log(
52+
'Available (first 10) transactions properties for new integration of institution in sortTransactions function',
53+
{ top10Transactions: JSON.stringify(transactions.slice(0, 10)) },
54+
);
55+
return sortByBookingDateOrValueDate(transactions);
56+
},
57+
58+
calculateStartingBalance(sortedTransactions = [], balances = []) {
59+
const currentBalance = balances.find(
60+
(balance) => 'interimBooked' === balance.balanceType,
61+
);
62+
63+
return sortedTransactions.reduce((total, trans) => {
64+
return total - amountToInteger(trans.transactionAmount.amount);
65+
}, amountToInteger(currentBalance.balanceAmount.amount));
66+
},
67+
};

upcoming-release-notes/316.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
category: Features
3+
authors: [myhrmans]
4+
---
5+
6+
Add SEB Private Bank integration to gocardless. Handle that SEB is sending the creditor name in additionalInfo.

0 commit comments

Comments
 (0)