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

feat: add SEB Privat bank #316

Merged
merged 3 commits into from
Mar 3, 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
2 changes: 2 additions & 0 deletions src/app-gocardless/bank-factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import DanskeBankDabNO22 from './banks/danskebank-dabno22.js';
import SparNordSpNoDK22 from './banks/sparnord-spnodk22.js';
import Belfius from './banks/belfius_gkccbebb.js';
import SpkMarburgBiedenkopfHeladef1mar from './banks/spk-marburg-biedenkopf-heladef1mar.js';
import SEBPrivat from './banks/seb-privat.js';

const banks = [
AmericanExpressAesudef1,
Expand All @@ -23,6 +24,7 @@ const banks = [
SparNordSpNoDK22,
Belfius,
SpkMarburgBiedenkopfHeladef1mar,
SEBPrivat,
];

export default (institutionId) =>
Expand Down
67 changes: 67 additions & 0 deletions src/app-gocardless/banks/seb-privat.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import * as d from 'date-fns';
import {
sortByBookingDateOrValueDate,
amountToInteger,
printIban,
} from '../utils.js';

/** @type {import('./bank.interface.js').IBank} */
export default {
institutionIds: ['SEB_ESSESESS_PRIVATE'],
normalizeAccount(account) {
console.log(
'Available account properties for new institution integration',
{ account: JSON.stringify(account) },
);

return {
account_id: account.id,
institution: account.institution,
mask: (account?.iban || '0000').slice(-4),
iban: account?.iban || null,
name: [account.name, printIban(account), account.currency]
.filter(Boolean)
.join(' '),
official_name: `integration-${account.institution_id}`,
type: 'checking',
};
},

normalizeTransaction(transaction, _booked) {
const date =
transaction.bookingDate ||
transaction.bookingDateTime ||
transaction.valueDate ||
transaction.valueDateTime;
// If we couldn't find a valid date field we filter out this transaction
// and hope that we will import it again once the bank has processed the
// transaction further.
if (!date) {
return null;
}
return {
...transaction,
// Creditor name is stored in additionInformation for SEB
creditorName: transaction.additionalInformation,
date: d.format(d.parseISO(date), 'yyyy-MM-dd'),
};
},

sortTransactions(transactions = []) {
console.log(
'Available (first 10) transactions properties for new integration of institution in sortTransactions function',
{ top10Transactions: JSON.stringify(transactions.slice(0, 10)) },
);
return sortByBookingDateOrValueDate(transactions);
},

calculateStartingBalance(sortedTransactions = [], balances = []) {
const currentBalance = balances.find(
(balance) => 'interimBooked' === balance.balanceType,
);

return sortedTransactions.reduce((total, trans) => {
return total - amountToInteger(trans.transactionAmount.amount);
}, amountToInteger(currentBalance.balanceAmount.amount));
},
};
6 changes: 6 additions & 0 deletions upcoming-release-notes/316.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Features
authors: [myhrmans]
---

Add SEB Private Bank integration to gocardless. Handle that SEB is sending the creditor name in additionalInfo.