@happyvertical/smrt-commerce 0.62.4 → 0.62.6

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.
Files changed (74) hide show
  1. package/AGENTS.md +1 -0
  2. package/agents/accounting-connection.md +76 -0
  3. package/agents/accounting-live-gate.md +40 -0
  4. package/agents/accounting-mapping.md +60 -0
  5. package/agents/accounting-payment-sync.md +76 -0
  6. package/agents/ordinary-accounting.md +3 -0
  7. package/dist/accounting-connection.d.ts +179 -0
  8. package/dist/accounting-connection.d.ts.map +1 -0
  9. package/dist/accounting-live-gate.d.ts +50 -0
  10. package/dist/accounting-live-gate.d.ts.map +1 -0
  11. package/dist/accounting-mapping.d.ts +189 -0
  12. package/dist/accounting-mapping.d.ts.map +1 -0
  13. package/dist/accounting-payment-sync.d.ts +233 -0
  14. package/dist/accounting-payment-sync.d.ts.map +1 -0
  15. package/dist/chunks/{InvoiceCollection-Cc-fJrHy.js → InvoiceCollection-xooQnUwq.js} +10 -10
  16. package/dist/chunks/{InvoiceCollection-Cc-fJrHy.js.map → InvoiceCollection-xooQnUwq.js.map} +1 -1
  17. package/dist/chunks/{allocation-integrity-CvXQm3wK.js → allocation-integrity-C4SZJcao.js} +6 -6
  18. package/dist/chunks/{allocation-integrity-CvXQm3wK.js.map → allocation-integrity-C4SZJcao.js.map} +1 -1
  19. package/dist/chunks/{contract-money-BoKHNfV6.js → contract-money-ATacxU6t.js} +4 -7
  20. package/dist/chunks/{contract-money-BoKHNfV6.js.map → contract-money-ATacxU6t.js.map} +1 -1
  21. package/dist/chunks/{invoice-posting-DlR_-TG1.js → invoice-posting-CDfxug3Q.js} +4 -5
  22. package/dist/chunks/{invoice-posting-DlR_-TG1.js.map → invoice-posting-CDfxug3Q.js.map} +1 -1
  23. package/dist/chunks/retention-accounting-BA4wXUQc.js +8710 -0
  24. package/dist/chunks/retention-accounting-BA4wXUQc.js.map +1 -0
  25. package/dist/chunks/{tenant-money-barrier-Bmu4YiID.js → tenant-money-barrier-BdyXIVT5.js} +3 -3
  26. package/dist/chunks/{tenant-money-barrier-Bmu4YiID.js.map → tenant-money-barrier-BdyXIVT5.js.map} +1 -1
  27. package/dist/collections/AccountingConnectionCollection.d.ts +27 -0
  28. package/dist/collections/AccountingConnectionCollection.d.ts.map +1 -0
  29. package/dist/collections/AccountingMappingCollection.d.ts +24 -0
  30. package/dist/collections/AccountingMappingCollection.d.ts.map +1 -0
  31. package/dist/collections/AccountingSyncRecordCollections.d.ts +27 -0
  32. package/dist/collections/AccountingSyncRecordCollections.d.ts.map +1 -0
  33. package/dist/collections/index.d.ts +3 -0
  34. package/dist/collections/index.d.ts.map +1 -1
  35. package/dist/index.d.ts +10 -0
  36. package/dist/index.d.ts.map +1 -1
  37. package/dist/index.js +1532 -21
  38. package/dist/index.js.map +1 -1
  39. package/dist/invoice-accounting-sync.d.ts +6 -0
  40. package/dist/invoice-accounting-sync.d.ts.map +1 -1
  41. package/dist/invoices.js +1 -1
  42. package/dist/manifest.json +6303 -3740
  43. package/dist/models/AccountingConnection.d.ts +101 -0
  44. package/dist/models/AccountingConnection.d.ts.map +1 -0
  45. package/dist/models/AccountingMapping.d.ts +85 -0
  46. package/dist/models/AccountingMapping.d.ts.map +1 -0
  47. package/dist/models/AccountingSyncRecords.d.ts +95 -0
  48. package/dist/models/AccountingSyncRecords.d.ts.map +1 -0
  49. package/dist/models/index.d.ts +3 -0
  50. package/dist/models/index.d.ts.map +1 -1
  51. package/dist/ordinary-accounting.d.ts +1 -0
  52. package/dist/ordinary-accounting.d.ts.map +1 -1
  53. package/dist/recipes.d.ts +1 -1
  54. package/dist/retention-accounting.d.ts +1 -0
  55. package/dist/retention-accounting.d.ts.map +1 -1
  56. package/dist/smrt-knowledge.json +1327 -99
  57. package/dist/smrt-knowledge.okf.md +55 -23
  58. package/package.json +15 -15
  59. package/dist/chunks/ContractLineItemCollection-BKHy-nR8.js +0 -260
  60. package/dist/chunks/ContractLineItemCollection-BKHy-nR8.js.map +0 -1
  61. package/dist/chunks/DocumentTaxCollection-BRebznXF.js +0 -4649
  62. package/dist/chunks/DocumentTaxCollection-BRebznXF.js.map +0 -1
  63. package/dist/chunks/TaxCodeCollection-BBqCugs5.js +0 -155
  64. package/dist/chunks/TaxCodeCollection-BBqCugs5.js.map +0 -1
  65. package/dist/chunks/TaxComponentCollection-BHJjbQxq.js +0 -134
  66. package/dist/chunks/TaxComponentCollection-BHJjbQxq.js.map +0 -1
  67. package/dist/chunks/credit-allocation-yspz0Lab.js +0 -121
  68. package/dist/chunks/credit-allocation-yspz0Lab.js.map +0 -1
  69. package/dist/chunks/retention-accounting-D0KzSw3f.js +0 -3069
  70. package/dist/chunks/retention-accounting-D0KzSw3f.js.map +0 -1
  71. package/dist/chunks/retention-accounting-internal-DNxLLVvK.js +0 -30
  72. package/dist/chunks/retention-accounting-internal-DNxLLVvK.js.map +0 -1
  73. package/dist/chunks/units-8ElbjVZK.js +0 -60
  74. package/dist/chunks/units-8ElbjVZK.js.map +0 -1
@@ -5,10 +5,10 @@ description: "Commerce models for the SMRT framework - contracts, fulfillments,
5
5
  status: "stable"
6
6
  generated:
7
7
  by: "smrt/scripts/generate-knowledge-okf.ts"
8
- at: "2026-11-17T21:17:44Z"
8
+ at: "2026-11-18T09:43:42Z"
9
9
  audience: "internal"
