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

Commit e1ffa97

Browse files
authored
Merge branch 'master' into master
2 parents 7a2a7df + 33c204d commit e1ffa97

File tree

13 files changed

+127
-47
lines changed

13 files changed

+127
-47
lines changed

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "actual-sync",
3-
"version": "24.4.0",
3+
"version": "24.5.0",
44
"license": "MIT",
55
"description": "actual syncing server",
66
"type": "module",
@@ -16,7 +16,7 @@
1616
},
1717
"dependencies": {
1818
"@actual-app/crdt": "2.1.0",
19-
"@actual-app/web": "24.4.0",
19+
"@actual-app/web": "24.5.0",
2020
"bcrypt": "^5.1.0",
2121
"better-sqlite3": "^9.1.1",
2222
"body-parser": "^1.20.1",

src/app-gocardless/bank-factory.js

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import SEBPrivat from './banks/seb-privat.js';
1212
import SandboxfinanceSfin0000 from './banks/sandboxfinance-sfin0000.js';
1313
import SparNordSpNoDK22 from './banks/sparnord-spnodk22.js';
1414
import SpkMarburgBiedenkopfHeladef1mar from './banks/spk-marburg-biedenkopf-heladef1mar.js';
15+
import SpkKarlsruhekarsde66 from './banks/spk-karlsruhe-karsde66.js';
1516

1617
const banks = [
1718
AmericanExpressAesudef1,
@@ -27,6 +28,7 @@ const banks = [
2728
SandboxfinanceSfin0000,
2829
SparNordSpNoDK22,
2930
SpkMarburgBiedenkopfHeladef1mar,
31+
SpkKarlsruhekarsde66,
3032
];
3133

3234
export default (institutionId) =>

src/app-gocardless/banks/seb-kort-bank-ab.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66

77
/** @type {import('./bank.interface.js').IBank} */
88
export default {
9-
institutionIds: ['SEB_KORT_AB_SE_SKHSFI21'],
9+
institutionIds: ['SEB_KORT_AB_NO_SKHSFI21', 'SEB_KORT_AB_SE_SKHSFI21'],
1010

1111
accessValidForDays: 180,
1212

@@ -44,11 +44,11 @@ export default {
4444
},
4545

4646
/**
47-
* For SEB_KORT_AB_SE_SKHSFI21 we don't know what balance was
47+
* For SEB_KORT_AB_NO_SKHSFI21 and SEB_KORT_AB_SE_SKHSFI21 we don't know what balance was
4848
* after each transaction so we have to calculate it by getting
4949
* current balance from the account and subtract all the transactions
5050
*
51-
* As a current balance we use `expected` balance type because it
51+
* As a current balance we use `expected` and `nonInvoiced` balance types because it
5252
* corresponds to the current running balance, whereas `interimAvailable`
5353
* holds the remaining credit limit.
5454
*/
@@ -57,8 +57,12 @@ export default {
5757
(balance) => 'expected' === balance.balanceType,
5858
);
5959

60+
const nonInvoiced = balances.find(
61+
(balance) => 'nonInvoiced' === balance.balanceType,
62+
);
63+
6064
return sortedTransactions.reduce((total, trans) => {
6165
return total - amountToInteger(trans.transactionAmount.amount);
62-
}, -amountToInteger(currentBalance.balanceAmount.amount));
66+
}, -amountToInteger(currentBalance.balanceAmount.amount) + amountToInteger(nonInvoiced.balanceAmount.amount));
6367
},
6468
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
import {
2+
printIban,
3+
amountToInteger,
4+
sortByBookingDateOrValueDate,
5+
} from '../utils.js';
6+
7+
/** @type {import('./bank.interface.js').IBank} */
8+
export default {
9+
institutionIds: ['SPK_KARLSRUHE_KARSDE66XXX'],
10+
11+
accessValidForDays: 90,
12+
13+
normalizeAccount(account) {
14+
return {
15+
account_id: account.id,
16+
institution: account.institution,
17+
mask: account.iban.slice(-4),
18+
iban: account.iban,
19+
name: [account.name, printIban(account)].join(' '),
20+
official_name: account.product,
21+
type: 'checking',
22+
};
23+
},
24+
25+
/**
26+
* Following the GoCardless documentation[0] we should prefer `bookingDate`
27+
* here, though some of their bank integrations uses the date field
28+
* differently from what's describen in their documentation and so it's
29+
* sometimes necessary to use `valueDate` instead.
30+
*
31+
* [0]: https://nordigen.zendesk.com/hc/en-gb/articles/7899367372829-valueDate-and-bookingDate-for-transactions
32+
*/
33+
normalizeTransaction(transaction, _booked) {
34+
const date =
35+
transaction.bookingDate ||
36+
transaction.bookingDateTime ||
37+
transaction.valueDate ||
38+
transaction.valueDateTime;
39+
40+
// If we couldn't find a valid date field we filter out this transaction
41+
// and hope that we will import it again once the bank has processed the
42+
// transaction further.
43+
if (!date) {
44+
return null;
45+
}
46+
47+
let remittanceInformationUnstructured;
48+
49+
if (transaction.remittanceInformationUnstructured) {
50+
remittanceInformationUnstructured =
51+
transaction.remittanceInformationUnstructured;
52+
} else if (transaction.remittanceInformationStructured) {
53+
remittanceInformationUnstructured =
54+
transaction.remittanceInformationStructured;
55+
} else if (transaction.remittanceInformationStructuredArray?.length > 0) {
56+
remittanceInformationUnstructured =
57+
transaction.remittanceInformationStructuredArray?.join(' ');
58+
}
59+
60+
if (transaction.additionalInformation)
61+
remittanceInformationUnstructured +=
62+
' ' + transaction.additionalInformation;
63+
64+
const usefulCreditorName =
65+
transaction.ultimateCreditor ||
66+
transaction.creditorName ||
67+
transaction.debtorName;
68+
69+
return {
70+
...transaction,
71+
creditorName: usefulCreditorName,
72+
remittanceInformationUnstructured: remittanceInformationUnstructured,
73+
date: transaction.bookingDate || transaction.valueDate,
74+
};
75+
},
76+
77+
sortTransactions(transactions = []) {
78+
return sortByBookingDateOrValueDate(transactions);
79+
},
80+
81+
/**
82+
* For SANDBOXFINANCE_SFIN0000 we don't know what balance was
83+
* after each transaction so we have to calculate it by getting
84+
* current balance from the account and subtract all the transactions
85+
*
86+
* As a current balance we use `interimBooked` balance type because
87+
* it includes transaction placed during current day
88+
*/
89+
calculateStartingBalance(sortedTransactions = [], balances = []) {
90+
const currentBalance = balances.find(
91+
(balance) => 'interimAvailable' === balance.balanceType,
92+
);
93+
94+
return sortedTransactions.reduce((total, trans) => {
95+
return total - amountToInteger(trans.transactionAmount.amount);
96+
}, amountToInteger(currentBalance.balanceAmount.amount));
97+
},
98+
};

