@happyvertical/smrt-commerce 0.55.24 → 0.56.1
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/AGENTS.md +11 -9
- package/README.md +114 -2
- package/agents/accounting-snapshot-mapper.md +111 -0
- package/agents/contract-money.md +18 -0
- package/agents/cost-billing.md +7 -2
- package/agents/document-money.md +126 -0
- package/agents/invoice-calculations.md +14 -2
- package/agents/line-amount-migration.md +50 -0
- package/agents/minor-unit-migration.md +20 -0
- package/agents/money-calculator.md +45 -0
- package/agents/money-model.md +113 -0
- package/agents/purchasing-ui.md +4 -3
- package/agents/quote-ui.md +3 -2
- package/agents/revenue-journal.md +23 -0
- package/agents/tax-codes.md +48 -0
- package/agents/tax-summary.md +126 -0
- package/dist/accounting-snapshot.d.ts +79 -0
- package/dist/accounting-snapshot.d.ts.map +1 -0
- package/dist/billing/runtime.d.ts +2 -0
- package/dist/billing/runtime.d.ts.map +1 -1
- package/dist/chunks/ContractLineItemCollection-DYjhj_pU.js +265 -0
- package/dist/chunks/ContractLineItemCollection-DYjhj_pU.js.map +1 -0
- package/dist/chunks/CustomerCollection-DQIujn4f.js +99 -0
- package/dist/chunks/CustomerCollection-DQIujn4f.js.map +1 -0
- package/dist/chunks/DocumentTaxCollection-BEpoqXAQ.js +1639 -0
- package/dist/chunks/DocumentTaxCollection-BEpoqXAQ.js.map +1 -0
- package/dist/chunks/InvoiceCollection-CKQflFjc.js +1047 -0
- package/dist/chunks/InvoiceCollection-CKQflFjc.js.map +1 -0
- package/dist/chunks/InvoiceLineItemCollection-CHm9zdqh.js +467 -0
- package/dist/chunks/InvoiceLineItemCollection-CHm9zdqh.js.map +1 -0
- package/dist/chunks/TaxCodeCollection-DOpzW4y8.js +149 -0
- package/dist/chunks/TaxCodeCollection-DOpzW4y8.js.map +1 -0
- package/dist/chunks/TaxComponentCollection-Cs2uXwEl.js +129 -0
- package/dist/chunks/TaxComponentCollection-Cs2uXwEl.js.map +1 -0
- package/dist/chunks/TaxSettingsCollection-BBTZDH1S.js +319 -0
- package/dist/chunks/TaxSettingsCollection-BBTZDH1S.js.map +1 -0
- package/dist/chunks/{money-DfrRxrel.js → allocation-integrity-DI3G16BN.js} +7 -12
- package/dist/chunks/allocation-integrity-DI3G16BN.js.map +1 -0
- package/dist/chunks/{calculations-Bz7RB3qK.js → calculations-DaHR17il.js} +134 -54
- package/dist/chunks/calculations-DaHR17il.js.map +1 -0
- package/dist/chunks/credit-allocation-yspz0Lab.js +121 -0
- package/dist/chunks/credit-allocation-yspz0Lab.js.map +1 -0
- package/dist/chunks/document-money-DNVhDJyC.js +860 -0
- package/dist/chunks/document-money-DNVhDJyC.js.map +1 -0
- package/dist/chunks/invoice-posting-BwV8g7z0.js +229 -0
- package/dist/chunks/invoice-posting-BwV8g7z0.js.map +1 -0
- package/dist/chunks/money-rational-CcW7gzG5.js +64 -0
- package/dist/chunks/money-rational-CcW7gzG5.js.map +1 -0
- package/dist/chunks/revenue-journal-DY9fro8E.js +140 -0
- package/dist/chunks/revenue-journal-DY9fro8E.js.map +1 -0
- package/dist/chunks/rolldown-runtime-D7D4PA-g.js +13 -0
- package/dist/chunks/tenant-money-barrier-DjRXgMnX.js +135 -0
- package/dist/chunks/tenant-money-barrier-DjRXgMnX.js.map +1 -0
- package/dist/chunks/{types-zVnIjSOk.js → types-LDETvQ1C.js} +3 -14
- package/dist/chunks/types-LDETvQ1C.js.map +1 -0
- package/dist/chunks/{units-BpZ0_Dpk.js → units-CNcjH_eE.js} +2 -2
- package/dist/chunks/{units-BpZ0_Dpk.js.map → units-CNcjH_eE.js.map} +1 -1
- package/dist/collections/ContractCollection.d.ts +37 -1
- package/dist/collections/ContractCollection.d.ts.map +1 -1
- package/dist/collections/ContractLineItemCollection.d.ts +26 -1
- package/dist/collections/ContractLineItemCollection.d.ts.map +1 -1
- package/dist/collections/DocumentTaxCollection.d.ts +75 -0
- package/dist/collections/DocumentTaxCollection.d.ts.map +1 -0
- package/dist/collections/InvoiceCollection.d.ts +26 -1
- package/dist/collections/InvoiceCollection.d.ts.map +1 -1
- package/dist/collections/InvoiceLineItemCollection.d.ts +26 -1
- package/dist/collections/InvoiceLineItemCollection.d.ts.map +1 -1
- package/dist/collections/MoneyMigrationDocumentCollection.d.ts +12 -0
- package/dist/collections/MoneyMigrationDocumentCollection.d.ts.map +1 -0
- package/dist/collections/PaymentAllocationCollection.d.ts +2 -0
- package/dist/collections/PaymentAllocationCollection.d.ts.map +1 -1
- package/dist/collections/PurchaseContractCollection.d.ts +8 -0
- package/dist/collections/PurchaseContractCollection.d.ts.map +1 -0
- package/dist/collections/SalesContractCollection.d.ts +8 -0
- package/dist/collections/SalesContractCollection.d.ts.map +1 -0
- package/dist/collections/TaxCodeCollection.d.ts +7 -0
- package/dist/collections/TaxCodeCollection.d.ts.map +1 -0
- package/dist/collections/TaxComponentCollection.d.ts +6 -0
- package/dist/collections/TaxComponentCollection.d.ts.map +1 -0
- package/dist/collections/TaxSettingsCollection.d.ts +16 -0
- package/dist/collections/TaxSettingsCollection.d.ts.map +1 -0
- package/dist/collections/TaxSummaryReportCollection.d.ts +151 -0
- package/dist/collections/TaxSummaryReportCollection.d.ts.map +1 -0
- package/dist/collections/index.d.ts +8 -0
- package/dist/collections/index.d.ts.map +1 -1
- package/dist/commerce-money-tools.d.ts +9 -0
- package/dist/commerce-money-tools.d.ts.map +1 -0
- package/dist/contract-money.d.ts +27 -0
- package/dist/contract-money.d.ts.map +1 -0
- package/dist/cost-billing.d.ts +0 -1
- package/dist/cost-billing.d.ts.map +1 -1
- package/dist/cost-billing.js +10 -15
- package/dist/cost-billing.js.map +1 -1
- package/dist/credit-allocation.d.ts +48 -0
- package/dist/credit-allocation.d.ts.map +1 -0
- package/dist/document-money-internal.d.ts +44 -0
- package/dist/document-money-internal.d.ts.map +1 -0
- package/dist/document-money.d.ts +85 -0
- package/dist/document-money.d.ts.map +1 -0
- package/dist/index.d.ts +16 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5563 -4243
- package/dist/index.js.map +1 -1
- package/dist/invoice-accounting-sync.d.ts +96 -0
- package/dist/invoice-accounting-sync.d.ts.map +1 -0
- package/dist/invoice-mcp.d.ts +16 -0
- package/dist/invoice-mcp.d.ts.map +1 -0
- package/dist/invoice-posting.d.ts +9 -0
- package/dist/invoice-posting.d.ts.map +1 -0
- package/dist/invoice-record-screen.d.ts +60 -0
- package/dist/invoice-record-screen.d.ts.map +1 -0
- package/dist/invoices.d.ts +2 -0
- package/dist/invoices.d.ts.map +1 -1
- package/dist/invoices.js +3 -2
- package/dist/manifest.json +11605 -4598
- package/dist/migrations/commerceLineAmounts.d.ts +84 -0
- package/dist/migrations/commerceLineAmounts.d.ts.map +1 -0
- package/dist/migrations/partyLinks.d.ts +39 -0
- package/dist/migrations/partyLinks.d.ts.map +1 -0
- package/dist/models/Contract.d.ts +61 -27
- package/dist/models/Contract.d.ts.map +1 -1
- package/dist/models/ContractLineItem.d.ts +30 -1
- package/dist/models/ContractLineItem.d.ts.map +1 -1
- package/dist/models/Customer.d.ts +7 -0
- package/dist/models/Customer.d.ts.map +1 -1
- package/dist/models/DocumentTax.d.ts +50 -0
- package/dist/models/DocumentTax.d.ts.map +1 -0
- package/dist/models/Invoice.d.ts +46 -2
- package/dist/models/Invoice.d.ts.map +1 -1
- package/dist/models/InvoiceLineItem.d.ts +33 -2
- package/dist/models/InvoiceLineItem.d.ts.map +1 -1
- package/dist/models/MoneyMigrationDocument.d.ts +28 -0
- package/dist/models/MoneyMigrationDocument.d.ts.map +1 -0
- package/dist/models/Payment.d.ts +5 -1
- package/dist/models/Payment.d.ts.map +1 -1
- package/dist/models/PaymentAllocation.d.ts.map +1 -1
- package/dist/models/TaxCode.d.ts +22 -0
- package/dist/models/TaxCode.d.ts.map +1 -0
- package/dist/models/TaxComponent.d.ts +21 -0
- package/dist/models/TaxComponent.d.ts.map +1 -0
- package/dist/models/TaxSettings.d.ts +33 -0
- package/dist/models/TaxSettings.d.ts.map +1 -0
- package/dist/models/TaxSummaryReport.d.ts +35 -0
- package/dist/models/TaxSummaryReport.d.ts.map +1 -0
- package/dist/models/Vendor.d.ts +9 -0
- package/dist/models/Vendor.d.ts.map +1 -1
- package/dist/models/index.d.ts +7 -1
- package/dist/models/index.d.ts.map +1 -1
- package/dist/money-rational.d.ts +15 -0
- package/dist/money-rational.d.ts.map +1 -0
- package/dist/money.d.ts +106 -25
- package/dist/money.d.ts.map +1 -1
- package/dist/money.js +274 -0
- package/dist/money.js.map +1 -0
- package/dist/recipes.d.ts +17 -47
- package/dist/recipes.d.ts.map +1 -1
- package/dist/revenue-journal.d.ts +61 -0
- package/dist/revenue-journal.d.ts.map +1 -0
- package/dist/smrt-knowledge.json +6558 -1316
- package/dist/svelte/components/InvoiceActions.svelte +12 -0
- package/dist/svelte/components/InvoiceActions.svelte.d.ts +5 -0
- package/dist/svelte/components/InvoiceActions.svelte.d.ts.map +1 -1
- package/dist/svelte/components/InvoiceEditor.svelte +15 -1
- package/dist/svelte/components/InvoiceEditor.svelte.d.ts.map +1 -1
- package/dist/svelte/components/InvoiceLineItems.svelte +3 -3
- package/dist/svelte/components/InvoiceRecordScreen.svelte +94 -0
- package/dist/svelte/components/InvoiceRecordScreen.svelte.d.ts +21 -0
- package/dist/svelte/components/InvoiceRecordScreen.svelte.d.ts.map +1 -0
- package/dist/svelte/components/InvoiceTotals.svelte +2 -2
- package/dist/svelte/components/MoneyInvoiceEditor.svelte +282 -0
- package/dist/svelte/components/MoneyInvoiceEditor.svelte.d.ts +31 -0
- package/dist/svelte/components/MoneyInvoiceEditor.svelte.d.ts.map +1 -0
- package/dist/svelte/components/PurchaseOrderEditor.svelte +53 -1
- package/dist/svelte/components/PurchaseOrderEditor.svelte.d.ts +5 -0
- package/dist/svelte/components/PurchaseOrderEditor.svelte.d.ts.map +1 -1
- package/dist/svelte/components/QuoteEditor.svelte +54 -1
- package/dist/svelte/components/QuoteEditor.svelte.d.ts +5 -0
- package/dist/svelte/components/QuoteEditor.svelte.d.ts.map +1 -1
- package/dist/svelte/i18n.d.ts +16 -0
- package/dist/svelte/i18n.d.ts.map +1 -1
- package/dist/svelte/i18n.js +16 -0
- package/dist/svelte/index.d.ts +7 -2
- package/dist/svelte/index.d.ts.map +1 -1
- package/dist/svelte/index.js +4 -1
- package/dist/svelte/invoices/calculations.d.ts +7 -2
- package/dist/svelte/invoices/calculations.d.ts.map +1 -1
- package/dist/svelte/invoices/calculations.js +141 -47
- package/dist/svelte/invoices/money-editor.d.ts +123 -0
- package/dist/svelte/invoices/money-editor.d.ts.map +1 -0
- package/dist/svelte/invoices/money-editor.js +101 -0
- package/dist/svelte/invoices/types.d.ts +5 -1
- package/dist/svelte/invoices/types.d.ts.map +1 -1
- package/dist/svelte/purchasing-i18n.d.ts +5 -0
- package/dist/svelte/purchasing-i18n.d.ts.map +1 -1
- package/dist/svelte/purchasing-i18n.js +5 -0
- package/dist/svelte/quote-i18n.d.ts +5 -0
- package/dist/svelte/quote-i18n.d.ts.map +1 -1
- package/dist/svelte/quote-i18n.js +5 -0
- package/dist/tax/cookbook.d.ts +22 -0
- package/dist/tax/cookbook.d.ts.map +1 -0
- package/dist/tax/example-pack.d.ts +25 -0
- package/dist/tax/example-pack.d.ts.map +1 -0
- package/dist/tax/identity.d.ts +5 -0
- package/dist/tax/identity.d.ts.map +1 -0
- package/dist/tax/index.d.ts +4 -0
- package/dist/tax/index.d.ts.map +1 -0
- package/dist/tax/legacy.d.ts +48 -0
- package/dist/tax/legacy.d.ts.map +1 -0
- package/dist/tax-summary-report-adapter.d.ts +37 -0
- package/dist/tax-summary-report-adapter.d.ts.map +1 -0
- package/dist/tax-summary.d.ts +129 -0
- package/dist/tax-summary.d.ts.map +1 -0
- package/dist/tenant-money-barrier.d.ts +66 -0
- package/dist/tenant-money-barrier.d.ts.map +1 -0
- package/dist/types/index.d.ts +145 -5
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +19 -11
- package/dist/chunks/calculations-Bz7RB3qK.js.map +0 -1
- package/dist/chunks/money-DfrRxrel.js.map +0 -1
- package/dist/chunks/types-zVnIjSOk.js.map +0 -1
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
* @packageDocumentation
|
|
4
4
|
*/
|
|
5
5
|
import { SmrtObject } from '@happyvertical/smrt-core';
|
|
6
|
+
import type { DatabaseInterface } from '@happyvertical/smrt-core/migrations';
|
|
7
|
+
import { type DocumentMoneyReadRebindCapability, type DocumentMoneyWriteCapability } from '../document-money-internal.js';
|
|
6
8
|
import { type InvoiceCalculationContext, type InvoiceLineDraft } from '../svelte/invoices/calculations.js';
|
|
7
|
-
import type { AccountingLineItemInput, InvoiceLineEditorState, InvoiceLineItemOptions } from '../types/index.js';
|
|
9
|
+
import type { AccountingLineItemInput, InvoiceCreditCalculationBasis, InvoiceLineEditorState, InvoiceLineItemOptions, InvoiceTaxComponentSnapshot } from '../types/index.js';
|
|
8
10
|
/**
|
|
9
11
|
* InvoiceLineItem represents a single line item on an invoice.
|
|
10
12
|
*
|
|
@@ -27,6 +29,8 @@ import type { AccountingLineItemInput, InvoiceLineEditorState, InvoiceLineItemOp
|
|
|
27
29
|
* ```
|
|
28
30
|
*/
|
|
29
31
|
export declare class InvoiceLineItem extends SmrtObject {
|
|
32
|
+
/** @internal Collection read guard returns this snapshot on its root DB. */
|
|
33
|
+
rebindMoneyRead(capability: DocumentMoneyReadRebindCapability, db: DatabaseInterface): this;
|
|
30
34
|
/**
|
|
31
35
|
* Tenant ID for multi-tenant isolation
|
|
32
36
|
* Nullable to support both tenant-scoped and global invoice line items
|
|
@@ -36,6 +40,10 @@ export declare class InvoiceLineItem extends SmrtObject {
|
|
|
36
40
|
* Parent invoice
|
|
37
41
|
*/
|
|
38
42
|
invoiceId: string;
|
|
43
|
+
creditedLineId: string | null;
|
|
44
|
+
creditCalculationBasisJson: string;
|
|
45
|
+
get creditCalculationBasis(): InvoiceCreditCalculationBasis | null;
|
|
46
|
+
set creditCalculationBasis(value: InvoiceCreditCalculationBasis | null);
|
|
39
47
|
/**
|
|
40
48
|
* Item description
|
|
41
49
|
*/
|
|
@@ -44,6 +52,7 @@ export declare class InvoiceLineItem extends SmrtObject {
|
|
|
44
52
|
* SKU or item code
|
|
45
53
|
*/
|
|
46
54
|
sku: string;
|
|
55
|
+
productId: string | null;
|
|
47
56
|
/** Nonnegative decimal quantity (hours, weight, units), up to six fractional digits. */
|
|
48
57
|
quantity: number;
|
|
49
58
|
/** Raw editor modes retained only while they resolve to the authoritative model fields. */
|
|
@@ -64,6 +73,8 @@ export declare class InvoiceLineItem extends SmrtObject {
|
|
|
64
73
|
* Discount amount (flat, not percentage), in integer minor units (#2361).
|
|
65
74
|
*/
|
|
66
75
|
discount: number;
|
|
76
|
+
discountType: 'none' | 'percent' | 'amount';
|
|
77
|
+
discountRate: string;
|
|
67
78
|
/**
|
|
68
79
|
* Tax rate as a decimal fraction (e.g., 0.05 for 5%).
|
|
69
80
|
*
|
|
@@ -72,6 +83,17 @@ export declare class InvoiceLineItem extends SmrtObject {
|
|
|
72
83
|
* truncate every rate to 0 (#2361).
|
|
73
84
|
*/
|
|
74
85
|
taxRate: number;
|
|
86
|
+
taxMode: 'inherit' | 'override';
|
|
87
|
+
taxCodeId: string | null;
|
|
88
|
+
taxCodeCode: string | null;
|
|
89
|
+
taxCodeName: string | null;
|
|
90
|
+
taxComponentsJson: string | null;
|
|
91
|
+
get taxComponents(): InvoiceTaxComponentSnapshot[];
|
|
92
|
+
set taxComponents(value: InvoiceTaxComponentSnapshot[]);
|
|
93
|
+
taxAmount: number;
|
|
94
|
+
legacyAmount: number | null;
|
|
95
|
+
/** Stable document snapshot identity; ordinary lifecycle saves do not change it. */
|
|
96
|
+
moneySnapshotId: string;
|
|
75
97
|
/**
|
|
76
98
|
* Calculated line amount, in integer minor units (#2361).
|
|
77
99
|
*/
|
|
@@ -96,7 +118,7 @@ export declare class InvoiceLineItem extends SmrtObject {
|
|
|
96
118
|
* Revenue account ID (cross-package ref to smrt-ledgers)
|
|
97
119
|
* Used for revenue recognition to specific accounts
|
|
98
120
|
*/
|
|
99
|
-
revenueAccountId: string;
|
|
121
|
+
revenueAccountId: string | null;
|
|
100
122
|
/**
|
|
101
123
|
* Sort order within the invoice
|
|
102
124
|
*/
|
|
@@ -114,6 +136,15 @@ export declare class InvoiceLineItem extends SmrtObject {
|
|
|
114
136
|
getEditorDraft(authorizedContext: InvoiceCalculationContext): InvoiceLineDraft | null;
|
|
115
137
|
/** Validate resolved fields and recompute amount before persistence; editor metadata never determines money. */
|
|
116
138
|
save(): Promise<this>;
|
|
139
|
+
/** @internal Aggregate persistence only. */
|
|
140
|
+
saveDerived(capability: DocumentMoneyWriteCapability, legacy: boolean): Promise<this>;
|
|
141
|
+
delete(options?: {
|
|
142
|
+
expectedUpdatedAt?: Date | string;
|
|
143
|
+
}): Promise<void>;
|
|
144
|
+
/** @internal Aggregate persistence only. */
|
|
145
|
+
deleteDerived(capability: DocumentMoneyWriteCapability, options?: {
|
|
146
|
+
expectedUpdatedAt?: Date | string;
|
|
147
|
+
}): Promise<void>;
|
|
117
148
|
/**
|
|
118
149
|
* Check if line item has source tracking
|
|
119
150
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InvoiceLineItem.d.ts","sourceRoot":"","sources":["../../src/models/InvoiceLineItem.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAIL,UAAU,EAEX,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"InvoiceLineItem.d.ts","sourceRoot":"","sources":["../../src/models/InvoiceLineItem.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAIL,UAAU,EAEX,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAG7E,OAAO,EAGL,KAAK,iCAAiC,EACtC,KAAK,4BAA4B,EAClC,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAEL,KAAK,yBAAyB,EAC9B,K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AaD,MAAM,CACnB,OAAO,GAAE;QAAE,iBAAiB,CAAC,EAAE,IAAI,GAAG,MAAM,CAAA;KAAO,GAClD,OAAO,CAAC,IAAI,CAAC;IAKhB,4CAA4C;IACtC,aAAa,CACjB,UAAU,EAAE,4BAA4B,EACxC,OAAO,GAAE;QAAE,iBAAiB,CAAC,EAAE,IAAI,GAAG,MAAM,CAAA;KAAO,GAClD,OAAO,CAAC,IAAI,CAAC;IAMhB;;OAEG;IACH,SAAS,IAAI,OAAO;IAIpB;;OAEG;IACH,SAAS,IAAI,OAAO;IAIpB;;;;;;OAMG;IACH,oBAAoB,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,uBAAuB;CAejE;AAED,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/** Durable, internal rollback journal for one commerce money document. */
|
|
2
|
+
import { SmrtObject, type SmrtObjectOptions } from '@happyvertical/smrt-core';
|
|
3
|
+
export type MoneyMigrationDocumentType = 'invoice' | 'contract';
|
|
4
|
+
export type MoneyMigrationDocumentState = 'prepared' | 'applied' | 'rolled_back';
|
|
5
|
+
export interface MoneyMigrationDocumentOptions extends SmrtObjectOptions {
|
|
6
|
+
tenantId?: string;
|
|
7
|
+
migrationId?: string;
|
|
8
|
+
documentType?: MoneyMigrationDocumentType;
|
|
9
|
+
documentId?: string;
|
|
10
|
+
state?: MoneyMigrationDocumentState;
|
|
11
|
+
preImageJson?: string;
|
|
12
|
+
preChecksum?: string;
|
|
13
|
+
postImageJson?: string;
|
|
14
|
+
postChecksum?: string;
|
|
15
|
+
}
|
|
16
|
+
export declare class MoneyMigrationDocument extends SmrtObject {
|
|
17
|
+
tenantId: string;
|
|
18
|
+
migrationId: string;
|
|
19
|
+
documentType: MoneyMigrationDocumentType;
|
|
20
|
+
documentId: string;
|
|
21
|
+
state: MoneyMigrationDocumentState;
|
|
22
|
+
preImageJson: string;
|
|
23
|
+
preChecksum: string;
|
|
24
|
+
postImageJson: string;
|
|
25
|
+
postChecksum: string;
|
|
26
|
+
constructor(options?: MoneyMigrationDocumentOptions);
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=MoneyMigrationDocument.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MoneyMigrationDocument.d.ts","sourceRoot":"","sources":["../../src/models/MoneyMigrationDocument.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAE1E,OAAO,EAEL,UAAU,EACV,KAAK,iBAAiB,EAEvB,MAAM,0BAA0B,CAAC;AAGlC,MAAM,MAAM,0BAA0B,GAAG,SAAS,GAAG,UAAU,CAAC;AAChE,MAAM,MAAM,2BAA2B,GACnC,UAAU,GACV,SAAS,GACT,aAAa,CAAC;AAElB,MAAM,WAAW,6BAA8B,SAAQ,iBAAiB;IACtE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,0BAA0B,CAAC;IAC1C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,2BAA2B,CAAC;IACpC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,qBAca,sBAAuB,SAAQ,UAAU;IAEpD,QAAQ,SAAM;IAGd,WAAW,SAAM;IAGjB,YAAY,EAAE,0BAA0B,CAAa;IAGrD,UAAU,SAAM;IAEhB,KAAK,EAAE,2BAA2B,CAAc;IAGhD,YAAY,SAAM;IAElB,WAAW,SAAM;IAGjB,aAAa,SAAM;IAEnB,YAAY,SAAM;gBAEN,OAAO,GAAE,6BAAkC;CAkBxD"}
|
package/dist/models/Payment.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { SmrtObject } from '@happyvertical/smrt-core';
|
|
6
6
|
import type { Journal } from '@happyvertical/smrt-ledgers';
|
|
7
|
-
import { PaymentMethod, type PaymentOptions, PaymentStatus, type RecordPaymentOptions } from '../types/index.js';
|
|
7
|
+
import { type PaymentKind, PaymentMethod, type PaymentOptions, PaymentStatus, type RecordPaymentOptions } from '../types/index.js';
|
|
8
8
|
/**
|
|
9
9
|
* Payment represents a financial transaction against a contract.
|
|
10
10
|
*
|
|
@@ -31,6 +31,8 @@ import { PaymentMethod, type PaymentOptions, PaymentStatus, type RecordPaymentOp
|
|
|
31
31
|
* ```
|
|
32
32
|
*/
|
|
33
33
|
export declare class Payment extends SmrtObject {
|
|
34
|
+
/** Incoming settlement or outgoing customer refund. Amount stays positive. */
|
|
35
|
+
kind: PaymentKind;
|
|
34
36
|
/**
|
|
35
37
|
* Tenant ID for multi-tenant isolation
|
|
36
38
|
* Nullable to support both tenant-scoped and global payments
|
|
@@ -277,6 +279,8 @@ export declare class Payment extends SmrtObject {
|
|
|
277
279
|
* ```
|
|
278
280
|
*/
|
|
279
281
|
recordPayment(options: RecordPaymentOptions): Promise<Journal>;
|
|
282
|
+
/** Settle an outgoing refund through the same guarded journal transaction. */
|
|
283
|
+
recordRefund(options: RecordPaymentOptions): Promise<Journal>;
|
|
280
284
|
/** Post and complete only inside recordPayment's claimed transaction. */
|
|
281
285
|
private postPaymentInTransaction;
|
|
282
286
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Payment.d.ts","sourceRoot":"","sources":["../../src/models/Payment.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAIL,UAAU,EAEX,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAO3D,OAAO,EACL,aAAa,EACb,KAAK,cAAc,EACnB,aAAa,EACb,KAAK,oBAAoB,EAC1B,MAAM,mBAAmB,CAAC;AAgD3B;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,
|
|
1
|
+
{"version":3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entAllocation.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAqB,UAAU,EAAQ,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"PaymentAllocation.d.ts","sourceRoot":"","sources":["../../src/models/PaymentAllocation.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAqB,UAAU,EAAQ,MAAM,0BAA0B,CAAC;AAK/E,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAYlE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,qBAoBa,iBAAkB,SAAQ,UAAU;IAC/C;;;OAGG;IAEH,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAQ;IAE/B;;OAEG;IAGH,SAAS,EAAE,MAAM,CAAM;IAEvB;;OAEG;IAGH,SAAS,EAAE,MAAM,CAAM;IAEvB;;;;;;;;;OASG;IAKH,MAAM,EAAE,MAAM,CAAK;IAEnB;;OAEG;IAEH,WAAW,EAAE,IAAI,CAAc;IAE/B;;OAEG;IACH,WAAW,EAAE,MAAM,CAAM;IAEzB;;OAEG;IAEH,KAAK,EAAE,MAAM,CAAM;gBAEP,OAAO,GAAE,wBAA6B;IAalD,6EAA6E;IAC9D,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAkJrC;AAED,eAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { SmrtObject } from '@happyvertical/smrt-core';
|
|
2
|
+
import type { TaxCodeOptions, TaxCodePart } from '../types/index.js';
|
|
3
|
+
export type TaxCodeKind = 'taxable' | 'zero-rated' | 'exempt' | 'out-of-scope';
|
|
4
|
+
export type TaxCodeAppliesTo = 'sales' | 'purchases' | 'both';
|
|
5
|
+
/** A reusable tax code whose ordered component list is safe to edit. */
|
|
6
|
+
export declare class TaxCode extends SmrtObject {
|
|
7
|
+
tenantId: string;
|
|
8
|
+
code: string;
|
|
9
|
+
name: string;
|
|
10
|
+
kind: TaxCodeKind;
|
|
11
|
+
appliesTo: TaxCodeAppliesTo;
|
|
12
|
+
/** Ordered component IDs; compound is reserved and deliberately unsupported. */
|
|
13
|
+
/** Stored JSON is guarded through the typed accessor below. */
|
|
14
|
+
componentsJson: string;
|
|
15
|
+
get components(): TaxCodePart[];
|
|
16
|
+
set components(value: TaxCodePart[] | string);
|
|
17
|
+
active: boolean;
|
|
18
|
+
constructor(options?: TaxCodeOptions);
|
|
19
|
+
save(): Promise<this>;
|
|
20
|
+
private parsedComponents;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=TaxCode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TaxCode.d.ts","sourceRoot":"","sources":["../../src/models/TaxCode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,UAAU,EAAQ,MAAM,0BAA0B,CAAC;AAGnE,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErE,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,YAAY,GAAG,QAAQ,GAAG,cAAc,CAAC;AAC/E,MAAM,MAAM,gBAAgB,GAAG,OAAO,GAAG,WAAW,GAAG,MAAM,CAAC;AAE9D,wEAAwE;AACxE,qBAUa,OAAQ,SAAQ,UAAU;IAErC,QAAQ,SAAM;IAGd,IAAI,SAAM;IAGV,IAAI,SAAM;IAGV,IAAI,EAAE,WAAW,CAAa;IAK9B,SAAS,EAAE,gBAAgB,CAAU;IAErC,gFAAgF;IAChF,+DAA+D;IAC/D,cAAc,SAAQ;IAEtB,IAII,UAAU,IAAI,WAAW,EAAE,CAc9B;IAED,IAAI,UAAU,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG,MAAM,EAG3C;IAKD,MAAM,UAAQ;gBAEF,OAAO,GAAE,cAAmB;IAYzB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAiEpC,OAAO,CAAC,gBAAgB;CAoBzB"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { SmrtObject } from '@happyvertical/smrt-core';
|
|
2
|
+
import type { TaxComponentOptions } from '../types/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* One reusable tax rate component. Codes may combine components, but the
|
|
5
|
+
* component's percent is immutable after it has been saved: archive it and
|
|
6
|
+
* repoint editable codes to a replacement rate instead of rewriting history.
|
|
7
|
+
*/
|
|
8
|
+
export declare class TaxComponent extends SmrtObject {
|
|
9
|
+
tenantId: string;
|
|
10
|
+
name: string;
|
|
11
|
+
/** Percent, not a fraction: 7.125 means 7.125%. Stored as DECIMAL. */
|
|
12
|
+
percent: string;
|
|
13
|
+
liabilityAccountId: string;
|
|
14
|
+
recoverable: boolean;
|
|
15
|
+
active: boolean;
|
|
16
|
+
constructor(options?: TaxComponentOptions);
|
|
17
|
+
initialize(): Promise<this>;
|
|
18
|
+
save(): Promise<this>;
|
|
19
|
+
private isReferenced;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=TaxComponent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TaxComponent.d.ts","sourceRoot":"","sources":["../../src/models/TaxComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,UAAU,EAEX,MAAM,0BAA0B,CAAC;AAIlC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAqB7D;;;;GAIG;AACH,qBAea,YAAa,SAAQ,UAAU;IAE1C,QAAQ,SAAM;IAGd,IAAI,SAAM;IAEV,sEAAsE;IAKtE,OAAO,SAAS;IAKhB,kBAAkB,SAAM;IAMxB,WAAW,UAAS;IAGpB,MAAM,UAAQ;gBAEF,OAAO,GAAE,mBAAwB;IAY9B,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAM3B,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;YA8CtB,YAAY;CA8B3B"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { SmrtObject } from '@happyvertical/smrt-core';
|
|
2
|
+
import { type MoneyMigrationWriteCapability } from '../document-money-internal.js';
|
|
3
|
+
import type { TaxSettingsOptions } from '../types/index.js';
|
|
4
|
+
export interface TaxRegistration {
|
|
5
|
+
taxComponentId: string;
|
|
6
|
+
number: string;
|
|
7
|
+
label: string;
|
|
8
|
+
}
|
|
9
|
+
/** Tenant-level defaults and registration numbers for tax determination. */
|
|
10
|
+
export declare class TaxSettings extends SmrtObject {
|
|
11
|
+
tenantId: string;
|
|
12
|
+
defaultSalesTaxCodeId: string;
|
|
13
|
+
defaultPurchaseTaxCodeId: string;
|
|
14
|
+
defaultLineAmountType: 'exclusive' | 'inclusive' | 'none';
|
|
15
|
+
taxRoundingScope: 'line' | 'document';
|
|
16
|
+
/** Stored JSON is guarded through the typed accessor below. */
|
|
17
|
+
taxRegistrationsJson: string;
|
|
18
|
+
/** Server-owned runtime semantics gate. Never exposed as a generated write. */
|
|
19
|
+
moneyModel: 'legacy' | 'migrating' | 'v2';
|
|
20
|
+
/** Opaque owner token while a tenant migration is in progress. */
|
|
21
|
+
moneyMigrationId: string;
|
|
22
|
+
get taxRegistrations(): TaxRegistration[];
|
|
23
|
+
set taxRegistrations(value: TaxRegistration[] | string);
|
|
24
|
+
constructor(options?: TaxSettingsOptions);
|
|
25
|
+
save(): Promise<this>;
|
|
26
|
+
/** @internal Money migration owns marker transitions. */
|
|
27
|
+
saveMoneyModel(capability: MoneyMigrationWriteCapability): Promise<this>;
|
|
28
|
+
/** @internal Caller already owns the transaction-bound migration barrier. */
|
|
29
|
+
saveMoneyModelOnTransaction(capability: MoneyMigrationWriteCapability): Promise<this>;
|
|
30
|
+
private saveValidated;
|
|
31
|
+
private parsedRegistrations;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=TaxSettings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TaxSettings.d.ts","sourceRoot":"","sources":["../../src/models/TaxSettings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,UAAU,EAAQ,MAAM,0BAA0B,CAAC;AAM/E,OAAO,EAEL,KAAK,6BAA6B,EACnC,MAAM,+BAA+B,CAAC;AAEvC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAE5D,MAAM,WAAW,eAAe;IAC9B,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf;AAED,4EAA4E;AAC5E,qBAgBa,WAAY,SAAQ,UAAU;IAEzC,QAAQ,SAAM;IAKd,qBAAqB,SAAM;IAK3B,wBAAwB,SAAM;IAM9B,qBAAqB,EAAE,WAAW,GAAG,WAAW,GAAG,MAAM,CAAe;IAGxE,gBAAgB,EAAE,MAAM,GAAG,UAAU,CAAU;IAE/C,+DAA+D;IAC/D,oBAAoB,SAAQ;IAE5B,+EAA+E;IAC/E,UAAU,EAAE,QAAQ,GAAG,WAAW,GAAG,IAAI,CAAY;IAErD,kEAAkE;IAClE,gBAAgB,SAAM;IAEtB,IAMI,gBAAgB,IAAI,eAAe,EAAE,CAexC;IAED,IAAI,gBAAgB,CAAC,KAAK,EAAE,eAAe,EAAE,GAAG,MAAM,EAGrD;gBAEW,OAAO,GAAE,kBAAuB;IAkB7B,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAIpC,yDAAyD;IACnD,cAAc,CAClB,UAAU,EAAE,6BAA6B,GACxC,OAAO,CAAC,IAAI,CAAC;IAUhB,6EAA6E;IACvE,2BAA2B,CAC/B,UAAU,EAAE,6BAA6B,GACxC,OAAO,CAAC,IAAI,CAAC;YAUF,aAAa;IAgG3B,OAAO,CAAC,mBAAmB;CAoB5B"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/** Materialized tax-summary rows compiled from immutable commerce snapshots. */
|
|
2
|
+
import { SmrtReport } from '@happyvertical/smrt-reports';
|
|
3
|
+
export type TaxSummaryReportRowKind = 'component' | 'kind' | 'reconciliation' | 'warning';
|
|
4
|
+
export declare class TaxSummaryReport extends SmrtReport {
|
|
5
|
+
tenantId: string;
|
|
6
|
+
/** Inclusive report window, stored as an RFC3339 instant. */
|
|
7
|
+
periodFrom: Date;
|
|
8
|
+
/** Inclusive report window, stored as an RFC3339 instant. */
|
|
9
|
+
periodTo: Date;
|
|
10
|
+
currency: string;
|
|
11
|
+
rowKind: TaxSummaryReportRowKind;
|
|
12
|
+
/** Stable key for replacement and a source drilldown dimension. */
|
|
13
|
+
dimensionKey: string;
|
|
14
|
+
direction: string;
|
|
15
|
+
taxComponentId: string | null;
|
|
16
|
+
taxCodeKind: string | null;
|
|
17
|
+
liabilityAccountId: string | null;
|
|
18
|
+
taxableMinor: number;
|
|
19
|
+
taxMinor: number;
|
|
20
|
+
recoverableMinor: number | null;
|
|
21
|
+
ledgerMovementMinor: number | null;
|
|
22
|
+
netTaxMinor: number | null;
|
|
23
|
+
differenceMinor: number | null;
|
|
24
|
+
documentCount: number;
|
|
25
|
+
/** Canonical source classes present when this row was materialized. */
|
|
26
|
+
sourceScopes: string;
|
|
27
|
+
complete: boolean;
|
|
28
|
+
warningCode: string | null;
|
|
29
|
+
/** Stable source category for an incomplete-source warning drilldown. */
|
|
30
|
+
warningSourceType: string | null;
|
|
31
|
+
/** Stable source identity for an incomplete-source warning drilldown. */
|
|
32
|
+
warningSourceId: string | null;
|
|
33
|
+
warningMessage: string | null;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=TaxSummaryReport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TaxSummaryReport.d.ts","sourceRoot":"","sources":["../../src/models/TaxSummaryReport.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAGhF,OAAO,EAAmB,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAI1E,MAAM,MAAM,uBAAuB,GAC/B,WAAW,GACX,MAAM,GACN,gBAAgB,GAChB,SAAS,CAAC;AAEd,qBAgBa,gBAAiB,SAAQ,UAAU;IAE9C,QAAQ,SAAM;IAEd,6DAA6D;IAM7D,UAAU,EAAE,IAAI,CAAe;IAE/B,6DAA6D;IAM7D,QAAQ,EAAE,IAAI,CAAe;IAM7B,QAAQ,SAAM;IAId,OAAO,EAAE,uBAAuB,CAAe;IAE/C,mEAAmE;IAKnE,YAAY,SAAM;IAMlB,SAAS,SAAM;IAOf,cAAc,EAAE,MAAM,GAAG,IAAI,CAAQ;IAIrC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAQ;IAOlC,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAQ;IAIzC,YAAY,SAAK;IAOjB,QAAQ,SAAK;IASb,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAQ;IAOvC,mBAAmB,EAAE,MAAM,GAAG,IAAI,CAAQ;IAQ1C,WAAW,EAAE,MAAM,GAAG,IAAI,CAAQ;IAOlC,eAAe,EAAE,MAAM,GAAG,IAAI,CAAQ;IAItC,aAAa,SAAK;IAElB,uEAAuE;IAMvE,YAAY,SAAM;IAMlB,QAAQ,UAAQ;IAIhB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAQ;IAElC,yEAAyE;IAGzE,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAQ;IAExC,yEAAyE;IAGzE,eAAe,EAAE,MAAM,GAAG,IAAI,CAAQ;IAOtC,cAAc,EAAE,MAAM,GAAG,IAAI,CAAQ;CACtC"}
|
package/dist/models/Vendor.d.ts
CHANGED
|
@@ -49,6 +49,15 @@ export declare class Vendor extends SmrtObject {
|
|
|
49
49
|
* Default currency for transactions with this vendor
|
|
50
50
|
*/
|
|
51
51
|
currency: string;
|
|
52
|
+
/**
|
|
53
|
+
* Supplier registration number.
|
|
54
|
+
*
|
|
55
|
+
* Sensitive for the same reason as a customer's tax ID: it is identifying
|
|
56
|
+
* business information and must not enter generated list/search surfaces.
|
|
57
|
+
*/
|
|
58
|
+
taxId: string;
|
|
59
|
+
/** Tax code normally used for purchases from this vendor. */
|
|
60
|
+
defaultTaxCodeId: string;
|
|
52
61
|
/**
|
|
53
62
|
* Default contact email for orders
|
|
54
63
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Vendor.d.ts","sourceRoot":"","sources":["../../src/models/Vendor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"Vendor.d.ts","sourceRoot":"","sources":["../../src/models/Vendor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAIL,UAAU,EAEX,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,YAAY,EACb,MAAM,mBAAmB,CAAC;AAE3B;;;;;;;;;;;;;;;GAeG;AACH,qBAMa,MAAO,SAAQ,UAAU;IACpC;;;OAGG;IAEH,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAQ;IAE/B;;;OAGG;IAKH,SAAS,EAAE,MAAM,CAAM;IAEvB;;OAEG;IAKH,YAAY,EAAE,MAAM,CAAK;IAEzB;;;;OAIG;IAKH,kBAAkB,EAAE,MAAM,CAAK;IAE/B;;OAEG;IAKH,YAAY,EAAE,MAAM,CAAM;IAE1B;;OAEG;IAKH,QAAQ,EAAE,MAAM,CAAS;IAEzB;;;;;OAKG;IAKH,KAAK,EAAE,MAAM,CAAM;IAEnB,6DAA6D;IAI7D,gBAAgB,EAAE,MAAM,CAAM;IAE9B;;OAEG;IAKH,mBAAmB,EAAE,MAAM,CAAM;IAEjC;;OAEG;IAKH,mBAAmB,EAAE,MAAM,CAAM;IAEjC;;OAEG;IAKH,MAAM,EAAE,YAAY,CAAuB;IAE3C;;OAEG;IAKH,KAAK,EAAE,MAAM,CAAM;IAEnB;;;;;;;;;;;;;;;;;;;OAmBG;IAKH,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAM;IAE7C;;;OAGG;IAKH,QAAQ,EAAE,YAAY,EAAE,CAAM;gBAElB,OAAO,GAAE,aAAkB;IA6BvC;;;;;;;;OAQG;IACY,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAS1C;;;;OAIG;IACY,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAQpC;;OAEG;IACH,QAAQ,IAAI,OAAO;IAInB;;OAEG;IACH,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;IAI1C;;;;;;;;;;OAUG;IACH,YAAY,IAAI,MAAM;IAItB;;;;;;;OAOG;IACH,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAOtD;;;;OAIG;IACH,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI;IAQ7D;;;OAGG;IACH,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAU1C;;;;;;;;;OASG;IACH,OAAO,CAAC,MAAM,CAAC,wBAAwB;CAqBxC;AAED,eAAe,MAAM,CAAC"}
|
package/dist/models/index.d.ts
CHANGED
|
@@ -3,17 +3,23 @@
|
|
|
3
3
|
* @packageDocumentation
|
|
4
4
|
*/
|
|
5
5
|
export { BillingAccount, type BillingCloseKind, BillingLineSource, type BillingLineSourceType, BillingPaymentAttempt, type BillingPaymentAttemptFlag, type BillingPaymentAttemptPurpose, type BillingPaymentAttemptTransition, BillingPeriodClose, type BillingPeriodCloseStatus, type BillingStanding, } from './billing.js';
|
|
6
|
-
export { Agreement, Cart, Contract, Estimate, Lease, type LicenseRightsSnapshot, LicenseSale, Order, ProductionOrder, PurchaseOrder, WholesaleOrder, } from './Contract.js';
|
|
6
|
+
export { Agreement, Cart, Contract, Estimate, Lease, type LicenseRightsSnapshot, LicenseSale, Order, ProductionOrder, PurchaseContract, PurchaseOrder, SalesContract, WholesaleOrder, } from './Contract.js';
|
|
7
7
|
export { ContractLineItem } from './ContractLineItem.js';
|
|
8
8
|
export { Customer } from './Customer.js';
|
|
9
|
+
export { type CommerceDocumentType, DocumentTax, type DocumentTaxOptions, } from './DocumentTax.js';
|
|
9
10
|
export { Fulfillment } from './Fulfillment.js';
|
|
10
11
|
export { FulfillmentLineItem } from './FulfillmentLineItem.js';
|
|
11
12
|
export { Invoice } from './Invoice.js';
|
|
12
13
|
export { InvoiceLineItem } from './InvoiceLineItem.js';
|
|
14
|
+
export { MoneyMigrationDocument, type MoneyMigrationDocumentOptions, type MoneyMigrationDocumentState, type MoneyMigrationDocumentType, } from './MoneyMigrationDocument.js';
|
|
13
15
|
export { Payment } from './Payment.js';
|
|
14
16
|
export { PaymentAllocation } from './PaymentAllocation.js';
|
|
15
17
|
export { PaymentInstrument } from './PaymentInstrument.js';
|
|
16
18
|
export { PaymentIntent } from './PaymentIntent.js';
|
|
17
19
|
export { Payout } from './Payout.js';
|
|
20
|
+
export { TaxCode, type TaxCodeAppliesTo, type TaxCodeKind } from './TaxCode.js';
|
|
21
|
+
export { TaxComponent } from './TaxComponent.js';
|
|
22
|
+
export { type TaxRegistration, TaxSettings } from './TaxSettings.js';
|
|
23
|
+
export { TaxSummaryReport, type TaxSummaryReportRowKind, } from './TaxSummaryReport.js';
|
|
18
24
|
export { Vendor } from './Vendor.js';
|
|
19
25
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,cAAc,EACd,KAAK,gBAAgB,EACrB,iBAAiB,EACjB,KAAK,qBAAqB,EAC1B,qBAAqB,EACrB,KAAK,yBAAyB,EAC9B,KAAK,4BAA4B,EACjC,KAAK,+BAA+B,EACpC,kBAAkB,EAClB,KAAK,wBAAwB,EAC7B,KAAK,eAAe,GACrB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,SAAS,EACT,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,KAAK,EACL,KAAK,qBAAqB,EAC1B,WAAW,EACX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BAAuB,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EACL,KAAK,oBAAoB,EACzB,WAAW,EACX,KAAK,kBAAkB,GACxB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EACL,sBAAsB,EACtB,KAAK,6BAA6B,EAClC,KAAK,2BAA2B,EAChC,KAAK,0BAA0B,GAChC,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAChF,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,KAAK,eAAe,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EACL,gBAAgB,EAChB,KAAK,uBAAuB,GAC7B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** Internal exact-rational primitives shared by commerce money calculators. */
|
|
2
|
+
export interface SignedRationalInput {
|
|
3
|
+
id: string;
|
|
4
|
+
numerator: bigint;
|
|
5
|
+
denominator: bigint;
|
|
6
|
+
}
|
|
7
|
+
export declare function roundSignedRational(numerator: bigint, denominator: bigint): bigint;
|
|
8
|
+
export declare function allocateSignedRationals(values: readonly SignedRationalInput[]): {
|
|
9
|
+
target: bigint;
|
|
10
|
+
allocations: {
|
|
11
|
+
id: string;
|
|
12
|
+
value: bigint;
|
|
13
|
+
}[];
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=money-rational.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"money-rational.d.ts","sourceRoot":"","sources":["../src/money-rational.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACrB;AASD,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,GAClB,MAAM,CAMR;AAYD,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,SAAS,mBAAmB,EAAE,GACrC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;CAAE,CAyClE"}
|
package/dist/money.d.ts
CHANGED
|
@@ -1,27 +1,108 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
* Every money column in this package is INTEGER minor units — cents,
|
|
5
|
-
* satoshis — so `$19.99` is `1999`. Before #2401 the models carried
|
|
6
|
-
* `EPSILON = 0.01` tolerances on every comparison, because the values really
|
|
7
|
-
* were floats and `0.1 * 3` really is `0.30000000000000004`. With exact
|
|
8
|
-
* integers those tolerances are not merely unnecessary, they are wrong: a
|
|
9
|
-
* one-cent discrepancy is a one-cent discrepancy, not rounding fuzz.
|
|
10
|
-
*
|
|
11
|
-
* Dropping the tolerances is only safe if the values are *actually* integers,
|
|
12
|
-
* which is what this guard establishes. A fractional major-unit write (`19.99`
|
|
13
|
-
* into a cents column) is the bug the whole convention exists to prevent;
|
|
14
|
-
* PostgreSQL catches it with a `22P02` and SQLite's type affinity does not
|
|
15
|
-
* catch it at all, so the model catches it first, on every engine and every
|
|
16
|
-
* write surface.
|
|
17
|
-
*/
|
|
18
|
-
/**
|
|
19
|
-
* Throw unless every named value is a finite integer.
|
|
20
|
-
*
|
|
21
|
-
* @param context - Model name for the error message, e.g. `Invoice`.
|
|
22
|
-
* @param label - Row identifier used in the error, e.g. an invoice number.
|
|
23
|
-
* @param entries - `[fieldName, value]` pairs to check.
|
|
24
|
-
* @throws When any value is non-finite or has a fractional part.
|
|
25
|
-
*/
|
|
1
|
+
/** Exact, transport-neutral commercial document money calculation. */
|
|
2
|
+
/** Throw unless every named model value is a finite integer minor-unit amount. */
|
|
26
3
|
export declare function assertIntegerMinorUnits(context: string, label: string, entries: ReadonlyArray<readonly [string, number]>): void;
|
|
4
|
+
export type LineAmountType = 'exclusive' | 'inclusive' | 'none';
|
|
5
|
+
export type TaxRoundingScope = 'line' | 'document';
|
|
6
|
+
export type TaxCodeKind = 'taxable' | 'zero-rated' | 'exempt' | 'out-of-scope';
|
|
7
|
+
export type TaxCodeAppliesTo = 'sales' | 'purchases' | 'both';
|
|
8
|
+
export type MoneyValidationCode = 'DISCOUNT_BOTH_FORMS' | 'DISCOUNT_EXCEEDS_GROSS' | 'DISCOUNT_SIGN' | 'PERCENT_OUT_OF_RANGE' | 'COMPOUND_UNSUPPORTED' | 'INVALID_MONEY_INPUT' | 'TAX_CODE_DUPLICATE_COMPONENT' | 'TAX_CODE_KIND' | 'TAX_CODE_NON_TAXABLE_COMPONENTS' | 'TAX_CODE_NOT_FOUND' | 'TAX_CODE_TAXABLE_EMPTY' | 'TAX_COMPONENT_RATE_CONFLICT' | 'TAX_CODE_INACTIVE' | 'TAX_CODE_SCOPE' | 'UNSAFE_MONEY' | 'FROZEN_DOCUMENT' | 'CURRENCY_MISMATCH' | 'ACCOUNTING_SYNC_IN_PROGRESS' | 'ACCOUNTING_SYNC_RECONCILIATION_REQUIRED' | 'ACCOUNTING_SYNC_UNSUPPORTED' | 'CREDIT_EXCEEDS_LINE' | 'CREDIT_TARGET_NOT_ISSUED';
|
|
9
|
+
/** Stable validation error shared by model, editor, and transport adapters. */
|
|
10
|
+
export declare class MoneyValidationError extends Error {
|
|
11
|
+
readonly code: MoneyValidationCode;
|
|
12
|
+
readonly name = "MoneyValidationError";
|
|
13
|
+
/** Explicit marker consumed by public transports that preserve typed errors. */
|
|
14
|
+
readonly publicMessage: string;
|
|
15
|
+
constructor(code: MoneyValidationCode, message: string);
|
|
16
|
+
}
|
|
17
|
+
export interface TaxComponentInput {
|
|
18
|
+
taxComponentId: string;
|
|
19
|
+
/** Exact percent: "7" means 7%; at most six fractional digits. */
|
|
20
|
+
percent: string;
|
|
21
|
+
compound: boolean;
|
|
22
|
+
}
|
|
23
|
+
export interface MoneyTaxCodeInput {
|
|
24
|
+
id: string;
|
|
25
|
+
kind: TaxCodeKind;
|
|
26
|
+
components: readonly TaxComponentInput[];
|
|
27
|
+
}
|
|
28
|
+
export interface ResolvableTaxCodeInput extends MoneyTaxCodeInput {
|
|
29
|
+
active: boolean;
|
|
30
|
+
appliesTo: TaxCodeAppliesTo;
|
|
31
|
+
}
|
|
32
|
+
export type MoneyDiscountInput = {
|
|
33
|
+
kind: 'none';
|
|
34
|
+
} | {
|
|
35
|
+
kind: 'percent';
|
|
36
|
+
rate: string;
|
|
37
|
+
} | {
|
|
38
|
+
kind: 'amount';
|
|
39
|
+
minor: number;
|
|
40
|
+
};
|
|
41
|
+
export interface MoneyLineInput {
|
|
42
|
+
id: string;
|
|
43
|
+
/** Nonnegative decimal quantity with at most six fractional digits. */
|
|
44
|
+
quantity: number;
|
|
45
|
+
/** Signed safe integer minor units. */
|
|
46
|
+
unitPrice: number;
|
|
47
|
+
discount: MoneyDiscountInput;
|
|
48
|
+
/** Explicit tax-exclusive basis for credit-note amount allocations. */
|
|
49
|
+
netAmountMinor?: number;
|
|
50
|
+
/** Null means no code resolved; `none` pricing requires an out-of-scope code. */
|
|
51
|
+
taxCode: MoneyTaxCodeInput | null;
|
|
52
|
+
}
|
|
53
|
+
export interface MoneyLineResult {
|
|
54
|
+
id: string;
|
|
55
|
+
grossMinor: number;
|
|
56
|
+
discountMinor: number;
|
|
57
|
+
amountMinor: number;
|
|
58
|
+
components: {
|
|
59
|
+
taxComponentId: string;
|
|
60
|
+
taxMinor: number;
|
|
61
|
+
}[];
|
|
62
|
+
taxMinor: number;
|
|
63
|
+
netMinor: number;
|
|
64
|
+
}
|
|
65
|
+
export interface MoneyDocumentTaxResult {
|
|
66
|
+
/** Null records an unassigned line without inventing a persisted tax-code ID. */
|
|
67
|
+
taxCodeId: string | null;
|
|
68
|
+
taxComponentId: string | null;
|
|
69
|
+
taxableMinor: number;
|
|
70
|
+
taxMinor: number;
|
|
71
|
+
}
|
|
72
|
+
export interface MoneyDocumentResult {
|
|
73
|
+
lines: MoneyLineResult[];
|
|
74
|
+
subtotalMinor: number;
|
|
75
|
+
discountTotalMinor: number;
|
|
76
|
+
taxMinor: number;
|
|
77
|
+
totalMinor: number;
|
|
78
|
+
taxes: MoneyDocumentTaxResult[];
|
|
79
|
+
}
|
|
80
|
+
export type TaxCodeResolutionSource = 'line' | 'exempt-customer' | 'product' | 'customer' | 'app' | 'none';
|
|
81
|
+
export interface ResolveLineTaxCodeInput {
|
|
82
|
+
lineAmountType: LineAmountType;
|
|
83
|
+
lineOverride?: string | null;
|
|
84
|
+
}
|
|
85
|
+
export interface ResolveLineTaxCodeContext {
|
|
86
|
+
direction: 'sales' | 'purchases';
|
|
87
|
+
codes: Readonly<Record<string, ResolvableTaxCodeInput>>;
|
|
88
|
+
customerTaxExempt: boolean;
|
|
89
|
+
exemptCodeId?: string | null;
|
|
90
|
+
productCodeId?: string | null;
|
|
91
|
+
partyCodeId?: string | null;
|
|
92
|
+
appDefaultCodeId?: string | null;
|
|
93
|
+
outOfScopeCodeId?: string | null;
|
|
94
|
+
}
|
|
95
|
+
export interface ResolvedLineTaxCode {
|
|
96
|
+
taxCode: ResolvableTaxCodeInput | null;
|
|
97
|
+
source: TaxCodeResolutionSource;
|
|
98
|
+
}
|
|
99
|
+
/** Calculate exact line amounts, per-component tax, and document totals. */
|
|
100
|
+
export declare function calculateMoneyDocument(input: {
|
|
101
|
+
currency: string;
|
|
102
|
+
lineAmountType: LineAmountType;
|
|
103
|
+
roundingScope: TaxRoundingScope;
|
|
104
|
+
lines: readonly MoneyLineInput[];
|
|
105
|
+
}): MoneyDocumentResult;
|
|
106
|
+
/** Resolve a line tax code from already-loaded values, without model or I/O access. */
|
|
107
|
+
export declare function resolveLineTaxCode(line: ResolveLineTaxCodeInput, context: ResolveLineTaxCodeContext): ResolvedLineTaxCode;
|
|
27
108
|
//# sourceMappingURL=money.d.ts.map
|
package/dist/money.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"money.d.ts","sourceRoot":"","sources":["../src/money.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"money.d.ts","sourceRoot":"","sources":["../src/money.ts"],"names":[],"mappings":"AAAA,sEAAsE;AAQtE,kFAAkF;AAClF,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,aAAa,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAChD,IAAI,CAUN;AAED,MAAM,MAAM,cAAc,GAAG,WAAW,GAAG,WAAW,GAAG,MAAM,CAAC;AAChE,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,UAAU,CAAC;AACnD,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,YAAY,GAAG,QAAQ,GAAG,cAAc,CAAC;AAC/E,MAAM,MAAM,gBAAgB,GAAG,OAAO,GAAG,WAAW,GAAG,MAAM,CAAC;AAE9D,MAAM,MAAM,mBAAmB,GAC3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