10
10
  evidence_level: "source-inspected"
11
- source_revision: "sha256:b69d297d85a62bf7b9022c57e93f432d5ce7b0a0861c9f413f897b85fac467d2"
11
+ source_revision: "sha256:316610435f74d9d1b7dde18b7ba1e4d30e54db49d35d58315010e5463cec3b0d"
12
12
  sources:
13
13
  - id: "manifest"
14
14
  resource: "https://github.com/happyvertical/smrt/blob/main/packages/commerce/package.json"
@@ -20,69 +20,81 @@ sources:
20
20
  resource: "https://github.com/happyvertical/smrt/blob/main/packages/commerce/README.md"
21
21
  title: "@happyvertical/smrt-commerce packages/commerce/README.md"
22
22
  - id: "agents-3"
23
+ resource: "https://github.com/happyvertical/smrt/blob/main/packages/commerce/agents/accounting-connection.md"
24
+ title: "@happyvertical/smrt-commerce packages/commerce/agents/accounting-connection.md"
25
+ - id: "agents-4"
26
+ resource: "https://github.com/happyvertical/smrt/blob/main/packages/commerce/agents/accounting-live-gate.md"
27
+ title: "@happyvertical/smrt-commerce packages/commerce/agents/accounting-live-gate.md"
28
+ - id: "agents-5"
29
+ resource: "https://github.com/happyvertical/smrt/blob/main/packages/commerce/agents/accounting-mapping.md"
30
+ title: "@happyvertical/smrt-commerce packages/commerce/agents/accounting-mapping.md"
31
+ - id: "agents-6"
32
+ resource: "https://github.com/happyvertical/smrt/blob/main/packages/commerce/agents/accounting-payment-sync.md"
33
+ title: "@happyvertical/smrt-commerce packages/commerce/agents/accounting-payment-sync.md"
34
+ - id: "agents-7"
23
35
  resource: "https://github.com/happyvertical/smrt/blob/main/packages/commerce/agents/commercial-ui.md"
24
36
  title: "@happyvertical/smrt-commerce packages/commerce/agents/commercial-ui.md"
25
- - id: "agents-4"
37
+ - id: "agents-8"
26
38
  resource: "https://github.com/happyvertical/smrt/blob/main/packages/commerce/agents/connected-payments.md"
27
39
  title: "@happyvertical/smrt-commerce packages/commerce/agents/connected-payments.md"
28
- - id: "agents-5"
40
+ - id: "agents-9"
29
41
  resource: "https://github.com/happyvertical/smrt/blob/main/packages/commerce/agents/contract-billing-schedules.md"
30
42
  title: "@happyvertical/smrt-commerce packages/commerce/agents/contract-billing-schedules.md"
31
- - id: "agents-6"
43
+ - id: "agents-10"
32
44
  resource: "https://github.com/happyvertical/smrt/blob/main/packages/commerce/agents/contract-money.md"
33
45
  title: "@happyvertical/smrt-commerce packages/commerce/agents/contract-money.md"
34
- - id: "agents-7"
46
+ - id: "agents-11"
35
47
  resource: "https://github.com/happyvertical/smrt/blob/main/packages/commerce/agents/cost-billing.md"
36
48
  title: "@happyvertical/smrt-commerce packages/commerce/agents/cost-billing.md"
37
- - id: "agents-8"
49
+ - id: "agents-12"
38
50
  resource: "https://github.com/happyvertical/smrt/blob/main/packages/commerce/agents/customer-funds.md"
39
51
  title: "@happyvertical/smrt-commerce packages/commerce/agents/customer-funds.md"
40
- - id: "agents-9"
52
+ - id: "agents-13"
41
53
  resource: "https://github.com/happyvertical/smrt/blob/main/packages/commerce/agents/customer-vendor-ui.md"
42
54
  title: "@happyvertical/smrt-commerce packages/commerce/agents/customer-vendor-ui.md"
43
- - id: "agents-10"
55
+ - id: "agents-14"
44
56
  resource: "https://github.com/happyvertical/smrt/blob/main/packages/commerce/agents/document-money.md"
45
57
  title: "@happyvertical/smrt-commerce packages/commerce/agents/document-money.md"
46
- - id: "agents-11"
58
+ - id: "agents-15"
47
59
  resource: "https://github.com/happyvertical/smrt/blob/main/packages/commerce/agents/estimate-conversion.md"
48
60
  title: "@happyvertical/smrt-commerce packages/commerce/agents/estimate-conversion.md"
49
- - id: "agents-12"
61
+ - id: "agents-16"
50
62
  resource: "https://github.com/happyvertical/smrt/blob/main/packages/commerce/agents/historical-sales.md"
51
63
  title: "@happyvertical/smrt-commerce packages/commerce/agents/historical-sales.md"
52
- - id: "agents-13"
64
+ - id: "agents-17"
53
65
  resource: "https://github.com/happyvertical/smrt/blob/main/packages/commerce/agents/invoice-quantity.md"
54
66
  title: "@happyvertical/smrt-commerce packages/commerce/agents/invoice-quantity.md"
55
- - id: "agents-14"
67
+ - id: "agents-18"
56
68
  resource: "https://github.com/happyvertical/smrt/blob/main/packages/commerce/agents/invoice-source-binding.md"
57
69
  title: "@happyvertical/smrt-commerce packages/commerce/agents/invoice-source-binding.md"
58
- - id: "agents-15"
70
+ - id: "agents-19"
59
71
  resource: "https://github.com/happyvertical/smrt/blob/main/packages/commerce/agents/money-calculator.md"
60
72
  title: "@happyvertical/smrt-commerce packages/commerce/agents/money-calculator.md"
61
- - id: "agents-16"
73
+ - id: "agents-20"
62
74
  resource: "https://github.com/happyvertical/smrt/blob/main/packages/commerce/agents/money-model.md"
63
75
  title: "@happyvertical/smrt-commerce packages/commerce/agents/money-model.md"
64
- - id: "agents-17"
76
+ - id: "agents-21"
65
77
  resource: "https://github.com/happyvertical/smrt/blob/main/packages/commerce/agents/money-upgrade.md"
66
78
  title: "@happyvertical/smrt-commerce packages/commerce/agents/money-upgrade.md"
67
- - id: "agents-18"
79
+ - id: "agents-22"
68
80
  resource: "https://github.com/happyvertical/smrt/blob/main/packages/commerce/agents/observed-purchase-prices.md"
69
81
  title: "@happyvertical/smrt-commerce packages/commerce/agents/observed-purchase-prices.md"
