@coderoftime/fints 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +377 -0
- package/README.md +31 -23
- package/dist/client.d.ts +3 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +52 -9
- package/dist/client.js.map +1 -1
- package/dist/core/account.d.ts +15 -4
- package/dist/core/account.d.ts.map +1 -1
- package/dist/core/account.js +84 -36
- package/dist/core/account.js.map +1 -1
- package/dist/core/amount.d.ts +13 -3
- package/dist/core/amount.d.ts.map +1 -1
- package/dist/core/amount.js +42 -8
- package/dist/core/amount.js.map +1 -1
- package/dist/core/balance.d.ts +3 -0
- package/dist/core/balance.d.ts.map +1 -1
- package/dist/core/balance.js +5 -0
- package/dist/core/balance.js.map +1 -1
- package/dist/core/bank-info.d.ts +20 -3
- package/dist/core/bank-info.d.ts.map +1 -1
- package/dist/core/bank-info.js +25 -4
- package/dist/core/bank-info.js.map +1 -1
- package/dist/core/client.d.ts +42 -15
- package/dist/core/client.d.ts.map +1 -1
- package/dist/core/config.d.ts +15 -7
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/config.js +29 -14
- package/dist/core/config.js.map +1 -1
- package/dist/core/errors.d.ts +17 -5
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/core/errors.js +25 -7
- package/dist/core/errors.js.map +1 -1
- package/dist/core/feedback.d.ts +7 -0
- package/dist/core/feedback.d.ts.map +1 -1
- package/dist/core/feedback.js +10 -1
- package/dist/core/feedback.js.map +1 -1
- package/dist/core/transaction.d.ts +5 -0
- package/dist/core/transaction.d.ts.map +1 -1
- package/dist/core/transaction.js +12 -0
- package/dist/core/transaction.js.map +1 -1
- package/dist/core/transport.d.ts +22 -7
- package/dist/core/transport.d.ts.map +1 -1
- package/dist/core/transport.js +51 -11
- package/dist/core/transport.js.map +1 -1
- package/dist/formats/camt.d.ts +7 -4
- package/dist/formats/camt.d.ts.map +1 -1
- package/dist/formats/camt.js +53 -54
- package/dist/formats/camt.js.map +1 -1
- package/dist/formats/mt940.d.ts +18 -6
- package/dist/formats/mt940.d.ts.map +1 -1
- package/dist/formats/mt940.js +83 -66
- package/dist/formats/mt940.js.map +1 -1
- package/dist/formats/readers.d.ts.map +1 -1
- package/dist/formats/readers.js +6 -2
- package/dist/formats/readers.js.map +1 -1
- package/dist/formats/sepa-purpose.d.ts +7 -4
- package/dist/formats/sepa-purpose.d.ts.map +1 -1
- package/dist/formats/sepa-purpose.js +18 -9
- package/dist/formats/sepa-purpose.js.map +1 -1
- package/dist/session/dialog-runner.d.ts +5 -2
- package/dist/session/dialog-runner.d.ts.map +1 -1
- package/dist/session/dialog-runner.js +23 -7
- package/dist/session/dialog-runner.js.map +1 -1
- package/dist/session/login-guard.d.ts +4 -4
- package/dist/session/login-guard.d.ts.map +1 -1
- package/dist/session/login-guard.js +29 -14
- package/dist/session/login-guard.js.map +1 -1
- package/dist/session/session-setup.d.ts +14 -5
- package/dist/session/session-setup.d.ts.map +1 -1
- package/dist/session/session-setup.js +30 -9
- package/dist/session/session-setup.js.map +1 -1
- package/dist/session/session-state.d.ts +4 -3
- package/dist/session/session-state.d.ts.map +1 -1
- package/dist/session/session-state.js +28 -9
- package/dist/session/session-state.js.map +1 -1
- package/dist/session/signed-dialog.d.ts +19 -13
- package/dist/session/signed-dialog.d.ts.map +1 -1
- package/dist/session/signed-dialog.js +45 -30
- package/dist/session/signed-dialog.js.map +1 -1
- package/dist/session/user-prompts.d.ts +6 -1
- package/dist/session/user-prompts.d.ts.map +1 -1
- package/dist/session/user-prompts.js +19 -4
- package/dist/session/user-prompts.js.map +1 -1
- package/dist/tan/challenge.d.ts +15 -13
- package/dist/tan/challenge.d.ts.map +1 -1
- package/dist/tan/challenge.js +32 -26
- package/dist/tan/challenge.js.map +1 -1
- package/dist/tan/flicker.d.ts +5 -1
- package/dist/tan/flicker.d.ts.map +1 -1
- package/dist/tan/flicker.js +42 -30
- package/dist/tan/flicker.js.map +1 -1
- package/dist/tan/tan-image.d.ts +4 -1
- package/dist/tan/tan-image.d.ts.map +1 -1
- package/dist/tan/tan-image.js +8 -2
- package/dist/tan/tan-image.js.map +1 -1
- package/dist/tan/tan-models.d.ts +9 -1
- package/dist/tan/tan-models.d.ts.map +1 -1
- package/dist/tan/tan-models.js +14 -2
- package/dist/tan/tan-models.js.map +1 -1
- package/dist/util/arguments.d.ts +13 -0
- package/dist/util/arguments.d.ts.map +1 -0
- package/dist/util/arguments.js +40 -0
- package/dist/util/arguments.js.map +1 -0
- package/dist/util/async.d.ts +4 -1
- package/dist/util/async.d.ts.map +1 -1
- package/dist/util/async.js +6 -3
- package/dist/util/async.js.map +1 -1
- package/dist/util/bytes.d.ts +1 -1
- package/dist/util/bytes.d.ts.map +1 -1
- package/dist/util/bytes.js +3 -3
- package/dist/util/bytes.js.map +1 -1
- package/dist/util/dates.d.ts +3 -10
- package/dist/util/dates.d.ts.map +1 -1
- package/dist/util/dates.js +49 -39
- package/dist/util/dates.js.map +1 -1
- package/dist/util/errors.d.ts +5 -3
- package/dist/util/errors.d.ts.map +1 -1
- package/dist/util/errors.js +8 -4
- package/dist/util/errors.js.map +1 -1
- package/dist/util/immutable-map.d.ts +5 -2
- package/dist/util/immutable-map.d.ts.map +1 -1
- package/dist/util/immutable-map.js +15 -12
- package/dist/util/immutable-map.js.map +1 -1
- package/dist/util/inspect.d.ts +11 -0
- package/dist/util/inspect.d.ts.map +1 -0
- package/dist/util/inspect.js +14 -0
- package/dist/util/inspect.js.map +1 -0
- package/dist/util/text.d.ts +18 -2
- package/dist/util/text.d.ts.map +1 -1
- package/dist/util/text.js +50 -5
- package/dist/util/text.js.map +1 -1
- package/dist/util/xml.d.ts +6 -4
- package/dist/util/xml.d.ts.map +1 -1
- package/dist/util/xml.js +106 -44
- package/dist/util/xml.js.map +1 -1
- package/dist/v3/bank-connection.d.ts +23 -3
- package/dist/v3/bank-connection.d.ts.map +1 -1
- package/dist/v3/bank-connection.js +66 -6
- package/dist/v3/bank-connection.js.map +1 -1
- package/dist/v3/dialog.d.ts +6 -2
- package/dist/v3/dialog.d.ts.map +1 -1
- package/dist/v3/dialog.js +20 -9
- package/dist/v3/dialog.js.map +1 -1
- package/dist/v3/message.d.ts +18 -10
- package/dist/v3/message.d.ts.map +1 -1
- package/dist/v3/message.js +92 -75
- package/dist/v3/message.js.map +1 -1
- package/dist/v3/parameter-store.d.ts +43 -7
- package/dist/v3/parameter-store.d.ts.map +1 -1
- package/dist/v3/parameter-store.js +69 -15
- package/dist/v3/parameter-store.js.map +1 -1
- package/dist/v3/parameters.d.ts +12 -11
- package/dist/v3/parameters.d.ts.map +1 -1
- package/dist/v3/parameters.js +57 -35
- package/dist/v3/parameters.js.map +1 -1
- package/dist/v3/protocol.d.ts +16 -9
- package/dist/v3/protocol.d.ts.map +1 -1
- package/dist/v3/protocol.js +57 -26
- package/dist/v3/protocol.js.map +1 -1
- package/dist/v3/queries.d.ts +2 -2
- package/dist/v3/queries.d.ts.map +1 -1
- package/dist/v3/queries.js +24 -16
- package/dist/v3/queries.js.map +1 -1
- package/dist/v3/segments.d.ts +18 -11
- package/dist/v3/segments.d.ts.map +1 -1
- package/dist/v3/segments.js +30 -21
- package/dist/v3/segments.js.map +1 -1
- package/dist/v3/syntax.d.ts +15 -11
- package/dist/v3/syntax.d.ts.map +1 -1
- package/dist/v3/syntax.js +30 -15
- package/dist/v3/syntax.js.map +1 -1
- package/package.json +1 -1
- package/src/client.ts +58 -17
- package/src/core/account.ts +91 -35
- package/src/core/amount.ts +42 -9
- package/src/core/balance.ts +6 -0
- package/src/core/bank-info.ts +28 -4
- package/src/core/client.ts +42 -15
- package/src/core/config.ts +37 -18
- package/src/core/errors.ts +27 -7
- package/src/core/feedback.ts +12 -1
- package/src/core/transaction.ts +13 -0
- package/src/core/transport.ts +62 -16
- package/src/formats/camt.ts +62 -51
- package/src/formats/mt940.ts +114 -78
- package/src/formats/readers.ts +6 -2
- package/src/formats/sepa-purpose.ts +17 -9
- package/src/session/dialog-runner.ts +34 -7
- package/src/session/login-guard.ts +29 -13
- package/src/session/session-setup.ts +27 -9
- package/src/session/session-state.ts +25 -8
- package/src/session/signed-dialog.ts +60 -30
- package/src/session/user-prompts.ts +28 -3
- package/src/tan/challenge.ts +50 -36
- package/src/tan/flicker.ts +40 -29
- package/src/tan/tan-image.ts +9 -2
- package/src/tan/tan-models.ts +16 -2
- package/src/util/arguments.ts +40 -0
- package/src/util/async.ts +10 -4
- package/src/util/bytes.ts +3 -3
- package/src/util/dates.ts +52 -38
- package/src/util/errors.ts +9 -4
- package/src/util/immutable-map.ts +15 -12
- package/src/util/inspect.ts +14 -0
- package/src/util/text.ts +47 -5
- package/src/util/xml.ts +105 -38
- package/src/v3/bank-connection.ts +65 -6
- package/src/v3/dialog.ts +18 -8
- package/src/v3/message.ts +81 -72
- package/src/v3/parameter-store.ts +82 -16
- package/src/v3/parameters.ts +68 -41
- package/src/v3/protocol.ts +61 -28
- package/src/v3/queries.ts +26 -18
- package/src/v3/segments.ts +32 -20
- package/src/v3/syntax.ts +31 -14
package/dist/formats/camt.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import { Amount } from '../core/amount.js';
|
|
2
|
-
import { Transaction } from '../core/transaction.js';
|
|
3
|
-
import {
|
|
1
|
+
import { addsUpTo, Amount } from '../core/amount.js';
|
|
2
|
+
import { requireStatus, Transaction } from '../core/transaction.js';
|
|
3
|
+
import { parseIsoDate } from '../util/dates.js';
|
|
4
4
|
import { fail, FormatError } from '../util/errors.js';
|
|
5
|
+
import { frozenWithInspect } from '../util/inspect.js';
|
|
6
|
+
import { counted, maskedId, nonBlank, trimBlanks } from '../util/text.js';
|
|
5
7
|
import { parseXml } from '../util/xml.js';
|
|
8
|
+
import { maxFieldLength } from './mt940.js';
|
|
6
9
|
import { RecordBudget } from './record-budget.js';
|
|
7
10
|
import { providedReference, SepaPurpose } from './sepa-purpose.js';
|
|
8
11
|
/** Local names of the elements of a document that hold the entries of one account. */
|
|
@@ -14,22 +17,29 @@ export const Camt = Object.freeze({
|
|
|
14
17
|
* statements of several accounts, which `parse` keeps apart. Throws as `parse` does.
|
|
15
18
|
*/
|
|
16
19
|
parseTransactions(xml, status) {
|
|
17
|
-
return Camt.parse(xml, status).flatMap((s) =>
|
|
20
|
+
return Camt.parse(xml, status).flatMap((s) => s.transactions);
|
|
18
21
|
},
|
|
19
22
|
/**
|
|
20
|
-
* Parses all statements, each with the account it is for. Throws `FormatError` for malformed XML, for
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
+
* Parses all statements, each with the account it is for. Throws `FormatError` for malformed XML, for XML nested more
|
|
24
|
+
* than 100 levels deep or of more than 500,000 nodes besides text or one per 16 characters, whichever is more, for a
|
|
25
|
+
* document without any statement, for an entry without amount, currency, credit/debit indicator or date, for a date
|
|
26
|
+
* it cannot read, for remittance information of more than 65,536 characters, and for more than 200,000 statements and
|
|
27
|
+
* transactions.
|
|
23
28
|
*
|
|
24
|
-
* `status` overrides the booking status stated in the entries
|
|
29
|
+
* `status` overrides the booking status stated in the entries, unless it is `undefined` or `null`; throws `TypeError`
|
|
30
|
+
* for one other than `booked` and `pending`.
|
|
25
31
|
*/
|
|
26
32
|
parse(xml, status) {
|
|
27
|
-
return parseCamt(xml, status, new RecordBudget());
|
|
33
|
+
return parseCamt(xml, forcedStatus(status), new RecordBudget());
|
|
28
34
|
},
|
|
29
35
|
});
|
|
36
|
+
/** The `status` of `Camt.parse`; `undefined` for `null`, the status the entries state. */
|
|
37
|
+
function forcedStatus(status) {
|
|
38
|
+
return status === undefined || status === null ? undefined : requireStatus(status);
|
|
39
|
+
}
|
|
30
40
|
/** `Camt.parse`, which takes each statement and transaction from `budget`, before it builds it. */
|
|
31
41
|
export function parseCamt(xml, status, budget) {
|
|
32
|
-
const root = parseXml(xml
|
|
42
|
+
const root = parseXml(trimBlanks(xml));
|
|
33
43
|
const statements = root.childElements.flatMap((message) => message.childElements.filter((c) => statementNames.has(c.localName)));
|
|
34
44
|
if (statements.length === 0)
|
|
35
45
|
throw new FormatError('camt document without report, statement or notification');
|
|
@@ -37,22 +47,16 @@ export function parseCamt(xml, status, budget) {
|
|
|
37
47
|
budget.take();
|
|
38
48
|
const account = statement.child('Acct');
|
|
39
49
|
const entries = statement.childrenNamed('Ntry');
|
|
40
|
-
return
|
|
50
|
+
return frozenWithInspect({
|
|
41
51
|
reference: statement.textAt(['Id']),
|
|
42
52
|
accountId: account?.textAt(['Id', 'IBAN']) ?? account?.textAt(['Id', 'Othr', 'Id']),
|
|
43
53
|
currency: account?.textAt(['Ccy']),
|
|
44
54
|
transactions: Object.freeze(entries.flatMap((entry) => new CamtEntry(entry, status, budget).transactions())),
|
|
45
|
-
});
|
|
55
|
+
}, (s) => `CamtStatement(${maskedId(s.accountId ?? '')}, ${counted(s.transactions.length, 'transaction')})`);
|
|
46
56
|
});
|
|
47
57
|
}
|
|
48
58
|
/** Width of the purpose lines banks cut the remittance information into, as in MT940 and DTAUS. */
|
|
49
59
|
const cutLineLength = 35;
|
|
50
|
-
/**
|
|
51
|
-
* The SEPA keywords of `purposeCodes` that count only where the bank states them apart, as `endToEndId`, `mandateId`
|
|
52
|
-
* and `creditorId`: in the remittance text, which the payer or the payee writes, a creditor ID or mandate reference
|
|
53
|
-
* could be that of a creditor the app trusts.
|
|
54
|
-
*/
|
|
55
|
-
const keywordsStatedApart = new Set(['EREF', 'MREF', 'CRED']);
|
|
56
60
|
/**
|
|
57
61
|
* One booking (`Ntry`) of a report; a batch booking yields one transaction per transaction detail (`TxDtls`) when the
|
|
58
62
|
* details state their amounts and these add up to the booked amount.
|
|
@@ -107,7 +111,8 @@ class CamtEntry {
|
|
|
107
111
|
const split = details.map((detail, i) => this.transaction(detail, amountOf(amounts[i], this.currency),
|
|
108
112
|
// A detail may book in the other direction than the batch as a whole.
|
|
109
113
|
debitIndicator(detail.textAt(['CdtDbtInd'])) ?? this.debit));
|
|
110
|
-
|
|
114
|
+
const parts = split.map((t) => t.amount);
|
|
115
|
+
return addsUpTo(parts, booking.amount) ? split : [booking];
|
|
111
116
|
}
|
|
112
117
|
/** A transaction of `amount`, booked as a debit if `debit`, with what `details` tell about it. */
|
|
113
118
|
transaction(details, amount, debit) {
|
|
@@ -120,28 +125,25 @@ class CamtEntry {
|
|
|
120
125
|
const counterparty = originalDebit ? 'Cdtr' : 'Dbtr';
|
|
121
126
|
const lines = (details?.child('RmtInf')?.childrenNamed('Ustrd') ?? [])
|
|
122
127
|
.map((line) => line.innerText)
|
|
123
|
-
.filter((text) => text
|
|
128
|
+
.filter((text) => trimBlanks(text) !== '');
|
|
124
129
|
// A line of 35 characters goes on in the next one as it is, maybe in the middle of a word or before a blank; any
|
|
125
130
|
// other line ends a phrase, which the next one follows after a blank.
|
|
126
131
|
const cut = (i) => lines[i]?.length === cutLineLength;
|
|
127
132
|
const purposeParts = lines.map((line, i) => {
|
|
128
|
-
const part = cut(i) ? line : line
|
|
129
|
-
return i === 0 || cut(i - 1) ? part : ` ${part
|
|
133
|
+
const part = cut(i) ? line : trimBlanks(line, { start: false });
|
|
134
|
+
return i === 0 || cut(i - 1) ? part : ` ${trimBlanks(part, { end: false })}`;
|
|
130
135
|
});
|
|
131
|
-
const
|
|
136
|
+
const remittance = purposeParts.join('');
|
|
137
|
+
// As long as an MT940 field: the keywords of megabytes of text would take memory without limit.
|
|
138
|
+
if (remittance.length > maxFieldLength)
|
|
139
|
+
throw new FormatError('camt remittance information too long');
|
|
132
140
|
const keywords = SepaPurpose.parseParts(purposeParts);
|
|
133
141
|
const endToEndId = providedReference(details?.textAt(['Refs', 'EndToEndId']));
|
|
134
142
|
const mandateId = details?.textAt(['Refs', 'MndtId']);
|
|
135
143
|
const creditorId = creditorIdOf(parties?.child('Cdtr'));
|
|
136
144
|
const purposeCode = details?.textAt(['Purp', 'Cd']);
|
|
137
145
|
const typeId = this.proprietaryCode[0]?.length === 4 ? this.proprietaryCode[0] : undefined;
|
|
138
|
-
const purposeCodes =
|
|
139
|
-
if (endToEndId !== undefined)
|
|
140
|
-
purposeCodes.set('EREF', endToEndId);
|
|
141
|
-
if (mandateId !== undefined)
|
|
142
|
-
purposeCodes.set('MREF', mandateId);
|
|
143
|
-
if (creditorId !== undefined)
|
|
144
|
-
purposeCodes.set('CRED', creditorId);
|
|
146
|
+
const purposeCodes = withKeywordsStatedApart(keywords, { EREF: endToEndId, MREF: mandateId, CRED: creditorId });
|
|
145
147
|
if (purposeCode !== undefined)
|
|
146
148
|
purposeCodes.set('PURP', purposeCode);
|
|
147
149
|
return new Transaction({
|
|
@@ -151,7 +153,10 @@ class CamtEntry {
|
|
|
151
153
|
amount: debit ? amount.negate() : amount,
|
|
152
154
|
isReversal: this.reversal,
|
|
153
155
|
bookingText: this.bookingText ?? details?.textAt(['AddtlTxInf']),
|
|
154
|
-
purpose: keywords.get('SVWZ') ??
|
|
156
|
+
purpose: keywords.get('SVWZ') ??
|
|
157
|
+
nonBlank(remittance) ??
|
|
158
|
+
details?.textAt(['RmtInf', 'Strd', 'CdtrRefInf', 'Ref']) ??
|
|
159
|
+
details?.textAt(['AddtlTxInf']),
|
|
155
160
|
counterpartyName: partyName(parties?.child(counterparty)),
|
|
156
161
|
counterpartyIban: parties?.child(`${counterparty}Acct`)?.textAt(['Id', 'IBAN']),
|
|
157
162
|
counterpartyAccountNumber: parties?.child(`${counterparty}Acct`)?.textAt(['Id', 'Othr', 'Id']),
|
|
@@ -181,21 +186,19 @@ function amountOf(element, currency) {
|
|
|
181
186
|
return amount;
|
|
182
187
|
}
|
|
183
188
|
/**
|
|
184
|
-
*
|
|
185
|
-
*
|
|
189
|
+
* `keywords` with the values of EREF, MREF and CRED that the bank `stated` apart, as `endToEndId`, `mandateId` and
|
|
190
|
+
* `creditorId`, in the place the text gives them, and without those it does not state: in the remittance text, which
|
|
191
|
+
* the payer or the payee writes, a creditor ID or mandate reference could be that of a creditor the app trusts.
|
|
186
192
|
*/
|
|
187
|
-
function
|
|
188
|
-
const
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
catch (error) {
|
|
195
|
-
if (error instanceof RangeError)
|
|
196
|
-
return false;
|
|
197
|
-
throw error;
|
|
193
|
+
function withKeywordsStatedApart(keywords, stated) {
|
|
194
|
+
const codes = new Map(keywords);
|
|
195
|
+
for (const [keyword, value] of Object.entries(stated)) {
|
|
196
|
+
if (value === undefined)
|
|
197
|
+
codes.delete(keyword);
|
|
198
|
+
else
|
|
199
|
+
codes.set(keyword, value);
|
|
198
200
|
}
|
|
201
|
+
return codes;
|
|
199
202
|
}
|
|
200
203
|
/** `true` for `DBIT`, `false` for `CRDT`, `undefined` if `indicator` is missing; throws for any other value. */
|
|
201
204
|
function debitIndicator(indicator) {
|
|
@@ -211,18 +214,14 @@ function debitIndicator(indicator) {
|
|
|
211
214
|
}
|
|
212
215
|
}
|
|
213
216
|
/**
|
|
214
|
-
* The calendar date of `e`: its date (`Dt`), or
|
|
215
|
-
* UTC or another offset
|
|
216
|
-
* pass for a missing one otherwise, such as a value
|
|
217
|
+
* The calendar date of `e`: its date (`Dt`), or else its date and time (`DtTm`), both read by `parseIsoDate`, so that
|
|
218
|
+
* a date and time, which may be stated in UTC or another offset, counts on its German day; `undefined` if it states
|
|
219
|
+
* neither. Throws `FormatError` for one it cannot read, which would pass for a missing one otherwise, such as a value
|
|
220
|
+
* date the booking date stands in for.
|
|
217
221
|
*/
|
|
218
222
|
function dateOf(e) {
|
|
219
|
-
const date = e?.textAt(['Dt']);
|
|
220
|
-
|
|
221
|
-
return parseIsoDate(date) ?? fail('Unreadable camt date', date);
|
|
222
|
-
const dateTime = e?.textAt(['DtTm']);
|
|
223
|
-
if (dateTime === undefined)
|
|
224
|
-
return undefined;
|
|
225
|
-
return germanDay(parseIsoMoment(dateTime) ?? fail('Unreadable camt date', dateTime));
|
|
223
|
+
const date = e?.textAt(['Dt']) ?? e?.textAt(['DtTm']);
|
|
224
|
+
return date === undefined ? undefined : (parseIsoDate(date) ?? fail('Unreadable camt date', date));
|
|
226
225
|
}
|
|
227
226
|
function partyName(party) {
|
|
228
227
|
return party?.textAt(['Nm']) ?? party?.textAt(['Pty', 'Nm']);
|
package/dist/formats/camt.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"camt.js","sourceRoot":"","sources":["../../src/formats/camt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAA0B,MAAM,wBAAwB,CAAC;AAC7E,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC3E,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAmB,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAcnE,sFAAsF;AACtF,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;AAE1D,0GAA0G;AAC1G,MAAM,CAAC,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC;IAChC;;;OAGG;IACH,iBAAiB,CAAC,GAAW,EAAE,MAA0B;QACvD,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC;IACrE,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,GAAW,EAAE,MAA0B;QAC3C,OAAO,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,YAAY,EAAE,CAAC,CAAC;IACpD,CAAC;CACF,CAAC,CAAC;AAEH,mG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AE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,KAAK,MAAM,CAAC,CAAC;IACnH,OAAO,IAAI,EAAE,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AAC9B,CAAC"}
|
package/dist/formats/mt940.d.ts
CHANGED
|
@@ -13,11 +13,17 @@ export interface Mt940Statement {
|
|
|
13
13
|
readonly currency: string | undefined;
|
|
14
14
|
/** The balance at the start of the statement (field 60), negative for a debit. */
|
|
15
15
|
readonly openingBalance: Amount | undefined;
|
|
16
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* The date of `openingBalance`; `undefined` where the bank states none, as `0` or `000000` for the first statement of
|
|
18
|
+
* an account.
|
|
19
|
+
*/
|
|
17
20
|
readonly openingDate: Date | undefined;
|
|
18
21
|
/** The balance at the end of the statement (field 62), negative for a debit. */
|
|
19
22
|
readonly closingBalance: Amount | undefined;
|
|
20
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* The date of `closingBalance`; `undefined` where the bank states none, as `0` or `000000` for the first statement of
|
|
25
|
+
* an account.
|
|
26
|
+
*/
|
|
21
27
|
readonly closingDate: Date | undefined;
|
|
22
28
|
/**
|
|
23
29
|
* The transactions of the statement, in the order the bank lists them; they lead from `openingBalance` to
|
|
@@ -32,6 +38,8 @@ export interface Mt940Options {
|
|
|
32
38
|
/** The currency of statements that state none in their balances. */
|
|
33
39
|
currency?: string | undefined;
|
|
34
40
|
}
|
|
41
|
+
/** Longest field the parser reads, from its tag to the next one: SWIFT fields have a few hundred characters. */
|
|
42
|
+
export declare const maxFieldLength = 65536;
|
|
35
43
|
/** Parser for SWIFT MT940/MT942 statements, including German structured `:86:` fields. */
|
|
36
44
|
export declare const Mt940: Readonly<{
|
|
37
45
|
/** Parses all transactions; see `parse`. */
|
|
@@ -40,12 +48,16 @@ export declare const Mt940: Readonly<{
|
|
|
40
48
|
* Parses all statements. Their lines are separated by line breaks, and by `@@` as well where the first line holds it,
|
|
41
49
|
* as some banks separate them.
|
|
42
50
|
*
|
|
43
|
-
* Throws `FormatError` for text without any field,
|
|
44
|
-
* the currency of a transaction is unknown
|
|
45
|
-
*
|
|
51
|
+
* Throws `FormatError` for text without any field, if a transaction line (`:61:`), a balance or the creation date of
|
|
52
|
+
* an MT942 (`:13D:`) cannot be read or the currency of a transaction is unknown, and for a closing balance dated
|
|
53
|
+
* before the opening one. It does as well for a statement that states only one of its opening and closing balances,
|
|
54
|
+
* one of them, its account, its number or its creation date twice, or transactions that do not lead from the one
|
|
46
55
|
* balance to the other: a line of a purpose that starts like a field, such as `:61:` or `:25:`, would pass for a
|
|
47
56
|
* transaction, the account or a statement of its own otherwise. Text of more than 200,000 statements and
|
|
48
|
-
* transactions is a `FormatError` as well.
|
|
57
|
+
* transactions, or with a field of more than 65,536 characters, is a `FormatError` as well.
|
|
58
|
+
*
|
|
59
|
+
* Throws `TypeError` for a `status` other than `booked` and `pending`, `null` included, and for a `currency` that is
|
|
60
|
+
* no string; `null` counts as no currency.
|
|
49
61
|
*/
|
|
50
62
|
parse(text: string, options?: Mt940Options): Mt940Statement[];
|
|
51
63
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mt940.d.ts","sourceRoot":"","sources":["../../src/formats/mt940.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"mt940.d.ts","sourceRoot":"","sources":["../../src/formats/mt940.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,MAAM,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAiB,WAAW,EAAE,KAAK,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAM5F,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGlD,qFAAqF;AACrF,MAAM,WAAW,cAAc;IAC7B,0DAA0D;IAC1D,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,mDAAmD;IACnD,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,iDAAiD;IACjD,QAAQ,CAAC,eAAe,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7C,gGAAgG;IAChG,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IACtC,kFAAkF;IAClF,QAAQ,CAAC,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5C;;;OAGG;IACH,QAAQ,CAAC,WAAW,EAAE,IAAI,GAAG,SAAS,CAAC;IACvC,gFAAgF;IAChF,QAAQ,CAAC,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5C;;;OAGG;IACH,QAAQ,CAAC,WAAW,EAAE,IAAI,GAAG,SAAS,CAAC;IACvC;;;OAGG;IACH,QAAQ,CAAC,YAAY,EAAE,SAAS,WAAW,EAAE,CAAC;CAC/C;AAED,oDAAoD;AACpD,MAAM,WAAW,YAAY;IAC3B,0FAA0F;IAC1F,MAAM,CAAC,EAAE,iBAAiB,CAAC;IAC3B,oEAAoE;IACpE,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC/B;AAID,gHAAgH;AAChH,eAAO,MAAM,cAAc,QAAS,CAAC;AAErC,0FAA0F;AAC1F,eAAO,MAAM,KAAK;IAChB,4CAA4C;4BACpB,MAAM,YAAW,YAAY,GAAQ,WAAW,EAAE;IAI1E;;;;;;;;;;;;;;OAcG;gBACS,MAAM,YAAW,YAAY,GAAQ,cAAc,EAAE;EAKjE,CAAC;AAEH,oGAAoG;AACpG,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,GAAG,cAAc,EAAE,CAkBtG"}
|
package/dist/formats/mt940.js
CHANGED
|
@@ -1,30 +1,40 @@
|
|
|
1
|
-
import { Amount } from '../core/amount.js';
|
|
2
|
-
import { Transaction } from '../core/transaction.js';
|
|
1
|
+
import { addsUpTo, Amount } from '../core/amount.js';
|
|
2
|
+
import { requireStatus, Transaction } from '../core/transaction.js';
|
|
3
|
+
import { optionalString } from '../util/arguments.js';
|
|
3
4
|
import { clampedDate, parseSwiftDate } from '../util/dates.js';
|
|
4
|
-
import { FormatError } from '../util/errors.js';
|
|
5
|
-
import {
|
|
5
|
+
import { fail, FormatError } from '../util/errors.js';
|
|
6
|
+
import { frozenWithInspect } from '../util/inspect.js';
|
|
7
|
+
import { counted, maskedId, nonBlank, trimBlanks } from '../util/text.js';
|
|
6
8
|
import { RecordBudget } from './record-budget.js';
|
|
7
9
|
import { providedReference, SepaPurpose } from './sepa-purpose.js';
|
|
8
10
|
const tagPattern = /^:(\d{2}[A-Z]?):/gm;
|
|
11
|
+
/** Longest field the parser reads, from its tag to the next one: SWIFT fields have a few hundred characters. */
|
|
12
|
+
export const maxFieldLength = 65_536;
|
|
9
13
|
/** Parser for SWIFT MT940/MT942 statements, including German structured `:86:` fields. */
|
|
10
14
|
export const Mt940 = Object.freeze({
|
|
11
15
|
/** Parses all transactions; see `parse`. */
|
|
12
16
|
parseTransactions(text, options = {}) {
|
|
13
|
-
return Mt940.parse(text, options).flatMap((s) =>
|
|
17
|
+
return Mt940.parse(text, options).flatMap((s) => s.transactions);
|
|
14
18
|
},
|
|
15
19
|
/**
|
|
16
20
|
* Parses all statements. Their lines are separated by line breaks, and by `@@` as well where the first line holds it,
|
|
17
21
|
* as some banks separate them.
|
|
18
22
|
*
|
|
19
|
-
* Throws `FormatError` for text without any field,
|
|
20
|
-
* the currency of a transaction is unknown
|
|
21
|
-
*
|
|
23
|
+
* Throws `FormatError` for text without any field, if a transaction line (`:61:`), a balance or the creation date of
|
|
24
|
+
* an MT942 (`:13D:`) cannot be read or the currency of a transaction is unknown, and for a closing balance dated
|
|
25
|
+
* before the opening one. It does as well for a statement that states only one of its opening and closing balances,
|
|
26
|
+
* one of them, its account, its number or its creation date twice, or transactions that do not lead from the one
|
|
22
27
|
* balance to the other: a line of a purpose that starts like a field, such as `:61:` or `:25:`, would pass for a
|
|
23
28
|
* transaction, the account or a statement of its own otherwise. Text of more than 200,000 statements and
|
|
24
|
-
* transactions is a `FormatError` as well.
|
|
29
|
+
* transactions, or with a field of more than 65,536 characters, is a `FormatError` as well.
|
|
30
|
+
*
|
|
31
|
+
* Throws `TypeError` for a `status` other than `booked` and `pending`, `null` included, and for a `currency` that is
|
|
32
|
+
* no string; `null` counts as no currency.
|
|
25
33
|
*/
|
|
26
34
|
parse(text, options = {}) {
|
|
27
|
-
|
|
35
|
+
const status = options.status === undefined ? undefined : requireStatus(options.status);
|
|
36
|
+
const currency = optionalString(options.currency, 'currency');
|
|
37
|
+
return parseMt940(text, { status, currency }, new RecordBudget());
|
|
28
38
|
},
|
|
29
39
|
});
|
|
30
40
|
/** `Mt940.parse`, which takes each statement and transaction from `budget`, before it builds it. */
|
|
@@ -34,6 +44,8 @@ export function parseMt940(text, options, budget) {
|
|
|
34
44
|
const statements = [];
|
|
35
45
|
let current;
|
|
36
46
|
for (const [tag, value] of taggedParts(normalized, tagPattern)) {
|
|
47
|
+
if (value.length > maxFieldLength)
|
|
48
|
+
throw new FormatError(`MT940 field :${tag}: too long`);
|
|
37
49
|
if (tag === '20' || current === undefined) {
|
|
38
50
|
if (current !== undefined)
|
|
39
51
|
statements.push(current.build());
|
|
@@ -69,25 +81,31 @@ function* taggedParts(text, tag) {
|
|
|
69
81
|
yield [current, text.substring(start)];
|
|
70
82
|
}
|
|
71
83
|
/**
|
|
72
|
-
* `text` with line feeds between its lines
|
|
73
|
-
*
|
|
74
|
-
*
|
|
84
|
+
* `text` with line feeds between its lines, without the blanks and the byte order mark it may start with, which would
|
|
85
|
+
* hide its first tag. Some banks separate the lines with `@@`, and may still break the line between statements or at
|
|
86
|
+
* the ends. So `@@` separates lines where the first line holds it, which the bank writes; in other text, `@@` may be
|
|
87
|
+
* part of a purpose, which the payer writes.
|
|
75
88
|
*/
|
|
76
89
|
function withLineFeeds(text) {
|
|
77
|
-
const lines = text.replace(/\r\n?/g, '\n');
|
|
78
|
-
return lines.
|
|
90
|
+
const lines = trimBlanks(text.replace(/\r\n?/g, '\n'), { end: false });
|
|
91
|
+
return lines.split('\n', 1)[0].includes('@@') ? lines.replace(/@@/g, '\n') : lines;
|
|
79
92
|
}
|
|
80
93
|
/**
|
|
81
|
-
* The value of a field in `text`, which runs from its tag to the next one: without the
|
|
82
|
-
*
|
|
94
|
+
* The value of a field in `text`, which runs from its tag to the next one: without the statement end (`-`) and the line
|
|
95
|
+
* feeds at its end. Other blanks there stay: the subfield of a `:86:` that ends it may precede others in the purpose.
|
|
83
96
|
*
|
|
84
97
|
* Trimmed without a pattern such as `/\n+$/`, which takes quadratic time on a long run of line breaks.
|
|
85
98
|
*/
|
|
86
99
|
function fieldValue(text) {
|
|
87
|
-
const
|
|
88
|
-
|
|
100
|
+
const trimmed = text.trimEnd();
|
|
101
|
+
let end = trimmed.endsWith('\n-') ? trimmed.length - 2 : text.length;
|
|
102
|
+
while (end > 0 && text.charCodeAt(end - 1) === 0x0a)
|
|
103
|
+
end--;
|
|
104
|
+
return text.substring(0, end);
|
|
89
105
|
}
|
|
90
|
-
|
|
106
|
+
/** The date is `0` or `000000` for the first statement of an account. */
|
|
107
|
+
const balancePattern = /^([CD])(\d{6}|0)([A-Z]{3})(\d+,\d*)/;
|
|
108
|
+
const dateTimePattern = /^(\d{6})\d{4}/;
|
|
91
109
|
const currencyPrefix = /^([A-Z]{3})/;
|
|
92
110
|
class StatementBuilder {
|
|
93
111
|
status;
|
|
@@ -100,6 +118,8 @@ class StatementBuilder {
|
|
|
100
118
|
openingDate;
|
|
101
119
|
closing;
|
|
102
120
|
closingDate;
|
|
121
|
+
/** The day an MT942 was created (field 13D). */
|
|
122
|
+
creationDate;
|
|
103
123
|
transactions = [];
|
|
104
124
|
/**
|
|
105
125
|
* The tag added last: a `:86:` right after a `:61:` details the transaction, anywhere else it informs the account
|
|
@@ -115,20 +135,29 @@ class StatementBuilder {
|
|
|
115
135
|
add(tag, value) {
|
|
116
136
|
switch (tag) {
|
|
117
137
|
case '20':
|
|
118
|
-
this.reference = value
|
|
138
|
+
this.reference = trimBlanks(value);
|
|
119
139
|
break;
|
|
120
140
|
case '25':
|
|
121
141
|
if (this.accountId !== undefined)
|
|
122
142
|
throw new FormatError('MT940 statement with two accounts', this.reference);
|
|
123
|
-
this.accountId = value
|
|
143
|
+
this.accountId = trimBlanks(value);
|
|
124
144
|
break;
|
|
125
145
|
case '28C':
|
|
126
146
|
case '28':
|
|
127
147
|
if (this.statementNumber !== undefined) {
|
|
128
148
|
throw new FormatError('MT940 statement with two statement numbers', this.reference);
|
|
129
149
|
}
|
|
130
|
-
this.statementNumber = value
|
|
150
|
+
this.statementNumber = trimBlanks(value);
|
|
151
|
+
break;
|
|
152
|
+
case '13D':
|
|
153
|
+
case '13': {
|
|
154
|
+
if (this.creationDate !== undefined) {
|
|
155
|
+
throw new FormatError('MT940 statement with two creation dates', this.reference);
|
|
156
|
+
}
|
|
157
|
+
const m = dateTimePattern.exec(trimBlanks(value));
|
|
158
|
+
this.creationDate = (m && parseSwiftDate(m[1])) ?? fail('Invalid MT940 creation date', value);
|
|
131
159
|
break;
|
|
160
|
+
}
|
|
132
161
|
case '60F':
|
|
133
162
|
case '60M': {
|
|
134
163
|
if (this.opening !== undefined) {
|
|
@@ -152,7 +181,7 @@ class StatementBuilder {
|
|
|
152
181
|
break;
|
|
153
182
|
}
|
|
154
183
|
case '34F':
|
|
155
|
-
this.currency ??= currencyPrefix.exec(value
|
|
184
|
+
this.currency ??= currencyPrefix.exec(trimBlanks(value))?.[1];
|
|
156
185
|
break;
|
|
157
186
|
case '61':
|
|
158
187
|
this.transactions.push(new TransactionLines(value));
|
|
@@ -170,10 +199,13 @@ class StatementBuilder {
|
|
|
170
199
|
throw new FormatError('MT940 statement without currency', this.reference);
|
|
171
200
|
}
|
|
172
201
|
const { openingDate, closingDate } = this;
|
|
202
|
+
if (openingDate && closingDate && closingDate.getTime() < openingDate.getTime()) {
|
|
203
|
+
throw new FormatError('MT940 closing balance dated before the opening balance', this.reference);
|
|
204
|
+
}
|
|
173
205
|
const period = openingDate && closingDate ? [openingDate, closingDate] : undefined;
|
|
174
|
-
const transactions = this.transactions.map((t) => t.toTransaction(statementCurrency, this.status, period));
|
|
206
|
+
const transactions = this.transactions.map((t) => t.toTransaction(statementCurrency, this.status, period, this.creationDate));
|
|
175
207
|
this.checkBalances(transactions);
|
|
176
|
-
return
|
|
208
|
+
return frozenWithInspect({
|
|
177
209
|
reference: this.reference,
|
|
178
210
|
accountId: this.accountId,
|
|
179
211
|
statementNumber: this.statementNumber,
|
|
@@ -183,7 +215,7 @@ class StatementBuilder {
|
|
|
183
215
|
closingBalance: this.closing,
|
|
184
216
|
closingDate: this.closingDate,
|
|
185
217
|
transactions: Object.freeze(transactions),
|
|
186
|
-
});
|
|
218
|
+
}, (s) => `Mt940Statement(${maskedId(s.accountId ?? '')}, ${counted(s.transactions.length, 'transaction')})`);
|
|
187
219
|
}
|
|
188
220
|
/** Checks that the statement states both balances or neither, and that its `transactions` lead from one to the other. */
|
|
189
221
|
checkBalances(transactions) {
|
|
@@ -196,30 +228,17 @@ class StatementBuilder {
|
|
|
196
228
|
if (opening.currency !== this.currency || closing.currency !== this.currency) {
|
|
197
229
|
throw new FormatError('MT940 balances in another currency than the statement', this.reference);
|
|
198
230
|
}
|
|
199
|
-
if (!
|
|
231
|
+
if (!addsUpTo([opening, ...transactions.map((t) => t.amount)], closing)) {
|
|
200
232
|
throw new FormatError('MT940 transactions do not add up to the closing balance', this.reference);
|
|
201
233
|
}
|
|
202
234
|
}
|
|
203
235
|
}
|
|
204
|
-
/** `opening` plus the amounts of `transactions`; throws `FormatError` for a sum beyond what an `Amount` holds. */
|
|
205
|
-
function balanceAfter(opening, transactions) {
|
|
206
|
-
try {
|
|
207
|
-
return transactions.reduce((balance, t) => balance.add(t.amount), opening);
|
|
208
|
-
}
|
|
209
|
-
catch (error) {
|
|
210
|
-
if (error instanceof RangeError)
|
|
211
|
-
throw new FormatError('MT940 amounts too large to add up');
|
|
212
|
-
throw error;
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
236
|
function parseBalance(value) {
|
|
216
|
-
const m = balancePattern.exec(value
|
|
237
|
+
const m = balancePattern.exec(trimBlanks(value));
|
|
217
238
|
if (!m)
|
|
218
239
|
throw new FormatError('Unreadable MT940 balance', value);
|
|
219
240
|
const amount = Amount.parseDecimal(m[4], m[3]);
|
|
220
|
-
const date = parseSwiftDate(m[2]);
|
|
221
|
-
if (date === undefined)
|
|
222
|
-
throw new FormatError('Invalid balance date', value);
|
|
241
|
+
const date = Number(m[2]) === 0 ? undefined : (parseSwiftDate(m[2]) ?? fail('Invalid balance date', value));
|
|
223
242
|
return [m[1] === 'D' ? amount.negate() : amount, date];
|
|
224
243
|
}
|
|
225
244
|
/**
|
|
@@ -227,6 +246,9 @@ function parseBalance(value) {
|
|
|
227
246
|
* reference, optional bank reference and supplementary details.
|
|
228
247
|
*/
|
|
229
248
|
const line61 = /^(\d{6})(\d{4})?(RC|RD|C|D)([A-Z])?(\d+,\d*)([NFS][A-Z0-9]{3})([^\n]*?)(?:\/\/([^\n]*))?(?:\n([\s\S]*))?$/;
|
|
249
|
+
function spanning(a, b) {
|
|
250
|
+
return a.getTime() <= b.getTime() ? [a, b] : [b, a];
|
|
251
|
+
}
|
|
230
252
|
/** The `:61:` line of a transaction and its `:86:` details. */
|
|
231
253
|
class TransactionLines {
|
|
232
254
|
line;
|
|
@@ -234,19 +256,21 @@ class TransactionLines {
|
|
|
234
256
|
constructor(line) {
|
|
235
257
|
this.line = line;
|
|
236
258
|
}
|
|
237
|
-
toTransaction(currency, status, period) {
|
|
238
|
-
const m = line61.exec(this.line
|
|
259
|
+
toTransaction(currency, status, period, created) {
|
|
260
|
+
const m = line61.exec(trimBlanks(this.line));
|
|
239
261
|
const valueDate = m ? parseSwiftDate(m[1]) : undefined;
|
|
240
262
|
if (!m || valueDate === undefined)
|
|
241
263
|
throw new FormatError('Unreadable MT940 transaction line (:61:)', this.line);
|
|
242
264
|
const mark = m[3];
|
|
243
265
|
const amount = Amount.parseDecimal(m[5], currency);
|
|
244
266
|
const debit = mark === 'D' || mark === 'RC';
|
|
245
|
-
const customerReference = nonBlank(m[7]);
|
|
246
267
|
const d = Details.parse(this.details);
|
|
268
|
+
const reference = nonBlank(m[7]);
|
|
269
|
+
// `KREF+` stands for the customer reference that :86: states.
|
|
270
|
+
const customerReference = reference === 'KREF+' ? d.sepa.get('KREF') : reference;
|
|
247
271
|
return new Transaction({
|
|
248
272
|
status,
|
|
249
|
-
bookingDate: this.bookingDate(m[2], valueDate, period),
|
|
273
|
+
bookingDate: this.bookingDate(m[2], valueDate, period ?? spanning(valueDate, created ?? valueDate)),
|
|
250
274
|
valueDate,
|
|
251
275
|
amount: debit ? amount.negate() : amount,
|
|
252
276
|
isReversal: mark.startsWith('R'),
|
|
@@ -272,15 +296,14 @@ class TransactionLines {
|
|
|
272
296
|
}
|
|
273
297
|
/**
|
|
274
298
|
* The booking date `MMDD`, in the year that places it within `period`, or else closest to it; of several such years,
|
|
275
|
-
* the one closest to `valueDate
|
|
276
|
-
*
|
|
299
|
+
* the one closest to `valueDate`. The value date alone misleads: banks book refunds and corrections with the value
|
|
300
|
+
* date of the original booking, up to 13 months before.
|
|
277
301
|
*/
|
|
278
|
-
bookingDate(mmdd, valueDate,
|
|
302
|
+
bookingDate(mmdd, valueDate, [first, last]) {
|
|
279
303
|
if (mmdd === undefined)
|
|
280
304
|
return undefined;
|
|
281
305
|
const month = Number(mmdd.substring(0, 2));
|
|
282
306
|
const day = Number(mmdd.substring(2, 4));
|
|
283
|
-
const [first, last] = period ?? [valueDate, valueDate];
|
|
284
307
|
const outside = (date) => Math.max(first.getTime() - date.getTime(), date.getTime() - last.getTime(), 0);
|
|
285
308
|
const fromValueDate = (date) => Math.abs(date.getTime() - valueDate.getTime());
|
|
286
309
|
// The best year lies next to one of these, however long the period.
|
|
@@ -324,7 +347,7 @@ class Details {
|
|
|
324
347
|
const text = raw.replace(/\n/g, '');
|
|
325
348
|
if (!structuredPattern.test(text)) {
|
|
326
349
|
// Free text, whose lines are separate phrases; the purpose and its keywords are read from the same text.
|
|
327
|
-
const free = raw.replace(/\n/g, ' ')
|
|
350
|
+
const free = trimBlanks(raw.replace(/\n/g, ' '));
|
|
328
351
|
d.sepa = SepaPurpose.parse(free);
|
|
329
352
|
d.purpose = d.sepa.get('SVWZ') ?? nonBlank(free);
|
|
330
353
|
return d;
|
|
@@ -341,8 +364,6 @@ class Details {
|
|
|
341
364
|
d.purpose = d.sepa.get('SVWZ') ?? nonBlank(purposeParts.join(''));
|
|
342
365
|
d.name = nonBlank(parts([32, 33]).join(''));
|
|
343
366
|
d.readCounterpartyAccount(subfield(30), subfield(31));
|
|
344
|
-
d.iban ??= d.sepa.get('IBAN');
|
|
345
|
-
d.bic ??= d.sepa.get('BIC');
|
|
346
367
|
return d;
|
|
347
368
|
}
|
|
348
369
|
/** The text of each subfield (`?nn` and what follows), by its number; a subfield that appears twice is joined. */
|
|
@@ -355,22 +376,18 @@ class Details {
|
|
|
355
376
|
return subfields;
|
|
356
377
|
}
|
|
357
378
|
/**
|
|
358
|
-
* Takes the counterparty's account from subfields 30 (bank) and 31 (account):
|
|
359
|
-
*
|
|
379
|
+
* Takes the counterparty's account from subfields 30 (bank) and 31 (account): a BIC, or else a bank code, and an IBAN,
|
|
380
|
+
* or else an account number.
|
|
360
381
|
*/
|
|
361
382
|
readCounterpartyAccount(bank, account) {
|
|
362
|
-
if (
|
|
363
|
-
this.iban = account;
|
|
364
|
-
this.bic = bank;
|
|
365
|
-
return;
|
|
366
|
-
}
|
|
367
|
-
this.accountNumber = account;
|
|
368
|
-
if (bank !== undefined && bicPattern.test(bank)) {
|
|
383
|
+
if (bank !== undefined && bicPattern.test(bank))
|
|
369
384
|
this.bic = bank;
|
|
370
|
-
|
|
371
|
-
else {
|
|
385
|
+
else
|
|
372
386
|
this.bankCode = bank;
|
|
373
|
-
|
|
387
|
+
if (account !== undefined && ibanPattern.test(account))
|
|
388
|
+
this.iban = account;
|
|
389
|
+
else
|
|
390
|
+
this.accountNumber = account;
|
|
374
391
|
}
|
|
375
392
|
}
|
|
376
393
|
//# sourceMappingURL=mt940.js.map
|