@ekwo-ai/core 0.4.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/README.md +76 -0
- package/dist/books/backend.d.ts +118 -0
- package/dist/books/backend.d.ts.map +1 -0
- package/dist/books/backend.js +69 -0
- package/dist/books/backend.js.map +1 -0
- package/dist/books/columns.d.ts +68 -0
- package/dist/books/columns.d.ts.map +1 -0
- package/dist/books/columns.js +466 -0
- package/dist/books/columns.js.map +1 -0
- package/dist/books/contacts.d.ts +43 -0
- package/dist/books/contacts.d.ts.map +1 -0
- package/dist/books/contacts.js +67 -0
- package/dist/books/contacts.js.map +1 -0
- package/dist/books/documents.d.ts +87 -0
- package/dist/books/documents.d.ts.map +1 -0
- package/dist/books/documents.js +413 -0
- package/dist/books/documents.js.map +1 -0
- package/dist/books/format.d.ts +21 -0
- package/dist/books/format.d.ts.map +1 -0
- package/dist/books/format.js +49 -0
- package/dist/books/format.js.map +1 -0
- package/dist/books/index.d.ts +18 -0
- package/dist/books/index.d.ts.map +1 -0
- package/dist/books/index.js +18 -0
- package/dist/books/index.js.map +1 -0
- package/dist/books/payments.d.ts +57 -0
- package/dist/books/payments.d.ts.map +1 -0
- package/dist/books/payments.js +255 -0
- package/dist/books/payments.js.map +1 -0
- package/dist/books/rounding.d.ts +25 -0
- package/dist/books/rounding.d.ts.map +1 -0
- package/dist/books/rounding.js +35 -0
- package/dist/books/rounding.js.map +1 -0
- package/dist/books/shared.d.ts +33 -0
- package/dist/books/shared.d.ts.map +1 -0
- package/dist/books/shared.js +98 -0
- package/dist/books/shared.js.map +1 -0
- package/dist/client.d.ts +73 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +138 -0
- package/dist/client.js.map +1 -0
- package/dist/fec.d.ts +14 -0
- package/dist/fec.d.ts.map +1 -0
- package/dist/fec.js +13 -0
- package/dist/fec.js.map +1 -0
- package/dist/identity.d.ts +46 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +62 -0
- package/dist/identity.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/refusal.d.ts +27 -0
- package/dist/refusal.d.ts.map +1 -0
- package/dist/refusal.js +38 -0
- package/dist/refusal.js.map +1 -0
- package/dist/schema.d.ts +23 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +42 -0
- package/dist/schema.js.map +1 -0
- package/dist/types.d.ts +466 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +170 -0
- package/dist/types.js.map +1 -0
- package/package.json +34 -0
|
@@ -0,0 +1,466 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What each tool reads back, written once.
|
|
3
|
+
*
|
|
4
|
+
* Two rules run through every list. A `numeric` column is asked for as
|
|
5
|
+
* `amount::text`, so the exact decimal arrives rather than a float; a `date`
|
|
6
|
+
* or a timestamp likewise, so `2026-06-15` is a string on both routes instead
|
|
7
|
+
* of whatever a driver decided a date object should be. Everything else —
|
|
8
|
+
* uuid, text, boolean, integer — crosses unchanged.
|
|
9
|
+
*/
|
|
10
|
+
export const COMPANY = [
|
|
11
|
+
'id',
|
|
12
|
+
'name',
|
|
13
|
+
'trade_name',
|
|
14
|
+
'legal_name',
|
|
15
|
+
'legal_form',
|
|
16
|
+
'country',
|
|
17
|
+
'fiscal_country',
|
|
18
|
+
'vat_number',
|
|
19
|
+
'registration_number',
|
|
20
|
+
'address_line1',
|
|
21
|
+
'address_line2',
|
|
22
|
+
'postal_code',
|
|
23
|
+
'city',
|
|
24
|
+
'country',
|
|
25
|
+
'region',
|
|
26
|
+
'email',
|
|
27
|
+
'phone',
|
|
28
|
+
'website',
|
|
29
|
+
'logo_url',
|
|
30
|
+
'share_capital::text',
|
|
31
|
+
'share_capital_currency',
|
|
32
|
+
'activity_code',
|
|
33
|
+
'activity_scheme',
|
|
34
|
+
'document_template',
|
|
35
|
+
'default_bank_account_id',
|
|
36
|
+
'language',
|
|
37
|
+
'currency_code',
|
|
38
|
+
'lock_date::text',
|
|
39
|
+
'tax_lock_date::text',
|
|
40
|
+
'receivable_account_id',
|
|
41
|
+
'payable_account_id',
|
|
42
|
+
'suspense_account_id',
|
|
43
|
+
'retained_earnings_account_id',
|
|
44
|
+
'sales_journal_id',
|
|
45
|
+
'purchase_journal_id',
|
|
46
|
+
'miscellaneous_journal_id',
|
|
47
|
+
];
|
|
48
|
+
export const FISCAL_YEAR = ['id', 'name', 'start_date::text', 'end_date::text', 'is_closed'];
|
|
49
|
+
export const ACCOUNT = [
|
|
50
|
+
'id',
|
|
51
|
+
'code',
|
|
52
|
+
'name',
|
|
53
|
+
'account_type',
|
|
54
|
+
'internal_group',
|
|
55
|
+
'reconcilable',
|
|
56
|
+
'currency_code',
|
|
57
|
+
'deprecated',
|
|
58
|
+
'pinned',
|
|
59
|
+
];
|
|
60
|
+
export const JOURNAL = ['id', 'code', 'name', 'journal_type', 'active'];
|
|
61
|
+
export const CONTACT = [
|
|
62
|
+
'id',
|
|
63
|
+
// The caller's own reference: the idempotency key of the creation.
|
|
64
|
+
'client_ref',
|
|
65
|
+
'name',
|
|
66
|
+
'contact_type',
|
|
67
|
+
'vat_number',
|
|
68
|
+
'auxiliary_code',
|
|
69
|
+
'email',
|
|
70
|
+
'country',
|
|
71
|
+
'payment_terms_days',
|
|
72
|
+
'receivable_account_id',
|
|
73
|
+
'payable_account_id',
|
|
74
|
+
'active',
|
|
75
|
+
];
|
|
76
|
+
export const TAX = [
|
|
77
|
+
'id',
|
|
78
|
+
'code',
|
|
79
|
+
'name',
|
|
80
|
+
'amount::text',
|
|
81
|
+
'amount_type',
|
|
82
|
+
'applies_to',
|
|
83
|
+
'treatment',
|
|
84
|
+
'vat_category',
|
|
85
|
+
'valid_from::text',
|
|
86
|
+
'valid_to::text',
|
|
87
|
+
'legal_reference',
|
|
88
|
+
// The generalised engine. `tax_kind` and `jurisdiction` say what a tax is
|
|
89
|
+
// where the code alone would have to be guessed at; `recoverable` and
|
|
90
|
+
// `price_include` change what a client should show; `cash_basis` is here so
|
|
91
|
+
// a reader is not surprised by it once cash-basis VAT starts writing it.
|
|
92
|
+
'tax_kind',
|
|
93
|
+
'recoverable',
|
|
94
|
+
'jurisdiction',
|
|
95
|
+
'price_include',
|
|
96
|
+
'cash_basis',
|
|
97
|
+
'active',
|
|
98
|
+
];
|
|
99
|
+
export const DOCUMENT = [
|
|
100
|
+
'id',
|
|
101
|
+
// The caller's own reference: the idempotency key of the creation.
|
|
102
|
+
'client_ref',
|
|
103
|
+
'company_id',
|
|
104
|
+
'doc_type',
|
|
105
|
+
'state',
|
|
106
|
+
'payment_state',
|
|
107
|
+
'number',
|
|
108
|
+
'supplier_reference',
|
|
109
|
+
'contact_id',
|
|
110
|
+
'journal_id',
|
|
111
|
+
'document_date::text',
|
|
112
|
+
'accounting_date::text',
|
|
113
|
+
'due_date::text',
|
|
114
|
+
'currency_code',
|
|
115
|
+
'language',
|
|
116
|
+
'amount_untaxed::text',
|
|
117
|
+
'amount_tax::text',
|
|
118
|
+
'amount_total::text',
|
|
119
|
+
'amount_paid::text',
|
|
120
|
+
'amount_residual::text',
|
|
121
|
+
'entry_id',
|
|
122
|
+
'sent_at::text',
|
|
123
|
+
];
|
|
124
|
+
/**
|
|
125
|
+
* The mentions the law of a country puts on one document, from the view that
|
|
126
|
+
* decides which of them apply. `text` is the sentence in the language the
|
|
127
|
+
* document was written in and `language` says which one that is; `text_i18n`
|
|
128
|
+
* crosses as it is, for a renderer printing a second language beside it.
|
|
129
|
+
*/
|
|
130
|
+
export const DOCUMENT_LEGAL_MENTION = [
|
|
131
|
+
'code',
|
|
132
|
+
'applies_when',
|
|
133
|
+
'language',
|
|
134
|
+
'text',
|
|
135
|
+
'text_i18n',
|
|
136
|
+
'sequence',
|
|
137
|
+
'legal_reference',
|
|
138
|
+
];
|
|
139
|
+
/**
|
|
140
|
+
* What the country of a document requires of it, beside the mentions: the
|
|
141
|
+
* payment term the law sets, how the number is built, when the tax falls due
|
|
142
|
+
* and how the document is exchanged. Read from `country_defaults`, which
|
|
143
|
+
* holds null wherever the pack has said nothing — and null is the answer, not
|
|
144
|
+
* an invitation to substitute another country's.
|
|
145
|
+
*/
|
|
146
|
+
export const COUNTRY_DOCUMENT_RULES = [
|
|
147
|
+
'country',
|
|
148
|
+
'numbering_gapless',
|
|
149
|
+
'number_format',
|
|
150
|
+
'legal_payment_days',
|
|
151
|
+
'late_payment_reference',
|
|
152
|
+
'tax_point_rule',
|
|
153
|
+
'einvoice_profile',
|
|
154
|
+
'einvoice_mandatory_from::text',
|
|
155
|
+
'party_scheme',
|
|
156
|
+
'vat_scheme',
|
|
157
|
+
];
|
|
158
|
+
/**
|
|
159
|
+
* The header of a document, from the view that assembles it: the seller, the
|
|
160
|
+
* buyer, the amounts, where it is paid and what the country of the document
|
|
161
|
+
* requires. `document_line_items` is the lines and `document_legal_mentions`
|
|
162
|
+
* the sentences — three reads, and no client holding a copy of the
|
|
163
|
+
* letterhead.
|
|
164
|
+
*/
|
|
165
|
+
export const DOCUMENT_HEADER = [
|
|
166
|
+
'document_id',
|
|
167
|
+
'company_id',
|
|
168
|
+
'doc_type',
|
|
169
|
+
'state',
|
|
170
|
+
'payment_state',
|
|
171
|
+
'number',
|
|
172
|
+
'supplier_reference',
|
|
173
|
+
'document_date::text',
|
|
174
|
+
'accounting_date::text',
|
|
175
|
+
'due_date::text',
|
|
176
|
+
'delivery_date::text',
|
|
177
|
+
'currency_code',
|
|
178
|
+
'amount_untaxed::text',
|
|
179
|
+
'amount_tax::text',
|
|
180
|
+
'amount_total::text',
|
|
181
|
+
'amount_paid::text',
|
|
182
|
+
'amount_residual::text',
|
|
183
|
+
'payment_terms',
|
|
184
|
+
'payment_means_code',
|
|
185
|
+
'payment_reference',
|
|
186
|
+
'buyer_reference',
|
|
187
|
+
'order_reference',
|
|
188
|
+
'contract_reference',
|
|
189
|
+
'project_reference',
|
|
190
|
+
'note',
|
|
191
|
+
'payee_iban',
|
|
192
|
+
'payee_bic',
|
|
193
|
+
'seller_name',
|
|
194
|
+
'seller_legal_name',
|
|
195
|
+
'seller_legal_form',
|
|
196
|
+
'seller_vat_number',
|
|
197
|
+
'seller_registration_number',
|
|
198
|
+
'seller_address_line1',
|
|
199
|
+
'seller_address_line2',
|
|
200
|
+
'seller_postal_code',
|
|
201
|
+
'seller_city',
|
|
202
|
+
'seller_country',
|
|
203
|
+
'seller_email',
|
|
204
|
+
'seller_phone',
|
|
205
|
+
'seller_website',
|
|
206
|
+
'seller_logo_url',
|
|
207
|
+
'seller_share_capital::text',
|
|
208
|
+
'seller_share_capital_currency',
|
|
209
|
+
'seller_activity_code',
|
|
210
|
+
'seller_activity_scheme',
|
|
211
|
+
'document_template',
|
|
212
|
+
'buyer_id',
|
|
213
|
+
'buyer_name',
|
|
214
|
+
'buyer_vat_number',
|
|
215
|
+
'buyer_registration_number',
|
|
216
|
+
'buyer_address_line1',
|
|
217
|
+
'buyer_address_line2',
|
|
218
|
+
'buyer_postal_code',
|
|
219
|
+
'buyer_city',
|
|
220
|
+
'buyer_country',
|
|
221
|
+
'buyer_email',
|
|
222
|
+
'language',
|
|
223
|
+
'country',
|
|
224
|
+
'number_format',
|
|
225
|
+
'numbering_gapless',
|
|
226
|
+
'legal_payment_days',
|
|
227
|
+
'late_payment_reference',
|
|
228
|
+
'tax_point_rule',
|
|
229
|
+
'einvoice_profile',
|
|
230
|
+
'einvoice_mandatory_from::text',
|
|
231
|
+
'party_scheme',
|
|
232
|
+
'vat_scheme',
|
|
233
|
+
];
|
|
234
|
+
export const PRODUCT = [
|
|
235
|
+
'id',
|
|
236
|
+
'company_id',
|
|
237
|
+
'code',
|
|
238
|
+
'name',
|
|
239
|
+
'description',
|
|
240
|
+
'kind',
|
|
241
|
+
'unit_code',
|
|
242
|
+
'currency_code',
|
|
243
|
+
'sale_price::text',
|
|
244
|
+
'purchase_price::text',
|
|
245
|
+
'sale_account_id',
|
|
246
|
+
'purchase_account_id',
|
|
247
|
+
'sale_tax_id',
|
|
248
|
+
'purchase_tax_id',
|
|
249
|
+
'active',
|
|
250
|
+
];
|
|
251
|
+
export const DOCUMENT_LINE = [
|
|
252
|
+
'id',
|
|
253
|
+
'document_id',
|
|
254
|
+
'sequence',
|
|
255
|
+
'line_type',
|
|
256
|
+
'name',
|
|
257
|
+
'description',
|
|
258
|
+
'product_id',
|
|
259
|
+
'quantity::text',
|
|
260
|
+
'unit_code',
|
|
261
|
+
'unit_price::text',
|
|
262
|
+
'discount_percent::text',
|
|
263
|
+
'tax_id',
|
|
264
|
+
'account_id',
|
|
265
|
+
'vat_category',
|
|
266
|
+
'vat_rate::text',
|
|
267
|
+
'amount_untaxed::text',
|
|
268
|
+
'unit_price_includes_tax',
|
|
269
|
+
'amount_incl_tax::text',
|
|
270
|
+
];
|
|
271
|
+
export const ENTRY = [
|
|
272
|
+
'id',
|
|
273
|
+
'company_id',
|
|
274
|
+
'journal_id',
|
|
275
|
+
'number',
|
|
276
|
+
'entry_date::text',
|
|
277
|
+
'reference',
|
|
278
|
+
'description',
|
|
279
|
+
'state',
|
|
280
|
+
'kind',
|
|
281
|
+
'document_id',
|
|
282
|
+
'total_debit::text',
|
|
283
|
+
'total_credit::text',
|
|
284
|
+
'is_balanced',
|
|
285
|
+
'posted_at::text',
|
|
286
|
+
];
|
|
287
|
+
export const ENTRY_LINE = [
|
|
288
|
+
'id',
|
|
289
|
+
'entry_id',
|
|
290
|
+
'account_id',
|
|
291
|
+
'sequence',
|
|
292
|
+
'name',
|
|
293
|
+
'debit::text',
|
|
294
|
+
'credit::text',
|
|
295
|
+
'balance::text',
|
|
296
|
+
'contact_id',
|
|
297
|
+
'date_maturity::text',
|
|
298
|
+
'tax_id',
|
|
299
|
+
'tax_line',
|
|
300
|
+
'declaration_box',
|
|
301
|
+
'box_amount::text',
|
|
302
|
+
'matching_number',
|
|
303
|
+
'matched_amount::text',
|
|
304
|
+
// The currency of the line and its amount in it, written whenever that
|
|
305
|
+
// currency is not the company's. A client matching two foreign lines needs
|
|
306
|
+
// both: that is the scale the matching is worked out on.
|
|
307
|
+
'currency_code',
|
|
308
|
+
'amount_currency::text',
|
|
309
|
+
];
|
|
310
|
+
export const BANK_ACCOUNT = [
|
|
311
|
+
'id',
|
|
312
|
+
'name',
|
|
313
|
+
'iban',
|
|
314
|
+
'bic',
|
|
315
|
+
'bank_name',
|
|
316
|
+
'currency_code',
|
|
317
|
+
'account_id',
|
|
318
|
+
'journal_id',
|
|
319
|
+
'active',
|
|
320
|
+
];
|
|
321
|
+
export const BANK_TRANSACTION = [
|
|
322
|
+
'id',
|
|
323
|
+
'company_id',
|
|
324
|
+
'bank_account_id',
|
|
325
|
+
'statement_id',
|
|
326
|
+
'transaction_date::text',
|
|
327
|
+
'value_date::text',
|
|
328
|
+
'amount::text',
|
|
329
|
+
'currency_code',
|
|
330
|
+
'description',
|
|
331
|
+
'counterpart_name',
|
|
332
|
+
'counterpart_iban',
|
|
333
|
+
'reference',
|
|
334
|
+
'structured_reference',
|
|
335
|
+
'contact_id',
|
|
336
|
+
'entry_id',
|
|
337
|
+
'state',
|
|
338
|
+
];
|
|
339
|
+
export const PAYMENT = [
|
|
340
|
+
'id',
|
|
341
|
+
// The caller's own reference: the idempotency key of the creation.
|
|
342
|
+
'client_ref',
|
|
343
|
+
'company_id',
|
|
344
|
+
'direction',
|
|
345
|
+
'payment_date::text',
|
|
346
|
+
'amount::text',
|
|
347
|
+
'currency_code',
|
|
348
|
+
'contact_id',
|
|
349
|
+
'journal_id',
|
|
350
|
+
'bank_account_id',
|
|
351
|
+
'entry_id',
|
|
352
|
+
'reference',
|
|
353
|
+
'memo',
|
|
354
|
+
'state',
|
|
355
|
+
];
|
|
356
|
+
/**
|
|
357
|
+
* An invitation, without its secret. `token_hash` is deliberately absent: it
|
|
358
|
+
* is of no use to a client, and a list of hashes is a thing to leak rather
|
|
359
|
+
* than a thing to show.
|
|
360
|
+
*/
|
|
361
|
+
/** What one person chose for themselves. Null everywhere is the fresh state. */
|
|
362
|
+
export const USER_PREFERENCES = [
|
|
363
|
+
'user_id',
|
|
364
|
+
'preferred_company_id',
|
|
365
|
+
'language',
|
|
366
|
+
'timezone',
|
|
367
|
+
'date_display_format',
|
|
368
|
+
'number_display_format',
|
|
369
|
+
'theme',
|
|
370
|
+
'updated_at::text',
|
|
371
|
+
];
|
|
372
|
+
export const INVITATION = [
|
|
373
|
+
'id',
|
|
374
|
+
'company_id',
|
|
375
|
+
'email',
|
|
376
|
+
'role',
|
|
377
|
+
'capabilities_granted',
|
|
378
|
+
'invited_by',
|
|
379
|
+
'created_at::text',
|
|
380
|
+
'expires_at::text',
|
|
381
|
+
'accepted_at::text',
|
|
382
|
+
'accepted_by',
|
|
383
|
+
'revoked_at::text',
|
|
384
|
+
];
|
|
385
|
+
/** A machine key, without its hash. The secret is returned once, elsewhere. */
|
|
386
|
+
export const API_KEY = [
|
|
387
|
+
'id',
|
|
388
|
+
'company_id',
|
|
389
|
+
'name',
|
|
390
|
+
'prefix',
|
|
391
|
+
'capabilities',
|
|
392
|
+
'created_by',
|
|
393
|
+
'created_at::text',
|
|
394
|
+
'expires_at::text',
|
|
395
|
+
'last_used_at::text',
|
|
396
|
+
'revoked_at::text',
|
|
397
|
+
];
|
|
398
|
+
/** A public link onto a document, without its secret. There is only a hash. */
|
|
399
|
+
export const DOCUMENT_SHARE = [
|
|
400
|
+
'id',
|
|
401
|
+
'company_id',
|
|
402
|
+
'document_id',
|
|
403
|
+
'subject_kind',
|
|
404
|
+
'created_by',
|
|
405
|
+
'created_at::text',
|
|
406
|
+
'expires_at::text',
|
|
407
|
+
'revoked_at::text',
|
|
408
|
+
'view_count',
|
|
409
|
+
'last_viewed_at::text',
|
|
410
|
+
];
|
|
411
|
+
export const INSTANCE = [
|
|
412
|
+
'instance_id',
|
|
413
|
+
'organization_name',
|
|
414
|
+
'country',
|
|
415
|
+
'edition',
|
|
416
|
+
'schema_version',
|
|
417
|
+
'installed_at::text',
|
|
418
|
+
'registered_at::text',
|
|
419
|
+
];
|
|
420
|
+
export const RECONCILIATION = [
|
|
421
|
+
'id',
|
|
422
|
+
'debit_line_id',
|
|
423
|
+
'credit_line_id',
|
|
424
|
+
'amount::text',
|
|
425
|
+
'matching_number',
|
|
426
|
+
'matched_at::text',
|
|
427
|
+
// What the matching revealed, when it revealed something: the entry that
|
|
428
|
+
// booked the realised exchange difference, and the one that moved the share
|
|
429
|
+
// of a cash-basis tax the settlement made due. A client that shows a
|
|
430
|
+
// matching shows what it caused.
|
|
431
|
+
'fx_entry_id',
|
|
432
|
+
'tax_transfer_entry_id',
|
|
433
|
+
];
|
|
434
|
+
export const AUDIT_LOG = [
|
|
435
|
+
'id',
|
|
436
|
+
'occurred_at::text',
|
|
437
|
+
'actor_id',
|
|
438
|
+
'api_key_id',
|
|
439
|
+
'company_id',
|
|
440
|
+
'table_name',
|
|
441
|
+
'record_id',
|
|
442
|
+
'record_key',
|
|
443
|
+
'operation',
|
|
444
|
+
'action',
|
|
445
|
+
'old_values',
|
|
446
|
+
'new_values',
|
|
447
|
+
];
|
|
448
|
+
/**
|
|
449
|
+
* `country_packs` — which pack this installation holds, and where its rules
|
|
450
|
+
* come from. `sources` is the register the pack declares: a reader that wants
|
|
451
|
+
* to check a rate rather than trust it starts there.
|
|
452
|
+
*/
|
|
453
|
+
export const COUNTRY_PACK = [
|
|
454
|
+
'country',
|
|
455
|
+
'name',
|
|
456
|
+
'version',
|
|
457
|
+
'released_at::text',
|
|
458
|
+
'schema_min',
|
|
459
|
+
'certification_status',
|
|
460
|
+
'certified_by',
|
|
461
|
+
'certified_at::text',
|
|
462
|
+
'checksum',
|
|
463
|
+
'sources',
|
|
464
|
+
'installed_at::text',
|
|
465
|
+
];
|
|
466
|
+
//# sourceMappingURL=columns.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"columns.js","sourceRoot":"","sources":["../../src/books/columns.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,MAAM,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V,SAAS;IACT,oBAAoB;CACrB,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contacts: the people and the companies the books name.
|
|
3
|
+
*/
|
|
4
|
+
import { type Backend } from './backend.js';
|
|
5
|
+
import type { ContactType } from '../types.js';
|
|
6
|
+
export declare const CONTACT_TYPES: readonly ["customer", "supplier", "both", "employee", "other"];
|
|
7
|
+
export interface CreateContactArgs {
|
|
8
|
+
company_id: string;
|
|
9
|
+
name: string;
|
|
10
|
+
/** Left out, the database's own default applies. */
|
|
11
|
+
contact_type?: ContactType | undefined;
|
|
12
|
+
vat_number?: string | undefined;
|
|
13
|
+
email?: string | undefined;
|
|
14
|
+
country?: string | undefined;
|
|
15
|
+
payment_terms_days?: number | undefined;
|
|
16
|
+
auxiliary_code?: string | undefined;
|
|
17
|
+
address_line1?: string | undefined;
|
|
18
|
+
postal_code?: string | undefined;
|
|
19
|
+
city?: string | undefined;
|
|
20
|
+
/** Your own reference. Creating twice under one reference creates once. */
|
|
21
|
+
client_ref?: string | undefined;
|
|
22
|
+
}
|
|
23
|
+
export interface SearchContactsArgs {
|
|
24
|
+
company_id: string;
|
|
25
|
+
query?: string | undefined;
|
|
26
|
+
contact_type?: ContactType | undefined;
|
|
27
|
+
vat_number?: string | undefined;
|
|
28
|
+
limit?: number | undefined;
|
|
29
|
+
}
|
|
30
|
+
export declare function createContact(backend: Backend, args: CreateContactArgs): Promise<unknown>;
|
|
31
|
+
export declare function searchContacts(backend: Backend, args: SearchContactsArgs): Promise<unknown>;
|
|
32
|
+
/**
|
|
33
|
+
* The contact a person means by an id, a name or part of one.
|
|
34
|
+
*
|
|
35
|
+
* One match is the answer; several are listed and refused, because an invoice
|
|
36
|
+
* addressed to the wrong one of two namesakes is posted before anybody
|
|
37
|
+
* notices. An exact name wins over names that merely contain it.
|
|
38
|
+
*/
|
|
39
|
+
export declare function resolveContact(backend: Backend, company: string, wanted: string): Promise<{
|
|
40
|
+
id: string;
|
|
41
|
+
name: string;
|
|
42
|
+
}>;
|
|
43
|
+
//# sourceMappingURL=contacts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contacts.d.ts","sourceRoot":"","sources":["../../src/books/contacts.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAc,KAAK,OAAO,EAAyB,MAAM,cAAc,CAAC;AAG/E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,eAAO,MAAM,aAAa,gEAAkG,CAAC;AAE7H,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,oDAAoD;IACpD,YAAY,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;IACvC,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,kBAAkB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACxC,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,2EAA2E;IAC3E,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACjC;AAED,MAAM,WAAW,kBAAkB;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,YAAY,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;IACvC,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC5B;AAED,wBAAsB,aAAa,CACjC,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,iBAAiB,GACtB,OAAO,CAAC,OAAO,CAAC,CAWlB;AAED,wBAAsB,cAAc,CAClC,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,kBAAkB,GACvB,OAAO,CAAC,OAAO,CAAC,CAclB;AAID;;;;;;GAMG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,GACb,OAAO,CAAC;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAyBvC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contacts: the people and the companies the books name.
|
|
3
|
+
*/
|
|
4
|
+
import { BooksError } from './backend.js';
|
|
5
|
+
import * as columns from './columns.js';
|
|
6
|
+
import { createdBefore, only } from './shared.js';
|
|
7
|
+
export const CONTACT_TYPES = ['customer', 'supplier', 'both', 'employee', 'other'];
|
|
8
|
+
export async function createContact(backend, args) {
|
|
9
|
+
const before = await createdBefore(backend, 'contacts', args.company_id, args.client_ref, columns.CONTACT);
|
|
10
|
+
if (before !== undefined)
|
|
11
|
+
return { contact: before, replayed: true };
|
|
12
|
+
const { company_id, ...rest } = args;
|
|
13
|
+
const row = { company_id, ...rest };
|
|
14
|
+
const created = only(await backend.insert('contacts', [row], columns.CONTACT), 'the contact could not be created');
|
|
15
|
+
return { contact: created };
|
|
16
|
+
}
|
|
17
|
+
export async function searchContacts(backend, args) {
|
|
18
|
+
const where = [{ column: 'company_id', op: 'eq', value: args.company_id }];
|
|
19
|
+
if (args.query !== undefined)
|
|
20
|
+
where.push({ column: 'name', op: 'ilike', value: `%${args.query}%` });
|
|
21
|
+
if (args.contact_type !== undefined)
|
|
22
|
+
where.push({ column: 'contact_type', op: 'eq', value: args.contact_type });
|
|
23
|
+
if (args.vat_number !== undefined)
|
|
24
|
+
where.push({ column: 'vat_number', op: 'eq', value: args.vat_number });
|
|
25
|
+
const contacts = await backend.select({
|
|
26
|
+
table: 'contacts',
|
|
27
|
+
columns: columns.CONTACT,
|
|
28
|
+
where,
|
|
29
|
+
order: [{ column: 'name' }],
|
|
30
|
+
limit: args.limit ?? 50,
|
|
31
|
+
});
|
|
32
|
+
return { contacts, count: contacts.length };
|
|
33
|
+
}
|
|
34
|
+
const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
35
|
+
/**
|
|
36
|
+
* The contact a person means by an id, a name or part of one.
|
|
37
|
+
*
|
|
38
|
+
* One match is the answer; several are listed and refused, because an invoice
|
|
39
|
+
* addressed to the wrong one of two namesakes is posted before anybody
|
|
40
|
+
* notices. An exact name wins over names that merely contain it.
|
|
41
|
+
*/
|
|
42
|
+
export async function resolveContact(backend, company, wanted) {
|
|
43
|
+
if (UUID.test(wanted))
|
|
44
|
+
return { id: wanted.toLowerCase(), name: wanted };
|
|
45
|
+
const found = await backend.select({
|
|
46
|
+
table: 'contacts',
|
|
47
|
+
columns: ['id', 'name'],
|
|
48
|
+
where: [
|
|
49
|
+
{ column: 'company_id', op: 'eq', value: company },
|
|
50
|
+
{ column: 'name', op: 'ilike', value: `%${wanted}%` },
|
|
51
|
+
],
|
|
52
|
+
order: [{ column: 'name' }],
|
|
53
|
+
limit: 20,
|
|
54
|
+
});
|
|
55
|
+
const exact = found.filter((contact) => contact.name.toLowerCase() === wanted.toLowerCase());
|
|
56
|
+
const matches = exact.length > 0 ? exact : found;
|
|
57
|
+
if (matches.length === 0) {
|
|
58
|
+
throw new BooksError(`unknown_contact: no contact of this company is called ${wanted}, or has it in its name.`);
|
|
59
|
+
}
|
|
60
|
+
if (matches.length > 1) {
|
|
61
|
+
throw new BooksError(`ambiguous_contact: ${wanted} is ${matches.length} contacts: ${matches
|
|
62
|
+
.map((contact) => `${contact.name} (${contact.id})`)
|
|
63
|
+
.join(', ')}. Name one by its id.`);
|
|
64
|
+
}
|
|
65
|
+
return matches[0];
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=contacts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contacts.js","sourceRoot":"","sources":["../../src/books/contacts.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAuC,MAAM,cAAc,CAAC;AAC/E,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAGlD,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,CAA2C,CAAC;AA2B7H,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,OAAgB,EAChB,IAAuB;IAEvB,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,OAAO,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IAC3G,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAErE,MAAM,EAAE,UAAU,EAAE,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC;IACrC,MAAM,GAAG,GAAQ,EAAE,UAAU,EAAE,GAAG,IAAI,EAAE,CAAC;IACzC,MAAM,OAAO,GAAG,IAAI,CAClB,MAAM,OAAO,CAAC,MAAM,CAAM,UAAU,EAAE,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,EAC7D,kCAAkC,CACnC,CAAC;IACF,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;AAC9B,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,OAAgB,EAChB,IAAwB;IAExB,MAAM,KAAK,GAAa,CAAC,EAAE,MAAM,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
|
|
2
|
+
* Documents: drafts and their lines, and the one call that books them.
|
|
3
|
+
*
|
|
4
|
+
* One rule holds everywhere here: the ledger is written by the schema, never
|
|
5
|
+
* by this package. `post_document` carries the accounting rules — balance,
|
|
6
|
+
* numbering, period locks, the counterpart that is the difference of
|
|
7
|
+
* everything else — and this file calls it. Nothing here inserts an `entries`
|
|
8
|
+
* or an `entry_lines` row. Direct inserts are for the objects a person types:
|
|
9
|
+
* draft documents and their lines.
|
|
10
|
+
*/
|
|
11
|
+
import { type Backend } from './backend.js';
|
|
12
|
+
import type { DocType } from '../types.js';
|
|
13
|
+
export declare const DOC_TYPES: readonly ["sale_invoice", "sale_credit_note", "sale_quote", "purchase_invoice", "purchase_credit_note", "purchase_order"];
|
|
14
|
+
export declare const DOCUMENT_STATES: readonly ["draft", "posted", "cancelled"];
|
|
15
|
+
export declare const PAYMENT_STATES: readonly ["not_paid", "partially_paid", "paid", "overpaid", "reversed"];
|
|
16
|
+
/** A line as a caller writes it: codes or ids, and whatever a product can fill in. */
|
|
17
|
+
export interface LineArgs {
|
|
18
|
+
name?: string | undefined;
|
|
19
|
+
description?: string | undefined;
|
|
20
|
+
quantity?: string | number | undefined;
|
|
21
|
+
unit_code?: string | undefined;
|
|
22
|
+
unit_price?: string | number | undefined;
|
|
23
|
+
discount_percent?: string | number | undefined;
|
|
24
|
+
product_id?: string | undefined;
|
|
25
|
+
product_code?: string | undefined;
|
|
26
|
+
account_id?: string | undefined;
|
|
27
|
+
account_code?: string | undefined;
|
|
28
|
+
tax_id?: string | undefined;
|
|
29
|
+
tax_code?: string | undefined;
|
|
30
|
+
}
|
|
31
|
+
export interface CreateDocumentArgs {
|
|
32
|
+
company_id: string;
|
|
33
|
+
doc_type: DocType;
|
|
34
|
+
contact_id: string;
|
|
35
|
+
document_date: string;
|
|
36
|
+
due_date?: string | undefined;
|
|
37
|
+
accounting_date?: string | undefined;
|
|
38
|
+
number?: string | undefined;
|
|
39
|
+
supplier_reference?: string | undefined;
|
|
40
|
+
currency_code?: string | undefined;
|
|
41
|
+
journal_id?: string | undefined;
|
|
42
|
+
payment_reference?: string | undefined;
|
|
43
|
+
/** Your own reference. Creating twice under one reference creates once. */
|
|
44
|
+
client_ref?: string | undefined;
|
|
45
|
+
lines: LineArgs[];
|
|
46
|
+
}
|
|
47
|
+
export interface UpdateDocumentLinesArgs {
|
|
48
|
+
document_id: string;
|
|
49
|
+
lines: LineArgs[];
|
|
50
|
+
}
|
|
51
|
+
export interface AddDocumentLineArgs {
|
|
52
|
+
document_id: string;
|
|
53
|
+
line: LineArgs;
|
|
54
|
+
}
|
|
55
|
+
export interface PostDocumentArgs {
|
|
56
|
+
document_id: string;
|
|
57
|
+
/** Ask the database what posting would write, and write nothing. */
|
|
58
|
+
dry_run?: boolean | undefined;
|
|
59
|
+
}
|
|
60
|
+
export interface ListDocumentsArgs {
|
|
61
|
+
company_id: string;
|
|
62
|
+
doc_type?: DocType | undefined;
|
|
63
|
+
state?: (typeof DOCUMENT_STATES)[number] | undefined;
|
|
64
|
+
payment_state?: (typeof PAYMENT_STATES)[number] | undefined;
|
|
65
|
+
contact_id?: string | undefined;
|
|
66
|
+
from?: string | undefined;
|
|
67
|
+
to?: string | undefined;
|
|
68
|
+
/** Posted and still owed: not paid, or partially. Drafts are owed by nobody. */
|
|
69
|
+
unpaid?: boolean | undefined;
|
|
70
|
+
limit?: number | undefined;
|
|
71
|
+
}
|
|
72
|
+
export interface GetDocumentArgs {
|
|
73
|
+
document_id: string;
|
|
74
|
+
}
|
|
75
|
+
export declare function createDocument(backend: Backend, args: CreateDocumentArgs): Promise<unknown>;
|
|
76
|
+
/** One more line at the end of a draft. The lines already there are untouched. */
|
|
77
|
+
export declare function addDocumentLine(backend: Backend, args: AddDocumentLineArgs): Promise<unknown>;
|
|
78
|
+
export declare function updateDocumentLines(backend: Backend, args: UpdateDocumentLinesArgs): Promise<unknown>;
|
|
79
|
+
export declare function postDocument(backend: Backend, args: PostDocumentArgs): Promise<unknown>;
|
|
80
|
+
export declare function listDocuments(backend: Backend, args: ListDocumentsArgs): Promise<unknown>;
|
|
81
|
+
export declare function getDocument(backend: Backend, args: GetDocumentArgs): Promise<unknown>;
|
|
82
|
+
/**
|
|
83
|
+
* The document a person means: its id, its number, or the reference its
|
|
84
|
+
* creator gave it. A draft has no number yet, which is what the third is for.
|
|
85
|
+
*/
|
|
86
|
+
export declare function resolveDocument(backend: Backend, company: string, wanted: string): Promise<string>;
|
|
87
|
+
//# sourceMappingURL=documents.d.ts.map
|