70
- - id: "agents-19"
82
+ - id: "agents-23"
71
83
  resource: "https://github.com/happyvertical/smrt/blob/main/packages/commerce/agents/ordinary-accounting.md"
72
84
  title: "@happyvertical/smrt-commerce packages/commerce/agents/ordinary-accounting.md"
73
- - id: "agents-20"
85
+ - id: "agents-24"
74
86
  resource: "https://github.com/happyvertical/smrt/blob/main/packages/commerce/agents/payment-allocations.md"
75
87
  title: "@happyvertical/smrt-commerce packages/commerce/agents/payment-allocations.md"
76
- - id: "agents-21"
88
+ - id: "agents-25"
77
89
  resource: "https://github.com/happyvertical/smrt/blob/main/packages/commerce/agents/purchasing-ui.md"
78
90
  title: "@happyvertical/smrt-commerce packages/commerce/agents/purchasing-ui.md"
79
- - id: "agents-22"
91
+ - id: "agents-26"
80
92
  resource: "https://github.com/happyvertical/smrt/blob/main/packages/commerce/agents/quote-ui.md"
81
93
  title: "@happyvertical/smrt-commerce packages/commerce/agents/quote-ui.md"
82
- - id: "agents-23"
94
+ - id: "agents-27"
83
95
  resource: "https://github.com/happyvertical/smrt/blob/main/packages/commerce/agents/received-sales-contract-money.md"
84
96
  title: "@happyvertical/smrt-commerce packages/commerce/agents/received-sales-contract-money.md"
85
- - id: "agents-24"
97
+ - id: "agents-28"
86
98
  resource: "https://github.com/happyvertical/smrt/blob/main/packages/commerce/agents/tax-codes.md"
87
99
  title: "@happyvertical/smrt-commerce packages/commerce/agents/tax-codes.md"
88
100
  ---
@@ -100,6 +112,10 @@ sources:
100
112
 
101
113
  - `packages/commerce/AGENTS.md`
102
114
  - `packages/commerce/README.md`
115
+ - `packages/commerce/agents/accounting-connection.md`
116
+ - `packages/commerce/agents/accounting-live-gate.md`
117
+ - `packages/commerce/agents/accounting-mapping.md`
118
+ - `packages/commerce/agents/accounting-payment-sync.md`
103
119
  - `packages/commerce/agents/commercial-ui.md`
104
120
  - `packages/commerce/agents/connected-payments.md`
105
121
  - `packages/commerce/agents/contract-billing-schedules.md`
@@ -156,6 +172,14 @@ sources:
156
172
 
157
173
  ## Models
158
174
 
175
+ - `AccountingConnection` (collection `accountingconnections`, extends `SmrtObject`)
176
+ - `AccountingConnectionCollection` (collection `accountingconnections`, extends `SmrtCollection`)
177
+ - `AccountingInvoiceReadback` (collection `accountinginvoicereadbacks`, extends `SmrtObject`)
178
+ - `AccountingInvoiceReadbackCollection` (collection `accountinginvoicereadbacks`, extends `SmrtCollection`)
179
+ - `AccountingMapping` (collection `accountingmappings`, extends `SmrtObject`)
180
+ - `AccountingMappingCollection` (collection `accountingmappings`, extends `SmrtCollection`)
181
+ - `AccountingPaymentSync` (collection `accountingpaymentsyncs`, extends `SmrtObject`)
182
+ - `AccountingPaymentSyncCollection` (collection `accountingpaymentsyncs`, extends `SmrtCollection`)
159
183
  - `Agreement` (collection `contracts`, extends `SalesContract`, STI table)
160
184
  - `BillingAccount` (collection `billingaccounts`, extends `SmrtObject`)
161
185
  - `BillingAccountCollection` (collection `billingaccounts`, extends `SmrtCollection`)
@@ -231,6 +255,14 @@ sources:
231
255
 
232
256
  ## MCP tools
233
257
 
258
+ - `accountingconnection_get`: get on `@happyvertical/smrt-commerce:AccountingConnection`
259
+ - `accountingconnection_list`: list on `@happyvertical/smrt-commerce:AccountingConnection`
260
+ - `accountinginvoicereadback_get`: get on `@happyvertical/smrt-commerce:AccountingInvoiceReadback`
261
+ - `accountinginvoicereadback_list`: list on `@happyvertical/smrt-commerce:AccountingInvoiceReadback`
262
+ - `accountingmapping_get`: get on `@happyvertical/smrt-commerce:AccountingMapping`
263
+ - `accountingmapping_list`: list on `@happyvertical/smrt-commerce:AccountingMapping`
264
+ - `accountingpaymentsync_get`: get on `@happyvertical/smrt-commerce:AccountingPaymentSync`
265
+ - `accountingpaymentsync_list`: list on `@happyvertical/smrt-commerce:AccountingPaymentSync`
234
266
  - `agreement_get`: get on `@happyvertical/smrt-commerce:Agreement`
235
267
  - `agreement_list`: list on `@happyvertical/smrt-commerce:Agreement`
236
268
  - `cart_get`: get on `@happyvertical/smrt-commerce:Cart`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@happyvertical/smrt-commerce",
3
- "version": "0.62.4",
3
+ "version": "0.62.6",
4
4
  "smrtJsdoc": "strict",
5
5
  "description": "Commerce models for the SMRT framework - contracts, fulfillments, payments",
6
6
  "type": "module",
@@ -65,18 +65,18 @@
65
65
  "dependencies": {
66
66
  "@happyvertical/accounting": "^0.113.0",
67
67
  "@happyvertical/payments": "^0.113.0",
68
- "@happyvertical/smrt-agents": "0.62.4",
69
- "@happyvertical/smrt-core": "0.62.4",
70
- "@happyvertical/smrt-jobs": "0.62.4",
71
- "@happyvertical/smrt-ledgers": "0.62.4",
72
- "@happyvertical/smrt-products": "0.62.4",
73
- "@happyvertical/smrt-profiles": "0.62.4",
74
- "@happyvertical/smrt-reports": "0.62.4",
75
- "@happyvertical/smrt-subscriptions": "0.62.4",
76
- "@happyvertical/smrt-svelte": "0.62.4",
77
- "@happyvertical/smrt-tenancy": "0.62.4",
78
- "@happyvertical/smrt-types": "0.62.4",
79
- "@happyvertical/smrt-ui": "0.62.4",
68
+ "@happyvertical/smrt-agents": "0.62.6",
69
+ "@happyvertical/smrt-core": "0.62.6",
70
+ "@happyvertical/smrt-jobs": "0.62.6",
71
+ "@happyvertical/smrt-ledgers": "0.62.6",
72
+ "@happyvertical/smrt-products": "0.62.6",
73
+ "@happyvertical/smrt-profiles": "0.62.6",
74
+ "@happyvertical/smrt-reports": "0.62.6",
75
+ "@happyvertical/smrt-subscriptions": "0.62.6",
76
+ "@happyvertical/smrt-svelte": "0.62.6",
77
+ "@happyvertical/smrt-tenancy": "0.62.6",
78
+ "@happyvertical/smrt-types": "0.62.6",
79
+ "@happyvertical/smrt-ui": "0.62.6",
80
80
  "@happyvertical/sql": "^0.113.0"
81
81
  },
