@opencxh/domain 1.240.0 → 1.242.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/catalog/codes.d.ts +32 -0
- package/dist/entities/catalog/codes.test.d.ts +1 -0
- package/dist/entities/catalog/index.d.ts +3 -0
- package/dist/entities/catalog/pricing.d.ts +40 -0
- package/dist/entities/catalog/pricing.test.d.ts +1 -0
- package/dist/entities/catalog/types.d.ts +107 -0
- package/dist/entities/document-template/tokens.d.ts +1 -1
- package/dist/entities/document-template/types.d.ts +1 -1
- package/dist/entities/money/index.d.ts +3 -0
- package/dist/entities/money/money.d.ts +66 -0
- package/dist/entities/money/money.test.d.ts +1 -0
- package/dist/entities/money/tax.d.ts +33 -0
- package/dist/entities/money/totals.d.ts +34 -0
- package/dist/entities/money/totals.test.d.ts +1 -0
- package/dist/entities/transaction/convert.d.ts +38 -0
- package/dist/entities/transaction/convert.test.d.ts +1 -0
- package/dist/entities/transaction/document.d.ts +71 -0
- package/dist/entities/transaction/document.test.d.ts +1 -0
- package/dist/entities/transaction/index.d.ts +5 -0
- package/dist/entities/transaction/keys.d.ts +16 -0
- package/dist/entities/transaction/kinds.d.ts +32 -0
- package/dist/entities/transaction/kinds.test.d.ts +1 -0
- package/dist/entities/transaction/types.d.ts +126 -0
- package/dist/index.cjs +21 -19
- package/dist/index.d.ts +3 -0
- package/dist/index.js +2009 -1623
- package/package.json +1 -1
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { Cents } from '../money/money';
|
|
2
|
+
import { OwnerScope } from '../scope/types';
|
|
3
|
+
/**
|
|
4
|
+
* The engine: a quote, an order, an invoice, a credit note.
|
|
5
|
+
*
|
|
6
|
+
* Deliberately **not** called a document. In this repo `Document*` means the sheet of paper —
|
|
7
|
+
* blocks, templates, slots — and that layer renders a contract as readily as an invoice. A
|
|
8
|
+
* transaction *has* a document; it is not one. See `plans/SALES-2026-09-14.md` §2.0.
|
|
9
|
+
*/
|
|
10
|
+
export interface Transaction {
|
|
11
|
+
id: string;
|
|
12
|
+
organizationId: string;
|
|
13
|
+
/** Which kind. See {@link TRANSACTION_KINDS}. In v1 only `quote` is switched on. */
|
|
14
|
+
kindKey: string;
|
|
15
|
+
/**
|
|
16
|
+
* The transaction this one came out of: quote -> order -> invoice.
|
|
17
|
+
*
|
|
18
|
+
* This one field *is* the conversion. `copyFrom()` carries over the lines, the customer, the
|
|
19
|
+
* currency and the price sources; there is no second code path per direction, and "which
|
|
20
|
+
* invoice belongs to this quote" is an indexed query instead of a hunt.
|
|
21
|
+
*/
|
|
22
|
+
sourceTransactionId?: string;
|
|
23
|
+
/** The agreement that produced it, when it came from one. */
|
|
24
|
+
agreementId?: string;
|
|
25
|
+
/** Version within the same quote. A sent quote is revised, never edited. */
|
|
26
|
+
version: number;
|
|
27
|
+
previousVersionId?: string;
|
|
28
|
+
companyId: string;
|
|
29
|
+
contactId?: string;
|
|
30
|
+
/** The work item (the deal) this belongs to. Optional: not every quote has a deal. */
|
|
31
|
+
dealItemId?: string;
|
|
32
|
+
ownerScope: OwnerScope;
|
|
33
|
+
ownerUserId: string;
|
|
34
|
+
title?: string;
|
|
35
|
+
reference?: string;
|
|
36
|
+
currency: string;
|
|
37
|
+
status: TransactionStatus;
|
|
38
|
+
/**
|
|
39
|
+
* The lines, as a column and not a table.
|
|
40
|
+
*
|
|
41
|
+
* A transaction is always read whole and never written half — and freezing has to be
|
|
42
|
+
* indivisible, which two tables without a transaction cannot do. The price is that "revenue per
|
|
43
|
+
* product" is not a query; that question is answered from the facts written at issue time.
|
|
44
|
+
*/
|
|
45
|
+
lines: TransactionLine[];
|
|
46
|
+
/** Recomputed on every save, stored so a list can sort and add up. */
|
|
47
|
+
totals: TransactionTotals;
|
|
48
|
+
/** Reverse charge or exemption: ticked, never derived. Replaces every line's rate. */
|
|
49
|
+
taxOverrideKey?: string;
|
|
50
|
+
introText?: string;
|
|
51
|
+
termsText?: string;
|
|
52
|
+
/** Epoch ms. `issuedAt` set = frozen. */
|
|
53
|
+
issuedAt?: number;
|
|
54
|
+
expiresAt?: number;
|
|
55
|
+
/** Only on a numbered kind, and only at the moment of issuing. */
|
|
56
|
+
number?: string;
|
|
57
|
+
/** Posted — to whichever set of books. Set by the push, never by a person. */
|
|
58
|
+
postedAt?: number;
|
|
59
|
+
/** The rendered PDF in `apps/storage`. A reference, never the content. */
|
|
60
|
+
fileRef?: {
|
|
61
|
+
mountId: string;
|
|
62
|
+
fileId: string;
|
|
63
|
+
};
|
|
64
|
+
/** Which dunning step went out when. This is the whole debtor state; there is no table. */
|
|
65
|
+
dunning?: {
|
|
66
|
+
level: number;
|
|
67
|
+
sentAt: number;
|
|
68
|
+
}[];
|
|
69
|
+
/**
|
|
70
|
+
* This transaction in external systems (`moneybird:412`). The dedupe axis the ingest pipeline
|
|
71
|
+
* upserts on — without it the second run of an order import creates every order again.
|
|
72
|
+
*/
|
|
73
|
+
externalIds?: string[];
|
|
74
|
+
/** Which credential a change has to be written back with. Two connections, two answers. */
|
|
75
|
+
source?: {
|
|
76
|
+
connectionId?: string;
|
|
77
|
+
};
|
|
78
|
+
createdBy: string;
|
|
79
|
+
createdAt?: number;
|
|
80
|
+
updatedAt?: number;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* The statuses, all kinds together. Which kind offers which is {@link TransactionKind.statuses}.
|
|
84
|
+
*
|
|
85
|
+
* A union and not a free string: kinds and their statuses are **ours**, not the organisation's.
|
|
86
|
+
* Labels follow from the key as `status_<key>`.
|
|
87
|
+
*/
|
|
88
|
+
export type TransactionStatus = "draft" | "sent" | "accepted" | "rejected" | "expired" | "confirmed" | "delivered" | "open" | "paid" | "overdue" | "settled" | "cancelled";
|
|
89
|
+
export interface TransactionLine {
|
|
90
|
+
/** Stable within the transaction, so a version diff can follow a line. */
|
|
91
|
+
id: string;
|
|
92
|
+
/** `product` counts; `text` is a heading or a paragraph and carries no amount. */
|
|
93
|
+
kind: "product" | "text";
|
|
94
|
+
productId?: string;
|
|
95
|
+
/** Copied on adding: a quote from last year must stay readable when the product is renamed. */
|
|
96
|
+
name: string;
|
|
97
|
+
description?: string;
|
|
98
|
+
unitKey: string;
|
|
99
|
+
quantity: number;
|
|
100
|
+
unitPriceCents: Cents;
|
|
101
|
+
discountPercent?: number;
|
|
102
|
+
taxRateKey: string;
|
|
103
|
+
/** Which rung of the price ladder produced this amount. Purely to account for it. */
|
|
104
|
+
priceSourceKey?: string;
|
|
105
|
+
/** Step 1 of the rounding order, stored so the client need not recompute. */
|
|
106
|
+
netCents: Cents;
|
|
107
|
+
/** This line's share of its rate group's VAT. Shielded, like the cost price. */
|
|
108
|
+
taxCents: Cents;
|
|
109
|
+
/** The cost price as it stood when the line was added. Shielded by `sales.product.cost`. */
|
|
110
|
+
costPriceCents?: Cents;
|
|
111
|
+
/** The mapping axis onto a chart of accounts, copied from the product's category. */
|
|
112
|
+
ledgerCategoryKey?: string;
|
|
113
|
+
}
|
|
114
|
+
export interface TransactionTotals {
|
|
115
|
+
netCents: Cents;
|
|
116
|
+
taxCents: Cents;
|
|
117
|
+
grossCents: Cents;
|
|
118
|
+
/** Sum of the copied cost prices. Shielded — strip it with the line's `costPriceCents`. */
|
|
119
|
+
costCents?: Cents;
|
|
120
|
+
/** Per rate, because that is what the invoice and the bookkeeping both need. */
|
|
121
|
+
byRate: {
|
|
122
|
+
taxRateKey: string;
|
|
123
|
+
netCents: Cents;
|
|
124
|
+
taxCents: Cents;
|
|
125
|
+
}[];
|
|
126
|
+
}
|