@dainamite/billing 0.20.0 → 0.21.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 (598) hide show
  1. package/CHANGELOG.md +90 -0
  2. package/dist/modules/billing/acl.js +13 -1
  3. package/dist/modules/billing/acl.js.map +2 -2
  4. package/dist/modules/billing/api/accounts/[id]/summary/route.js +52 -0
  5. package/dist/modules/billing/api/accounts/[id]/summary/route.js.map +7 -0
  6. package/dist/modules/billing/api/accounts/route.js +46 -4
  7. package/dist/modules/billing/api/accounts/route.js.map +2 -2
  8. package/dist/modules/billing/api/export/account/[id]/route.js +11 -7
  9. package/dist/modules/billing/api/export/account/[id]/route.js.map +2 -2
  10. package/dist/modules/billing/api/invoices/[id]/memos/route.js +54 -0
  11. package/dist/modules/billing/api/invoices/[id]/memos/route.js.map +7 -0
  12. package/dist/modules/billing/api/invoices/[id]/pdf/route.js +69 -0
  13. package/dist/modules/billing/api/invoices/[id]/pdf/route.js.map +7 -0
  14. package/dist/modules/billing/api/invoices/[id]/route.js +44 -24
  15. package/dist/modules/billing/api/invoices/[id]/route.js.map +2 -2
  16. package/dist/modules/billing/api/invoices/[id]/send/route.js +107 -0
  17. package/dist/modules/billing/api/invoices/[id]/send/route.js.map +7 -0
  18. package/dist/modules/billing/api/invoices/add-line/route.js +2 -2
  19. package/dist/modules/billing/api/invoices/add-line/route.js.map +2 -2
  20. package/dist/modules/billing/api/invoices/delete-draft/route.js +33 -0
  21. package/dist/modules/billing/api/invoices/delete-draft/route.js.map +7 -0
  22. package/dist/modules/billing/api/invoices/edit-line/route.js +2 -2
  23. package/dist/modules/billing/api/invoices/edit-line/route.js.map +2 -2
  24. package/dist/modules/billing/api/invoices/post/route.js +2 -2
  25. package/dist/modules/billing/api/invoices/post/route.js.map +2 -2
  26. package/dist/modules/billing/api/invoices/remove-line/route.js +2 -2
  27. package/dist/modules/billing/api/invoices/remove-line/route.js.map +2 -2
  28. package/dist/modules/billing/api/invoices/route.js +45 -46
  29. package/dist/modules/billing/api/invoices/route.js.map +2 -2
  30. package/dist/modules/billing/api/items/bulk/route.js +1 -1
  31. package/dist/modules/billing/api/items/bulk/route.js.map +2 -2
  32. package/dist/modules/billing/api/items/change-price/route.js +44 -0
  33. package/dist/modules/billing/api/items/change-price/route.js.map +7 -0
  34. package/dist/modules/billing/api/items/route.js +19 -7
  35. package/dist/modules/billing/api/items/route.js.map +2 -2
  36. package/dist/modules/billing/api/payment-imports/[id]/route.js +49 -0
  37. package/dist/modules/billing/api/payment-imports/[id]/route.js.map +7 -0
  38. package/dist/modules/billing/api/payment-imports/route.js +57 -0
  39. package/dist/modules/billing/api/payment-imports/route.js.map +7 -0
  40. package/dist/modules/billing/api/payments/[id]/route.js +60 -0
  41. package/dist/modules/billing/api/payments/[id]/route.js.map +7 -0
  42. package/dist/modules/billing/api/payments/allocate/route.js +35 -0
  43. package/dist/modules/billing/api/payments/allocate/route.js.map +7 -0
  44. package/dist/modules/billing/api/payments/assign/route.js +36 -0
  45. package/dist/modules/billing/api/payments/assign/route.js.map +7 -0
  46. package/dist/modules/billing/api/payments/convert-to-topup/route.js +35 -0
  47. package/dist/modules/billing/api/payments/convert-to-topup/route.js.map +7 -0
  48. package/dist/modules/billing/api/payments/ignore/route.js +35 -0
  49. package/dist/modules/billing/api/payments/ignore/route.js.map +7 -0
  50. package/dist/modules/billing/api/payments/import/route.js +63 -0
  51. package/dist/modules/billing/api/payments/import/route.js.map +7 -0
  52. package/dist/modules/billing/api/payments/restore/route.js +35 -0
  53. package/dist/modules/billing/api/payments/restore/route.js.map +7 -0
  54. package/dist/modules/billing/api/payments/route.js +114 -0
  55. package/dist/modules/billing/api/payments/route.js.map +7 -0
  56. package/dist/modules/billing/api/payments/unallocate/route.js +35 -0
  57. package/dist/modules/billing/api/payments/unallocate/route.js.map +7 -0
  58. package/dist/modules/billing/api/payments/unassign/route.js +35 -0
  59. package/dist/modules/billing/api/payments/unassign/route.js.map +7 -0
  60. package/dist/modules/billing/api/run-outcomes/route.js +43 -6
  61. package/dist/modules/billing/api/run-outcomes/route.js.map +2 -2
  62. package/dist/modules/billing/api/runs/[id]/post-drafts/route.js +61 -0
  63. package/dist/modules/billing/api/runs/[id]/post-drafts/route.js.map +7 -0
  64. package/dist/modules/billing/api/runs/[id]/route.js +53 -0
  65. package/dist/modules/billing/api/runs/[id]/route.js.map +7 -0
  66. package/dist/modules/billing/api/runs/retry-failed/route.js +1 -1
  67. package/dist/modules/billing/api/runs/retry-failed/route.js.map +2 -2
  68. package/dist/modules/billing/api/runs/route.js +9 -3
  69. package/dist/modules/billing/api/runs/route.js.map +2 -2
  70. package/dist/modules/billing/api/settings/number-preview/route.js +42 -0
  71. package/dist/modules/billing/api/settings/number-preview/route.js.map +7 -0
  72. package/dist/modules/billing/api/settings/route.js +92 -0
  73. package/dist/modules/billing/api/settings/route.js.map +7 -0
  74. package/dist/modules/billing/api/statements/route.js +3 -0
  75. package/dist/modules/billing/api/statements/route.js.map +2 -2
  76. package/dist/modules/billing/api/test-invoices/wipe/route.js +2 -2
  77. package/dist/modules/billing/api/test-invoices/wipe/route.js.map +2 -2
  78. package/dist/modules/billing/backend/billing/accounts/[id]/page.js +121 -232
  79. package/dist/modules/billing/backend/billing/accounts/[id]/page.js.map +2 -2
  80. package/dist/modules/billing/backend/billing/accounts/create/page.js +6 -0
  81. package/dist/modules/billing/backend/billing/accounts/create/page.js.map +2 -2
  82. package/dist/modules/billing/backend/billing/accounts/page.js +63 -4
  83. package/dist/modules/billing/backend/billing/accounts/page.js.map +2 -2
  84. package/dist/modules/billing/backend/billing/invoices/[id]/page.js +297 -65
  85. package/dist/modules/billing/backend/billing/invoices/[id]/page.js.map +3 -3
  86. package/dist/modules/billing/backend/billing/invoices/page.js +6 -172
  87. package/dist/modules/billing/backend/billing/invoices/page.js.map +2 -2
  88. package/dist/modules/billing/backend/billing/items/[id]/page.js +51 -7
  89. package/dist/modules/billing/backend/billing/items/[id]/page.js.map +2 -2
  90. package/dist/modules/billing/backend/billing/items/create/page.js +9 -6
  91. package/dist/modules/billing/backend/billing/items/create/page.js.map +2 -2
  92. package/dist/modules/billing/backend/billing/items/page.js +8 -2
  93. package/dist/modules/billing/backend/billing/items/page.js.map +2 -2
  94. package/dist/modules/billing/backend/billing/payments/[id]/page.js +297 -0
  95. package/dist/modules/billing/backend/billing/payments/[id]/page.js.map +7 -0
  96. package/dist/modules/billing/backend/billing/payments/[id]/page.meta.js +21 -0
  97. package/dist/modules/billing/backend/billing/payments/[id]/page.meta.js.map +7 -0
  98. package/dist/modules/billing/backend/billing/payments/imports/[id]/page.js +74 -0
  99. package/dist/modules/billing/backend/billing/payments/imports/[id]/page.js.map +7 -0
  100. package/dist/modules/billing/backend/billing/payments/imports/[id]/page.meta.js +21 -0
  101. package/dist/modules/billing/backend/billing/payments/imports/[id]/page.meta.js.map +7 -0
  102. package/dist/modules/billing/backend/billing/payments/page.js +58 -0
  103. package/dist/modules/billing/backend/billing/payments/page.js.map +7 -0
  104. package/dist/modules/billing/backend/billing/payments/page.meta.js +18 -0
  105. package/dist/modules/billing/backend/billing/payments/page.meta.js.map +7 -0
  106. package/dist/modules/billing/backend/billing/runs/[id]/page.js +49 -14
  107. package/dist/modules/billing/backend/billing/runs/[id]/page.js.map +2 -2
  108. package/dist/modules/billing/backend/billing/runs/page.js +58 -7
  109. package/dist/modules/billing/backend/billing/runs/page.js.map +2 -2
  110. package/dist/modules/billing/backend/billing/statements/[id]/page.js +61 -6
  111. package/dist/modules/billing/backend/billing/statements/[id]/page.js.map +2 -2
  112. package/dist/modules/billing/backend/billing/statements/page.js +1 -1
  113. package/dist/modules/billing/backend/billing/statements/page.js.map +2 -2
  114. package/dist/modules/billing/backend/billing/topups/page.js +1 -1
  115. package/dist/modules/billing/backend/billing/topups/page.js.map +2 -2
  116. package/dist/modules/billing/backend/billing/transactions/page.js +1 -1
  117. package/dist/modules/billing/backend/billing/transactions/page.js.map +2 -2
  118. package/dist/modules/billing/backend/billing/usage/create/page.js +3 -2
  119. package/dist/modules/billing/backend/billing/usage/create/page.js.map +2 -2
  120. package/dist/modules/billing/backend/config/billing/page.js +472 -0
  121. package/dist/modules/billing/backend/config/billing/page.js.map +7 -0
  122. package/dist/modules/billing/backend/config/billing/page.meta.js +19 -0
  123. package/dist/modules/billing/backend/config/billing/page.meta.js.map +7 -0
  124. package/dist/modules/billing/cli.js +22 -1
  125. package/dist/modules/billing/cli.js.map +2 -2
  126. package/dist/modules/billing/commands/accounts.js +6 -0
  127. package/dist/modules/billing/commands/accounts.js.map +2 -2
  128. package/dist/modules/billing/commands/index.js +3 -0
  129. package/dist/modules/billing/commands/index.js.map +2 -2
  130. package/dist/modules/billing/commands/invoices.js +269 -167
  131. package/dist/modules/billing/commands/invoices.js.map +2 -2
  132. package/dist/modules/billing/commands/items.js +108 -0
  133. package/dist/modules/billing/commands/items.js.map +2 -2
  134. package/dist/modules/billing/commands/memos.js +179 -0
  135. package/dist/modules/billing/commands/memos.js.map +7 -0
  136. package/dist/modules/billing/commands/payments.js +379 -0
  137. package/dist/modules/billing/commands/payments.js.map +7 -0
  138. package/dist/modules/billing/commands/runs.js +151 -4
  139. package/dist/modules/billing/commands/runs.js.map +2 -2
  140. package/dist/modules/billing/commands/settings.js +59 -0
  141. package/dist/modules/billing/commands/settings.js.map +7 -0
  142. package/dist/modules/billing/commands/topups.js +9 -2
  143. package/dist/modules/billing/commands/topups.js.map +2 -2
  144. package/dist/modules/billing/commands/transactions.js +2 -2
  145. package/dist/modules/billing/commands/transactions.js.map +2 -2
  146. package/dist/modules/billing/components/AccountForm.js +149 -42
  147. package/dist/modules/billing/components/AccountForm.js.map +2 -2
  148. package/dist/modules/billing/components/AccountInvoicesSection.js +64 -0
  149. package/dist/modules/billing/components/AccountInvoicesSection.js.map +7 -0
  150. package/dist/modules/billing/components/AccountPaymentsSection.js +43 -0
  151. package/dist/modules/billing/components/AccountPaymentsSection.js.map +7 -0
  152. package/dist/modules/billing/components/AccountPicker.js +56 -0
  153. package/dist/modules/billing/components/AccountPicker.js.map +7 -0
  154. package/dist/modules/billing/components/AllocatePaymentDialog.js +134 -0
  155. package/dist/modules/billing/components/AllocatePaymentDialog.js.map +7 -0
  156. package/dist/modules/billing/components/BillingDataTable.js +21 -0
  157. package/dist/modules/billing/components/BillingDataTable.js.map +7 -0
  158. package/dist/modules/billing/components/BillingSettingsLink.js +19 -0
  159. package/dist/modules/billing/components/BillingSettingsLink.js.map +7 -0
  160. package/dist/modules/billing/components/ChangeItemPriceDialog.js +158 -0
  161. package/dist/modules/billing/components/ChangeItemPriceDialog.js.map +7 -0
  162. package/dist/modules/billing/components/CreateMemoDialog.js +200 -0
  163. package/dist/modules/billing/components/CreateMemoDialog.js.map +7 -0
  164. package/dist/modules/billing/components/CustomerLabel.js +33 -0
  165. package/dist/modules/billing/components/CustomerLabel.js.map +7 -0
  166. package/dist/modules/billing/components/InvoicesTable.js +270 -0
  167. package/dist/modules/billing/components/InvoicesTable.js.map +7 -0
  168. package/dist/modules/billing/components/ItemForm.js +176 -44
  169. package/dist/modules/billing/components/ItemForm.js.map +2 -2
  170. package/dist/modules/billing/components/ItemPriceField.js +46 -0
  171. package/dist/modules/billing/components/ItemPriceField.js.map +7 -0
  172. package/dist/modules/billing/components/LineFormDialog.js +25 -2
  173. package/dist/modules/billing/components/LineFormDialog.js.map +2 -2
  174. package/dist/modules/billing/components/ManualPaymentDialog.js +122 -0
  175. package/dist/modules/billing/components/ManualPaymentDialog.js.map +7 -0
  176. package/dist/modules/billing/components/MoneyInput.js +14 -0
  177. package/dist/modules/billing/components/MoneyInput.js.map +7 -0
  178. package/dist/modules/billing/components/PaymentUploadDialog.js +115 -0
  179. package/dist/modules/billing/components/PaymentUploadDialog.js.map +7 -0
  180. package/dist/modules/billing/components/PaymentsTable.js +171 -0
  181. package/dist/modules/billing/components/PaymentsTable.js.map +7 -0
  182. package/dist/modules/billing/components/PostRunDraftsButton.js +105 -0
  183. package/dist/modules/billing/components/PostRunDraftsButton.js.map +7 -0
  184. package/dist/modules/billing/components/PrepaidPanel.js +14 -4
  185. package/dist/modules/billing/components/PrepaidPanel.js.map +2 -2
  186. package/dist/modules/billing/components/RunCyclesSection.js +209 -0
  187. package/dist/modules/billing/components/RunCyclesSection.js.map +7 -0
  188. package/dist/modules/billing/components/TestRunActions.js +127 -0
  189. package/dist/modules/billing/components/TestRunActions.js.map +7 -0
  190. package/dist/modules/billing/components/account/AccountItemsTab.js +157 -0
  191. package/dist/modules/billing/components/account/AccountItemsTab.js.map +7 -0
  192. package/dist/modules/billing/components/account/AccountRunBillingDialog.js +122 -0
  193. package/dist/modules/billing/components/account/AccountRunBillingDialog.js.map +7 -0
  194. package/dist/modules/billing/components/account/AccountRunsTab.js +152 -0
  195. package/dist/modules/billing/components/account/AccountRunsTab.js.map +7 -0
  196. package/dist/modules/billing/components/account/AccountStatementsTab.js +98 -0
  197. package/dist/modules/billing/components/account/AccountStatementsTab.js.map +7 -0
  198. package/dist/modules/billing/components/account/AccountSummaryCards.js +125 -0
  199. package/dist/modules/billing/components/account/AccountSummaryCards.js.map +7 -0
  200. package/dist/modules/billing/components/account/AccountUsageTab.js +91 -0
  201. package/dist/modules/billing/components/account/AccountUsageTab.js.map +7 -0
  202. package/dist/modules/billing/components/account/AccountView.js +73 -0
  203. package/dist/modules/billing/components/account/AccountView.js.map +7 -0
  204. package/dist/modules/billing/components/account/accountRow.js +39 -0
  205. package/dist/modules/billing/components/account/accountRow.js.map +7 -0
  206. package/dist/modules/billing/components/customerNames.js +42 -0
  207. package/dist/modules/billing/components/customerNames.js.map +7 -0
  208. package/dist/modules/billing/data/entities.js +560 -4
  209. package/dist/modules/billing/data/entities.js.map +2 -2
  210. package/dist/modules/billing/data/entityIds.js +10 -1
  211. package/dist/modules/billing/data/entityIds.js.map +2 -2
  212. package/dist/modules/billing/data/validators.js +269 -15
  213. package/dist/modules/billing/data/validators.js.map +2 -2
  214. package/dist/modules/billing/events.js +50 -0
  215. package/dist/modules/billing/events.js.map +2 -2
  216. package/dist/modules/billing/i18n/en.json +457 -21
  217. package/dist/modules/billing/i18n/pl.json +457 -21
  218. package/dist/modules/billing/index.js +6 -2
  219. package/dist/modules/billing/index.js.map +2 -2
  220. package/dist/modules/billing/lib/accountFinancials.js +58 -0
  221. package/dist/modules/billing/lib/accountFinancials.js.map +7 -0
  222. package/dist/modules/billing/lib/accountLock.js +14 -0
  223. package/dist/modules/billing/lib/accountLock.js.map +7 -0
  224. package/dist/modules/billing/lib/accountStatus.js +9 -7
  225. package/dist/modules/billing/lib/accountStatus.js.map +2 -2
  226. package/dist/modules/billing/lib/accountSummary.js +106 -0
  227. package/dist/modules/billing/lib/accountSummary.js.map +7 -0
  228. package/dist/modules/billing/lib/allocation.js +356 -0
  229. package/dist/modules/billing/lib/allocation.js.map +7 -0
  230. package/dist/modules/billing/lib/allocationEvents.js +22 -0
  231. package/dist/modules/billing/lib/allocationEvents.js.map +7 -0
  232. package/dist/modules/billing/lib/billPeriod.js +15 -1
  233. package/dist/modules/billing/lib/billPeriod.js.map +2 -2
  234. package/dist/modules/billing/lib/billRunEngine.js +237 -102
  235. package/dist/modules/billing/lib/billRunEngine.js.map +2 -2
  236. package/dist/modules/billing/lib/billingSettings.js +116 -0
  237. package/dist/modules/billing/lib/billingSettings.js.map +7 -0
  238. package/dist/modules/billing/lib/commandRoute.js +81 -0
  239. package/dist/modules/billing/lib/commandRoute.js.map +7 -0
  240. package/dist/modules/billing/lib/customerLookup.js +97 -0
  241. package/dist/modules/billing/lib/customerLookup.js.map +7 -0
  242. package/dist/modules/billing/lib/dateOnly.js +13 -0
  243. package/dist/modules/billing/lib/dateOnly.js.map +7 -0
  244. package/dist/modules/billing/lib/documentParties.js +16 -0
  245. package/dist/modules/billing/lib/documentParties.js.map +7 -0
  246. package/dist/modules/billing/lib/documentTypes.js +27 -0
  247. package/dist/modules/billing/lib/documentTypes.js.map +7 -0
  248. package/dist/modules/billing/lib/dueDate.js +18 -0
  249. package/dist/modules/billing/lib/dueDate.js.map +7 -0
  250. package/dist/modules/billing/lib/iban.js +29 -0
  251. package/dist/modules/billing/lib/iban.js.map +7 -0
  252. package/dist/modules/billing/lib/invoiceDelivery.js +131 -0
  253. package/dist/modules/billing/lib/invoiceDelivery.js.map +7 -0
  254. package/dist/modules/billing/lib/invoiceLanguages.js +16 -0
  255. package/dist/modules/billing/lib/invoiceLanguages.js.map +7 -0
  256. package/dist/modules/billing/lib/invoiceWriter.js +107 -99
  257. package/dist/modules/billing/lib/invoiceWriter.js.map +2 -2
  258. package/dist/modules/billing/lib/itemBillingState.js +27 -0
  259. package/dist/modules/billing/lib/itemBillingState.js.map +7 -0
  260. package/dist/modules/billing/lib/itemPriceChange.js +18 -0
  261. package/dist/modules/billing/lib/itemPriceChange.js.map +7 -0
  262. package/dist/modules/billing/lib/itemSelector.js.map +2 -2
  263. package/dist/modules/billing/lib/lineAmounts.js +32 -0
  264. package/dist/modules/billing/lib/lineAmounts.js.map +7 -0
  265. package/dist/modules/billing/lib/memoGuards.js +25 -0
  266. package/dist/modules/billing/lib/memoGuards.js.map +7 -0
  267. package/dist/modules/billing/lib/navigation.js +48 -0
  268. package/dist/modules/billing/lib/navigation.js.map +7 -0
  269. package/dist/modules/billing/lib/numbering.js +120 -0
  270. package/dist/modules/billing/lib/numbering.js.map +7 -0
  271. package/dist/modules/billing/lib/overdue.js +36 -0
  272. package/dist/modules/billing/lib/overdue.js.map +7 -0
  273. package/dist/modules/billing/lib/paymentCsv.js +125 -0
  274. package/dist/modules/billing/lib/paymentCsv.js.map +7 -0
  275. package/dist/modules/billing/lib/paymentGateway.js +15 -0
  276. package/dist/modules/billing/lib/paymentGateway.js.map +7 -0
  277. package/dist/modules/billing/lib/paymentImport.js +164 -0
  278. package/dist/modules/billing/lib/paymentImport.js.map +7 -0
  279. package/dist/modules/billing/lib/paymentMatcher.js +36 -0
  280. package/dist/modules/billing/lib/paymentMatcher.js.map +7 -0
  281. package/dist/modules/billing/lib/pdf/attachmentStore.js +46 -0
  282. package/dist/modules/billing/lib/pdf/attachmentStore.js.map +7 -0
  283. package/dist/modules/billing/lib/pdf/fonts/embeddedFonts.js +7 -0
  284. package/dist/modules/billing/lib/pdf/fonts/embeddedFonts.js.map +7 -0
  285. package/dist/modules/billing/lib/pdf/invoiceModel.js +194 -0
  286. package/dist/modules/billing/lib/pdf/invoiceModel.js.map +7 -0
  287. package/dist/modules/billing/lib/pdf/invoicePdf.js +165 -0
  288. package/dist/modules/billing/lib/pdf/invoicePdf.js.map +7 -0
  289. package/dist/modules/billing/lib/pdf/invoiceTemplate.js +274 -0
  290. package/dist/modules/billing/lib/pdf/invoiceTemplate.js.map +7 -0
  291. package/dist/modules/billing/lib/prepaidConfig.js +17 -25
  292. package/dist/modules/billing/lib/prepaidConfig.js.map +2 -2
  293. package/dist/modules/billing/lib/prepaidConsume.js +26 -7
  294. package/dist/modules/billing/lib/prepaidConsume.js.map +2 -2
  295. package/dist/modules/billing/lib/prepaidPeriodClose.js +277 -158
  296. package/dist/modules/billing/lib/prepaidPeriodClose.js.map +2 -2
  297. package/dist/modules/billing/lib/prepaidTaxPoint.js +37 -0
  298. package/dist/modules/billing/lib/prepaidTaxPoint.js.map +7 -0
  299. package/dist/modules/billing/lib/seeds/demo.js +51 -3
  300. package/dist/modules/billing/lib/seeds/demo.js.map +2 -2
  301. package/dist/modules/billing/lib/seeds/paymentsSample.js +93 -0
  302. package/dist/modules/billing/lib/seeds/paymentsSample.js.map +7 -0
  303. package/dist/modules/billing/lib/seeds/sellerSettings.js +41 -0
  304. package/dist/modules/billing/lib/seeds/sellerSettings.js.map +7 -0
  305. package/dist/modules/billing/lib/servicePeriods.js +121 -0
  306. package/dist/modules/billing/lib/servicePeriods.js.map +7 -0
  307. package/dist/modules/billing/lib/testRunCleanup.js +24 -0
  308. package/dist/modules/billing/lib/testRunCleanup.js.map +7 -0
  309. package/dist/modules/billing/lib/topupCapture.js +2 -2
  310. package/dist/modules/billing/lib/topupCapture.js.map +2 -2
  311. package/dist/modules/billing/lib/topupReceipt.js +58 -79
  312. package/dist/modules/billing/lib/topupReceipt.js.map +2 -2
  313. package/dist/modules/billing/lib/usageRater.js.map +1 -1
  314. package/dist/modules/billing/lib/usageRunner.js +14 -6
  315. package/dist/modules/billing/lib/usageRunner.js.map +2 -2
  316. package/dist/modules/billing/lib/vat.js +39 -0
  317. package/dist/modules/billing/lib/vat.js.map +7 -0
  318. package/dist/modules/billing/migrations/Migration20261114000000_billing_customer_kind.js +15 -0
  319. package/dist/modules/billing/migrations/Migration20261114000000_billing_customer_kind.js.map +7 -0
  320. package/dist/modules/billing/migrations/Migration20261114100000_billing_cycle_semantics.js +25 -0
  321. package/dist/modules/billing/migrations/Migration20261114100000_billing_cycle_semantics.js.map +7 -0
  322. package/dist/modules/billing/migrations/Migration20261115000000_billing_invoice_ledger.js +115 -0
  323. package/dist/modules/billing/migrations/Migration20261115000000_billing_invoice_ledger.js.map +7 -0
  324. package/dist/modules/billing/migrations/Migration20261116000000_billing_invoice_documents.js +47 -0
  325. package/dist/modules/billing/migrations/Migration20261116000000_billing_invoice_documents.js.map +7 -0
  326. package/dist/modules/billing/migrations/Migration20261117000000_billing_payments.js +89 -0
  327. package/dist/modules/billing/migrations/Migration20261117000000_billing_payments.js.map +7 -0
  328. package/dist/modules/billing/migrations/Migration20261118000000_billing_memos.js +17 -0
  329. package/dist/modules/billing/migrations/Migration20261118000000_billing_memos.js.map +7 -0
  330. package/dist/modules/billing/migrations/Migration20261119000000_billing_operator_feedback.js +27 -0
  331. package/dist/modules/billing/migrations/Migration20261119000000_billing_operator_feedback.js.map +7 -0
  332. package/dist/modules/billing/migrations/Migration20261120000000_billing_allocation_scope_indexes.js +29 -0
  333. package/dist/modules/billing/migrations/Migration20261120000000_billing_allocation_scope_indexes.js.map +7 -0
  334. package/dist/modules/billing/setup.js +7 -184
  335. package/dist/modules/billing/setup.js.map +2 -2
  336. package/dist/modules/billing/subscribers/credit-memo-auto-send.js +16 -0
  337. package/dist/modules/billing/subscribers/credit-memo-auto-send.js.map +7 -0
  338. package/dist/modules/billing/subscribers/debit-memo-apply-credit.js +16 -0
  339. package/dist/modules/billing/subscribers/debit-memo-apply-credit.js.map +7 -0
  340. package/dist/modules/billing/subscribers/debit-memo-auto-send.js +16 -0
  341. package/dist/modules/billing/subscribers/debit-memo-auto-send.js.map +7 -0
  342. package/dist/modules/billing/subscribers/invoice-apply-credit.js +34 -0
  343. package/dist/modules/billing/subscribers/invoice-apply-credit.js.map +7 -0
  344. package/dist/modules/billing/subscribers/invoice-auto-send.js +30 -0
  345. package/dist/modules/billing/subscribers/invoice-auto-send.js.map +7 -0
  346. package/dist/modules/billing/subscribers/payment-captured-to-paid.js +69 -33
  347. package/dist/modules/billing/subscribers/payment-captured-to-paid.js.map +2 -2
  348. package/dist/modules/billing/subscribers/prepaid-topup-captured.js +4 -6
  349. package/dist/modules/billing/subscribers/prepaid-topup-captured.js.map +2 -2
  350. package/generated/entities/billing_account/index.ts +3 -0
  351. package/generated/entities/billing_allocation/index.ts +18 -0
  352. package/generated/entities/billing_document_sequence/index.ts +11 -0
  353. package/generated/entities/billing_invoice/index.ts +38 -0
  354. package/generated/entities/billing_invoice_line/index.ts +24 -0
  355. package/generated/entities/billing_item/index.ts +4 -0
  356. package/generated/entities/billing_payment/index.ts +25 -0
  357. package/generated/entities/billing_payment_import/index.ts +14 -0
  358. package/generated/entities/billing_run/index.ts +0 -1
  359. package/generated/entities/billing_run_outcome/index.ts +1 -0
  360. package/generated/entities/billing_settings/index.ts +26 -0
  361. package/generated/entities/billing_statement/index.ts +1 -0
  362. package/generated/entities.ids.generated.ts +7 -0
  363. package/package.json +5 -1
  364. package/src/modules/billing/__integration__/TC-BILL-004.spec.ts +170 -0
  365. package/src/modules/billing/__integration__/TC-BILL-005.spec.ts +134 -0
  366. package/src/modules/billing/__integration__/TC-BILL-006.spec.ts +101 -0
  367. package/src/modules/billing/__integration__/TC-BILL-007.spec.ts +140 -0
  368. package/src/modules/billing/__integration__/TC-BILL-008.spec.ts +108 -0
  369. package/src/modules/billing/__integration__/TC-BILL-009.spec.ts +113 -0
  370. package/src/modules/billing/__integration__/TC-BILL-010.spec.ts +118 -0
  371. package/src/modules/billing/__integration__/TC-BILL-011.spec.ts +142 -0
  372. package/src/modules/billing/__integration__/TC-BILL-012.spec.ts +115 -0
  373. package/src/modules/billing/__integration__/TC-BILL-013.spec.ts +118 -0
  374. package/src/modules/billing/__integration__/sellerSettings.ts +24 -0
  375. package/src/modules/billing/__tests__/commands/invoices.test.ts +436 -354
  376. package/src/modules/billing/__tests__/commands/itemsBulk.test.ts +33 -0
  377. package/src/modules/billing/__tests__/commands/memos.test.ts +205 -0
  378. package/src/modules/billing/__tests__/commands/payments.test.ts +241 -0
  379. package/src/modules/billing/__tests__/commands/runsDelete.test.ts +146 -0
  380. package/src/modules/billing/__tests__/commands/runsPostDrafts.test.ts +106 -0
  381. package/src/modules/billing/__tests__/commands/topups.test.ts +11 -0
  382. package/src/modules/billing/__tests__/entityRegistry.test.ts +8 -1
  383. package/src/modules/billing/__tests__/helpers/prepaidMockEm.ts +28 -11
  384. package/src/modules/billing/__tests__/lib/accountFinancials.test.ts +53 -0
  385. package/src/modules/billing/__tests__/lib/accountSummary.test.ts +97 -0
  386. package/src/modules/billing/__tests__/lib/allocation.test.ts +319 -0
  387. package/src/modules/billing/__tests__/lib/billRunEngine.test.ts +228 -17
  388. package/src/modules/billing/__tests__/lib/billingSettings.test.ts +109 -0
  389. package/src/modules/billing/__tests__/lib/customerLookup.test.ts +156 -0
  390. package/src/modules/billing/__tests__/lib/dueDate.test.ts +35 -0
  391. package/src/modules/billing/__tests__/lib/iban.test.ts +38 -0
  392. package/src/modules/billing/__tests__/lib/invoiceDelivery.test.ts +189 -0
  393. package/src/modules/billing/__tests__/lib/invoiceWriter.test.ts +212 -10
  394. package/src/modules/billing/__tests__/lib/itemBillingState.test.ts +42 -0
  395. package/src/modules/billing/__tests__/lib/itemPriceChange.test.ts +165 -0
  396. package/src/modules/billing/__tests__/lib/lineAmounts.test.ts +86 -0
  397. package/src/modules/billing/__tests__/lib/navigation.test.ts +71 -0
  398. package/src/modules/billing/__tests__/lib/numbering.test.ts +91 -0
  399. package/src/modules/billing/__tests__/lib/overdue.test.ts +36 -0
  400. package/src/modules/billing/__tests__/lib/paymentCsv.test.ts +148 -0
  401. package/src/modules/billing/__tests__/lib/paymentImport.test.ts +113 -0
  402. package/src/modules/billing/__tests__/lib/paymentsSample.test.ts +73 -0
  403. package/src/modules/billing/__tests__/lib/pdf/invoicePdf.test.ts +199 -0
  404. package/src/modules/billing/__tests__/lib/pdf/invoicePdfService.test.ts +147 -0
  405. package/src/modules/billing/__tests__/lib/prepaidPeriodClose.test.ts +374 -98
  406. package/src/modules/billing/__tests__/lib/prepaidTaxPoint.test.ts +118 -0
  407. package/src/modules/billing/__tests__/lib/seedsDemo.test.ts +53 -2
  408. package/src/modules/billing/__tests__/lib/sellerSettings.test.ts +28 -0
  409. package/src/modules/billing/__tests__/lib/servicePeriods.test.ts +190 -0
  410. package/src/modules/billing/__tests__/lib/topupCapture.test.ts +6 -28
  411. package/src/modules/billing/__tests__/lib/topupReceipt.test.ts +21 -52
  412. package/src/modules/billing/__tests__/lib/vat.test.ts +51 -0
  413. package/src/modules/billing/__tests__/package-isolation.test.ts +22 -8
  414. package/src/modules/billing/__tests__/setup.test.ts +13 -4
  415. package/src/modules/billing/__tests__/validators.test.ts +193 -3
  416. package/src/modules/billing/acl.ts +12 -0
  417. package/src/modules/billing/api/accounts/[id]/summary/route.ts +62 -0
  418. package/src/modules/billing/api/accounts/route.ts +58 -4
  419. package/src/modules/billing/api/export/account/[id]/route.ts +13 -11
  420. package/src/modules/billing/api/invoices/[id]/memos/route.ts +63 -0
  421. package/src/modules/billing/api/invoices/[id]/pdf/route.ts +79 -0
  422. package/src/modules/billing/api/invoices/[id]/route.ts +57 -70
  423. package/src/modules/billing/api/invoices/[id]/send/route.ts +127 -0
  424. package/src/modules/billing/api/invoices/add-line/route.ts +2 -2
  425. package/src/modules/billing/api/invoices/delete-draft/route.ts +33 -0
  426. package/src/modules/billing/api/invoices/edit-line/route.ts +2 -2
  427. package/src/modules/billing/api/invoices/post/route.ts +7 -6
  428. package/src/modules/billing/api/invoices/remove-line/route.ts +2 -2
  429. package/src/modules/billing/api/invoices/route.ts +81 -86
  430. package/src/modules/billing/api/items/bulk/route.ts +2 -1
  431. package/src/modules/billing/api/items/change-price/route.ts +54 -0
  432. package/src/modules/billing/api/items/route.ts +23 -7
  433. package/src/modules/billing/api/payment-imports/[id]/route.ts +49 -0
  434. package/src/modules/billing/api/payment-imports/route.ts +57 -0
  435. package/src/modules/billing/api/payments/[id]/route.ts +63 -0
  436. package/src/modules/billing/api/payments/allocate/route.ts +35 -0
  437. package/src/modules/billing/api/payments/assign/route.ts +36 -0
  438. package/src/modules/billing/api/payments/convert-to-topup/route.ts +35 -0
  439. package/src/modules/billing/api/payments/ignore/route.ts +35 -0
  440. package/src/modules/billing/api/payments/import/route.ts +72 -0
  441. package/src/modules/billing/api/payments/restore/route.ts +35 -0
  442. package/src/modules/billing/api/payments/route.ts +147 -0
  443. package/src/modules/billing/api/payments/unallocate/route.ts +35 -0
  444. package/src/modules/billing/api/payments/unassign/route.ts +35 -0
  445. package/src/modules/billing/api/run-outcomes/route.ts +49 -6
  446. package/src/modules/billing/api/runs/[id]/post-drafts/route.ts +71 -0
  447. package/src/modules/billing/api/runs/[id]/route.ts +59 -0
  448. package/src/modules/billing/api/runs/retry-failed/route.ts +2 -1
  449. package/src/modules/billing/api/runs/route.ts +15 -7
  450. package/src/modules/billing/api/settings/number-preview/route.ts +46 -0
  451. package/src/modules/billing/api/settings/route.ts +116 -0
  452. package/src/modules/billing/api/statements/route.ts +5 -0
  453. package/src/modules/billing/api/test-invoices/wipe/route.ts +2 -2
  454. package/src/modules/billing/backend/billing/accounts/[id]/page.tsx +151 -372
  455. package/src/modules/billing/backend/billing/accounts/create/page.tsx +6 -0
  456. package/src/modules/billing/backend/billing/accounts/page.tsx +70 -4
  457. package/src/modules/billing/backend/billing/invoices/[id]/page.tsx +444 -95
  458. package/src/modules/billing/backend/billing/invoices/page.tsx +8 -227
  459. package/src/modules/billing/backend/billing/items/[id]/page.tsx +75 -6
  460. package/src/modules/billing/backend/billing/items/create/page.tsx +13 -8
  461. package/src/modules/billing/backend/billing/items/page.tsx +18 -2
  462. package/src/modules/billing/backend/billing/payments/[id]/page.meta.ts +19 -0
  463. package/src/modules/billing/backend/billing/payments/[id]/page.tsx +415 -0
  464. package/src/modules/billing/backend/billing/payments/imports/[id]/page.meta.ts +19 -0
  465. package/src/modules/billing/backend/billing/payments/imports/[id]/page.tsx +106 -0
  466. package/src/modules/billing/backend/billing/payments/page.meta.ts +16 -0
  467. package/src/modules/billing/backend/billing/payments/page.tsx +56 -0
  468. package/src/modules/billing/backend/billing/runs/[id]/page.tsx +49 -18
  469. package/src/modules/billing/backend/billing/runs/page.tsx +59 -8
  470. package/src/modules/billing/backend/billing/statements/[id]/page.tsx +86 -5
  471. package/src/modules/billing/backend/billing/statements/page.tsx +1 -1
  472. package/src/modules/billing/backend/billing/topups/page.tsx +1 -1
  473. package/src/modules/billing/backend/billing/transactions/page.tsx +1 -1
  474. package/src/modules/billing/backend/billing/usage/create/page.tsx +3 -2
  475. package/src/modules/billing/backend/config/billing/page.meta.ts +21 -0
  476. package/src/modules/billing/backend/config/billing/page.tsx +549 -0
  477. package/src/modules/billing/cli.ts +31 -1
  478. package/src/modules/billing/commands/accounts.ts +6 -0
  479. package/src/modules/billing/commands/index.ts +3 -0
  480. package/src/modules/billing/commands/invoices.ts +364 -231
  481. package/src/modules/billing/commands/items.ts +143 -0
  482. package/src/modules/billing/commands/memos.ts +218 -0
  483. package/src/modules/billing/commands/payments.ts +428 -0
  484. package/src/modules/billing/commands/runs.ts +205 -3
  485. package/src/modules/billing/commands/settings.ts +77 -0
  486. package/src/modules/billing/commands/topups.ts +12 -3
  487. package/src/modules/billing/commands/transactions.ts +2 -2
  488. package/src/modules/billing/components/AccountForm.tsx +199 -53
  489. package/src/modules/billing/components/AccountInvoicesSection.tsx +75 -0
  490. package/src/modules/billing/components/AccountPaymentsSection.tsx +42 -0
  491. package/src/modules/billing/components/AccountPicker.tsx +70 -0
  492. package/src/modules/billing/components/AllocatePaymentDialog.tsx +167 -0
  493. package/src/modules/billing/components/BillingDataTable.tsx +34 -0
  494. package/src/modules/billing/components/BillingSettingsLink.tsx +25 -0
  495. package/src/modules/billing/components/ChangeItemPriceDialog.tsx +180 -0
  496. package/src/modules/billing/components/CreateMemoDialog.tsx +232 -0
  497. package/src/modules/billing/components/CustomerLabel.tsx +53 -0
  498. package/src/modules/billing/components/InvoicesTable.tsx +344 -0
  499. package/src/modules/billing/components/ItemForm.tsx +233 -44
  500. package/src/modules/billing/components/ItemPriceField.tsx +81 -0
  501. package/src/modules/billing/components/LineFormDialog.tsx +25 -1
  502. package/src/modules/billing/components/ManualPaymentDialog.tsx +140 -0
  503. package/src/modules/billing/components/MoneyInput.tsx +26 -0
  504. package/src/modules/billing/components/PaymentUploadDialog.tsx +148 -0
  505. package/src/modules/billing/components/PaymentsTable.tsx +213 -0
  506. package/src/modules/billing/components/PostRunDraftsButton.tsx +129 -0
  507. package/src/modules/billing/components/PrepaidPanel.tsx +19 -6
  508. package/src/modules/billing/components/RunCyclesSection.tsx +298 -0
  509. package/src/modules/billing/components/TestRunActions.tsx +152 -0
  510. package/src/modules/billing/components/account/AccountItemsTab.tsx +192 -0
  511. package/src/modules/billing/components/account/AccountRunBillingDialog.tsx +147 -0
  512. package/src/modules/billing/components/account/AccountRunsTab.tsx +201 -0
  513. package/src/modules/billing/components/account/AccountStatementsTab.tsx +120 -0
  514. package/src/modules/billing/components/account/AccountSummaryCards.tsx +153 -0
  515. package/src/modules/billing/components/account/AccountUsageTab.tsx +122 -0
  516. package/src/modules/billing/components/account/AccountView.tsx +101 -0
  517. package/src/modules/billing/components/account/accountRow.ts +70 -0
  518. package/src/modules/billing/components/customerNames.ts +62 -0
  519. package/src/modules/billing/data/entities.ts +654 -5
  520. package/src/modules/billing/data/entityIds.ts +9 -0
  521. package/src/modules/billing/data/validators.ts +388 -8
  522. package/src/modules/billing/events.ts +56 -3
  523. package/src/modules/billing/i18n/en.json +457 -21
  524. package/src/modules/billing/i18n/pl.json +457 -21
  525. package/src/modules/billing/index.ts +6 -2
  526. package/src/modules/billing/lib/accountFinancials.ts +84 -0
  527. package/src/modules/billing/lib/accountLock.ts +32 -0
  528. package/src/modules/billing/lib/accountStatus.ts +11 -9
  529. package/src/modules/billing/lib/accountSummary.ts +172 -0
  530. package/src/modules/billing/lib/allocation.ts +515 -0
  531. package/src/modules/billing/lib/allocationEvents.ts +26 -0
  532. package/src/modules/billing/lib/billPeriod.ts +19 -0
  533. package/src/modules/billing/lib/billRunEngine.ts +350 -150
  534. package/src/modules/billing/lib/billingSettings.ts +145 -0
  535. package/src/modules/billing/lib/commandRoute.ts +112 -0
  536. package/src/modules/billing/lib/customerLookup.ts +157 -0
  537. package/src/modules/billing/lib/dateOnly.ts +22 -0
  538. package/src/modules/billing/lib/documentParties.ts +23 -0
  539. package/src/modules/billing/lib/documentTypes.ts +37 -0
  540. package/src/modules/billing/lib/dueDate.ts +26 -0
  541. package/src/modules/billing/lib/iban.ts +36 -0
  542. package/src/modules/billing/lib/invoiceDelivery.ts +197 -0
  543. package/src/modules/billing/lib/invoiceLanguages.ts +34 -0
  544. package/src/modules/billing/lib/invoiceWriter.ts +162 -148
  545. package/src/modules/billing/lib/itemBillingState.ts +67 -0
  546. package/src/modules/billing/lib/itemPriceChange.ts +56 -0
  547. package/src/modules/billing/lib/itemSelector.ts +4 -1
  548. package/src/modules/billing/lib/lineAmounts.ts +61 -0
  549. package/src/modules/billing/lib/memoGuards.ts +41 -0
  550. package/src/modules/billing/lib/navigation.ts +64 -0
  551. package/src/modules/billing/lib/numbering.ts +174 -0
  552. package/src/modules/billing/lib/overdue.ts +60 -0
  553. package/src/modules/billing/lib/paymentCsv.ts +171 -0
  554. package/src/modules/billing/lib/paymentGateway.ts +52 -0
  555. package/src/modules/billing/lib/paymentImport.ts +228 -0
  556. package/src/modules/billing/lib/paymentMatcher.ts +88 -0
  557. package/src/modules/billing/lib/pdf/attachmentStore.ts +60 -0
  558. package/src/modules/billing/lib/pdf/fonts/NotoSans-Bold.ttf +0 -0
  559. package/src/modules/billing/lib/pdf/fonts/NotoSans-Regular.ttf +0 -0
  560. package/src/modules/billing/lib/pdf/fonts/OFL.txt +93 -0
  561. package/src/modules/billing/lib/pdf/fonts/embeddedFonts.ts +9 -0
  562. package/src/modules/billing/lib/pdf/invoiceModel.ts +328 -0
  563. package/src/modules/billing/lib/pdf/invoicePdf.ts +216 -0
  564. package/src/modules/billing/lib/pdf/invoiceTemplate.ts +338 -0
  565. package/src/modules/billing/lib/prepaidConfig.ts +27 -36
  566. package/src/modules/billing/lib/prepaidConsume.ts +29 -6
  567. package/src/modules/billing/lib/prepaidPeriodClose.ts +407 -239
  568. package/src/modules/billing/lib/prepaidTaxPoint.ts +76 -0
  569. package/src/modules/billing/lib/seeds/demo.ts +79 -6
  570. package/src/modules/billing/lib/seeds/paymentsSample.ts +136 -0
  571. package/src/modules/billing/lib/seeds/sellerSettings.ts +78 -0
  572. package/src/modules/billing/lib/servicePeriods.ts +226 -0
  573. package/src/modules/billing/lib/testRunCleanup.ts +42 -0
  574. package/src/modules/billing/lib/topupCapture.ts +3 -4
  575. package/src/modules/billing/lib/topupReceipt.ts +70 -103
  576. package/src/modules/billing/lib/usageRater.ts +1 -1
  577. package/src/modules/billing/lib/usageRunner.ts +17 -5
  578. package/src/modules/billing/lib/vat.ts +56 -0
  579. package/src/modules/billing/migrations/Migration20261114000000_billing_customer_kind.ts +25 -0
  580. package/src/modules/billing/migrations/Migration20261114100000_billing_cycle_semantics.ts +37 -0
  581. package/src/modules/billing/migrations/Migration20261115000000_billing_invoice_ledger.ts +132 -0
  582. package/src/modules/billing/migrations/Migration20261116000000_billing_invoice_documents.ts +58 -0
  583. package/src/modules/billing/migrations/Migration20261117000000_billing_payments.ts +97 -0
  584. package/src/modules/billing/migrations/Migration20261118000000_billing_memos.ts +21 -0
  585. package/src/modules/billing/migrations/Migration20261119000000_billing_operator_feedback.ts +39 -0
  586. package/src/modules/billing/migrations/Migration20261120000000_billing_allocation_scope_indexes.ts +35 -0
  587. package/src/modules/billing/setup.ts +11 -237
  588. package/src/modules/billing/subscribers/credit-memo-auto-send.ts +15 -0
  589. package/src/modules/billing/subscribers/debit-memo-apply-credit.ts +15 -0
  590. package/src/modules/billing/subscribers/debit-memo-auto-send.ts +15 -0
  591. package/src/modules/billing/subscribers/invoice-apply-credit.ts +39 -0
  592. package/src/modules/billing/subscribers/invoice-auto-send.ts +46 -0
  593. package/src/modules/billing/subscribers/payment-captured-to-paid.ts +84 -62
  594. package/src/modules/billing/subscribers/prepaid-topup-captured.ts +4 -8
  595. package/dist/modules/billing/lib/invoiceStatus.js +0 -38
  596. package/dist/modules/billing/lib/invoiceStatus.js.map +0 -7
  597. package/src/modules/billing/__tests__/lib/invoiceStatus.test.ts +0 -97
  598. package/src/modules/billing/lib/invoiceStatus.ts +0 -61
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
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 | 'billingMode'\n | 'creditLimit'\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 // Billing mode \u2014 'postpaid' (default; the shipped Bill Run \u2192 draft \u2192\n // post flow) or 'prepaid' (top up a balance, draw it down in real time;\n // SPEC-002). Immutable after create (like currency_code); validated at\n // API ingress. Existing rows default to postpaid \u2014 zero behavior change.\n @Property({ name: 'billing_mode', type: 'text', default: 'postpaid' })\n billingMode: string = 'postpaid'\n\n // Credit line extended to this customer (both modes). Prepaid: permitted\n // overdraft below zero. Postpaid: max outstanding AR exposure. `0` = no\n // credit. Reported, never enforced by billing (SPEC-002 assumption #11).\n @Property({ name: 'credit_limit', type: 'numeric', columnType: 'numeric(18, 4)', default: '0' })\n creditLimit: string = '0'\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 BillingRun \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// Class names must be the PascalCase of the entity-id suffix (`billing:\n// billing_run` \u2192 `BillingRun`) \u2014 that is how Open Mercato maps an id to its\n// table. Until 0.20.0 this class was `BillRun` (likewise `BillRunOutcome`,\n// `DraftInvoiceEdit`), and those three ids resolved to no table; see\n// data/entityIds.ts. Type-only aliases for the old names are at the end of\n// this file.\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 BillingRun {\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 BillingRunOutcome \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 BillingRun.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 BillingRunOutcome {\n [OptionalProps]?:\n | 'errorMessage'\n | 'warnings'\n | 'draftInvoiceId'\n | 'statementId'\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 // FK (string) to the BillingStatement produced for a PREPAID account\n // (SPEC-002). Prepaid accounts get a statement instead of a draft invoice\n // at period close, so this is the prepaid analogue of `draft_invoice_id`.\n @Property({ name: 'statement_id', type: 'uuid', nullable: true })\n statementId?: 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 BillingDraftInvoiceEdit (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\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 BillingDraftInvoiceEdit {\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\n// \u2500\u2500\u2500 BillingAccountBalance (SPEC-002) \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// The denormalized running balance for a prepaid account \u2014 exactly one\n// row per prepaid account. It is the O(1) read AND the row the atomic\n// `UPDATE \u2026 RETURNING` debit/credit locks, which is why the balance is\n// NOT a column on `billing_accounts`: the high-write balance update never\n// touches the account row that the Bill Run hot-path index sits on.\n//\n// `balance` is the cache; the source of truth is\n// `SUM(billing_account_transactions.amount)`. The reconciliation invariant\n// `balance == SUM(amount) == latest.balance_after` is unit-tested.\n\n@Entity({ tableName: 'billing_account_balances' })\n@Unique({\n name: 'billing_account_balances_account_unique',\n properties: ['tenantId', 'billAccountId'],\n})\n@Index({\n name: 'billing_account_balances_balance_idx',\n properties: ['organizationId', 'tenantId', 'balance'],\n})\nexport class BillingAccountBalance {\n [OptionalProps]?:\n | 'lowBalanceThreshold'\n | 'lastMovementAt'\n | 'createdAt'\n | 'updatedAt'\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 // Unique FK (string) to BillingAccount.id \u2014 one balance per account.\n @Property({ name: 'bill_account_id', type: 'uuid' })\n billAccountId!: string\n\n // Denormalized from the account so the balance row is self-contained.\n @Property({ name: 'currency_code', type: 'text' })\n currencyCode!: string\n\n // Running balance. May be NEGATIVE (usage is never rejected). Maintained\n // exclusively by the atomic `UPDATE \u2026 RETURNING` in lib/balanceLedger.ts.\n @Property({ name: 'balance', type: 'numeric', columnType: 'numeric(18, 4)', default: '0' })\n balance: string = '0'\n\n // When `balance <= threshold` \u2192 status `low` + `billing.balance.low`.\n // Null = use the tenant config default\n // (`billing.prepaid.low_balance_threshold_default`).\n @Property({\n name: 'low_balance_threshold',\n type: 'numeric',\n columnType: 'numeric(18, 4)',\n nullable: true,\n })\n lowBalanceThreshold?: string | null\n\n // Timestamp of the most recent transaction \u2014 a cheap \"is this account\n // active?\" signal.\n @Property({ name: 'last_movement_at', type: Date, nullable: true })\n lastMovementAt?: Date | null\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\n// \u2500\u2500\u2500 BillingAccountTransaction (SPEC-002, append-only) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n//\n// The source of truth for every balance movement. Append-only \u2014 pattern\n// mirrors BillingDraftInvoiceEdit (no `updated_at` / `is_active`;\n// `deleted_at` reserved for compliance erasure only). `balance = SUM(amount)`.\n//\n// The unique `(tenant_id, bill_account_id, source_ref)` is the idempotency\n// gate: a deduplicated usage upload or a retried recurring charge can never\n// double-debit (Postgres treats NULL source_ref as distinct \u2014 manual\n// adjustments without a key always insert).\n\n@Entity({ tableName: 'billing_account_transactions' })\n@Unique({\n name: 'billing_account_transactions_source_ref_unique',\n properties: ['tenantId', 'billAccountId', 'sourceRef'],\n})\n@Index({\n name: 'billing_account_transactions_history_idx',\n properties: ['organizationId', 'tenantId', 'billAccountId', 'createdAt'],\n})\n@Index({\n name: 'billing_account_transactions_account_type_idx',\n properties: ['billAccountId', 'type', 'createdAt'],\n})\nexport class BillingAccountTransaction {\n [OptionalProps]?:\n | 'usageId'\n | 'billingItemId'\n | 'topupId'\n | 'statementId'\n | 'sourceRef'\n | 'metadata'\n | 'userId'\n | 'createdAt'\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 // 'topup' | 'usage' | 'recurring' | 'one_time' | 'adjustment' | 'reversal'.\n @Property({ type: 'text' })\n type!: string\n\n // SIGNED: `> 0` credit, `< 0` debit. Balance = SUM(amount).\n @Property({ type: 'numeric', columnType: 'numeric(18, 4)' })\n amount!: string\n\n @Property({ name: 'currency_code', type: 'text' })\n currencyCode!: string\n\n // Running balance AFTER this transaction \u2014 snapshotted from the atomic\n // `UPDATE \u2026 RETURNING`. Enables audit + fast statement math without\n // re-summing the whole ledger.\n @Property({ name: 'balance_after', type: 'numeric', columnType: 'numeric(18, 4)' })\n balanceAfter!: string\n\n // FK (string) to BillingAccountUsage for type='usage'.\n @Property({ name: 'usage_id', type: 'uuid', nullable: true })\n usageId?: string | null\n\n // FK (string) to the Billing Item that priced this debit.\n @Property({ name: 'billing_item_id', type: 'uuid', nullable: true })\n billingItemId?: string | null\n\n // FK (string) to BillingTopup for type='topup'.\n @Property({ name: 'topup_id', type: 'uuid', nullable: true })\n topupId?: string | null\n\n // FK (string) to the BillingStatement a period-close charge was rolled into.\n @Property({ name: 'statement_id', type: 'uuid', nullable: true })\n statementId?: string | null\n\n @Property({ type: 'text' })\n description!: string\n\n // Idempotency key, unique per (tenant_id, bill_account_id, source_ref).\n // usage debits = the usage record's source_ref; recurring =\n // `recurring-{itemId}-{periodEndISO}`; topup = `topup-{paymentId}`.\n @Property({ name: 'source_ref', type: 'text', nullable: true })\n sourceRef?: string | null\n\n // e.g. usage_tier_breakdown, uom_code, bill_period_start/end, gateway ids.\n @Property({ type: 'jsonb', nullable: true })\n metadata?: Record<string, unknown> | null\n\n // Operator for manual `adjustment` / `reversal`.\n @Property({ name: 'user_id', type: 'uuid', nullable: true })\n userId?: string | null\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n\n // Compliance erasure only.\n @Property({ name: 'deleted_at', type: Date, nullable: true })\n deletedAt?: Date | null\n}\n\n// \u2500\u2500\u2500 BillingTopup (SPEC-002 \u2014 the \"registered top-up\") \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n//\n// One row per top-up attempt with a lifecycle (pending \u2192 captured | failed\n// | expired | cancelled), linked to its GatewayTransaction, its balance\n// credit transaction, and its VAT receipt invoice. \"The balance went up\"\n// is always explainable.\n\n@Entity({ tableName: 'billing_topups' })\n@Unique({\n name: 'billing_topups_payment_id_unique',\n properties: ['tenantId', 'paymentId'],\n})\n@Index({\n name: 'billing_topups_account_history_idx',\n properties: ['organizationId', 'tenantId', 'billAccountId', 'createdAt'],\n})\n@Index({\n name: 'billing_topups_status_idx',\n properties: ['tenantId', 'status'],\n})\nexport class BillingTopup {\n [OptionalProps]?:\n | 'gatewayTransactionId'\n | 'transactionId'\n | 'receiptInvoiceId'\n | 'sourceRef'\n | 'metadata'\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 // 'pending' | 'captured' | 'failed' | 'expired' | 'cancelled'.\n @Property({ type: 'text' })\n status!: string\n\n @Property({ type: 'numeric', columnType: 'numeric(18, 4)' })\n amount!: string\n\n @Property({ name: 'currency_code', type: 'text' })\n currencyCode!: string\n\n @Property({ name: 'provider_key', type: 'text' })\n providerKey!: string\n\n // The UUID we pass to createPaymentSession and match the captured event\n // on. Unique per tenant.\n @Property({ name: 'payment_id', type: 'uuid' })\n paymentId!: string\n\n // FK (string) to payment_gateways.GatewayTransaction once the session is\n // created.\n @Property({ name: 'gateway_transaction_id', type: 'uuid', nullable: true })\n gatewayTransactionId?: string | null\n\n // FK (string) to the credit BillingAccountTransaction written on capture.\n @Property({ name: 'transaction_id', type: 'uuid', nullable: true })\n transactionId?: string | null\n\n // FK (string) to the core/sales VAT receipt invoice.\n @Property({ name: 'receipt_invoice_id', type: 'uuid', nullable: true })\n receiptInvoiceId?: string | null\n\n // Optional idempotency for the initiating request.\n @Property({ name: 'source_ref', type: 'text', nullable: true })\n sourceRef?: string | null\n\n // success_url / cancel_url, provider payload echoes.\n @Property({ type: 'jsonb', nullable: true })\n metadata?: Record<string, unknown> | null\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 BillingStatement (SPEC-002 \u2014 period close) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n//\n// A non-fiscal consumption summary for a prepaid account's bill period.\n// Chains cleanly: each statement's `opening_balance` equals the prior\n// statement's `closing_balance`. Anti-duplicate via the unique\n// (tenant_id, bill_account_id, period_start, period_end).\n\n@Entity({ tableName: 'billing_statements' })\n@Unique({\n name: 'billing_statements_period_unique',\n properties: ['tenantId', 'billAccountId', 'periodStart', 'periodEnd'],\n})\n@Index({\n name: 'billing_statements_account_period_idx',\n properties: ['organizationId', 'tenantId', 'billAccountId', 'periodEnd'],\n})\nexport class BillingStatement {\n [OptionalProps]?:\n | 'billRunId'\n | 'totalAdjustments'\n | 'createdAt'\n | 'updatedAt'\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 // FK (string) to the BillingRun that generated it (period close reuses the\n // run engine). Null for a manually-generated statement.\n @Property({ name: 'bill_run_id', type: 'uuid', nullable: true })\n billRunId?: string | null\n\n @Property({ name: 'period_start', type: 'date', columnType: 'date' })\n periodStart!: Date\n\n @Property({ name: 'period_end', type: 'date', columnType: 'date' })\n periodEnd!: Date\n\n @Property({ name: 'currency_code', type: 'text' })\n currencyCode!: string\n\n // Balance at period_start (= the prior statement's closing_balance).\n @Property({ name: 'opening_balance', type: 'numeric', columnType: 'numeric(18, 4)' })\n openingBalance!: string\n\n // Sum of credits in window.\n @Property({ name: 'total_topups', type: 'numeric', columnType: 'numeric(18, 4)' })\n totalTopups!: string\n\n // Sum of metered (real-time) usage debits in window (absolute).\n @Property({ name: 'total_usage', type: 'numeric', columnType: 'numeric(18, 4)' })\n totalUsage!: string\n\n // Sum of recurring + one_time charges debited at this close (absolute).\n @Property({ name: 'total_recurring', type: 'numeric', columnType: 'numeric(18, 4)' })\n totalRecurring!: string\n\n // Signed sum of manual adjustment + reversal movements in the window. Kept as\n // its own term so the statement stays self-consistent (closing reproduces\n // from the shown components) and the opening\u2192closing chain never drifts.\n @Property({ name: 'total_adjustments', type: 'numeric', columnType: 'numeric(18, 4)', default: '0' })\n totalAdjustments: string = '0'\n\n // opening + topups + adjustments \u2212 usage \u2212 recurring (= the period's net).\n @Property({ name: 'closing_balance', type: 'numeric', columnType: 'numeric(18, 4)' })\n closingBalance!: string\n\n // Per billing_item_id: { billing_type, uom_code?, quantity, amount }.\n @Property({ name: 'debit_breakdown', type: 'jsonb' })\n debitBreakdown!: Record<string, unknown>\n\n // 'generated' | 'sent'.\n @Property({ type: 'text' })\n status!: string\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\n// \u2500\u2500\u2500 Deprecated names (0.20.0) \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// Type-only on purpose: a runtime alias (`export const BillRun = BillingRun`)\n// would make the app's generated `entities` list carry the same class twice.\n// Code that used the old names as values (`em.find(BillRun, \u2026)`) must switch\n// to the new ones \u2014 TypeScript flags it.\n\n/** @deprecated Renamed to {@link BillingRun} in 0.20.0. */\nexport type BillRun = BillingRun\n/** @deprecated Renamed to {@link BillingRunOutcome} in 0.20.0. */\nexport type BillRunOutcome = BillingRunOutcome\n/** @deprecated Renamed to {@link BillingDraftInvoiceEdit} in 0.20.0. */\nexport type DraftInvoiceEdit = BillingDraftInvoiceEdit\n"],
5
- "mappings": ";;;;;;;;;;AAAA,SAAS,qBAAqB;AAC9B,SAAS,QAAQ,OAAO,YAAY,UAAU,cAAc;AA8BzD;AADI,IAAM,iBAAN,MAAqB;AAAA,EAArB;AAyEL,uBAAsB;AAMtB,uBAAsB;AAGtB,oBAAoB;AAGpB,qBAAk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AGA;AAAA,EADC,SAAS,EAAE,MAAM,cAAc,MAAM,MAAM,UAAU,MAAM,oBAAI,KAAK,EAAE,CAAC;AAAA,GAtE7D,iBAuEX;AAvEW,mBAAN;AAAA,EATN,OAAO,EAAE,WAAW,qBAAqB,CAAC;AAAA,EAC1C,OAAO;AAAA,IACN,MAAM;AAAA,IACN,YAAY,CAAC,YAAY,iBAAiB,eAAe,WAAW;AAAA,EACtE,CAAC;AAAA,EACA,MAAM;AAAA,IACL,MAAM;AAAA,IACN,YAAY,CAAC,kBAAkB,YAAY,iBAAiB,WAAW;AAAA,EACzE,CAAC;AAAA,GACY;",
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 | 'customerKind'\n | 'taxId'\n | 'lastBillDate'\n | 'billingMode'\n | 'creditLimit'\n | 'paymentTermsDays'\n | 'autoSendInvoice'\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 // Spec E (B2C): which customers collection `customer_id` points into \u2014\n // 'company' | 'person'. Drives the lookup + label only; immutable after\n // create, like `customer_id`.\n @Property({ name: 'customer_kind', type: 'text', default: 'company' })\n customerKind: 'company' | 'person' = 'company'\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 // Billing mode \u2014 'postpaid' (default; the shipped Bill Run \u2192 draft \u2192\n // post flow) or 'prepaid' (top up a balance, draw it down in real time;\n // SPEC-002). Immutable after create (like currency_code); validated at\n // API ingress. Existing rows default to postpaid \u2014 zero behavior change.\n @Property({ name: 'billing_mode', type: 'text', default: 'postpaid' })\n billingMode: string = 'postpaid'\n\n // Credit line extended to this customer (both modes). Prepaid: permitted\n // overdraft below zero. Postpaid: max outstanding AR exposure. `0` = no\n // credit. Reported, never enforced by billing (SPEC-002 assumption #11).\n @Property({ name: 'credit_limit', type: 'numeric', columnType: 'numeric(18, 4)', default: '0' })\n creditLimit: string = '0'\n\n // Spec B \u2014 payment terms in days for this account's invoices; null = the\n // organization default (`billing_settings.default_payment_terms_days`).\n @Property({ name: 'payment_terms_days', type: 'integer', nullable: true })\n paymentTermsDays?: number | null\n\n // Spec B \u2014 email each invoice to `invoice_email` automatically at post.\n @Property({ name: 'auto_send_invoice', type: 'boolean', default: false })\n autoSendInvoice: boolean = false\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 | 'chargeTiming'\n | 'prorate'\n | 'taxRate'\n | 'priceBasis'\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 // Spec A \u2014 recurring items only. 'in_advance' (default) bills the coming\n // period on the bill date; 'in_arrears' bills the period just ended.\n @Property({ name: 'charge_timing', type: 'text', default: 'in_advance' })\n chargeTiming: 'in_advance' | 'in_arrears' = 'in_advance'\n\n // Spec A \u2014 recurring items only. Prorate partial periods (item starts /\n // ends mid-period) by calendar days, and credit unused days when an item\n // billed in advance ends early. False = skip partial periods.\n @Property({ name: 'prorate', type: 'boolean', default: true })\n prorate: boolean = true\n\n // Spec B (B-D1) \u2014 VAT rate in percent, snapshotted onto every invoice line.\n // Filled from `billing_settings.default_tax_rate` at creation when omitted;\n // never looked up live, so a default change never re-prices subscriptions.\n @Property({ name: 'tax_rate', type: 'numeric', columnType: 'numeric(7, 4)', default: '0' })\n taxRate: string = '0'\n\n // Spec F (F-D2) \u2014 the `rate_json` amounts are stored as typed, on this\n // basis. Invoice lines are computed from it (`lib/lineAmounts.ts`), so a\n // typed gross is reproduced exactly. Tiered usage rates are always 'net'.\n @Property({ name: 'price_basis', type: 'text', default: 'net' })\n priceBasis: 'net' | 'gross' = 'net'\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 BillingRun \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// Class names must be the PascalCase of the entity-id suffix (`billing:\n// billing_run` \u2192 `BillingRun`) \u2014 that is how Open Mercato maps an id to its\n// table. Until 0.20.0 this class was `BillRun` (likewise `BillRunOutcome`,\n// `DraftInvoiceEdit`), and those three ids resolved to no table; see\n// data/entityIds.ts. Type-only aliases for the old names are at the end of\n// this file.\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 BillingRun {\n [OptionalProps]?:\n | 'parentRunId'\n | 'dryRun'\n | 'testMode'\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 // 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 BillingRunOutcome \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 BillingRun.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 BillingRunOutcome {\n [OptionalProps]?:\n | 'errorMessage'\n | 'warnings'\n | 'draftInvoiceId'\n | 'statementId'\n | 'cycles'\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 // FK (string) to the BillingStatement produced for a PREPAID account\n // (SPEC-002). Prepaid accounts get a statement instead of a draft invoice\n // at period close, so this is the prepaid analogue of `draft_invoice_id`.\n @Property({ name: 'statement_id', type: 'uuid', nullable: true })\n statementId?: string | null\n\n // Spec A \u2014 one entry per bill date the run processed for this account\n // (catch-up emits several): `[{ bill_date, period_start, period_end,\n // status, line_count, total_net, invoice_id }]`. `draft_invoice_id` keeps\n // pointing at the last invoice for backward compatibility.\n @Property({ type: 'jsonb', nullable: true })\n cycles?: Array<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 BillingDraftInvoiceEdit (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\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 BillingDraftInvoiceEdit {\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\n// \u2500\u2500\u2500 BillingAccountBalance (SPEC-002) \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// The denormalized running balance for a prepaid account \u2014 exactly one\n// row per prepaid account. It is the O(1) read AND the row the atomic\n// `UPDATE \u2026 RETURNING` debit/credit locks, which is why the balance is\n// NOT a column on `billing_accounts`: the high-write balance update never\n// touches the account row that the Bill Run hot-path index sits on.\n//\n// `balance` is the cache; the source of truth is\n// `SUM(billing_account_transactions.amount)`. The reconciliation invariant\n// `balance == SUM(amount) == latest.balance_after` is unit-tested.\n\n@Entity({ tableName: 'billing_account_balances' })\n@Unique({\n name: 'billing_account_balances_account_unique',\n properties: ['tenantId', 'billAccountId'],\n})\n@Index({\n name: 'billing_account_balances_balance_idx',\n properties: ['organizationId', 'tenantId', 'balance'],\n})\nexport class BillingAccountBalance {\n [OptionalProps]?:\n | 'lowBalanceThreshold'\n | 'lastMovementAt'\n | 'createdAt'\n | 'updatedAt'\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 // Unique FK (string) to BillingAccount.id \u2014 one balance per account.\n @Property({ name: 'bill_account_id', type: 'uuid' })\n billAccountId!: string\n\n // Denormalized from the account so the balance row is self-contained.\n @Property({ name: 'currency_code', type: 'text' })\n currencyCode!: string\n\n // Running balance. May be NEGATIVE (usage is never rejected). Maintained\n // exclusively by the atomic `UPDATE \u2026 RETURNING` in lib/balanceLedger.ts.\n @Property({ name: 'balance', type: 'numeric', columnType: 'numeric(18, 4)', default: '0' })\n balance: string = '0'\n\n // When `balance <= threshold` \u2192 status `low` + `billing.balance.low`.\n // Null = use the tenant config default\n // (`billing.prepaid.low_balance_threshold_default`).\n @Property({\n name: 'low_balance_threshold',\n type: 'numeric',\n columnType: 'numeric(18, 4)',\n nullable: true,\n })\n lowBalanceThreshold?: string | null\n\n // Timestamp of the most recent transaction \u2014 a cheap \"is this account\n // active?\" signal.\n @Property({ name: 'last_movement_at', type: Date, nullable: true })\n lastMovementAt?: Date | null\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\n// \u2500\u2500\u2500 BillingAccountTransaction (SPEC-002, append-only) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n//\n// The source of truth for every balance movement. Append-only \u2014 pattern\n// mirrors BillingDraftInvoiceEdit (no `updated_at` / `is_active`;\n// `deleted_at` reserved for compliance erasure only). `balance = SUM(amount)`.\n//\n// The unique `(tenant_id, bill_account_id, source_ref)` is the idempotency\n// gate: a deduplicated usage upload or a retried recurring charge can never\n// double-debit (Postgres treats NULL source_ref as distinct \u2014 manual\n// adjustments without a key always insert).\n\n@Entity({ tableName: 'billing_account_transactions' })\n@Unique({\n name: 'billing_account_transactions_source_ref_unique',\n properties: ['tenantId', 'billAccountId', 'sourceRef'],\n})\n@Index({\n name: 'billing_account_transactions_history_idx',\n properties: ['organizationId', 'tenantId', 'billAccountId', 'createdAt'],\n})\n@Index({\n name: 'billing_account_transactions_account_type_idx',\n properties: ['billAccountId', 'type', 'createdAt'],\n})\nexport class BillingAccountTransaction {\n [OptionalProps]?:\n | 'usageId'\n | 'billingItemId'\n | 'topupId'\n | 'statementId'\n | 'sourceRef'\n | 'metadata'\n | 'userId'\n | 'createdAt'\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 // 'topup' | 'usage' | 'recurring' | 'one_time' | 'adjustment' | 'reversal'.\n @Property({ type: 'text' })\n type!: string\n\n // SIGNED: `> 0` credit, `< 0` debit. Balance = SUM(amount).\n @Property({ type: 'numeric', columnType: 'numeric(18, 4)' })\n amount!: string\n\n @Property({ name: 'currency_code', type: 'text' })\n currencyCode!: string\n\n // Running balance AFTER this transaction \u2014 snapshotted from the atomic\n // `UPDATE \u2026 RETURNING`. Enables audit + fast statement math without\n // re-summing the whole ledger.\n @Property({ name: 'balance_after', type: 'numeric', columnType: 'numeric(18, 4)' })\n balanceAfter!: string\n\n // FK (string) to BillingAccountUsage for type='usage'.\n @Property({ name: 'usage_id', type: 'uuid', nullable: true })\n usageId?: string | null\n\n // FK (string) to the Billing Item that priced this debit.\n @Property({ name: 'billing_item_id', type: 'uuid', nullable: true })\n billingItemId?: string | null\n\n // FK (string) to BillingTopup for type='topup'.\n @Property({ name: 'topup_id', type: 'uuid', nullable: true })\n topupId?: string | null\n\n // FK (string) to the BillingStatement a period-close charge was rolled into.\n @Property({ name: 'statement_id', type: 'uuid', nullable: true })\n statementId?: string | null\n\n @Property({ type: 'text' })\n description!: string\n\n // Idempotency key, unique per (tenant_id, bill_account_id, source_ref).\n // usage debits = the usage record's source_ref; recurring =\n // `recurring-{itemId}-{periodEndISO}`; topup = `topup-{paymentId}`.\n @Property({ name: 'source_ref', type: 'text', nullable: true })\n sourceRef?: string | null\n\n // e.g. usage_tier_breakdown, uom_code, bill_period_start/end, gateway ids.\n @Property({ type: 'jsonb', nullable: true })\n metadata?: Record<string, unknown> | null\n\n // Operator for manual `adjustment` / `reversal`.\n @Property({ name: 'user_id', type: 'uuid', nullable: true })\n userId?: string | null\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n\n // Compliance erasure only.\n @Property({ name: 'deleted_at', type: Date, nullable: true })\n deletedAt?: Date | null\n}\n\n// \u2500\u2500\u2500 BillingTopup (SPEC-002 \u2014 the \"registered top-up\") \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n//\n// One row per top-up attempt with a lifecycle (pending \u2192 captured | failed\n// | expired | cancelled), linked to its GatewayTransaction, its balance\n// credit transaction, and its VAT receipt invoice. \"The balance went up\"\n// is always explainable.\n\n@Entity({ tableName: 'billing_topups' })\n@Unique({\n name: 'billing_topups_payment_id_unique',\n properties: ['tenantId', 'paymentId'],\n})\n@Index({\n name: 'billing_topups_account_history_idx',\n properties: ['organizationId', 'tenantId', 'billAccountId', 'createdAt'],\n})\n@Index({\n name: 'billing_topups_status_idx',\n properties: ['tenantId', 'status'],\n})\nexport class BillingTopup {\n [OptionalProps]?:\n | 'gatewayTransactionId'\n | 'transactionId'\n | 'receiptInvoiceId'\n | 'sourceRef'\n | 'metadata'\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 // 'pending' | 'captured' | 'failed' | 'expired' | 'cancelled'.\n @Property({ type: 'text' })\n status!: string\n\n @Property({ type: 'numeric', columnType: 'numeric(18, 4)' })\n amount!: string\n\n @Property({ name: 'currency_code', type: 'text' })\n currencyCode!: string\n\n @Property({ name: 'provider_key', type: 'text' })\n providerKey!: string\n\n // The UUID we pass to createPaymentSession and match the captured event\n // on. Unique per tenant.\n @Property({ name: 'payment_id', type: 'uuid' })\n paymentId!: string\n\n // FK (string) to payment_gateways.GatewayTransaction once the session is\n // created.\n @Property({ name: 'gateway_transaction_id', type: 'uuid', nullable: true })\n gatewayTransactionId?: string | null\n\n // FK (string) to the credit BillingAccountTransaction written on capture.\n @Property({ name: 'transaction_id', type: 'uuid', nullable: true })\n transactionId?: string | null\n\n // FK (string) to the core/sales VAT receipt invoice.\n @Property({ name: 'receipt_invoice_id', type: 'uuid', nullable: true })\n receiptInvoiceId?: string | null\n\n // Optional idempotency for the initiating request.\n @Property({ name: 'source_ref', type: 'text', nullable: true })\n sourceRef?: string | null\n\n // success_url / cancel_url, provider payload echoes.\n @Property({ type: 'jsonb', nullable: true })\n metadata?: Record<string, unknown> | null\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 BillingStatement (SPEC-002 \u2014 period close) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n//\n// A non-fiscal consumption summary for a prepaid account's bill period.\n// Chains cleanly: each statement's `opening_balance` equals the prior\n// statement's `closing_balance`. Anti-duplicate via the unique\n// (tenant_id, bill_account_id, period_start, period_end).\n\n@Entity({ tableName: 'billing_statements' })\n@Unique({\n name: 'billing_statements_period_unique',\n properties: ['tenantId', 'billAccountId', 'periodStart', 'periodEnd'],\n})\n@Index({\n name: 'billing_statements_account_period_idx',\n properties: ['organizationId', 'tenantId', 'billAccountId', 'periodEnd'],\n})\nexport class BillingStatement {\n [OptionalProps]?:\n | 'billRunId'\n | 'totalAdjustments'\n | 'vatSummary'\n | 'createdAt'\n | 'updatedAt'\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 // FK (string) to the BillingRun that generated it (period close reuses the\n // run engine). Null for a manually-generated statement.\n @Property({ name: 'bill_run_id', type: 'uuid', nullable: true })\n billRunId?: string | null\n\n @Property({ name: 'period_start', type: 'date', columnType: 'date' })\n periodStart!: Date\n\n @Property({ name: 'period_end', type: 'date', columnType: 'date' })\n periodEnd!: Date\n\n @Property({ name: 'currency_code', type: 'text' })\n currencyCode!: string\n\n // Balance at period_start (= the prior statement's closing_balance).\n @Property({ name: 'opening_balance', type: 'numeric', columnType: 'numeric(18, 4)' })\n openingBalance!: string\n\n // Sum of credits in window.\n @Property({ name: 'total_topups', type: 'numeric', columnType: 'numeric(18, 4)' })\n totalTopups!: string\n\n // Sum of metered (real-time) usage debits in window (absolute).\n @Property({ name: 'total_usage', type: 'numeric', columnType: 'numeric(18, 4)' })\n totalUsage!: string\n\n // Sum of recurring + one_time charges debited at this close (absolute).\n @Property({ name: 'total_recurring', type: 'numeric', columnType: 'numeric(18, 4)' })\n totalRecurring!: string\n\n // Signed sum of manual adjustment + reversal movements in the window. Kept as\n // its own term so the statement stays self-consistent (closing reproduces\n // from the shown components) and the opening\u2192closing chain never drifts.\n @Property({ name: 'total_adjustments', type: 'numeric', columnType: 'numeric(18, 4)', default: '0' })\n totalAdjustments: string = '0'\n\n // opening + topups + adjustments \u2212 usage \u2212 recurring (= the period's net).\n @Property({ name: 'closing_balance', type: 'numeric', columnType: 'numeric(18, 4)' })\n closingBalance!: string\n\n // Per billing_item_id: { billing_type, uom_code?, quantity, amount }.\n @Property({ name: 'debit_breakdown', type: 'jsonb' })\n debitBreakdown!: Record<string, unknown>\n\n // Spec F (F5) \u2014 `[{ rate, net, tax, gross }]` per VAT rate of the period's\n // prepaid debits. Empty in `topup` tax-point mode (VAT was on the receipt).\n @Property({ name: 'vat_summary', type: 'jsonb', nullable: true })\n vatSummary?: Array<{ rate: string; net: string; tax: string; gross: string }> | null\n\n // 'generated' | 'sent'.\n @Property({ type: 'text' })\n status!: string\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\n// \u2500\u2500\u2500 Deprecated names (0.20.0) \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// Type-only on purpose: a runtime alias (`export const BillRun = BillingRun`)\n// would make the app's generated `entities` list carry the same class twice.\n// Code that used the old names as values (`em.find(BillRun, \u2026)`) must switch\n// to the new ones \u2014 TypeScript flags it.\n\n/** @deprecated Renamed to {@link BillingRun} in 0.20.0. */\nexport type BillRun = BillingRun\n/** @deprecated Renamed to {@link BillingRunOutcome} in 0.20.0. */\nexport type BillRunOutcome = BillingRunOutcome\n/** @deprecated Renamed to {@link BillingDraftInvoiceEdit} in 0.20.0. */\nexport type DraftInvoiceEdit = BillingDraftInvoiceEdit\n\n// \u2500\u2500\u2500 Spec 0 \u2014 standalone invoice ledger \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// Billing owns its documents end to end: invoices, credit / debit memos and\n// prepaid top-up receipts live here, NOT in core `sales_invoices`. FK\n// columns are plain strings (the package guard forbids ORM relations).\n// Partial unique indexes (dedupe per bill date, unique posted number) are\n// created in the migration \u2014 decorators can't express their WHERE clause.\n\n@Entity({ tableName: 'billing_invoices' })\n@Index({\n name: 'billing_invoices_status_idx',\n properties: ['tenantId', 'organizationId', 'status'],\n})\n@Index({\n name: 'billing_invoices_account_idx',\n properties: ['billAccountId', 'status', 'dueDate'],\n})\n@Index({ name: 'billing_invoices_run_idx', properties: ['billRunId'] })\n@Index({ name: 'billing_invoices_corrects_idx', properties: ['correctsInvoiceId'] })\n@Index({ name: 'billing_invoices_topup_idx', properties: ['topupId'] })\nexport class BillingInvoice {\n [OptionalProps]?:\n | 'documentType'\n | 'series'\n | 'status'\n | 'testRun'\n | 'billRunId'\n | 'billDate'\n | 'periodStart'\n | 'periodEnd'\n | 'issueDate'\n | 'dueDate'\n | 'subtotalNet'\n | 'taxTotal'\n | 'totalGross'\n | 'paidTotal'\n | 'creditedTotal'\n | 'outstanding'\n | 'correctsInvoiceId'\n | 'correctionReason'\n | 'correctsInvoiceNumber'\n | 'correctsIssueDate'\n | 'buyerSnapshot'\n | 'sellerSnapshot'\n | 'pdfAttachmentId'\n | 'topupId'\n | 'postedAt'\n | 'metadata'\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 // 'invoice' | 'credit_memo' | 'debit_memo' | 'receipt'.\n @Property({ name: 'document_type', type: 'text', default: 'invoice' })\n documentType: string = 'invoice'\n\n // DRAFT-\u2026 / TEST-\u2026 until posted, then the series number (Spec 0 numbering).\n @Property({ type: 'text' })\n number!: string\n\n // Numbering series the posted number came from; null while draft.\n @Property({ type: 'text', nullable: true })\n series?: string | null\n\n // 'draft' | 'posted' | 'partially_paid' | 'paid' | 'credited'. No 'void'.\n @Property({ type: 'text', default: 'draft' })\n status: string = 'draft'\n\n @Property({ name: 'test_run', type: 'boolean', default: false })\n testRun: boolean = false\n\n @Property({ name: 'bill_run_id', type: 'uuid', nullable: true })\n billRunId?: string | null\n\n // Spec A: the bill date this invoice is for (dedupe key).\n @Property({ name: 'bill_date', type: 'date', columnType: 'date', nullable: true })\n billDate?: Date | null\n\n // Display period = min/max of the line service periods.\n @Property({ name: 'period_start', type: 'date', columnType: 'date', nullable: true })\n periodStart?: Date | null\n\n @Property({ name: 'period_end', type: 'date', columnType: 'date', nullable: true })\n periodEnd?: Date | null\n\n @Property({ name: 'issue_date', type: 'date', columnType: 'date', nullable: true })\n issueDate?: Date | null\n\n @Property({ name: 'due_date', type: 'date', columnType: 'date', nullable: true })\n dueDate?: Date | null\n\n @Property({ name: 'currency_code', type: 'text' })\n currencyCode!: string\n\n @Property({ name: 'subtotal_net', type: 'numeric', columnType: 'numeric(18, 4)', default: '0' })\n subtotalNet: string = '0'\n\n @Property({ name: 'tax_total', type: 'numeric', columnType: 'numeric(18, 4)', default: '0' })\n taxTotal: string = '0'\n\n @Property({ name: 'total_gross', type: 'numeric', columnType: 'numeric(18, 4)', default: '0' })\n totalGross: string = '0'\n\n @Property({ name: 'paid_total', type: 'numeric', columnType: 'numeric(18, 4)', default: '0' })\n paidTotal: string = '0'\n\n @Property({ name: 'credited_total', type: 'numeric', columnType: 'numeric(18, 4)', default: '0' })\n creditedTotal: string = '0'\n\n @Property({ type: 'numeric', columnType: 'numeric(18, 4)', default: '0' })\n outstanding: string = '0'\n\n // Spec D groundwork: the document a credit / debit memo corrects.\n @Property({ name: 'corrects_invoice_id', type: 'uuid', nullable: true })\n correctsInvoiceId?: string | null\n\n @Property({ name: 'correction_reason', type: 'text', nullable: true })\n correctionReason?: string | null\n\n // Spec D \u2014 snapshot of the corrected document (printed \"Corrects invoice X of DATE\").\n @Property({ name: 'corrects_invoice_number', type: 'text', nullable: true })\n correctsInvoiceNumber?: string | null\n\n @Property({ name: 'corrects_issue_date', type: 'date', columnType: 'date', nullable: true })\n correctsIssueDate?: Date | null\n\n // Frozen at post: who the document was issued to / by.\n @Property({ name: 'buyer_snapshot', type: 'jsonb', nullable: true })\n buyerSnapshot?: Record<string, unknown> | null\n\n @Property({ name: 'seller_snapshot', type: 'jsonb', nullable: true })\n sellerSnapshot?: Record<string, unknown> | null\n\n @Property({ name: 'pdf_attachment_id', type: 'uuid', nullable: true })\n pdfAttachmentId?: string | null\n\n // Receipts: the BillingTopup this receipt was issued for.\n @Property({ name: 'topup_id', type: 'uuid', nullable: true })\n topupId?: string | null\n\n @Property({ name: 'posted_at', type: Date, nullable: true })\n postedAt?: Date | null\n\n // Free-form extras only (delivery log, \u2026) \u2014 never a query key.\n @Property({ type: 'jsonb', nullable: true })\n metadata?: Record<string, unknown> | null\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@Entity({ tableName: 'billing_invoice_lines' })\n@Index({ name: 'billing_invoice_lines_invoice_idx', properties: ['invoiceId', 'lineNumber'] })\nexport class BillingInvoiceLine {\n [OptionalProps]?:\n | 'billingItemId'\n | 'taxRate'\n | 'taxAmount'\n | 'servicePeriodStart'\n | 'servicePeriodEnd'\n | 'correctsLineId'\n | 'metadata'\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: 'invoice_id', type: 'uuid' })\n invoiceId!: string\n\n @Property({ name: 'line_number', type: 'integer' })\n lineNumber!: number\n\n @Property({ name: 'billing_item_id', type: 'uuid', nullable: true })\n billingItemId?: string | null\n\n // 'one_time' | 'recurring' | 'usage' | 'manual' | 'receipt'.\n @Property({ name: 'billing_type', type: 'text' })\n billingType!: string\n\n @Property({ type: 'text' })\n description!: string\n\n @Property({ type: 'numeric', columnType: 'numeric(18, 4)' })\n quantity!: string\n\n @Property({ name: 'unit_price_net', type: 'numeric', columnType: 'numeric(18, 4)' })\n unitPriceNet!: string\n\n @Property({ name: 'tax_rate', type: 'numeric', columnType: 'numeric(7, 4)', default: '0' })\n taxRate: string = '0'\n\n @Property({ name: 'net_amount', type: 'numeric', columnType: 'numeric(18, 4)' })\n netAmount!: string\n\n @Property({ name: 'tax_amount', type: 'numeric', columnType: 'numeric(18, 4)', default: '0' })\n taxAmount: string = '0'\n\n @Property({ name: 'gross_amount', type: 'numeric', columnType: 'numeric(18, 4)' })\n grossAmount!: string\n\n @Property({ name: 'service_period_start', type: 'date', columnType: 'date', nullable: true })\n servicePeriodStart?: Date | null\n\n @Property({ name: 'service_period_end', type: 'date', columnType: 'date', nullable: true })\n servicePeriodEnd?: Date | null\n\n // Spec D groundwork: the original line a memo line corrects.\n @Property({ name: 'corrects_line_id', type: 'uuid', nullable: true })\n correctsLineId?: string | null\n\n // Proration / credit / usage tier breakdown / charge timing.\n @Property({ type: 'jsonb', nullable: true })\n metadata?: Record<string, unknown> | null\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@Entity({ tableName: 'billing_document_sequences' })\n@Unique({\n name: 'billing_document_sequences_scope_uq',\n properties: ['tenantId', 'organizationId', 'series', 'scopeKey'],\n})\nexport class BillingDocumentSequence {\n [OptionalProps]?: 'scopeKey' | 'nextValue' | 'createdAt' | 'updatedAt'\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 // 'invoice' | 'credit_memo' | 'receipt'.\n @Property({ type: 'text' })\n series!: string\n\n // '' (never resets), 'YYYY' (yearly) or 'YYYY-MM' (monthly) \u2014 from the mask.\n @Property({ name: 'scope_key', type: 'text', default: '' })\n scopeKey: string = ''\n\n @Property({ name: 'next_value', type: 'bigint', default: 1 })\n nextValue: number = 1\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\n@Entity({ tableName: 'billing_settings' })\n// Mirrors the partial unique index `billing_settings_org_uq` (\u2026 WHERE deleted_at IS NULL)\n// created in Migration20261115000000_billing_invoice_ledger: one settings row per organization.\n@Unique({ name: 'billing_settings_org_uq', properties: ['tenantId', 'organizationId'] })\nexport class BillingSettings {\n [OptionalProps]?:\n | 'lowBalanceThresholdDefault'\n | 'nearLimitBufferDefault'\n | 'statementEnabled'\n | 'topupTaxRate'\n | 'prepaidTaxPoint'\n | 'topupProvider'\n | 'numberMasks'\n | 'legalName'\n | 'sellerAddress'\n | 'taxId'\n | 'bankName'\n | 'iban'\n | 'bic'\n | 'invoiceFooter'\n | 'logoAttachmentId'\n | 'defaultPaymentTermsDays'\n | 'defaultTaxRate'\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 // Prepaid defaults (moved from core `configs`, E-D2).\n @Property({ name: 'low_balance_threshold_default', type: 'numeric', columnType: 'numeric(18, 4)', default: '0' })\n lowBalanceThresholdDefault: string = '0'\n\n @Property({ name: 'near_limit_buffer_default', type: 'numeric', columnType: 'numeric(18, 4)', default: '0' })\n nearLimitBufferDefault: string = '0'\n\n @Property({ name: 'statement_enabled', type: 'boolean', default: true })\n statementEnabled: boolean = true\n\n @Property({ name: 'topup_tax_rate', type: 'numeric', columnType: 'numeric(7, 4)', default: '0' })\n topupTaxRate: string = '0'\n\n // Spec F (F-D3) \u2014 where prepaid VAT is charged: 'topup' (VAT split on the\n // top-up receipt; consumption debits carry no VAT) or 'consumption'\n // (receipts carry no VAT; debits are gross at the item's tax rate).\n @Property({ name: 'prepaid_tax_point', type: 'text', default: 'topup' })\n prepaidTaxPoint: 'topup' | 'consumption' = 'topup'\n\n @Property({ name: 'topup_provider', type: 'text', default: 'stripe' })\n topupProvider: string = 'stripe'\n\n // { invoice, credit_memo, receipt } number masks (Spec 0 numbering).\n @Property({ name: 'number_masks', type: 'jsonb', nullable: true })\n numberMasks?: Record<string, string> | null\n\n // Seller / payment / document fields (Spec B). Posting is blocked until\n // legal_name, seller_address, tax_id and iban are filled.\n @Property({ name: 'legal_name', type: 'text', nullable: true })\n legalName?: string | null\n\n // { line1, line2?, city, postal_code, country }\n @Property({ name: 'seller_address', type: 'jsonb', nullable: true })\n sellerAddress?: Record<string, unknown> | null\n\n @Property({ name: 'tax_id', type: 'text', nullable: true })\n taxId?: string | null\n\n @Property({ name: 'bank_name', type: 'text', nullable: true })\n bankName?: string | null\n\n @Property({ name: 'iban', type: 'text', nullable: true })\n iban?: string | null\n\n @Property({ name: 'bic', type: 'text', nullable: true })\n bic?: string | null\n\n @Property({ name: 'invoice_footer', type: 'text', nullable: true })\n invoiceFooter?: string | null\n\n // Attachment id (core `attachments`) of the document logo.\n @Property({ name: 'logo_attachment_id', type: 'uuid', nullable: true })\n logoAttachmentId?: string | null\n\n @Property({ name: 'default_payment_terms_days', type: 'integer', default: 14 })\n defaultPaymentTermsDays: number = 14\n\n @Property({ name: 'default_tax_rate', type: 'numeric', columnType: 'numeric(7, 4)', default: '23' })\n defaultTaxRate: string = '23'\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 Spec C \u2014 payments, allocations, imports \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n//\n// A billing-owned payment register (no core `SalesPayment`). One row per\n// money-in event (bank CSV line, manual entry, gateway capture). Invoice\n// `paid_total` / `outstanding` / status are always RECOMPUTED from the\n// active allocations (`lib/allocation.ts`), never incremented.\n// Partial unique indexes (source_ref, external_ref) are in the migration.\n\n@Entity({ tableName: 'billing_payments' })\n@Index({ name: 'billing_payments_status_idx', properties: ['tenantId', 'organizationId', 'status'] })\n@Index({ name: 'billing_payments_account_idx', properties: ['billAccountId', 'status'] })\n@Index({ name: 'billing_payments_import_idx', properties: ['importId'] })\nexport class BillingPayment {\n [OptionalProps]?:\n | 'reference'\n | 'payerName'\n | 'payerAccount'\n | 'importId'\n | 'billAccountId'\n | 'matchReason'\n | 'externalRef'\n | 'topupId'\n | 'metadata'\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: 'received_at', type: 'date', columnType: 'date' })\n receivedAt!: Date\n\n // Always > 0 (refunds are out of scope).\n @Property({ type: 'numeric', columnType: 'numeric(18, 4)' })\n amount!: string\n\n @Property({ name: 'currency_code', type: 'text' })\n currencyCode!: string\n\n @Property({ type: 'text', nullable: true })\n reference?: string | null\n\n @Property({ name: 'payer_name', type: 'text', nullable: true })\n payerName?: string | null\n\n @Property({ name: 'payer_account', type: 'text', nullable: true })\n payerAccount?: string | null\n\n // csv | manual | gateway\n @Property({ type: 'text' })\n source!: string\n\n @Property({ name: 'import_id', type: 'uuid', nullable: true })\n importId?: string | null\n\n // Null while unmatched; set by the matcher or \"assign account\".\n @Property({ name: 'bill_account_id', type: 'uuid', nullable: true })\n billAccountId?: string | null\n\n // unmatched | matched | partially_allocated | allocated | ignored | converted_to_topup\n @Property({ type: 'text' })\n status!: string\n\n @Property({ name: 'unallocated_amount', type: 'numeric', columnType: 'numeric(18, 4)' })\n unallocatedAmount!: string\n\n // no_reference | currency_mismatch | invoice_already_paid | prepaid_account | manual\n @Property({ name: 'match_reason', type: 'text', nullable: true })\n matchReason?: string | null\n\n // Duplicate guard \u2014 sha256 of the row + occurrence index (unique per org).\n @Property({ name: 'source_ref', type: 'text' })\n sourceRef!: string\n\n // Gateway transaction id (unique per org when set).\n @Property({ name: 'external_ref', type: 'text', nullable: true })\n externalRef?: string | null\n\n // Set by \"convert to top-up\" (C-D3).\n @Property({ name: 'topup_id', type: 'uuid', nullable: true })\n topupId?: string | null\n\n @Property({ type: 'jsonb', nullable: true })\n metadata?: Record<string, unknown> | null\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// Source-typed allocation (Spec C, generalised for Spec D credit memos):\n// `source_type = 'payment' | 'credit_memo'`, `source_id` \u2192 billing_payments\n// or billing_invoices. Un-allocate = soft delete (history kept).\n@Entity({ tableName: 'billing_allocations' })\n// Scope-first like the package's other indexes; every allocation read filters by\n// tenant + organization plus the invoice or the source (Migration20261120000000).\n@Index({ name: 'billing_allocations_source_idx', properties: ['tenantId', 'organizationId', 'sourceType', 'sourceId'] })\n@Index({ name: 'billing_allocations_invoice_idx', properties: ['tenantId', 'organizationId', 'invoiceId'] })\n@Index({ name: 'billing_allocations_account_idx', properties: ['tenantId', 'organizationId', 'billAccountId'] })\nexport class BillingAllocation {\n [OptionalProps]?: 'userId' | 'deallocatedByUserId' | 'createdAt' | 'updatedAt' | '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: 'source_type', type: 'text' })\n sourceType!: string\n\n @Property({ name: 'source_id', type: 'uuid' })\n sourceId!: string\n\n @Property({ name: 'invoice_id', type: 'uuid' })\n invoiceId!: string\n\n @Property({ name: 'bill_account_id', type: 'uuid' })\n billAccountId!: string\n\n @Property({ type: 'numeric', columnType: 'numeric(18, 4)' })\n amount!: string\n\n @Property({ name: 'currency_code', type: 'text' })\n currencyCode!: string\n\n // auto | credit | user | gateway\n @Property({ name: 'allocated_by', type: 'text' })\n allocatedBy!: string\n\n @Property({ name: 'user_id', type: 'uuid', nullable: true })\n userId?: string | null\n\n @Property({ name: 'deallocated_by_user_id', type: 'uuid', nullable: true })\n deallocatedByUserId?: string | null\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// One CSV upload (C-D4): counts per outcome + row errors.\n@Entity({ tableName: 'billing_payment_imports' })\n@Index({ name: 'billing_payment_imports_scope_idx', properties: ['tenantId', 'organizationId', 'createdAt'] })\nexport class BillingPaymentImport {\n [OptionalProps]?: 'userId' | 'counts' | 'errors' | 'createdAt' | 'updatedAt' | '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: 'file_name', type: 'text' })\n fileName!: string\n\n @Property({ name: 'row_count', type: 'integer' })\n rowCount!: number\n\n // { allocated, partially_allocated, matched, unmatched, duplicate, rejected }\n @Property({ type: 'jsonb', nullable: true })\n counts?: Record<string, number> | null\n\n // [{ row, message }] \u2014 capped at 200 entries\n @Property({ type: 'jsonb', nullable: true })\n errors?: Array<{ row: number; message: string }> | null\n\n @Property({ name: 'user_id', type: 'uuid', nullable: true })\n userId?: string | null\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"],
5
+ "mappings": ";;;;;;;;;;AAAA,SAAS,qBAAqB;AAC9B,SAAS,QAAQ,OAAO,YAAY,UAAU,cAAc;AA8BzD;AADI,IAAM,iBAAN,MAAqB;AAAA,EAArB;AAiCL,wBAAqC;AAiDrC,uBAAsB;AAMtB,uBAAsB;AAStB,2BAA2B;AAG3B,oBAAoB;AAGpB,qBAAkB,oBAAI,KAAK;AAG3B,qBAAkB,oBAAI,KAAK;AAAA;AAI7B;AA/FE;AAAA,EADC,WAAW,EAAE,MAAM,QAAQ,YAAY,oBAAoB,CAAC;AAAA,GAdlD,eAeX;AAGA;AAAA,EADC,SAAS,EAAE,MAAM,mBAAmB,MAAM,OAAO,CAAC;AAAA,GAjBxC,eAkBX;AAGA;AAAA,EADC,SAAS,EAAE,MAAM,aAAa,MAAM,OAAO,CAAC;AAAA,GApBlC,eAqBX;AAMA;AAAA,EADC,SAAS,EAAE,MAAM,eAAe,MAAM,OAAO,CAAC;AAAA,GA1BpC,eA2BX;AAMA;AAAA,EADC,SAAS,EAAE,MAAM,iBAAiB,MAAM,QAAQ,SAAS,UAAU,CAAC;AAAA,GAhC1D,eAiCX;AAGA;AAAA,EADC,SAAS,EAAE,MAAM,OAAO,CAAC;AAAA,GAnCf,eAoCX;AAKA;AAAA,EADC,SAAS,EAAE,MAAM,iBAAiB,MAAM,OAAO,CAAC;AAAA,G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AkB,WAAW,EAAE,CAAC;AAAA,GAChG;",
6
6
  "names": []
