@dainamite/billing 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (248) hide show
  1. package/CHANGELOG.md +658 -0
  2. package/LICENSE +21 -0
  3. package/README.md +77 -0
  4. package/dist/modules/billing/acl.js +20 -0
  5. package/dist/modules/billing/acl.js.map +7 -0
  6. package/dist/modules/billing/api/accounts/route.js +182 -0
  7. package/dist/modules/billing/api/accounts/route.js.map +7 -0
  8. package/dist/modules/billing/api/export/account/[id]/route.js +170 -0
  9. package/dist/modules/billing/api/export/account/[id]/route.js.map +7 -0
  10. package/dist/modules/billing/api/invoices/[id]/route.js +85 -0
  11. package/dist/modules/billing/api/invoices/[id]/route.js.map +7 -0
  12. package/dist/modules/billing/api/invoices/add-line/route.js +69 -0
  13. package/dist/modules/billing/api/invoices/add-line/route.js.map +7 -0
  14. package/dist/modules/billing/api/invoices/edit-line/route.js +78 -0
  15. package/dist/modules/billing/api/invoices/edit-line/route.js.map +7 -0
  16. package/dist/modules/billing/api/invoices/post/route.js +74 -0
  17. package/dist/modules/billing/api/invoices/post/route.js.map +7 -0
  18. package/dist/modules/billing/api/invoices/remove-line/route.js +69 -0
  19. package/dist/modules/billing/api/invoices/remove-line/route.js.map +7 -0
  20. package/dist/modules/billing/api/invoices/route.js +109 -0
  21. package/dist/modules/billing/api/invoices/route.js.map +7 -0
  22. package/dist/modules/billing/api/items/bulk/route.js +74 -0
  23. package/dist/modules/billing/api/items/bulk/route.js.map +7 -0
  24. package/dist/modules/billing/api/items/route.js +224 -0
  25. package/dist/modules/billing/api/items/route.js.map +7 -0
  26. package/dist/modules/billing/api/openapi.js +25 -0
  27. package/dist/modules/billing/api/openapi.js.map +7 -0
  28. package/dist/modules/billing/api/run-outcomes/route.js +122 -0
  29. package/dist/modules/billing/api/run-outcomes/route.js.map +7 -0
  30. package/dist/modules/billing/api/runs/retry-failed/route.js +70 -0
  31. package/dist/modules/billing/api/runs/retry-failed/route.js.map +7 -0
  32. package/dist/modules/billing/api/runs/route.js +143 -0
  33. package/dist/modules/billing/api/runs/route.js.map +7 -0
  34. package/dist/modules/billing/api/test-invoices/wipe/route.js +65 -0
  35. package/dist/modules/billing/api/test-invoices/wipe/route.js.map +7 -0
  36. package/dist/modules/billing/api/usage/route.js +138 -0
  37. package/dist/modules/billing/api/usage/route.js.map +7 -0
  38. package/dist/modules/billing/backend/billing/accounts/[id]/page.js +402 -0
  39. package/dist/modules/billing/backend/billing/accounts/[id]/page.js.map +7 -0
  40. package/dist/modules/billing/backend/billing/accounts/[id]/page.meta.js +25 -0
  41. package/dist/modules/billing/backend/billing/accounts/[id]/page.meta.js.map +7 -0
  42. package/dist/modules/billing/backend/billing/accounts/create/page.js +82 -0
  43. package/dist/modules/billing/backend/billing/accounts/create/page.js.map +7 -0
  44. package/dist/modules/billing/backend/billing/accounts/create/page.meta.js +25 -0
  45. package/dist/modules/billing/backend/billing/accounts/create/page.meta.js.map +7 -0
  46. package/dist/modules/billing/backend/billing/accounts/page.js +173 -0
  47. package/dist/modules/billing/backend/billing/accounts/page.js.map +7 -0
  48. package/dist/modules/billing/backend/billing/accounts/page.meta.js +18 -0
  49. package/dist/modules/billing/backend/billing/accounts/page.meta.js.map +7 -0
  50. package/dist/modules/billing/backend/billing/invoices/[id]/page.js +500 -0
  51. package/dist/modules/billing/backend/billing/invoices/[id]/page.js.map +7 -0
  52. package/dist/modules/billing/backend/billing/invoices/[id]/page.meta.js +25 -0
  53. package/dist/modules/billing/backend/billing/invoices/[id]/page.meta.js.map +7 -0
  54. package/dist/modules/billing/backend/billing/invoices/page.js +187 -0
  55. package/dist/modules/billing/backend/billing/invoices/page.js.map +7 -0
  56. package/dist/modules/billing/backend/billing/invoices/page.meta.js +18 -0
  57. package/dist/modules/billing/backend/billing/invoices/page.meta.js.map +7 -0
  58. package/dist/modules/billing/backend/billing/items/[id]/page.js +265 -0
  59. package/dist/modules/billing/backend/billing/items/[id]/page.js.map +7 -0
  60. package/dist/modules/billing/backend/billing/items/[id]/page.meta.js +25 -0
  61. package/dist/modules/billing/backend/billing/items/[id]/page.meta.js.map +7 -0
  62. package/dist/modules/billing/backend/billing/items/create/page.js +90 -0
  63. package/dist/modules/billing/backend/billing/items/create/page.js.map +7 -0
  64. package/dist/modules/billing/backend/billing/items/create/page.meta.js +25 -0
  65. package/dist/modules/billing/backend/billing/items/create/page.meta.js.map +7 -0
  66. package/dist/modules/billing/backend/billing/items/page.js +208 -0
  67. package/dist/modules/billing/backend/billing/items/page.js.map +7 -0
  68. package/dist/modules/billing/backend/billing/items/page.meta.js +18 -0
  69. package/dist/modules/billing/backend/billing/items/page.meta.js.map +7 -0
  70. package/dist/modules/billing/backend/billing/runs/[id]/page.js +293 -0
  71. package/dist/modules/billing/backend/billing/runs/[id]/page.js.map +7 -0
  72. package/dist/modules/billing/backend/billing/runs/[id]/page.meta.js +21 -0
  73. package/dist/modules/billing/backend/billing/runs/[id]/page.meta.js.map +7 -0
  74. package/dist/modules/billing/backend/billing/runs/page.js +341 -0
  75. package/dist/modules/billing/backend/billing/runs/page.js.map +7 -0
  76. package/dist/modules/billing/backend/billing/runs/page.meta.js +18 -0
  77. package/dist/modules/billing/backend/billing/runs/page.meta.js.map +7 -0
  78. package/dist/modules/billing/backend/billing/usage/create/page.js +100 -0
  79. package/dist/modules/billing/backend/billing/usage/create/page.js.map +7 -0
  80. package/dist/modules/billing/backend/billing/usage/create/page.meta.js +25 -0
  81. package/dist/modules/billing/backend/billing/usage/create/page.meta.js.map +7 -0
  82. package/dist/modules/billing/ce.js +56 -0
  83. package/dist/modules/billing/ce.js.map +7 -0
  84. package/dist/modules/billing/cli.js +67 -0
  85. package/dist/modules/billing/cli.js.map +7 -0
  86. package/dist/modules/billing/commands/accounts.js +157 -0
  87. package/dist/modules/billing/commands/accounts.js.map +7 -0
  88. package/dist/modules/billing/commands/index.js +6 -0
  89. package/dist/modules/billing/commands/index.js.map +7 -0
  90. package/dist/modules/billing/commands/invoices.js +401 -0
  91. package/dist/modules/billing/commands/invoices.js.map +7 -0
  92. package/dist/modules/billing/commands/items.js +317 -0
  93. package/dist/modules/billing/commands/items.js.map +7 -0
  94. package/dist/modules/billing/commands/runs.js +123 -0
  95. package/dist/modules/billing/commands/runs.js.map +7 -0
  96. package/dist/modules/billing/commands/usage.js +88 -0
  97. package/dist/modules/billing/commands/usage.js.map +7 -0
  98. package/dist/modules/billing/components/AccountForm.js +420 -0
  99. package/dist/modules/billing/components/AccountForm.js.map +7 -0
  100. package/dist/modules/billing/components/DetailFields.js +37 -0
  101. package/dist/modules/billing/components/DetailFields.js.map +7 -0
  102. package/dist/modules/billing/components/ItemForm.js +440 -0
  103. package/dist/modules/billing/components/ItemForm.js.map +7 -0
  104. package/dist/modules/billing/components/LineFormDialog.js +195 -0
  105. package/dist/modules/billing/components/LineFormDialog.js.map +7 -0
  106. package/dist/modules/billing/components/UsageForm.js +262 -0
  107. package/dist/modules/billing/components/UsageForm.js.map +7 -0
  108. package/dist/modules/billing/data/entities.js +433 -0
  109. package/dist/modules/billing/data/entities.js.map +7 -0
  110. package/dist/modules/billing/data/entityIds.js +12 -0
  111. package/dist/modules/billing/data/entityIds.js.map +7 -0
  112. package/dist/modules/billing/data/validators.js +396 -0
  113. package/dist/modules/billing/data/validators.js.map +7 -0
  114. package/dist/modules/billing/di.js +6 -0
  115. package/dist/modules/billing/di.js.map +7 -0
  116. package/dist/modules/billing/events.js +35 -0
  117. package/dist/modules/billing/events.js.map +7 -0
  118. package/dist/modules/billing/i18n/en.json +336 -0
  119. package/dist/modules/billing/i18n/pl.json +336 -0
  120. package/dist/modules/billing/index.js +17 -0
  121. package/dist/modules/billing/index.js.map +7 -0
  122. package/dist/modules/billing/lib/billPeriod.js +101 -0
  123. package/dist/modules/billing/lib/billPeriod.js.map +7 -0
  124. package/dist/modules/billing/lib/billRunEngine.js +256 -0
  125. package/dist/modules/billing/lib/billRunEngine.js.map +7 -0
  126. package/dist/modules/billing/lib/billRunLabel.js +8 -0
  127. package/dist/modules/billing/lib/billRunLabel.js.map +7 -0
  128. package/dist/modules/billing/lib/idempotency.js +13 -0
  129. package/dist/modules/billing/lib/idempotency.js.map +7 -0
  130. package/dist/modules/billing/lib/invoiceStatus.js +38 -0
  131. package/dist/modules/billing/lib/invoiceStatus.js.map +7 -0
  132. package/dist/modules/billing/lib/invoiceWriter.js +153 -0
  133. package/dist/modules/billing/lib/invoiceWriter.js.map +7 -0
  134. package/dist/modules/billing/lib/itemSelector.js +77 -0
  135. package/dist/modules/billing/lib/itemSelector.js.map +7 -0
  136. package/dist/modules/billing/lib/seeds/demo.js +130 -0
  137. package/dist/modules/billing/lib/seeds/demo.js.map +7 -0
  138. package/dist/modules/billing/lib/tenantLock.js +32 -0
  139. package/dist/modules/billing/lib/tenantLock.js.map +7 -0
  140. package/dist/modules/billing/lib/usageRater.js +150 -0
  141. package/dist/modules/billing/lib/usageRater.js.map +7 -0
  142. package/dist/modules/billing/lib/usageRunner.js +82 -0
  143. package/dist/modules/billing/lib/usageRunner.js.map +7 -0
  144. package/dist/modules/billing/migrations/Migration20260519000000_billing.js +144 -0
  145. package/dist/modules/billing/migrations/Migration20260519000000_billing.js.map +7 -0
  146. package/dist/modules/billing/setup.js +190 -0
  147. package/dist/modules/billing/setup.js.map +7 -0
  148. package/dist/modules/billing/subscribers/payment-captured-to-paid.js +47 -0
  149. package/dist/modules/billing/subscribers/payment-captured-to-paid.js.map +7 -0
  150. package/dist/modules/billing/translations.js +5 -0
  151. package/dist/modules/billing/translations.js.map +7 -0
  152. package/dist/modules/billing/workers/reap-stale-bill-runs.js +31 -0
  153. package/dist/modules/billing/workers/reap-stale-bill-runs.js.map +7 -0
  154. package/package.json +148 -0
  155. package/src/modules/billing/__integration__/TC-BILL-001.spec.ts +116 -0
  156. package/src/modules/billing/__integration__/TC-BILL-002.spec.ts +169 -0
  157. package/src/modules/billing/__integration__/TC-BILL-003.spec.ts +28 -0
  158. package/src/modules/billing/__integration__/meta.ts +4 -0
  159. package/src/modules/billing/__tests__/commands/invoices.test.ts +464 -0
  160. package/src/modules/billing/__tests__/commands/itemsBulk.test.ts +284 -0
  161. package/src/modules/billing/__tests__/lib/billPeriod.test.ts +131 -0
  162. package/src/modules/billing/__tests__/lib/billRunEngine.test.ts +561 -0
  163. package/src/modules/billing/__tests__/lib/idempotency.test.ts +81 -0
  164. package/src/modules/billing/__tests__/lib/invoiceStatus.test.ts +97 -0
  165. package/src/modules/billing/__tests__/lib/invoiceWriter.test.ts +119 -0
  166. package/src/modules/billing/__tests__/lib/itemSelector.test.ts +192 -0
  167. package/src/modules/billing/__tests__/lib/seedsDemo.test.ts +86 -0
  168. package/src/modules/billing/__tests__/lib/tenantLock.test.ts +126 -0
  169. package/src/modules/billing/__tests__/lib/usageRater.test.ts +190 -0
  170. package/src/modules/billing/__tests__/package-isolation.test.ts +223 -0
  171. package/src/modules/billing/__tests__/setup.test.ts +107 -0
  172. package/src/modules/billing/__tests__/validators.test.ts +594 -0
  173. package/src/modules/billing/acl.ts +16 -0
  174. package/src/modules/billing/api/accounts/route.ts +198 -0
  175. package/src/modules/billing/api/export/account/[id]/route.ts +233 -0
  176. package/src/modules/billing/api/invoices/[id]/route.ts +143 -0
  177. package/src/modules/billing/api/invoices/add-line/route.ts +74 -0
  178. package/src/modules/billing/api/invoices/edit-line/route.ts +97 -0
  179. package/src/modules/billing/api/invoices/post/route.ts +97 -0
  180. package/src/modules/billing/api/invoices/remove-line/route.ts +75 -0
  181. package/src/modules/billing/api/invoices/route.ts +167 -0
  182. package/src/modules/billing/api/items/bulk/route.ts +92 -0
  183. package/src/modules/billing/api/items/route.ts +255 -0
  184. package/src/modules/billing/api/openapi.ts +33 -0
  185. package/src/modules/billing/api/run-outcomes/route.ts +149 -0
  186. package/src/modules/billing/api/runs/retry-failed/route.ts +88 -0
  187. package/src/modules/billing/api/runs/route.ts +170 -0
  188. package/src/modules/billing/api/test-invoices/wipe/route.ts +87 -0
  189. package/src/modules/billing/api/usage/route.ts +148 -0
  190. package/src/modules/billing/backend/billing/accounts/[id]/page.meta.ts +23 -0
  191. package/src/modules/billing/backend/billing/accounts/[id]/page.tsx +574 -0
  192. package/src/modules/billing/backend/billing/accounts/create/page.meta.ts +23 -0
  193. package/src/modules/billing/backend/billing/accounts/create/page.tsx +101 -0
  194. package/src/modules/billing/backend/billing/accounts/page.meta.ts +16 -0
  195. package/src/modules/billing/backend/billing/accounts/page.tsx +222 -0
  196. package/src/modules/billing/backend/billing/invoices/[id]/page.meta.ts +23 -0
  197. package/src/modules/billing/backend/billing/invoices/[id]/page.tsx +613 -0
  198. package/src/modules/billing/backend/billing/invoices/page.meta.ts +16 -0
  199. package/src/modules/billing/backend/billing/invoices/page.tsx +245 -0
  200. package/src/modules/billing/backend/billing/items/[id]/page.meta.ts +23 -0
  201. package/src/modules/billing/backend/billing/items/[id]/page.tsx +366 -0
  202. package/src/modules/billing/backend/billing/items/create/page.meta.ts +23 -0
  203. package/src/modules/billing/backend/billing/items/create/page.tsx +110 -0
  204. package/src/modules/billing/backend/billing/items/page.meta.ts +16 -0
  205. package/src/modules/billing/backend/billing/items/page.tsx +272 -0
  206. package/src/modules/billing/backend/billing/runs/[id]/page.meta.ts +19 -0
  207. package/src/modules/billing/backend/billing/runs/[id]/page.tsx +404 -0
  208. package/src/modules/billing/backend/billing/runs/page.meta.ts +16 -0
  209. package/src/modules/billing/backend/billing/runs/page.tsx +426 -0
  210. package/src/modules/billing/backend/billing/usage/create/page.meta.ts +23 -0
  211. package/src/modules/billing/backend/billing/usage/create/page.tsx +120 -0
  212. package/src/modules/billing/ce.ts +74 -0
  213. package/src/modules/billing/cli.ts +89 -0
  214. package/src/modules/billing/commands/accounts.ts +205 -0
  215. package/src/modules/billing/commands/index.ts +13 -0
  216. package/src/modules/billing/commands/invoices.ts +542 -0
  217. package/src/modules/billing/commands/items.ts +438 -0
  218. package/src/modules/billing/commands/runs.ts +166 -0
  219. package/src/modules/billing/commands/usage.ts +118 -0
  220. package/src/modules/billing/components/AccountForm.tsx +517 -0
  221. package/src/modules/billing/components/DetailFields.tsx +60 -0
  222. package/src/modules/billing/components/ItemForm.tsx +558 -0
  223. package/src/modules/billing/components/LineFormDialog.tsx +253 -0
  224. package/src/modules/billing/components/UsageForm.tsx +326 -0
  225. package/src/modules/billing/data/entities.ts +533 -0
  226. package/src/modules/billing/data/entityIds.ts +25 -0
  227. package/src/modules/billing/data/validators.ts +562 -0
  228. package/src/modules/billing/di.ts +14 -0
  229. package/src/modules/billing/events.ts +47 -0
  230. package/src/modules/billing/i18n/en.json +336 -0
  231. package/src/modules/billing/i18n/pl.json +336 -0
  232. package/src/modules/billing/index.ts +22 -0
  233. package/src/modules/billing/lib/billPeriod.ts +181 -0
  234. package/src/modules/billing/lib/billRunEngine.ts +416 -0
  235. package/src/modules/billing/lib/billRunLabel.ts +14 -0
  236. package/src/modules/billing/lib/idempotency.ts +46 -0
  237. package/src/modules/billing/lib/invoiceStatus.ts +61 -0
  238. package/src/modules/billing/lib/invoiceWriter.ts +260 -0
  239. package/src/modules/billing/lib/itemSelector.ts +154 -0
  240. package/src/modules/billing/lib/seeds/demo.ts +199 -0
  241. package/src/modules/billing/lib/tenantLock.ts +87 -0
  242. package/src/modules/billing/lib/usageRater.ts +250 -0
  243. package/src/modules/billing/lib/usageRunner.ts +189 -0
  244. package/src/modules/billing/migrations/Migration20260519000000_billing.ts +175 -0
  245. package/src/modules/billing/setup.ts +252 -0
  246. package/src/modules/billing/subscribers/payment-captured-to-paid.ts +89 -0
  247. package/src/modules/billing/translations.ts +9 -0
  248. package/src/modules/billing/workers/reap-stale-bill-runs.ts +57 -0
