@ekwo-ai/qonto-transactions 0.0.0-stage → 0.30.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/LICENSE +21 -0
- package/README.md +116 -2
- package/dist/decimal.d.ts +18 -0
- package/dist/decimal.d.ts.map +1 -0
- package/dist/decimal.js +47 -0
- package/dist/decimal.js.map +1 -0
- package/dist/errors.d.ts +18 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +9 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +284 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +243 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +21 -0
- package/dist/types.js.map +1 -0
- package/package.json +49 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 EKWO OÜ, trading as Ekwo
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,117 @@
|
|
|
1
|
-
#
|
|
1
|
+
# `@ekwo-ai/qonto-transactions`
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Reads what the **Qonto** API answers for one bank account — the account and
|
|
4
|
+
its transactions — into a bank statement, in TypeScript, with no dependencies.
|
|
5
|
+
|
|
6
|
+
A company reaches its own Qonto accounts with its own key: the organisation's
|
|
7
|
+
login and secret key, read only. This reader makes **no request**: the caller
|
|
8
|
+
fetches (`GET /v2/organization` for the bank accounts, the pages of
|
|
9
|
+
`GET /v2/transactions` for one of them) and hands the answer over. What comes
|
|
10
|
+
back is a statement as the file readers return one — an account, two balances
|
|
11
|
+
and lines — so it enters a ledger the way a camt.053 does.
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { readQontoTransactions } from '@ekwo-ai/qonto-transactions';
|
|
15
|
+
|
|
16
|
+
const { statements, violations } = readQontoTransactions(
|
|
17
|
+
{ account, transactions }, // one of organization.bank_accounts, and every page's transactions
|
|
18
|
+
{ openingBalance: '1700.00', balanceDate: '2026-11-30' },
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
const statement = statements[0];
|
|
22
|
+
statement.closingBalance; // { type: 'CLBD', amount: '2149.90', currency: 'EUR', date: '2026-11-30' }
|
|
23
|
+
statement.balanced; // true: 1700.00 plus the settled lines is the balance
|
|
24
|
+
for (const line of statement.lines) {
|
|
25
|
+
line.amount; // '-800.00' — signed by its `side`, a decimal string, never a float
|
|
26
|
+
line.booked; // true for a settled transaction; a pending or declined one is returned, not booked
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
It knows no database and no ledger. The shape it returns is declared in
|
|
31
|
+
[`src/types.ts`](./src/types.ts), imported from nowhere, and is **field for
|
|
32
|
+
field the shape [`@ekwo-ai/camt053`](../camt053/) declares for itself**; what
|
|
33
|
+
only Qonto says comes after (`emittedOn` on a line, `openingImplied` on the
|
|
34
|
+
statement). Nothing here assumes a currency, a number of decimals, a country or
|
|
35
|
+
a language.
|
|
36
|
+
|
|
37
|
+
## The balances
|
|
38
|
+
|
|
39
|
+
An API gives a balance **now**, not a statement with two ends. So:
|
|
40
|
+
|
|
41
|
+
- **The closing balance** is the account's `balance`, dated on `balanceDate`
|
|
42
|
+
— the day the caller read it — or, without one, on the newest settled line.
|
|
43
|
+
- **The opening balance** is the caller's to declare: the closing balance of
|
|
44
|
+
the statement before, which it kept. The settled lines are then **checked**
|
|
45
|
+
against it, and a transaction the answer lacks shows as `balance_mismatch`,
|
|
46
|
+
with the difference. It is never corrected.
|
|
47
|
+
- **`openingBalance: 'implied'`** is for a first statement, with nothing before
|
|
48
|
+
it: the opening is the balance less the settled lines, `openingImplied` says
|
|
49
|
+
so, and `balanced` stays `null`.
|
|
50
|
+
|
|
51
|
+
A line's booking day is the day of `settled_at`, as written. Settled lines
|
|
52
|
+
are ordered by the instant they settled, and the same instant by id. The
|
|
53
|
+
statement's `id` is the day of the balance and the id of the newest settled
|
|
54
|
+
transaction: the same transactions, in any order, always make the same one.
|
|
55
|
+
|
|
56
|
+
The statement's `period` runs from the earliest to the latest of the settled
|
|
57
|
+
days and the balance day, so it never ends before it starts. A line settled
|
|
58
|
+
after `balanceDate` widens it to that line's day; the closing balance keeps
|
|
59
|
+
its own day.
|
|
60
|
+
|
|
61
|
+
## Options
|
|
62
|
+
|
|
63
|
+
| Option | What it says |
|
|
64
|
+
|---|---|
|
|
65
|
+
| `openingBalance` | A decimal string (`1250.00`, `-40.10`), or `implied`. Left out, the statement has no opening balance. |
|
|
66
|
+
| `balanceDate` | `YYYY-MM-DD`: the day the balance was read. |
|
|
67
|
+
| `maxTransactions` | Refuse more transactions than this, unread. Default 100 000. |
|
|
68
|
+
|
|
69
|
+
## What is thrown, and what comes back as a violation
|
|
70
|
+
|
|
71
|
+
**Thrown** (`StatementFileError`, with a `code`): `not_a_response` (no account,
|
|
72
|
+
no IBAN, no currency, a balance that is not an amount, transactions that are
|
|
73
|
+
not a list), `too_large`, `invalid_option`.
|
|
74
|
+
|
|
75
|
+
**Returned** in `violations`, with the line and the transaction id:
|
|
76
|
+
|
|
77
|
+
| code | when |
|
|
78
|
+
|---|---|
|
|
79
|
+
| `balance_mismatch` | the declared opening plus the settled lines is not the balance |
|
|
80
|
+
| `invalid_amount`, `invalid_date` | the line comes back with `null` there |
|
|
81
|
+
| `unknown_side` | a `side` that is neither `credit` nor `debit`: the amount has no sign, and comes back `null` |
|
|
82
|
+
| `other_currency` | a transaction in another currency than its account: kept, and an importer refuses it |
|
|
83
|
+
| `duplicate_transaction` | the same id twice — two pages that overlap: the second is returned with status `INFO`, not booked and not counted in the balance, so it is imported once |
|
|
84
|
+
|
|
85
|
+
## What it does not do
|
|
86
|
+
|
|
87
|
+
- **It makes no request** and holds no key.
|
|
88
|
+
- **It reads no attachment.** The receipts attached to a transaction are
|
|
89
|
+
another answer of the API, and another brick's job.
|
|
90
|
+
- **It converts nothing**: the amount of an operation in another currency is
|
|
91
|
+
kept beside the line (`instructedAmount`), never used for the balance.
|
|
92
|
+
- **It moves no date to another time zone**: `settled_at` is read as written.
|
|
93
|
+
Qonto writes it in UTC, so the booking day is the UTC day — open point for
|
|
94
|
+
the caller: a transaction settled on 31 December at 23:30 UTC is booked on
|
|
95
|
+
31 December, though it is already 1 January in Paris.
|
|
96
|
+
|
|
97
|
+
## Not verified
|
|
98
|
+
|
|
99
|
+
The answers in the tests are invented, shaped on Qonto's documentation.
|
|
100
|
+
|
|
101
|
+
**Read in Qonto's sandbox** (30/11/2026, one account, three settled incoming
|
|
102
|
+
transfers, fetched over two pages): the reader returns three booked lines and
|
|
103
|
+
no violation; an opening balance of `0.00` plus the lines is the account's
|
|
104
|
+
`balance`, and a wrong opening comes back as `balance_mismatch`; every settled
|
|
105
|
+
transaction carries `settled_at`; `GET /v2/transactions` answers the same
|
|
106
|
+
transactions by `iban` and by `bank_account_id`; an incoming transfer carries
|
|
107
|
+
its counterparty under `income`.
|
|
108
|
+
|
|
109
|
+
**Still not verified**: that `balance` leaves out a transaction that is not
|
|
110
|
+
settled yet — the sandbox account had none, so the sum is the same either way
|
|
111
|
+
(the account also carries an `authorized_balance`, which the reader does not
|
|
112
|
+
use); the counterparty fields of an outgoing transfer (`transfer`), of a card
|
|
113
|
+
payment and of a direct debit; and an account with months of history.
|
|
114
|
+
|
|
115
|
+
## Licence
|
|
116
|
+
|
|
117
|
+
MIT. See [`LICENSE`](./LICENSE).
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Amounts as the API wrote them, added without a float.
|
|
3
|
+
*
|
|
4
|
+
* JSON writes an amount as a number, and JavaScript reads it into a float; the
|
|
5
|
+
* float prints back as the shortest text that reads into the same float,
|
|
6
|
+
* which is the text JSON wrote for every amount a bank books. That text is
|
|
7
|
+
* what is kept. An amount is then held as a `bigint` of millionths: exact, and
|
|
8
|
+
* enough for any currency. Nothing here knows how many decimals a currency has.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* An amount as millionths, or null when it is not one: a finite number, or a
|
|
12
|
+
* string of digits with a full stop at most once and a leading sign. No
|
|
13
|
+
* exponent — `1e-7` is refused rather than read one way or another.
|
|
14
|
+
*/
|
|
15
|
+
export declare function parseAmount(value: unknown): bigint | null;
|
|
16
|
+
/** Millionths as a decimal string: signed, two decimals, more when they are written. */
|
|
17
|
+
export declare function formatAmount(value: bigint): string;
|
|
18
|
+
//# sourceMappingURL=decimal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decimal.d.ts","sourceRoot":"","sources":["../src/decimal.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAgBzD;AAED,wFAAwF;AACxF,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAMlD"}
|
package/dist/decimal.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Amounts as the API wrote them, added without a float.
|
|
3
|
+
*
|
|
4
|
+
* JSON writes an amount as a number, and JavaScript reads it into a float; the
|
|
5
|
+
* float prints back as the shortest text that reads into the same float,
|
|
6
|
+
* which is the text JSON wrote for every amount a bank books. That text is
|
|
7
|
+
* what is kept. An amount is then held as a `bigint` of millionths: exact, and
|
|
8
|
+
* enough for any currency. Nothing here knows how many decimals a currency has.
|
|
9
|
+
*/
|
|
10
|
+
const SCALE = 6;
|
|
11
|
+
const UNIT = 10n ** BigInt(SCALE);
|
|
12
|
+
/**
|
|
13
|
+
* An amount as millionths, or null when it is not one: a finite number, or a
|
|
14
|
+
* string of digits with a full stop at most once and a leading sign. No
|
|
15
|
+
* exponent — `1e-7` is refused rather than read one way or another.
|
|
16
|
+
*/
|
|
17
|
+
export function parseAmount(value) {
|
|
18
|
+
let text;
|
|
19
|
+
if (typeof value === 'number') {
|
|
20
|
+
if (!Number.isFinite(value))
|
|
21
|
+
return null;
|
|
22
|
+
text = String(value);
|
|
23
|
+
}
|
|
24
|
+
else if (typeof value === 'string') {
|
|
25
|
+
text = value.trim();
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
const match = /^([+-]?)([0-9]+)(?:\.([0-9]+))?$/.exec(text);
|
|
31
|
+
if (match === null)
|
|
32
|
+
return null;
|
|
33
|
+
const fraction = match[3] ?? '';
|
|
34
|
+
if (fraction.replace(/0+$/, '').length > SCALE)
|
|
35
|
+
return null;
|
|
36
|
+
const units = BigInt(match[2]) * UNIT + BigInt(fraction.padEnd(SCALE, '0').slice(0, SCALE) || '0');
|
|
37
|
+
return match[1] === '-' ? -units : units;
|
|
38
|
+
}
|
|
39
|
+
/** Millionths as a decimal string: signed, two decimals, more when they are written. */
|
|
40
|
+
export function formatAmount(value) {
|
|
41
|
+
const negative = value < 0n;
|
|
42
|
+
const digits = (negative ? -value : value).toString().padStart(SCALE + 1, '0');
|
|
43
|
+
const whole = digits.slice(0, -SCALE);
|
|
44
|
+
const fraction = digits.slice(-SCALE).replace(/0+$/, '').padEnd(2, '0');
|
|
45
|
+
return `${negative ? '-' : ''}${whole}.${fraction}`;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=decimal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decimal.js","sourceRoot":"","sources":["../src/decimal.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,MAAM,KAAK,GAAG,CAAC,CAAC;AAChB,MAAM,IAAI,GAAG,GAAG,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC;AAElC;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,KAAc;IACxC,IAAI,IAAY,CAAC;IACjB,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;YAAE,OAAO,IAAI,CAAC;QACzC,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;SAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACrC,IAAI,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IACtB,CAAC;SAAM,CAAC;QACN,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,KAAK,GAAG,kCAAkC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5D,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAChC,MAAM,QAAQ,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI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comes back in `violations`; the first is
|
|
4
|
+
* thrown, because an answer without an account has no statement to hang a
|
|
5
|
+
* violation on.
|
|
6
|
+
*/
|
|
7
|
+
export type StatementFileErrorCode =
|
|
8
|
+
/** Not the account and the transactions of the API: no account, no IBAN, no currency, transactions that are not a list. */
|
|
9
|
+
'not_a_response'
|
|
10
|
+
/** More transactions than `maxTransactions`. Refused before one is read. */
|
|
11
|
+
| 'too_large'
|
|
12
|
+
/** An option that cannot be what it says: an opening balance that is not a decimal, a day that is not a day. */
|
|
13
|
+
| 'invalid_option';
|
|
14
|
+
export declare class StatementFileError extends Error {
|
|
15
|
+
readonly code: StatementFileErrorCode;
|
|
16
|
+
constructor(code: StatementFileErrorCode, message: string);
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,MAAM,sBAAsB;AAChC,2HAA2H;AACzH,gBAAgB;AAClB,4EAA4E;GAC1E,WAAW;AACb,gHAAgH;GAC9G,gBAAgB,CAAC;AAErB,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,QAAQ,CAAC,IAAI,EAAE,sBAAsB,CAAC;gBAE1B,IAAI,EAAE,sBAAsB,EAAE,OAAO,EAAE,MAAM;CAK1D"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAcA,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAClC,IAAI,CAAyB;IAEtC,YAAY,IAA4B,EAAE,OAAe;QACvD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;QACjC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { QontoResponse, ReadOptions, StatementFile } from './types.js';
|
|
2
|
+
export { StatementFileError, type StatementFileErrorCode } from './errors.js';
|
|
3
|
+
export type * from './types.js';
|
|
4
|
+
/** The word this reader returns as `format`, and the importer keeps as the statement's source. */
|
|
5
|
+
export declare const FORMAT = "qonto-transactions";
|
|
6
|
+
/** ISO 13616: move four characters to the end, letters to numbers, mod 97 is 1. */
|
|
7
|
+
export declare function isValidIban(iban: string): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Read what Qonto answered for one bank account — the account and its
|
|
10
|
+
* transactions — into one statement, its lines, and what does not add up.
|
|
11
|
+
*
|
|
12
|
+
* The statement closes at the account's balance, on the day the caller read
|
|
13
|
+
* it. It opens at the balance the caller declares — the closing balance of
|
|
14
|
+
* the statement before it — and is then checked against the settled lines: a
|
|
15
|
+
* transaction the answer lacks shows as a difference, reported and never
|
|
16
|
+
* corrected. A pending or declined transaction is returned, not booked: it
|
|
17
|
+
* has not moved the balance.
|
|
18
|
+
*
|
|
19
|
+
* Throws a `StatementFileError` for what is not an answer at all: no account,
|
|
20
|
+
* an account without an IBAN or a currency, transactions that are not a list.
|
|
21
|
+
* Everything else comes back, with the trouble named in `violations`.
|
|
22
|
+
*/
|
|
23
|
+
export declare function readQontoTransactions(response: QontoResponse, options?: ReadOptions): StatementFile;
|
|
24
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAGV,aAAa,EAEb,WAAW,EAGX,aAAa,EAId,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,kBAAkB,EAAE,KAAK,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAC9E,mBAAmB,YAAY,CAAC;AAEhC,kGAAkG;AAClG,eAAO,MAAM,MAAM,uBAAuB,CAAC;AAoB3C,mFAAmF;AACnF,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAGjD;AAoCD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,aAAa,EAAE,OAAO,GAAE,WAAgB,GAAG,aAAa,CAgNvG"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import { formatAmount, parseAmount } from './decimal.js';
|
|
2
|
+
import { StatementFileError } from './errors.js';
|
|
3
|
+
export { StatementFileError } from './errors.js';
|
|
4
|
+
/** The word this reader returns as `format`, and the importer keeps as the statement's source. */
|
|
5
|
+
export const FORMAT = 'qonto-transactions';
|
|
6
|
+
const DEFAULTS = { maxTransactions: 100_000 };
|
|
7
|
+
/** What a status of the API is, in the words of a statement: only a settled transaction is booked. */
|
|
8
|
+
const STATUSES = { completed: 'BOOK', pending: 'PDNG', declined: 'RJCT' };
|
|
9
|
+
// --- small readers -------------------------------------------------------------
|
|
10
|
+
/** ISO 7064 MOD 97-10 over a string of digits and letters (A = 10 … Z = 35). */
|
|
11
|
+
function mod97(text) {
|
|
12
|
+
let remainder = 0;
|
|
13
|
+
for (const character of text) {
|
|
14
|
+
const code = character.charCodeAt(0);
|
|
15
|
+
const value = code >= 65 ? code - 55 : code - 48;
|
|
16
|
+
remainder = (value > 9 ? remainder * 100 + value : remainder * 10 + value) % 97;
|
|
17
|
+
}
|
|
18
|
+
return remainder;
|
|
19
|
+
}
|
|
20
|
+
/** ISO 13616: move four characters to the end, letters to numbers, mod 97 is 1. */
|
|
21
|
+
export function isValidIban(iban) {
|
|
22
|
+
if (!/^[A-Z]{2}[0-9]{2}[A-Z0-9]{1,30}$/.test(iban))
|
|
23
|
+
return false;
|
|
24
|
+
return mod97(iban.slice(4) + iban.slice(0, 4)) === 1;
|
|
25
|
+
}
|
|
26
|
+
/** An account as written: an IBAN when it passes ISO 13616, else what was written. */
|
|
27
|
+
function identifierOf(text, issuer = null) {
|
|
28
|
+
if (typeof text !== 'string')
|
|
29
|
+
return null;
|
|
30
|
+
const compact = text.replace(/\s+/g, '');
|
|
31
|
+
if (compact === '')
|
|
32
|
+
return null;
|
|
33
|
+
if (isValidIban(compact.toUpperCase()))
|
|
34
|
+
return { kind: 'iban', value: compact.toUpperCase() };
|
|
35
|
+
return { kind: 'other', value: compact, scheme: null, issuer };
|
|
36
|
+
}
|
|
37
|
+
/** The day an ISO 8601 moment or date names, as written — never moved to another time zone. */
|
|
38
|
+
function dayOf(value) {
|
|
39
|
+
if (value === null || value === undefined || value === '')
|
|
40
|
+
return null;
|
|
41
|
+
if (typeof value !== 'string')
|
|
42
|
+
return undefined;
|
|
43
|
+
const match = /^([0-9]{4})-([0-9]{2})-([0-9]{2})(?:$|T)/.exec(value.trim());
|
|
44
|
+
if (match === null)
|
|
45
|
+
return undefined;
|
|
46
|
+
const [year, month, day] = [Number(match[1]), Number(match[2]), Number(match[3])];
|
|
47
|
+
const leap = (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
|
|
48
|
+
const length = [31, leap ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month - 1];
|
|
49
|
+
if (length === undefined || day < 1 || day > length)
|
|
50
|
+
return undefined;
|
|
51
|
+
return `${match[1]}-${match[2]}-${match[3]}`;
|
|
52
|
+
}
|
|
53
|
+
function text(value) {
|
|
54
|
+
if (typeof value !== 'string')
|
|
55
|
+
return null;
|
|
56
|
+
const trimmed = value.trim();
|
|
57
|
+
return trimmed === '' ? null : trimmed;
|
|
58
|
+
}
|
|
59
|
+
function isObject(value) {
|
|
60
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
61
|
+
}
|
|
62
|
+
// --- the reader ------------------------------------------------------------------
|
|
63
|
+
/**
|
|
64
|
+
* Read what Qonto answered for one bank account — the account and its
|
|
65
|
+
* transactions — into one statement, its lines, and what does not add up.
|
|
66
|
+
*
|
|
67
|
+
* The statement closes at the account's balance, on the day the caller read
|
|
68
|
+
* it. It opens at the balance the caller declares — the closing balance of
|
|
69
|
+
* the statement before it — and is then checked against the settled lines: a
|
|
70
|
+
* transaction the answer lacks shows as a difference, reported and never
|
|
71
|
+
* corrected. A pending or declined transaction is returned, not booked: it
|
|
72
|
+
* has not moved the balance.
|
|
73
|
+
*
|
|
74
|
+
* Throws a `StatementFileError` for what is not an answer at all: no account,
|
|
75
|
+
* an account without an IBAN or a currency, transactions that are not a list.
|
|
76
|
+
* Everything else comes back, with the trouble named in `violations`.
|
|
77
|
+
*/
|
|
78
|
+
export function readQontoTransactions(response, options = {}) {
|
|
79
|
+
const refuse = (message) => {
|
|
80
|
+
throw new StatementFileError('not_a_response', message);
|
|
81
|
+
};
|
|
82
|
+
if (!isObject(response))
|
|
83
|
+
refuse('no answer: expected { account, transactions } as the API returned them');
|
|
84
|
+
const account = response.account;
|
|
85
|
+
if (!isObject(account))
|
|
86
|
+
refuse('no account: expected one bank account of the organisation');
|
|
87
|
+
const transactions = response.transactions;
|
|
88
|
+
if (!Array.isArray(transactions))
|
|
89
|
+
refuse('transactions: expected the list of transactions, every page\'s together');
|
|
90
|
+
const list = transactions;
|
|
91
|
+
const most = options.maxTransactions ?? DEFAULTS.maxTransactions;
|
|
92
|
+
if (list.length > most) {
|
|
93
|
+
throw new StatementFileError('too_large', `${list.length} transactions, and at most ${most} are read at once`);
|
|
94
|
+
}
|
|
95
|
+
const identifier = identifierOf(account.iban);
|
|
96
|
+
if (identifier === null)
|
|
97
|
+
refuse('the account has no IBAN: nothing names the account the lines are of');
|
|
98
|
+
const currency = text(account.currency)?.toUpperCase() ?? null;
|
|
99
|
+
if (currency === null)
|
|
100
|
+
refuse('the account has no currency');
|
|
101
|
+
const closing = parseAmount(account.balance);
|
|
102
|
+
if (closing === null)
|
|
103
|
+
refuse(`the account's balance ${JSON.stringify(account.balance)} is not an amount`);
|
|
104
|
+
const givenDay = options.balanceDate === undefined ? null : dayOf(options.balanceDate);
|
|
105
|
+
if (options.balanceDate !== undefined && (givenDay === undefined || givenDay === null)) {
|
|
106
|
+
throw new StatementFileError('invalid_option', `balanceDate "${options.balanceDate}": a day, as 2026-11-30`);
|
|
107
|
+
}
|
|
108
|
+
let declared = null;
|
|
109
|
+
if (options.openingBalance === 'implied')
|
|
110
|
+
declared = 'implied';
|
|
111
|
+
else if (options.openingBalance !== undefined) {
|
|
112
|
+
declared = typeof options.openingBalance === 'string' ? parseAmount(options.openingBalance) : null;
|
|
113
|
+
if (declared === null) {
|
|
114
|
+
throw new StatementFileError('invalid_option', `openingBalance ${JSON.stringify(options.openingBalance)}: a decimal string, as 1250.00 or -40.10, or "implied"`);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
const violations = [];
|
|
118
|
+
const report = (code, message, where = {}) => {
|
|
119
|
+
violations.push({ code, message, statement: 1, ...where });
|
|
120
|
+
};
|
|
121
|
+
const instantOf = (value) => {
|
|
122
|
+
if (typeof dayOf(value) !== 'string')
|
|
123
|
+
return null;
|
|
124
|
+
const instant = Date.parse(value);
|
|
125
|
+
return Number.isNaN(instant) ? null : instant;
|
|
126
|
+
};
|
|
127
|
+
const read = list.map((item, at) => {
|
|
128
|
+
const tx = (isObject(item) ? item : {});
|
|
129
|
+
return { at, id: text(tx.id), settledAt: tx.status === 'completed' ? instantOf(tx.settled_at) : null, tx };
|
|
130
|
+
});
|
|
131
|
+
read.sort((a, b) => {
|
|
132
|
+
if (a.settledAt !== b.settledAt) {
|
|
133
|
+
if (a.settledAt === null)
|
|
134
|
+
return 1;
|
|
135
|
+
if (b.settledAt === null)
|
|
136
|
+
return -1;
|
|
137
|
+
return a.settledAt - b.settledAt;
|
|
138
|
+
}
|
|
139
|
+
if (a.settledAt !== null && a.id !== b.id) {
|
|
140
|
+
if (a.id === null)
|
|
141
|
+
return 1;
|
|
142
|
+
if (b.id === null)
|
|
143
|
+
return -1;
|
|
144
|
+
return a.id < b.id ? -1 : 1;
|
|
145
|
+
}
|
|
146
|
+
return a.at - b.at;
|
|
147
|
+
});
|
|
148
|
+
const seen = new Set();
|
|
149
|
+
const lines = [];
|
|
150
|
+
let total = 0n;
|
|
151
|
+
let unreadable = false;
|
|
152
|
+
for (const item of read) {
|
|
153
|
+
const { tx } = item;
|
|
154
|
+
const index = lines.length + 1;
|
|
155
|
+
const name = item.id ?? `#${index}`;
|
|
156
|
+
const where = { line: index, ...(item.id === null ? {} : { transaction: item.id }) };
|
|
157
|
+
// The same id is the same movement: listed again, it is returned and
|
|
158
|
+
// said, and neither booked nor counted a second time.
|
|
159
|
+
const repeated = item.id !== null && seen.has(item.id);
|
|
160
|
+
if (repeated)
|
|
161
|
+
report('duplicate_transaction', `transaction ${item.id} is listed twice: two pages that overlap; the second is returned, not booked`, where);
|
|
162
|
+
if (item.id !== null)
|
|
163
|
+
seen.add(item.id);
|
|
164
|
+
const said = String(tx.status);
|
|
165
|
+
const status = repeated ? 'INFO' : Object.hasOwn(STATUSES, said) ? STATUSES[said] : 'PDNG';
|
|
166
|
+
const booked = status === 'BOOK';
|
|
167
|
+
const magnitude = parseAmount(tx.amount);
|
|
168
|
+
let amount = null;
|
|
169
|
+
if (magnitude === null) {
|
|
170
|
+
report('invalid_amount', `transaction ${name}: the amount ${JSON.stringify(tx.amount)} is not an amount`, where);
|
|
171
|
+
}
|
|
172
|
+
else if (tx.side === 'credit' || tx.side === 'debit') {
|
|
173
|
+
const absolute = magnitude < 0n ? -magnitude : magnitude;
|
|
174
|
+
amount = tx.side === 'debit' ? -absolute : absolute;
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
report('unknown_side', `transaction ${name}: side ${JSON.stringify(tx.side)} is neither credit nor debit, so its amount has no sign`, where);
|
|
178
|
+
}
|
|
179
|
+
if (booked) {
|
|
180
|
+
if (amount === null)
|
|
181
|
+
unreadable = true;
|
|
182
|
+
else
|
|
183
|
+
total += amount;
|
|
184
|
+
}
|
|
185
|
+
const bookingDate = booked ? dayOf(tx.settled_at) : null;
|
|
186
|
+
if (booked && (bookingDate === undefined || bookingDate === null)) {
|
|
187
|
+
report('invalid_date', `transaction ${name}: settled, and its settled_at ${JSON.stringify(tx.settled_at)} is not a moment`, where);
|
|
188
|
+
}
|
|
189
|
+
const emittedOn = dayOf(tx.emitted_at);
|
|
190
|
+
if (emittedOn === undefined)
|
|
191
|
+
report('invalid_date', `transaction ${name}: the emitted_at ${JSON.stringify(tx.emitted_at)} is not a moment`, where);
|
|
192
|
+
const lineCurrency = text(tx.currency)?.toUpperCase() ?? currency;
|
|
193
|
+
if (lineCurrency !== currency)
|
|
194
|
+
report('other_currency', `transaction ${name} is in ${lineCurrency}, and the account in ${currency}`, where);
|
|
195
|
+
const localCurrency = text(tx.local_currency)?.toUpperCase() ?? null;
|
|
196
|
+
const local = localCurrency !== null && localCurrency !== lineCurrency ? parseAmount(tx.local_amount) : null;
|
|
197
|
+
const other = isObject(tx.transfer) ? tx.transfer : isObject(tx.income) ? tx.income : null;
|
|
198
|
+
const counterpartAccount = other === null ? null : identifierOf(other['counterparty_account_number'], text(other['counterparty_bank_identifier']));
|
|
199
|
+
const label = text(tx.label);
|
|
200
|
+
const reference = text(tx.reference);
|
|
201
|
+
const operation = text(tx.operation_type);
|
|
202
|
+
lines.push({
|
|
203
|
+
index,
|
|
204
|
+
entry: index,
|
|
205
|
+
detail: null,
|
|
206
|
+
detailCount: null,
|
|
207
|
+
status,
|
|
208
|
+
booked,
|
|
209
|
+
reversal: false,
|
|
210
|
+
bookingDate: bookingDate ?? null,
|
|
211
|
+
valueDate: null,
|
|
212
|
+
amount: amount === null ? null : formatAmount(amount),
|
|
213
|
+
currency: lineCurrency,
|
|
214
|
+
entryAmount: null,
|
|
215
|
+
bankReference: item.id,
|
|
216
|
+
entryReference: text(tx.transaction_id),
|
|
217
|
+
endToEndId: null,
|
|
218
|
+
transactionId: null,
|
|
219
|
+
instructionId: null,
|
|
220
|
+
paymentInformationId: null,
|
|
221
|
+
mandateId: null,
|
|
222
|
+
counterparty: label === null && counterpartAccount === null ? null : { name: label, account: counterpartAccount, agentBic: null, ultimateName: null },
|
|
223
|
+
remittance: { unstructured: reference === null ? [] : [reference], structured: [] },
|
|
224
|
+
bankTransactionCode: operation === null ? null : { domain: null, family: null, subFamily: null, proprietary: operation, proprietaryIssuer: null },
|
|
225
|
+
returnReason: null,
|
|
226
|
+
instructedAmount: local === null || localCurrency === null ? null : { amount: formatAmount(local < 0n ? -local : local), currency: localCurrency },
|
|
227
|
+
exchangeRate: null,
|
|
228
|
+
additionalInformation: null,
|
|
229
|
+
emittedOn: emittedOn ?? null,
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
// 2. The balances: the closing one the account gives; the opening one the
|
|
233
|
+
// caller declares, checked, or works out on its request, said.
|
|
234
|
+
// The period runs from the earliest to the latest of the settled days and
|
|
235
|
+
// the balance day: a line settled after the balance day widens it, and
|
|
236
|
+
// the closing balance keeps its own day.
|
|
237
|
+
const days = lines.filter((line) => line.booked).map((line) => line.bookingDate).filter((day) => day !== null);
|
|
238
|
+
const closedOn = givenDay ?? days[days.length - 1] ?? null;
|
|
239
|
+
const span = [...days, ...(closedOn === null ? [] : [closedOn])].sort();
|
|
240
|
+
const from = span[0] ?? null;
|
|
241
|
+
const to = span[span.length - 1] ?? null;
|
|
242
|
+
let opening = null;
|
|
243
|
+
let balanced = null;
|
|
244
|
+
if (declared === 'implied') {
|
|
245
|
+
if (!unreadable)
|
|
246
|
+
opening = closing - total;
|
|
247
|
+
}
|
|
248
|
+
else if (declared !== null) {
|
|
249
|
+
opening = declared;
|
|
250
|
+
if (!unreadable) {
|
|
251
|
+
balanced = opening + total === closing;
|
|
252
|
+
if (!balanced) {
|
|
253
|
+
report('balance_mismatch', `opening balance ${formatAmount(opening)} plus the settled transactions ${formatAmount(total)} is ${formatAmount(opening + total)}, and the account's balance is ${formatAmount(closing)}: a difference of ${formatAmount(closing - (opening + total))} ${currency}`);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
const balanceOf = (type, amount) => amount === null ? null : { type, amount: formatAmount(amount), currency, date: type === 'CLBD' ? closedOn : null };
|
|
258
|
+
const openingBalance = balanceOf('OPBD', opening);
|
|
259
|
+
const closingBalance = balanceOf('CLBD', closing);
|
|
260
|
+
const newest = [...lines].reverse().find((line) => line.booked && line.bankReference !== null)?.bankReference ?? '-';
|
|
261
|
+
const statement = {
|
|
262
|
+
id: `${closedOn ?? '…'}/${newest}`,
|
|
263
|
+
electronicSequenceNumber: null,
|
|
264
|
+
legalSequenceNumber: null,
|
|
265
|
+
createdAt: null,
|
|
266
|
+
period: { from, to },
|
|
267
|
+
page: null,
|
|
268
|
+
account: {
|
|
269
|
+
identifier: identifier,
|
|
270
|
+
currency,
|
|
271
|
+
name: text(account.name),
|
|
272
|
+
ownerName: null,
|
|
273
|
+
servicerBic: text(account.bic),
|
|
274
|
+
},
|
|
275
|
+
openingBalance,
|
|
276
|
+
closingBalance,
|
|
277
|
+
balances: [openingBalance, closingBalance].filter((item) => item !== null),
|
|
278
|
+
lines,
|
|
279
|
+
balanced,
|
|
280
|
+
openingImplied: declared === 'implied' && opening !== null,
|
|
281
|
+
};
|
|
282
|
+
return { format: FORMAT, version: null, namespace: FORMAT, statements: [statement], violations };
|
|
283
|
+
}
|
|
284
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAejD,OAAO,EAAE,kBAAkB,EAA+B,MAAM,aAAa,CAAC;AAG9E,kGAAkG;AAClG,MAAM,CAAC,MAAM,MAAM,GAAG,oBAAoB,CAAC;AAE3C,MAAM,QAAQ,GAAG,EAAE,eAAe,EAAE,OAAO,EAAE,CAAC;AAE9C,sGAAsG;AACtG,MAAM,QAAQ,GAA2B,EAAE,SAAS,EAAE,M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V,OAAO,EAAE;YACP,UAAU,EAAE,UAA+B;YAC3C,QAAQ;YACR,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;YACxB,SAAS,EAAE,IAAI;YACf,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC;SAC/B;QACD,cAAc;QACd,cAAc;QACd,QAAQ,EAAE,CAAC,cAAc,EAAE,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAA4B,EAAE,CAAC,IAAI,KAAK,IAAI,CAAC;QACpG,KAAK;QACL,QAAQ;QACR,cAAc,EAAE,QAAQ,KAAK,SAAS,IAAI,OAAO,KAAK,IAAI;KAC3D,CAAC;IACF,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,SAAS,CAAC,EAAE,UAAU,EAAE,CAAC;AACnG,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Qonto is a bank whose API a company reaches with its own key: the
|
|
3
|
+
* organisation's login and secret key, read only. It answers, in JSON, the
|
|
4
|
+
* company's bank accounts (each with its IBAN, its currency and its balance)
|
|
5
|
+
* and the transactions of one account. This reader takes what the API
|
|
6
|
+
* answered — one bank account and its transactions, as the caller fetched
|
|
7
|
+
* them — and returns a statement as the other readers return one: an
|
|
8
|
+
* account, two balances and lines.
|
|
9
|
+
*
|
|
10
|
+
* It is, field for field, the shape `@ekwo-ai/camt053` declares for itself, so
|
|
11
|
+
* whatever takes one takes the other; what only Qonto says comes after, under
|
|
12
|
+
* names of its own.
|
|
13
|
+
*
|
|
14
|
+
* Every amount is a **decimal string**, signed from the account holder's side:
|
|
15
|
+
* money in is positive, money out is negative. The API writes an amount as a
|
|
16
|
+
* JSON number without its sign and says the direction in `side`; each is
|
|
17
|
+
* turned into the digits JSON wrote and signed by its side, never added as a
|
|
18
|
+
* float.
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* A bank account, as `GET /v2/organization` lists them under
|
|
22
|
+
* `organization.bank_accounts`. Only the fields read here are named.
|
|
23
|
+
*/
|
|
24
|
+
export interface QontoBankAccount {
|
|
25
|
+
id?: string;
|
|
26
|
+
slug?: string;
|
|
27
|
+
iban: string;
|
|
28
|
+
bic?: string | null;
|
|
29
|
+
/** ISO 4217. */
|
|
30
|
+
currency: string;
|
|
31
|
+
/** The balance of what is settled on the account. */
|
|
32
|
+
balance: number | string;
|
|
33
|
+
name?: string | null;
|
|
34
|
+
updated_at?: string | null;
|
|
35
|
+
[other: string]: unknown;
|
|
36
|
+
}
|
|
37
|
+
/** A transaction, as `GET /v2/transactions` lists them under `transactions`. */
|
|
38
|
+
export interface QontoTransaction {
|
|
39
|
+
/** Qonto's id of the transaction, stable. */
|
|
40
|
+
id: string;
|
|
41
|
+
/** The reference Qonto shows a person, as `acme-1-transaction-123`. */
|
|
42
|
+
transaction_id?: string | null;
|
|
43
|
+
/** Without a sign: `side` says the direction. */
|
|
44
|
+
amount: number | string;
|
|
45
|
+
/** `credit` (money in) or `debit` (money out). */
|
|
46
|
+
side: string;
|
|
47
|
+
currency: string;
|
|
48
|
+
/** The amount in the currency of the operation, when it is another. */
|
|
49
|
+
local_amount?: number | string | null;
|
|
50
|
+
local_currency?: string | null;
|
|
51
|
+
/** The other party, as Qonto names it. */
|
|
52
|
+
label?: string | null;
|
|
53
|
+
/** The text of a transfer. */
|
|
54
|
+
reference?: string | null;
|
|
55
|
+
operation_type?: string | null;
|
|
56
|
+
/** `completed`, `pending` or `declined`. */
|
|
57
|
+
status: string;
|
|
58
|
+
/** When it moved the balance, ISO 8601. */
|
|
59
|
+
settled_at?: string | null;
|
|
60
|
+
/** When it was started, ISO 8601. */
|
|
61
|
+
emitted_at?: string | null;
|
|
62
|
+
transfer?: {
|
|
63
|
+
counterparty_account_number?: string | null;
|
|
64
|
+
counterparty_bank_identifier?: string | null;
|
|
65
|
+
} | null;
|
|
66
|
+
income?: {
|
|
67
|
+
counterparty_account_number?: string | null;
|
|
68
|
+
counterparty_bank_identifier?: string | null;
|
|
69
|
+
} | null;
|
|
70
|
+
[other: string]: unknown;
|
|
71
|
+
}
|
|
72
|
+
/** What is read: one bank account, and its transactions — every page's `transactions`, in any order. */
|
|
73
|
+
export interface QontoResponse {
|
|
74
|
+
account: QontoBankAccount;
|
|
75
|
+
transactions: QontoTransaction[];
|
|
76
|
+
}
|
|
77
|
+
/** What the caller knows and the API does not say. */
|
|
78
|
+
export interface ReadOptions {
|
|
79
|
+
/**
|
|
80
|
+
* The balance the statement opens at, as a decimal string: the closing
|
|
81
|
+
* balance of the statement before it, which the caller keeps and the API
|
|
82
|
+
* does not give. The statement is then checked against it: the opening
|
|
83
|
+
* plus the settled lines is the account's balance, or `balance_mismatch` is
|
|
84
|
+
* reported.
|
|
85
|
+
*
|
|
86
|
+
* `implied` asks for the opening the balance and the lines imply, for a
|
|
87
|
+
* first statement that has nothing before it. It is said on the statement
|
|
88
|
+
* (`openingImplied`), and nothing is checked: a balance worked out from the
|
|
89
|
+
* lines cannot prove the lines are all there.
|
|
90
|
+
*
|
|
91
|
+
* Left out, the statement has no opening balance.
|
|
92
|
+
*/
|
|
93
|
+
openingBalance?: string | 'implied';
|
|
94
|
+
/** The day the balance is of, `YYYY-MM-DD`: the day the caller read it. Left out, the day of the newest settled line. */
|
|
95
|
+
balanceDate?: string;
|
|
96
|
+
/** Refuse more transactions than this, unread. Default 100 000. */
|
|
97
|
+
maxTransactions?: number;
|
|
98
|
+
}
|
|
99
|
+
export type AccountIdentifier = {
|
|
100
|
+
kind: 'iban';
|
|
101
|
+
value: string;
|
|
102
|
+
} | {
|
|
103
|
+
kind: 'other';
|
|
104
|
+
value: string;
|
|
105
|
+
scheme: string | null;
|
|
106
|
+
issuer: string | null;
|
|
107
|
+
};
|
|
108
|
+
export interface StatementAccount {
|
|
109
|
+
identifier: AccountIdentifier;
|
|
110
|
+
currency: string | null;
|
|
111
|
+
/** The account's `name`. */
|
|
112
|
+
name: string | null;
|
|
113
|
+
/** Always null: the account names no holder. */
|
|
114
|
+
ownerName: string | null;
|
|
115
|
+
servicerBic: string | null;
|
|
116
|
+
}
|
|
117
|
+
export interface StatementBalance {
|
|
118
|
+
/** `OPBD` for the opening balance, `CLBD` for the closing one. */
|
|
119
|
+
type: string;
|
|
120
|
+
amount: string;
|
|
121
|
+
currency: string | null;
|
|
122
|
+
/** `YYYY-MM-DD`; null for an opening balance, which the API dates nowhere. */
|
|
123
|
+
date: string | null;
|
|
124
|
+
}
|
|
125
|
+
export interface StructuredReference {
|
|
126
|
+
reference: string;
|
|
127
|
+
type: string | null;
|
|
128
|
+
issuer: string | null;
|
|
129
|
+
}
|
|
130
|
+
export interface Remittance {
|
|
131
|
+
unstructured: string[];
|
|
132
|
+
structured: StructuredReference[];
|
|
133
|
+
}
|
|
134
|
+
export interface Counterparty {
|
|
135
|
+
name: string | null;
|
|
136
|
+
account: AccountIdentifier | null;
|
|
137
|
+
agentBic: string | null;
|
|
138
|
+
ultimateName: string | null;
|
|
139
|
+
}
|
|
140
|
+
export interface BankTransactionCode {
|
|
141
|
+
domain: string | null;
|
|
142
|
+
family: string | null;
|
|
143
|
+
subFamily: string | null;
|
|
144
|
+
proprietary: string | null;
|
|
145
|
+
proprietaryIssuer: string | null;
|
|
146
|
+
}
|
|
147
|
+
export interface StatementLine {
|
|
148
|
+
/** Position among the statement's lines, from 1, oldest first. */
|
|
149
|
+
index: number;
|
|
150
|
+
entry: number;
|
|
151
|
+
detail: number | null;
|
|
152
|
+
detailCount: number | null;
|
|
153
|
+
/** `BOOK` for a settled transaction, `PDNG` for one pending, `RJCT` for one declined: only the first is booked. `INFO` for a transaction listed again, which is not booked either. */
|
|
154
|
+
status: string;
|
|
155
|
+
booked: boolean;
|
|
156
|
+
reversal: boolean;
|
|
157
|
+
bookingDate: string | null;
|
|
158
|
+
valueDate: string | null;
|
|
159
|
+
amount: string | null;
|
|
160
|
+
currency: string | null;
|
|
161
|
+
entryAmount: string | null;
|
|
162
|
+
/** The transaction's `id` at Qonto: stable, and what recognises it in a later answer. */
|
|
163
|
+
bankReference: string | null;
|
|
164
|
+
/** The reference Qonto shows a person, `transaction_id`. */
|
|
165
|
+
entryReference: string | null;
|
|
166
|
+
endToEndId: string | null;
|
|
167
|
+
transactionId: string | null;
|
|
168
|
+
instructionId: string | null;
|
|
169
|
+
paymentInformationId: string | null;
|
|
170
|
+
mandateId: string | null;
|
|
171
|
+
counterparty: Counterparty | null;
|
|
172
|
+
remittance: Remittance;
|
|
173
|
+
bankTransactionCode: BankTransactionCode | null;
|
|
174
|
+
returnReason: string | null;
|
|
175
|
+
instructedAmount: {
|
|
176
|
+
amount: string;
|
|
177
|
+
currency: string;
|
|
178
|
+
} | null;
|
|
179
|
+
exchangeRate: string | null;
|
|
180
|
+
additionalInformation: string | null;
|
|
181
|
+
/** The day the transaction was started, `emitted_at`, as written. */
|
|
182
|
+
emittedOn: string | null;
|
|
183
|
+
}
|
|
184
|
+
export interface Statement {
|
|
185
|
+
/**
|
|
186
|
+
* The API numbers no statement. This one is the day of the balance and the
|
|
187
|
+
* id of the newest settled transaction, `2026-11-30/9a1c…`: the same answer always
|
|
188
|
+
* makes the same one, and an answer with one transaction more another.
|
|
189
|
+
*/
|
|
190
|
+
id: string;
|
|
191
|
+
electronicSequenceNumber: string | null;
|
|
192
|
+
legalSequenceNumber: string | null;
|
|
193
|
+
createdAt: string | null;
|
|
194
|
+
/** From the oldest line to the day of the balance. */
|
|
195
|
+
/** From the earliest to the latest of the booked days and the balance day: it never ends before it starts. */
|
|
196
|
+
period: {
|
|
197
|
+
from: string | null;
|
|
198
|
+
to: string | null;
|
|
199
|
+
} | null;
|
|
200
|
+
page: {
|
|
201
|
+
number: string;
|
|
202
|
+
last: boolean;
|
|
203
|
+
} | null;
|
|
204
|
+
account: StatementAccount;
|
|
205
|
+
openingBalance: StatementBalance | null;
|
|
206
|
+
/** The account's balance, on the day it was read. */
|
|
207
|
+
closingBalance: StatementBalance | null;
|
|
208
|
+
balances: StatementBalance[];
|
|
209
|
+
lines: StatementLine[];
|
|
210
|
+
/**
|
|
211
|
+
* The declared opening plus the settled lines is the account's balance: true, false,
|
|
212
|
+
* or null when no opening was declared. False is reported as
|
|
213
|
+
* `balance_mismatch` and **never corrected**.
|
|
214
|
+
*/
|
|
215
|
+
balanced: boolean | null;
|
|
216
|
+
/** The opening balance was worked out from the closing one and the lines, as the caller asked (`openingBalance: 'implied'`). */
|
|
217
|
+
openingImplied: boolean;
|
|
218
|
+
}
|
|
219
|
+
export interface Violation {
|
|
220
|
+
code: ViolationCode;
|
|
221
|
+
message: string;
|
|
222
|
+
/** Always 1: an answer is one statement. */
|
|
223
|
+
statement: number;
|
|
224
|
+
line?: number;
|
|
225
|
+
/** The transaction's id, where there is one. */
|
|
226
|
+
transaction?: string;
|
|
227
|
+
}
|
|
228
|
+
export type ViolationCode = 'balance_mismatch' | 'invalid_amount' | 'invalid_date'
|
|
229
|
+
/** A transaction whose `side` is neither `credit` nor `debit`: its amount has no sign, and comes back null. */
|
|
230
|
+
| 'unknown_side'
|
|
231
|
+
/** A transaction in another currency than its account. Kept, and said: the importer refuses it. */
|
|
232
|
+
| 'other_currency'
|
|
233
|
+
/** The same transaction id twice: two pages that overlap. The second is returned with status `INFO`, not booked and not counted in the balance. */
|
|
234
|
+
| 'duplicate_transaction';
|
|
235
|
+
export interface StatementFile {
|
|
236
|
+
format: 'qonto-transactions';
|
|
237
|
+
version: string | null;
|
|
238
|
+
/** The same word as `format`: the key under which `@ekwo-ai/camt053` says what it read. */
|
|
239
|
+
namespace: string;
|
|
240
|
+
statements: Statement[];
|
|
241
|
+
violations: Violation[];
|
|
242
|
+
}
|
|
243
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;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AA;KAAE,GAAG,IAAI,CAAC;IAC1D,IAAI,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI,CAAC;IAC/C,OAAO,EAAE,gBAAgB,CAAC;IAC1B,cAAc,EAAE,gBAAgB,GAAG,IAAI,CAAC;IACxC,qDAAqD;IACrD,cAAc,EAAE,gBAAgB,GAAG,IAAI,CAAC;IACxC,QAAQ,EAAE,gBAAgB,EAAE,CAAC;IAC7B,KAAK,EAAE,aAAa,EAAE,CAAC;IACvB;;;;OAIG;IACH,QAAQ,EAAE,OAAO,GAAG,IAAI,CAAC;IAIzB,gIAAgI;IAChI,cAAc,EAAE,OAAO,CAAC;CACzB;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,aAAa,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,4CAA4C;IAC5C,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,gDAAgD;IAChD,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,MAAM,aAAa,GACrB,kBAAkB,GAClB,gBAAgB,GAChB,cAAc;AAChB,+GAA+G;GAC7G,cAAc;AAChB,mGAAmG;GACjG,gBAAgB;AAClB,mJAAmJ;GACjJ,uBAAuB,CAAC;AAE5B,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,oBAAoB,CAAC;IAC7B,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,2FAA2F;IAC3F,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,SAAS,EAAE,CAAC;IACxB,UAAU,EAAE,SAAS,EAAE,CAAC;CACzB"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Qonto is a bank whose API a company reaches with its own key: the
|
|
3
|
+
* organisation's login and secret key, read only. It answers, in JSON, the
|
|
4
|
+
* company's bank accounts (each with its IBAN, its currency and its balance)
|
|
5
|
+
* and the transactions of one account. This reader takes what the API
|
|
6
|
+
* answered — one bank account and its transactions, as the caller fetched
|
|
7
|
+
* them — and returns a statement as the other readers return one: an
|
|
8
|
+
* account, two balances and lines.
|
|
9
|
+
*
|
|
10
|
+
* It is, field for field, the shape `@ekwo-ai/camt053` declares for itself, so
|
|
11
|
+
* whatever takes one takes the other; what only Qonto says comes after, under
|
|
12
|
+
* names of its own.
|
|
13
|
+
*
|
|
14
|
+
* Every amount is a **decimal string**, signed from the account holder's side:
|
|
15
|
+
* money in is positive, money out is negative. The API writes an amount as a
|
|
16
|
+
* JSON number without its sign and says the direction in `side`; each is
|
|
17
|
+
* turned into the digits JSON wrote and signed by its side, never added as a
|
|
18
|
+
* float.
|
|
19
|
+
*/
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,51 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ekwo-ai/qonto-transactions",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.30.0",
|
|
4
|
+
"description": "Reads what the Qonto API answers for one bank account — the account and its transactions — into a bank statement in TypeScript: account, balances and lines, amounts as decimal strings signed by their side, checked against the opening balance the caller declares, and what does not add up. Zero dependencies.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"qonto",
|
|
7
|
+
"bank-statement",
|
|
8
|
+
"business-account",
|
|
9
|
+
"reconciliation",
|
|
10
|
+
"parser"
|
|
11
|
+
],
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"author": "Ekwo AI",
|
|
14
|
+
"homepage": "https://github.com/Ekwo-ai/ekwo-os/tree/main/packages/formats/qonto-transactions#readme",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/Ekwo-ai/ekwo-os.git",
|
|
18
|
+
"directory": "packages/formats/qonto-transactions"
|
|
19
|
+
},
|
|
20
|
+
"bugs": {
|
|
21
|
+
"url": "https://github.com/Ekwo-ai/ekwo-os/issues"
|
|
22
|
+
},
|
|
23
|
+
"type": "module",
|
|
24
|
+
"sideEffects": false,
|
|
25
|
+
"engines": {
|
|
26
|
+
"node": ">=18"
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"dist",
|
|
30
|
+
"README.md",
|
|
31
|
+
"LICENSE"
|
|
32
|
+
],
|
|
33
|
+
"main": "./dist/index.js",
|
|
34
|
+
"types": "./dist/index.d.ts",
|
|
35
|
+
"exports": {
|
|
36
|
+
".": {
|
|
37
|
+
"types": "./dist/index.d.ts",
|
|
38
|
+
"import": "./dist/index.js"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build": "tsc -p tsconfig.build.json",
|
|
43
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
44
|
+
"test": "vitest run"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@types/node": "^24.0.0",
|
|
48
|
+
"typescript": "^5.9.0",
|
|
49
|
+
"vitest": "^5.0.3"
|
|
50
|
+
}
|
|
51
|
+
}
|