@dainamite/billing 0.19.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 (614) hide show
  1. package/CHANGELOG.md +172 -0
  2. package/README.md +14 -0
  3. package/dist/modules/billing/acl.js +13 -1
  4. package/dist/modules/billing/acl.js.map +2 -2
  5. package/dist/modules/billing/api/accounts/[id]/summary/route.js +52 -0
  6. package/dist/modules/billing/api/accounts/[id]/summary/route.js.map +7 -0
  7. package/dist/modules/billing/api/accounts/route.js +46 -4
  8. package/dist/modules/billing/api/accounts/route.js.map +2 -2
  9. package/dist/modules/billing/api/export/account/[id]/route.js +16 -12
  10. package/dist/modules/billing/api/export/account/[id]/route.js.map +2 -2
  11. package/dist/modules/billing/api/invoices/[id]/memos/route.js +54 -0
  12. package/dist/modules/billing/api/invoices/[id]/memos/route.js.map +7 -0
  13. package/dist/modules/billing/api/invoices/[id]/pdf/route.js +69 -0
  14. package/dist/modules/billing/api/invoices/[id]/pdf/route.js.map +7 -0
  15. package/dist/modules/billing/api/invoices/[id]/route.js +44 -24
  16. package/dist/modules/billing/api/invoices/[id]/route.js.map +2 -2
  17. package/dist/modules/billing/api/invoices/[id]/send/route.js +107 -0
  18. package/dist/modules/billing/api/invoices/[id]/send/route.js.map +7 -0
  19. package/dist/modules/billing/api/invoices/add-line/route.js +3 -3
  20. package/dist/modules/billing/api/invoices/add-line/route.js.map +2 -2
  21. package/dist/modules/billing/api/invoices/delete-draft/route.js +33 -0
  22. package/dist/modules/billing/api/invoices/delete-draft/route.js.map +7 -0
  23. package/dist/modules/billing/api/invoices/edit-line/route.js +3 -3
  24. package/dist/modules/billing/api/invoices/edit-line/route.js.map +2 -2
  25. package/dist/modules/billing/api/invoices/post/route.js +2 -2
  26. package/dist/modules/billing/api/invoices/post/route.js.map +2 -2
  27. package/dist/modules/billing/api/invoices/remove-line/route.js +3 -3
  28. package/dist/modules/billing/api/invoices/remove-line/route.js.map +2 -2
  29. package/dist/modules/billing/api/invoices/route.js +45 -46
  30. package/dist/modules/billing/api/invoices/route.js.map +2 -2
  31. package/dist/modules/billing/api/items/bulk/route.js +1 -1
  32. package/dist/modules/billing/api/items/bulk/route.js.map +2 -2
  33. package/dist/modules/billing/api/items/change-price/route.js +44 -0
  34. package/dist/modules/billing/api/items/change-price/route.js.map +7 -0
  35. package/dist/modules/billing/api/items/route.js +19 -7
  36. package/dist/modules/billing/api/items/route.js.map +2 -2
  37. package/dist/modules/billing/api/payment-imports/[id]/route.js +49 -0
  38. package/dist/modules/billing/api/payment-imports/[id]/route.js.map +7 -0
  39. package/dist/modules/billing/api/payment-imports/route.js +57 -0
  40. package/dist/modules/billing/api/payment-imports/route.js.map +7 -0
  41. package/dist/modules/billing/api/payments/[id]/route.js +60 -0
  42. package/dist/modules/billing/api/payments/[id]/route.js.map +7 -0
  43. package/dist/modules/billing/api/payments/allocate/route.js +35 -0
  44. package/dist/modules/billing/api/payments/allocate/route.js.map +7 -0
  45. package/dist/modules/billing/api/payments/assign/route.js +36 -0
  46. package/dist/modules/billing/api/payments/assign/route.js.map +7 -0
  47. package/dist/modules/billing/api/payments/convert-to-topup/route.js +35 -0
  48. package/dist/modules/billing/api/payments/convert-to-topup/route.js.map +7 -0
  49. package/dist/modules/billing/api/payments/ignore/route.js +35 -0
  50. package/dist/modules/billing/api/payments/ignore/route.js.map +7 -0
  51. package/dist/modules/billing/api/payments/import/route.js +63 -0
  52. package/dist/modules/billing/api/payments/import/route.js.map +7 -0
  53. package/dist/modules/billing/api/payments/restore/route.js +35 -0
  54. package/dist/modules/billing/api/payments/restore/route.js.map +7 -0
  55. package/dist/modules/billing/api/payments/route.js +114 -0
  56. package/dist/modules/billing/api/payments/route.js.map +7 -0
  57. package/dist/modules/billing/api/payments/unallocate/route.js +35 -0
  58. package/dist/modules/billing/api/payments/unallocate/route.js.map +7 -0
  59. package/dist/modules/billing/api/payments/unassign/route.js +35 -0
  60. package/dist/modules/billing/api/payments/unassign/route.js.map +7 -0
  61. package/dist/modules/billing/api/run-outcomes/route.js +44 -7
  62. package/dist/modules/billing/api/run-outcomes/route.js.map +2 -2
  63. package/dist/modules/billing/api/runs/[id]/post-drafts/route.js +61 -0
  64. package/dist/modules/billing/api/runs/[id]/post-drafts/route.js.map +7 -0
  65. package/dist/modules/billing/api/runs/[id]/route.js +53 -0
  66. package/dist/modules/billing/api/runs/[id]/route.js.map +7 -0
  67. package/dist/modules/billing/api/runs/retry-failed/route.js +3 -3
  68. package/dist/modules/billing/api/runs/retry-failed/route.js.map +2 -2
  69. package/dist/modules/billing/api/runs/route.js +11 -5
  70. package/dist/modules/billing/api/runs/route.js.map +2 -2
  71. package/dist/modules/billing/api/settings/number-preview/route.js +42 -0
  72. package/dist/modules/billing/api/settings/number-preview/route.js.map +7 -0
  73. package/dist/modules/billing/api/settings/route.js +92 -0
  74. package/dist/modules/billing/api/settings/route.js.map +7 -0
  75. package/dist/modules/billing/api/statements/route.js +3 -0
  76. package/dist/modules/billing/api/statements/route.js.map +2 -2
  77. package/dist/modules/billing/api/test-invoices/wipe/route.js +2 -2
  78. package/dist/modules/billing/api/test-invoices/wipe/route.js.map +2 -2
  79. package/dist/modules/billing/backend/billing/accounts/[id]/page.js +121 -232
  80. package/dist/modules/billing/backend/billing/accounts/[id]/page.js.map +2 -2
  81. package/dist/modules/billing/backend/billing/accounts/create/page.js +6 -0
  82. package/dist/modules/billing/backend/billing/accounts/create/page.js.map +2 -2
  83. package/dist/modules/billing/backend/billing/accounts/page.js +63 -4
  84. package/dist/modules/billing/backend/billing/accounts/page.js.map +2 -2
  85. package/dist/modules/billing/backend/billing/invoices/[id]/page.js +297 -65
  86. package/dist/modules/billing/backend/billing/invoices/[id]/page.js.map +3 -3
  87. package/dist/modules/billing/backend/billing/invoices/page.js +6 -172
  88. package/dist/modules/billing/backend/billing/invoices/page.js.map +2 -2
  89. package/dist/modules/billing/backend/billing/items/[id]/page.js +51 -7
  90. package/dist/modules/billing/backend/billing/items/[id]/page.js.map +2 -2
  91. package/dist/modules/billing/backend/billing/items/create/page.js +9 -6
  92. package/dist/modules/billing/backend/billing/items/create/page.js.map +2 -2
  93. package/dist/modules/billing/backend/billing/items/page.js +8 -2
  94. package/dist/modules/billing/backend/billing/items/page.js.map +2 -2
  95. package/dist/modules/billing/backend/billing/payments/[id]/page.js +297 -0
  96. package/dist/modules/billing/backend/billing/payments/[id]/page.js.map +7 -0
  97. package/dist/modules/billing/backend/billing/payments/[id]/page.meta.js +21 -0
  98. package/dist/modules/billing/backend/billing/payments/[id]/page.meta.js.map +7 -0
  99. package/dist/modules/billing/backend/billing/payments/imports/[id]/page.js +74 -0
  100. package/dist/modules/billing/backend/billing/payments/imports/[id]/page.js.map +7 -0
  101. package/dist/modules/billing/backend/billing/payments/imports/[id]/page.meta.js +21 -0
  102. package/dist/modules/billing/backend/billing/payments/imports/[id]/page.meta.js.map +7 -0
  103. package/dist/modules/billing/backend/billing/payments/page.js +58 -0
  104. package/dist/modules/billing/backend/billing/payments/page.js.map +7 -0
  105. package/dist/modules/billing/backend/billing/payments/page.meta.js +18 -0
  106. package/dist/modules/billing/backend/billing/payments/page.meta.js.map +7 -0
  107. package/dist/modules/billing/backend/billing/runs/[id]/page.js +49 -14
  108. package/dist/modules/billing/backend/billing/runs/[id]/page.js.map +2 -2
  109. package/dist/modules/billing/backend/billing/runs/page.js +58 -7
  110. package/dist/modules/billing/backend/billing/runs/page.js.map +2 -2
  111. package/dist/modules/billing/backend/billing/statements/[id]/page.js +61 -6
  112. package/dist/modules/billing/backend/billing/statements/[id]/page.js.map +2 -2
  113. package/dist/modules/billing/backend/billing/statements/page.js +1 -1
  114. package/dist/modules/billing/backend/billing/statements/page.js.map +2 -2
  115. package/dist/modules/billing/backend/billing/topups/page.js +1 -1
  116. package/dist/modules/billing/backend/billing/topups/page.js.map +2 -2
  117. package/dist/modules/billing/backend/billing/transactions/page.js +1 -1
  118. package/dist/modules/billing/backend/billing/transactions/page.js.map +2 -2
  119. package/dist/modules/billing/backend/billing/usage/create/page.js +3 -2
  120. package/dist/modules/billing/backend/billing/usage/create/page.js.map +2 -2
  121. package/dist/modules/billing/backend/config/billing/page.js +472 -0
  122. package/dist/modules/billing/backend/config/billing/page.js.map +7 -0
  123. package/dist/modules/billing/backend/config/billing/page.meta.js +19 -0
  124. package/dist/modules/billing/backend/config/billing/page.meta.js.map +7 -0
  125. package/dist/modules/billing/ce.js.map +2 -2
  126. package/dist/modules/billing/cli.js +22 -1
  127. package/dist/modules/billing/cli.js.map +2 -2
  128. package/dist/modules/billing/commands/accounts.js +6 -0
  129. package/dist/modules/billing/commands/accounts.js.map +2 -2
  130. package/dist/modules/billing/commands/index.js +3 -0
  131. package/dist/modules/billing/commands/index.js.map +2 -2
  132. package/dist/modules/billing/commands/invoices.js +272 -170
  133. package/dist/modules/billing/commands/invoices.js.map +2 -2
  134. package/dist/modules/billing/commands/items.js +108 -0
  135. package/dist/modules/billing/commands/items.js.map +2 -2
  136. package/dist/modules/billing/commands/memos.js +179 -0
  137. package/dist/modules/billing/commands/memos.js.map +7 -0
  138. package/dist/modules/billing/commands/payments.js +379 -0
  139. package/dist/modules/billing/commands/payments.js.map +7 -0
  140. package/dist/modules/billing/commands/runs.js +154 -7
  141. package/dist/modules/billing/commands/runs.js.map +2 -2
  142. package/dist/modules/billing/commands/settings.js +59 -0
  143. package/dist/modules/billing/commands/settings.js.map +7 -0
  144. package/dist/modules/billing/commands/topups.js +9 -2
  145. package/dist/modules/billing/commands/topups.js.map +2 -2
  146. package/dist/modules/billing/commands/transactions.js +2 -2
  147. package/dist/modules/billing/commands/transactions.js.map +2 -2
  148. package/dist/modules/billing/components/AccountForm.js +149 -42
  149. package/dist/modules/billing/components/AccountForm.js.map +2 -2
  150. package/dist/modules/billing/components/AccountInvoicesSection.js +64 -0
  151. package/dist/modules/billing/components/AccountInvoicesSection.js.map +7 -0
  152. package/dist/modules/billing/components/AccountPaymentsSection.js +43 -0
  153. package/dist/modules/billing/components/AccountPaymentsSection.js.map +7 -0
  154. package/dist/modules/billing/components/AccountPicker.js +56 -0
  155. package/dist/modules/billing/components/AccountPicker.js.map +7 -0
  156. package/dist/modules/billing/components/AllocatePaymentDialog.js +134 -0
  157. package/dist/modules/billing/components/AllocatePaymentDialog.js.map +7 -0
  158. package/dist/modules/billing/components/BillingDataTable.js +21 -0
  159. package/dist/modules/billing/components/BillingDataTable.js.map +7 -0
  160. package/dist/modules/billing/components/BillingSettingsLink.js +19 -0
  161. package/dist/modules/billing/components/BillingSettingsLink.js.map +7 -0
  162. package/dist/modules/billing/components/ChangeItemPriceDialog.js +158 -0
  163. package/dist/modules/billing/components/ChangeItemPriceDialog.js.map +7 -0
  164. package/dist/modules/billing/components/CreateMemoDialog.js +200 -0
  165. package/dist/modules/billing/components/CreateMemoDialog.js.map +7 -0
  166. package/dist/modules/billing/components/CustomerLabel.js +33 -0
  167. package/dist/modules/billing/components/CustomerLabel.js.map +7 -0
  168. package/dist/modules/billing/components/InvoicesTable.js +270 -0
  169. package/dist/modules/billing/components/InvoicesTable.js.map +7 -0
  170. package/dist/modules/billing/components/ItemForm.js +176 -44
  171. package/dist/modules/billing/components/ItemForm.js.map +2 -2
  172. package/dist/modules/billing/components/ItemPriceField.js +46 -0
  173. package/dist/modules/billing/components/ItemPriceField.js.map +7 -0
  174. package/dist/modules/billing/components/LineFormDialog.js +25 -2
  175. package/dist/modules/billing/components/LineFormDialog.js.map +2 -2
  176. package/dist/modules/billing/components/ManualPaymentDialog.js +122 -0
  177. package/dist/modules/billing/components/ManualPaymentDialog.js.map +7 -0
  178. package/dist/modules/billing/components/MoneyInput.js +14 -0
  179. package/dist/modules/billing/components/MoneyInput.js.map +7 -0
  180. package/dist/modules/billing/components/PaymentUploadDialog.js +115 -0
  181. package/dist/modules/billing/components/PaymentUploadDialog.js.map +7 -0
  182. package/dist/modules/billing/components/PaymentsTable.js +171 -0
  183. package/dist/modules/billing/components/PaymentsTable.js.map +7 -0
  184. package/dist/modules/billing/components/PostRunDraftsButton.js +105 -0
  185. package/dist/modules/billing/components/PostRunDraftsButton.js.map +7 -0
  186. package/dist/modules/billing/components/PrepaidPanel.js +14 -4
  187. package/dist/modules/billing/components/PrepaidPanel.js.map +2 -2
  188. package/dist/modules/billing/components/RunCyclesSection.js +209 -0
  189. package/dist/modules/billing/components/RunCyclesSection.js.map +7 -0
  190. package/dist/modules/billing/components/TestRunActions.js +127 -0
  191. package/dist/modules/billing/components/TestRunActions.js.map +7 -0
  192. package/dist/modules/billing/components/account/AccountItemsTab.js +157 -0
  193. package/dist/modules/billing/components/account/AccountItemsTab.js.map +7 -0
  194. package/dist/modules/billing/components/account/AccountRunBillingDialog.js +122 -0
  195. package/dist/modules/billing/components/account/AccountRunBillingDialog.js.map +7 -0
  196. package/dist/modules/billing/components/account/AccountRunsTab.js +152 -0
  197. package/dist/modules/billing/components/account/AccountRunsTab.js.map +7 -0
  198. package/dist/modules/billing/components/account/AccountStatementsTab.js +98 -0
  199. package/dist/modules/billing/components/account/AccountStatementsTab.js.map +7 -0
  200. package/dist/modules/billing/components/account/AccountSummaryCards.js +125 -0
  201. package/dist/modules/billing/components/account/AccountSummaryCards.js.map +7 -0
  202. package/dist/modules/billing/components/account/AccountUsageTab.js +91 -0
  203. package/dist/modules/billing/components/account/AccountUsageTab.js.map +7 -0
  204. package/dist/modules/billing/components/account/AccountView.js +73 -0
  205. package/dist/modules/billing/components/account/AccountView.js.map +7 -0
  206. package/dist/modules/billing/components/account/accountRow.js +39 -0
  207. package/dist/modules/billing/components/account/accountRow.js.map +7 -0
  208. package/dist/modules/billing/components/customerNames.js +42 -0
  209. package/dist/modules/billing/components/customerNames.js.map +7 -0
  210. package/dist/modules/billing/data/entities.js +615 -59
  211. package/dist/modules/billing/data/entities.js.map +2 -2
  212. package/dist/modules/billing/data/entityIds.js +10 -1
  213. package/dist/modules/billing/data/entityIds.js.map +2 -2
  214. package/dist/modules/billing/data/validators.js +269 -15
  215. package/dist/modules/billing/data/validators.js.map +2 -2
  216. package/dist/modules/billing/events.js +70 -0
  217. package/dist/modules/billing/events.js.map +2 -2
  218. package/dist/modules/billing/i18n/en.json +457 -21
  219. package/dist/modules/billing/i18n/pl.json +457 -21
  220. package/dist/modules/billing/index.js +6 -2
  221. package/dist/modules/billing/index.js.map +2 -2
  222. package/dist/modules/billing/lib/accountFinancials.js +58 -0
  223. package/dist/modules/billing/lib/accountFinancials.js.map +7 -0
  224. package/dist/modules/billing/lib/accountLock.js +14 -0
  225. package/dist/modules/billing/lib/accountLock.js.map +7 -0
  226. package/dist/modules/billing/lib/accountStatus.js +9 -7
  227. package/dist/modules/billing/lib/accountStatus.js.map +2 -2
  228. package/dist/modules/billing/lib/accountSummary.js +106 -0
  229. package/dist/modules/billing/lib/accountSummary.js.map +7 -0
  230. package/dist/modules/billing/lib/allocation.js +356 -0
  231. package/dist/modules/billing/lib/allocation.js.map +7 -0
  232. package/dist/modules/billing/lib/allocationEvents.js +22 -0
  233. package/dist/modules/billing/lib/allocationEvents.js.map +7 -0
  234. package/dist/modules/billing/lib/billPeriod.js +15 -1
  235. package/dist/modules/billing/lib/billPeriod.js.map +2 -2
  236. package/dist/modules/billing/lib/billRunEngine.js +241 -106
  237. package/dist/modules/billing/lib/billRunEngine.js.map +2 -2
  238. package/dist/modules/billing/lib/billRunLabel.js.map +1 -1
  239. package/dist/modules/billing/lib/billingSettings.js +116 -0
  240. package/dist/modules/billing/lib/billingSettings.js.map +7 -0
  241. package/dist/modules/billing/lib/commandRoute.js +81 -0
  242. package/dist/modules/billing/lib/commandRoute.js.map +7 -0
  243. package/dist/modules/billing/lib/customerLookup.js +97 -0
  244. package/dist/modules/billing/lib/customerLookup.js.map +7 -0
  245. package/dist/modules/billing/lib/dateOnly.js +13 -0
  246. package/dist/modules/billing/lib/dateOnly.js.map +7 -0
  247. package/dist/modules/billing/lib/documentParties.js +16 -0
  248. package/dist/modules/billing/lib/documentParties.js.map +7 -0
  249. package/dist/modules/billing/lib/documentTypes.js +27 -0
  250. package/dist/modules/billing/lib/documentTypes.js.map +7 -0
  251. package/dist/modules/billing/lib/dueDate.js +18 -0
  252. package/dist/modules/billing/lib/dueDate.js.map +7 -0
  253. package/dist/modules/billing/lib/iban.js +29 -0
  254. package/dist/modules/billing/lib/iban.js.map +7 -0
  255. package/dist/modules/billing/lib/invoiceDelivery.js +131 -0
  256. package/dist/modules/billing/lib/invoiceDelivery.js.map +7 -0
  257. package/dist/modules/billing/lib/invoiceLanguages.js +16 -0
  258. package/dist/modules/billing/lib/invoiceLanguages.js.map +7 -0
  259. package/dist/modules/billing/lib/invoiceWriter.js +107 -99
  260. package/dist/modules/billing/lib/invoiceWriter.js.map +2 -2
  261. package/dist/modules/billing/lib/itemBillingState.js +27 -0
  262. package/dist/modules/billing/lib/itemBillingState.js.map +7 -0
  263. package/dist/modules/billing/lib/itemPriceChange.js +18 -0
  264. package/dist/modules/billing/lib/itemPriceChange.js.map +7 -0
  265. package/dist/modules/billing/lib/itemSelector.js.map +2 -2
  266. package/dist/modules/billing/lib/lineAmounts.js +32 -0
  267. package/dist/modules/billing/lib/lineAmounts.js.map +7 -0
  268. package/dist/modules/billing/lib/memoGuards.js +25 -0
  269. package/dist/modules/billing/lib/memoGuards.js.map +7 -0
  270. package/dist/modules/billing/lib/navigation.js +48 -0
  271. package/dist/modules/billing/lib/navigation.js.map +7 -0
  272. package/dist/modules/billing/lib/numbering.js +120 -0
  273. package/dist/modules/billing/lib/numbering.js.map +7 -0
  274. package/dist/modules/billing/lib/overdue.js +36 -0
  275. package/dist/modules/billing/lib/overdue.js.map +7 -0
  276. package/dist/modules/billing/lib/paymentCsv.js +125 -0
  277. package/dist/modules/billing/lib/paymentCsv.js.map +7 -0
  278. package/dist/modules/billing/lib/paymentGateway.js +15 -0
  279. package/dist/modules/billing/lib/paymentGateway.js.map +7 -0
  280. package/dist/modules/billing/lib/paymentImport.js +164 -0
  281. package/dist/modules/billing/lib/paymentImport.js.map +7 -0
  282. package/dist/modules/billing/lib/paymentMatcher.js +36 -0
  283. package/dist/modules/billing/lib/paymentMatcher.js.map +7 -0
  284. package/dist/modules/billing/lib/pdf/attachmentStore.js +46 -0
  285. package/dist/modules/billing/lib/pdf/attachmentStore.js.map +7 -0
  286. package/dist/modules/billing/lib/pdf/fonts/embeddedFonts.js +7 -0
  287. package/dist/modules/billing/lib/pdf/fonts/embeddedFonts.js.map +7 -0
  288. package/dist/modules/billing/lib/pdf/invoiceModel.js +194 -0
  289. package/dist/modules/billing/lib/pdf/invoiceModel.js.map +7 -0
  290. package/dist/modules/billing/lib/pdf/invoicePdf.js +165 -0
  291. package/dist/modules/billing/lib/pdf/invoicePdf.js.map +7 -0
  292. package/dist/modules/billing/lib/pdf/invoiceTemplate.js +274 -0
  293. package/dist/modules/billing/lib/pdf/invoiceTemplate.js.map +7 -0
  294. package/dist/modules/billing/lib/prepaidConfig.js +17 -25
  295. package/dist/modules/billing/lib/prepaidConfig.js.map +2 -2
  296. package/dist/modules/billing/lib/prepaidConsume.js +26 -7
  297. package/dist/modules/billing/lib/prepaidConsume.js.map +2 -2
  298. package/dist/modules/billing/lib/prepaidPeriodClose.js +277 -158
  299. package/dist/modules/billing/lib/prepaidPeriodClose.js.map +2 -2
  300. package/dist/modules/billing/lib/prepaidTaxPoint.js +37 -0
  301. package/dist/modules/billing/lib/prepaidTaxPoint.js.map +7 -0
  302. package/dist/modules/billing/lib/seeds/demo.js +51 -3
  303. package/dist/modules/billing/lib/seeds/demo.js.map +2 -2
  304. package/dist/modules/billing/lib/seeds/paymentsSample.js +93 -0
  305. package/dist/modules/billing/lib/seeds/paymentsSample.js.map +7 -0
  306. package/dist/modules/billing/lib/seeds/sellerSettings.js +41 -0
  307. package/dist/modules/billing/lib/seeds/sellerSettings.js.map +7 -0
  308. package/dist/modules/billing/lib/servicePeriods.js +121 -0
  309. package/dist/modules/billing/lib/servicePeriods.js.map +7 -0
  310. package/dist/modules/billing/lib/tenantLock.js.map +1 -1
  311. package/dist/modules/billing/lib/testRunCleanup.js +24 -0
  312. package/dist/modules/billing/lib/testRunCleanup.js.map +7 -0
  313. package/dist/modules/billing/lib/topupCapture.js +2 -2
  314. package/dist/modules/billing/lib/topupCapture.js.map +2 -2
  315. package/dist/modules/billing/lib/topupReceipt.js +58 -79
  316. package/dist/modules/billing/lib/topupReceipt.js.map +2 -2
  317. package/dist/modules/billing/lib/usageRater.js.map +1 -1
  318. package/dist/modules/billing/lib/usageRunner.js +14 -6
  319. package/dist/modules/billing/lib/usageRunner.js.map +2 -2
  320. package/dist/modules/billing/lib/vat.js +39 -0
  321. package/dist/modules/billing/lib/vat.js.map +7 -0
  322. package/dist/modules/billing/migrations/Migration20261114000000_billing_customer_kind.js +15 -0
  323. package/dist/modules/billing/migrations/Migration20261114000000_billing_customer_kind.js.map +7 -0
  324. package/dist/modules/billing/migrations/Migration20261114100000_billing_cycle_semantics.js +25 -0
  325. package/dist/modules/billing/migrations/Migration20261114100000_billing_cycle_semantics.js.map +7 -0
  326. package/dist/modules/billing/migrations/Migration20261115000000_billing_invoice_ledger.js +115 -0
  327. package/dist/modules/billing/migrations/Migration20261115000000_billing_invoice_ledger.js.map +7 -0
  328. package/dist/modules/billing/migrations/Migration20261116000000_billing_invoice_documents.js +47 -0
  329. package/dist/modules/billing/migrations/Migration20261116000000_billing_invoice_documents.js.map +7 -0
  330. package/dist/modules/billing/migrations/Migration20261117000000_billing_payments.js +89 -0
  331. package/dist/modules/billing/migrations/Migration20261117000000_billing_payments.js.map +7 -0
  332. package/dist/modules/billing/migrations/Migration20261118000000_billing_memos.js +17 -0
  333. package/dist/modules/billing/migrations/Migration20261118000000_billing_memos.js.map +7 -0
  334. package/dist/modules/billing/migrations/Migration20261119000000_billing_operator_feedback.js +27 -0
  335. package/dist/modules/billing/migrations/Migration20261119000000_billing_operator_feedback.js.map +7 -0
  336. package/dist/modules/billing/migrations/Migration20261120000000_billing_allocation_scope_indexes.js +29 -0
  337. package/dist/modules/billing/migrations/Migration20261120000000_billing_allocation_scope_indexes.js.map +7 -0
  338. package/dist/modules/billing/setup.js +7 -184
  339. package/dist/modules/billing/setup.js.map +2 -2
  340. package/dist/modules/billing/subscribers/credit-memo-auto-send.js +16 -0
  341. package/dist/modules/billing/subscribers/credit-memo-auto-send.js.map +7 -0
  342. package/dist/modules/billing/subscribers/debit-memo-apply-credit.js +16 -0
  343. package/dist/modules/billing/subscribers/debit-memo-apply-credit.js.map +7 -0
  344. package/dist/modules/billing/subscribers/debit-memo-auto-send.js +16 -0
  345. package/dist/modules/billing/subscribers/debit-memo-auto-send.js.map +7 -0
  346. package/dist/modules/billing/subscribers/invoice-apply-credit.js +34 -0
  347. package/dist/modules/billing/subscribers/invoice-apply-credit.js.map +7 -0
  348. package/dist/modules/billing/subscribers/invoice-auto-send.js +30 -0
  349. package/dist/modules/billing/subscribers/invoice-auto-send.js.map +7 -0
  350. package/dist/modules/billing/subscribers/payment-captured-to-paid.js +69 -33
  351. package/dist/modules/billing/subscribers/payment-captured-to-paid.js.map +2 -2
  352. package/dist/modules/billing/subscribers/prepaid-topup-captured.js +4 -6
  353. package/dist/modules/billing/subscribers/prepaid-topup-captured.js.map +2 -2
  354. package/dist/modules/billing/workers/reap-stale-bill-runs.js +2 -2
  355. package/dist/modules/billing/workers/reap-stale-bill-runs.js.map +2 -2
  356. package/generated/entities/billing_account/index.ts +26 -0
  357. package/generated/entities/billing_account_balance/index.ts +13 -0
  358. package/generated/entities/billing_account_transaction/index.ts +21 -0
  359. package/generated/entities/billing_account_usage/index.ts +18 -0
  360. package/generated/entities/billing_allocation/index.ts +18 -0
  361. package/generated/entities/billing_document_sequence/index.ts +11 -0
  362. package/generated/entities/billing_draft_invoice_edit/index.ts +14 -0
  363. package/generated/entities/billing_invoice/index.ts +38 -0
  364. package/generated/entities/billing_invoice_line/index.ts +24 -0
  365. package/generated/entities/billing_item/index.ts +26 -0
  366. package/generated/entities/billing_payment/index.ts +25 -0
  367. package/generated/entities/billing_payment_import/index.ts +14 -0
  368. package/generated/entities/billing_run/index.ts +20 -0
  369. package/generated/entities/billing_run_outcome/index.ts +18 -0
  370. package/generated/entities/billing_settings/index.ts +26 -0
  371. package/generated/entities/billing_statement/index.ts +22 -0
  372. package/generated/entities/billing_topup/index.ts +20 -0
  373. package/generated/entities.ids.generated.ts +35 -0
  374. package/package.json +15 -10
  375. package/src/modules/billing/__integration__/TC-BILL-004.spec.ts +170 -0
  376. package/src/modules/billing/__integration__/TC-BILL-005.spec.ts +134 -0
  377. package/src/modules/billing/__integration__/TC-BILL-006.spec.ts +101 -0
  378. package/src/modules/billing/__integration__/TC-BILL-007.spec.ts +140 -0
  379. package/src/modules/billing/__integration__/TC-BILL-008.spec.ts +108 -0
  380. package/src/modules/billing/__integration__/TC-BILL-009.spec.ts +113 -0
  381. package/src/modules/billing/__integration__/TC-BILL-010.spec.ts +118 -0
  382. package/src/modules/billing/__integration__/TC-BILL-011.spec.ts +142 -0
  383. package/src/modules/billing/__integration__/TC-BILL-012.spec.ts +115 -0
  384. package/src/modules/billing/__integration__/TC-BILL-013.spec.ts +118 -0
  385. package/src/modules/billing/__integration__/sellerSettings.ts +24 -0
  386. package/src/modules/billing/__tests__/commands/invoices.test.ts +437 -355
  387. package/src/modules/billing/__tests__/commands/itemsBulk.test.ts +33 -0
  388. package/src/modules/billing/__tests__/commands/memos.test.ts +205 -0
  389. package/src/modules/billing/__tests__/commands/payments.test.ts +241 -0
  390. package/src/modules/billing/__tests__/commands/runsDelete.test.ts +146 -0
  391. package/src/modules/billing/__tests__/commands/runsPostDrafts.test.ts +106 -0
  392. package/src/modules/billing/__tests__/commands/topups.test.ts +11 -0
  393. package/src/modules/billing/__tests__/entityRegistry.test.ts +326 -0
  394. package/src/modules/billing/__tests__/events.test.ts +142 -0
  395. package/src/modules/billing/__tests__/helpers/prepaidMockEm.ts +28 -11
  396. package/src/modules/billing/__tests__/lib/accountFinancials.test.ts +53 -0
  397. package/src/modules/billing/__tests__/lib/accountSummary.test.ts +97 -0
  398. package/src/modules/billing/__tests__/lib/allocation.test.ts +319 -0
  399. package/src/modules/billing/__tests__/lib/billRunEngine.test.ts +231 -20
  400. package/src/modules/billing/__tests__/lib/billingSettings.test.ts +109 -0
  401. package/src/modules/billing/__tests__/lib/customerLookup.test.ts +156 -0
  402. package/src/modules/billing/__tests__/lib/dueDate.test.ts +35 -0
  403. package/src/modules/billing/__tests__/lib/iban.test.ts +38 -0
  404. package/src/modules/billing/__tests__/lib/invoiceDelivery.test.ts +189 -0
  405. package/src/modules/billing/__tests__/lib/invoiceWriter.test.ts +212 -10
  406. package/src/modules/billing/__tests__/lib/itemBillingState.test.ts +42 -0
  407. package/src/modules/billing/__tests__/lib/itemPriceChange.test.ts +165 -0
  408. package/src/modules/billing/__tests__/lib/lineAmounts.test.ts +86 -0
  409. package/src/modules/billing/__tests__/lib/navigation.test.ts +71 -0
  410. package/src/modules/billing/__tests__/lib/numbering.test.ts +91 -0
  411. package/src/modules/billing/__tests__/lib/overdue.test.ts +36 -0
  412. package/src/modules/billing/__tests__/lib/paymentCsv.test.ts +148 -0
  413. package/src/modules/billing/__tests__/lib/paymentImport.test.ts +113 -0
  414. package/src/modules/billing/__tests__/lib/paymentsSample.test.ts +73 -0
  415. package/src/modules/billing/__tests__/lib/pdf/invoicePdf.test.ts +199 -0
  416. package/src/modules/billing/__tests__/lib/pdf/invoicePdfService.test.ts +147 -0
  417. package/src/modules/billing/__tests__/lib/prepaidPeriodClose.test.ts +374 -98
  418. package/src/modules/billing/__tests__/lib/prepaidTaxPoint.test.ts +118 -0
  419. package/src/modules/billing/__tests__/lib/seedsDemo.test.ts +53 -2
  420. package/src/modules/billing/__tests__/lib/sellerSettings.test.ts +28 -0
  421. package/src/modules/billing/__tests__/lib/servicePeriods.test.ts +190 -0
  422. package/src/modules/billing/__tests__/lib/topupCapture.test.ts +6 -28
  423. package/src/modules/billing/__tests__/lib/topupReceipt.test.ts +21 -52
  424. package/src/modules/billing/__tests__/lib/vat.test.ts +51 -0
  425. package/src/modules/billing/__tests__/package-isolation.test.ts +22 -8
  426. package/src/modules/billing/__tests__/setup.test.ts +13 -4
  427. package/src/modules/billing/__tests__/validators.test.ts +193 -3
  428. package/src/modules/billing/acl.ts +12 -0
  429. package/src/modules/billing/api/accounts/[id]/summary/route.ts +62 -0
  430. package/src/modules/billing/api/accounts/route.ts +58 -4
  431. package/src/modules/billing/api/export/account/[id]/route.ts +20 -18
  432. package/src/modules/billing/api/invoices/[id]/memos/route.ts +63 -0
  433. package/src/modules/billing/api/invoices/[id]/pdf/route.ts +79 -0
  434. package/src/modules/billing/api/invoices/[id]/route.ts +57 -70
  435. package/src/modules/billing/api/invoices/[id]/send/route.ts +127 -0
  436. package/src/modules/billing/api/invoices/add-line/route.ts +3 -3
  437. package/src/modules/billing/api/invoices/delete-draft/route.ts +33 -0
  438. package/src/modules/billing/api/invoices/edit-line/route.ts +4 -4
  439. package/src/modules/billing/api/invoices/post/route.ts +7 -6
  440. package/src/modules/billing/api/invoices/remove-line/route.ts +3 -3
  441. package/src/modules/billing/api/invoices/route.ts +81 -86
  442. package/src/modules/billing/api/items/bulk/route.ts +2 -1
  443. package/src/modules/billing/api/items/change-price/route.ts +54 -0
  444. package/src/modules/billing/api/items/route.ts +23 -7
  445. package/src/modules/billing/api/payment-imports/[id]/route.ts +49 -0
  446. package/src/modules/billing/api/payment-imports/route.ts +57 -0
  447. package/src/modules/billing/api/payments/[id]/route.ts +63 -0
  448. package/src/modules/billing/api/payments/allocate/route.ts +35 -0
  449. package/src/modules/billing/api/payments/assign/route.ts +36 -0
  450. package/src/modules/billing/api/payments/convert-to-topup/route.ts +35 -0
  451. package/src/modules/billing/api/payments/ignore/route.ts +35 -0
  452. package/src/modules/billing/api/payments/import/route.ts +72 -0
  453. package/src/modules/billing/api/payments/restore/route.ts +35 -0
  454. package/src/modules/billing/api/payments/route.ts +147 -0
  455. package/src/modules/billing/api/payments/unallocate/route.ts +35 -0
  456. package/src/modules/billing/api/payments/unassign/route.ts +35 -0
  457. package/src/modules/billing/api/run-outcomes/route.ts +50 -7
  458. package/src/modules/billing/api/runs/[id]/post-drafts/route.ts +71 -0
  459. package/src/modules/billing/api/runs/[id]/route.ts +59 -0
  460. package/src/modules/billing/api/runs/retry-failed/route.ts +4 -3
  461. package/src/modules/billing/api/runs/route.ts +17 -9
  462. package/src/modules/billing/api/settings/number-preview/route.ts +46 -0
  463. package/src/modules/billing/api/settings/route.ts +116 -0
  464. package/src/modules/billing/api/statements/route.ts +5 -0
  465. package/src/modules/billing/api/test-invoices/wipe/route.ts +2 -2
  466. package/src/modules/billing/backend/billing/accounts/[id]/page.tsx +151 -372
  467. package/src/modules/billing/backend/billing/accounts/create/page.tsx +6 -0
  468. package/src/modules/billing/backend/billing/accounts/page.tsx +71 -5
  469. package/src/modules/billing/backend/billing/invoices/[id]/page.tsx +445 -96
  470. package/src/modules/billing/backend/billing/invoices/page.tsx +8 -227
  471. package/src/modules/billing/backend/billing/items/[id]/page.tsx +75 -6
  472. package/src/modules/billing/backend/billing/items/create/page.tsx +13 -8
  473. package/src/modules/billing/backend/billing/items/page.tsx +19 -3
  474. package/src/modules/billing/backend/billing/payments/[id]/page.meta.ts +19 -0
  475. package/src/modules/billing/backend/billing/payments/[id]/page.tsx +415 -0
  476. package/src/modules/billing/backend/billing/payments/imports/[id]/page.meta.ts +19 -0
  477. package/src/modules/billing/backend/billing/payments/imports/[id]/page.tsx +106 -0
  478. package/src/modules/billing/backend/billing/payments/page.meta.ts +16 -0
  479. package/src/modules/billing/backend/billing/payments/page.tsx +56 -0
  480. package/src/modules/billing/backend/billing/runs/[id]/page.tsx +50 -19
  481. package/src/modules/billing/backend/billing/runs/page.tsx +60 -9
  482. package/src/modules/billing/backend/billing/statements/[id]/page.tsx +87 -6
  483. package/src/modules/billing/backend/billing/statements/page.tsx +2 -2
  484. package/src/modules/billing/backend/billing/topups/page.tsx +2 -2
  485. package/src/modules/billing/backend/billing/transactions/page.tsx +2 -2
  486. package/src/modules/billing/backend/billing/usage/create/page.tsx +3 -2
  487. package/src/modules/billing/backend/config/billing/page.meta.ts +21 -0
  488. package/src/modules/billing/backend/config/billing/page.tsx +549 -0
  489. package/src/modules/billing/ce.ts +8 -7
  490. package/src/modules/billing/cli.ts +31 -1
  491. package/src/modules/billing/commands/accounts.ts +6 -0
  492. package/src/modules/billing/commands/index.ts +3 -0
  493. package/src/modules/billing/commands/invoices.ts +371 -238
  494. package/src/modules/billing/commands/items.ts +143 -0
  495. package/src/modules/billing/commands/memos.ts +218 -0
  496. package/src/modules/billing/commands/payments.ts +428 -0
  497. package/src/modules/billing/commands/runs.ts +208 -6
  498. package/src/modules/billing/commands/settings.ts +77 -0
  499. package/src/modules/billing/commands/topups.ts +12 -3
  500. package/src/modules/billing/commands/transactions.ts +2 -2
  501. package/src/modules/billing/components/AccountForm.tsx +199 -53
  502. package/src/modules/billing/components/AccountInvoicesSection.tsx +75 -0
  503. package/src/modules/billing/components/AccountPaymentsSection.tsx +42 -0
  504. package/src/modules/billing/components/AccountPicker.tsx +70 -0
  505. package/src/modules/billing/components/AllocatePaymentDialog.tsx +167 -0
  506. package/src/modules/billing/components/BillingDataTable.tsx +34 -0
  507. package/src/modules/billing/components/BillingSettingsLink.tsx +25 -0
  508. package/src/modules/billing/components/ChangeItemPriceDialog.tsx +180 -0
  509. package/src/modules/billing/components/CreateMemoDialog.tsx +232 -0
  510. package/src/modules/billing/components/CustomerLabel.tsx +53 -0
  511. package/src/modules/billing/components/InvoicesTable.tsx +344 -0
  512. package/src/modules/billing/components/ItemForm.tsx +233 -44
  513. package/src/modules/billing/components/ItemPriceField.tsx +81 -0
  514. package/src/modules/billing/components/LineFormDialog.tsx +25 -1
  515. package/src/modules/billing/components/ManualPaymentDialog.tsx +140 -0
  516. package/src/modules/billing/components/MoneyInput.tsx +26 -0
  517. package/src/modules/billing/components/PaymentUploadDialog.tsx +148 -0
  518. package/src/modules/billing/components/PaymentsTable.tsx +213 -0
  519. package/src/modules/billing/components/PostRunDraftsButton.tsx +129 -0
  520. package/src/modules/billing/components/PrepaidPanel.tsx +20 -7
  521. package/src/modules/billing/components/RunCyclesSection.tsx +298 -0
  522. package/src/modules/billing/components/TestRunActions.tsx +152 -0
  523. package/src/modules/billing/components/account/AccountItemsTab.tsx +192 -0
  524. package/src/modules/billing/components/account/AccountRunBillingDialog.tsx +147 -0
  525. package/src/modules/billing/components/account/AccountRunsTab.tsx +201 -0
  526. package/src/modules/billing/components/account/AccountStatementsTab.tsx +120 -0
  527. package/src/modules/billing/components/account/AccountSummaryCards.tsx +153 -0
  528. package/src/modules/billing/components/account/AccountUsageTab.tsx +122 -0
  529. package/src/modules/billing/components/account/AccountView.tsx +101 -0
  530. package/src/modules/billing/components/account/accountRow.ts +70 -0
  531. package/src/modules/billing/components/customerNames.ts +62 -0
  532. package/src/modules/billing/data/entities.ts +685 -15
  533. package/src/modules/billing/data/entityIds.ts +25 -11
  534. package/src/modules/billing/data/validators.ts +388 -8
  535. package/src/modules/billing/events.ts +82 -3
  536. package/src/modules/billing/i18n/en.json +457 -21
  537. package/src/modules/billing/i18n/pl.json +457 -21
  538. package/src/modules/billing/index.ts +6 -2
  539. package/src/modules/billing/lib/accountFinancials.ts +84 -0
  540. package/src/modules/billing/lib/accountLock.ts +32 -0
  541. package/src/modules/billing/lib/accountStatus.ts +11 -9
  542. package/src/modules/billing/lib/accountSummary.ts +172 -0
  543. package/src/modules/billing/lib/allocation.ts +515 -0
  544. package/src/modules/billing/lib/allocationEvents.ts +26 -0
  545. package/src/modules/billing/lib/billPeriod.ts +19 -0
  546. package/src/modules/billing/lib/billRunEngine.ts +362 -162
  547. package/src/modules/billing/lib/billRunLabel.ts +1 -1
  548. package/src/modules/billing/lib/billingSettings.ts +145 -0
  549. package/src/modules/billing/lib/commandRoute.ts +112 -0
  550. package/src/modules/billing/lib/customerLookup.ts +157 -0
  551. package/src/modules/billing/lib/dateOnly.ts +22 -0
  552. package/src/modules/billing/lib/documentParties.ts +23 -0
  553. package/src/modules/billing/lib/documentTypes.ts +37 -0
  554. package/src/modules/billing/lib/dueDate.ts +26 -0
  555. package/src/modules/billing/lib/iban.ts +36 -0
  556. package/src/modules/billing/lib/invoiceDelivery.ts +197 -0
  557. package/src/modules/billing/lib/invoiceLanguages.ts +34 -0
  558. package/src/modules/billing/lib/invoiceWriter.ts +162 -148
  559. package/src/modules/billing/lib/itemBillingState.ts +67 -0
  560. package/src/modules/billing/lib/itemPriceChange.ts +56 -0
  561. package/src/modules/billing/lib/itemSelector.ts +4 -1
  562. package/src/modules/billing/lib/lineAmounts.ts +61 -0
  563. package/src/modules/billing/lib/memoGuards.ts +41 -0
  564. package/src/modules/billing/lib/navigation.ts +64 -0
  565. package/src/modules/billing/lib/numbering.ts +174 -0
  566. package/src/modules/billing/lib/overdue.ts +60 -0
  567. package/src/modules/billing/lib/paymentCsv.ts +171 -0
  568. package/src/modules/billing/lib/paymentGateway.ts +52 -0
  569. package/src/modules/billing/lib/paymentImport.ts +228 -0
  570. package/src/modules/billing/lib/paymentMatcher.ts +88 -0
  571. package/src/modules/billing/lib/pdf/attachmentStore.ts +60 -0
  572. package/src/modules/billing/lib/pdf/fonts/NotoSans-Bold.ttf +0 -0
  573. package/src/modules/billing/lib/pdf/fonts/NotoSans-Regular.ttf +0 -0
  574. package/src/modules/billing/lib/pdf/fonts/OFL.txt +93 -0
  575. package/src/modules/billing/lib/pdf/fonts/embeddedFonts.ts +9 -0
  576. package/src/modules/billing/lib/pdf/invoiceModel.ts +328 -0
  577. package/src/modules/billing/lib/pdf/invoicePdf.ts +216 -0
  578. package/src/modules/billing/lib/pdf/invoiceTemplate.ts +338 -0
  579. package/src/modules/billing/lib/prepaidConfig.ts +27 -36
  580. package/src/modules/billing/lib/prepaidConsume.ts +29 -6
  581. package/src/modules/billing/lib/prepaidPeriodClose.ts +410 -242
  582. package/src/modules/billing/lib/prepaidTaxPoint.ts +76 -0
  583. package/src/modules/billing/lib/seeds/demo.ts +79 -6
  584. package/src/modules/billing/lib/seeds/paymentsSample.ts +136 -0
  585. package/src/modules/billing/lib/seeds/sellerSettings.ts +78 -0
  586. package/src/modules/billing/lib/servicePeriods.ts +226 -0
  587. package/src/modules/billing/lib/tenantLock.ts +1 -1
  588. package/src/modules/billing/lib/testRunCleanup.ts +42 -0
  589. package/src/modules/billing/lib/topupCapture.ts +3 -4
  590. package/src/modules/billing/lib/topupReceipt.ts +70 -103
  591. package/src/modules/billing/lib/usageRater.ts +1 -1
  592. package/src/modules/billing/lib/usageRunner.ts +17 -5
  593. package/src/modules/billing/lib/vat.ts +56 -0
  594. package/src/modules/billing/migrations/Migration20261114000000_billing_customer_kind.ts +25 -0
  595. package/src/modules/billing/migrations/Migration20261114100000_billing_cycle_semantics.ts +37 -0
  596. package/src/modules/billing/migrations/Migration20261115000000_billing_invoice_ledger.ts +132 -0
  597. package/src/modules/billing/migrations/Migration20261116000000_billing_invoice_documents.ts +58 -0
  598. package/src/modules/billing/migrations/Migration20261117000000_billing_payments.ts +97 -0
  599. package/src/modules/billing/migrations/Migration20261118000000_billing_memos.ts +21 -0
  600. package/src/modules/billing/migrations/Migration20261119000000_billing_operator_feedback.ts +39 -0
  601. package/src/modules/billing/migrations/Migration20261120000000_billing_allocation_scope_indexes.ts +35 -0
  602. package/src/modules/billing/setup.ts +11 -237
  603. package/src/modules/billing/subscribers/credit-memo-auto-send.ts +15 -0
  604. package/src/modules/billing/subscribers/debit-memo-apply-credit.ts +15 -0
  605. package/src/modules/billing/subscribers/debit-memo-auto-send.ts +15 -0
  606. package/src/modules/billing/subscribers/invoice-apply-credit.ts +39 -0
  607. package/src/modules/billing/subscribers/invoice-auto-send.ts +46 -0
  608. package/src/modules/billing/subscribers/payment-captured-to-paid.ts +84 -62
  609. package/src/modules/billing/subscribers/prepaid-topup-captured.ts +4 -8
  610. package/src/modules/billing/workers/reap-stale-bill-runs.ts +4 -4
  611. package/dist/modules/billing/lib/invoiceStatus.js +0 -38
  612. package/dist/modules/billing/lib/invoiceStatus.js.map +0 -7
  613. package/src/modules/billing/__tests__/lib/invoiceStatus.test.ts +0 -97
  614. package/src/modules/billing/lib/invoiceStatus.ts +0 -61
