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

[WIP] Add support for DKB Bank #500

Closed
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 @@ -28,6 +28,7 @@ import SpkMarburgBiedenkopfHeladef1mar from './banks/spk-marburg-biedenkopf-hela
import SpkWormsAlzeyRiedMalade51wor from './banks/spk-worms-alzey-ried-malade51wor.js';
import SwedbankHabaLV22 from './banks/swedbank-habalv22.js';
import VirginNrnbgb22 from './banks/virgin_nrnbgb22.js';
import Dkb_byladem1 from './banks/dkb_byladem1.js';

export const banks = [
AbancaCaglesmm,
Expand Down Expand Up @@ -59,6 +60,7 @@ export const banks = [
SpkWormsAlzeyRiedMalade51wor,
SwedbankHabaLV22,
VirginNrnbgb22,
Dkb_byladem1,
];

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

/** @type {import('./bank.interface.js').IBank} */
export default {
...Fallback,

accessValidForDays: 180,

institutionIds: ['DKB_BYLADEM1'],

normalizeAccount(account) {
return {
account_id: account.id,
institution: account.institution,
mask: account.iban.slice(-4),
iban: account.iban,
name: [account.product, printIban(account)].join(' '),
official_name: account.product,
type: 'checking',
};
},

sortTransactions(transactions = []) {
const dateFormat = "yyyy-MM-dd-HH.mm.ss.SSSSSS'Z'";
return transactions.sort((a, b) => {
const dateA = d.parse(a.transactionId, dateFormat, new Date());
const dateB = d.parse(b.transactionId, dateFormat, new Date());
return d.compareAsc(dateA, dateB);
});
},
};
121 changes: 121 additions & 0 deletions src/app-gocardless/banks/tests/dkb_byladem1.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
import Dkb_byladem1 from '../dkb_byladem1.js';
import { mockTransactionAmount } from '../../services/tests/fixtures.js';

describe('dkb_byladem1', function () {
describe('#normalizeAccount', function () {
it('should normalize the account information', function () {
/** @type {import('../../gocardless.types.js').DetailedAccountWithInstitution} */
const accountRaw = {
resourceId: 'd1c61254-242e-4a88-aaff-8490846e2491',
iban: 'DE02500105170137075030',
currency: 'EUR',
ownerName: 'Jane Doe',
product: 'Girokonto',
id: 'a787ba27-02ee-4fd6-be86-73831adc5498',
created: '2023-09-04T14:38:58.841381Z',
last_accessed: '2024-11-08T08:48:39.667722Z',
institution_id: 'DKB_BYLADEM1',
status: 'READY',
owner_name: 'Jane Doe',
cashAccountType: 'CACC',
usage: 'PRIV',
institution: {
id: 'DKB_BYLADEM1',
name: 'Deutsche Kreditbank AG (DKB)',
bic: 'BALLADE1001',
transaction_total_days: '365',
countries: ['DE'],
logo: 'https://storage.googleapis.com/gc-prd-institution_icons-production/DE/PNG/deutschekreditbank.png',
supported_payments: {
'single-payment': ['SCT', 'ISCSI'],
},
supported_features: [
'business_accounts',
'corporate_accounts',
'payments',
'pending_transactions',
'private_accounts',
],
},
};

/** @type {import('../../gocardless.types.js').NormalizedAccountDetails} */
const expected = {
account_id: 'a787ba27-02ee-4fd6-be86-73831adc5498',
iban: 'DE02500105170137075030',
institution: {
id: 'DKB_BYLADEM1',
name: 'Deutsche Kreditbank AG (DKB)',
bic: 'BALLADE1001',
transaction_total_days: '365',
countries: ['DE'],
logo: 'https://storage.googleapis.com/gc-prd-institution_icons-production/DE/PNG/deutschekreditbank.png',
supported_payments: {
'single-payment': ['SCT', 'ISCSI'],
},
supported_features: [
'business_accounts',
'corporate_accounts',
'payments',
'pending_transactions',
'private_accounts',
],
},
mask: '5030',
name: 'Girokonto (XXX 5030)',
official_name: 'Girokonto',
type: 'checking',
};

const actual = Dkb_byladem1.normalizeAccount(accountRaw);
expect(actual).toEqual(expected);
});
});

describe('#sortTransactions', function () {
it('should sort by transaction id', function () {
/** @type {import('../../gocardless-node.types.js').Transaction[]} */
const transactionsRaw = [
{
transactionId: '2024-11-05-00.25.38.982769Z',
transactionAmount: mockTransactionAmount,
},
{
transactionId: '2024-11-05-01.25.38.982769Z',
transactionAmount: mockTransactionAmount,
},
{
transactionId: '2024-11-04-01.26.38.982769Z',
transactionAmount: mockTransactionAmount,
},
{
transactionId: '2024-11-05-01.26.38.982769Z',
transactionAmount: mockTransactionAmount,
},
];

/** @type {import('../../gocardless-node.types.js').Transaction[]} */
const expected = [
{
transactionId: '2024-11-04-01.26.38.982769Z',
transactionAmount: mockTransactionAmount,
},
{
transactionId: '2024-11-05-00.25.38.982769Z',
transactionAmount: mockTransactionAmount,
},
{
transactionId: '2024-11-05-01.25.38.982769Z',
transactionAmount: mockTransactionAmount,
},
{
transactionId: '2024-11-05-01.26.38.982769Z',
transactionAmount: mockTransactionAmount,
},
];

const actual = Dkb_byladem1.sortTransactions(transactionsRaw);
expect(actual).toEqual(expected);
});
});
});
6 changes: 6 additions & 0 deletions upcoming-release-notes/500.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Features
authors: [mrsteakhouse]
---

Implements support for sync with DKB bank accounts.