82
82
  "peerDependencies": {
@@ -88,7 +88,7 @@
88
88
  }
89
89
  },
90
90
  "devDependencies": {
91
- "@happyvertical/smrt-vitest": "0.62.4",
91
+ "@happyvertical/smrt-vitest": "0.62.6",
92
92
  "@sveltejs/package": "^2.5.8",
93
93
  "@sveltejs/vite-plugin-svelte": "^7.3.0",
94
94
  "@testing-library/jest-dom": "^7.0.1",
@@ -119,6 +119,6 @@
119
119
  "test:e2e:invoices": "playwright test -c e2e/invoices/playwright.config.ts",
120
120
  "test:e2e:pricing": "cd ../.. && QUOTE_BROWSER_EXTENSION=packages/commerce/test-support/pricing-browser.mjs node packages/commerce/test-support/quote-browser.mjs",
121
121
  "test:e2e:purchasing": "cd ../.. && QUOTE_BROWSER_EXTENSION=packages/commerce/test-support/purchasing-browser-extension.mjs node packages/commerce/test-support/quote-browser.mjs && QUOTE_BROWSER_EXTENSION=packages/commerce/test-support/purchasing-header-browser.mjs node packages/commerce/test-support/quote-browser.mjs",
122
- "test:pglite": "node ../core/scripts/test-pglite.mjs src/__tests__/customer-display-projection.test.ts src/__tests__/customer-write-through.test.ts"
122
+ "test:pglite": "node ../core/scripts/test-pglite.mjs src/__tests__/customer-display-projection.test.ts src/__tests__/customer-write-through.test.ts src/__tests__/accounting-connection.test.ts src/__tests__/accounting-mapping-records.test.ts"
123
123
  }
124
124
  }