@@ -11,18 +11,30 @@ import {
11
11
  SelectValue
12
12
  } from "@open-mercato/ui/primitives/select";
13
13
  import { Switch } from "@open-mercato/ui/primitives/switch";
14
+ import { SegmentedControl, SegmentedControlItem } from "@open-mercato/ui/primitives/segmented-control";
15
+ import { Building2, User } from "lucide-react";
14
16
  import { Kbd, KbdShortcut } from "@open-mercato/ui/primitives/kbd";
15
17
  import { ComboboxInput } from "@open-mercato/ui/backend/inputs";
16
18
  import { apiCall } from "@open-mercato/ui/backend/utils/apiCall";
17
19
  import { useT } from "@open-mercato/shared/lib/i18n/context";
20
+ import {
21
+ applyCustomerPrefill,
22
+ customerEndpoint,
23
+ extractItems,
24
+ mapPrimaryAddress,
25
+ toCustomerSummary
26
+ } from "../lib/customerLookup.js";
27
+ import { DEFAULT_INVOICE_LANGUAGE, SUPPORTED_INVOICE_LANGUAGES } from "../lib/invoiceLanguages.js";
28
+ import { fetchCustomerAddressRows } from "./customerNames.js";
18
29
  const EMPTY_VALUES = {
19
30
  customerId: "",
31
+ customerKind: "company",
20
32
  name: "",
21
33
  currencyCode: "EUR",
22
34
  billCycle: "monthly",
23
35
  billCycleAnchor: "1",
24
36
  invoiceEmail: "",
25
- invoiceLanguage: "en",
37
+ invoiceLanguage: DEFAULT_INVOICE_LANGUAGE,
26
38
  taxId: "",
27
39
  invoiceAddress: {
28
40
  line1: "",
@@ -35,7 +47,9 @@ const EMPTY_VALUES = {
35
47
  isActive: true,
36
48
  billingMode: "postpaid",
37
49
  creditLimit: "0",
38
- lowBalanceThreshold: ""
50
+ lowBalanceThreshold: "",
51
+ paymentTermsDays: "",
52
+ autoSendInvoice: false
39
53
  };
40
54
  function todayIso() {
41
55
  return (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
@@ -63,39 +77,79 @@ function AccountForm({
63
77
  const [values, setValues] = React.useState(() => mergeInitial(initial));
64
78
  const [error, setError] = React.useState(null);
65
79
  const isEdit = mode === "edit";
66
- const customerLabelCacheRef = React.useRef(/* @__PURE__ */ new Map());
80
+ const customerCacheRef = React.useRef(/* @__PURE__ */ new Map());
81
+ const prefilledRef = React.useRef({});
67
82
  const loadCustomerOptions = React.useCallback(
68
83
  async (query) => {
69
84
  const params = new URLSearchParams({ page: "1", pageSize: "20" });
70
85
  const q = (query ?? "").trim();
71
86
  if (q) params.set("search", q);
72
- const call = await apiCall(`/api/customers/companies?${params.toString()}`);
87
+ const call = await apiCall(`${customerEndpoint(values.customerKind)}?${params.toString()}`);
73
88
  if (!call.ok || call.result == null) return [];
74
- const raw = call.result;
75
- const items = Array.isArray(raw) ? raw : Array.isArray(raw.items) ? raw.items : [];
76
89
  const options = [];
77
- for (const c of items) {
78
- const id = typeof c.id === "string" ? c.id : c.id != null ? String(c.id) : "";
79
- if (!id) continue;
80
- const label = String(c.display_name ?? c.displayName ?? c.name ?? id);
81
- const emailRaw = c.primary_email ?? c.email;
82
- const description = typeof emailRaw === "string" && emailRaw ? emailRaw : null;
83
- const opt = { value: id, label, description };
84
- customerLabelCacheRef.current.set(id, opt);
85
- options.push(opt);
90
+ for (const raw of extractItems(call.result)) {
91
+ const summary = toCustomerSummary(raw);
92
+ if (!summary) continue;
93
+ customerCacheRef.current.set(summary.id, summary);
94
+ options.push({ value: summary.id, label: summary.name, description: summary.email });
86
95
  }
87
96
  return options;
88
97
  },
89
- []
98
+ [values.customerKind]
90
99
  );
91
100
  const resolveCustomerLabel = React.useCallback(
92
- (id) => customerLabelCacheRef.current.get(id)?.label ?? id,
101
+ (id) => customerCacheRef.current.get(id)?.name ?? id,
93
102
  []
94
103
  );
95
104
  const resolveCustomerDescription = React.useCallback(
96
- (id) => customerLabelCacheRef.current.get(id)?.description ?? null,
105
+ (id) => customerCacheRef.current.get(id)?.email ?? null,
97
106
  []
98
107
  );
108
+ const withoutUntouchedPrefill = React.useCallback((prev) => {
109
+ const filled = prefilledRef.current;
110
+ let next = prev;
111
+ if (filled.name !== void 0 && prev.name === filled.name) next = { ...next, name: "" };
112
+ if (filled.invoiceEmail !== void 0 && prev.invoiceEmail === filled.invoiceEmail) {
113
+ next = { ...next, invoiceEmail: "" };
114
+ }
115
+ if (filled.address && JSON.stringify(prev.invoiceAddress) === JSON.stringify(filled.address)) {
116
+ next = { ...next, invoiceAddress: { ...EMPTY_VALUES.invoiceAddress } };
117
+ }
118
+ return next;
119
+ }, []);
120
+ const handleKindChange = React.useCallback(
121
+ (next) => {
122
+ const kind = next === "person" ? "person" : "company";
123
+ if (values.customerKind === kind) return;
124
+ const reset = { ...withoutUntouchedPrefill(values), customerKind: kind, customerId: "" };
125
+ prefilledRef.current = {};
126
+ setValues(reset);
127
+ },
128
+ [values, withoutUntouchedPrefill]
129
+ );
130
+ const handleCustomerChange = React.useCallback(
131
+ (customerId) => {
132
+ const summary = customerCacheRef.current.get(customerId) ?? null;
133
+ const base = { ...withoutUntouchedPrefill(values), customerId };
134
+ const filled = applyCustomerPrefill(base, summary, null);
135
+ prefilledRef.current = {
136
+ ...filled.name !== base.name ? { name: filled.name } : {},
137
+ ...filled.invoiceEmail !== base.invoiceEmail ? { invoiceEmail: filled.invoiceEmail } : {}
138
+ };
139
+ setValues(filled);
140
+ if (!customerId) return;
141
+ void fetchCustomerAddressRows(customerId).then((rows) => {
142
+ const address = mapPrimaryAddress(rows);
143
+ if (!address) return;
144
+ setValues((prev) => {
145
+ if (prev.customerId !== customerId) return prev;
146
+ return applyCustomerPrefill(prev, null, address);
147
+ });
148
+ prefilledRef.current = { ...prefilledRef.current, address };
149
+ });
150
+ },
151
+ [values, withoutUntouchedPrefill]
152
+ );
99
153
  const initialKey = React.useMemo(
100
154
  () => JSON.stringify(initial ?? null),
101
155
  [initial]
@@ -166,43 +220,62 @@ function AccountForm({
166
220
  if ((event.metaKey || event.ctrlKey) && event.key === "Enter") {
167
221
  event.preventDefault();
168
222
  void handleSubmit();
223
+ } else if (event.key === "Escape") {
224
+ event.preventDefault();
225
+ onCancel();
169
226
  }
170
227
  },
171
- [handleSubmit]
228
+ [handleSubmit, onCancel]
172
229
  );
173
230
  return /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-border bg-card p-6", onKeyDown: handleKeyDown, children: [
174
231
  /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
232
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1 text-sm col-span-2", children: [
233
+ /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: t("billing.accounts.form.customer_kind", "Customer type") }),
234
+ isEdit ? /* @__PURE__ */ jsxs("span", { className: "inline-flex items-center gap-2", children: [
235
+ values.customerKind === "person" ? /* @__PURE__ */ jsx(User, { size: 16 }) : /* @__PURE__ */ jsx(Building2, { size: 16 }),
236
+ values.customerKind === "person" ? t("billing.accounts.kind.person", "Person") : t("billing.accounts.kind.company", "Company")
237
+ ] }) : /* @__PURE__ */ jsxs(
238
+ SegmentedControl,
239
+ {
240
+ value: values.customerKind,
241
+ onValueChange: handleKindChange,
242
+ "aria-label": t("billing.accounts.form.customer_kind", "Customer type"),
243
+ className: "self-start",
244
+ children: [
245
+ /* @__PURE__ */ jsxs(SegmentedControlItem, { value: "company", children: [
246
+ /* @__PURE__ */ jsx(Building2, { size: 14 }),
247
+ t("billing.accounts.kind.company", "Company")
248
+ ] }),
249
+ /* @__PURE__ */ jsxs(SegmentedControlItem, { value: "person", children: [
250
+ /* @__PURE__ */ jsx(User, { size: 14 }),
251
+ t("billing.accounts.kind.person", "Person")
252
+ ] })
253
+ ]
254
+ }
255
+ )
256
+ ] }),
175
257
  /* @__PURE__ */ jsxs("label", { className: "flex flex-col gap-1 text-sm", children: [
176
258
  /* @__PURE__ */ jsxs("span", { className: "text-muted-foreground", children: [
177
- isEdit ? t("billing.accounts.form.customer_id", "Customer ID") : t("billing.accounts.form.customer", "Customer"),
259
+ isEdit ? t("billing.accounts.form.customer_id", "Customer ID") : values.customerKind === "person" ? t("billing.accounts.form.customer.person", "Person") : t("billing.accounts.form.customer.company", "Company"),
178
260
  !isEdit ? /* @__PURE__ */ jsx("span", { className: "text-destructive", children: " *" }) : null
179
261
  ] }),
180
262
  isEdit ? /* @__PURE__ */ jsx(Input, { value: values.customerId, disabled: true }) : /* @__PURE__ */ jsx(
181
263
  ComboboxInput,
182
264
  {
183
265
  value: values.customerId,
184
- onChange: (next) => {
185
- setValues((prev) => {
186
- const customerLabel = customerLabelCacheRef.current.get(next)?.label ?? "";
187
- const shouldFillName = customerLabel && !prev.name.trim();
188
- return {
189
- ...prev,
190
- customerId: next,
191
- name: shouldFillName ? customerLabel : prev.name
192
- };
193
- });
194
- },
266
+ onChange: handleCustomerChange,
195
267
  loadSuggestions: loadCustomerOptions,
196
268
  resolveLabel: resolveCustomerLabel,
197
269
  resolveDescription: resolveCustomerDescription,
198
- placeholder: t(
199
- "billing.accounts.form.customer.placeholder",
200
- "Search customers by name or email\u2026"
201
- ),
270
+ placeholder: values.customerKind === "person" ? t("billing.accounts.form.customer.placeholder_person", "Search people by name or email\u2026") : t("billing.accounts.form.customer.placeholder", "Search customers by name or email\u2026"),
202
271
  allowCustomValues: false
203
- }
272
+ },
273
+ values.customerKind
204
274
  ),
205
- isEdit ? /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: t("billing.accounts.form.customer_id.locked", "Immutable \u2014 create a new account to re-link the customer.") }) : null
275
+ isEdit ? /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: t("billing.accounts.form.customer_id.locked", "Immutable \u2014 create a new account to re-link the customer.") }) : /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: t(
276
+ "billing.accounts.form.customer.prefill_hint",
277
+ "Name, invoice email and address are prefilled from the customer record when empty."
278
+ ) })
206
279
  ] }),