7
7
  }
@@ -9,7 +9,16 @@ const billingEntityIds = {
9
9
  balance: "billing:billing_account_balance",
10
10
  transaction: "billing:billing_account_transaction",
11
11
  topup: "billing:billing_topup",
12
- statement: "billing:billing_statement"
12
+ statement: "billing:billing_statement",
13
+ // Spec 0 (standalone invoice ledger)
14
+ invoice: "billing:billing_invoice",
15
+ invoiceLine: "billing:billing_invoice_line",
16
+ documentSequence: "billing:billing_document_sequence",
17
+ settings: "billing:billing_settings",
18
+ // Spec C (payments)
19
+ payment: "billing:billing_payment",
20
+ allocation: "billing:billing_allocation",
21
+ paymentImport: "billing:billing_payment_import"
13
22
  };
14
23
  export {
15
24
  billingEntityIds
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/modules/billing/data/entityIds.ts"],
4
- "sourcesContent": ["/**\n * Canonical entity IDs for the billing module \u2014 the single source of truth.\n * Billing code (CRUD factory `entityId`, indexer `entityType`, response\n * enricher `targetEntity`, \u2026) imports from here; a package must not import\n * the app's `#generated/entities.ids.generated`.\n *\n * The build turns this object into the shipped registry\n * `generated/entities.ids.generated.ts` (scripts/generate-entity-registry.mjs),\n * which a consuming app's `mercato generate` reads to register these ids in\n * its own `E.billing`. Without that, the query index rejects billing writes\n * and `mercato entities install` treats the ids as virtual custom entities.\n *\n * Adding an entity: add it here, then `yarn workspace @dainamite/billing\n * build` and commit `generated/`. The id suffix must be the snake_case of\n * the entity class name (`billing_run` \u2192 `BillingRun`): that is how the\n * framework maps an id to its table, and the build fails otherwise. Do not\n * rely on its table-name fallback \u2014 on Open Mercato 0.9 with MikroORM 7 it\n * never matches (it iterates `MetadataStorage.getAll()` as an array, but\n * that returns a Map).\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 // SPEC-002 (prepaid balance billing)\n balance: 'billing:billing_account_balance',\n transaction: 'billing:billing_account_transaction',\n topup: 'billing:billing_topup',\n statement: 'billing:billing_statement',\n} as const\n\nexport type BillingEntityId = (typeof billingEntityIds)[keyof typeof billingEntityIds]\n"],
5
- "mappings": "AAoBO,MAAM,mBAAmB;AAAA,EAC9B,SAAS;AAAA,EACT,MAAM;AAAA,EACN,OAAO;AAAA,EACP,KAAK;AAAA,EACL,YAAY;AAAA,EACZ,kBAAkB;AAAA;AAAA,EAElB,SAAS;AAAA,EACT,aAAa;AAAA,EACb,OAAO;AAAA,EACP,WAAW;AACb;",
4
+ "sourcesContent": ["/**\n * Canonical entity IDs for the billing module \u2014 the single source of truth.\n * Billing code (CRUD factory `entityId`, indexer `entityType`, response\n * enricher `targetEntity`, \u2026) imports from here; a package must not import\n * the app's `#generated/entities.ids.generated`.\n *\n * The build turns this object into the shipped registry\n * `generated/entities.ids.generated.ts` (scripts/generate-entity-registry.mjs),\n * which a consuming app's `mercato generate` reads to register these ids in\n * its own `E.billing`. Without that, the query index rejects billing writes\n * and `mercato entities install` treats the ids as virtual custom entities.\n *\n * Adding an entity: add it here, then `yarn workspace @dainamite/billing\n * build` and commit `generated/`. The id suffix must be the snake_case of\n * the entity class name (`billing_run` \u2192 `BillingRun`): that is how the\n * framework maps an id to its table, and the build fails otherwise. Do not\n * rely on its table-name fallback \u2014 on Open Mercato 0.9 with MikroORM 7 it\n * never matches (it iterates `MetadataStorage.getAll()` as an array, but\n * that returns a Map).\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 // SPEC-002 (prepaid balance billing)\n balance: 'billing:billing_account_balance',\n transaction: 'billing:billing_account_transaction',\n topup: 'billing:billing_topup',\n statement: 'billing:billing_statement',\n // Spec 0 (standalone invoice ledger)\n invoice: 'billing:billing_invoice',\n invoiceLine: 'billing:billing_invoice_line',\n documentSequence: 'billing:billing_document_sequence',\n settings: 'billing:billing_settings',\n // Spec C (payments)\n payment: 'billing:billing_payment',\n allocation: 'billing:billing_allocation',\n paymentImport: 'billing:billing_payment_import',\n} as const\n\nexport type BillingEntityId = (typeof billingEntityIds)[keyof typeof billingEntityIds]\n"],
5
+ "mappings": "AAoBO,MAAM,mBAAmB;AAAA,EAC9B,SAAS;AAAA,EACT,MAAM;AAAA,EACN,OAAO;AAAA,EACP,KAAK;AAAA,EACL,YAAY;AAAA,EACZ,kBAAkB;AAAA;AAAA,EAElB,SAAS;AAAA,EACT,aAAa;AAAA,EACb,OAAO;AAAA,EACP,WAAW;AAAA;AAAA,EAEX,SAAS;AAAA,EACT,aAAa;AAAA,EACb,kBAAkB;AAAA,EAClB,UAAU;AAAA;AAAA,EAEV,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,eAAe;AACjB;",
6
6
  "names": []
7
7
  }