upcoming-release-notes/333.md

-6
This file was deleted.

upcoming-release-notes/334.md

-6
This file was deleted.

upcoming-release-notes/341.md

-6
This file was deleted.

upcoming-release-notes/342.md

-6
This file was deleted.

upcoming-release-notes/343.md

-6
This file was deleted.

upcoming-release-notes/345.md

-6
This file was deleted.

upcoming-release-notes/346.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
category: Enhancements
3+
authors: [Nebukadneza]
4+
---
5+
6+
Add gocardless support for Sparkasse Karlsruhe (Germany)

upcoming-release-notes/350.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
category: Enhancements
3+
authors: [jakoblover]
4+
---
5+
6+
Extended bank adapter for SEB to support SEB_KORT_AB_NO_SKHSFI21

yarn.lock

+5-5
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ __metadata:
1616
languageName: node
1717
linkType: hard
1818

19-
"@actual-app/web@npm:24.4.0":
20-
version: 24.4.0
21-
resolution: "@actual-app/web@npm:24.4.0"
22-
checksum: c2b8b1e5fb3e8e9ad021e78405bb1ba45ce74d32ab3f15078bae4645a7b7d2683bdcea45e34f1c88d645df60d0c20f805d8cdd5ebe7a256c6001e4d59559cd43
19+
"@actual-app/web@npm:24.5.0":
20+
version: 24.5.0
21+
resolution: "@actual-app/web@npm:24.5.0"
22+
checksum: f4200326fc5014ddf9b91922da7ed7bab0f7d370f1b288e6f6fe3fc5108778abfa2cf586c293aafa2c8725ef90a2844c7b001db0850681bd1f464533e1010f64
2323
languageName: node
2424
linkType: hard
2525

@@ -1611,7 +1611,7 @@ __metadata:
16111611
resolution: "actual-sync@workspace:."
16121612
dependencies:
16131613
"@actual-app/crdt": "npm:2.1.0"
1614-
"@actual-app/web": "npm:24.4.0"
1614+
"@actual-app/web": "npm:24.5.0"
16151615
"@babel/preset-typescript": "npm:^7.20.2"
16161616
"@types/bcrypt": "npm:^5.0.0"
16171617
"@types/better-sqlite3": "npm:^7.6.7"

0 commit comments

Comments
 (0)