207
280
  /* @__PURE__ */ jsxs("label", { className: "flex flex-col gap-1 text-sm", children: [
208
281
  /* @__PURE__ */ jsxs("span", { className: "text-muted-foreground", children: [
@@ -296,13 +369,16 @@ function AccountForm({
296
369
  )
297
370
  ] }),
298
371
  /* @__PURE__ */ jsxs("label", { className: "flex flex-col gap-1 text-sm", children: [
299
- /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: t("billing.accounts.form.invoice_language", "Invoice language (ISO 639-1)") }),
300
- /* @__PURE__ */ jsx(
301
- Input,
372
+ /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: t("billing.accounts.form.invoice_language", "Invoice language") }),
373
+ /* @__PURE__ */ jsxs(
374
+ Select,
302
375
  {
303
376
  value: values.invoiceLanguage,
304
- maxLength: 5,
305
- onChange: (event) => set("invoiceLanguage", event.currentTarget.value.toLowerCase())
377
+ onValueChange: (next) => set("invoiceLanguage", next),
378
+ children: [
379
+ /* @__PURE__ */ jsx(SelectTrigger, { children: /* @__PURE__ */ jsx(SelectValue, {}) }),
380
+ /* @__PURE__ */ jsx(SelectContent, { children: SUPPORTED_INVOICE_LANGUAGES.map((language) => /* @__PURE__ */ jsx(SelectItem, { value: language.code, children: language.label }, language.code)) })
381
+ ]
306
382
  }
307
383
  )
308
384
  ] }),
@@ -417,6 +493,37 @@ function AccountForm({
417
493
  }
418
494
  )
419
495
  ] }),
