@opencxh/domain 1.288.0 → 1.291.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/dist/entities/bank/bank.test.d.ts +1 -0
- package/dist/entities/bank/index.d.ts +3 -0
- package/dist/entities/bank/match.d.ts +52 -0
- package/dist/entities/bank/parse.d.ts +13 -0
- package/dist/entities/bank/types.d.ts +202 -0
- package/dist/entities/bookkeeping/index.d.ts +2 -0
- package/dist/entities/bookkeeping/receipt.d.ts +104 -0
- package/dist/entities/bookkeeping/receipt.test.d.ts +1 -0
- package/dist/entities/bookkeeping/types.d.ts +114 -0
- package/dist/entities/bookkeeping/types.test.d.ts +1 -0
- package/dist/entities/business-entity/types.d.ts +21 -1
- package/dist/entities/company/identifiers.d.ts +9 -0
- package/dist/entities/company/identifiers.test.d.ts +1 -0
- package/dist/entities/company/index.d.ts +1 -0
- package/dist/entities/company/types.d.ts +9 -0
- package/dist/entities/financing/closing-schedules.test.d.ts +1 -0
- package/dist/entities/financing/index.d.ts +2 -0
- package/dist/entities/financing/schedule.d.ts +73 -0
- package/dist/entities/financing/schedule.test.d.ts +1 -0
- package/dist/entities/financing/types.d.ts +138 -0
- package/dist/entities/ledger/closing.d.ts +18 -0
- package/dist/entities/ledger/closing.test.d.ts +1 -0
- package/dist/entities/ledger/entry.d.ts +83 -0
- package/dist/entities/ledger/index.d.ts +6 -0
- package/dist/entities/ledger/ledger.test.d.ts +1 -0
- package/dist/entities/ledger/periods.d.ts +9 -0
- package/dist/entities/ledger/template.d.ts +35 -0
- package/dist/entities/ledger/types.d.ts +178 -0
- package/dist/entities/ledger/xaf.d.ts +82 -0
- package/dist/entities/money/tax.d.ts +62 -0
- package/dist/entities/money/tax.test.d.ts +1 -0
- package/dist/entities/reports/index.d.ts +2 -0
- package/dist/entities/reports/reports.d.ts +90 -0
- package/dist/entities/reports/reports.test.d.ts +1 -0
- package/dist/entities/reports/vat.d.ts +59 -0
- package/dist/entities/transaction/booking.d.ts +14 -0
- package/dist/entities/transaction/booking.test.d.ts +1 -0
- package/dist/entities/transaction/convert.d.ts +5 -0
- package/dist/entities/transaction/dunning.d.ts +37 -0
- package/dist/entities/transaction/dunning.test.d.ts +1 -0
- package/dist/entities/transaction/index.d.ts +4 -0
- package/dist/entities/transaction/receivable.d.ts +47 -0
- package/dist/entities/transaction/receivable.test.d.ts +1 -0
- package/dist/entities/transaction/settlement.d.ts +20 -0
- package/dist/entities/transaction/settlement.test.d.ts +1 -0
- package/dist/entities/transaction/types.d.ts +20 -2
- package/dist/index.cjs +24 -21
- package/dist/index.d.ts +7 -1
- package/dist/index.js +4113 -2577
- package/dist/platform/bookkeeping.d.ts +276 -0
- package/package.json +1 -1
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import { LedgerMappingRule } from '../entities/bookkeeping/types';
|
|
2
|
+
import { Cents } from '../entities/money/money';
|
|
3
|
+
import { TaxRateKind } from '../entities/money/tax';
|
|
4
|
+
export declare const BOOKABLE_SOURCE_PROVIDER_GROUP = "bookable-source";
|
|
5
|
+
export declare const BOOKKEEPING_PROVIDER_GROUP = "bookkeeping";
|
|
6
|
+
/** Routes under `/provider`. Constants, so caller and provider cannot drift apart. */
|
|
7
|
+
export declare const BOOKABLE_ROUTES: {
|
|
8
|
+
readonly get: "/bookable/get";
|
|
9
|
+
readonly issued: "/bookable/issued";
|
|
10
|
+
readonly ledgerCategories: "/bookable/ledger-categories";
|
|
11
|
+
readonly settled: "/bookable/settled";
|
|
12
|
+
};
|
|
13
|
+
export declare const BOOKKEEPING_ROUTES: {
|
|
14
|
+
readonly describe: "/bookkeeping/describe";
|
|
15
|
+
readonly post: "/bookkeeping/post";
|
|
16
|
+
readonly lookup: "/bookkeeping/lookup";
|
|
17
|
+
readonly payments: "/bookkeeping/payments";
|
|
18
|
+
readonly paymentRegister: "/bookkeeping/payment-register";
|
|
19
|
+
readonly paymentUndo: "/bookkeeping/payment-undo";
|
|
20
|
+
readonly settle: "/bookkeeping/settle";
|
|
21
|
+
readonly reports: "/bookkeeping/reports";
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* What has to be booked, in EN 16931 terms so every e-invoice format is a serialisation of it.
|
|
25
|
+
* Carries no HTML and no type of the source app.
|
|
26
|
+
*/
|
|
27
|
+
export interface BookingDocument {
|
|
28
|
+
sourceApp: string;
|
|
29
|
+
documentId: string;
|
|
30
|
+
direction: "sale" | "purchase";
|
|
31
|
+
kind: "invoice" | "credit_note" | "receipt";
|
|
32
|
+
businessEntityId: string;
|
|
33
|
+
/** Empty for a receipt without a number, and for an invoice the books will number themselves. */
|
|
34
|
+
number?: string;
|
|
35
|
+
counterparty: {
|
|
36
|
+
companyId?: string;
|
|
37
|
+
name: string;
|
|
38
|
+
vatNumber?: string;
|
|
39
|
+
kvkNumber?: string;
|
|
40
|
+
/** As entered: `country` is free text here, the books map it onto their own code. */
|
|
41
|
+
address?: {
|
|
42
|
+
street?: string;
|
|
43
|
+
postalCode?: string;
|
|
44
|
+
city?: string;
|
|
45
|
+
country?: string;
|
|
46
|
+
};
|
|
47
|
+
country?: string;
|
|
48
|
+
};
|
|
49
|
+
/** `"2026-09-24"`. Dates are days, not instants. */
|
|
50
|
+
issueDate: string;
|
|
51
|
+
/** Delivery date or end of the service period: decides the VAT period. */
|
|
52
|
+
taxPointDate?: string;
|
|
53
|
+
dueDate?: string;
|
|
54
|
+
currency: string;
|
|
55
|
+
/** Decimal string, only when the currency differs from the administration's own. */
|
|
56
|
+
fxRate?: string;
|
|
57
|
+
lines: BookingLine[];
|
|
58
|
+
totals: {
|
|
59
|
+
netCents: Cents;
|
|
60
|
+
taxCents: Cents;
|
|
61
|
+
grossCents: Cents;
|
|
62
|
+
};
|
|
63
|
+
creditsDocumentId?: string;
|
|
64
|
+
attachment?: {
|
|
65
|
+
mountId: string;
|
|
66
|
+
fileId: string;
|
|
67
|
+
};
|
|
68
|
+
externalIds?: string[];
|
|
69
|
+
}
|
|
70
|
+
export interface BookingLine {
|
|
71
|
+
description: string;
|
|
72
|
+
netCents: Cents;
|
|
73
|
+
taxCents: Cents;
|
|
74
|
+
/** `TaxCode.key`. The books map it onto their own box and account. */
|
|
75
|
+
taxRateKey: string;
|
|
76
|
+
taxKind: TaxRateKind;
|
|
77
|
+
/** The percent the line was priced at (`21`). Absent on documents priced before it was stored. */
|
|
78
|
+
taxPercent?: number;
|
|
79
|
+
ledgerCategoryKey?: string;
|
|
80
|
+
/**
|
|
81
|
+
* The account in the target books a person chose for this line (a receipt: "Kiezen"). Beats
|
|
82
|
+
* every mapping rule: `LedgerOption.key` in external books, the account id in our own.
|
|
83
|
+
*/
|
|
84
|
+
accountKey?: string;
|
|
85
|
+
productId?: string;
|
|
86
|
+
/** Open map: cost centre, project, and whatever a later country needs. */
|
|
87
|
+
dimensions?: Record<string, string>;
|
|
88
|
+
}
|
|
89
|
+
/** One row of the sweeper's safety net: an issued document the books may not have heard of. */
|
|
90
|
+
export interface IssuedDocumentRef {
|
|
91
|
+
documentId: string;
|
|
92
|
+
businessEntityId: string;
|
|
93
|
+
kind: BookingDocument["kind"];
|
|
94
|
+
issuedAt: number;
|
|
95
|
+
number?: string;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* "This was issued": what a source tells finance (`POST finance/booking/enqueue`). Best effort —
|
|
99
|
+
* the sweeper asks `bookable/issued` for anything this missed.
|
|
100
|
+
*/
|
|
101
|
+
export interface BookingAnnouncement {
|
|
102
|
+
sourceApp: string;
|
|
103
|
+
documentId: string;
|
|
104
|
+
/** Empty = the default administration; finance resolves it, a row never carries "". */
|
|
105
|
+
businessEntityId?: string;
|
|
106
|
+
documentKind: BookingDocument["kind"];
|
|
107
|
+
documentNumber?: string;
|
|
108
|
+
issuedAt: number;
|
|
109
|
+
}
|
|
110
|
+
/** A bucket a product or line is booked under. The mapping UIs pick from this list, never free text. */
|
|
111
|
+
export interface LedgerCategory {
|
|
112
|
+
key: string;
|
|
113
|
+
label: string;
|
|
114
|
+
}
|
|
115
|
+
export type SettlementState = "unpaid" | "partially_paid" | "paid" | "overpaid";
|
|
116
|
+
/**
|
|
117
|
+
* What the books know about one source document: that it arrived, and its whole payment state —
|
|
118
|
+
* never a delta, so a repeated or late notice can do no harm. The receiver ignores a notice whose
|
|
119
|
+
* `asOf` is older than what it holds. The payment fields are absent on a "posted" notice.
|
|
120
|
+
*/
|
|
121
|
+
export interface SettledNotice {
|
|
122
|
+
documentId: string;
|
|
123
|
+
asOf: number;
|
|
124
|
+
postedAt?: number;
|
|
125
|
+
externalId?: string;
|
|
126
|
+
/** The books' number, when they number the document themselves (Jortt). */
|
|
127
|
+
number?: string;
|
|
128
|
+
payment?: {
|
|
129
|
+
state: SettlementState;
|
|
130
|
+
paidCents: Cents;
|
|
131
|
+
openCents: Cents;
|
|
132
|
+
lastPaymentAt?: number;
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
export type BookkeepingCapability = "ledger" | "journal" | "invoice-push" | "expense-push" | "payment-register" | "payment-status" | "bank" | "reconcile" | "vat-report" | "reports" | "attachments";
|
|
136
|
+
export interface LedgerOption {
|
|
137
|
+
key: string;
|
|
138
|
+
label: string;
|
|
139
|
+
kind: "revenue" | "expense" | "balance";
|
|
140
|
+
}
|
|
141
|
+
export interface BookkeepingDescribe {
|
|
142
|
+
app: string;
|
|
143
|
+
capabilities: BookkeepingCapability[];
|
|
144
|
+
/** Why a capability is missing, as an i18n key: the UI shows it beside the disabled control. */
|
|
145
|
+
missingReasons?: Partial<Record<BookkeepingCapability, string>>;
|
|
146
|
+
/** The target accounts a mapping UI offers, for books without separate connections. */
|
|
147
|
+
ledgerOptions?: LedgerOption[];
|
|
148
|
+
/**
|
|
149
|
+
* The connections a binding can pick (`BookkeepingBinding.accountId`), each with its own
|
|
150
|
+
* accounts: two Jortt administrations have two charts. Absent for our own books.
|
|
151
|
+
*/
|
|
152
|
+
accounts?: {
|
|
153
|
+
id: string;
|
|
154
|
+
label: string;
|
|
155
|
+
ledgerOptions?: LedgerOption[];
|
|
156
|
+
}[];
|
|
157
|
+
/**
|
|
158
|
+
* Books whose chart is per administration of ours (our own books): the options for each,
|
|
159
|
+
* keyed by `businessEntityId`. A mapping UI picks from here when there is no connection.
|
|
160
|
+
*/
|
|
161
|
+
administrationOptions?: Record<string, LedgerOption[]>;
|
|
162
|
+
/** Can a lost create response be recovered? `none` forbids an automatic retry. */
|
|
163
|
+
lookup: "correlation" | "number" | "none";
|
|
164
|
+
/** Who numbers an invoice: us at issue, or the books when it arrives there. */
|
|
165
|
+
numbering: "local" | "external";
|
|
166
|
+
}
|
|
167
|
+
/** What the binding says about the connection, handed along so the books need not ask back. */
|
|
168
|
+
export interface BookingConnection {
|
|
169
|
+
/** `ManagedAccount.id` of the connection; empty for our own books. */
|
|
170
|
+
accountId?: string;
|
|
171
|
+
ledgerMapping?: LedgerMappingRule[];
|
|
172
|
+
}
|
|
173
|
+
export interface PostRequest {
|
|
174
|
+
sourceApp: string;
|
|
175
|
+
documentId: string;
|
|
176
|
+
businessEntityId: string;
|
|
177
|
+
/** Sent along to the books and searched on during recovery: `oc:<documentId>`. */
|
|
178
|
+
correlationKey: string;
|
|
179
|
+
connection: BookingConnection;
|
|
180
|
+
}
|
|
181
|
+
export interface PostResult {
|
|
182
|
+
externalId: string;
|
|
183
|
+
postedAt: number;
|
|
184
|
+
/** Set when the books numbered the document. */
|
|
185
|
+
number?: string;
|
|
186
|
+
}
|
|
187
|
+
export interface LookupRequest {
|
|
188
|
+
correlationKey: string;
|
|
189
|
+
connection: BookingConnection;
|
|
190
|
+
documentNumber?: string;
|
|
191
|
+
grossCents: Cents;
|
|
192
|
+
counterpartyName: string;
|
|
193
|
+
issueDate: string;
|
|
194
|
+
}
|
|
195
|
+
/** `unknown` means the search itself failed: do not create again. */
|
|
196
|
+
export type LookupResult = {
|
|
197
|
+
found: true;
|
|
198
|
+
externalId: string;
|
|
199
|
+
number?: string;
|
|
200
|
+
} | {
|
|
201
|
+
found: false;
|
|
202
|
+
} | {
|
|
203
|
+
unknown: true;
|
|
204
|
+
reason: string;
|
|
205
|
+
};
|
|
206
|
+
/** A posted document in the books, and the connection to reach it by. */
|
|
207
|
+
export interface BooksDocumentRef {
|
|
208
|
+
connection: BookingConnection;
|
|
209
|
+
/** `PostResult.externalId` as the books gave it. */
|
|
210
|
+
externalId: string;
|
|
211
|
+
}
|
|
212
|
+
/** One payment the books hold on a document. `id` is what undoing it takes. */
|
|
213
|
+
export interface BooksPayment {
|
|
214
|
+
id: string;
|
|
215
|
+
/** Positive: money towards settling the document. */
|
|
216
|
+
amountCents: Cents;
|
|
217
|
+
date?: string;
|
|
218
|
+
/** The account it came from, by name. */
|
|
219
|
+
from?: string;
|
|
220
|
+
/** It came from another document (a credit note settling this one), not from an account. */
|
|
221
|
+
fromDocument?: boolean;
|
|
222
|
+
description?: string;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* A document's payments in the books, the accounts a new one may come from, and its whole
|
|
226
|
+
* payment state after the call: every payment route answers with this, so the caller never
|
|
227
|
+
* waits for the next poll.
|
|
228
|
+
*/
|
|
229
|
+
export interface BooksPayments {
|
|
230
|
+
payment: NonNullable<SettledNotice["payment"]>;
|
|
231
|
+
payments: BooksPayment[];
|
|
232
|
+
fromOptions: {
|
|
233
|
+
key: string;
|
|
234
|
+
label: string;
|
|
235
|
+
}[];
|
|
236
|
+
}
|
|
237
|
+
export interface RegisterPaymentRequest extends BooksDocumentRef {
|
|
238
|
+
amountCents: Cents;
|
|
239
|
+
date: string;
|
|
240
|
+
/** `BooksPayments.fromOptions[].key`. */
|
|
241
|
+
fromKey: string;
|
|
242
|
+
description?: string;
|
|
243
|
+
}
|
|
244
|
+
export interface UndoPaymentRequest extends BooksDocumentRef {
|
|
245
|
+
paymentId: string;
|
|
246
|
+
}
|
|
247
|
+
/** A report the books compute themselves (Jortt), in the shape our own reports have. */
|
|
248
|
+
export interface ReportRequest {
|
|
249
|
+
connection: BookingConnection;
|
|
250
|
+
kind: "profit_and_loss" | "balance";
|
|
251
|
+
from: string;
|
|
252
|
+
to: string;
|
|
253
|
+
}
|
|
254
|
+
/** Settle an invoice with its credit note: the note's open amount pays the invoice. */
|
|
255
|
+
export interface SettleRequest extends BooksDocumentRef {
|
|
256
|
+
sourceExternalId: string;
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Who numbers this administration's invoices. `external` means the source issues without a number
|
|
260
|
+
* and takes the books' number from the "posted" {@link SettledNotice}.
|
|
261
|
+
*/
|
|
262
|
+
export interface NumberingAnswer {
|
|
263
|
+
numbering: BookkeepingDescribe["numbering"];
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* A payment state the books saw on their own (Jortt is polled), reported to finance, which knows
|
|
267
|
+
* which source document the correlation key belongs to and forwards a {@link SettledNotice}.
|
|
268
|
+
*/
|
|
269
|
+
export interface PaymentReport {
|
|
270
|
+
targetApp: string;
|
|
271
|
+
correlationKey: string;
|
|
272
|
+
asOf: number;
|
|
273
|
+
payment: NonNullable<SettledNotice["payment"]>;
|
|
274
|
+
}
|
|
275
|
+
/** The deterministic key a retry reuses, so the books can recognise a second attempt. */
|
|
276
|
+
export declare function correlationKeyFor(documentId: string): string;
|