@@ -1,260 +0,0 @@
1
- import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
2
- import { MoneyValidationError } from "../money.js";
3
- import { a as assertCommerceMoneySchemaCurrent, f as DOCUMENT_MONEY_READ_REBIND, p as DOCUMENT_MONEY_WRITE } from "./detect-DAE-_NAk.js";
4
- import { n as withTenantMoneyCollectionRead } from "./tenant-money-barrier-Bmu4YiID.js";
5
- import { SmrtCollection, SmrtObject, crossPackageRef, field, foreignKey, smrt } from "@happyvertical/smrt-core";
6
- import { TenantScoped, getTenantId, queryGlobal, queryWithGlobals, tenantId } from "@happyvertical/smrt-tenancy";
7
- //#region src/models/ContractLineItem.ts
8
- var __defProp = Object.defineProperty;
9
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
10
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
11
- enumerable: true,
12
- configurable: true,
13
- writable: true,
14
- value
15
- }) : obj[key] = value;
16
- var __decorateClass = (decorators, target, key, kind) => {
17
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
18
- for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result;
19
- if (kind && result) __defProp(target, key, result);
20
- return result;
21
- };
22
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
23
- var ContractLineItem = class extends SmrtObject {
24
- /** @internal Collection read guard returns this snapshot on its root DB. */
25
- rebindMoneyRead(capability, db) {
26
- if (capability !== DOCUMENT_MONEY_READ_REBIND) throw new Error("Contract line read rebinding requires the owning capability");
27
- this._db = db;
28
- this.options.db = db;
29
- return this;
30
- }
31
- tenantId = null;
32
- contractId = "";
33
- description = "";
34
- quantity = 1;
35
- unitPrice = 0;
36
- discount = 0;
37
- discountType = "none";
38
- discountRate = "0.0";
39
- taxRate = 0;
40
- taxMode = "inherit";
41
- taxCodeId = null;
42
- taxCodeCode = null;
43
- taxCodeName = null;
44
- taxComponentsJson = null;
45
- get taxComponents() {
46
- if (this.taxComponentsJson === null) return [];
47
- try {
48
- const value = JSON.parse(this.taxComponentsJson);
49
- if (!Array.isArray(value)) return [];
50
- return value.filter((entry) => !!entry && typeof entry === "object" && typeof entry.taxComponentId === "string" && typeof entry.name === "string" && typeof entry.percent === "string" && Number.isSafeInteger(entry.taxMinor));
51
- } catch {
52
- return [];
53
- }
54
- }
55
- set taxComponents(value) {
56
- this.taxComponentsJson = JSON.stringify(value);
57
- }
58
- taxAmount = 0;
59
- /** Stable issue/freeze identity, independent of lifecycle updated_at. */
60
- moneySnapshotId = "";
61
- amount = 0;
62
- productId = "";
63
- /**
64
- * SKU or item code
65
- */
66
- sku = "";
67
- /**
68
- * Start date (for lease/subscription items)
69
- */
70
- startDate = null;
71
- /**
72
- * End date (for lease/subscription items)
73
- */
74
- endDate = null;
75
- /**
76
- * Billing period (for subscriptions: 'monthly', 'yearly', etc.)
77
- */
78
- billingPeriod = "";
79
- /**
80
- * Sort order within the contract
81
- */
82
- sortOrder = 0;
83
- constructor(options = {}) {
84
- super(options);
85
- if (options.tenantId !== void 0) this.tenantId = options.tenantId;
86
- if (options.contractId !== void 0) this.contractId = options.contractId;
87
- if (options.description !== void 0) this.description = options.description;
88
- if (options.quantity !== void 0) this.quantity = options.quantity;
89
- if (options.unitPrice !== void 0) this.unitPrice = options.unitPrice;
90
- if (options.discount !== void 0) this.discount = options.discount;
91
- if (options.discountType !== void 0) this.discountType = options.discountType;
92
- if (options.discountRate !== void 0) this.discountRate = options.discountRate;
93
- if (options.taxRate !== void 0) this.taxRate = options.taxRate;
94
- if (options.taxMode !== void 0) this.taxMode = options.taxMode;
95
- if (options.taxCodeId !== void 0) this.taxCodeId = options.taxCodeId;
96
- if (options.taxCodeCode !== void 0) this.taxCodeCode = options.taxCodeCode;
97
- if (options.taxCodeName !== void 0) this.taxCodeName = options.taxCodeName;
98
- if (options.taxComponentsJson !== void 0) this.taxComponentsJson = options.taxComponentsJson;
99
- if (options.taxComponents !== void 0) this.taxComponents = structuredClone(options.taxComponents);
100
- if (options.taxAmount !== void 0) this.taxAmount = options.taxAmount;
101
- if (options.moneySnapshotId !== void 0) this.moneySnapshotId = options.moneySnapshotId;
102
- if (options.amount !== void 0) this.amount = options.amount;
103
- if (options.productId !== void 0) this.productId = options.productId;
104
- if (options.sku !== void 0) this.sku = options.sku;
105
- if (options.startDate !== void 0) this.startDate = options.startDate;
106
- if (options.endDate !== void 0) this.endDate = options.endDate;
107
- if (options.billingPeriod !== void 0) this.billingPeriod = options.billingPeriod;
108
- if (options.sortOrder !== void 0) this.sortOrder = options.sortOrder;
109
- }
110
- async initialize() {
111
- await super.initialize();
112
- if (this.isPersisted) {
113
- const { assertHydratedMoneyRowCurrent } = await import("./detect-DAE-_NAk.js").then((n) => n.c);
114
- await assertHydratedMoneyRowCurrent(this);
115
- }
116
- return this;
117
- }
118
- async save(options) {
119
- const { saveContractLineItem } = await import("./contract-money-BoKHNfV6.js").then((n) => n.n);
120
- return await saveContractLineItem(this, options);
121
- }
122
- /** @internal Contract aggregate persistence only. */
123
- async saveDerived(capability, options) {
124
- if (capability !== DOCUMENT_MONEY_WRITE) throw new Error("Contract line money write capability is required");
125
- for (const [field2, value] of [["unitPrice", this.unitPrice], ["discount", this.discount]]) if (!Number.isSafeInteger(value)) throw new MoneyValidationError("UNSAFE_MONEY", `Contract line ${field2} ${value} must be a safe integer number of minor units`);
126
- return await super.save(options);
127
- }
128
- async delete(options = {}) {
129
- const { deleteContractLineItem } = await import("./contract-money-BoKHNfV6.js").then((n) => n.n);
130
- await deleteContractLineItem(this, options);
131
- }
132
- /** @internal Contract aggregate persistence only. */
133
- async deleteDerived(capability, options = {}) {
134
- if (capability !== DOCUMENT_MONEY_WRITE) throw new Error("Contract line money write capability is required");
135
- await super.delete(options);
136
- }
137
- /**
138
- * Check if this is a subscription/recurring item
139
- */
140
- isRecurring() {
141
- return !!this.billingPeriod && !!this.startDate;
142
- }
143
- /**
144
- * Check if subscription is active
145
- */
146
- isSubscriptionActive() {
147
- if (!this.isRecurring()) return false;
148
- if (!this.startDate) return false;
149
- const now = /* @__PURE__ */ new Date();
150
- if (now < this.startDate) return false;
151
- if (this.endDate && now > this.endDate) return false;
152
- return true;
153
- }
154
- };
155
- __publicField(ContractLineItem, "__smrtPackage__", "@happyvertical/smrt-commerce");
156
- __decorateClass([tenantId({ nullable: true })], ContractLineItem.prototype, "tenantId", 2);
157
- __decorateClass([field({ description: "The order, quote or agreement this line belongs to." }), foreignKey("Contract", { role: "items" })], ContractLineItem.prototype, "contractId", 2);
158
- __decorateClass([field({ description: "What is being sold or bought on this line." })], ContractLineItem.prototype, "description", 2);
159
- __decorateClass([field({ description: "How many." })], ContractLineItem.prototype, "quantity", 2);
160
- __decorateClass([field({
161
- description: "The price of one, before discount; includes tax when the document's prices include tax.",
162
- ui: { format: "money" }
163
- })], ContractLineItem.prototype, "unitPrice", 2);
164
- __decorateClass([field({ ui: { format: "money" } })], ContractLineItem.prototype, "discount", 2);
165
- __decorateClass([field({ type: "decimal" })], ContractLineItem.prototype, "discountRate", 2);
166
- __decorateClass([field({ description: "The stored fractional tax rate for this line (0.05 means 5%)." })], ContractLineItem.prototype, "taxRate", 2);
167
- __decorateClass([foreignKey("TaxCode", { nullable: true })], ContractLineItem.prototype, "taxCodeId", 2);
168
- __decorateClass([field({ ui: { format: "money" } })], ContractLineItem.prototype, "taxAmount", 2);
169
- __decorateClass([field({
170
- description: "The line amount: net of discount, and including tax only when the document's prices include tax.",
171
- ui: { format: "money" }
172
- })], ContractLineItem.prototype, "amount", 2);
173
- __decorateClass([field({ description: "The product this line is for, if it is one you list." }), crossPackageRef("@happyvertical/smrt-products:Product")], ContractLineItem.prototype, "productId", 2);
174
- ContractLineItem = __decorateClass([TenantScoped({ mode: "optional" }), smrt({
175
- tableStrategy: "sti",
176
- api: { include: [
177
- "list",
178
- "get",
179
- "create",
180
- "update",
181
- "delete"
182
- ] },
183
- mcp: { include: ["list", "get"] },
184
- cli: { skipApiCheck: true }
185
- })], ContractLineItem);
186
- //#endregion
187
- //#region src/collections/ContractLineItemCollection.ts
188
- var ContractLineItemCollection_exports = /* @__PURE__ */ __exportAll({ ContractLineItemCollection: () => ContractLineItemCollection });
189
- var ContractLineItemCollection = class extends SmrtCollection {
190
- static _itemClass = ContractLineItem;
191
- async withMoneyRead(operation) {
192
- const rootDb = this.db;
193
- const tenantId = getTenantId();
194
- if (!tenantId) {
195
- await assertCommerceMoneySchemaCurrent(rootDb);
196
- return operation();
197
- }
198
- const result = await withTenantMoneyCollectionRead(rootDb, tenantId, (boundDb) => this.withDatabase(boundDb, operation));
199
- if (result instanceof ContractLineItem) result.rebindMoneyRead(DOCUMENT_MONEY_READ_REBIND, rootDb);
200
- else if (Array.isArray(result)) {
201
- for (const item of result) if (item instanceof ContractLineItem) item.rebindMoneyRead(DOCUMENT_MONEY_READ_REBIND, rootDb);
202
- }
203
- return result;
204
- }
205
- async get(filter, options = {}) {
206
- return this.withMoneyRead(() => super.get(filter, options));
207
- }
208
- async list(options = {}) {
209
- return this.withMoneyRead(() => super.list(options));
210
- }
211
- /**
212
- * Find contract line items by their parent contract.
213
- *
214
- * @param contractId - Contract ID
215
- * @returns Array of contract line items, sorted by sortOrder
216
- */
217
- async findByContract(contractId) {
218
- return await this.list({
219
- where: { contractId },
220
- orderBy: "sortOrder ASC"
221
- });
222
- }
223
- /**
224
- * Find all contract line items belonging to a specific tenant
225
- *
226
- * @param tenantId - Tenant ID
227
- * @returns Array of contract line items for the tenant
228
- */
229
- async findByTenant(tenantId) {
230
- return this.list({ where: { tenantId } });
231
- }
232
- /**
233
- * Find all global contract line items (not associated with any tenant).
234
- *
235
- * Routes through the shared tenant-global helper so it does not throw under
236
- * an active tenant context (an explicit `tenant_id IS NULL` filter would be
237
- * flagged as an isolation violation). (#1600)
238
- *
239
- * @returns Array of global contract line items
240
- */
241
- async findGlobal() {
242
- return queryGlobal(this);
243
- }
244
- /**
245
- * Find contract line items for a tenant including global line items.
246
- *
247
- * Fails closed if an active tenant context requests a different tenant's
248
- * rows; the admin/system path keeps the cross-tenant capability. (#1600)
249
- *
250
- * @param tenantId - Tenant ID
251
- * @returns Array of tenant-specific and global contract line items
252
- */
253
- async findWithGlobals(tenantId) {
254
- return queryWithGlobals(this, tenantId, "ContractLineItem.findWithGlobals");
255
- }
256
- };
257
- //#endregion
258
- export { ContractLineItemCollection_exports as n, ContractLineItem as r, ContractLineItemCollection as t };
259
-
260
- //# sourceMappingURL=ContractLineItemCollection-BKHy-nR8.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ContractLineItemCollection-BKHy-nR8.js","names":["field"],"sources":["../../src/models/ContractLineItem.ts","../../src/collections/ContractLineItemCollection.ts"],"sourcesContent":["/**\n * ContractLineItem model - individual items on a contract\n * @packageDocumentation\n */\n\nimport {\n crossPackageRef,\n field,\n foreignKey,\n SmrtObject,\n type SmrtSaveOptions,\n smrt,\n} from '@happyvertical/smrt-core';\nimport type { DatabaseInterface } from '@happyvertical/smrt-core/migrations';\nimport { TenantScoped, tenantId } from '@happyvertical/smrt-tenancy';\nimport {\n DOCUMENT_MONEY_READ_REBIND,\n DOCUMENT_MONEY_WRITE,\n type DocumentMoneyReadRebindCapability,\n type DocumentMoneyWriteCapability,\n} from '../document-money-internal.js';\nimport { MoneyValidationError } from '../money.js';\nimport type {\n ContractLineItemOptions,\n ContractTaxComponentSnapshot,\n} from '../types/index.js';\n\n/**\n * ContractLineItem represents a single line item on a contract.\n *\n * Line items contain the details of what is being sold/purchased,\n * including quantity, pricing, and optional subscription details.\n *\n * @example\n * ```typescript\n * const lineItem = await lineItems.create({\n * contractId: order.id,\n * description: 'Widget Pro',\n * quantity: 10,\n * unitPrice: 4999, // $49.99 in cents\n * taxRate: 0.08\n * });\n * ```\n */\n@TenantScoped({ mode: 'optional' })\n@smrt({\n tableStrategy: 'sti',\n api: { include: ['list', 'get', 'create', 'update', 'delete'] },\n mcp: { include: ['list', 'get'] },\n cli: { skipApiCheck: true },\n})\nexport class ContractLineItem extends SmrtObject { static __smrtPackage__ = \"@happyvertical/smrt-commerce\";\n /** @internal Collection read guard returns this snapshot on its root DB. */\n rebindMoneyRead(\n capability: DocumentMoneyReadRebindCapability,\n db: DatabaseInterface,\n ): this {\n if (capability !== DOCUMENT_MONEY_READ_REBIND)\n throw new Error(\n 'Contract line read rebinding requires the owning capability',\n );\n this._db = db;\n this.options.db = db;\n return this;\n }\n\n /**\n * Tenant ID for multi-tenant isolation\n * Nullable to support both tenant-scoped and global line items\n */\n @tenantId({ nullable: true })\n tenantId: string | null = null;\n\n /**\n * Parent contract\n */\n @field({ description: 'The order, quote or agreement this line belongs to.' })\n @foreignKey('Contract', { role: 'items' })\n contractId: string = '';\n\n /**\n * Item description\n */\n @field({ description: 'What is being sold or bought on this line.' })\n description: string = '';\n\n /**\n * Quantity ordered. Decimal on purpose — contracts price fractional\n * quantities (hours, weight, bandwidth), as do invoice line items.\n */\n @field({ description: 'How many.' })\n quantity: number = 1.0;\n\n /**\n * Unit price before discount, in **integer minor units** (cents, satoshis),\n * in the document's pricing mode: tax-inclusive when its `lineAmountType`\n * is `inclusive`.\n *\n * The `= 0` initializer is load-bearing: SMRT maps an integer literal to\n * INTEGER and a decimal literal to DECIMAL. Money is exact, so `$49.99` is\n * `4999` (#2401).\n */\n @field({\n description:\n \"The price of one, before discount; includes tax when the document's prices include tax.\",\n ui: { format: 'money' },\n })\n unitPrice: number = 0;\n\n /**\n * Discount amount (flat, not percentage), in integer minor units (#2401).\n */\n @field({ ui: { format: 'money' } })\n discount: number = 0;\n\n discountType: 'none' | 'percent' | 'amount' = 'none';\n\n @field({ type: 'decimal' })\n discountRate = '0.0';\n\n /**\n * Tax rate as decimal (e.g., 0.08 for 8%). A rate is inherently fractional,\n * so it stays DECIMAL — INTEGER would truncate every meaningful value.\n */\n @field({\n description:\n 'The stored fractional tax rate for this line (0.05 means 5%).',\n })\n taxRate: number = 0.0;\n\n taxMode: 'inherit' | 'override' = 'inherit';\n\n @foreignKey('TaxCode', { nullable: true })\n taxCodeId: string | null = null;\n\n taxCodeCode: string | null = null;\n\n taxCodeName: string | null = null;\n\n taxComponentsJson: string | null = null;\n\n get taxComponents(): ContractTaxComponentSnapshot[] {\n if (this.taxComponentsJson === null) return [];\n try {\n const value: unknown = JSON.parse(this.taxComponentsJson);\n if (!Array.isArray(value)) return [];\n return value.filter(\n (entry): entry is ContractTaxComponentSnapshot =>\n !!entry &&\n typeof entry === 'object' &&\n typeof (entry as ContractTaxComponentSnapshot).taxComponentId ===\n 'string' &&\n typeof (entry as ContractTaxComponentSnapshot).name === 'string' &&\n typeof (entry as ContractTaxComponentSnapshot).percent === 'string' &&\n Number.isSafeInteger(\n (entry as ContractTaxComponentSnapshot).taxMinor,\n ),\n );\n } catch {\n return [];\n }\n }\n\n set taxComponents(value: ContractTaxComponentSnapshot[]) {\n this.taxComponentsJson = JSON.stringify(value);\n }\n\n /** Exact sum of frozen component taxes, in integer minor units. */\n @field({ ui: { format: 'money' } })\n taxAmount = 0;\n\n /** Stable issue/freeze identity, independent of lifecycle updated_at. */\n moneySnapshotId = '';\n\n /**\n * Line amount in integer minor units: net of discount and before tax for\n * `exclusive` / `none` documents, and tax-inclusive for `inclusive` ones;\n * {@link taxAmount} holds the tax. Derived by the Contract money aggregate\n * on every save.\n */\n @field({\n description:\n \"The line amount: net of discount, and including tax only when the document's prices include tax.\",\n ui: { format: 'money' },\n })\n amount: number = 0;\n\n /**\n * Optional product reference (cross-package, plain string)\n */\n @field({\n description: 'The product this line is for, if it is one you list.',\n })\n @crossPackageRef('@happyvertical/smrt-products:Product')\n productId: string = '';\n\n /**\n * SKU or item code\n */\n sku: string = '';\n\n /**\n * Start date (for lease/subscription items)\n */\n startDate: Date | null = null;\n\n /**\n * End date (for lease/subscription items)\n */\n endDate: Date | null = null;\n\n /**\n * Billing period (for subscriptions: 'monthly', 'yearly', etc.)\n */\n billingPeriod: string = '';\n\n /**\n * Sort order within the contract\n */\n sortOrder: number = 0;\n\n constructor(options: ContractLineItemOptions = {}) {\n super(options);\n if (options.tenantId !== undefined) this.tenantId = options.tenantId;\n if (options.contractId !== undefined) this.contractId = options.contractId;\n if (options.description !== undefined)\n this.description = options.description;\n if (options.quantity !== undefined) this.quantity = options.quantity;\n if (options.unitPrice !== undefined) this.unitPrice = options.unitPrice;\n if (options.discount !== undefined) this.discount = options.discount;\n if (options.discountType !== undefined)\n this.discountType = options.discountType;\n if (options.discountRate !== undefined)\n this.discountRate = options.discountRate;\n if (options.taxRate !== undefined) this.taxRate = options.taxRate;\n if (options.taxMode !== undefined) this.taxMode = options.taxMode;\n if (options.taxCodeId !== undefined) this.taxCodeId = options.taxCodeId;\n if (options.taxCodeCode !== undefined)\n this.taxCodeCode = options.taxCodeCode;\n if (options.taxCodeName !== undefined)\n this.taxCodeName = options.taxCodeName;\n if (options.taxComponentsJson !== undefined)\n this.taxComponentsJson = options.taxComponentsJson;\n if (options.taxComponents !== undefined)\n this.taxComponents = structuredClone(options.taxComponents);\n if (options.taxAmount !== undefined) this.taxAmount = options.taxAmount;\n if (options.moneySnapshotId !== undefined)\n this.moneySnapshotId = options.moneySnapshotId;\n if (options.amount !== undefined) this.amount = options.amount;\n if (options.productId !== undefined) this.productId = options.productId;\n if (options.sku !== undefined) this.sku = options.sku;\n if (options.startDate !== undefined) this.startDate = options.startDate;\n if (options.endDate !== undefined) this.endDate = options.endDate;\n if (options.billingPeriod !== undefined)\n this.billingPeriod = options.billingPeriod;\n if (options.sortOrder !== undefined) this.sortOrder = options.sortOrder;\n }\n\n override async initialize(): Promise<this> {\n await super.initialize();\n // A row read from the database must not be old-format money data.\n if (this.isPersisted) {\n const { assertHydratedMoneyRowCurrent } = await import(\n '../upgrade/detect.js'\n );\n await assertHydratedMoneyRowCurrent(this);\n }\n return this;\n }\n\n override async save(options?: SmrtSaveOptions): Promise<this> {\n const { saveContractLineItem } = await import('../contract-money.js');\n return (await saveContractLineItem(this, options)) as this;\n }\n\n /** @internal Contract aggregate persistence only. */\n async saveDerived(\n capability: DocumentMoneyWriteCapability,\n options?: SmrtSaveOptions,\n ): Promise<this> {\n if (capability !== DOCUMENT_MONEY_WRITE)\n throw new Error('Contract line money write capability is required');\n // Money is integer minor units: refuse a major-unit price before it can\n // reach the database (#2401), ahead of the aggregate recompute.\n for (const [field, value] of [\n ['unitPrice', this.unitPrice],\n ['discount', this.discount],\n ] as const)\n if (!Number.isSafeInteger(value))\n throw new MoneyValidationError(\n 'UNSAFE_MONEY',\n `Contract line ${field} ${value} must be a safe integer number of minor units`,\n );\n return (await super.save(options)) as this;\n }\n\n override async delete(\n options: { expectedUpdatedAt?: Date | string } = {},\n ): Promise<void> {\n const { deleteContractLineItem } = await import('../contract-money.js');\n await deleteContractLineItem(this, options);\n }\n\n /** @internal Contract aggregate persistence only. */\n async deleteDerived(\n capability: DocumentMoneyWriteCapability,\n options: { expectedUpdatedAt?: Date | string } = {},\n ): Promise<void> {\n if (capability !== DOCUMENT_MONEY_WRITE)\n throw new Error('Contract line money write capability is required');\n await super.delete(options);\n }\n\n /**\n * Check if this is a subscription/recurring item\n */\n isRecurring(): boolean {\n return !!this.billingPeriod && !!this.startDate;\n }\n\n /**\n * Check if subscription is active\n */\n isSubscriptionActive(): boolean {\n if (!this.isRecurring()) return false;\n if (!this.startDate) return false;\n\n const now = new Date();\n if (now < this.startDate) return false;\n if (this.endDate && now > this.endDate) return false;\n\n return true;\n }\n}\n\nexport default ContractLineItem;\n","/**\n * ContractLineItemCollection - Collection manager for ContractLineItem objects\n * @packageDocumentation\n */\n\nimport {\n SmrtCollection,\n type SmrtListOptions,\n type SmrtObject,\n type SmrtSelectedRow,\n type SmrtSelectField,\n type SmrtStiReadScope,\n type SmrtWhereClause,\n} from '@happyvertical/smrt-core';\nimport {\n getTenantId,\n queryGlobal,\n queryWithGlobals,\n} from '@happyvertical/smrt-tenancy';\nimport { DOCUMENT_MONEY_READ_REBIND } from '../document-money-internal.js';\nimport { ContractLineItem } from '../models/ContractLineItem.js';\nimport { withTenantMoneyCollectionRead } from '../tenant-money-barrier.js';\nimport { assertCommerceMoneySchemaCurrent } from '../upgrade/detect.js';\n\nexport class ContractLineItemCollection extends SmrtCollection<ContractLineItem> {\n static readonly _itemClass = ContractLineItem;\n\n private async withMoneyRead<T>(operation: () => Promise<T>): Promise<T> {\n const rootDb = this.db;\n const tenantId = getTenantId();\n if (!tenantId) {\n // Without a tenant, still refuse a database with old money storage.\n await assertCommerceMoneySchemaCurrent(rootDb);\n return operation();\n }\n const result = await withTenantMoneyCollectionRead(\n rootDb,\n tenantId,\n (boundDb) => this.withDatabase(boundDb, operation),\n );\n if (result instanceof ContractLineItem)\n result.rebindMoneyRead(DOCUMENT_MONEY_READ_REBIND, rootDb);\n else if (Array.isArray(result))\n for (const item of result)\n if (item instanceof ContractLineItem)\n item.rebindMoneyRead(DOCUMENT_MONEY_READ_REBIND, rootDb);\n return result;\n }\n\n override async get(\n filter: string | SmrtWhereClause<ContractLineItem>,\n options: Parameters<SmrtCollection<ContractLineItem>['get']>[1] = {},\n ): Promise<ContractLineItem | null> {\n return this.withMoneyRead(() => super.get(filter, options));\n }\n\n override async list<\n const Select extends readonly SmrtSelectField<ContractLineItem>[],\n >(\n options: Omit<SmrtListOptions<ContractLineItem>, 'select' | 'stiScope'> & {\n select: Select;\n include?: never;\n stiScope: SmrtStiReadScope;\n },\n ): Promise<Record<string, unknown>[]>;\n override async list<\n const Select extends readonly SmrtSelectField<ContractLineItem>[],\n >(\n options: Omit<SmrtListOptions<ContractLineItem>, 'select' | 'stiScope'> & {\n select: Select;\n include?: never;\n stiScope?: undefined;\n },\n ): Promise<SmrtSelectedRow<ContractLineItem, Select>[]>;\n override async list(\n options: Omit<SmrtListOptions<ContractLineItem>, 'select' | 'stiScope'> & {\n select?: undefined;\n stiScope: SmrtStiReadScope;\n },\n ): Promise<SmrtObject[]>;\n override async list(options?: undefined): Promise<ContractLineItem[]>;\n override async list(\n options: Omit<SmrtListOptions<ContractLineItem>, 'select' | 'stiScope'> & {\n select?: undefined;\n stiScope?: undefined;\n },\n ): Promise<ContractLineItem[]>;\n override async list(\n options:\n | (Omit<SmrtListOptions<ContractLineItem>, 'select'> & {\n select?: undefined;\n })\n | undefined,\n ): Promise<SmrtObject[]>;\n override async list(\n options: SmrtListOptions<ContractLineItem> | undefined,\n ): Promise<SmrtObject[] | Record<string, unknown>[]>;\n override async list(\n options: SmrtListOptions<ContractLineItem> = {},\n ): Promise<SmrtObject[] | Record<string, unknown>[]> {\n return this.withMoneyRead(() => super.list(options));\n }\n\n /**\n * Find contract line items by their parent contract.\n *\n * @param contractId - Contract ID\n * @returns Array of contract line items, sorted by sortOrder\n */\n async findByContract(contractId: string): Promise<ContractLineItem[]> {\n return await this.list({\n where: { contractId },\n orderBy: 'sortOrder ASC',\n });\n }\n\n // ============================================================================\n // Tenant Helper Methods\n // ============================================================================\n\n /**\n * Find all contract line items belonging to a specific tenant\n *\n * @param tenantId - Tenant ID\n * @returns Array of contract line items for the tenant\n */\n async findByTenant(tenantId: string): Promise<ContractLineItem[]> {\n return this.list({ where: { tenantId } });\n }\n\n /**\n * Find all global contract line items (not associated with any tenant).\n *\n * Routes through the shared tenant-global helper so it does not throw under\n * an active tenant context (an explicit `tenant_id IS NULL` filter would be\n * flagged as an isolation violation). (#1600)\n *\n * @returns Array of global contract line items\n */\n async findGlobal(): Promise<ContractLineItem[]> {\n return queryGlobal<ContractLineItem>(this);\n }\n\n /**\n * Find contract line items for a tenant including global line items.\n *\n * Fails closed if an active tenant context requests a different tenant's\n * rows; the admin/system path keeps the cross-tenant capability. (#1600)\n *\n * @param tenantId - Tenant ID\n * @returns Array of tenant-specific and global contract line items\n */\n async findWithGlobals(tenantId: string): Promise<ContractLineItem[]> {\n return queryWithGlobals<ContractLineItem>(\n this,\n tenantId,\n 'ContractLineItem.findWithGlobals',\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAmDO,IAAM,mBAAN,cAA+B,WAAW;;CAE/C,gBACE,YACA,IACM;EACN,IAAI,eAAe,4BACjB,MAAM,IAAI,MACR,6DACF;EACF,KAAK,MAAM;EACX,KAAK,QAAQ,KAAK;EAClB,OAAO;CACT;CAOA,WAA0B;CAO1B,aAAqB;CAMrB,cAAsB;CAOtB,WAAmB;CAgBnB,YAAoB;CAMpB,WAAmB;CAEnB,eAA8C;CAG9C,eAAe;CAUf,UAAkB;CAElB,UAAkC;CAGlC,YAA2B;CAE3B,c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