496
+ /* @__PURE__ */ jsxs("label", { className: "flex flex-col gap-1 text-sm", children: [
497
+ /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: t("billing.accounts.form.payment_terms", "Payment terms (days)") }),
498
+ /* @__PURE__ */ jsx(
499
+ Input,
500
+ {
501
+ type: "number",
502
+ min: "0",
503
+ max: "365",
504
+ step: "1",
505
+ value: values.paymentTermsDays,
506
+ placeholder: t("billing.accounts.form.payment_terms.hint", "Blank = organization default"),
507
+ onChange: (event) => set("paymentTermsDays", event.currentTarget.value)
508
+ }
509
+ )
510
+ ] }),
511
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-3 col-span-2", children: [
512
+ /* @__PURE__ */ jsxs("div", { children: [
513
+ /* @__PURE__ */ jsx("div", { className: "text-sm font-medium", children: t("billing.accounts.form.auto_send", "Email invoices automatically") }),
514
+ /* @__PURE__ */ jsx("div", { className: "text-xs text-muted-foreground", children: t(
515
+ "billing.accounts.form.auto_send.help",
516
+ "Each posted invoice is emailed as a PDF to the invoice email."
517
+ ) })
518
+ ] }),
519
+ /* @__PURE__ */ jsx(
520
+ Switch,
521
+ {
522
+ checked: values.autoSendInvoice,
523
+ onCheckedChange: (next) => set("autoSendInvoice", next)
524
+ }
525
+ )
526
+ ] }),
420
527
  values.billingMode === "prepaid" ? /* @__PURE__ */ jsxs("label", { className: "flex flex-col gap-1 text-sm", children: [
421
528
  /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: t("billing.prepaid.panel.threshold", "Low threshold") }),
422
529
  /* @__PURE__ */ jsx(
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/modules/billing/components/AccountForm.tsx"],
4
- "sourcesContent": ["\"use client\"\nimport * as React from 'react'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { Input } from '@open-mercato/ui/primitives/input'\nimport {\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n} from '@open-mercato/ui/primitives/select'\nimport { Switch } from '@open-mercato/ui/primitives/switch'\nimport { Kbd, KbdShortcut } from '@open-mercato/ui/primitives/kbd'\nimport { ComboboxInput, type ComboboxOption } from '@open-mercato/ui/backend/inputs'\nimport { apiCall } from '@open-mercato/ui/backend/utils/apiCall'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\n\n/**\n * Shared form for Billing Account create + edit.\n *\n * Hand-rolled (not CrudForm) on purpose \u2014 the form's `invoiceAddress`\n * jsonb sub-object would need a custom-field renderer in the\n * CrudForm DSL, which is heavier than just rendering five inputs\n * inline. The trade-off is documented in `xd-249-billing-spec.md`\n * Phase 4d notes.\n *\n * UX per the OM UI AGENTS.md:\n * - `Cmd/Ctrl + Enter` submits.\n * - Buttons use the `Button` / `Switch` primitives, never raw HTML.\n * - Footer hint row uses `Kbd` / `KbdShortcut`.\n *\n * `mode='create'` shows the always-required fields. `mode='edit'`\n * disables `customerId` and `currencyCode` per the spec\n * (\"immutable per spec \u2014 create a new account if the customer FK\n * changes\" \u2014 see `billingAccountUpdateSchema`).\n */\n\nexport type AccountFormValues = {\n customerId: string\n name: string\n currencyCode: string\n billCycle: 'weekly' | 'monthly' | 'quarterly' | 'annually'\n billCycleAnchor: string\n invoiceEmail: string\n invoiceLanguage: string\n taxId: string\n invoiceAddress: {\n line1: string\n line2: string\n city: string\n postal_code: string\n country: string\n }\n nextBillDate: string\n isActive: boolean\n // SPEC-002 \u2014 immutable after create (like currencyCode).\n billingMode: 'postpaid' | 'prepaid'\n creditLimit: string\n // Prepaid-only initial low-balance threshold for the balance row.\n lowBalanceThreshold: string\n}\n\nexport type AccountFormProps = {\n mode: 'create' | 'edit'\n initial?: Partial<AccountFormValues>\n submitting?: boolean\n onSubmit: (values: AccountFormValues) => Promise<void> | void\n onCancel: () => void\n}\n\nconst EMPTY_VALUES: AccountFormValues = {\n customerId: '',\n name: '',\n currencyCode: 'EUR',\n billCycle: 'monthly',\n billCycleAnchor: '1',\n invoiceEmail: '',\n invoiceLanguage: 'en',\n taxId: '',\n invoiceAddress: {\n line1: '',\n line2: '',\n city: '',\n postal_code: '',\n country: 'PL',\n },\n nextBillDate: '',\n isActive: true,\n billingMode: 'postpaid',\n creditLimit: '0',\n lowBalanceThreshold: '',\n}\n\nfunction todayIso(): string {\n return new Date().toISOString().slice(0, 10)\n}\n\nfunction mergeInitial(initial: Partial<AccountFormValues> | undefined): AccountFormValues {\n if (!initial) return { ...EMPTY_VALUES, nextBillDate: todayIso() }\n return {\n ...EMPTY_VALUES,\n nextBillDate: EMPTY_VALUES.nextBillDate || todayIso(),\n ...initial,\n invoiceAddress: {\n ...EMPTY_VALUES.invoiceAddress,\n ...(initial.invoiceAddress ?? {}),\n },\n }\n}\n\nexport function AccountForm({\n mode,\n initial,\n submitting = false,\n onSubmit,\n onCancel,\n}: AccountFormProps) {\n const t = useT()\n const [values, setValues] = React.useState<AccountFormValues>(() => mergeInitial(initial))\n const [error, setError] = React.useState<string | null>(null)\n const isEdit = mode === 'edit'\n\n // Label cache for the customer combobox \u2014 populated as the user searches,\n // so the picker can render \"Acme Telecom\" after selection instead of the\n // raw UUID we send to the API.\n const customerLabelCacheRef = React.useRef<Map<string, ComboboxOption>>(new Map())\n\n const loadCustomerOptions = React.useCallback(\n async (query?: string): Promise<ComboboxOption[]> => {\n const params = new URLSearchParams({ page: '1', pageSize: '20' })\n const q = (query ?? '').trim()\n if (q) params.set('search', q)\n const call = await apiCall<unknown>(`/api/customers/companies?${params.toString()}`)\n if (!call.ok || call.result == null) return []\n const raw = call.result as { items?: unknown } | unknown[]\n const items: Array<Record<string, unknown>> = Array.isArray(raw)\n ? (raw as Array<Record<string, unknown>>)\n : Array.isArray((raw as { items?: unknown }).items)\n ? ((raw as { items: unknown[] }).items as Array<Record<string, unknown>>)\n : []\n const options: ComboboxOption[] = []\n for (const c of items) {\n const id = typeof c.id === 'string' ? c.id : c.id != null ? String(c.id) : ''\n if (!id) continue\n const label = String(c.display_name ?? c.displayName ?? c.name ?? id)\n const emailRaw = c.primary_email ?? c.email\n const description = typeof emailRaw === 'string' && emailRaw ? emailRaw : null\n const opt: ComboboxOption = { value: id, label, description }\n customerLabelCacheRef.current.set(id, opt)\n options.push(opt)\n }\n return options\n },\n [],\n )\n\n const resolveCustomerLabel = React.useCallback(\n (id: string) => customerLabelCacheRef.current.get(id)?.label ?? id,\n [],\n )\n const resolveCustomerDescription = React.useCallback(\n (id: string) => customerLabelCacheRef.current.get(id)?.description ?? null,\n [],\n )\n\n // Reset when the parent swaps `initial` (e.g. after loading the edit row).\n const initialKey = React.useMemo(\n () => JSON.stringify(initial ?? null),\n [initial],\n )\n React.useEffect(() => {\n setValues(mergeInitial(initial))\n }, [initialKey, initial])\n\n const set = React.useCallback(\n <K extends keyof AccountFormValues>(key: K, value: AccountFormValues[K]) => {\n setValues((prev) => ({ ...prev, [key]: value }))\n },\n [],\n )\n\n const setAddress = React.useCallback(\n <K extends keyof AccountFormValues['invoiceAddress']>(\n key: K,\n value: AccountFormValues['invoiceAddress'][K],\n ) => {\n setValues((prev) => ({\n ...prev,\n invoiceAddress: { ...prev.invoiceAddress, [key]: value },\n }))\n },\n [],\n )\n\n const handleSubmit = React.useCallback(async () => {\n if (!isEdit && !values.customerId.trim()) {\n setError(t('billing.accounts.form.error.customerId_required', 'Please select a customer'))\n return\n }\n if (!values.name.trim()) {\n setError(t('billing.accounts.form.error.name_required', 'Name is required'))\n return\n }\n if (!isEdit && values.currencyCode.trim().length !== 3) {\n setError(t('billing.accounts.form.error.currency_invalid', 'Currency must be a 3-letter ISO code'))\n return\n }\n if (!values.invoiceEmail.includes('@')) {\n setError(t('billing.accounts.form.error.email_invalid', 'Invoice email looks invalid'))\n return\n }\n if (\n !values.invoiceAddress.line1.trim() ||\n !values.invoiceAddress.city.trim() ||\n !values.invoiceAddress.postal_code.trim()\n ) {\n setError(\n t(\n 'billing.accounts.form.error.address_required',\n 'Invoice address (line 1 + city + postal code) is required',\n ),\n )\n return\n }\n const country = values.invoiceAddress.country.trim()\n if (country.length < 2 || country.length > 3) {\n setError(\n t(\n 'billing.accounts.form.error.country_invalid',\n 'Country must be a 2- or 3-letter ISO 3166 code',\n ),\n )\n return\n }\n if (!values.nextBillDate) {\n setError(t('billing.accounts.form.error.next_bill_date_required', 'Next bill date is required'))\n return\n }\n setError(null)\n await onSubmit(values)\n }, [isEdit, onSubmit, t, values])\n\n const handleKeyDown = React.useCallback(\n (event: React.KeyboardEvent<HTMLDivElement>) => {\n if ((event.metaKey || event.ctrlKey) && event.key === 'Enter') {\n event.preventDefault()\n void handleSubmit()\n }\n },\n [handleSubmit],\n )\n\n return (\n <div className=\"rounded-lg border border-border bg-card p-6\" onKeyDown={handleKeyDown}>\n <div className=\"grid grid-cols-2 gap-4\">\n <label className=\"flex flex-col gap-1 text-sm\">\n <span className=\"text-muted-foreground\">\n {isEdit\n ? t('billing.accounts.form.customer_id', 'Customer ID')\n : t('billing.accounts.form.customer', 'Customer')}\n {!isEdit ? <span className=\"text-destructive\"> *</span> : null}\n </span>\n {isEdit ? (\n <Input value={values.customerId} disabled />\n ) : (\n <ComboboxInput\n value={values.customerId}\n onChange={(next) => {\n setValues((prev) => {\n const customerLabel = customerLabelCacheRef.current.get(next)?.label ?? ''\n // Auto-fill Name with the customer's display name on the first\n // pick. We leave it alone if the operator has already typed\n // something \u2014 one customer can have multiple billing accounts\n // (e.g. \"Acme \u2014 production\" / \"Acme \u2014 staging\").\n const shouldFillName = customerLabel && !prev.name.trim()\n return {\n ...prev,\n customerId: next,\n name: shouldFillName ? customerLabel : prev.name,\n }\n })\n }}\n loadSuggestions={loadCustomerOptions}\n resolveLabel={resolveCustomerLabel}\n resolveDescription={resolveCustomerDescription}\n placeholder={t(\n 'billing.accounts.form.customer.placeholder',\n 'Search customers by name or email\u2026',\n )}\n allowCustomValues={false}\n />\n )}\n {isEdit ? (\n <span className=\"text-xs text-muted-foreground\">\n {t('billing.accounts.form.customer_id.locked', 'Immutable \u2014 create a new account to re-link the customer.')}\n </span>\n ) : null}\n </label>\n\n <label className=\"flex flex-col gap-1 text-sm\">\n <span className=\"text-muted-foreground\">\n {t('billing.accounts.form.name', 'Name')}\n <span className=\"text-destructive\"> *</span>\n </span>\n <Input\n value={values.name}\n placeholder={\n !isEdit\n ? t(\n 'billing.accounts.form.name.placeholder',\n 'Auto-filled from customer \u2014 override e.g. \"Acme \u2014 production\"',\n )\n : undefined\n }\n onChange={(event) => set('name', event.currentTarget.value)}\n />\n </label>\n\n <label className=\"flex flex-col gap-1 text-sm\">\n <span className=\"text-muted-foreground\">\n {t('billing.accounts.form.currency', 'Currency (ISO 4217)')}\n {!isEdit ? <span className=\"text-destructive\"> *</span> : null}\n </span>\n <Input\n value={values.currencyCode}\n disabled={isEdit}\n maxLength={3}\n onChange={(event) =>\n set('currencyCode', event.currentTarget.value.toUpperCase())\n }\n />\n {isEdit ? (\n <span className=\"text-xs text-muted-foreground\">\n {t('billing.accounts.form.currency.locked', 'Immutable \u2014 frozen at account create time.')}\n </span>\n ) : null}\n </label>\n\n <label className=\"flex flex-col gap-1 text-sm\">\n <span className=\"text-muted-foreground\">\n {t('billing.accounts.form.bill_cycle', 'Bill cycle')}\n </span>\n <Select\n value={values.billCycle}\n onValueChange={(next) =>\n set('billCycle', next as AccountFormValues['billCycle'])\n }\n >\n <SelectTrigger>\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n <SelectItem value=\"weekly\">{t('billing.cycle.weekly', 'Weekly')}</SelectItem>\n <SelectItem value=\"monthly\">{t('billing.cycle.monthly', 'Monthly')}</SelectItem>\n <SelectItem value=\"quarterly\">{t('billing.cycle.quarterly', 'Quarterly')}</SelectItem>\n <SelectItem value=\"annually\">{t('billing.cycle.annually', 'Annually')}</SelectItem>\n </SelectContent>\n </Select>\n </label>\n\n <label className=\"flex flex-col gap-1 text-sm\">\n <span className=\"text-muted-foreground\">\n {t('billing.accounts.form.cycle_anchor', 'Cycle anchor')}\n </span>\n <Input\n value={values.billCycleAnchor}\n placeholder={\n values.billCycle === 'weekly'\n ? t('billing.accounts.form.cycle_anchor.weekly_hint', 'mon | tue | \u2026 | sun')\n : t('billing.accounts.form.cycle_anchor.month_hint', '1 \u2014 28')\n }\n onChange={(event) => set('billCycleAnchor', event.currentTarget.value)}\n />\n </label>\n\n <label className=\"flex flex-col gap-1 text-sm\">\n <span className=\"text-muted-foreground\">\n {t('billing.accounts.form.next_bill_date', 'Next bill date')}\n <span className=\"text-destructive\"> *</span>\n </span>\n <Input\n type=\"date\"\n value={values.nextBillDate}\n onChange={(event) => set('nextBillDate', event.currentTarget.value)}\n />\n </label>\n\n <label className=\"flex flex-col gap-1 text-sm\">\n <span className=\"text-muted-foreground\">\n {t('billing.accounts.form.invoice_email', 'Invoice email')}\n <span className=\"text-destructive\"> *</span>\n </span>\n <Input\n type=\"email\"\n value={values.invoiceEmail}\n onChange={(event) => set('invoiceEmail', event.currentTarget.value)}\n />\n </label>\n\n <label className=\"flex flex-col gap-1 text-sm\">\n <span className=\"text-muted-foreground\">\n {t('billing.accounts.form.invoice_language', 'Invoice language (ISO 639-1)')}\n </span>\n <Input\n value={values.invoiceLanguage}\n maxLength={5}\n onChange={(event) =>\n set('invoiceLanguage', event.currentTarget.value.toLowerCase())\n }\n />\n </label>\n\n <label className=\"flex flex-col gap-1 text-sm col-span-2\">\n <span className=\"text-muted-foreground\">\n {t('billing.accounts.form.tax_id', 'Tax ID (NIP / VATIN, optional)')}\n </span>\n <Input\n value={values.taxId}\n onChange={(event) => set('taxId', event.currentTarget.value)}\n />\n </label>\n </div>\n\n <h3 className=\"text-sm font-semibold mt-6 mb-2\">\n {t('billing.accounts.form.address.title', 'Invoice address')}\n </h3>\n <div className=\"grid grid-cols-2 gap-4\">\n <label className=\"flex flex-col gap-1 text-sm col-span-2\">\n <span className=\"text-muted-foreground\">\n {t('billing.accounts.form.address.line1', 'Line 1')}\n <span className=\"text-destructive\"> *</span>\n </span>\n <Input\n value={values.invoiceAddress.line1}\n onChange={(event) => setAddress('line1', event.currentTarget.value)}\n />\n </label>\n <label className=\"flex flex-col gap-1 text-sm col-span-2\">\n <span className=\"text-muted-foreground\">\n {t('billing.accounts.form.address.line2', 'Line 2')}\n </span>\n <Input\n value={values.invoiceAddress.line2}\n onChange={(event) => setAddress('line2', event.currentTarget.value)}\n />\n </label>\n <label className=\"flex flex-col gap-1 text-sm\">\n <span className=\"text-muted-foreground\">\n {t('billing.accounts.form.address.city', 'City')}\n <span className=\"text-destructive\"> *</span>\n </span>\n <Input\n value={values.invoiceAddress.city}\n onChange={(event) => setAddress('city', event.currentTarget.value)}\n />\n </label>\n <label className=\"flex flex-col gap-1 text-sm\">\n <span className=\"text-muted-foreground\">\n {t('billing.accounts.form.address.postal_code', 'Postal code')}\n <span className=\"text-destructive\"> *</span>\n </span>\n <Input\n value={values.invoiceAddress.postal_code}\n onChange={(event) => setAddress('postal_code', event.currentTarget.value)}\n />\n </label>\n <label className=\"flex flex-col gap-1 text-sm\">\n <span className=\"text-muted-foreground\">\n {t('billing.accounts.form.address.country', 'Country (ISO 3166)')}\n <span className=\"text-destructive\"> *</span>\n </span>\n <Input\n value={values.invoiceAddress.country}\n maxLength={3}\n onChange={(event) =>\n setAddress('country', event.currentTarget.value.toUpperCase())\n }\n />\n </label>\n </div>\n\n <h3 className=\"text-sm font-semibold mt-6 mb-2\">\n {t('billing.accounts.form.mode.title', 'Billing mode & credit')}\n </h3>\n <div className=\"grid grid-cols-2 gap-4\">\n <label className=\"flex flex-col gap-1 text-sm\">\n <span className=\"text-muted-foreground\">\n {t('billing.accounts.columns.mode', 'Mode')}\n </span>\n <Select\n value={values.billingMode}\n disabled={isEdit}\n onValueChange={(next) => set('billingMode', next as AccountFormValues['billingMode'])}\n >\n <SelectTrigger>\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n <SelectItem value=\"postpaid\">{t('billing.mode.postpaid', 'Postpaid')}</SelectItem>\n <SelectItem value=\"prepaid\">{t('billing.mode.prepaid', 'Prepaid')}</SelectItem>\n </SelectContent>\n </Select>\n {isEdit ? (\n <span className=\"text-xs text-muted-foreground\">\n {t('billing.accounts.form.mode.locked', 'Immutable \u2014 frozen at account create time.')}\n </span>\n ) : null}\n </label>\n\n <label className=\"flex flex-col gap-1 text-sm\">\n <span className=\"text-muted-foreground\">\n {t('billing.accounts.columns.credit_limit', 'Credit limit')}\n </span>\n <Input\n type=\"number\"\n min=\"0\"\n step=\"0.01\"\n value={values.creditLimit}\n onChange={(event) => set('creditLimit', event.currentTarget.value)}\n />\n </label>\n\n {values.billingMode === 'prepaid' ? (\n <label className=\"flex flex-col gap-1 text-sm\">\n <span className=\"text-muted-foreground\">\n {t('billing.prepaid.panel.threshold', 'Low threshold')}\n </span>\n <Input\n type=\"number\"\n min=\"0\"\n step=\"0.01\"\n value={values.lowBalanceThreshold}\n placeholder={t('billing.accounts.form.threshold.hint', 'Blank = tenant default')}\n onChange={(event) => set('lowBalanceThreshold', event.currentTarget.value)}\n />\n </label>\n ) : null}\n </div>\n\n {isEdit ? (\n <div className=\"mt-6 flex items-center justify-between gap-3\">\n <div>\n <div className=\"text-sm font-medium\">\n {t('billing.accounts.form.active', 'Active')}\n </div>\n <div className=\"text-xs text-muted-foreground\">\n {t(\n 'billing.accounts.form.active.help',\n 'Inactive accounts stay billable until soft-deleted \u2014 toggle for visibility filtering only.',\n )}\n </div>\n </div>\n <Switch\n checked={values.isActive}\n onCheckedChange={(next) => set('isActive', next)}\n />\n </div>\n ) : null}\n\n {error ? <div className=\"mt-4 text-sm text-destructive\">{error}</div> : null}\n\n <div className=\"mt-6 flex items-center justify-between gap-3\">\n <span className=\"text-xs text-muted-foreground\">\n <KbdShortcut keys={['Ctrl/\u2318', 'Enter']} />{' '}\n {t('billing.accounts.form.submit_hint', 'to save,')} <Kbd>Esc</Kbd>{' '}\n {t('billing.accounts.form.cancel_hint', 'to discard')}\n </span>\n <div className=\"flex items-center gap-2\">\n <Button type=\"button\" variant=\"outline\" onClick={onCancel}>\n {t('billing.common.cancel', 'Cancel')}\n </Button>\n <Button type=\"button\" onClick={() => void handleSubmit()} disabled={submitting}>\n {submitting\n ? t('billing.accounts.form.saving', 'Saving\u2026')\n : isEdit\n ? t('billing.accounts.form.save', 'Save changes')\n : t('billing.accounts.form.create', 'Create account')}\n </Button>\n </div>\n </div>\n </div>\n )\n}\n"],
5
- "mappings": ";AAgQU,SAIa,KAJb;AA/PV,YAAY,WAAW;AACvB,SAAS,cAAc;AACvB,SAAS,aAAa;AACtB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,cAAc;AACvB,SAAS,KAAK,mBAAmB;AACjC,SAAS,qBAA0C;AACnD,SAAS,eAAe;AACxB,SAAS,YAAY;AAuDrB,MAAM,eAAkC;AAAA,EACtC,YAAY;AAAA,EACZ,MAAM;AAAA,EACN,cAAc;AAAA,EACd,WAAW;AAAA,EACX,iBAAiB;AAAA,EACjB,cAA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M,CAAC,eAAU,OAAO,GAAG;AAAA,QAAG;AAAA,QAC1C,EAAE,qCAAqC,UAAU;AAAA,QAAE;AAAA,QAAC,oBAAC,OAAI,iBAAG;AAAA,QAAO;AAAA,QACnE,EAAE,qCAAqC,YAAY;AAAA,SACtD;AAAA,MACA,qBAAC,SAAI,WAAU,2BACb;AAAA,4BAAC,UAAO,MAAK,UAAS,SAAQ,WAAU,SAAS,UAC9C,YAAE,yBAAyB,QAAQ,GACtC;AAAA,QACA,oBAAC,UAAO,MAAK,UAAS,SAAS,MAAM,KAAK,aAAa,GAAG,UAAU,YACjE,uBACG,EAAE,gCAAgC,cAAS,IAC3C,SACE,EAAE,8BAA8B,cAAc,IAC9C,EAAE,gCAAgC,gBAAgB,GAC1D;AAAA,SACF;AAAA,OACF;AAAA,KACF;AAEJ;",
4
+ "sourcesContent": ["\"use client\"\nimport * as React from 'react'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { Input } from '@open-mercato/ui/primitives/input'\nimport {\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n} from '@open-mercato/ui/primitives/select'\nimport { Switch } from '@open-mercato/ui/primitives/switch'\nimport { SegmentedControl, SegmentedControlItem } from '@open-mercato/ui/primitives/segmented-control'\nimport { Building2, User } from 'lucide-react'\nimport { Kbd, KbdShortcut } from '@open-mercato/ui/primitives/kbd'\nimport { ComboboxInput, type ComboboxOption } from '@open-mercato/ui/backend/inputs'\nimport { apiCall } from '@open-mercato/ui/backend/utils/apiCall'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport type { CustomerKind } from '../data/validators'\nimport {\n applyCustomerPrefill,\n customerEndpoint,\n extractItems,\n mapPrimaryAddress,\n toCustomerSummary,\n type CustomerSummary,\n type PrefillAddress,\n} from '../lib/customerLookup'\nimport { DEFAULT_INVOICE_LANGUAGE, SUPPORTED_INVOICE_LANGUAGES } from '../lib/invoiceLanguages'\nimport { fetchCustomerAddressRows } from './customerNames'\n\n/**\n * Shared form for Billing Account create + edit.\n *\n * Hand-rolled (not CrudForm) on purpose \u2014 the form's `invoiceAddress`\n * jsonb sub-object would need a custom-field renderer in the\n * CrudForm DSL, which is heavier than just rendering five inputs\n * inline. The trade-off is documented in `xd-249-billing-spec.md`\n * Phase 4d notes.\n *\n * UX per the OM UI AGENTS.md:\n * - `Cmd/Ctrl + Enter` submits.\n * - Buttons use the `Button` / `Switch` primitives, never raw HTML.\n * - Footer hint row uses `Kbd` / `KbdShortcut`.\n *\n * `mode='create'` shows the always-required fields. `mode='edit'`\n * disables `customerId` and `currencyCode` per the spec\n * (\"immutable per spec \u2014 create a new account if the customer FK\n * changes\" \u2014 see `billingAccountUpdateSchema`).\n *\n * Spec E (B2C): the customer can be a company or a person\n * (`customerKind`, immutable after create). Picking a customer prefills\n * name / invoice email / invoice address \u2014 only into empty fields, and a\n * prefill that the operator has not touched is rolled back when they pick a\n * different customer or switch kind.\n */\n\nexport type AccountFormValues = {\n customerId: string\n customerKind: CustomerKind\n name: string\n currencyCode: string\n billCycle: 'weekly' | 'monthly' | 'quarterly' | 'annually'\n billCycleAnchor: string\n invoiceEmail: string\n invoiceLanguage: string\n taxId: string\n invoiceAddress: {\n line1: string\n line2: string\n city: string\n postal_code: string\n country: string\n }\n nextBillDate: string\n isActive: boolean\n // SPEC-002 \u2014 immutable after create (like currencyCode).\n billingMode: 'postpaid' | 'prepaid'\n creditLimit: string\n // Prepaid-only initial low-balance threshold for the balance row.\n lowBalanceThreshold: string\n // Spec B \u2014 blank = organization default terms.\n paymentTermsDays: string\n autoSendInvoice: boolean\n}\n\nexport type AccountFormProps = {\n mode: 'create' | 'edit'\n initial?: Partial<AccountFormValues>\n submitting?: boolean\n onSubmit: (values: AccountFormValues) => Promise<void> | void\n onCancel: () => void\n}\n\nconst EMPTY_VALUES: AccountFormValues = {\n customerId: '',\n customerKind: 'company',\n name: '',\n currencyCode: 'EUR',\n billCycle: 'monthly',\n billCycleAnchor: '1',\n invoiceEmail: '',\n invoiceLanguage: DEFAULT_INVOICE_LANGUAGE,\n taxId: '',\n invoiceAddress: {\n line1: '',\n line2: '',\n city: '',\n postal_code: '',\n country: 'PL',\n },\n nextBillDate: '',\n isActive: true,\n billingMode: 'postpaid',\n creditLimit: '0',\n lowBalanceThreshold: '',\n paymentTermsDays: '',\n autoSendInvoice: false,\n}\n\nfunction todayIso(): string {\n return new Date().toISOString().slice(0, 10)\n}\n\nfunction mergeInitial(initial: Partial<AccountFormValues> | undefined): AccountFormValues {\n if (!initial) return { ...EMPTY_VALUES, nextBillDate: todayIso() }\n return {\n ...EMPTY_VALUES,\n nextBillDate: EMPTY_VALUES.nextBillDate || todayIso(),\n ...initial,\n invoiceAddress: {\n ...EMPTY_VALUES.invoiceAddress,\n ...(initial.invoiceAddress ?? {}),\n },\n }\n}\n\nexport function AccountForm({\n mode,\n initial,\n submitting = false,\n onSubmit,\n onCancel,\n}: AccountFormProps) {\n const t = useT()\n const [values, setValues] = React.useState<AccountFormValues>(() => mergeInitial(initial))\n const [error, setError] = React.useState<string | null>(null)\n const isEdit = mode === 'edit'\n\n // Customer cache for the combobox \u2014 populated as the user searches, so the\n // picker can render \"Acme Telecom\" after selection instead of the raw UUID\n // we send to the API, and so prefill has the name + email at hand.\n const customerCacheRef = React.useRef<Map<string, CustomerSummary>>(new Map())\n // What the last prefill wrote \u2014 used to roll it back (only where the\n // operator has not edited it since) when the customer or kind changes.\n const prefilledRef = React.useRef<{ name?: string; invoiceEmail?: string; address?: PrefillAddress }>({})\n\n const loadCustomerOptions = React.useCallback(\n async (query?: string): Promise<ComboboxOption[]> => {\n const params = new URLSearchParams({ page: '1', pageSize: '20' })\n const q = (query ?? '').trim()\n if (q) params.set('search', q)\n const call = await apiCall<unknown>(`${customerEndpoint(values.customerKind)}?${params.toString()}`)\n if (!call.ok || call.result == null) return []\n const options: ComboboxOption[] = []\n for (const raw of extractItems(call.result)) {\n const summary = toCustomerSummary(raw)\n if (!summary) continue\n customerCacheRef.current.set(summary.id, summary)\n options.push({ value: summary.id, label: summary.name, description: summary.email })\n }\n return options\n },\n [values.customerKind],\n )\n\n const resolveCustomerLabel = React.useCallback(\n (id: string) => customerCacheRef.current.get(id)?.name ?? id,\n [],\n )\n const resolveCustomerDescription = React.useCallback(\n (id: string) => customerCacheRef.current.get(id)?.email ?? null,\n [],\n )\n\n // Pure: strip fields that still hold the last prefill (untouched by the\n // operator). Kept free of side effects so it is safe inside state updaters.\n const withoutUntouchedPrefill = React.useCallback((prev: AccountFormValues): AccountFormValues => {\n const filled = prefilledRef.current\n let next = prev\n if (filled.name !== undefined && prev.name === filled.name) next = { ...next, name: '' }\n if (filled.invoiceEmail !== undefined && prev.invoiceEmail === filled.invoiceEmail) {\n next = { ...next, invoiceEmail: '' }\n }\n if (filled.address && JSON.stringify(prev.invoiceAddress) === JSON.stringify(filled.address)) {\n next = { ...next, invoiceAddress: { ...EMPTY_VALUES.invoiceAddress } }\n }\n return next\n }, [])\n\n const handleKindChange = React.useCallback(\n (next: string) => {\n const kind: CustomerKind = next === 'person' ? 'person' : 'company'\n if (values.customerKind === kind) return\n const reset = { ...withoutUntouchedPrefill(values), customerKind: kind, customerId: '' }\n prefilledRef.current = {}\n setValues(reset)\n },\n [values, withoutUntouchedPrefill],\n )\n\n const handleCustomerChange = React.useCallback(\n (customerId: string) => {\n const summary = customerCacheRef.current.get(customerId) ?? null\n const base = { ...withoutUntouchedPrefill(values), customerId }\n const filled = applyCustomerPrefill(base, summary, null)\n prefilledRef.current = {\n ...(filled.name !== base.name ? { name: filled.name } : {}),\n ...(filled.invoiceEmail !== base.invoiceEmail ? { invoiceEmail: filled.invoiceEmail } : {}),\n }\n setValues(filled)\n if (!customerId) return\n void fetchCustomerAddressRows(customerId).then((rows) => {\n const address = mapPrimaryAddress(rows)\n if (!address) return\n setValues((prev) => {\n // Ignore a late response for a customer the operator already left.\n if (prev.customerId !== customerId) return prev\n return applyCustomerPrefill(prev, null, address)\n })\n // Record what we wrote; harmless if the updater above skipped (the\n // rollback compares values, so a non-matching address is kept).\n prefilledRef.current = { ...prefilledRef.current, address }\n })\n },\n [values, withoutUntouchedPrefill],\n )\n\n // Reset when the parent swaps `initial` (e.g. after loading the edit row).\n const initialKey = React.useMemo(\n () => JSON.stringify(initial ?? null),\n [initial],\n )\n React.useEffect(() => {\n setValues(mergeInitial(initial))\n }, [initialKey, initial])\n\n const set = React.useCallback(\n <K extends keyof AccountFormValues>(key: K, value: AccountFormValues[K]) => {\n setValues((prev) => ({ ...prev, [key]: value }))\n },\n [],\n )\n\n const setAddress = React.useCallback(\n <K extends keyof AccountFormValues['invoiceAddress']>(\n key: K,\n value: AccountFormValues['invoiceAddress'][K],\n ) => {\n setValues((prev) => ({\n ...prev,\n invoiceAddress: { ...prev.invoiceAddress, [key]: value },\n }))\n },\n [],\n )\n\n const handleSubmit = React.useCallback(async () => {\n if (!isEdit && !values.customerId.trim()) {\n setError(t('billing.accounts.form.error.customerId_required', 'Please select a customer'))\n return\n }\n if (!values.name.trim()) {\n setError(t('billing.accounts.form.error.name_required', 'Name is required'))\n return\n }\n if (!isEdit && values.currencyCode.trim().length !== 3) {\n setError(t('billing.accounts.form.error.currency_invalid', 'Currency must be a 3-letter ISO code'))\n return\n }\n if (!values.invoiceEmail.includes('@')) {\n setError(t('billing.accounts.form.error.email_invalid', 'Invoice email looks invalid'))\n return\n }\n if (\n !values.invoiceAddress.line1.trim() ||\n !values.invoiceAddress.city.trim() ||\n !values.invoiceAddress.postal_code.trim()\n ) {\n setError(\n t(\n 'billing.accounts.form.error.address_required',\n 'Invoice address (line 1 + city + postal code) is required',\n ),\n )\n return\n }\n const country = values.invoiceAddress.country.trim()\n if (country.length < 2 || country.length > 3) {\n setError(\n t(\n 'billing.accounts.form.error.country_invalid',\n 'Country must be a 2- or 3-letter ISO 3166 code',\n ),\n )\n return\n }\n if (!values.nextBillDate) {\n setError(t('billing.accounts.form.error.next_bill_date_required', 'Next bill date is required'))\n return\n }\n setError(null)\n await onSubmit(values)\n }, [isEdit, onSubmit, t, values])\n\n const handleKeyDown = React.useCallback(\n (event: React.KeyboardEvent<HTMLDivElement>) => {\n if ((event.metaKey || event.ctrlKey) && event.key === 'Enter') {\n event.preventDefault()\n void handleSubmit()\n } else if (event.key === 'Escape') {\n event.preventDefault()\n onCancel()\n }\n },\n [handleSubmit, onCancel],\n )\n\n return (\n <div className=\"rounded-lg border border-border bg-card p-6\" onKeyDown={handleKeyDown}>\n <div className=\"grid grid-cols-2 gap-4\">\n <div className=\"flex flex-col gap-1 text-sm col-span-2\">\n <span className=\"text-muted-foreground\">\n {t('billing.accounts.form.customer_kind', 'Customer type')}\n </span>\n {isEdit ? (\n <span className=\"inline-flex items-center gap-2\">\n {values.customerKind === 'person' ? <User size={16} /> : <Building2 size={16} />}\n {values.customerKind === 'person'\n ? t('billing.accounts.kind.person', 'Person')\n : t('billing.accounts.kind.company', 'Company')}\n </span>\n ) : (\n <SegmentedControl\n value={values.customerKind}\n onValueChange={handleKindChange}\n aria-label={t('billing.accounts.form.customer_kind', 'Customer type')}\n className=\"self-start\"\n >\n <SegmentedControlItem value=\"company\">\n <Building2 size={14} />\n {t('billing.accounts.kind.company', 'Company')}\n </SegmentedControlItem>\n <SegmentedControlItem value=\"person\">\n <User size={14} />\n {t('billing.accounts.kind.person', 'Person')}\n </SegmentedControlItem>\n </SegmentedControl>\n )}\n </div>\n\n <label className=\"flex flex-col gap-1 text-sm\">\n <span className=\"text-muted-foreground\">\n {isEdit\n ? t('billing.accounts.form.customer_id', 'Customer ID')\n : values.customerKind === 'person'\n ? t('billing.accounts.form.customer.person', 'Person')\n : t('billing.accounts.form.customer.company', 'Company')}\n {!isEdit ? <span className=\"text-destructive\"> *</span> : null}\n </span>\n {isEdit ? (\n <Input value={values.customerId} disabled />\n ) : (\n <ComboboxInput\n // Re-mount on kind switch so cached suggestions from the other\n // collection never leak into this one.\n key={values.customerKind}\n value={values.customerId}\n onChange={handleCustomerChange}\n loadSuggestions={loadCustomerOptions}\n resolveLabel={resolveCustomerLabel}\n resolveDescription={resolveCustomerDescription}\n placeholder={\n values.customerKind === 'person'\n ? t('billing.accounts.form.customer.placeholder_person', 'Search people by name or email\u2026')\n : t('billing.accounts.form.customer.placeholder', 'Search customers by name or email\u2026')\n }\n allowCustomValues={false}\n />\n )}\n {isEdit ? (\n <span className=\"text-xs text-muted-foreground\">\n {t('billing.accounts.form.customer_id.locked', 'Immutable \u2014 create a new account to re-link the customer.')}\n </span>\n ) : (\n <span className=\"text-xs text-muted-foreground\">\n {t(\n 'billing.accounts.form.customer.prefill_hint',\n 'Name, invoice email and address are prefilled from the customer record when empty.',\n )}\n </span>\n )}\n </label>\n\n <label className=\"flex flex-col gap-1 text-sm\">\n <span className=\"text-muted-foreground\">\n {t('billing.accounts.form.name', 'Name')}\n <span className=\"text-destructive\"> *</span>\n </span>\n <Input\n value={values.name}\n placeholder={\n !isEdit\n ? t(\n 'billing.accounts.form.name.placeholder',\n 'Auto-filled from customer \u2014 override e.g. \"Acme \u2014 production\"',\n )\n : undefined\n }\n onChange={(event) => set('name', event.currentTarget.value)}\n />\n </label>\n\n <label className=\"flex flex-col gap-1 text-sm\">\n <span className=\"text-muted-foreground\">\n {t('billing.accounts.form.currency', 'Currency (ISO 4217)')}\n {!isEdit ? <span className=\"text-destructive\"> *</span> : null}\n </span>\n <Input\n value={values.currencyCode}\n disabled={isEdit}\n maxLength={3}\n onChange={(event) =>\n set('currencyCode', event.currentTarget.value.toUpperCase())\n }\n />\n {isEdit ? (\n <span className=\"text-xs text-muted-foreground\">\n {t('billing.accounts.form.currency.locked', 'Immutable \u2014 frozen at account create time.')}\n </span>\n ) : null}\n </label>\n\n <label className=\"flex flex-col gap-1 text-sm\">\n <span className=\"text-muted-foreground\">\n {t('billing.accounts.form.bill_cycle', 'Bill cycle')}\n </span>\n <Select\n value={values.billCycle}\n onValueChange={(next) =>\n set('billCycle', next as AccountFormValues['billCycle'])\n }\n >\n <SelectTrigger>\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n <SelectItem value=\"weekly\">{t('billing.cycle.weekly', 'Weekly')}</SelectItem>\n <SelectItem value=\"monthly\">{t('billing.cycle.monthly', 'Monthly')}</SelectItem>\n <SelectItem value=\"quarterly\">{t('billing.cycle.quarterly', 'Quarterly')}</SelectItem>\n <SelectItem value=\"annually\">{t('billing.cycle.annually', 'Annually')}</SelectItem>\n </SelectContent>\n </Select>\n </label>\n\n <label className=\"flex flex-col gap-1 text-sm\">\n <span className=\"text-muted-foreground\">\n {t('billing.accounts.form.cycle_anchor', 'Cycle anchor')}\n </span>\n <Input\n value={values.billCycleAnchor}\n placeholder={\n values.billCycle === 'weekly'\n ? t('billing.accounts.form.cycle_anchor.weekly_hint', 'mon | tue | \u2026 | sun')\n : t('billing.accounts.form.cycle_anchor.month_hint', '1 \u2014 28')\n }\n onChange={(event) => set('billCycleAnchor', event.currentTarget.value)}\n />\n </label>\n\n <label className=\"flex flex-col gap-1 text-sm\">\n <span className=\"text-muted-foreground\">\n {t('billing.accounts.form.next_bill_date', 'Next bill date')}\n <span className=\"text-destructive\"> *</span>\n </span>\n <Input\n type=\"date\"\n value={values.nextBillDate}\n onChange={(event) => set('nextBillDate', event.currentTarget.value)}\n />\n </label>\n\n <label className=\"flex flex-col gap-1 text-sm\">\n <span className=\"text-muted-foreground\">\n {t('billing.accounts.form.invoice_email', 'Invoice email')}\n <span className=\"text-destructive\"> *</span>\n </span>\n <Input\n type=\"email\"\n value={values.invoiceEmail}\n onChange={(event) => set('invoiceEmail', event.currentTarget.value)}\n />\n </label>\n\n <label className=\"flex flex-col gap-1 text-sm\">\n <span className=\"text-muted-foreground\">\n {t('billing.accounts.form.invoice_language', 'Invoice language')}\n </span>\n <Select\n value={values.invoiceLanguage}\n onValueChange={(next) => set('invoiceLanguage', next)}\n >\n <SelectTrigger>\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n {SUPPORTED_INVOICE_LANGUAGES.map((language) => (\n <SelectItem key={language.code} value={language.code}>\n {language.label}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </label>\n\n <label className=\"flex flex-col gap-1 text-sm col-span-2\">\n <span className=\"text-muted-foreground\">\n {t('billing.accounts.form.tax_id', 'Tax ID (NIP / VATIN, optional)')}\n </span>\n <Input\n value={values.taxId}\n onChange={(event) => set('taxId', event.currentTarget.value)}\n />\n </label>\n </div>\n\n <h3 className=\"text-sm font-semibold mt-6 mb-2\">\n {t('billing.accounts.form.address.title', 'Invoice address')}\n </h3>\n <div className=\"grid grid-cols-2 gap-4\">\n <label className=\"flex flex-col gap-1 text-sm col-span-2\">\n <span className=\"text-muted-foreground\">\n {t('billing.accounts.form.address.line1', 'Line 1')}\n <span className=\"text-destructive\"> *</span>\n </span>\n <Input\n value={values.invoiceAddress.line1}\n onChange={(event) => setAddress('line1', event.currentTarget.value)}\n />\n </label>\n <label className=\"flex flex-col gap-1 text-sm col-span-2\">\n <span className=\"text-muted-foreground\">\n {t('billing.accounts.form.address.line2', 'Line 2')}\n </span>\n <Input\n value={values.invoiceAddress.line2}\n onChange={(event) => setAddress('line2', event.currentTarget.value)}\n />\n </label>\n <label className=\"flex flex-col gap-1 text-sm\">\n <span className=\"text-muted-foreground\">\n {t('billing.accounts.form.address.city', 'City')}\n <span className=\"text-destructive\"> *</span>\n </span>\n <Input\n value={values.invoiceAddress.city}\n onChange={(event) => setAddress('city', event.currentTarget.value)}\n />\n </label>\n <label className=\"flex flex-col gap-1 text-sm\">\n <span className=\"text-muted-foreground\">\n {t('billing.accounts.form.address.postal_code', 'Postal code')}\n <span className=\"text-destructive\"> *</span>\n </span>\n <Input\n value={values.invoiceAddress.postal_code}\n onChange={(event) => setAddress('postal_code', event.currentTarget.value)}\n />\n </label>\n <label className=\"flex flex-col gap-1 text-sm\">\n <span className=\"text-muted-foreground\">\n {t('billing.accounts.form.address.country', 'Country (ISO 3166)')}\n <span className=\"text-destructive\"> *</span>\n </span>\n <Input\n value={values.invoiceAddress.country}\n maxLength={3}\n onChange={(event) =>\n setAddress('country', event.currentTarget.value.toUpperCase())\n }\n />\n </label>\n </div>\n\n <h3 className=\"text-sm font-semibold mt-6 mb-2\">\n {t('billing.accounts.form.mode.title', 'Billing mode & credit')}\n </h3>\n <div className=\"grid grid-cols-2 gap-4\">\n <label className=\"flex flex-col gap-1 text-sm\">\n <span className=\"text-muted-foreground\">\n {t('billing.accounts.columns.mode', 'Mode')}\n </span>\n <Select\n value={values.billingMode}\n disabled={isEdit}\n onValueChange={(next) => set('billingMode', next as AccountFormValues['billingMode'])}\n >\n <SelectTrigger>\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n <SelectItem value=\"postpaid\">{t('billing.mode.postpaid', 'Postpaid')}</SelectItem>\n <SelectItem value=\"prepaid\">{t('billing.mode.prepaid', 'Prepaid')}</SelectItem>\n </SelectContent>\n </Select>\n {isEdit ? (\n <span className=\"text-xs text-muted-foreground\">\n {t('billing.accounts.form.mode.locked', 'Immutable \u2014 frozen at account create time.')}\n </span>\n ) : null}\n </label>\n\n <label className=\"flex flex-col gap-1 text-sm\">\n <span className=\"text-muted-foreground\">\n {t('billing.accounts.columns.credit_limit', 'Credit limit')}\n </span>\n <Input\n type=\"number\"\n min=\"0\"\n step=\"0.01\"\n value={values.creditLimit}\n onChange={(event) => set('creditLimit', event.currentTarget.value)}\n />\n </label>\n\n <label className=\"flex flex-col gap-1 text-sm\">\n <span className=\"text-muted-foreground\">\n {t('billing.accounts.form.payment_terms', 'Payment terms (days)')}\n </span>\n <Input\n type=\"number\"\n min=\"0\"\n max=\"365\"\n step=\"1\"\n value={values.paymentTermsDays}\n placeholder={t('billing.accounts.form.payment_terms.hint', 'Blank = organization default')}\n onChange={(event) => set('paymentTermsDays', event.currentTarget.value)}\n />\n </label>\n\n <div className=\"flex items-center justify-between gap-3 col-span-2\">\n <div>\n <div className=\"text-sm font-medium\">\n {t('billing.accounts.form.auto_send', 'Email invoices automatically')}\n </div>\n <div className=\"text-xs text-muted-foreground\">\n {t(\n 'billing.accounts.form.auto_send.help',\n 'Each posted invoice is emailed as a PDF to the invoice email.',\n )}\n </div>\n </div>\n <Switch\n checked={values.autoSendInvoice}\n onCheckedChange={(next) => set('autoSendInvoice', next)}\n />\n </div>\n\n {values.billingMode === 'prepaid' ? (\n <label className=\"flex flex-col gap-1 text-sm\">\n <span className=\"text-muted-foreground\">\n {t('billing.prepaid.panel.threshold', 'Low threshold')}\n </span>\n <Input\n type=\"number\"\n min=\"0\"\n step=\"0.01\"\n value={values.lowBalanceThreshold}\n placeholder={t('billing.accounts.form.threshold.hint', 'Blank = tenant default')}\n onChange={(event) => set('lowBalanceThreshold', event.currentTarget.value)}\n />\n </label>\n ) : null}\n </div>\n\n {isEdit ? (\n <div className=\"mt-6 flex items-center justify-between gap-3\">\n <div>\n <div className=\"text-sm font-medium\">\n {t('billing.accounts.form.active', 'Active')}\n </div>\n <div className=\"text-xs text-muted-foreground\">\n {t(\n 'billing.accounts.form.active.help',\n 'Inactive accounts stay billable until soft-deleted \u2014 toggle for visibility filtering only.',\n )}\n </div>\n </div>\n <Switch\n checked={values.isActive}\n onCheckedChange={(next) => set('isActive', next)}\n />\n </div>\n ) : null}\n\n {error ? <div className=\"mt-4 text-sm text-destructive\">{error}</div> : null}\n\n <div className=\"mt-6 flex items-center justify-between gap-3\">\n <span className=\"text-xs text-muted-foreground\">\n <KbdShortcut keys={['Ctrl/\u2318', 'Enter']} />{' '}\n {t('billing.accounts.form.submit_hint', 'to save,')} <Kbd>Esc</Kbd>{' '}\n {t('billing.accounts.form.cancel_hint', 'to discard')}\n </span>\n <div className=\"flex items-center gap-2\">\n <Button type=\"button\" variant=\"outline\" onClick={onCancel}>\n {t('billing.common.cancel', 'Cancel')}\n </Button>\n <Button type=\"button\" onClick={() => void handleSubmit()} disabled={submitting}>\n {submitting\n ? t('billing.accounts.form.saving', 'Saving\u2026')\n : isEdit\n ? t('billing.accounts.form.save', 'Save changes')\n : t('billing.accounts.form.create', 'Create account')}\n </Button>\n </div>\n </div>\n </div>\n )\n}\n"],
5
+ "mappings": ";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AO,MAAK,UAAS,SAAQ,WAAU,SAAS,UAC9C,YAAE,yBAAyB,QAAQ,GACtC;AAAA,QACA,oBAAC,UAAO,MAAK,UAAS,SAAS,MAAM,KAAK,aAAa,GAAG,UAAU,YACjE,uBACG,EAAE,gCAAgC,cAAS,IAC3C,SACE,EAAE,8BAA8B,cAAc,IAC9C,EAAE,gCAAgC,gBAAgB,GAC1D;AAAA,SACF;AAAA,OACF;AAAA,KACF;AAEJ;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,64 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import * as React from "react";
4
+ import { useT } from "@open-mercato/shared/lib/i18n/context";
5
+ import { readApiResultOrThrow } from "@open-mercato/ui/backend/utils/apiCall";
6
+ import { Stat, StatCard } from "./DetailFields.js";
7
+ import { InvoicesTable, formatMoney } from "./InvoicesTable.js";
8
+ function AccountInvoicesSection({
9
+ accountId,
10
+ showSummary = true
11
+ }) {
12
+ const t = useT();
13
+ const [summary, setSummary] = React.useState(null);
14
+ React.useEffect(() => {
15
+ if (!showSummary) return;
16
+ let cancelled = false;
17
+ readApiResultOrThrow(`/api/billing/accounts/${encodeURIComponent(accountId)}/summary`).then((result) => {
18
+ if (!cancelled) setSummary(result);
19
+ }).catch(() => {
20
+ if (!cancelled) setSummary(null);
21
+ });
22
+ return () => {
23
+ cancelled = true;
24
+ };
25
+ }, [accountId, showSummary]);
26
+ return /* @__PURE__ */ jsxs("div", { className: showSummary ? "mt-6 space-y-3" : "space-y-3", children: [
27
+ showSummary && summary ? /* @__PURE__ */ jsxs(StatCard, { children: [
28
+ /* @__PURE__ */ jsx(
29
+ Stat,
30
+ {
31
+ label: t("billing.accounts.summary.open", "Open receivables"),
32
+ value: formatMoney(summary.open_amount, summary.currency_code)
33
+ }
34
+ ),
35
+ /* @__PURE__ */ jsx(
36
+ Stat,
37
+ {
38
+ label: t("billing.accounts.summary.overdue", "Overdue"),
39
+ value: `${formatMoney(summary.overdue_amount, summary.currency_code)} (${summary.overdue_count})`
40
+ }
41
+ ),
42
+ /* @__PURE__ */ jsx(
43
+ Stat,
44
+ {
45
+ label: t("billing.accounts.summary.credit", "Unapplied credit"),
46
+ value: formatMoney(summary.credit_amount, summary.currency_code)
47
+ }
48
+ )
49
+ ] }) : null,
50
+ /* @__PURE__ */ jsx(
51
+ InvoicesTable,
52
+ {
53
+ title: t("billing.accounts.detail.invoices", "Invoices"),
54
+ billAccountId: accountId,
55
+ tableId: "billing-account-invoices",
56
+ pageSize: 10
57
+ }
58
+ )
59
+ ] });
60
+ }
61
+ export {
62
+ AccountInvoicesSection
63
+ };
64
+ //# sourceMappingURL=AccountInvoicesSection.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/modules/billing/components/AccountInvoicesSection.tsx"],
4
+ "sourcesContent": ["\"use client\"\nimport * as React from 'react'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport { readApiResultOrThrow } from '@open-mercato/ui/backend/utils/apiCall'\nimport { Stat, StatCard } from './DetailFields'\nimport { InvoicesTable, formatMoney } from './InvoicesTable'\n\n/**\n * Account Invoices section (Spec B): receivables summary cards + the\n * account's billing documents. Self-contained so Spec E's account workspace\n * can drop it into its Invoices tab unchanged.\n */\n\ntype AccountSummary = {\n currency_code: string\n open_amount: string\n overdue_amount: string\n overdue_count: number\n credit_amount: string\n}\n\nexport function AccountInvoicesSection({\n accountId,\n showSummary = true,\n}: {\n accountId: string\n /** False inside the account workspace, whose header already shows these figures. */\n showSummary?: boolean\n}) {\n const t = useT()\n const [summary, setSummary] = React.useState<AccountSummary | null>(null)\n\n React.useEffect(() => {\n if (!showSummary) return\n let cancelled = false\n readApiResultOrThrow<AccountSummary>(`/api/billing/accounts/${encodeURIComponent(accountId)}/summary`)\n .then((result) => {\n if (!cancelled) setSummary(result)\n })\n .catch(() => {\n // Summary is informational; the invoices table reports its own errors.\n if (!cancelled) setSummary(null)\n })\n return () => {\n cancelled = true\n }\n }, [accountId, showSummary])\n\n return (\n <div className={showSummary ? 'mt-6 space-y-3' : 'space-y-3'}>\n {showSummary && summary ? (\n <StatCard>\n <Stat\n label={t('billing.accounts.summary.open', 'Open receivables')}\n value={formatMoney(summary.open_amount, summary.currency_code)}\n />\n <Stat\n label={t('billing.accounts.summary.overdue', 'Overdue')}\n value={`${formatMoney(summary.overdue_amount, summary.currency_code)} (${summary.overdue_count})`}\n />\n <Stat\n label={t('billing.accounts.summary.credit', 'Unapplied credit')}\n value={formatMoney(summary.credit_amount, summary.currency_code)}\n />\n </StatCard>\n ) : null}\n <InvoicesTable\n title={t('billing.accounts.detail.invoices', 'Invoices')}\n billAccountId={accountId}\n tableId=\"billing-account-invoices\"\n pageSize={10}\n />\n </div>\n )\n}\n"],
5
+ "mappings": ";AAmDQ,SACE,KADF;AAlDR,YAAY,WAAW;AACvB,SAAS,YAAY;AACrB,SAAS,4BAA4B;AACrC,SAAS,MAAM,gBAAgB;AAC/B,SAAS,eAAe,mBAAmB;AAgBpC,SAAS,uBAAuB;AAAA,EACrC;AAAA,EACA,cAAc;AAChB,GAIG;AACD,QAAM,IAAI,KAAK;AACf,QAAM,CAAC,SAAS,UAAU,IAAI,MAAM,SAAgC,IAAI;AAExE,QAAM,UAAU,MAAM;AACpB,QAAI,CAAC,YAAa;AAClB,QAAI,YAAY;AAChB,yBAAqC,yBAAyB,mBAAmB,SAAS,CAAC,UAAU,EAClG,KAAK,CAAC,WAAW;AAChB,UAAI,CAAC,UAAW,YAAW,MAAM;AAAA,IACnC,CAAC,EACA,MAAM,MAAM;AAEX,UAAI,CAAC,UAAW,YAAW,IAAI;AAAA,IACjC,CAAC;AACH,WAAO,MAAM;AACX,kBAAY;AAAA,IACd;AAAA,EACF,GAAG,CAAC,WAAW,WAAW,CAAC;AAE3B,SACE,qBAAC,SAAI,WAAW,cAAc,mBAAmB,aAC9C;AAAA,mBAAe,UACd,qBAAC,YACC;AAAA;AAAA,QAAC;AAAA;AAAA,UACC,OAAO,EAAE,iCAAiC,kBAAkB;AAAA,UAC5D,OAAO,YAAY,QAAQ,aAAa,QAAQ,aAAa;AAAA;AAAA,MAC/D;AAAA,MACA;AAAA,QAAC;AAAA;AAAA,UACC,OAAO,EAAE,oCAAoC,SAAS;AAAA,UACtD,OAAO,GAAG,YAAY,QAAQ,gBAAgB,QAAQ,aAAa,CAAC,KAAK,QAAQ,aAAa;AAAA;AAAA,MAChG;AAAA,MACA;AAAA,QAAC;AAAA;AAAA,UACC,OAAO,EAAE,mCAAmC,kBAAkB;AAAA,UAC9D,OAAO,YAAY,QAAQ,eAAe,QAAQ,aAAa;AAAA;AAAA,MACjE;AAAA,OACF,IACE;AAAA,IACJ;AAAA,MAAC;AAAA;AAAA,QACC,OAAO,EAAE,oCAAoC,UAAU;AAAA,QACvD,eAAe;AAAA,QACf,SAAQ;AAAA,QACR,UAAU;AAAA;AAAA,IACZ;AAAA,KACF;AAEJ;",
6
+ "names": []
7
+ }
@@ -0,0 +1,43 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import * as React from "react";
4
+ import { useRouter } from "next/navigation";
5
+ import { Plus } from "lucide-react";
6
+ import { useT } from "@open-mercato/shared/lib/i18n/context";
7
+ import { Button } from "@open-mercato/ui/primitives/button";
8
+ import { PaymentsTable } from "./PaymentsTable.js";
9
+ import { ManualPaymentDialog } from "./ManualPaymentDialog.js";
10
+ function AccountPaymentsSection({ accountId, currencyCode }) {
11
+ const t = useT();
12
+ const router = useRouter();
13
+ const [open, setOpen] = React.useState(false);
14
+ return /* @__PURE__ */ jsxs("div", { className: "mt-6", children: [
15
+ /* @__PURE__ */ jsx(
16
+ PaymentsTable,
17
+ {
18
+ title: t("billing.accounts.detail.payments", "Payments"),
19
+ tableId: "billing-account-payments",
20
+ billAccountId: accountId,
21
+ pageSize: 10,
22
+ actions: /* @__PURE__ */ jsxs(Button, { type: "button", variant: "outline", onClick: () => setOpen(true), children: [
23
+ /* @__PURE__ */ jsx(Plus, { size: 16 }),
24
+ t("billing.payments.manual.action", "Record payment")
25
+ ] })
26
+ }
27
+ ),
28
+ /* @__PURE__ */ jsx(
29
+ ManualPaymentDialog,
30
+ {
31
+ open,
32
+ onClose: () => setOpen(false),
33
+ billAccountId: accountId,
34
+ currencyCode,
35
+ onCreated: (paymentId) => router.push(`/backend/billing/payments/${encodeURIComponent(paymentId)}`)
36
+ }
37
+ )
38
+ ] });
39
+ }
40
+ export {
41
+ AccountPaymentsSection
42
+ };
43
+ //# sourceMappingURL=AccountPaymentsSection.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/modules/billing/components/AccountPaymentsSection.tsx"],
4
+ "sourcesContent": ["\"use client\"\nimport * as React from 'react'\nimport { useRouter } from 'next/navigation'\nimport { Plus } from 'lucide-react'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { PaymentsTable } from './PaymentsTable'\nimport { ManualPaymentDialog } from './ManualPaymentDialog'\n\n/**\n * Account Payments section (Spec C): the account's payments plus \"Record\n * payment\" (pre-filled account and currency). Self-contained so Spec E's\n * Payments tab can reuse it.\n */\nexport function AccountPaymentsSection({ accountId, currencyCode }: { accountId: string; currencyCode: string }) {\n const t = useT()\n const router = useRouter()\n const [open, setOpen] = React.useState(false)\n return (\n <div className=\"mt-6\">\n <PaymentsTable\n title={t('billing.accounts.detail.payments', 'Payments')}\n tableId=\"billing-account-payments\"\n billAccountId={accountId}\n pageSize={10}\n actions={\n <Button type=\"button\" variant=\"outline\" onClick={() => setOpen(true)}>\n <Plus size={16} />\n {t('billing.payments.manual.action', 'Record payment')}\n </Button>\n }\n />\n <ManualPaymentDialog\n open={open}\n onClose={() => setOpen(false)}\n billAccountId={accountId}\n currencyCode={currencyCode}\n onCreated={(paymentId) => router.push(`/backend/billing/payments/${encodeURIComponent(paymentId)}`)}\n />\n </div>\n )\n}\n"],
5
+ "mappings": ";AA0BU,SACE,KADF;AAzBV,YAAY,WAAW;AACvB,SAAS,iBAAiB;AAC1B,SAAS,YAAY;AACrB,SAAS,YAAY;AACrB,SAAS,cAAc;AACvB,SAAS,qBAAqB;AAC9B,SAAS,2BAA2B;AAO7B,SAAS,uBAAuB,EAAE,WAAW,aAAa,GAAgD;AAC/G,QAAM,IAAI,KAAK;AACf,QAAM,SAAS,UAAU;AACzB,QAAM,CAAC,MAAM,OAAO,IAAI,MAAM,SAAS,KAAK;AAC5C,SACE,qBAAC,SAAI,WAAU,QACb;AAAA;AAAA,MAAC;AAAA;AAAA,QACC,OAAO,EAAE,oCAAoC,UAAU;AAAA,QACvD,SAAQ;AAAA,QACR,eAAe;AAAA,QACf,UAAU;AAAA,QACV,SACE,qBAAC,UAAO,MAAK,UAAS,SAAQ,WAAU,SAAS,MAAM,QAAQ,IAAI,GACjE;AAAA,8BAAC,QAAK,MAAM,IAAI;AAAA,UACf,EAAE,kCAAkC,gBAAgB;AAAA,WACvD;AAAA;AAAA,IAEJ;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA,SAAS,MAAM,QAAQ,KAAK;AAAA,QAC5B,eAAe;AAAA,QACf;AAAA,QACA,WAAW,CAAC,cAAc,OAAO,KAAK,6BAA6B,mBAAmB,SAAS,CAAC,EAAE;AAAA;AAAA,IACpG;AAAA,KACF;AAEJ;",
6
+ "names": []
7
+ }