@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
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,466 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types of the Ekwo OS schema.
|
|
3
|
+
*
|
|
4
|
+
* Hand written rather than generated, so they stay readable and so the
|
|
5
|
+
* package has no build-time dependency on a running database. They mirror
|
|
6
|
+
* `supabase/migrations/`; `docs/schema.md` is the prose version.
|
|
7
|
+
*/
|
|
8
|
+
export type Uuid = string;
|
|
9
|
+
/** ISO 8601 calendar date, `YYYY-MM-DD`. */
|
|
10
|
+
export type IsoDate = string;
|
|
11
|
+
/** ISO 8601 timestamp with time zone. */
|
|
12
|
+
export type IsoTimestamp = string;
|
|
13
|
+
/** Postgres `numeric`, carried as a string so no cent is lost to a float. */
|
|
14
|
+
export type Decimal = string;
|
|
15
|
+
/**
|
|
16
|
+
* One vocabulary for the whole installation. `instance_admin` is held by a
|
|
17
|
+
* row in `instance_admins`; the others are per company and live in
|
|
18
|
+
* `company_members`, which refuses `instance_admin` by check constraint.
|
|
19
|
+
* `client` is the person whose company it is, in the installation of whoever
|
|
20
|
+
* keeps their books: every read, and handing a piece over.
|
|
21
|
+
*/
|
|
22
|
+
export type MemberRole = 'instance_admin' | 'owner' | 'accountant' | 'viewer' | 'client';
|
|
23
|
+
export type CompanyRole = Exclude<MemberRole, 'instance_admin'>;
|
|
24
|
+
export type InstanceEdition = 'community' | 'cloud';
|
|
25
|
+
/**
|
|
26
|
+
* The installation itself: exactly one row, written by the installer.
|
|
27
|
+
*
|
|
28
|
+
* There is no `tenant_id` in this schema because the instance is the tenant.
|
|
29
|
+
* `contact_email` and `registered_at` are an opt-in: they are empty on a
|
|
30
|
+
* fresh install, nothing writes them unless the operator asks, and nothing
|
|
31
|
+
* checks them.
|
|
32
|
+
*/
|
|
33
|
+
export interface Instance {
|
|
34
|
+
id: 1;
|
|
35
|
+
instance_id: Uuid;
|
|
36
|
+
organization_name: string;
|
|
37
|
+
country: string;
|
|
38
|
+
edition: InstanceEdition;
|
|
39
|
+
schema_version: string;
|
|
40
|
+
installed_at: IsoTimestamp;
|
|
41
|
+
contact_email: string | null;
|
|
42
|
+
registered_at: IsoTimestamp | null;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* An instance administrator: creates companies and invites members. The
|
|
46
|
+
* table name is the role, so there is no role column. `user_id` is a real
|
|
47
|
+
* foreign key onto the customer's own `auth.users`.
|
|
48
|
+
*/
|
|
49
|
+
export interface InstanceAdmin {
|
|
50
|
+
user_id: Uuid;
|
|
51
|
+
created_at: IsoTimestamp;
|
|
52
|
+
}
|
|
53
|
+
/** True when the operator has opted into being registered with Ekwo. */
|
|
54
|
+
export declare function isRegistered(instance: Instance): boolean;
|
|
55
|
+
export declare const ACCOUNT_TYPES: readonly ["asset_receivable", "asset_cash", "asset_current", "asset_prepayments", "asset_fixed", "asset_non_current", "liability_payable", "liability_credit_card", "liability_current", "liability_non_current", "equity", "equity_retained", "income", "income_other", "expense", "expense_direct_cost", "expense_depreciation", "off_balance"];
|
|
56
|
+
export type AccountType = (typeof ACCOUNT_TYPES)[number];
|
|
57
|
+
export type InternalGroup = 'asset' | 'liability' | 'equity' | 'income' | 'expense' | 'off_balance';
|
|
58
|
+
/** The balance-sheet group of an account type, as the database derives it. */
|
|
59
|
+
export declare function internalGroup(type: AccountType): InternalGroup;
|
|
60
|
+
export type JournalType = 'sales' | 'purchase' | 'bank' | 'cash' | 'general' | 'opening';
|
|
61
|
+
export type EntryState = 'draft' | 'posted' | 'cancelled';
|
|
62
|
+
export type ContactType = 'customer' | 'supplier' | 'both' | 'employee' | 'other';
|
|
63
|
+
export type DocType = 'sale_invoice' | 'sale_credit_note' | 'sale_quote' | 'purchase_invoice' | 'purchase_credit_note' | 'purchase_order';
|
|
64
|
+
export type DocState = 'draft' | 'posted' | 'cancelled';
|
|
65
|
+
export type PaymentState = 'not_paid' | 'partially_paid' | 'paid' | 'overpaid' | 'reversed';
|
|
66
|
+
export type DocumentLineType = 'product' | 'section' | 'note';
|
|
67
|
+
export type TaxAmountType = 'percent' | 'fixed';
|
|
68
|
+
export type TaxScope = 'sale' | 'purchase' | 'both';
|
|
69
|
+
export type TaxDocumentKind = 'invoice' | 'credit_note';
|
|
70
|
+
export type TaxPostingType = 'base' | 'tax';
|
|
71
|
+
/**
|
|
72
|
+
* How an operation is treated for the return, in the order the Postgres enum
|
|
73
|
+
* `tax_treatment` declares them.
|
|
74
|
+
*
|
|
75
|
+
* A value, not a union of string literals, because three places say this list
|
|
76
|
+
* — the enum, `packs/schema/pack.1.json` and this file — and until one of them
|
|
77
|
+
* could be read at runtime nothing compared them. `tests/vat_codes.test.ts`
|
|
78
|
+
* now does, in order, so a treatment added to the database and forgotten here
|
|
79
|
+
* fails rather than silently narrowing what a pack may declare.
|
|
80
|
+
*
|
|
81
|
+
* `foreign_services_received` is a service bought from a supplier who is not
|
|
82
|
+
* established in the buyer's country and who charges no tax on it, the buyer
|
|
83
|
+
* accounting for it themselves under the general business-to-business rule of
|
|
84
|
+
* articles 44 and 196 of Directive 2006/112/EC. It is the sibling of
|
|
85
|
+
* `intracom_acquisition_services` for a supplier the intra-Union rules do not
|
|
86
|
+
* reach, and it says nothing about where that supplier is: the rule is about
|
|
87
|
+
* establishment, not about membership of the Union.
|
|
88
|
+
*
|
|
89
|
+
* `self_assessed` is a tax a buyer owes **directly to an administration under
|
|
90
|
+
* that administration's own law**, and computes and declares themselves:
|
|
91
|
+
* American use tax, imposed on the buyer and not on a supplier the levying
|
|
92
|
+
* State can reach. It is not the reverse charge beside it, which moves the
|
|
93
|
+
* liability for a value added tax from a supplier who was relieved of it and
|
|
94
|
+
* which the buyer deducts again at the other end. Nothing is deducted here,
|
|
95
|
+
* and whether the tax is a cost is said by the postings.
|
|
96
|
+
*/
|
|
97
|
+
export declare const TAX_TREATMENTS: readonly ["domestic", "domestic_reverse_charge", "self_assessed", "intracom_goods", "intracom_services", "intracom_triangular", "intracom_acquisition_goods", "intracom_acquisition_services", "foreign_services_received", "export", "import", "exempt", "not_subject"];
|
|
98
|
+
export type TaxTreatment = (typeof TAX_TREATMENTS)[number];
|
|
99
|
+
/**
|
|
100
|
+
* What a tax turns on that the ledger cannot see.
|
|
101
|
+
*
|
|
102
|
+
* A closed vocabulary, written in the same three places as the treatments
|
|
103
|
+
* above and compared by the same test. It records **what the question is**
|
|
104
|
+
* and never how to answer it: there is no value beside any of these words —
|
|
105
|
+
* no threshold amount, no certificate number, no operator and no expression —
|
|
106
|
+
* because a pack that could carry the test would be a pack that executes.
|
|
107
|
+
* The amount a threshold is set at and the contents a certificate must have
|
|
108
|
+
* are in the article the tax already cites.
|
|
109
|
+
*
|
|
110
|
+
* - `buyer_certificate`: the buyer hands the seller a document the seller has
|
|
111
|
+
* to hold and be able to produce — the American resale certificate.
|
|
112
|
+
* - `buyer_status`: a quality of the buyer the statute names, such as a
|
|
113
|
+
* government body the law exempts as such.
|
|
114
|
+
* - `transport_evidence`: proof that what was sold went where the exemption
|
|
115
|
+
* requires it to have gone.
|
|
116
|
+
* - `seller_threshold`: a running total the seller crossed, or has not —
|
|
117
|
+
* economic nexus, a distance-selling limit, a small-business franchise.
|
|
118
|
+
* - `supply_nature`: what is supplied, classified more finely than any ledger
|
|
119
|
+
* holds it: food products, but not hot, carbonated or alcoholic ones.
|
|
120
|
+
*/
|
|
121
|
+
export declare const TAX_CONDITIONS: readonly ["buyer_certificate", "buyer_status", "transport_evidence", "seller_threshold", "supply_nature"];
|
|
122
|
+
export type TaxCondition = (typeof TAX_CONDITIONS)[number];
|
|
123
|
+
export type PaymentDirection = 'inbound' | 'outbound';
|
|
124
|
+
export type BankTransactionState = 'pending' | 'reconciled' | 'ignored';
|
|
125
|
+
/** True for the four document types that produce a journal entry. */
|
|
126
|
+
export declare function isAccountable(type: DocType): boolean;
|
|
127
|
+
/** True for sales documents; the rest are purchases. */
|
|
128
|
+
export declare function isSale(type: DocType): boolean;
|
|
129
|
+
export declare function isCreditNote(type: DocType): boolean;
|
|
130
|
+
export interface Company {
|
|
131
|
+
id: Uuid;
|
|
132
|
+
name: string;
|
|
133
|
+
legal_name: string | null;
|
|
134
|
+
legal_form: string | null;
|
|
135
|
+
country: string;
|
|
136
|
+
fiscal_country: string;
|
|
137
|
+
vat_number: string | null;
|
|
138
|
+
registration_number: string | null;
|
|
139
|
+
address_line1: string | null;
|
|
140
|
+
postal_code: string | null;
|
|
141
|
+
city: string | null;
|
|
142
|
+
email: string | null;
|
|
143
|
+
/** BT-34, the electronic address the company sends and receives under: a scheme of the EAS list and a value, both or neither. */
|
|
144
|
+
peppol_scheme: string | null;
|
|
145
|
+
peppol_identifier: string | null;
|
|
146
|
+
currency_code: string;
|
|
147
|
+
lock_date: IsoDate | null;
|
|
148
|
+
tax_lock_date: IsoDate | null;
|
|
149
|
+
receivable_account_id: Uuid | null;
|
|
150
|
+
payable_account_id: Uuid | null;
|
|
151
|
+
suspense_account_id: Uuid | null;
|
|
152
|
+
retained_earnings_account_id: Uuid | null;
|
|
153
|
+
sales_journal_id: Uuid | null;
|
|
154
|
+
purchase_journal_id: Uuid | null;
|
|
155
|
+
miscellaneous_journal_id: Uuid | null;
|
|
156
|
+
}
|
|
157
|
+
export interface CompanyMember {
|
|
158
|
+
company_id: Uuid;
|
|
159
|
+
user_id: Uuid;
|
|
160
|
+
role: CompanyRole;
|
|
161
|
+
created_at: IsoTimestamp;
|
|
162
|
+
}
|
|
163
|
+
export interface FiscalYear {
|
|
164
|
+
id: Uuid;
|
|
165
|
+
company_id: Uuid;
|
|
166
|
+
name: string;
|
|
167
|
+
start_date: IsoDate;
|
|
168
|
+
end_date: IsoDate;
|
|
169
|
+
is_closed: boolean;
|
|
170
|
+
}
|
|
171
|
+
export interface Account {
|
|
172
|
+
id: Uuid;
|
|
173
|
+
company_id: Uuid;
|
|
174
|
+
code: string;
|
|
175
|
+
name: string;
|
|
176
|
+
account_type: AccountType;
|
|
177
|
+
internal_group: InternalGroup;
|
|
178
|
+
carries_forward: boolean;
|
|
179
|
+
reconcilable: boolean;
|
|
180
|
+
currency_code: string | null;
|
|
181
|
+
parent_id: Uuid | null;
|
|
182
|
+
deprecated: boolean;
|
|
183
|
+
}
|
|
184
|
+
export interface Journal {
|
|
185
|
+
id: Uuid;
|
|
186
|
+
company_id: Uuid;
|
|
187
|
+
code: string;
|
|
188
|
+
name: string;
|
|
189
|
+
journal_type: JournalType;
|
|
190
|
+
default_account_id: Uuid | null;
|
|
191
|
+
suspense_account_id: Uuid | null;
|
|
192
|
+
bank_account_id: Uuid | null;
|
|
193
|
+
active: boolean;
|
|
194
|
+
}
|
|
195
|
+
export interface Contact {
|
|
196
|
+
id: Uuid;
|
|
197
|
+
company_id: Uuid;
|
|
198
|
+
/** The creator's own reference: the idempotency key of the creation. */
|
|
199
|
+
client_ref: string | null;
|
|
200
|
+
name: string;
|
|
201
|
+
contact_type: ContactType;
|
|
202
|
+
parent_id: Uuid | null;
|
|
203
|
+
vat_number: string | null;
|
|
204
|
+
auxiliary_code: string | null;
|
|
205
|
+
email: string | null;
|
|
206
|
+
country: string | null;
|
|
207
|
+
payment_terms_days: number;
|
|
208
|
+
receivable_account_id: Uuid | null;
|
|
209
|
+
payable_account_id: Uuid | null;
|
|
210
|
+
peppol_scheme: string | null;
|
|
211
|
+
peppol_identifier: string | null;
|
|
212
|
+
active: boolean;
|
|
213
|
+
}
|
|
214
|
+
export interface Tax {
|
|
215
|
+
id: Uuid;
|
|
216
|
+
company_id: Uuid;
|
|
217
|
+
code: string;
|
|
218
|
+
name: string;
|
|
219
|
+
amount_type: TaxAmountType;
|
|
220
|
+
amount: Decimal;
|
|
221
|
+
applies_to: TaxScope;
|
|
222
|
+
treatment: TaxTreatment;
|
|
223
|
+
country: string | null;
|
|
224
|
+
valid_from: IsoDate;
|
|
225
|
+
valid_to: IsoDate | null;
|
|
226
|
+
legal_reference: string | null;
|
|
227
|
+
vat_category: string | null;
|
|
228
|
+
active: boolean;
|
|
229
|
+
}
|
|
230
|
+
export interface TaxPosting {
|
|
231
|
+
id: Uuid;
|
|
232
|
+
tax_id: Uuid;
|
|
233
|
+
company_id: Uuid;
|
|
234
|
+
document_kind: TaxDocumentKind;
|
|
235
|
+
posting_type: TaxPostingType;
|
|
236
|
+
factor_percent: Decimal;
|
|
237
|
+
account_id: Uuid | null;
|
|
238
|
+
/** The box this posting is known by: the first of `declaration_boxes`. */
|
|
239
|
+
declaration_box: string | null;
|
|
240
|
+
/**
|
|
241
|
+
* Every box the form prints this one amount in. Almost always the single box
|
|
242
|
+
* above; longer where the form shows one figure in boxes that are not sums
|
|
243
|
+
* of one another.
|
|
244
|
+
*/
|
|
245
|
+
declaration_boxes: string[] | null;
|
|
246
|
+
box_factor_percent: Decimal;
|
|
247
|
+
sequence: number;
|
|
248
|
+
}
|
|
249
|
+
export interface Entry {
|
|
250
|
+
id: Uuid;
|
|
251
|
+
company_id: Uuid;
|
|
252
|
+
journal_id: Uuid;
|
|
253
|
+
fiscal_year_id: Uuid | null;
|
|
254
|
+
number: string | null;
|
|
255
|
+
entry_date: IsoDate;
|
|
256
|
+
reference: string | null;
|
|
257
|
+
description: string | null;
|
|
258
|
+
state: EntryState;
|
|
259
|
+
document_id: Uuid | null;
|
|
260
|
+
total_debit: Decimal;
|
|
261
|
+
total_credit: Decimal;
|
|
262
|
+
is_balanced: boolean;
|
|
263
|
+
posted_at: IsoTimestamp | null;
|
|
264
|
+
}
|
|
265
|
+
export interface EntryLine {
|
|
266
|
+
id: Uuid;
|
|
267
|
+
entry_id: Uuid;
|
|
268
|
+
company_id: Uuid;
|
|
269
|
+
account_id: Uuid;
|
|
270
|
+
sequence: number;
|
|
271
|
+
name: string | null;
|
|
272
|
+
debit: Decimal;
|
|
273
|
+
credit: Decimal;
|
|
274
|
+
balance: Decimal;
|
|
275
|
+
contact_id: Uuid | null;
|
|
276
|
+
date_maturity: IsoDate | null;
|
|
277
|
+
tax_id: Uuid | null;
|
|
278
|
+
tax_line: boolean;
|
|
279
|
+
declaration_box: string | null;
|
|
280
|
+
box_amount: Decimal | null;
|
|
281
|
+
matching_number: string | null;
|
|
282
|
+
matched_amount: Decimal;
|
|
283
|
+
}
|
|
284
|
+
export interface EkwoDocument {
|
|
285
|
+
id: Uuid;
|
|
286
|
+
company_id: Uuid;
|
|
287
|
+
doc_type: DocType;
|
|
288
|
+
state: DocState;
|
|
289
|
+
payment_state: PaymentState;
|
|
290
|
+
number: string | null;
|
|
291
|
+
supplier_reference: string | null;
|
|
292
|
+
contact_id: Uuid;
|
|
293
|
+
journal_id: Uuid | null;
|
|
294
|
+
document_date: IsoDate;
|
|
295
|
+
accounting_date: IsoDate | null;
|
|
296
|
+
due_date: IsoDate | null;
|
|
297
|
+
currency_code: string;
|
|
298
|
+
buyer_reference: string | null;
|
|
299
|
+
order_reference: string | null;
|
|
300
|
+
payment_reference: string | null;
|
|
301
|
+
/** The creator's own reference: the idempotency key of the creation. */
|
|
302
|
+
client_ref: string | null;
|
|
303
|
+
amount_untaxed: Decimal;
|
|
304
|
+
amount_tax: Decimal;
|
|
305
|
+
amount_total: Decimal;
|
|
306
|
+
amount_paid: Decimal;
|
|
307
|
+
amount_residual: Decimal;
|
|
308
|
+
reversed_document_id: Uuid | null;
|
|
309
|
+
entry_id: Uuid | null;
|
|
310
|
+
sent_at: IsoTimestamp | null;
|
|
311
|
+
}
|
|
312
|
+
/** What a product is: a service or goods. They are not taxed the same way. */
|
|
313
|
+
export type ProductKind = 'service' | 'goods';
|
|
314
|
+
/**
|
|
315
|
+
* The unit codes worth offering, out of UN/ECE recommendation 20.
|
|
316
|
+
*
|
|
317
|
+
* The recommendation carries some eighteen hundred, and an invoice for
|
|
318
|
+
* professional services uses five of them. This is the short list a client
|
|
319
|
+
* proposes; `products.unit_code` accepts any well-formed code, because
|
|
320
|
+
* refusing `KWH` or `TNE` in the database because a list here is short would
|
|
321
|
+
* be the list deciding what a business may sell.
|
|
322
|
+
*/
|
|
323
|
+
export declare const UNIT_CODES: {
|
|
324
|
+
readonly C62: "one (a piece)";
|
|
325
|
+
readonly HUR: "hour";
|
|
326
|
+
readonly DAY: "day";
|
|
327
|
+
readonly MON: "month";
|
|
328
|
+
readonly ANN: "year";
|
|
329
|
+
readonly KGM: "kilogram";
|
|
330
|
+
readonly GRM: "gram";
|
|
331
|
+
readonly TNE: "tonne";
|
|
332
|
+
readonly LTR: "litre";
|
|
333
|
+
readonly MTR: "metre";
|
|
334
|
+
readonly MTK: "square metre";
|
|
335
|
+
readonly MTQ: "cubic metre";
|
|
336
|
+
readonly KMT: "kilometre";
|
|
337
|
+
readonly KWH: "kilowatt hour";
|
|
338
|
+
readonly SET: "set";
|
|
339
|
+
readonly PR: "pair";
|
|
340
|
+
};
|
|
341
|
+
export type UnitCode = keyof typeof UNIT_CODES;
|
|
342
|
+
/** True for one of the codes above. A code outside it may still be valid. */
|
|
343
|
+
export declare function isUnitCode(value: string): value is UnitCode;
|
|
344
|
+
/**
|
|
345
|
+
* True for anything shaped like a UN/ECE rec. 20 code — the rule the database
|
|
346
|
+
* enforces on `products.unit_code`, repeated here so a client can refuse the
|
|
347
|
+
* value before the round trip rather than after it.
|
|
348
|
+
*/
|
|
349
|
+
export declare function isWellFormedUnitCode(value: string): boolean;
|
|
350
|
+
/**
|
|
351
|
+
* A catalogue row. It fills a document line in and never constrains it: the
|
|
352
|
+
* line keeps its own text, price, account and tax once it has them.
|
|
353
|
+
*/
|
|
354
|
+
export interface Product {
|
|
355
|
+
id: Uuid;
|
|
356
|
+
company_id: Uuid;
|
|
357
|
+
/** EN 16931 BT-155, the seller's item identifier. Unique in the company. */
|
|
358
|
+
code: string;
|
|
359
|
+
/** EN 16931 BT-153. */
|
|
360
|
+
name: string;
|
|
361
|
+
/** EN 16931 BT-154. */
|
|
362
|
+
description: string | null;
|
|
363
|
+
kind: ProductKind;
|
|
364
|
+
/** UN/ECE recommendation 20, BT-130. */
|
|
365
|
+
unit_code: string;
|
|
366
|
+
currency_code: string;
|
|
367
|
+
sale_price: Decimal | null;
|
|
368
|
+
purchase_price: Decimal | null;
|
|
369
|
+
sale_account_id: Uuid | null;
|
|
370
|
+
purchase_account_id: Uuid | null;
|
|
371
|
+
sale_tax_id: Uuid | null;
|
|
372
|
+
purchase_tax_id: Uuid | null;
|
|
373
|
+
active: boolean;
|
|
374
|
+
}
|
|
375
|
+
export interface DocumentLine {
|
|
376
|
+
id: Uuid;
|
|
377
|
+
document_id: Uuid;
|
|
378
|
+
company_id: Uuid;
|
|
379
|
+
sequence: number;
|
|
380
|
+
line_type: DocumentLineType;
|
|
381
|
+
name: string;
|
|
382
|
+
quantity: Decimal;
|
|
383
|
+
unit_code: string;
|
|
384
|
+
unit_price: Decimal;
|
|
385
|
+
discount_percent: Decimal;
|
|
386
|
+
tax_id: Uuid | null;
|
|
387
|
+
account_id: Uuid | null;
|
|
388
|
+
/** The catalogue row it was filled in from, when there was one. */
|
|
389
|
+
product_id: Uuid | null;
|
|
390
|
+
/** EN 16931 BT-154; `name` is BT-153. */
|
|
391
|
+
description: string | null;
|
|
392
|
+
vat_category: string | null;
|
|
393
|
+
vat_rate: Decimal | null;
|
|
394
|
+
amount_untaxed: Decimal;
|
|
395
|
+
/**
|
|
396
|
+
* The unit price was quoted with the tax in it. Snapshotted from the tax
|
|
397
|
+
* while the document is a draft and frozen when it is posted, so `unit_price`
|
|
398
|
+
* is the gross price and `amount_untaxed` the net one.
|
|
399
|
+
*/
|
|
400
|
+
unit_price_includes_tax: boolean;
|
|
401
|
+
/** The gross the line was quoted at. Null where the price excludes the tax. */
|
|
402
|
+
amount_incl_tax: Decimal | null;
|
|
403
|
+
}
|
|
404
|
+
/** One row of the `document_line_items` view: a line with its EN 16931 item terms. */
|
|
405
|
+
export interface DocumentLineItem {
|
|
406
|
+
document_line_id: Uuid;
|
|
407
|
+
document_id: Uuid;
|
|
408
|
+
company_id: Uuid;
|
|
409
|
+
sequence: number;
|
|
410
|
+
line_type: DocumentLineType;
|
|
411
|
+
/** BT-153. */
|
|
412
|
+
item_name: string;
|
|
413
|
+
/** BT-154. */
|
|
414
|
+
item_description: string | null;
|
|
415
|
+
/** BT-155, which is `products.code`. Null on a line with no product. */
|
|
416
|
+
seller_item_identifier: string | null;
|
|
417
|
+
product_id: Uuid | null;
|
|
418
|
+
product_kind: ProductKind | null;
|
|
419
|
+
quantity: Decimal;
|
|
420
|
+
unit_code: string;
|
|
421
|
+
unit_price: Decimal;
|
|
422
|
+
discount_percent: Decimal;
|
|
423
|
+
amount_untaxed: Decimal;
|
|
424
|
+
tax_id: Uuid | null;
|
|
425
|
+
vat_category: string | null;
|
|
426
|
+
vat_rate: Decimal | null;
|
|
427
|
+
account_id: Uuid | null;
|
|
428
|
+
/** The unit price above was quoted with the tax in it, so it is the gross one. */
|
|
429
|
+
unit_price_includes_tax: boolean;
|
|
430
|
+
/** The gross the line was quoted at. Null where the price excludes the tax. */
|
|
431
|
+
amount_incl_tax: Decimal | null;
|
|
432
|
+
}
|
|
433
|
+
/** One row of `trial_balance(company_id, from, to)`. */
|
|
434
|
+
export interface TrialBalanceRow {
|
|
435
|
+
account_id: Uuid;
|
|
436
|
+
account_code: string;
|
|
437
|
+
account_name: string;
|
|
438
|
+
account_type: AccountType;
|
|
439
|
+
internal_group: InternalGroup;
|
|
440
|
+
opening_balance: Decimal;
|
|
441
|
+
debit: Decimal;
|
|
442
|
+
credit: Decimal;
|
|
443
|
+
closing_balance: Decimal;
|
|
444
|
+
}
|
|
445
|
+
/** One row of `aged_balance(company_id, at, group)`. */
|
|
446
|
+
export interface AgedBalanceRow {
|
|
447
|
+
contact_id: Uuid | null;
|
|
448
|
+
contact_name: string | null;
|
|
449
|
+
account_id: Uuid;
|
|
450
|
+
account_code: string;
|
|
451
|
+
not_due: Decimal | null;
|
|
452
|
+
days_1_30: Decimal | null;
|
|
453
|
+
days_31_60: Decimal | null;
|
|
454
|
+
days_61_90: Decimal | null;
|
|
455
|
+
days_over_90: Decimal | null;
|
|
456
|
+
total: Decimal;
|
|
457
|
+
}
|
|
458
|
+
/** One row of `vat_return(company_id, from, to)`. */
|
|
459
|
+
export interface VatReturnRow {
|
|
460
|
+
box: string;
|
|
461
|
+
kind: 'base' | 'tax' | 'total';
|
|
462
|
+
amount: Decimal;
|
|
463
|
+
/** True for boxes derived from the others, such as Belgian 71 and 72. */
|
|
464
|
+
computed: boolean;
|
|
465
|
+
}
|
|
466
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,MAAM,IAAI,GAAG,MAAM,CAAC;AAC1B,4CAA4C;AAC5C,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC;AAC7B,yCAAyC;AACzC,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC;AAClC,6EAA6E;AAC7E,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC;AAE7B;;;;;;GAMG;AACH,MAAM,MAAM,UAAU,GAAG,gBAAgB,GAAG,OAAO,GAAG,YAAY,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAEzF,MAAM,MAAM,WAAW,GAAG,OAAO,CAAC,UAAU,EAAE,gBAAgB,CAAC,CAAC;AAEhE,MAAM,MAAM,eAAe,GAAG,WAAW,GAAG,OAAO,CAAC;AAEpD;;;;;;;GAOG;AACH,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,CAAC,CAAC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AAE,IAAI,GAAG,IAAI,CAAC;IACxB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,UAAU,EAAE,IAAI,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IACxB,SAAS,EAAE,OAAO,GAAG,IAAI,CAAC;IAC1B,UAAU,EAAE,OAAO,GAAG,IAAI,CAAC;IAC3B,UAAU,EAAE,OAAO,GAAG,IAAI,CAAC;IAC3B,YAAY,EAAE,OAAO,GAAG,IAAI,CAAC;IAC7B,KAAK,EAAE,OAAO,CAAC;CAChB;AAED,qDAAqD;AACrD,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,GAAG,KAAK,GAAG,OAAO,CAAC;IAC/B,MAAM,EAAE,OAAO,CAAC;IAChB,yEAAyE;IACzE,QAAQ,EAAE,OAAO,CAAC;CACnB"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types of the Ekwo OS schema.
|
|
3
|
+
*
|
|
4
|
+
* Hand written rather than generated, so they stay readable and so the
|
|
5
|
+
* package has no build-time dependency on a running database. They mirror
|
|
6
|
+
* `supabase/migrations/`; `docs/schema.md` is the prose version.
|
|
7
|
+
*/
|
|
8
|
+
/** True when the operator has opted into being registered with Ekwo. */
|
|
9
|
+
export function isRegistered(instance) {
|
|
10
|
+
return instance.registered_at !== null;
|
|
11
|
+
}
|
|
12
|
+
export const ACCOUNT_TYPES = [
|
|
13
|
+
'asset_receivable',
|
|
14
|
+
'asset_cash',
|
|
15
|
+
'asset_current',
|
|
16
|
+
'asset_prepayments',
|
|
17
|
+
'asset_fixed',
|
|
18
|
+
'asset_non_current',
|
|
19
|
+
'liability_payable',
|
|
20
|
+
'liability_credit_card',
|
|
21
|
+
'liability_current',
|
|
22
|
+
'liability_non_current',
|
|
23
|
+
'equity',
|
|
24
|
+
'equity_retained',
|
|
25
|
+
'income',
|
|
26
|
+
'income_other',
|
|
27
|
+
'expense',
|
|
28
|
+
'expense_direct_cost',
|
|
29
|
+
'expense_depreciation',
|
|
30
|
+
'off_balance',
|
|
31
|
+
];
|
|
32
|
+
/** The balance-sheet group of an account type, as the database derives it. */
|
|
33
|
+
export function internalGroup(type) {
|
|
34
|
+
if (type === 'off_balance')
|
|
35
|
+
return 'off_balance';
|
|
36
|
+
const prefix = type.split('_')[0];
|
|
37
|
+
switch (prefix) {
|
|
38
|
+
case 'asset':
|
|
39
|
+
return 'asset';
|
|
40
|
+
case 'liability':
|
|
41
|
+
return 'liability';
|
|
42
|
+
case 'equity':
|
|
43
|
+
return 'equity';
|
|
44
|
+
case 'income':
|
|
45
|
+
return 'income';
|
|
46
|
+
default:
|
|
47
|
+
return 'expense';
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* How an operation is treated for the return, in the order the Postgres enum
|
|
52
|
+
* `tax_treatment` declares them.
|
|
53
|
+
*
|
|
54
|
+
* A value, not a union of string literals, because three places say this list
|
|
55
|
+
* — the enum, `packs/schema/pack.1.json` and this file — and until one of them
|
|
56
|
+
* could be read at runtime nothing compared them. `tests/vat_codes.test.ts`
|
|
57
|
+
* now does, in order, so a treatment added to the database and forgotten here
|
|
58
|
+
* fails rather than silently narrowing what a pack may declare.
|
|
59
|
+
*
|
|
60
|
+
* `foreign_services_received` is a service bought from a supplier who is not
|
|
61
|
+
* established in the buyer's country and who charges no tax on it, the buyer
|
|
62
|
+
* accounting for it themselves under the general business-to-business rule of
|
|
63
|
+
* articles 44 and 196 of Directive 2006/112/EC. It is the sibling of
|
|
64
|
+
* `intracom_acquisition_services` for a supplier the intra-Union rules do not
|
|
65
|
+
* reach, and it says nothing about where that supplier is: the rule is about
|
|
66
|
+
* establishment, not about membership of the Union.
|
|
67
|
+
*
|
|
68
|
+
* `self_assessed` is a tax a buyer owes **directly to an administration under
|
|
69
|
+
* that administration's own law**, and computes and declares themselves:
|
|
70
|
+
* American use tax, imposed on the buyer and not on a supplier the levying
|
|
71
|
+
* State can reach. It is not the reverse charge beside it, which moves the
|
|
72
|
+
* liability for a value added tax from a supplier who was relieved of it and
|
|
73
|
+
* which the buyer deducts again at the other end. Nothing is deducted here,
|
|
74
|
+
* and whether the tax is a cost is said by the postings.
|
|
75
|
+
*/
|
|
76
|
+
export const TAX_TREATMENTS = [
|
|
77
|
+
'domestic',
|
|
78
|
+
'domestic_reverse_charge',
|
|
79
|
+
'self_assessed',
|
|
80
|
+
'intracom_goods',
|
|
81
|
+
'intracom_services',
|
|
82
|
+
'intracom_triangular',
|
|
83
|
+
'intracom_acquisition_goods',
|
|
84
|
+
'intracom_acquisition_services',
|
|
85
|
+
'foreign_services_received',
|
|
86
|
+
'export',
|
|
87
|
+
'import',
|
|
88
|
+
'exempt',
|
|
89
|
+
'not_subject',
|
|
90
|
+
];
|
|
91
|
+
/**
|
|
92
|
+
* What a tax turns on that the ledger cannot see.
|
|
93
|
+
*
|
|
94
|
+
* A closed vocabulary, written in the same three places as the treatments
|
|
95
|
+
* above and compared by the same test. It records **what the question is**
|
|
96
|
+
* and never how to answer it: there is no value beside any of these words —
|
|
97
|
+
* no threshold amount, no certificate number, no operator and no expression —
|
|
98
|
+
* because a pack that could carry the test would be a pack that executes.
|
|
99
|
+
* The amount a threshold is set at and the contents a certificate must have
|
|
100
|
+
* are in the article the tax already cites.
|
|
101
|
+
*
|
|
102
|
+
* - `buyer_certificate`: the buyer hands the seller a document the seller has
|
|
103
|
+
* to hold and be able to produce — the American resale certificate.
|
|
104
|
+
* - `buyer_status`: a quality of the buyer the statute names, such as a
|
|
105
|
+
* government body the law exempts as such.
|
|
106
|
+
* - `transport_evidence`: proof that what was sold went where the exemption
|
|
107
|
+
* requires it to have gone.
|
|
108
|
+
* - `seller_threshold`: a running total the seller crossed, or has not —
|
|
109
|
+
* economic nexus, a distance-selling limit, a small-business franchise.
|
|
110
|
+
* - `supply_nature`: what is supplied, classified more finely than any ledger
|
|
111
|
+
* holds it: food products, but not hot, carbonated or alcoholic ones.
|
|
112
|
+
*/
|
|
113
|
+
export const TAX_CONDITIONS = [
|
|
114
|
+
'buyer_certificate',
|
|
115
|
+
'buyer_status',
|
|
116
|
+
'transport_evidence',
|
|
117
|
+
'seller_threshold',
|
|
118
|
+
'supply_nature',
|
|
119
|
+
];
|
|
120
|
+
/** True for the four document types that produce a journal entry. */
|
|
121
|
+
export function isAccountable(type) {
|
|
122
|
+
return type !== 'sale_quote' && type !== 'purchase_order';
|
|
123
|
+
}
|
|
124
|
+
/** True for sales documents; the rest are purchases. */
|
|
125
|
+
export function isSale(type) {
|
|
126
|
+
return type.startsWith('sale_');
|
|
127
|
+
}
|
|
128
|
+
export function isCreditNote(type) {
|
|
129
|
+
return type === 'sale_credit_note' || type === 'purchase_credit_note';
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* The unit codes worth offering, out of UN/ECE recommendation 20.
|
|
133
|
+
*
|
|
134
|
+
* The recommendation carries some eighteen hundred, and an invoice for
|
|
135
|
+
* professional services uses five of them. This is the short list a client
|
|
136
|
+
* proposes; `products.unit_code` accepts any well-formed code, because
|
|
137
|
+
* refusing `KWH` or `TNE` in the database because a list here is short would
|
|
138
|
+
* be the list deciding what a business may sell.
|
|
139
|
+
*/
|
|
140
|
+
export const UNIT_CODES = {
|
|
141
|
+
C62: 'one (a piece)',
|
|
142
|
+
HUR: 'hour',
|
|
143
|
+
DAY: 'day',
|
|
144
|
+
MON: 'month',
|
|
145
|
+
ANN: 'year',
|
|
146
|
+
KGM: 'kilogram',
|
|
147
|
+
GRM: 'gram',
|
|
148
|
+
TNE: 'tonne',
|
|
149
|
+
LTR: 'litre',
|
|
150
|
+
MTR: 'metre',
|
|
151
|
+
MTK: 'square metre',
|
|
152
|
+
MTQ: 'cubic metre',
|
|
153
|
+
KMT: 'kilometre',
|
|
154
|
+
KWH: 'kilowatt hour',
|
|
155
|
+
SET: 'set',
|
|
156
|
+
PR: 'pair',
|
|
157
|
+
};
|
|
158
|
+
/** True for one of the codes above. A code outside it may still be valid. */
|
|
159
|
+
export function isUnitCode(value) {
|
|
160
|
+
return Object.prototype.hasOwnProperty.call(UNIT_CODES, value);
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* True for anything shaped like a UN/ECE rec. 20 code — the rule the database
|
|
164
|
+
* enforces on `products.unit_code`, repeated here so a client can refuse the
|
|
165
|
+
* value before the round trip rather than after it.
|
|
166
|
+
*/
|
|
167
|
+
export function isWellFormedUnitCode(value) {
|
|
168
|
+
return /^[A-Z0-9]{1,3}$/.test(value);
|
|
169
|
+
}
|
|
170
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAqDH,wEAAwE;AACxE,MAAM,UAAU,YAAY,CAAC,QAAkB;IAC7C,OAAO,QAAQ,CAAC,aAAa,KAAK,IAAI,CAAC;AACzC,CAAC;AAED,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,kBAAkB;IAClB,YAAY;IACZ,eAAe;IACf,mBAAmB;IACnB,aAAa;IACb,mBAAmB;IACnB,mBAAmB;IACnB,uBAAuB;IACvB,mBAAmB;IACnB,uBAAuB;IACvB,QAAQ;IACR,iBAAiB;IACjB,QAAQ;IACR,cAAc;IACd,SAAS;IACT,qBAAqB;IACrB,sBAAsB;IACtB,aAAa;CACL,CAAC;AAMX,8EAA8E;AAC9E,MAAM,UAAU,aAAa,CAAC,IAAiB;IAC7C,IAAI,IAAI,KAAK,aAAa;QAAE,OAAO,aAAa,CAAC;IACjD,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAClC,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,OAAO;YACV,OAAO,OAAO,CAAC;QACjB,KAAK,WAAW;YACd,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