@@ -0,0 +1,433 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __decorateClass = (decorators, target, key, kind) => {
4
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
5
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
6
+ if (decorator = decorators[i])
7
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8
+ if (kind && result) __defProp(target, key, result);
9
+ return result;
10
+ };
11
+ import { OptionalProps } from "@mikro-orm/core";
12
+ import { Entity, Index, PrimaryKey, Property, Unique } from "@mikro-orm/decorators/legacy";
13
+ OptionalProps;
14
+ let BillingAccount = class {
15
+ constructor() {
16
+ this.isActive = true;
17
+ this.createdAt = /* @__PURE__ */ new Date();
18
+ this.updatedAt = /* @__PURE__ */ new Date();
19
+ }
20
+ };
21
+ __decorateClass([
22
+ PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
23
+ ], BillingAccount.prototype, "id", 2);
24
+ __decorateClass([
25
+ Property({ name: "organization_id", type: "uuid" })
26
+ ], BillingAccount.prototype, "organizationId", 2);
27
+ __decorateClass([
28
+ Property({ name: "tenant_id", type: "uuid" })
29
+ ], BillingAccount.prototype, "tenantId", 2);
30
+ __decorateClass([
31
+ Property({ name: "customer_id", type: "text" })
32
+ ], BillingAccount.prototype, "customerId", 2);
33
+ __decorateClass([
34
+ Property({ type: "text" })
35
+ ], BillingAccount.prototype, "name", 2);
36
+ __decorateClass([
37
+ Property({ name: "currency_code", type: "text" })
38
+ ], BillingAccount.prototype, "currencyCode", 2);
39
+ __decorateClass([
40
+ Property({ name: "bill_cycle", type: "text" })
41
+ ], BillingAccount.prototype, "billCycle", 2);
42
+ __decorateClass([
43
+ Property({ name: "bill_cycle_anchor", type: "text" })
44
+ ], BillingAccount.prototype, "billCycleAnchor", 2);
45
+ __decorateClass([
46
+ Property({ name: "invoice_email", type: "text" })
47
+ ], BillingAccount.prototype, "invoiceEmail", 2);
48
+ __decorateClass([
49
+ Property({ name: "invoice_language", type: "text" })
50
+ ], BillingAccount.prototype, "invoiceLanguage", 2);
51
+ __decorateClass([
52
+ Property({ name: "tax_id", type: "text", nullable: true })
53
+ ], BillingAccount.prototype, "taxId", 2);
54
+ __decorateClass([
55
+ Property({ name: "invoice_address", type: "jsonb" })
56
+ ], BillingAccount.prototype, "invoiceAddress", 2);
57
+ __decorateClass([
58
+ Property({ name: "next_bill_date", type: "date", columnType: "date" })
59
+ ], BillingAccount.prototype, "nextBillDate", 2);
60
+ __decorateClass([
61
+ Property({ name: "last_bill_date", type: "date", columnType: "date", nullable: true })
62
+ ], BillingAccount.prototype, "lastBillDate", 2);
63
+ __decorateClass([
64
+ Property({ name: "is_active", type: "boolean", default: true })
65
+ ], BillingAccount.prototype, "isActive", 2);
66
+ __decorateClass([
67
+ Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
68
+ ], BillingAccount.prototype, "createdAt", 2);
69
+ __decorateClass([
70
+ Property({ name: "updated_at", type: Date, onUpdate: () => /* @__PURE__ */ new Date() })
71
+ ], BillingAccount.prototype, "updatedAt", 2);
72
+ __decorateClass([
73
+ Property({ name: "deleted_at", type: Date, nullable: true })
74
+ ], BillingAccount.prototype, "deletedAt", 2);
75
+ BillingAccount = __decorateClass([
76
+ Entity({ tableName: "billing_accounts" }),
77
+ Index({
78
+ name: "billing_accounts_next_bill_date_idx",
79
+ properties: ["organizationId", "tenantId", "nextBillDate"],
80
+ expression: 'CREATE INDEX "billing_accounts_next_bill_date_idx" ON "billing_accounts" ("organization_id", "tenant_id", "next_bill_date") WHERE "deleted_at" IS NULL'
81
+ }),
82
+ Index({
83
+ name: "billing_accounts_customer_idx",
84
+ properties: ["organizationId", "tenantId", "customerId"]
85
+ }),
86
+ Index({
87
+ name: "billing_accounts_sort_idx",
88
+ properties: ["organizationId", "tenantId", "deletedAt", "createdAt"]
89
+ })
90
+ ], BillingAccount);
91
+ OptionalProps;
92
+ let BillingItem = class {
93
+ constructor() {
94
+ this.currencyMismatch = false;
95
+ this.isActive = true;
96
+ this.createdAt = /* @__PURE__ */ new Date();
97
+ this.updatedAt = /* @__PURE__ */ new Date();
98
+ }
99
+ };
100
+ __decorateClass([
101
+ PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
102
+ ], BillingItem.prototype, "id", 2);
103
+ __decorateClass([
104
+ Property({ name: "organization_id", type: "uuid" })
105
+ ], BillingItem.prototype, "organizationId", 2);
106
+ __decorateClass([
107
+ Property({ name: "tenant_id", type: "uuid" })
108
+ ], BillingItem.prototype, "tenantId", 2);
109
+ __decorateClass([
110
+ Property({ name: "bill_account_id", type: "uuid" })
111
+ ], BillingItem.prototype, "billAccountId", 2);
112
+ __decorateClass([
113
+ Property({ type: "text" })
114
+ ], BillingItem.prototype, "type", 2);
115
+ __decorateClass([
116
+ Property({ name: "bill_start_date", type: "date", columnType: "date" })
117
+ ], BillingItem.prototype, "billStartDate", 2);
118
+ __decorateClass([
119
+ Property({ name: "bill_end_date", type: "date", columnType: "date", nullable: true })
120
+ ], BillingItem.prototype, "billEndDate", 2);
121
+ __decorateClass([
122
+ Property({ type: "text" })
123
+ ], BillingItem.prototype, "description", 2);
124
+ __decorateClass([
125
+ Property({ name: "rate_json", type: "jsonb" })
126
+ ], BillingItem.prototype, "rateJson", 2);
127
+ __decorateClass([
128
+ Property({ name: "uom_code", type: "text", nullable: true })
129
+ ], BillingItem.prototype, "uomCode", 2);
130
+ __decorateClass([
131
+ Property({ name: "subscription_id", type: "text", nullable: true })
132
+ ], BillingItem.prototype, "subscriptionId", 2);
133
+ __decorateClass([
134
+ Property({ name: "subscription_item_id", type: "text", nullable: true })
135
+ ], BillingItem.prototype, "subscriptionItemId", 2);
136
+ __decorateClass([
137
+ Property({ name: "source_ref", type: "text", nullable: true })
138
+ ], BillingItem.prototype, "sourceRef", 2);
139
+ __decorateClass([
140
+ Property({ name: "currency_mismatch", type: "boolean", default: false })
141
+ ], BillingItem.prototype, "currencyMismatch", 2);
142
+ __decorateClass([
143
+ Property({ name: "billed_to_date", type: "date", columnType: "date", nullable: true })
144
+ ], BillingItem.prototype, "billedToDate", 2);
145
+ __decorateClass([
146
+ Property({ name: "is_active", type: "boolean", default: true })
147
+ ], BillingItem.prototype, "isActive", 2);
148
+ __decorateClass([
149
+ Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
150
+ ], BillingItem.prototype, "createdAt", 2);
151
+ __decorateClass([
152
+ Property({ name: "updated_at", type: Date, onUpdate: () => /* @__PURE__ */ new Date() })
153
+ ], BillingItem.prototype, "updatedAt", 2);
154
+ __decorateClass([
155
+ Property({ name: "deleted_at", type: Date, nullable: true })
156
+ ], BillingItem.prototype, "deletedAt", 2);
157
+ BillingItem = __decorateClass([
158
+ Entity({ tableName: "billing_items" }),
159
+ Unique({
160
+ name: "billing_items_source_ref_unique",
161
+ properties: ["tenantId", "billAccountId", "sourceRef"]
162
+ }),
163
+ Index({
164
+ name: "billing_items_account_type_idx",
165
+ properties: ["billAccountId", "type"]
166
+ }),
167
+ Index({
168
+ name: "billing_items_account_active_idx",
169
+ properties: ["billAccountId", "type", "isActive"],
170
+ expression: 'CREATE INDEX "billing_items_account_active_idx" ON "billing_items" ("bill_account_id", "type", "is_active") WHERE "deleted_at" IS NULL'
171
+ }),
172
+ Index({
173
+ name: "billing_items_subscription_idx",
174
+ properties: ["organizationId", "tenantId", "subscriptionId"]
175
+ })
176
+ ], BillingItem);
177
+ OptionalProps;
178
+ let BillingAccountUsage = class {
179
+ constructor() {
180
+ this.isActive = true;
181
+ this.createdAt = /* @__PURE__ */ new Date();
182
+ this.updatedAt = /* @__PURE__ */ new Date();
183
+ }
184
+ };
185
+ __decorateClass([
186
+ PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
187
+ ], BillingAccountUsage.prototype, "id", 2);
188
+ __decorateClass([
189
+ Property({ name: "organization_id", type: "uuid" })
190
+ ], BillingAccountUsage.prototype, "organizationId", 2);
191
+ __decorateClass([
192
+ Property({ name: "tenant_id", type: "uuid" })
193
+ ], BillingAccountUsage.prototype, "tenantId", 2);
194
+ __decorateClass([
195
+ Property({ name: "bill_account_id", type: "uuid" })
196
+ ], BillingAccountUsage.prototype, "billAccountId", 2);
197
+ __decorateClass([
198
+ Property({ name: "uom_code", type: "text" })
199
+ ], BillingAccountUsage.prototype, "uomCode", 2);
200
+ __decorateClass([
201
+ Property({ type: "numeric", columnType: "numeric(18, 4)" })
202
+ ], BillingAccountUsage.prototype, "quantity", 2);
203
+ __decorateClass([
204
+ Property({ name: "period_start", type: Date })
205
+ ], BillingAccountUsage.prototype, "periodStart", 2);
206
+ __decorateClass([
207
+ Property({ name: "period_end", type: Date })
208
+ ], BillingAccountUsage.prototype, "periodEnd", 2);
209
+ __decorateClass([
210
+ Property({ name: "line_description", type: "text", nullable: true })
211
+ ], BillingAccountUsage.prototype, "lineDescription", 2);
212
+ __decorateClass([
213
+ Property({ name: "source_ref", type: "text", nullable: true })
214
+ ], BillingAccountUsage.prototype, "sourceRef", 2);
215
+ __decorateClass([
216
+ Property({ name: "rated_in_bill_run_id", type: "uuid", nullable: true })
217
+ ], BillingAccountUsage.prototype, "ratedInBillRunId", 2);
218
+ __decorateClass([
219
+ Property({ name: "is_active", type: "boolean", default: true })
220
+ ], BillingAccountUsage.prototype, "isActive", 2);
221
+ __decorateClass([
222
+ Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
223
+ ], BillingAccountUsage.prototype, "createdAt", 2);
224
+ __decorateClass([
225
+ Property({ name: "updated_at", type: Date, onUpdate: () => /* @__PURE__ */ new Date() })
226
+ ], BillingAccountUsage.prototype, "updatedAt", 2);
227
+ __decorateClass([
228
+ Property({ name: "deleted_at", type: Date, nullable: true })
229
+ ], BillingAccountUsage.prototype, "deletedAt", 2);
230
+ BillingAccountUsage = __decorateClass([
231
+ Entity({ tableName: "billing_account_usage" }),
232
+ Unique({
233
+ name: "billing_account_usage_source_ref_unique",
234
+ properties: ["tenantId", "billAccountId", "sourceRef"]
235
+ }),
236
+ Index({
237
+ name: "billing_account_usage_rating_idx",
238
+ properties: ["billAccountId", "uomCode", "ratedInBillRunId", "periodEnd"]
239
+ })
240
+ ], BillingAccountUsage);
241
+ OptionalProps;
242
+ let BillRun = class {
243
+ constructor() {
244
+ this.dryRun = false;
245
+ this.testMode = false;
246
+ this.catchUp = false;
247
+ this.isActive = true;
248
+ this.createdAt = /* @__PURE__ */ new Date();
249
+ this.updatedAt = /* @__PURE__ */ new Date();
250
+ }
251
+ };
252
+ __decorateClass([
253
+ PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
254
+ ], BillRun.prototype, "id", 2);
255
+ __decorateClass([
256
+ Property({ name: "organization_id", type: "uuid" })
257
+ ], BillRun.prototype, "organizationId", 2);
258
+ __decorateClass([
259
+ Property({ name: "tenant_id", type: "uuid" })
260
+ ], BillRun.prototype, "tenantId", 2);
261
+ __decorateClass([
262
+ Property({ name: "triggered_by", type: "text" })
263
+ ], BillRun.prototype, "triggeredBy", 2);
264
+ __decorateClass([
265
+ Property({ name: "parent_run_id", type: "uuid", nullable: true })
266
+ ], BillRun.prototype, "parentRunId", 2);
267
+ __decorateClass([
268
+ Property({ name: "dry_run", type: "boolean", default: false })
269
+ ], BillRun.prototype, "dryRun", 2);
270
+ __decorateClass([
271
+ Property({ name: "test_mode", type: "boolean", default: false })
272
+ ], BillRun.prototype, "testMode", 2);
273
+ __decorateClass([
274
+ Property({ name: "catch_up", type: "boolean", default: false })
275
+ ], BillRun.prototype, "catchUp", 2);
276
+ __decorateClass([
277
+ Property({ name: "scoped_account_ids", type: "jsonb", nullable: true })
278
+ ], BillRun.prototype, "scopedAccountIds", 2);
279
+ __decorateClass([
280
+ Property({ name: "as_of_date", type: "date", columnType: "date" })
281
+ ], BillRun.prototype, "asOfDate", 2);
282
+ __decorateClass([
283
+ Property({ name: "started_at", type: Date, nullable: true })
284
+ ], BillRun.prototype, "startedAt", 2);
285
+ __decorateClass([
286
+ Property({ name: "finished_at", type: Date, nullable: true })
287
+ ], BillRun.prototype, "finishedAt", 2);
288
+ __decorateClass([
289
+ Property({ type: "text" })
290
+ ], BillRun.prototype, "status", 2);
291
+ __decorateClass([
292
+ Property({ type: "jsonb", nullable: true })
293
+ ], BillRun.prototype, "summary", 2);
294
+ __decorateClass([
295
+ Property({ name: "is_active", type: "boolean", default: true })
296
+ ], BillRun.prototype, "isActive", 2);
297
+ __decorateClass([
298
+ Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
299
+ ], BillRun.prototype, "createdAt", 2);
300
+ __decorateClass([
301
+ Property({ name: "updated_at", type: Date, onUpdate: () => /* @__PURE__ */ new Date() })
302
+ ], BillRun.prototype, "updatedAt", 2);
303
+ __decorateClass([
304
+ Property({ name: "deleted_at", type: Date, nullable: true })
305
+ ], BillRun.prototype, "deletedAt", 2);
306
+ BillRun = __decorateClass([
307
+ Entity({ tableName: "billing_runs" }),
308
+ Index({
309
+ name: "billing_runs_tenant_status_idx",
310
+ properties: ["tenantId", "status", "startedAt"]
311
+ }),
312
+ Index({
313
+ name: "billing_runs_parent_idx",
314
+ properties: ["parentRunId"]
315
+ })
316
+ ], BillRun);
317
+ OptionalProps;
318
+ let BillRunOutcome = class {
319
+ constructor() {
320
+ this.isActive = true;
321
+ this.createdAt = /* @__PURE__ */ new Date();
322
+ this.updatedAt = /* @__PURE__ */ new Date();
323
+ }
324
+ };
325
+ __decorateClass([
326
+ PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
327
+ ], BillRunOutcome.prototype, "id", 2);
328
+ __decorateClass([
329
+ Property({ name: "organization_id", type: "uuid" })
330
+ ], BillRunOutcome.prototype, "organizationId", 2);
331
+ __decorateClass([
332
+ Property({ name: "tenant_id", type: "uuid" })
333
+ ], BillRunOutcome.prototype, "tenantId", 2);
334
+ __decorateClass([
335
+ Property({ name: "bill_run_id", type: "uuid" })
336
+ ], BillRunOutcome.prototype, "billRunId", 2);
337
+ __decorateClass([
338
+ Property({ name: "bill_account_id", type: "uuid" })
339
+ ], BillRunOutcome.prototype, "billAccountId", 2);
340
+ __decorateClass([
341
+ Property({ type: "text" })
342
+ ], BillRunOutcome.prototype, "status", 2);
343
+ __decorateClass([
344
+ Property({ name: "error_message", type: "text", nullable: true })
345
+ ], BillRunOutcome.prototype, "errorMessage", 2);
346
+ __decorateClass([
347
+ Property({ type: "jsonb", nullable: true })
348
+ ], BillRunOutcome.prototype, "warnings", 2);
349
+ __decorateClass([
350
+ Property({ name: "draft_invoice_id", type: "uuid", nullable: true })
351
+ ], BillRunOutcome.prototype, "draftInvoiceId", 2);
352
+ __decorateClass([
353
+ Property({ name: "is_active", type: "boolean", default: true })
354
+ ], BillRunOutcome.prototype, "isActive", 2);
355
+ __decorateClass([
356
+ Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
357
+ ], BillRunOutcome.prototype, "createdAt", 2);
358
+ __decorateClass([
359
+ Property({ name: "updated_at", type: Date, onUpdate: () => /* @__PURE__ */ new Date() })
360
+ ], BillRunOutcome.prototype, "updatedAt", 2);
361
+ __decorateClass([
362
+ Property({ name: "deleted_at", type: Date, nullable: true })
363
+ ], BillRunOutcome.prototype, "deletedAt", 2);
364
+ BillRunOutcome = __decorateClass([
365
+ Entity({ tableName: "billing_run_outcomes" }),
366
+ Index({
367
+ name: "billing_run_outcomes_run_status_idx",
368
+ properties: ["billRunId", "status"]
369
+ }),
370
+ Index({
371
+ name: "billing_run_outcomes_account_history_idx",
372
+ properties: ["organizationId", "tenantId", "billAccountId", "createdAt"]
373
+ })
374
+ ], BillRunOutcome);
375
+ OptionalProps;
376
+ let DraftInvoiceEdit = class {
377
+ constructor() {
378
+ this.createdAt = /* @__PURE__ */ new Date();
379
+ }
380
+ };
381
+ __decorateClass([
382
+ PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
383
+ ], DraftInvoiceEdit.prototype, "id", 2);
384
+ __decorateClass([
385
+ Property({ name: "organization_id", type: "uuid" })
386
+ ], DraftInvoiceEdit.prototype, "organizationId", 2);
387
+ __decorateClass([
388
+ Property({ name: "tenant_id", type: "uuid" })
389
+ ], DraftInvoiceEdit.prototype, "tenantId", 2);
390
+ __decorateClass([
391
+ Property({ name: "invoice_id", type: "uuid" })
392
+ ], DraftInvoiceEdit.prototype, "invoiceId", 2);
393
+ __decorateClass([
394
+ Property({ name: "invoice_line_id", type: "uuid", nullable: true })
395
+ ], DraftInvoiceEdit.prototype, "invoiceLineId", 2);
396
+ __decorateClass([
397
+ Property({ name: "user_id", type: "uuid" })
398
+ ], DraftInvoiceEdit.prototype, "userId", 2);
399
+ __decorateClass([
400
+ Property({ type: "text" })
401
+ ], DraftInvoiceEdit.prototype, "action", 2);
402
+ __decorateClass([
403
+ Property({ name: "before_json", type: "jsonb", nullable: true })
404
+ ], DraftInvoiceEdit.prototype, "beforeJson", 2);
405
+ __decorateClass([
406
+ Property({ name: "after_json", type: "jsonb", nullable: true })
407
+ ], DraftInvoiceEdit.prototype, "afterJson", 2);
408
+ __decorateClass([
409
+ Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
410
+ ], DraftInvoiceEdit.prototype, "createdAt", 2);
411
+ __decorateClass([
412
+ Property({ name: "deleted_at", type: Date, nullable: true })
413
+ ], DraftInvoiceEdit.prototype, "deletedAt", 2);
414
+ DraftInvoiceEdit = __decorateClass([
415
+ Entity({ tableName: "billing_draft_invoice_edits" }),
416
+ Index({
417
+ name: "billing_draft_invoice_edits_invoice_idx",
418
+ properties: ["organizationId", "tenantId", "invoiceId", "createdAt"]
419
+ }),
420
+ Index({
421
+ name: "billing_draft_invoice_edits_user_idx",
422
+ properties: ["organizationId", "tenantId", "userId", "createdAt"]
423
+ })
424
+ ], DraftInvoiceEdit);
425
+ export {
426
+ BillRun,
427
+ BillRunOutcome,
428
+ BillingAccount,
429
+ BillingAccountUsage,
430
+ BillingItem,
431
+ DraftInvoiceEdit
432
+ };
433
+ //# sourceMappingURL=entities.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/modules/billing/data/entities.ts"],
4
+ "sourcesContent": ["import { OptionalProps } from '@mikro-orm/core'\nimport { Entity, Index, PrimaryKey, Property, Unique } from '@mikro-orm/decorators/legacy'\n\n// \u2500\u2500\u2500 BillingAccount \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n//\n// A container per customer (typically one customer = one account, but the\n// engine does not enforce uniqueness \u2014 multi-account-per-customer is a\n// legitimate model for B2B with separate budgets / currencies / branches).\n//\n// The `(organization_id, tenant_id, next_bill_date)` partial index is the\n// Bill Run hot path \u2014 every nightly run filters by tenant + org and orders\n// by next_bill_date. Multi-org tenants share `tenant_id` across orgs, so a\n// `(tenant_id, next_bill_date)`-only index would scan every other org's\n// rows for each tenant \u2014 fine at 1 org / tenant, painful at 50.\n\n@Entity({ tableName: 'billing_accounts' })\n@Index({\n name: 'billing_accounts_next_bill_date_idx',\n properties: ['organizationId', 'tenantId', 'nextBillDate'],\n expression:\n 'CREATE INDEX \"billing_accounts_next_bill_date_idx\" ON \"billing_accounts\" (\"organization_id\", \"tenant_id\", \"next_bill_date\") WHERE \"deleted_at\" IS NULL',\n})\n@Index({\n name: 'billing_accounts_customer_idx',\n properties: ['organizationId', 'tenantId', 'customerId'],\n})\n@Index({\n name: 'billing_accounts_sort_idx',\n properties: ['organizationId', 'tenantId', 'deletedAt', 'createdAt'],\n})\nexport class BillingAccount {\n [OptionalProps]?:\n | 'taxId'\n | 'lastBillDate'\n | 'isActive'\n | 'createdAt'\n | 'updatedAt'\n | 'deletedAt'\n\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @Property({ name: 'organization_id', type: 'uuid' })\n organizationId!: string\n\n @Property({ name: 'tenant_id', type: 'uuid' })\n tenantId!: string\n\n // String FK to customers.person.id (or any external customer system).\n // Kept as text so the package stays installable without the customers\n // module \u2014 see SPEC-001 cross-package data rule.\n @Property({ name: 'customer_id', type: 'text' })\n customerId!: string\n\n @Property({ type: 'text' })\n name!: string\n\n // ISO 4217 currency code. An account is single-currency by design \u2014\n // multi-currency = multiple accounts.\n @Property({ name: 'currency_code', type: 'text' })\n currencyCode!: string\n\n // 'monthly' | 'quarterly' | 'annually' | 'weekly'. Validated at API ingress.\n @Property({ name: 'bill_cycle', type: 'text' })\n billCycle!: string\n\n // Day-of-month for monthly/quarterly/annually (1\u201328), or weekday code\n // ('mon'\u2026'sun') for weekly. Text so both shapes coexist.\n @Property({ name: 'bill_cycle_anchor', type: 'text' })\n billCycleAnchor!: string\n\n @Property({ name: 'invoice_email', type: 'text' })\n invoiceEmail!: string\n\n // ISO 639-1 (`en`, `pl`, \u2026). Used by mailer / template renderer.\n @Property({ name: 'invoice_language', type: 'text' })\n invoiceLanguage!: string\n\n // NIP / VATIN / TaxID. Nullable for individuals without a registered tax ID.\n @Property({ name: 'tax_id', type: 'text', nullable: true })\n taxId?: string | null\n\n // { line1, line2?, city, postal_code, country } \u2014 JSONB because address\n // shape differs across countries and we never query by address fields.\n @Property({ name: 'invoice_address', type: 'jsonb' })\n invoiceAddress!: Record<string, unknown>\n\n // Anchor of the NEXT bill period to be processed (advanced by Bill Run\n // on success). Date-only \u2014 calendar-aware cycle arithmetic.\n @Property({ name: 'next_bill_date', type: 'date', columnType: 'date' })\n nextBillDate!: Date\n\n // Anchor of the most recently billed period; null for fresh accounts.\n @Property({ name: 'last_bill_date', type: 'date', columnType: 'date', nullable: true })\n lastBillDate?: Date | null\n\n @Property({ name: 'is_active', type: 'boolean', default: true })\n isActive: boolean = true\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n\n @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date() })\n updatedAt: Date = new Date()\n\n @Property({ name: 'deleted_at', type: Date, nullable: true })\n deletedAt?: Date | null\n}\n\n// \u2500\u2500\u2500 BillingItem \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n//\n// A single line that will appear on an invoice. Three flavours:\n// `one_time` / `recurring` / `usage` \u2014 see rate_json shape per type in\n// data/validators.ts.\n//\n// `(tenant_id, bill_account_id, source_ref)` is unique for idempotency.\n// Postgres treats NULLs as distinct, so items without a source_ref do not\n// conflict \u2014 that is intentional (CSV imports / manual entries).\n\n@Entity({ tableName: 'billing_items' })\n@Unique({\n name: 'billing_items_source_ref_unique',\n properties: ['tenantId', 'billAccountId', 'sourceRef'],\n})\n@Index({\n name: 'billing_items_account_type_idx',\n properties: ['billAccountId', 'type'],\n})\n@Index({\n name: 'billing_items_account_active_idx',\n properties: ['billAccountId', 'type', 'isActive'],\n expression:\n 'CREATE INDEX \"billing_items_account_active_idx\" ON \"billing_items\" (\"bill_account_id\", \"type\", \"is_active\") WHERE \"deleted_at\" IS NULL',\n})\n@Index({\n name: 'billing_items_subscription_idx',\n properties: ['organizationId', 'tenantId', 'subscriptionId'],\n})\nexport class BillingItem {\n [OptionalProps]?:\n | 'billEndDate'\n | 'uomCode'\n | 'subscriptionId'\n | 'subscriptionItemId'\n | 'sourceRef'\n | 'currencyMismatch'\n | 'billedToDate'\n | 'isActive'\n | 'createdAt'\n | 'updatedAt'\n | 'deletedAt'\n\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @Property({ name: 'organization_id', type: 'uuid' })\n organizationId!: string\n\n @Property({ name: 'tenant_id', type: 'uuid' })\n tenantId!: string\n\n // FK string to BillingAccount.id (intra-module; no ORM relation kept to\n // avoid coupling \u2014 we resolve at runtime).\n @Property({ name: 'bill_account_id', type: 'uuid' })\n billAccountId!: string\n\n // 'one_time' | 'recurring' | 'usage'.\n @Property({ type: 'text' })\n type!: string\n\n @Property({ name: 'bill_start_date', type: 'date', columnType: 'date' })\n billStartDate!: Date\n\n // Null = open-ended (typical for ongoing recurring items).\n @Property({ name: 'bill_end_date', type: 'date', columnType: 'date', nullable: true })\n billEndDate?: Date | null\n\n @Property({ type: 'text' })\n description!: string\n\n // Pricing definition. Shape validated by Zod per `type`; see\n // data/validators.ts.\n @Property({ name: 'rate_json', type: 'jsonb' })\n rateJson!: Record<string, unknown>\n\n // Required for type='usage' (must match a Usage record's uom_code\n // exactly \u2014 no conversion). Ignored for other types.\n @Property({ name: 'uom_code', type: 'text', nullable: true })\n uomCode?: string | null\n\n // String FK to upstream subscription (e.g. CPQ's\n // cpq_inventory_subscriptions.id). Null for CSV / manual / non-subscription\n // contexts.\n @Property({ name: 'subscription_id', type: 'text', nullable: true })\n subscriptionId?: string | null\n\n @Property({ name: 'subscription_item_id', type: 'text', nullable: true })\n subscriptionItemId?: string | null\n\n // Idempotency key \u2014 duplicate POST returns the existing row.\n @Property({ name: 'source_ref', type: 'text', nullable: true })\n sourceRef?: string | null\n\n // Set when the integrator POSTed a value in a different currency than the\n // account's currency_code. Operator sees a warning on the draft.\n @Property({ name: 'currency_mismatch', type: 'boolean', default: false })\n currencyMismatch: boolean = false\n\n // Anti-double-bill guard at the item level \u2014 see spec\n // \"Why two anti-duplicate guards\".\n @Property({ name: 'billed_to_date', type: 'date', columnType: 'date', nullable: true })\n billedToDate?: Date | null\n\n @Property({ name: 'is_active', type: 'boolean', default: true })\n isActive: boolean = true\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n\n @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date() })\n updatedAt: Date = new Date()\n\n @Property({ name: 'deleted_at', type: Date, nullable: true })\n deletedAt?: Date | null\n}\n\n// \u2500\u2500\u2500 BillingAccountUsage \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n//\n// Bucket for pre-aggregated usage uploaded by external systems. The\n// selection index `(bill_account_id, uom_code, rated_in_bill_run_id,\n// period_end)` matches the Bill Run \"find unrated records\" predicate\n// exactly \u2014 keep it in sync if that predicate changes.\n\n@Entity({ tableName: 'billing_account_usage' })\n@Unique({\n name: 'billing_account_usage_source_ref_unique',\n properties: ['tenantId', 'billAccountId', 'sourceRef'],\n})\n@Index({\n name: 'billing_account_usage_rating_idx',\n properties: ['billAccountId', 'uomCode', 'ratedInBillRunId', 'periodEnd'],\n})\nexport class BillingAccountUsage {\n [OptionalProps]?:\n | 'lineDescription'\n | 'sourceRef'\n | 'ratedInBillRunId'\n | 'isActive'\n | 'createdAt'\n | 'updatedAt'\n | 'deletedAt'\n\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @Property({ name: 'organization_id', type: 'uuid' })\n organizationId!: string\n\n @Property({ name: 'tenant_id', type: 'uuid' })\n tenantId!: string\n\n @Property({ name: 'bill_account_id', type: 'uuid' })\n billAccountId!: string\n\n // Must match the `uom_code` on a corresponding `type='usage'` Billing Item.\n @Property({ name: 'uom_code', type: 'text' })\n uomCode!: string\n\n // numeric(18,4) \u2192 string in app code (standard MikroORM numeric handling).\n @Property({ type: 'numeric', columnType: 'numeric(18, 4)' })\n quantity!: string\n\n @Property({ name: 'period_start', type: Date })\n periodStart!: Date\n\n @Property({ name: 'period_end', type: Date })\n periodEnd!: Date\n\n // Optional per-record description. When set, Bill Run emits one invoice\n // line per Usage record with this description. When null, the run\n // aggregates all matching Usage records into a single line using the\n // Billing Item's `description`.\n @Property({ name: 'line_description', type: 'text', nullable: true })\n lineDescription?: string | null\n\n @Property({ name: 'source_ref', type: 'text', nullable: true })\n sourceRef?: string | null\n\n // Set when consumed; prevents double-rating on retry.\n @Property({ name: 'rated_in_bill_run_id', type: 'uuid', nullable: true })\n ratedInBillRunId?: string | null\n\n @Property({ name: 'is_active', type: 'boolean', default: true })\n isActive: boolean = true\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n\n @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date() })\n updatedAt: Date = new Date()\n\n @Property({ name: 'deleted_at', type: Date, nullable: true })\n deletedAt?: Date | null\n}\n\n// \u2500\u2500\u2500 BillRun \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n//\n// A single execution of the engine \u2014 one row per trigger (schedule or\n// manual). The concurrency lock is a Postgres transaction-scoped advisory\n// lock keyed by hash(tenant_id || 'billing-run'); it is NOT stored on this\n// row. Crash recovery for zombie `status='running'` rows is handled by\n// workers/reap-stale-bill-runs.ts.\n\n@Entity({ tableName: 'billing_runs' })\n@Index({\n name: 'billing_runs_tenant_status_idx',\n properties: ['tenantId', 'status', 'startedAt'],\n})\n@Index({\n name: 'billing_runs_parent_idx',\n properties: ['parentRunId'],\n})\nexport class BillRun {\n [OptionalProps]?:\n | 'parentRunId'\n | 'dryRun'\n | 'testMode'\n | 'catchUp'\n | 'scopedAccountIds'\n | 'startedAt'\n | 'finishedAt'\n | 'summary'\n | 'isActive'\n | 'createdAt'\n | 'updatedAt'\n | 'deletedAt'\n\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @Property({ name: 'organization_id', type: 'uuid' })\n organizationId!: string\n\n @Property({ name: 'tenant_id', type: 'uuid' })\n tenantId!: string\n\n // 'schedule' | 'manual'.\n @Property({ name: 'triggered_by', type: 'text' })\n triggeredBy!: string\n\n // Set when this run is a \"retry failed\" of a previous run.\n @Property({ name: 'parent_run_id', type: 'uuid', nullable: true })\n parentRunId?: string | null\n\n // True \u2192 compute everything but persist nothing (preview).\n @Property({ name: 'dry_run', type: 'boolean', default: false })\n dryRun: boolean = false\n\n // True \u2192 persist drafts flagged as test, but do not advance state.\n @Property({ name: 'test_mode', type: 'boolean', default: false })\n testMode: boolean = false\n\n // True \u2192 loop missed cycles per account in one run (manual only).\n @Property({ name: 'catch_up', type: 'boolean', default: false })\n catchUp: boolean = false\n\n // Optional \u2014 run processes only these accounts when set. JSONB\n // (Postgres arrays would work too, but jsonb keeps tooling uniform\n // across this package).\n @Property({ name: 'scoped_account_ids', type: 'jsonb', nullable: true })\n scopedAccountIds?: string[] | null\n\n // The \"today\" the run uses to evaluate `next_bill_date <= as_of_date`.\n @Property({ name: 'as_of_date', type: 'date', columnType: 'date' })\n asOfDate!: Date\n\n @Property({ name: 'started_at', type: Date, nullable: true })\n startedAt?: Date | null\n\n @Property({ name: 'finished_at', type: Date, nullable: true })\n finishedAt?: Date | null\n\n // 'running' | 'completed' | 'partial_failure' | 'failed'.\n @Property({ type: 'text' })\n status!: string\n\n // { accounts_processed, drafts_created, drafts_skipped_existing,\n // accounts_failed, accounts_with_warnings, usage_records_rated }\n @Property({ type: 'jsonb', nullable: true })\n summary?: Record<string, unknown> | null\n\n @Property({ name: 'is_active', type: 'boolean', default: true })\n isActive: boolean = true\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n\n @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date() })\n updatedAt: Date = new Date()\n\n @Property({ name: 'deleted_at', type: Date, nullable: true })\n deletedAt?: Date | null\n}\n\n// \u2500\u2500\u2500 BillRunOutcome \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n//\n// Per-account outcome of a Bill Run. Stored in its own table (not as a\n// JSONB array on BillRun.summary) so operators can query failures across\n// runs without jsonb_array_elements gymnastics. See spec rationale.\n\n@Entity({ tableName: 'billing_run_outcomes' })\n@Index({\n name: 'billing_run_outcomes_run_status_idx',\n properties: ['billRunId', 'status'],\n})\n@Index({\n name: 'billing_run_outcomes_account_history_idx',\n properties: ['organizationId', 'tenantId', 'billAccountId', 'createdAt'],\n})\nexport class BillRunOutcome {\n [OptionalProps]?:\n | 'errorMessage'\n | 'warnings'\n | 'draftInvoiceId'\n | 'isActive'\n | 'createdAt'\n | 'updatedAt'\n | 'deletedAt'\n\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @Property({ name: 'organization_id', type: 'uuid' })\n organizationId!: string\n\n @Property({ name: 'tenant_id', type: 'uuid' })\n tenantId!: string\n\n @Property({ name: 'bill_run_id', type: 'uuid' })\n billRunId!: string\n\n @Property({ name: 'bill_account_id', type: 'uuid' })\n billAccountId!: string\n\n // 'success' | 'success_with_warnings' | 'skipped_existing_draft' | 'failed'.\n @Property({ type: 'text' })\n status!: string\n\n @Property({ name: 'error_message', type: 'text', nullable: true })\n errorMessage?: string | null\n\n // E.g. `{ unmatched_usage_uoms: [\"api_request\"] }`.\n @Property({ type: 'jsonb', nullable: true })\n warnings?: Record<string, unknown> | null\n\n // FK string to the core/sales invoice (drafted by the run). Null when\n // the run skipped (status='skipped_existing_draft' or 'failed').\n @Property({ name: 'draft_invoice_id', type: 'uuid', nullable: true })\n draftInvoiceId?: string | null\n\n @Property({ name: 'is_active', type: 'boolean', default: true })\n isActive: boolean = true\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n\n @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date() })\n updatedAt: Date = new Date()\n\n @Property({ name: 'deleted_at', type: Date, nullable: true })\n deletedAt?: Date | null\n}\n\n// \u2500\u2500\u2500 DraftInvoiceEdit (audit) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n//\n// Append-only audit of every operator edit on a draft invoice line.\n// Pattern mirrors `cpq_subscription_change_logs` \u2014 minimal columns\n// (no updated_at / is_active), append-only, soft-delete reserved for\n// compliance erasure only.\n\n@Entity({ tableName: 'billing_draft_invoice_edits' })\n@Index({\n name: 'billing_draft_invoice_edits_invoice_idx',\n properties: ['organizationId', 'tenantId', 'invoiceId', 'createdAt'],\n})\n@Index({\n name: 'billing_draft_invoice_edits_user_idx',\n properties: ['organizationId', 'tenantId', 'userId', 'createdAt'],\n})\nexport class DraftInvoiceEdit {\n [OptionalProps]?: 'invoiceLineId' | 'beforeJson' | 'afterJson' | 'createdAt' | 'deletedAt'\n\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @Property({ name: 'organization_id', type: 'uuid' })\n organizationId!: string\n\n @Property({ name: 'tenant_id', type: 'uuid' })\n tenantId!: string\n\n // FK string to the core/sales invoice (no ORM relation across packages).\n @Property({ name: 'invoice_id', type: 'uuid' })\n invoiceId!: string\n\n // Null for `line_added` / `line_removed` actions whose target line does\n // not yet (or no longer) exist on the invoice.\n @Property({ name: 'invoice_line_id', type: 'uuid', nullable: true })\n invoiceLineId?: string | null\n\n @Property({ name: 'user_id', type: 'uuid' })\n userId!: string\n\n // 'line_added' | 'line_removed' | 'line_edited'.\n @Property({ type: 'text' })\n action!: string\n\n // Snapshot before the edit. Null for `line_added` (no prior state).\n @Property({ name: 'before_json', type: 'jsonb', nullable: true })\n beforeJson?: Record<string, unknown> | null\n\n // Snapshot after the edit. Null for `line_removed` (no resulting state).\n @Property({ name: 'after_json', type: 'jsonb', nullable: true })\n afterJson?: Record<string, unknown> | null\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n\n // Reserved for compliance erasure only; runtime never deletes audit rows\n // through normal flows.\n @Property({ name: 'deleted_at', type: Date, nullable: true })\n deletedAt?: Date | null\n}\n"],
5
+ "mappings": ";;;;;;;;;;AAAA,SAAS,qBAAqB;AAC9B,SAAS,QAAQ,OAAO,YAAY,UAAU,cAAc;AA8BzD;AADI,IAAM,iBAAN,MAAqB;AAAA,EAArB;AAmEL,oBAAoB;AAGpB,qBAAkB,oBAAI,KAAK;AAG3B,qBAAkB,oBAAI,KAAK;AAAA;AAI7B;AAnEE;AAAA,EADC,WAAW,EAAE,MAAM,QAAQ,YAAY,oBAAoB,CAAC;AAAA,GATlD,eAUX;AAGA;AAAA,EADC,SAAS,EAAE,MAAM,mBAAmB,MAAM,OAAO,CAAC;AAAA,GAZxC,eAaX;AAGA;AAAA,EADC,SAAS,EAAE,MAAM,aAAa,MAAM,OAAO,CAAC;AAAA,GAflC,eAgBX;AAMA;AAAA,EADC,SAAS,EAAE,MAAM,eAAe,MAAM,OAAO,CAAC;AAAA,GArBpC,eAsBX;AAGA;AAAA,EADC,SAAS,EAAE,MAAM,OAAO,CAAC;AAAA,GAxBf,eAyBX;AAKA;AAAA,EADC,SAAS,EAAE,MAAM,iBAAiB,MAAM,OAAO,CAAC;AAAA,GA7BtC,eA8BX;AAIA;AAAA,EADC,SAAS,EAAE,MAAM,cAAc,MAAM,OAAO,CAAC;AAAA,GAjCnC,eAkCX;AAKA;AAAA,EADC,SAAS,EAAE,MAAM,qBAAqB,MAAM,OAAO,CAAC;AAAA,GAtC1C,eAuCX;AAGA;AAAA,EADC,SAAS,EAAE,MAAM,iBAAiB,MAAM,OAAO,CAAC;AAAA,GAzCtC,eA0CX;AAIA;AAAA,EADC,SAAS,EAAE,MAAM,oBAAoB,MAAM,OAAO,CAA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AAAA,GApC7D,iBAqCX;AAKA;AAAA,EADC,SAAS,EAAE,MAAM,cAAc,MAAM,MAAM,UAAU,KAAK,CAAC;AAAA,GAzCjD,iBA0CX;AA1CW,mBAAN;AAAA,EATN,OAAO,EAAE,WAAW,8BAA8B,CAAC;AAAA,EACnD,MAAM;AAAA,IACL,MAAM;AAAA,IACN,YAAY,CAAC,kBAAkB,YAAY,aAAa,WAAW;AAAA,EACrE,CAAC;AAAA,EACA,MAAM;AAAA,IACL,MAAM;AAAA,IACN,YAAY,CAAC,kBAAkB,YAAY,UAAU,WAAW;AAAA,EAClE,CAAC;AAAA,GACY;",
6
+ "names": []
7
+ }
@@ -0,0 +1,12 @@
1
+ const billingEntityIds = {
2
+ account: "billing:billing_account",
3
+ item: "billing:billing_item",
4
+ usage: "billing:billing_account_usage",
5
+ run: "billing:billing_run",
6
+ runOutcome: "billing:billing_run_outcome",
7
+ draftInvoiceEdit: "billing:billing_draft_invoice_edit"
8
+ };
9
+ export {
10
+ billingEntityIds
11
+ };
12
+ //# sourceMappingURL=entityIds.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/modules/billing/data/entityIds.ts"],
4
+ "sourcesContent": ["/**\n * Canonical entity IDs for the billing module.\n *\n * Mirrors what `E.billing.<entity>` would be in\n * `.mercato/generated/entities.ids.generated.ts` if the standalone-app\n * CLI properly discovered `@dainamite/*` workspace entities (see the\n * Phase 0 deviation note in `xd-249-billing-spec.md`). Until the CLI\n * gap is closed upstream, this is the single source of truth \u2014 every\n * place that previously would have referenced `E.billing.*` (CRUD\n * factory `entityId`, indexer `entityType`, response enricher\n * `targetEntity`, etc.) imports from here instead.\n *\n * When the CLI is fixed, this file can be replaced by `import { E }\n * from '#generated/entities.ids.generated'` in one PR.\n */\nexport const billingEntityIds = {\n account: 'billing:billing_account',\n item: 'billing:billing_item',\n usage: 'billing:billing_account_usage',\n run: 'billing:billing_run',\n runOutcome: 'billing:billing_run_outcome',\n draftInvoiceEdit: 'billing:billing_draft_invoice_edit',\n} as const\n\nexport type BillingEntityId = (typeof billingEntityIds)[keyof typeof billingEntityIds]\n"],
5
+ "mappings": "AAeO,MAAM,mBAAmB;AAAA,EAC9B,SAAS;AAAA,EACT,MAAM;AAAA,EACN,OAAO;AAAA,EACP,KAAK;AAAA,EACL,YAAY;AAAA,EACZ,kBAAkB;AACpB;",
6
+ "names": []
7
+ }