@coderoftime/fints 0.1.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 +519 -1
- package/README.md +138 -40
- package/dist/client.d.ts +49 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +242 -0
- package/dist/client.js.map +1 -0
- package/dist/core/account.d.ts +46 -7
- package/dist/core/account.d.ts.map +1 -1
- package/dist/core/account.js +143 -24
- package/dist/core/account.js.map +1 -1
- package/dist/core/amount.d.ts +15 -4
- package/dist/core/amount.d.ts.map +1 -1
- package/dist/core/amount.js +46 -9
- package/dist/core/amount.js.map +1 -1
- package/dist/core/balance.d.ts +4 -0
- package/dist/core/balance.d.ts.map +1 -1
- package/dist/core/balance.js +11 -5
- package/dist/core/balance.js.map +1 -1
- package/dist/core/bank-info.d.ts +21 -4
- package/dist/core/bank-info.d.ts.map +1 -1
- package/dist/core/bank-info.js +26 -5
- package/dist/core/bank-info.js.map +1 -1
- package/dist/core/client.d.ts +81 -19
- package/dist/core/client.d.ts.map +1 -1
- package/dist/core/config.d.ts +40 -20
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/config.js +85 -30
- package/dist/core/config.js.map +1 -1
- package/dist/core/errors.d.ts +100 -26
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/core/errors.js +136 -53
- package/dist/core/errors.js.map +1 -1
- package/dist/core/feedback.d.ts +11 -1
- package/dist/core/feedback.d.ts.map +1 -1
- package/dist/core/feedback.js +14 -2
- package/dist/core/feedback.js.map +1 -1
- package/dist/core/transaction.d.ts +11 -1
- package/dist/core/transaction.d.ts.map +1 -1
- package/dist/core/transaction.js +21 -4
- package/dist/core/transaction.js.map +1 -1
- package/dist/core/transport.d.ts +48 -6
- package/dist/core/transport.d.ts.map +1 -1
- package/dist/core/transport.js +126 -29
- package/dist/core/transport.js.map +1 -1
- package/dist/formats/camt.d.ts +28 -5
- package/dist/formats/camt.d.ts.map +1 -1
- package/dist/formats/camt.js +132 -50
- package/dist/formats/camt.js.map +1 -1
- package/dist/formats/mt940.d.ts +29 -5
- package/dist/formats/mt940.d.ts.map +1 -1
- package/dist/formats/mt940.js +209 -113
- package/dist/formats/mt940.js.map +1 -1
- package/dist/formats/readers.d.ts +6 -2
- package/dist/formats/readers.d.ts.map +1 -1
- package/dist/formats/readers.js +28 -29
- package/dist/formats/readers.js.map +1 -1
- package/dist/formats/record-budget.d.ts +7 -0
- package/dist/formats/record-budget.d.ts.map +1 -0
- package/dist/formats/record-budget.js +17 -0
- package/dist/formats/record-budget.js.map +1 -0
- package/dist/formats/sepa-purpose.d.ts +9 -0
- package/dist/formats/sepa-purpose.d.ts.map +1 -1
- package/dist/formats/sepa-purpose.js +32 -2
- package/dist/formats/sepa-purpose.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/session/app-approval.d.ts +11 -5
- package/dist/session/app-approval.d.ts.map +1 -1
- package/dist/session/app-approval.js +23 -12
- package/dist/session/app-approval.js.map +1 -1
- package/dist/session/dialog-runner.d.ts +11 -11
- package/dist/session/dialog-runner.d.ts.map +1 -1
- package/dist/session/dialog-runner.js +34 -19
- package/dist/session/dialog-runner.js.map +1 -1
- package/dist/session/login-guard.d.ts +54 -49
- package/dist/session/login-guard.d.ts.map +1 -1
- package/dist/session/login-guard.js +170 -83
- package/dist/session/login-guard.js.map +1 -1
- package/dist/session/sepa-accounts.d.ts +20 -14
- package/dist/session/sepa-accounts.d.ts.map +1 -1
- package/dist/session/sepa-accounts.js +62 -46
- package/dist/session/sepa-accounts.js.map +1 -1
- package/dist/session/session-setup.d.ts +41 -24
- package/dist/session/session-setup.d.ts.map +1 -1
- package/dist/session/session-setup.js +106 -63
- package/dist/session/session-setup.js.map +1 -1
- package/dist/session/session-state.d.ts +10 -6
- package/dist/session/session-state.d.ts.map +1 -1
- package/dist/session/session-state.js +72 -18
- package/dist/session/session-state.js.map +1 -1
- package/dist/session/signed-dialog.d.ts +83 -0
- package/dist/session/signed-dialog.d.ts.map +1 -0
- package/dist/session/signed-dialog.js +185 -0
- package/dist/session/signed-dialog.js.map +1 -0
- package/dist/session/tan-selection.d.ts +26 -18
- package/dist/session/tan-selection.d.ts.map +1 -1
- package/dist/session/tan-selection.js +44 -33
- package/dist/session/tan-selection.js.map +1 -1
- package/dist/session/user-prompts.d.ts +14 -5
- package/dist/session/user-prompts.d.ts.map +1 -1
- package/dist/session/user-prompts.js +53 -18
- package/dist/session/user-prompts.js.map +1 -1
- package/dist/tan/challenge.d.ts +47 -24
- package/dist/tan/challenge.d.ts.map +1 -1
- package/dist/tan/challenge.js +56 -51
- package/dist/tan/challenge.js.map +1 -1
- package/dist/tan/flicker.d.ts +11 -1
- package/dist/tan/flicker.d.ts.map +1 -1
- package/dist/tan/flicker.js +70 -24
- package/dist/tan/flicker.js.map +1 -1
- package/dist/tan/tan-image.d.ts +6 -2
- package/dist/tan/tan-image.d.ts.map +1 -1
- package/dist/tan/tan-image.js +14 -6
- package/dist/tan/tan-image.js.map +1 -1
- package/dist/tan/tan-models.d.ts +14 -2
- package/dist/tan/tan-models.d.ts.map +1 -1
- package/dist/tan/tan-models.js +24 -7
- 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 -3
- package/dist/util/async.d.ts.map +1 -1
- package/dist/util/async.js +6 -7
- package/dist/util/async.js.map +1 -1
- package/dist/util/bytes.d.ts +3 -4
- package/dist/util/bytes.d.ts.map +1 -1
- package/dist/util/bytes.js +13 -21
- package/dist/util/bytes.js.map +1 -1
- package/dist/util/call-context.d.ts.map +1 -1
- package/dist/util/call-context.js +3 -2
- package/dist/util/call-context.js.map +1 -1
- package/dist/util/dates.d.ts +6 -20
- package/dist/util/dates.d.ts.map +1 -1
- package/dist/util/dates.js +58 -28
- package/dist/util/dates.js.map +1 -1
- package/dist/util/errors.d.ts +13 -3
- package/dist/util/errors.d.ts.map +1 -1
- package/dist/util/errors.js +19 -6
- 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/json.d.ts +4 -0
- package/dist/util/json.d.ts.map +1 -1
- package/dist/util/json.js +18 -0
- package/dist/util/json.js.map +1 -1
- package/dist/util/text.d.ts +38 -5
- package/dist/util/text.d.ts.map +1 -1
- package/dist/util/text.js +90 -16
- package/dist/util/text.js.map +1 -1
- package/dist/util/xml.d.ts +9 -6
- package/dist/util/xml.d.ts.map +1 -1
- package/dist/util/xml.js +129 -56
- package/dist/util/xml.js.map +1 -1
- package/dist/v3/account-extension.d.ts.map +1 -1
- package/dist/v3/account-extension.js +7 -10
- package/dist/v3/account-extension.js.map +1 -1
- package/dist/v3/bank-connection.d.ts +54 -0
- package/dist/v3/bank-connection.d.ts.map +1 -0
- package/dist/v3/bank-connection.js +118 -0
- package/dist/v3/bank-connection.js.map +1 -0
- package/dist/v3/dialog.d.ts +84 -46
- package/dist/v3/dialog.d.ts.map +1 -1
- package/dist/v3/dialog.js +174 -60
- package/dist/v3/dialog.js.map +1 -1
- package/dist/v3/message.d.ts +32 -11
- package/dist/v3/message.d.ts.map +1 -1
- package/dist/v3/message.js +144 -83
- package/dist/v3/message.js.map +1 -1
- package/dist/v3/parameter-store.d.ts +111 -0
- package/dist/v3/parameter-store.d.ts.map +1 -0
- package/dist/v3/parameter-store.js +197 -0
- package/dist/v3/parameter-store.js.map +1 -0
- package/dist/v3/parameters.d.ts +44 -17
- package/dist/v3/parameters.d.ts.map +1 -1
- package/dist/v3/parameters.js +136 -60
- package/dist/v3/parameters.js.map +1 -1
- package/dist/v3/protocol.d.ts +50 -50
- package/dist/v3/protocol.d.ts.map +1 -1
- package/dist/v3/protocol.js +91 -210
- package/dist/v3/protocol.js.map +1 -1
- package/dist/v3/queries.d.ts +51 -0
- package/dist/v3/queries.d.ts.map +1 -0
- package/dist/v3/queries.js +128 -0
- package/dist/v3/queries.js.map +1 -0
- package/dist/v3/segments.d.ts +43 -19
- package/dist/v3/segments.d.ts.map +1 -1
- package/dist/v3/segments.js +84 -33
- package/dist/v3/segments.js.map +1 -1
- package/dist/v3/syntax.d.ts +68 -13
- package/dist/v3/syntax.d.ts.map +1 -1
- package/dist/v3/syntax.js +183 -102
- package/dist/v3/syntax.js.map +1 -1
- package/package.json +10 -6
- package/src/client.ts +293 -0
- package/src/core/account.ts +153 -24
- package/src/core/amount.ts +45 -10
- package/src/core/balance.ts +12 -5
- package/src/core/bank-info.ts +29 -5
- package/src/core/client.ts +83 -19
- package/src/core/config.ts +95 -35
- package/src/core/errors.ts +148 -54
- package/src/core/feedback.ts +16 -2
- package/src/core/transaction.ts +22 -4
- package/src/core/transport.ts +153 -32
- package/src/formats/camt.ts +153 -45
- package/src/formats/mt940.ts +244 -122
- package/src/formats/readers.ts +28 -31
- package/src/formats/record-budget.ts +18 -0
- package/src/formats/sepa-purpose.ts +29 -2
- package/src/index.ts +4 -2
- package/src/session/app-approval.ts +51 -38
- package/src/session/dialog-runner.ts +61 -31
- package/src/session/login-guard.ts +189 -87
- package/src/session/sepa-accounts.ts +63 -45
- package/src/session/session-setup.ts +105 -68
- package/src/session/session-state.ts +74 -23
- package/src/session/signed-dialog.ts +222 -0
- package/src/session/tan-selection.ts +50 -39
- package/src/session/user-prompts.ts +62 -18
- package/src/tan/challenge.ts +87 -64
- package/src/tan/flicker.ts +72 -23
- package/src/tan/tan-image.ts +15 -6
- package/src/tan/tan-models.ts +26 -7
- package/src/util/arguments.ts +40 -0
- package/src/util/async.ts +10 -9
- package/src/util/bytes.ts +14 -20
- package/src/util/call-context.ts +3 -2
- package/src/util/dates.ts +64 -33
- package/src/util/errors.ts +22 -6
- package/src/util/immutable-map.ts +15 -12
- package/src/util/inspect.ts +14 -0
- package/src/util/json.ts +16 -0
- package/src/util/text.ts +87 -15
- package/src/util/xml.ts +130 -52
- package/src/v3/account-extension.ts +7 -12
- package/src/v3/bank-connection.ts +126 -0
- package/src/v3/dialog.ts +186 -92
- package/src/v3/message.ts +140 -79
- package/src/v3/parameter-store.ts +226 -0
- package/src/v3/parameters.ts +166 -66
- package/src/v3/protocol.ts +103 -253
- package/src/v3/queries.ts +198 -0
- package/src/v3/segments.ts +86 -31
- package/src/v3/syntax.ts +172 -93
- package/dist/session/bank-connection.d.ts +0 -28
- package/dist/session/bank-connection.d.ts.map +0 -1
- package/dist/session/bank-connection.js +0 -48
- package/dist/session/bank-connection.js.map +0 -1
- package/dist/session/parameter-data.d.ts +0 -83
- package/dist/session/parameter-data.d.ts.map +0 -1
- package/dist/session/parameter-data.js +0 -68
- package/dist/session/parameter-data.js.map +0 -1
- package/dist/session/pin-tan-client.d.ts +0 -54
- package/dist/session/pin-tan-client.d.ts.map +0 -1
- package/dist/session/pin-tan-client.js +0 -153
- package/dist/session/pin-tan-client.js.map +0 -1
- package/dist/session/pin-tan-dialog.d.ts +0 -71
- package/dist/session/pin-tan-dialog.d.ts.map +0 -1
- package/dist/session/pin-tan-dialog.js +0 -124
- package/dist/session/pin-tan-dialog.js.map +0 -1
- package/dist/session/protocol.d.ts +0 -209
- package/dist/session/protocol.d.ts.map +0 -1
- package/dist/session/protocol.js +0 -75
- package/dist/session/protocol.js.map +0 -1
- package/dist/session/response-handler.d.ts +0 -48
- package/dist/session/response-handler.d.ts.map +0 -1
- package/dist/session/response-handler.js +0 -121
- package/dist/session/response-handler.js.map +0 -1
- package/dist/v3/client.d.ts +0 -24
- package/dist/v3/client.d.ts.map +0 -1
- package/dist/v3/client.js +0 -16
- package/dist/v3/client.js.map +0 -1
- package/src/session/bank-connection.ts +0 -51
- package/src/session/parameter-data.ts +0 -137
- package/src/session/pin-tan-client.ts +0 -186
- package/src/session/pin-tan-dialog.ts +0 -160
- package/src/session/protocol.ts +0 -311
- package/src/session/response-handler.ts +0 -130
- package/src/v3/client.ts +0 -29
package/dist/core/account.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { inspectCustom } from '../util/inspect.js';
|
|
1
2
|
/** Account kind derived from the FinTS account type code. */
|
|
2
3
|
export type AccountCategory =
|
|
3
4
|
/** Current account (type codes 1 to 9). */
|
|
@@ -22,8 +23,6 @@ export type AccountCategory =
|
|
|
22
23
|
| 'other'
|
|
23
24
|
/** The bank states no type code. */
|
|
24
25
|
| 'unknown';
|
|
25
|
-
/** The category of the FinTS account type `code`, which is `undefined` if the bank states none. */
|
|
26
|
-
export declare function accountCategoryOf(code: number | undefined): AccountCategory;
|
|
27
26
|
/** What `Account` takes; the bank states the details it knows. */
|
|
28
27
|
export interface AccountInit {
|
|
29
28
|
accountNumber?: string | undefined;
|
|
@@ -41,7 +40,15 @@ export interface AccountInit {
|
|
|
41
40
|
allowedTransactionsComplete?: boolean | undefined;
|
|
42
41
|
dataStatus?: AccountDataStatus | undefined;
|
|
43
42
|
}
|
|
44
|
-
/**
|
|
43
|
+
/**
|
|
44
|
+
* A bank account as reported by the user parameter data or the SEPA account query.
|
|
45
|
+
*
|
|
46
|
+
* An account the app builds itself, such as from a stored IBAN, stands for the one of `getAccounts` it `matches`:
|
|
47
|
+
* queries take the details the bank states of that one, and the transactions the bank permits for it. One the bank
|
|
48
|
+
* names nowhere goes out with its account number, sub-account, IBAN, BIC, bank and country code and currency only, and
|
|
49
|
+
* is refused with `FinTsUnsupportedError` where the bank's lists of permitted transactions are complete. Queries never
|
|
50
|
+
* take the permitted transactions from the app's account.
|
|
51
|
+
*/
|
|
45
52
|
export declare class Account {
|
|
46
53
|
/** National account number. */
|
|
47
54
|
readonly accountNumber: string | undefined;
|
|
@@ -51,9 +58,12 @@ export declare class Account {
|
|
|
51
58
|
readonly bankCode: string;
|
|
52
59
|
/** Numeric country code of the bank, `280` for Germany. */
|
|
53
60
|
readonly countryCode: string;
|
|
54
|
-
/**
|
|
61
|
+
/**
|
|
62
|
+
* International bank account number, in its electronic format: without blanks and in capitals, however
|
|
63
|
+
* `AccountInit.iban` wrote it, such as in groups of four as printed.
|
|
64
|
+
*/
|
|
55
65
|
readonly iban: string | undefined;
|
|
56
|
-
/** Bank identifier code of the bank holding the account. */
|
|
66
|
+
/** Bank identifier code of the bank holding the account, without blanks and in capitals. */
|
|
57
67
|
readonly bic: string | undefined;
|
|
58
68
|
/** Customer ID the account is assigned to; may differ from the login name. */
|
|
59
69
|
readonly customerId: string | undefined;
|
|
@@ -68,8 +78,8 @@ export declare class Account {
|
|
|
68
78
|
/**
|
|
69
79
|
* The transactions the bank lists as permitted for this account, by their segment IDs, such as `HKSAL`.
|
|
70
80
|
*
|
|
71
|
-
* The client applies them itself: `getBalance` and `getTransactions`
|
|
72
|
-
*
|
|
81
|
+
* The client applies them itself: `getBalance` and `getTransactions` do not send a query they rule out, and fail with
|
|
82
|
+
* `FinTsUnsupportedError`.
|
|
73
83
|
*/
|
|
74
84
|
readonly allowedTransactions: readonly string[];
|
|
75
85
|
/**
|
|
@@ -79,6 +89,12 @@ export declare class Account {
|
|
|
79
89
|
readonly allowedTransactionsComplete: boolean;
|
|
80
90
|
/** What the bank tells about the data it holds for the account, where it does. */
|
|
81
91
|
readonly dataStatus: AccountDataStatus | undefined;
|
|
92
|
+
/**
|
|
93
|
+
* Takes copies of the permitted transactions and the data status of `init`, which no other account shares.
|
|
94
|
+
*
|
|
95
|
+
* Throws `TypeError` for a detail of another type than `AccountInit` names, such as a number as `bankCode` or
|
|
96
|
+
* `accountNumber`, or a missing `bankCode`; `null` counts as a detail not given. The message leaves out the value.
|
|
97
|
+
*/
|
|
82
98
|
constructor(init: AccountInit);
|
|
83
99
|
/** The kind of account, derived from `typeCode`. */
|
|
84
100
|
get category(): AccountCategory;
|
|
@@ -97,6 +113,23 @@ export declare class Account {
|
|
|
97
113
|
* collect account data.
|
|
98
114
|
*/
|
|
99
115
|
toString(): string;
|
|
116
|
+
/** What Node.js's `util.inspect` and `console.log` show: `toString`, not the fields. */
|
|
117
|
+
[inspectCustom](): string;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Accounts by IBAN and by national account, to find the first one an account `matches` without comparing it with each:
|
|
121
|
+
* a bank may list tens of thousands.
|
|
122
|
+
*/
|
|
123
|
+
export declare class AccountIndex {
|
|
124
|
+
private readonly accounts;
|
|
125
|
+
private readonly byIban;
|
|
126
|
+
/** By national account, under its bank and country code and under `null` for any of each, as `matches` takes them. */
|
|
127
|
+
private readonly byNational;
|
|
128
|
+
/** Those without IBAN only: an account with IBAN matches one with IBAN by that alone. */
|
|
129
|
+
private readonly byNationalWithoutIban;
|
|
130
|
+
constructor(accounts: readonly Account[]);
|
|
131
|
+
/** The first of the accounts that `account` matches. */
|
|
132
|
+
find(account: Account): Account | undefined;
|
|
100
133
|
}
|
|
101
134
|
/**
|
|
102
135
|
* What the bank tells about the data it holds for an account, so that an app asks only for what has changed (FinTS 3.0
|
|
@@ -126,6 +159,7 @@ export declare class AccountDataStatus {
|
|
|
126
159
|
readonly nextTransactionsAt: Date | undefined;
|
|
127
160
|
/** Whether the balances the transactions carry are the current ones. */
|
|
128
161
|
readonly transactionBalancesCurrent: boolean;
|
|
162
|
+
/** Takes copies of the inventory and the date of `init`, which no other status shares. */
|
|
129
163
|
constructor(init: {
|
|
130
164
|
inventory?: ReadonlyMap<string, string>;
|
|
131
165
|
lastTransactions?: string | undefined;
|
|
@@ -136,5 +170,10 @@ export declare class AccountDataStatus {
|
|
|
136
170
|
get mt940TransactionsId(): string | undefined;
|
|
137
171
|
/** The ID of the transactions the bank holds as camt, its entry for `HKCAZ` in `inventory`. */
|
|
138
172
|
get camtTransactionsId(): string | undefined;
|
|
173
|
+
/**
|
|
174
|
+
* What Node.js's `util.inspect` and `console.log` show: the queries `inventory` holds an ID for, not the IDs, which
|
|
175
|
+
* mark the user's data.
|
|
176
|
+
*/
|
|
177
|
+
[inspectCustom](): string;
|
|
139
178
|
}
|
|
140
179
|
//# sourceMappingURL=account.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../../src/core/account.ts"],"names":[],"mappings":"AAIA,6DAA6D;AAC7D,MAAM,MAAM,eAAe;AACzB,2CAA2C;AACzC,UAAU;AACZ,kCAAkC;GAChC,SAAS;AACX,qCAAqC;GACnC,cAAc;AAChB,qCAAqC;GACnC,YAAY;AACd,+BAA+B;GAC7B,MAAM;AACR,sCAAsC;GACpC,YAAY;AACd,+BAA+B;GAC7B,MAAM;AACR,wCAAwC;GACtC,aAAa;AACf,4BAA4B;GAC1B,WAAW;AACb,2BAA2B;GACzB,OAAO;AACT,oCAAoC;GAClC,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../../src/core/account.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAKnD,6DAA6D;AAC7D,MAAM,MAAM,eAAe;AACzB,2CAA2C;AACzC,UAAU;AACZ,kCAAkC;GAChC,SAAS;AACX,qCAAqC;GACnC,cAAc;AAChB,qCAAqC;GACnC,YAAY;AACd,+BAA+B;GAC7B,MAAM;AACR,sCAAsC;GACpC,YAAY;AACd,+BAA+B;GAC7B,MAAM;AACR,wCAAwC;GACtC,aAAa;AACf,4BAA4B;GAC1B,WAAW;AACb,2BAA2B;GACzB,OAAO;AACT,oCAAoC;GAClC,SAAS,CAAC;AAoBd,kEAAkE;AAClE,MAAM,WAAW,WAAW;IAC1B,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,QAAQ,EAAE,MAA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;OAGG;IACH,QAAQ,CAAC,gBAAgB,EAAE,MAAM,GAAG,SAAS,CAAC;IAE9C,qEAAqE;IACrE,QAAQ,CAAC,kBAAkB,EAAE,IAAI,GAAG,SAAS,CAAC;IAE9C,wEAAwE;IACxE,QAAQ,CAAC,0BAA0B,EAAE,OAAO,CAAC;IAE7C,0FAA0F;gBAC9E,IAAI,EAAE;QAChB,SAAS,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACxC,gBAAgB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QACtC,kBAAkB,CAAC,EAAE,IAAI,GAAG,SAAS,CAAC;QACtC,0BAA0B,CAAC,EAAE,OAAO,CAAC;KACtC;IAOD,gGAAgG;IAChG,IAAI,mBAAmB,IAAI,MAAM,GAAG,SAAS,CAE5C;IAED,+FAA+F;IAC/F,IAAI,kBAAkB,IAAI,MAAM,GAAG,SAAS,CAE3C;IAED;;;OAGG;IACH,CAAC,aAAa,CAAC,IAAI,MAAM;CAG1B"}
|
package/dist/core/account.js
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
+
import { optionalBoolean, optionalInteger, optionalString, requireString } from '../util/arguments.js';
|
|
2
|
+
import { copyDate } from '../util/dates.js';
|
|
3
|
+
import { invalidArgument } from '../util/errors.js';
|
|
1
4
|
import { ImmutableMap } from '../util/immutable-map.js';
|
|
2
|
-
import {
|
|
5
|
+
import { inspectCustom } from '../util/inspect.js';
|
|
6
|
+
import { isString } from '../util/json.js';
|
|
7
|
+
import { maskedId, nonBlank } from '../util/text.js';
|
|
3
8
|
import { defaultCountryCode } from './config.js';
|
|
4
9
|
const categoriesByTens = [
|
|
5
10
|
'checking',
|
|
@@ -13,12 +18,20 @@ const categoriesByTens = [
|
|
|
13
18
|
'insurance',
|
|
14
19
|
];
|
|
15
20
|
/** The category of the FinTS account type `code`, which is `undefined` if the bank states none. */
|
|
16
|
-
|
|
21
|
+
function accountCategoryOf(code) {
|
|
17
22
|
if (code === undefined || code < 1)
|
|
18
23
|
return 'unknown';
|
|
19
24
|
return categoriesByTens[Math.floor(code / 10)] ?? 'other';
|
|
20
25
|
}
|
|
21
|
-
/**
|
|
26
|
+
/**
|
|
27
|
+
* A bank account as reported by the user parameter data or the SEPA account query.
|
|
28
|
+
*
|
|
29
|
+
* An account the app builds itself, such as from a stored IBAN, stands for the one of `getAccounts` it `matches`:
|
|
30
|
+
* queries take the details the bank states of that one, and the transactions the bank permits for it. One the bank
|
|
31
|
+
* names nowhere goes out with its account number, sub-account, IBAN, BIC, bank and country code and currency only, and
|
|
32
|
+
* is refused with `FinTsUnsupportedError` where the bank's lists of permitted transactions are complete. Queries never
|
|
33
|
+
* take the permitted transactions from the app's account.
|
|
34
|
+
*/
|
|
22
35
|
export class Account {
|
|
23
36
|
/** National account number. */
|
|
24
37
|
accountNumber;
|
|
@@ -28,9 +41,12 @@ export class Account {
|
|
|
28
41
|
bankCode;
|
|
29
42
|
/** Numeric country code of the bank, `280` for Germany. */
|
|
30
43
|
countryCode;
|
|
31
|
-
/**
|
|
44
|
+
/**
|
|
45
|
+
* International bank account number, in its electronic format: without blanks and in capitals, however
|
|
46
|
+
* `AccountInit.iban` wrote it, such as in groups of four as printed.
|
|
47
|
+
*/
|
|
32
48
|
iban;
|
|
33
|
-
/** Bank identifier code of the bank holding the account. */
|
|
49
|
+
/** Bank identifier code of the bank holding the account, without blanks and in capitals. */
|
|
34
50
|
bic;
|
|
35
51
|
/** Customer ID the account is assigned to; may differ from the login name. */
|
|
36
52
|
customerId;
|
|
@@ -45,8 +61,8 @@ export class Account {
|
|
|
45
61
|
/**
|
|
46
62
|
* The transactions the bank lists as permitted for this account, by their segment IDs, such as `HKSAL`.
|
|
47
63
|
*
|
|
48
|
-
* The client applies them itself: `getBalance` and `getTransactions`
|
|
49
|
-
*
|
|
64
|
+
* The client applies them itself: `getBalance` and `getTransactions` do not send a query they rule out, and fail with
|
|
65
|
+
* `FinTsUnsupportedError`.
|
|
50
66
|
*/
|
|
51
67
|
allowedTransactions;
|
|
52
68
|
/**
|
|
@@ -56,21 +72,28 @@ export class Account {
|
|
|
56
72
|
allowedTransactionsComplete;
|
|
57
73
|
/** What the bank tells about the data it holds for the account, where it does. */
|
|
58
74
|
dataStatus;
|
|
75
|
+
/**
|
|
76
|
+
* Takes copies of the permitted transactions and the data status of `init`, which no other account shares.
|
|
77
|
+
*
|
|
78
|
+
* Throws `TypeError` for a detail of another type than `AccountInit` names, such as a number as `bankCode` or
|
|
79
|
+
* `accountNumber`, or a missing `bankCode`; `null` counts as a detail not given. The message leaves out the value.
|
|
80
|
+
*/
|
|
59
81
|
constructor(init) {
|
|
60
|
-
this.accountNumber = init.accountNumber;
|
|
61
|
-
this.subAccount = init.subAccount;
|
|
62
|
-
this.bankCode = init.bankCode;
|
|
63
|
-
this.countryCode = init.countryCode ?? defaultCountryCode;
|
|
64
|
-
this.iban = init.iban;
|
|
65
|
-
this.bic = init.bic;
|
|
66
|
-
this.customerId = init.customerId;
|
|
67
|
-
this.currency = init.currency;
|
|
68
|
-
this.ownerName = init.ownerName;
|
|
69
|
-
this.productName = init.productName;
|
|
70
|
-
this.typeCode = init.typeCode;
|
|
71
|
-
this.allowedTransactions = Object.freeze(
|
|
72
|
-
this.allowedTransactionsComplete =
|
|
73
|
-
|
|
82
|
+
this.accountNumber = optionalString(init.accountNumber, 'accountNumber');
|
|
83
|
+
this.subAccount = optionalString(init.subAccount, 'subAccount');
|
|
84
|
+
this.bankCode = requireString(init.bankCode, 'bankCode');
|
|
85
|
+
this.countryCode = optionalString(init.countryCode, 'countryCode') ?? defaultCountryCode;
|
|
86
|
+
this.iban = electronicFormat(optionalString(init.iban, 'iban'));
|
|
87
|
+
this.bic = electronicFormat(optionalString(init.bic, 'bic'));
|
|
88
|
+
this.customerId = optionalString(init.customerId, 'customerId');
|
|
89
|
+
this.currency = optionalString(init.currency, 'currency');
|
|
90
|
+
this.ownerName = optionalString(init.ownerName, 'ownerName');
|
|
91
|
+
this.productName = optionalString(init.productName, 'productName');
|
|
92
|
+
this.typeCode = optionalInteger(init.typeCode, 'typeCode');
|
|
93
|
+
this.allowedTransactions = Object.freeze(segmentIds(init.allowedTransactions));
|
|
94
|
+
this.allowedTransactionsComplete =
|
|
95
|
+
optionalBoolean(init.allowedTransactionsComplete, 'allowedTransactionsComplete') ?? false;
|
|
96
|
+
this.dataStatus = copiedDataStatus(init.dataStatus);
|
|
74
97
|
}
|
|
75
98
|
/** The kind of account, derived from `typeCode`. */
|
|
76
99
|
get category() {
|
|
@@ -86,9 +109,9 @@ export class Account {
|
|
|
86
109
|
matches(other) {
|
|
87
110
|
if (this.iban !== undefined && other.iban !== undefined)
|
|
88
111
|
return this.iban === other.iban;
|
|
89
|
-
const number = this
|
|
112
|
+
const number = nationalNumber(this);
|
|
90
113
|
return (number !== undefined &&
|
|
91
|
-
number === other
|
|
114
|
+
number === nationalNumber(other) &&
|
|
92
115
|
(this.subAccount ?? '') === (other.subAccount ?? '') &&
|
|
93
116
|
sameOrUnstated(this.bankCode, other.bankCode) &&
|
|
94
117
|
sameOrUnstated(this.countryCode, other.countryCode));
|
|
@@ -124,10 +147,98 @@ export class Account {
|
|
|
124
147
|
];
|
|
125
148
|
return `Account(${parts.join(', ')})`;
|
|
126
149
|
}
|
|
150
|
+
/** What Node.js's `util.inspect` and `console.log` show: `toString`, not the fields. */
|
|
151
|
+
[inspectCustom]() {
|
|
152
|
+
return this.toString();
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* An IBAN or BIC in the form the bank sends and compares, without blanks, U+0085 (NEL) among them, and in capitals;
|
|
157
|
+
* `undefined` for blanks only.
|
|
158
|
+
*/
|
|
159
|
+
function electronicFormat(code) {
|
|
160
|
+
return nonBlank(code?.replace(/[\s\u0085]/g, '').toUpperCase());
|
|
161
|
+
}
|
|
162
|
+
/** A copy of `ids`, none for `undefined` or `null`; throws `TypeError` unless they are an array of strings. */
|
|
163
|
+
function segmentIds(ids) {
|
|
164
|
+
if (ids === undefined || ids === null)
|
|
165
|
+
return [];
|
|
166
|
+
if (!Array.isArray(ids) || !ids.every(isString)) {
|
|
167
|
+
throw invalidArgument('Must be an array of strings', 'allowedTransactions');
|
|
168
|
+
}
|
|
169
|
+
return [...ids];
|
|
170
|
+
}
|
|
171
|
+
/** A copy of `status`, none for `undefined` or `null`; throws `TypeError` unless it is an `AccountDataStatus`. */
|
|
172
|
+
function copiedDataStatus(status) {
|
|
173
|
+
if (status === undefined || status === null)
|
|
174
|
+
return undefined;
|
|
175
|
+
if (!(status instanceof AccountDataStatus))
|
|
176
|
+
throw invalidArgument('Must be an AccountDataStatus', 'dataStatus');
|
|
177
|
+
return new AccountDataStatus(status);
|
|
127
178
|
}
|
|
128
179
|
function sameOrUnstated(a, b) {
|
|
129
180
|
return a === '' || b === '' || a === b;
|
|
130
181
|
}
|
|
182
|
+
/** The account number as `Account.matches` compares it: without leading zeros. */
|
|
183
|
+
function nationalNumber(account) {
|
|
184
|
+
return account.accountNumber?.replace(/^0+/, '');
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Accounts by IBAN and by national account, to find the first one an account `matches` without comparing it with each:
|
|
188
|
+
* a bank may list tens of thousands.
|
|
189
|
+
*/
|
|
190
|
+
export class AccountIndex {
|
|
191
|
+
accounts;
|
|
192
|
+
byIban = new Map();
|
|
193
|
+
/** By national account, under its bank and country code and under `null` for any of each, as `matches` takes them. */
|
|
194
|
+
byNational = new Map();
|
|
195
|
+
/** Those without IBAN only: an account with IBAN matches one with IBAN by that alone. */
|
|
196
|
+
byNationalWithoutIban = new Map();
|
|
197
|
+
constructor(accounts) {
|
|
198
|
+
this.accounts = accounts;
|
|
199
|
+
accounts.forEach((account, i) => {
|
|
200
|
+
if (account.iban !== undefined)
|
|
201
|
+
keepFirst(this.byIban, account.iban, i);
|
|
202
|
+
const number = nationalNumber(account);
|
|
203
|
+
if (number === undefined)
|
|
204
|
+
return;
|
|
205
|
+
for (const bankCode of [account.bankCode, null]) {
|
|
206
|
+
for (const countryCode of [account.countryCode, null]) {
|
|
207
|
+
const national = nationalKey(number, account.subAccount, bankCode, countryCode);
|
|
208
|
+
keepFirst(this.byNational, national, i);
|
|
209
|
+
if (account.iban === undefined)
|
|
210
|
+
keepFirst(this.byNationalWithoutIban, national, i);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
/** The first of the accounts that `account` matches. */
|
|
216
|
+
find(account) {
|
|
217
|
+
const number = nationalNumber(account);
|
|
218
|
+
const byNational = account.iban === undefined ? this.byNational : this.byNationalWithoutIban;
|
|
219
|
+
const found = [account.iban === undefined ? undefined : this.byIban.get(account.iban)];
|
|
220
|
+
if (number !== undefined) {
|
|
221
|
+
for (const bankCode of codesMatching(account.bankCode)) {
|
|
222
|
+
for (const countryCode of codesMatching(account.countryCode)) {
|
|
223
|
+
found.push(byNational.get(nationalKey(number, account.subAccount, bankCode, countryCode)));
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
const positions = found.filter((i) => i !== undefined);
|
|
228
|
+
return positions.length === 0 ? undefined : this.accounts[Math.min(...positions)];
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
/** The keys of the codes that `code` matches: an empty one matches any, and a stated one also an empty one. */
|
|
232
|
+
function codesMatching(code) {
|
|
233
|
+
return code === '' ? [null] : [code, ''];
|
|
234
|
+
}
|
|
235
|
+
function nationalKey(number, subAccount, bankCode, countryCode) {
|
|
236
|
+
return JSON.stringify([number, subAccount ?? '', bankCode, countryCode]);
|
|
237
|
+
}
|
|
238
|
+
function keepFirst(index, key, position) {
|
|
239
|
+
if (!index.has(key))
|
|
240
|
+
index.set(key, position);
|
|
241
|
+
}
|
|
131
242
|
/**
|
|
132
243
|
* What the bank tells about the data it holds for an account, so that an app asks only for what has changed (FinTS 3.0
|
|
133
244
|
* user parameter data, "Erweiterung, kontobezogen", Formals E.3.1 and F).
|
|
@@ -156,10 +267,11 @@ export class AccountDataStatus {
|
|
|
156
267
|
nextTransactionsAt;
|
|
157
268
|
/** Whether the balances the transactions carry are the current ones. */
|
|
158
269
|
transactionBalancesCurrent;
|
|
270
|
+
/** Takes copies of the inventory and the date of `init`, which no other status shares. */
|
|
159
271
|
constructor(init) {
|
|
160
272
|
this.inventory = new ImmutableMap(init.inventory ?? []);
|
|
161
273
|
this.lastTransactions = init.lastTransactions;
|
|
162
|
-
this.nextTransactionsAt = init.nextTransactionsAt;
|
|
274
|
+
this.nextTransactionsAt = copyDate(init.nextTransactionsAt);
|
|
163
275
|
this.transactionBalancesCurrent = init.transactionBalancesCurrent ?? false;
|
|
164
276
|
}
|
|
165
277
|
/** The ID of the transactions the bank holds as MT940, its entry for `HKKAZ` in `inventory`. */
|
|
@@ -170,5 +282,12 @@ export class AccountDataStatus {
|
|
|
170
282
|
get camtTransactionsId() {
|
|
171
283
|
return this.inventory.get('HKCAZ');
|
|
172
284
|
}
|
|
285
|
+
/**
|
|
286
|
+
* What Node.js's `util.inspect` and `console.log` show: the queries `inventory` holds an ID for, not the IDs, which
|
|
287
|
+
* mark the user's data.
|
|
288
|
+
*/
|
|
289
|
+
[inspectCustom]() {
|
|
290
|
+
return `AccountDataStatus(${[...this.inventory.keys()].join(', ')})`;
|
|
291
|
+
}
|
|
173
292
|
}
|
|
174
293
|
//# sourceMappingURL=account.js.map
|
package/dist/core/account.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account.js","sourceRoot":"","sources":["../../src/core/account.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AA2BjD,MAAM,gBAAgB,GAA+B;IACnD,UAAU;IACV,SAAS;IACT,cAAc;IACd,YAAY;IACZ,MAAM;IACN,YAAY;IACZ,MAA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er number of `scale`-digit minor units. */
|
|
2
3
|
export declare class Amount {
|
|
3
4
|
/** The amount in units of 10^-`scale` of the currency, negative for a debit: 1234 with scale 2 is 12.34. */
|
|
@@ -9,6 +10,8 @@ export declare class Amount {
|
|
|
9
10
|
/**
|
|
10
11
|
* An amount of `minorUnits` with `scale` decimal places; throws `RangeError` for a `scale` outside 0 to 5, and for
|
|
11
12
|
* `minorUnits` that are no integer or beyond 2^53 - 1 in either direction, about 90 trillion at two decimal places.
|
|
13
|
+
* Throws `TypeError` for `minorUnits` or `scale` that are no number, such as `'1234'`, and a `currency` that is no
|
|
14
|
+
* string.
|
|
12
15
|
*/
|
|
13
16
|
constructor(minorUnits: number, scale: number, currency: string);
|
|
14
17
|
/**
|
|
@@ -19,8 +22,9 @@ export declare class Amount {
|
|
|
19
22
|
* `JPY`, three for `KWD`. It has more where the value has more significant digits. So `100,` in `EUR` is `100.00`, in
|
|
20
23
|
* `JPY` `100`.
|
|
21
24
|
*
|
|
22
|
-
* Throws `FormatError` for anything else, so that `1.234,56` in bank data is an error, not a guess,
|
|
23
|
-
* five decimal places (trailing zeros aside) or more than 15 digits
|
|
25
|
+
* Throws `FormatError` for anything else, so that `1.234,56` in bank data is an error, not a guess, for more than
|
|
26
|
+
* five decimal places (trailing zeros aside) or more than 15 digits, and for more than 64 characters, zeros included
|
|
27
|
+
* and surrounding blanks aside. Throws `TypeError` for a `value` or `currency` that is no string.
|
|
24
28
|
*/
|
|
25
29
|
static parseDecimal(value: string, currency: string): Amount;
|
|
26
30
|
/** The amount as a floating-point number, which cannot hold every decimal fraction exactly; do not calculate with it. */
|
|
@@ -47,16 +51,23 @@ export declare class Amount {
|
|
|
47
51
|
/** Formats the amount without currency, for example `-12.50`. */
|
|
48
52
|
toDecimalString(decimalSeparator?: string): string;
|
|
49
53
|
toString(): string;
|
|
54
|
+
/** What Node.js's `util.inspect` and `console.log` show: `toString`, not the fields. */
|
|
55
|
+
[inspectCustom](): string;
|
|
50
56
|
/** The minor units of both amounts at the larger scale, as `bigint`s, since the factor could leave the safe range. */
|
|
51
57
|
private atCommonScale;
|
|
52
|
-
private rescale;
|
|
53
58
|
private compareValue;
|
|
54
59
|
private checkCurrency;
|
|
55
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* Whether `parts` are all in the currency of `total` and add up to exactly `total`; unlike `add`, also where a sum on
|
|
63
|
+
* the way lies beyond what an amount holds.
|
|
64
|
+
*/
|
|
65
|
+
export declare function addsUpTo(parts: readonly Amount[], total: Amount): boolean;
|
|
56
66
|
/**
|
|
57
67
|
* `amount` as a credit (unchanged) or a debit (negated), by the bank's credit/debit `mark`.
|
|
58
68
|
*
|
|
59
|
-
* Throws `FormatError` for any other `mark`, `undefined` included: a missing mark must not be read as a credit.
|
|
69
|
+
* Throws `FormatError` for any other `mark`, `undefined` included: a missing mark must not be read as a credit. It does
|
|
70
|
+
* as well for a negative `amount`, whose sign the mark would turn: the mark alone gives the direction.
|
|
60
71
|
*/
|
|
61
72
|
export declare function withMark(amount: Amount, mark: string | undefined, credit: string, debit: string): Amount;
|
|
62
73
|
//# sourceMappingURL=amount.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"amount.d.ts","sourceRoot":"","sources":["../../src/core/amount.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"amount.d.ts","sourceRoot":"","sources":["../../src/core/amount.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAuDnD,+EAA+E;AAC/E,qBAAa,MAAM;IACjB,4GAA4G;IAC5G,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAE5B,8DAA8D;IAC9D,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAEvB,iDAAiD;IACjD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAE1B;;;;;OAKG;gBACS,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;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Argument } from '../util/errors.js';
|
|
3
|
+
import { inspectCustom } from '../util/inspect.js';
|
|
4
|
+
import { trimBlanks } from '../util/text.js';
|
|
2
5
|
/** Most decimal places an amount has: ISO 20022, the widest of the bank formats, allows five. */
|
|
3
6
|
const maxScale = 5;
|
|
4
7
|
/** Largest `minorUnits` an amount holds: 2^53 - 1, which JavaScript numbers represent exactly. */
|
|
@@ -6,6 +9,8 @@ const maxMinorUnits = Number.MAX_SAFE_INTEGER;
|
|
|
6
9
|
const powersOfTen = [1, 10, 100, 1000, 10000, 100000];
|
|
7
10
|
/** Most digits a parsed amount has: few enough that the sum of two parsed amounts still fits. */
|
|
8
11
|
const maxDigits = 15;
|
|
12
|
+
/** Most characters a parsed value has: room for the zeros banks pad amounts with besides `maxDigits` digits. */
|
|
13
|
+
const maxLength = 64;
|
|
9
14
|
const decimal = /^([+-]?)(\d*)(?:[.,](\d*))?$/;
|
|
10
15
|
/** Decimal places of the minor unit of `currency` (ISO 4217): two, except for the currencies listed here. */
|
|
11
16
|
function minorUnitDigits(currency) {
|
|
@@ -54,8 +59,15 @@ export class Amount {
|
|
|
54
59
|
/**
|
|
55
60
|
* An amount of `minorUnits` with `scale` decimal places; throws `RangeError` for a `scale` outside 0 to 5, and for
|
|
56
61
|
* `minorUnits` that are no integer or beyond 2^53 - 1 in either direction, about 90 trillion at two decimal places.
|
|
62
|
+
* Throws `TypeError` for `minorUnits` or `scale` that are no number, such as `'1234'`, and a `currency` that is no
|
|
63
|
+
* string.
|
|
57
64
|
*/
|
|
58
65
|
constructor(minorUnits, scale, currency) {
|
|
66
|
+
if (typeof minorUnits !== 'number')
|
|
67
|
+
throw invalidArgument('Must be a number', 'minorUnits');
|
|
68
|
+
if (typeof scale !== 'number')
|
|
69
|
+
throw invalidArgument('Must be a number', 'scale');
|
|
70
|
+
requireString(currency, 'currency');
|
|
59
71
|
if (!Number.isInteger(scale) || scale < 0 || scale > maxScale) {
|
|
60
72
|
throw new RangeError(`scale must be an integer from 0 to ${maxScale}: ${scale}`);
|
|
61
73
|
}
|
|
@@ -74,11 +86,16 @@ export class Amount {
|
|
|
74
86
|
* `JPY`, three for `KWD`. It has more where the value has more significant digits. So `100,` in `EUR` is `100.00`, in
|
|
75
87
|
* `JPY` `100`.
|
|
76
88
|
*
|
|
77
|
-
* Throws `FormatError` for anything else, so that `1.234,56` in bank data is an error, not a guess,
|
|
78
|
-
* five decimal places (trailing zeros aside) or more than 15 digits
|
|
89
|
+
* Throws `FormatError` for anything else, so that `1.234,56` in bank data is an error, not a guess, for more than
|
|
90
|
+
* five decimal places (trailing zeros aside) or more than 15 digits, and for more than 64 characters, zeros included
|
|
91
|
+
* and surrounding blanks aside. Throws `TypeError` for a `value` or `currency` that is no string.
|
|
79
92
|
*/
|
|
80
93
|
static parseDecimal(value, currency) {
|
|
81
|
-
const
|
|
94
|
+
const trimmed = trimBlanks(requireString(value, 'value'));
|
|
95
|
+
requireString(currency, 'currency');
|
|
96
|
+
if (trimmed.length > maxLength)
|
|
97
|
+
throw new FormatError(`Amount longer than ${maxLength} characters`, value);
|
|
98
|
+
const match = decimal.exec(trimmed);
|
|
82
99
|
const whole = match?.[2] ?? '';
|
|
83
100
|
let fraction = match?.[3] ?? '';
|
|
84
101
|
if (!match || (whole === '' && fraction === ''))
|
|
@@ -155,13 +172,14 @@ export class Amount {
|
|
|
155
172
|
toString() {
|
|
156
173
|
return `${this.toDecimalString()} ${this.currency}`;
|
|
157
174
|
}
|
|
175
|
+
/** What Node.js's `util.inspect` and `console.log` show: `toString`, not the fields. */
|
|
176
|
+
[inspectCustom]() {
|
|
177
|
+
return this.toString();
|
|
178
|
+
}
|
|
158
179
|
/** The minor units of both amounts at the larger scale, as `bigint`s, since the factor could leave the safe range. */
|
|
159
180
|
atCommonScale(other) {
|
|
160
181
|
const target = Math.max(this.scale, other.scale);
|
|
161
|
-
return [this
|
|
162
|
-
}
|
|
163
|
-
rescale(target) {
|
|
164
|
-
return BigInt(this.minorUnits) * BigInt(powersOfTen[target - this.scale]);
|
|
182
|
+
return [unitsAtScale(this, target), unitsAtScale(other, target)];
|
|
165
183
|
}
|
|
166
184
|
compareValue(other) {
|
|
167
185
|
if (this.scale === other.scale)
|
|
@@ -174,12 +192,31 @@ export class Amount {
|
|
|
174
192
|
throw new TypeError(`Currency mismatch: ${this.currency} vs ${other.currency}`);
|
|
175
193
|
}
|
|
176
194
|
}
|
|
195
|
+
function unitsAtScale(amount, scale) {
|
|
196
|
+
return BigInt(amount.minorUnits) * BigInt(powersOfTen[scale - amount.scale]);
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Whether `parts` are all in the currency of `total` and add up to exactly `total`; unlike `add`, also where a sum on
|
|
200
|
+
* the way lies beyond what an amount holds.
|
|
201
|
+
*/
|
|
202
|
+
export function addsUpTo(parts, total) {
|
|
203
|
+
let sum = 0n;
|
|
204
|
+
for (const part of parts) {
|
|
205
|
+
if (part.currency !== total.currency)
|
|
206
|
+
return false;
|
|
207
|
+
sum += unitsAtScale(part, maxScale);
|
|
208
|
+
}
|
|
209
|
+
return sum === unitsAtScale(total, maxScale);
|
|
210
|
+
}
|
|
177
211
|
/**
|
|
178
212
|
* `amount` as a credit (unchanged) or a debit (negated), by the bank's credit/debit `mark`.
|
|
179
213
|
*
|
|
180
|
-
* Throws `FormatError` for any other `mark`, `undefined` included: a missing mark must not be read as a credit.
|
|
214
|
+
* Throws `FormatError` for any other `mark`, `undefined` included: a missing mark must not be read as a credit. It does
|
|
215
|
+
* as well for a negative `amount`, whose sign the mark would turn: the mark alone gives the direction.
|
|
181
216
|
*/
|
|
182
217
|
export function withMark(amount, mark, credit, debit) {
|
|
218
|
+
if (amount.isNegative)
|
|
219
|
+
throw new FormatError('Negative amount with a credit/debit mark', amount.toString());
|
|
183
220
|
if (mark === credit)
|
|
184
221
|
return amount;
|
|
185
222
|
if (mark === debit)
|
package/dist/core/amount.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"amount.js","sourceRoot":"","sources":["../../src/core/amount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"amount.js","sourceRoot":"","sources":["../../src/core/amount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,iGAAiG;AACjG,MAAM,QAAQ,GAAG,CAAC,CAAC;AAEnB,kGAAkG;AAClG,MAAM,aAAa,GAAG,MAAM,CAAC,gBAAgB,CAAC;AAC9C,MAAM,WAAW,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;AAEtD,iGAAiG;AACjG,MAAM,SAAS,GAAG,EAAE,CAAC;AAErB,gHAAgH;AAChH,MAAM,SAAS,GAAG,EAAE,CAAC;AAErB,MAAM,OAAO,GAAG,8BAA8B,CAAC;AAE/C,6GAA6G;AAC7G,SAAS,eAAe,CAAC,QAAgB;IACvC,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,KAAK,CAAC;QACX,KAAK,KAAK,CAAC;QACX,KAAK,KAAK,CAAC;QACX,KAAK,KAAK,CAAC;QACX,KAAK,KAAK,CAAC;QACX,KAAK,KAAK,CAAC;QACX,KAAK,KAAK,CAAC;QACX,KAAK,KAAK,CAAC;QACX,KAAK,KAAK,CAAC;QACX,KAAK,KAAK,CAAC;QACX,KAAK,KAAK,CAAC;QACX,KAAK,KAAK,CAAC;QACX,KAAK,KAAK,CAAC;QACX,KAAK,KAAK,CAAC;QACX,KAAK,KAAK,CAAC;QACX,KAAK,KAAK,CAAC;QACX,KAAK,KAAK;YACR,OAAO,CAAC,CA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|
package/dist/core/balance.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { inspectCustom } from '../util/inspect.js';
|
|
1
2
|
import type { Account } from './account.js';
|
|
2
3
|
import type { Amount } from './amount.js';
|
|
3
4
|
/** What `Balance` takes; the bank states the amounts it knows. */
|
|
@@ -44,11 +45,14 @@ export declare class Balance {
|
|
|
44
45
|
readonly bookingTime: Date | undefined;
|
|
45
46
|
/** The bank's name for the account, for example `Girokonto`. */
|
|
46
47
|
readonly productName: string | undefined;
|
|
48
|
+
/** Takes copies of the dates of `init`: each balance has its own, which no other one shares. */
|
|
47
49
|
constructor(init: BalanceInit);
|
|
48
50
|
/**
|
|
49
51
|
* The account, as `Account.toString` shows it, and the date; no amount, so that logs and crash reports do not collect
|
|
50
52
|
* account data.
|
|
51
53
|
*/
|
|
52
54
|
toString(): string;
|
|
55
|
+
/** What Node.js's `util.inspect` and `console.log` show: `toString`, not the fields. */
|
|
56
|
+
[inspectCustom](): string;
|
|
53
57
|
}
|
|
54
58
|
//# sourceMappingURL=balance.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"balance.d.ts","sourceRoot":"","sources":["../../src/core/balance.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C,kEAAkE;AAClE,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,IAAI,CAAC;IACjB,cAAc,CAAC,EAAE,IAAI,GAAG,SAAS,CAAC;IAClC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,IAAI,CAAC,EAAE,MAAM,GAA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