@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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/modules/billing/components/LineFormDialog.tsx"],
4
- "sourcesContent": ["\"use client\"\nimport * as React from 'react'\nimport {\n Dialog,\n DialogContent,\n DialogDescription,\n DialogFooter,\n DialogHeader,\n DialogTitle,\n} from '@open-mercato/ui/primitives/dialog'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { Input } from '@open-mercato/ui/primitives/input'\nimport { Textarea } from '@open-mercato/ui/primitives/textarea'\nimport { Kbd, KbdShortcut } from '@open-mercato/ui/primitives/kbd'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\n\n/**\n * Shared dialog for add / edit of an invoice line.\n *\n * - `mode='add'` shows empty fields and calls the\n * `billing.invoices.add_draft_line` route on submit.\n * - `mode='edit'` pre-fills from `initial` and calls\n * `billing.invoices.edit_draft_line`.\n *\n * The caller owns the network call (so we can stay simple and avoid\n * threading apiCall context through the component). On submit, this\n * dialog only emits `onSubmit(values)` and the parent decides which\n * command to hit.\n *\n * UX conventions per `@open-mercato/ui`:\n * - `Cmd/Ctrl + Enter` submits.\n * - `Escape` cancels (Radix Dialog handles this for free).\n * - Hint row at the bottom lists both shortcuts via `Kbd` /\n * `KbdShortcut` (not raw `<span>`).\n */\n\nexport type LineFormValues = {\n description: string\n quantity: number\n unitPriceNet: number\n /** Optional explicit total override (operator \"I know better\" path). */\n totalNetAmount?: number\n}\n\nexport type LineFormDialogProps = {\n open: boolean\n mode: 'add' | 'edit'\n /** Pre-fill values for edit mode. */\n initial?: Partial<LineFormValues>\n submitting?: boolean\n onSubmit: (values: LineFormValues) => Promise<void> | void\n onCancel: () => void\n}\n\nfunction toNumber(raw: string): number | null {\n if (raw.trim() === '') return null\n const n = Number.parseFloat(raw)\n return Number.isFinite(n) ? n : null\n}\n\nexport function LineFormDialog({\n open,\n mode,\n initial,\n submitting = false,\n onSubmit,\n onCancel,\n}: LineFormDialogProps) {\n const t = useT()\n const [description, setDescription] = React.useState(initial?.description ?? '')\n const [quantity, setQuantity] = React.useState(\n initial?.quantity != null ? String(initial.quantity) : '',\n )\n const [unitPriceNet, setUnitPriceNet] = React.useState(\n initial?.unitPriceNet != null ? String(initial.unitPriceNet) : '',\n )\n const [totalOverride, setTotalOverride] = React.useState(\n initial?.totalNetAmount != null ? String(initial.totalNetAmount) : '',\n )\n const [error, setError] = React.useState<string | null>(null)\n\n React.useEffect(() => {\n if (open) {\n setDescription(initial?.description ?? '')\n setQuantity(initial?.quantity != null ? String(initial.quantity) : '')\n setUnitPriceNet(initial?.unitPriceNet != null ? String(initial.unitPriceNet) : '')\n setTotalOverride(initial?.totalNetAmount != null ? String(initial.totalNetAmount) : '')\n setError(null)\n }\n }, [open, initial])\n\n const handleSubmit = React.useCallback(async () => {\n const trimmedDescription = description.trim()\n if (!trimmedDescription) {\n setError(t('billing.invoices.lines.form.error.description_required', 'Description is required'))\n return\n }\n const quantityValue = toNumber(quantity)\n if (quantityValue == null || quantityValue < 0) {\n setError(t('billing.invoices.lines.form.error.quantity_invalid', 'Quantity must be a non-negative number'))\n return\n }\n const unitPriceValue = toNumber(unitPriceNet)\n if (unitPriceValue == null) {\n setError(t('billing.invoices.lines.form.error.unit_price_invalid', 'Unit price must be a number'))\n return\n }\n const totalOverrideRaw = totalOverride.trim()\n let totalOverrideValue: number | undefined\n if (totalOverrideRaw !== '') {\n const parsed = toNumber(totalOverrideRaw)\n if (parsed == null) {\n setError(t('billing.invoices.lines.form.error.total_invalid', 'Total override must be a number when set'))\n return\n }\n totalOverrideValue = parsed\n }\n setError(null)\n await onSubmit({\n description: trimmedDescription,\n quantity: quantityValue,\n unitPriceNet: unitPriceValue,\n totalNetAmount: totalOverrideValue,\n })\n }, [description, onSubmit, quantity, t, totalOverride, unitPriceNet])\n\n const handleKeyDown = React.useCallback(\n (event: React.KeyboardEvent<HTMLDivElement>) => {\n // Cmd/Ctrl + Enter submits \u2014 required by the OM UX convention\n // for every dialog. Escape is handled by Radix Dialog itself.\n if ((event.metaKey || event.ctrlKey) && event.key === 'Enter') {\n event.preventDefault()\n void handleSubmit()\n }\n },\n [handleSubmit],\n )\n\n // Auto-compute total for the helper text \u2014 purely informational, not\n // submitted unless the operator types into `totalOverride`.\n const computedTotal = React.useMemo(() => {\n const q = toNumber(quantity)\n const u = toNumber(unitPriceNet)\n if (q == null || u == null) return null\n return (Math.round(q * u * 100) / 100).toFixed(2)\n }, [quantity, unitPriceNet])\n\n return (\n <Dialog open={open} onOpenChange={(next) => { if (!next) onCancel() }}>\n <DialogContent onKeyDown={handleKeyDown}>\n <DialogHeader>\n <DialogTitle>\n {mode === 'add'\n ? t('billing.invoices.lines.form.title_add', 'Add invoice line')\n : t('billing.invoices.lines.form.title_edit', 'Edit invoice line')}\n </DialogTitle>\n <DialogDescription>\n {t(\n 'billing.invoices.lines.form.help',\n 'Changes are recorded in the draft-edit audit log.',\n )}\n </DialogDescription>\n </DialogHeader>\n <div className=\"flex flex-col gap-4 py-2\">\n <label className=\"flex flex-col gap-1 text-sm\">\n <span className=\"text-muted-foreground\">\n {t('billing.invoices.lines.form.description', 'Description')}\n </span>\n <Textarea\n value={description}\n onChange={(event) => setDescription(event.currentTarget.value)}\n rows={2}\n />\n </label>\n <div className=\"grid grid-cols-2 gap-3\">\n <label className=\"flex flex-col gap-1 text-sm\">\n <span className=\"text-muted-foreground\">\n {t('billing.invoices.lines.form.quantity', 'Quantity')}\n </span>\n <Input\n type=\"number\"\n value={quantity}\n step=\"0.0001\"\n onChange={(event) => setQuantity(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.invoices.lines.form.unit_price', 'Unit price (net)')}\n </span>\n <Input\n type=\"number\"\n value={unitPriceNet}\n step=\"0.0001\"\n onChange={(event) => setUnitPriceNet(event.currentTarget.value)}\n />\n </label>\n </div>\n <label className=\"flex flex-col gap-1 text-sm\">\n <span className=\"text-muted-foreground\">\n {t('billing.invoices.lines.form.total_override', 'Total override (optional)')}\n </span>\n <Input\n type=\"number\"\n value={totalOverride}\n step=\"0.0001\"\n placeholder={computedTotal ?? ''}\n onChange={(event) => setTotalOverride(event.currentTarget.value)}\n />\n <span className=\"text-xs text-muted-foreground\">\n {computedTotal != null\n ? t(\n 'billing.invoices.lines.form.computed_total',\n 'Computed total: {computed}',\n ).replace('{computed}', computedTotal)\n : null}\n </span>\n </label>\n {error ? (\n <div className=\"text-sm text-destructive\">{error}</div>\n ) : null}\n </div>\n <DialogFooter>\n <div className=\"flex items-center justify-between gap-3 w-full\">\n <span className=\"text-xs text-muted-foreground\">\n <KbdShortcut keys={['Ctrl/\u2318', 'Enter']} />\n {' '}\n {t('billing.invoices.lines.form.submit_hint', 'to save,')}\n {' '}\n <Kbd>Esc</Kbd>\n {' '}\n {t('billing.invoices.lines.form.cancel_hint', 'to cancel')}\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\n type=\"button\"\n onClick={() => void handleSubmit()}\n disabled={submitting}\n >\n {submitting\n ? t('billing.invoices.lines.form.saving', 'Saving\u2026')\n : t('billing.common.save', 'Save')}\n </Button>\n </div>\n </div>\n </DialogFooter>\n </DialogContent>\n </Dialog>\n )\n}\n"],
5
- "mappings": ";AAsJQ,SACE,KADF;AArJR,YAAY,WAAW;AACvB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,cAAc;AACvB,SAAS,aAAa;AACtB,SAAS,gBAAgB;AACzB,SAAS,KAAK,mBAAmB;AACjC,SAAS,YAAY;AAwCrB,SAAS,SAAS,KAA4B;AAC5C,MAAI,IAAI,KAAK,MAAM,GAAI,QAAO;AAC9B,QAAM,IAAI,OAAO,WAAW,GAAG;AAC/B,SAAO,OAAO,SAAS,CAAC,IAAI,IAAI;AAClC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QAAQ,cAAc,aAAa,IACrC,MACN;AAAA,SACF;AAAA,MACC,QACC,oBAAC,SAAI,WAAU,4BAA4B,iBAAM,IAC/C;AAAA,OACN;AAAA,IACA,oBAAC,gBACC,+BAAC,SAAI,WAAU,kDACb;AAAA,2BAAC,UAAK,WAAU,iCACd;AAAA,4BAAC,eAAY,MAAM,CAAC,eAAU,OAAO,GAAG;AAAA,QACvC;AAAA,QACA,EAAE,2CAA2C,UAAU;AAAA,QACvD;AAAA,QACD,oBAAC,OAAI,iBAAG;AAAA,QACP;AAAA,QACA,EAAE,2CAA2C,WAAW;AAAA,SAC3D;AAAA,MACA,qBAAC,SAAI,WAAU,2BACb;AAAA,4BAAC,UAAO,MAAK,UAAS,SAAQ,WAAU,SAAS,UAC9C,YAAE,yBAAyB,QAAQ,GACtC;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YACC,MAAK;AAAA,YACL,SAAS,MAAM,KAAK,aAAa;AAAA,YACjC,UAAU;AAAA,YAET,uBACG,EAAE,sCAAsC,cAAS,IACjD,EAAE,uBAAuB,MAAM;AAAA;AAAA,QACrC;AAAA,SACF;AAAA,OACF,GACF;AAAA,KACF,GACF;AAEJ;",
4
+ "sourcesContent": ["\"use client\"\nimport * as React from 'react'\nimport {\n Dialog,\n DialogContent,\n DialogDescription,\n DialogFooter,\n DialogHeader,\n DialogTitle,\n} from '@open-mercato/ui/primitives/dialog'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { Input } from '@open-mercato/ui/primitives/input'\nimport { Textarea } from '@open-mercato/ui/primitives/textarea'\nimport { Kbd, KbdShortcut } from '@open-mercato/ui/primitives/kbd'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\n\n/**\n * Shared dialog for add / edit of an invoice line.\n *\n * - `mode='add'` shows empty fields and calls the\n * `billing.invoices.add_draft_line` route on submit.\n * - `mode='edit'` pre-fills from `initial` and calls\n * `billing.invoices.edit_draft_line`.\n *\n * The caller owns the network call (so we can stay simple and avoid\n * threading apiCall context through the component). On submit, this\n * dialog only emits `onSubmit(values)` and the parent decides which\n * command to hit.\n *\n * UX conventions per `@open-mercato/ui`:\n * - `Cmd/Ctrl + Enter` submits.\n * - `Escape` cancels (Radix Dialog handles this for free).\n * - Hint row at the bottom lists both shortcuts via `Kbd` /\n * `KbdShortcut` (not raw `<span>`).\n */\n\nexport type LineFormValues = {\n description: string\n quantity: number\n unitPriceNet: number\n /** Optional explicit total override (operator \"I know better\" path). */\n totalNetAmount?: number\n /** Spec B: VAT %. Omitted on add \u2192 the organization default rate. */\n taxRate?: number\n}\n\nexport type LineFormDialogProps = {\n open: boolean\n mode: 'add' | 'edit'\n /** Pre-fill values for edit mode. */\n initial?: Partial<LineFormValues>\n submitting?: boolean\n onSubmit: (values: LineFormValues) => Promise<void> | void\n onCancel: () => void\n}\n\nfunction toNumber(raw: string): number | null {\n if (raw.trim() === '') return null\n const n = Number.parseFloat(raw)\n return Number.isFinite(n) ? n : null\n}\n\nexport function LineFormDialog({\n open,\n mode,\n initial,\n submitting = false,\n onSubmit,\n onCancel,\n}: LineFormDialogProps) {\n const t = useT()\n const [description, setDescription] = React.useState(initial?.description ?? '')\n const [quantity, setQuantity] = React.useState(\n initial?.quantity != null ? String(initial.quantity) : '',\n )\n const [unitPriceNet, setUnitPriceNet] = React.useState(\n initial?.unitPriceNet != null ? String(initial.unitPriceNet) : '',\n )\n const [totalOverride, setTotalOverride] = React.useState(\n initial?.totalNetAmount != null ? String(initial.totalNetAmount) : '',\n )\n const [taxRate, setTaxRate] = React.useState(initial?.taxRate != null ? String(initial.taxRate) : '')\n const [error, setError] = React.useState<string | null>(null)\n\n React.useEffect(() => {\n if (open) {\n setDescription(initial?.description ?? '')\n setQuantity(initial?.quantity != null ? String(initial.quantity) : '')\n setUnitPriceNet(initial?.unitPriceNet != null ? String(initial.unitPriceNet) : '')\n setTotalOverride(initial?.totalNetAmount != null ? String(initial.totalNetAmount) : '')\n setTaxRate(initial?.taxRate != null ? String(initial.taxRate) : '')\n setError(null)\n }\n }, [open, initial])\n\n const handleSubmit = React.useCallback(async () => {\n const trimmedDescription = description.trim()\n if (!trimmedDescription) {\n setError(t('billing.invoices.lines.form.error.description_required', 'Description is required'))\n return\n }\n const quantityValue = toNumber(quantity)\n if (quantityValue == null || quantityValue < 0) {\n setError(t('billing.invoices.lines.form.error.quantity_invalid', 'Quantity must be a non-negative number'))\n return\n }\n const unitPriceValue = toNumber(unitPriceNet)\n if (unitPriceValue == null) {\n setError(t('billing.invoices.lines.form.error.unit_price_invalid', 'Unit price must be a number'))\n return\n }\n const totalOverrideRaw = totalOverride.trim()\n let totalOverrideValue: number | undefined\n if (totalOverrideRaw !== '') {\n const parsed = toNumber(totalOverrideRaw)\n if (parsed == null) {\n setError(t('billing.invoices.lines.form.error.total_invalid', 'Total override must be a number when set'))\n return\n }\n totalOverrideValue = parsed\n }\n const taxRateValue = toNumber(taxRate)\n if (taxRate.trim() !== '' && (taxRateValue == null || taxRateValue < 0 || taxRateValue > 100)) {\n setError(t('billing.invoices.lines.form.error.tax_rate_invalid', 'VAT rate must be between 0 and 100'))\n return\n }\n setError(null)\n await onSubmit({\n description: trimmedDescription,\n quantity: quantityValue,\n unitPriceNet: unitPriceValue,\n totalNetAmount: totalOverrideValue,\n taxRate: taxRateValue ?? undefined,\n })\n }, [description, onSubmit, quantity, t, taxRate, totalOverride, unitPriceNet])\n\n const handleKeyDown = React.useCallback(\n (event: React.KeyboardEvent<HTMLDivElement>) => {\n // Cmd/Ctrl + Enter submits \u2014 required by the OM UX convention\n // for every dialog. Escape is handled by Radix Dialog itself.\n if ((event.metaKey || event.ctrlKey) && event.key === 'Enter') {\n event.preventDefault()\n void handleSubmit()\n }\n },\n [handleSubmit],\n )\n\n // Auto-compute total for the helper text \u2014 purely informational, not\n // submitted unless the operator types into `totalOverride`.\n const computedTotal = React.useMemo(() => {\n const q = toNumber(quantity)\n const u = toNumber(unitPriceNet)\n if (q == null || u == null) return null\n return (Math.round(q * u * 100) / 100).toFixed(2)\n }, [quantity, unitPriceNet])\n\n return (\n <Dialog open={open} onOpenChange={(next) => { if (!next) onCancel() }}>\n <DialogContent onKeyDown={handleKeyDown}>\n <DialogHeader>\n <DialogTitle>\n {mode === 'add'\n ? t('billing.invoices.lines.form.title_add', 'Add invoice line')\n : t('billing.invoices.lines.form.title_edit', 'Edit invoice line')}\n </DialogTitle>\n <DialogDescription>\n {t(\n 'billing.invoices.lines.form.help',\n 'Changes are recorded in the draft-edit audit log.',\n )}\n </DialogDescription>\n </DialogHeader>\n <div className=\"flex flex-col gap-4 py-2\">\n <label className=\"flex flex-col gap-1 text-sm\">\n <span className=\"text-muted-foreground\">\n {t('billing.invoices.lines.form.description', 'Description')}\n </span>\n <Textarea\n value={description}\n onChange={(event) => setDescription(event.currentTarget.value)}\n rows={2}\n />\n </label>\n <div className=\"grid grid-cols-2 gap-3\">\n <label className=\"flex flex-col gap-1 text-sm\">\n <span className=\"text-muted-foreground\">\n {t('billing.invoices.lines.form.quantity', 'Quantity')}\n </span>\n <Input\n type=\"number\"\n value={quantity}\n step=\"0.0001\"\n onChange={(event) => setQuantity(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.invoices.lines.form.unit_price', 'Unit price (net)')}\n </span>\n <Input\n type=\"number\"\n value={unitPriceNet}\n step=\"0.0001\"\n onChange={(event) => setUnitPriceNet(event.currentTarget.value)}\n />\n </label>\n </div>\n <label className=\"flex flex-col gap-1 text-sm\">\n <span className=\"text-muted-foreground\">\n {t('billing.invoices.lines.form.tax_rate', 'VAT rate (%)')}\n </span>\n <Input\n type=\"number\"\n value={taxRate}\n min=\"0\"\n max=\"100\"\n step=\"0.01\"\n placeholder={mode === 'add' ? t('billing.invoices.lines.form.tax_rate.default', 'Organization default') : ''}\n onChange={(event) => setTaxRate(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.invoices.lines.form.total_override', 'Total override (optional)')}\n </span>\n <Input\n type=\"number\"\n value={totalOverride}\n step=\"0.0001\"\n placeholder={computedTotal ?? ''}\n onChange={(event) => setTotalOverride(event.currentTarget.value)}\n />\n <span className=\"text-xs text-muted-foreground\">\n {computedTotal != null\n ? t(\n 'billing.invoices.lines.form.computed_total',\n 'Computed total: {computed}',\n ).replace('{computed}', computedTotal)\n : null}\n </span>\n </label>\n {error ? (\n <div className=\"text-sm text-destructive\">{error}</div>\n ) : null}\n </div>\n <DialogFooter>\n <div className=\"flex items-center justify-between gap-3 w-full\">\n <span className=\"text-xs text-muted-foreground\">\n <KbdShortcut keys={['Ctrl/\u2318', 'Enter']} />\n {' '}\n {t('billing.invoices.lines.form.submit_hint', 'to save,')}\n {' '}\n <Kbd>Esc</Kbd>\n {' '}\n {t('billing.invoices.lines.form.cancel_hint', 'to cancel')}\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\n type=\"button\"\n onClick={() => void handleSubmit()}\n disabled={submitting}\n >\n {submitting\n ? t('billing.invoices.lines.form.saving', 'Saving\u2026')\n : t('billing.common.save', 'Save')}\n </Button>\n </div>\n </div>\n </DialogFooter>\n </DialogContent>\n </Dialog>\n )\n}\n"],
5
+ "mappings": ";AAgKQ,SACE,KADF;AA/JR,YAAY,WAAW;AACvB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,cAAc;AACvB,SAAS,aAAa;AACtB,SAAS,gBAAgB;AACzB,SAAS,KAAK,mBAAmB;AACjC,SAAS,YAAY;AA0CrB,SAAS,SAAS,KAA4B;AAC5C,MAAI,IAAI,KAAK,MAAM,GAAI,QAAO;AAC9B,QAAM,IAAI,OAAO,WAAW,GAAG;AAC/B,SAAO,OAAO,SAAS,CAAC,IAAI,IAAI;AAClC;AAEO,SAAS,eAA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A,YACC,MAAK;AAAA,YACL,SAAS,MAAM,KAAK,aAAa;AAAA,YACjC,UAAU;AAAA,YAET,uBACG,EAAE,sCAAsC,cAAS,IACjD,EAAE,uBAAuB,MAAM;AAAA;AAAA,QACrC;AAAA,SACF;AAAA,OACF,GACF;AAAA,KACF,GACF;AAEJ;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,122 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import * as React from "react";
4
+ import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle } from "@open-mercato/ui/primitives/dialog";
5
+ import { Button } from "@open-mercato/ui/primitives/button";
6
+ import { Input } from "@open-mercato/ui/primitives/input";
7
+ import { Kbd, KbdShortcut } from "@open-mercato/ui/primitives/kbd";
8
+ import { useT } from "@open-mercato/shared/lib/i18n/context";
9
+ import { apiCallOrThrow } from "@open-mercato/ui/backend/utils/apiCall";
10
+ import { normalizeCrudServerError } from "@open-mercato/ui/backend/utils/serverErrors";
11
+ import { flash } from "@open-mercato/ui/backend/FlashMessages";
12
+ import { AccountPicker } from "./AccountPicker.js";
13
+ function ManualPaymentDialog({
14
+ open,
15
+ onClose,
16
+ onCreated,
17
+ billAccountId,
18
+ currencyCode
19
+ }) {
20
+ const t = useT();
21
+ const today = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
22
+ const [receivedAt, setReceivedAt] = React.useState(today);
23
+ const [amount, setAmount] = React.useState("");
24
+ const [currency, setCurrency] = React.useState(currencyCode ?? "PLN");
25
+ const [reference, setReference] = React.useState("");
26
+ const [payerName, setPayerName] = React.useState("");
27
+ const [accountId, setAccountId] = React.useState(billAccountId ?? "");
28
+ const [saving, setSaving] = React.useState(false);
29
+ React.useEffect(() => {
30
+ if (!open) return;
31
+ setReceivedAt((/* @__PURE__ */ new Date()).toISOString().slice(0, 10));
32
+ setAmount("");
33
+ setReference("");
34
+ setPayerName("");
35
+ setAccountId(billAccountId ?? "");
36
+ setCurrency(currencyCode ?? "PLN");
37
+ }, [billAccountId, currencyCode, open]);
38
+ const submit = React.useCallback(async () => {
39
+ const value = Number.parseFloat(amount);
40
+ if (!(value > 0) || saving) {
41
+ flash(t("billing.payments.manual.amount_invalid", "Amount must be greater than 0"), "error");
42
+ return;
43
+ }
44
+ setSaving(true);
45
+ try {
46
+ const call = await apiCallOrThrow("/api/billing/payments", {
47
+ method: "POST",
48
+ headers: { "Content-Type": "application/json" },
49
+ body: JSON.stringify({
50
+ receivedAt,
51
+ amount: value,
52
+ currencyCode: currency.trim().toUpperCase(),
53
+ ...reference.trim() ? { reference: reference.trim() } : {},
54
+ ...payerName.trim() ? { payerName: payerName.trim() } : {},
55
+ ...accountId ? { billAccountId: accountId } : {}
56
+ })
57
+ });
58
+ flash(t("billing.payments.manual.saved", "Payment recorded"), "success");
59
+ onClose();
60
+ if (call.result?.paymentId) onCreated(call.result.paymentId);
61
+ } catch (err) {
62
+ flash(normalizeCrudServerError(err).message || t("billing.payments.manual.failed", "Could not record the payment"), "error");
63
+ } finally {
64
+ setSaving(false);
65
+ }
66
+ }, [accountId, amount, currency, onClose, onCreated, payerName, receivedAt, reference, saving, t]);
67
+ return /* @__PURE__ */ jsx(Dialog, { open, onOpenChange: (next) => !next ? onClose() : void 0, children: /* @__PURE__ */ jsxs(
68
+ DialogContent,
69
+ {
70
+ onKeyDown: (event) => {
71
+ if ((event.metaKey || event.ctrlKey) && event.key === "Enter") {
72
+ event.preventDefault();
73
+ void submit();
74
+ }
75
+ },
76
+ children: [
77
+ /* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsx(DialogTitle, { children: t("billing.payments.manual.title", "Record payment") }) }),
78
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-3 py-2 text-sm", children: [
79
+ /* @__PURE__ */ jsxs("label", { className: "flex flex-col gap-1", children: [
80
+ /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: t("billing.payments.columns.received", "Received") }),
81
+ /* @__PURE__ */ jsx(Input, { type: "date", value: receivedAt, onChange: (e) => setReceivedAt(e.currentTarget.value) })
82
+ ] }),
83
+ /* @__PURE__ */ jsxs("label", { className: "flex flex-col gap-1", children: [
84
+ /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: t("billing.payments.columns.amount", "Amount") }),
85
+ /* @__PURE__ */ jsx(Input, { type: "number", min: "0", step: "0.01", value: amount, onChange: (e) => setAmount(e.currentTarget.value) })
86
+ ] }),
87
+ /* @__PURE__ */ jsxs("label", { className: "flex flex-col gap-1", children: [
88
+ /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: t("billing.payments.fields.currency", "Currency") }),
89
+ /* @__PURE__ */ jsx(Input, { value: currency, maxLength: 3, disabled: Boolean(currencyCode), onChange: (e) => setCurrency(e.currentTarget.value) })
90
+ ] }),
91
+ /* @__PURE__ */ jsxs("label", { className: "flex flex-col gap-1", children: [
92
+ /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: t("billing.payments.columns.payer", "Payer") }),
93
+ /* @__PURE__ */ jsx(Input, { value: payerName, onChange: (e) => setPayerName(e.currentTarget.value) })
94
+ ] }),
95
+ /* @__PURE__ */ jsxs("label", { className: "col-span-2 flex flex-col gap-1", children: [
96
+ /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: t("billing.payments.columns.reference", "Reference") }),
97
+ /* @__PURE__ */ jsx(Input, { value: reference, onChange: (e) => setReference(e.currentTarget.value) })
98
+ ] }),
99
+ !billAccountId ? /* @__PURE__ */ jsxs("div", { className: "col-span-2 flex flex-col gap-1", children: [
100
+ /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: t("billing.payments.fields.account_optional", "Billing account (optional)") }),
101
+ /* @__PURE__ */ jsx(AccountPicker, { value: accountId, onChange: setAccountId, currencyCode: currency.trim().toUpperCase(), billingMode: "postpaid" })
102
+ ] }) : null
103
+ ] }),
104
+ /* @__PURE__ */ jsx(DialogFooter, { children: /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between gap-3", children: [
105
+ /* @__PURE__ */ jsxs("span", { className: "text-xs text-muted-foreground", children: [
106
+ /* @__PURE__ */ jsx(KbdShortcut, { keys: ["Ctrl/\u2318", "Enter"] }),
107
+ " \xB7 ",
108
+ /* @__PURE__ */ jsx(Kbd, { children: "Esc" })
109
+ ] }),
110
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
111
+ /* @__PURE__ */ jsx(Button, { type: "button", variant: "outline", onClick: onClose, children: t("billing.common.cancel", "Cancel") }),
112
+ /* @__PURE__ */ jsx(Button, { type: "button", onClick: () => void submit(), disabled: saving, children: t("billing.common.save", "Save") })
113
+ ] })
114
+ ] }) })
115
+ ]
116
+ }
117
+ ) });
118
+ }
119
+ export {
120
+ ManualPaymentDialog
121
+ };
122
+ //# sourceMappingURL=ManualPaymentDialog.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/modules/billing/components/ManualPaymentDialog.tsx"],
4
+ "sourcesContent": ["\"use client\"\nimport * as React from 'react'\nimport { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle } from '@open-mercato/ui/primitives/dialog'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { Input } from '@open-mercato/ui/primitives/input'\nimport { Kbd, KbdShortcut } from '@open-mercato/ui/primitives/kbd'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport { apiCallOrThrow } from '@open-mercato/ui/backend/utils/apiCall'\nimport { normalizeCrudServerError } from '@open-mercato/ui/backend/utils/serverErrors'\nimport { flash } from '@open-mercato/ui/backend/FlashMessages'\nimport { AccountPicker } from './AccountPicker'\n\n/**\n * Manual payment entry (Spec C). With an account the payment is matched and\n * applied as credit to the account's open invoices; without one it stays\n * unmatched. `billAccountId` pre-selects the account (account page).\n */\nexport function ManualPaymentDialog({\n open,\n onClose,\n onCreated,\n billAccountId,\n currencyCode,\n}: {\n open: boolean\n onClose: () => void\n onCreated: (paymentId: string) => void\n billAccountId?: string\n currencyCode?: string\n}) {\n const t = useT()\n const today = new Date().toISOString().slice(0, 10)\n const [receivedAt, setReceivedAt] = React.useState(today)\n const [amount, setAmount] = React.useState('')\n const [currency, setCurrency] = React.useState(currencyCode ?? 'PLN')\n const [reference, setReference] = React.useState('')\n const [payerName, setPayerName] = React.useState('')\n const [accountId, setAccountId] = React.useState(billAccountId ?? '')\n const [saving, setSaving] = React.useState(false)\n\n React.useEffect(() => {\n if (!open) return\n setReceivedAt(new Date().toISOString().slice(0, 10))\n setAmount('')\n setReference('')\n setPayerName('')\n setAccountId(billAccountId ?? '')\n setCurrency(currencyCode ?? 'PLN')\n }, [billAccountId, currencyCode, open])\n\n const submit = React.useCallback(async () => {\n const value = Number.parseFloat(amount)\n if (!(value > 0) || saving) {\n flash(t('billing.payments.manual.amount_invalid', 'Amount must be greater than 0'), 'error')\n return\n }\n setSaving(true)\n try {\n const call = await apiCallOrThrow<{ paymentId: string }>('/api/billing/payments', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n receivedAt,\n amount: value,\n currencyCode: currency.trim().toUpperCase(),\n ...(reference.trim() ? { reference: reference.trim() } : {}),\n ...(payerName.trim() ? { payerName: payerName.trim() } : {}),\n ...(accountId ? { billAccountId: accountId } : {}),\n }),\n })\n flash(t('billing.payments.manual.saved', 'Payment recorded'), 'success')\n onClose()\n if (call.result?.paymentId) onCreated(call.result.paymentId)\n } catch (err) {\n flash(normalizeCrudServerError(err).message || t('billing.payments.manual.failed', 'Could not record the payment'), 'error')\n } finally {\n setSaving(false)\n }\n }, [accountId, amount, currency, onClose, onCreated, payerName, receivedAt, reference, saving, t])\n\n return (\n <Dialog open={open} onOpenChange={(next) => (!next ? onClose() : undefined)}>\n <DialogContent\n onKeyDown={(event) => {\n if ((event.metaKey || event.ctrlKey) && event.key === 'Enter') {\n event.preventDefault()\n void submit()\n }\n }}\n >\n <DialogHeader>\n <DialogTitle>{t('billing.payments.manual.title', 'Record payment')}</DialogTitle>\n </DialogHeader>\n <div className=\"grid grid-cols-2 gap-3 py-2 text-sm\">\n <label className=\"flex flex-col gap-1\">\n <span className=\"text-muted-foreground\">{t('billing.payments.columns.received', 'Received')}</span>\n <Input type=\"date\" value={receivedAt} onChange={(e) => setReceivedAt(e.currentTarget.value)} />\n </label>\n <label className=\"flex flex-col gap-1\">\n <span className=\"text-muted-foreground\">{t('billing.payments.columns.amount', 'Amount')}</span>\n <Input type=\"number\" min=\"0\" step=\"0.01\" value={amount} onChange={(e) => setAmount(e.currentTarget.value)} />\n </label>\n <label className=\"flex flex-col gap-1\">\n <span className=\"text-muted-foreground\">{t('billing.payments.fields.currency', 'Currency')}</span>\n <Input value={currency} maxLength={3} disabled={Boolean(currencyCode)} onChange={(e) => setCurrency(e.currentTarget.value)} />\n </label>\n <label className=\"flex flex-col gap-1\">\n <span className=\"text-muted-foreground\">{t('billing.payments.columns.payer', 'Payer')}</span>\n <Input value={payerName} onChange={(e) => setPayerName(e.currentTarget.value)} />\n </label>\n <label className=\"col-span-2 flex flex-col gap-1\">\n <span className=\"text-muted-foreground\">{t('billing.payments.columns.reference', 'Reference')}</span>\n <Input value={reference} onChange={(e) => setReference(e.currentTarget.value)} />\n </label>\n {!billAccountId ? (\n <div className=\"col-span-2 flex flex-col gap-1\">\n <span className=\"text-muted-foreground\">{t('billing.payments.fields.account_optional', 'Billing account (optional)')}</span>\n <AccountPicker value={accountId} onChange={setAccountId} currencyCode={currency.trim().toUpperCase()} billingMode=\"postpaid\" />\n </div>\n ) : null}\n </div>\n <DialogFooter>\n <div className=\"flex w-full items-center justify-between gap-3\">\n <span className=\"text-xs text-muted-foreground\">\n <KbdShortcut keys={['Ctrl/\u2318', 'Enter']} /> \u00B7 <Kbd>Esc</Kbd>\n </span>\n <div className=\"flex items-center gap-2\">\n <Button type=\"button\" variant=\"outline\" onClick={onClose}>\n {t('billing.common.cancel', 'Cancel')}\n </Button>\n <Button type=\"button\" onClick={() => void submit()} disabled={saving}>\n {t('billing.common.save', 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E,4CAA4C,4BAA4B,GAAE;AAAA,YACrH,oBAAC,iBAAc,OAAO,WAAW,UAAU,cAAc,cAAc,SAAS,KAAK,EAAE,YAAY,GAAG,aAAY,YAAW;AAAA,aAC/H,IACE;AAAA,WACN;AAAA,QACA,oBAAC,gBACC,+BAAC,SAAI,WAAU,kDACb;AAAA,+BAAC,UAAK,WAAU,iCACd;AAAA,gCAAC,eAAY,MAAM,CAAC,eAAU,OAAO,GAAG;AAAA,YAAE;AAAA,YAAG,oBAAC,OAAI,iBAAG;AAAA,aACvD;AAAA,UACA,qBAAC,SAAI,WAAU,2BACb;AAAA,gCAAC,UAAO,MAAK,UAAS,SAAQ,WAAU,SAAS,SAC9C,YAAE,yBAAyB,QAAQ,GACtC;AAAA,YACA,oBAAC,UAAO,MAAK,UAAS,SAAS,MAAM,KAAK,OAAO,GAAG,UAAU,QAC3D,YAAE,uBAAuB,MAAM,GAClC;AAAA,aACF;AAAA,WACF,GACF;AAAA;AAAA;AAAA,EACF,GACF;AAEJ;",
6
+ "names": []
7
+ }
@@ -0,0 +1,14 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { Input } from "@open-mercato/ui/primitives/input";
4
+ function MoneyInput({ currencyCode, className, ...inputProps }) {
5
+ const code = currencyCode?.trim();
6
+ return /* @__PURE__ */ jsxs("div", { className: "relative", children: [
7
+ /* @__PURE__ */ jsx(Input, { type: "number", ...inputProps, className: code ? `pr-14 ${className ?? ""}` : className }),
8
+ code ? /* @__PURE__ */ jsx("span", { className: "pointer-events-none absolute inset-y-0 right-3 flex items-center text-xs font-medium text-muted-foreground", children: code }) : null
9
+ ] });
10
+ }
11
+ export {
12
+ MoneyInput
13
+ };
14
+ //# sourceMappingURL=MoneyInput.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/modules/billing/components/MoneyInput.tsx"],
4
+ "sourcesContent": ["\"use client\"\nimport * as React from 'react'\nimport { Input } from '@open-mercato/ui/primitives/input'\n\nexport type MoneyInputProps = Omit<React.ComponentProps<typeof Input>, 'type'> & {\n /** ISO currency code shown as a read-only suffix; nothing is shown when empty. */\n currencyCode?: string | null\n}\n\n/**\n * Number input with a read-only currency suffix (Spec F, F2). The currency\n * comes from the parent Billing Account and is never editable here.\n */\nexport function MoneyInput({ currencyCode, className, ...inputProps }: MoneyInputProps) {\n const code = currencyCode?.trim()\n return (\n <div className=\"relative\">\n <Input type=\"number\" {...inputProps} className={code ? `pr-14 ${className ?? ''}` : className} />\n {code ? (\n <span className=\"pointer-events-none absolute inset-y-0 right-3 flex items-center text-xs font-medium text-muted-foreground\">\n {code}\n </span>\n ) : null}\n </div>\n )\n}\n"],
5
+ "mappings": ";AAgBI,SACE,KADF;AAdJ,SAAS,aAAa;AAWf,SAAS,WAAW,EAAE,cAAc,WAAW,GAAG,WAAW,GAAoB;AACtF,QAAM,OAAO,cAAc,KAAK;AAChC,SACE,qBAAC,SAAI,WAAU,YACb;AAAA,wBAAC,SAAM,MAAK,UAAU,GAAG,YAAY,WAAW,OAAO,SAAS,aAAa,EAAE,KAAK,WAAW;AAAA,IAC9F,OACC,oBAAC,UAAK,WAAU,8GACb,gBACH,IACE;AAAA,KACN;AAEJ;",
6
+ "names": []
7
+ }
@@ -0,0 +1,115 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import * as React from "react";
4
+ import {
5
+ Dialog,
6
+ DialogContent,
7
+ DialogDescription,
8
+ DialogFooter,
9
+ DialogHeader,
10
+ DialogTitle
11
+ } from "@open-mercato/ui/primitives/dialog";
12
+ import { Button } from "@open-mercato/ui/primitives/button";
13
+ import { Input } from "@open-mercato/ui/primitives/input";
14
+ import { Kbd, KbdShortcut } from "@open-mercato/ui/primitives/kbd";
15
+ import { useT } from "@open-mercato/shared/lib/i18n/context";
16
+ import { apiCall } from "@open-mercato/ui/backend/utils/apiCall";
17
+ import { flash } from "@open-mercato/ui/backend/FlashMessages";
18
+ const COUNT_KEYS = ["allocated", "partially_allocated", "matched", "unmatched", "duplicate", "rejected"];
19
+ function PaymentUploadDialog({
20
+ open,
21
+ onClose,
22
+ onImported
23
+ }) {
24
+ const t = useT();
25
+ const [file, setFile] = React.useState(null);
26
+ const [uploading, setUploading] = React.useState(false);
27
+ const [summary, setSummary] = React.useState(null);
28
+ React.useEffect(() => {
29
+ if (open) {
30
+ setFile(null);
31
+ setSummary(null);
32
+ }
33
+ }, [open]);
34
+ const countLabel = {
35
+ allocated: t("billing.payments.import.counts.allocated", "Allocated"),
36
+ partially_allocated: t("billing.payments.import.counts.partially_allocated", "Partially allocated"),
37
+ matched: t("billing.payments.import.counts.matched", "Matched (credit)"),
38
+ unmatched: t("billing.payments.import.counts.unmatched", "Unmatched"),
39
+ duplicate: t("billing.payments.import.counts.duplicate", "Duplicates"),
40
+ rejected: t("billing.payments.import.counts.rejected", "Rejected rows")
41
+ };
42
+ const upload = React.useCallback(async () => {
43
+ if (!file || uploading) return;
44
+ setUploading(true);
45
+ try {
46
+ const form = new FormData();
47
+ form.set("file", file);
48
+ const call = await apiCall("/api/billing/payments/import", { method: "POST", body: form });
49
+ if (!call.ok || !call.result?.importId) {
50
+ flash(call.result?.error ?? t("billing.payments.import.failed", "Import failed"), "error");
51
+ return;
52
+ }
53
+ setSummary(call.result);
54
+ onImported(call.result);
55
+ } finally {
56
+ setUploading(false);
57
+ }
58
+ }, [file, onImported, t, uploading]);
59
+ return /* @__PURE__ */ jsx(Dialog, { open, onOpenChange: (next) => !next ? onClose() : void 0, children: /* @__PURE__ */ jsxs(
60
+ DialogContent,
61
+ {
62
+ onKeyDown: (event) => {
63
+ if ((event.metaKey || event.ctrlKey) && event.key === "Enter") {
64
+ event.preventDefault();
65
+ if (!summary) void upload();
66
+ else onClose();
67
+ }
68
+ },
69
+ children: [
70
+ /* @__PURE__ */ jsxs(DialogHeader, { children: [
71
+ /* @__PURE__ */ jsx(DialogTitle, { children: t("billing.payments.import.title", "Upload bank payments") }),
72
+ /* @__PURE__ */ jsx(DialogDescription, { children: t(
73
+ "billing.payments.import.help",
74
+ "CSV with the header date,amount,currency,reference,payer_name,payer_account. Payments are matched by the invoice number in the reference."
75
+ ) })
76
+ ] }),
77
+ summary ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3 text-sm", children: [
78
+ /* @__PURE__ */ jsxs("div", { className: "text-muted-foreground", children: [
79
+ summary.fileName,
80
+ " \xB7 ",
81
+ t("billing.payments.import.rows", "rows"),
82
+ ": ",
83
+ summary.rowCount
84
+ ] }),
85
+ /* @__PURE__ */ jsx("div", { className: "grid grid-cols-2 gap-2", children: COUNT_KEYS.map((key) => /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between rounded-md border px-3 py-2", children: [
86
+ /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: countLabel[key] }),
87
+ /* @__PURE__ */ jsx("span", { className: "font-medium tabular-nums", children: summary.counts[key] ?? 0 })
88
+ ] }, key)) }),
89
+ summary.errors.length > 0 ? /* @__PURE__ */ jsx("div", { className: "max-h-40 overflow-auto rounded-md border p-2 text-xs", children: summary.errors.slice(0, 20).map((error) => /* @__PURE__ */ jsxs("div", { children: [
90
+ t("billing.payments.import.line", "Line"),
91
+ " ",
92
+ error.row,
93
+ ": ",
94
+ error.message
95
+ ] }, `${error.row}-${error.message}`)) }) : null
96
+ ] }) : /* @__PURE__ */ jsx(Input, { type: "file", accept: ".csv,text/csv", onChange: (event) => setFile(event.currentTarget.files?.[0] ?? null) }),
97
+ /* @__PURE__ */ jsx(DialogFooter, { children: /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between gap-3", children: [
98
+ /* @__PURE__ */ jsxs("span", { className: "text-xs text-muted-foreground", children: [
99
+ /* @__PURE__ */ jsx(KbdShortcut, { keys: ["Ctrl/\u2318", "Enter"] }),
100
+ " \xB7 ",
101
+ /* @__PURE__ */ jsx(Kbd, { children: "Esc" })
102
+ ] }),
103
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
104
+ /* @__PURE__ */ jsx(Button, { type: "button", variant: "outline", onClick: onClose, children: summary ? t("billing.common.close", "Close") : t("billing.common.cancel", "Cancel") }),
105
+ !summary ? /* @__PURE__ */ jsx(Button, { type: "button", onClick: () => void upload(), disabled: !file || uploading, children: uploading ? t("billing.payments.import.uploading", "Uploading\u2026") : t("billing.payments.import.action", "Upload") }) : null
106
+ ] })
107
+ ] }) })
108
+ ]
109
+ }
110
+ ) });
111
+ }
112
+ export {
113
+ PaymentUploadDialog
114
+ };
115
+ //# sourceMappingURL=PaymentUploadDialog.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/modules/billing/components/PaymentUploadDialog.tsx"],
4
+ "sourcesContent": ["\"use client\"\nimport * as React from 'react'\nimport {\n Dialog,\n DialogContent,\n DialogDescription,\n DialogFooter,\n DialogHeader,\n DialogTitle,\n} from '@open-mercato/ui/primitives/dialog'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { Input } from '@open-mercato/ui/primitives/input'\nimport { Kbd, KbdShortcut } from '@open-mercato/ui/primitives/kbd'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport { apiCall } from '@open-mercato/ui/backend/utils/apiCall'\nimport { flash } from '@open-mercato/ui/backend/FlashMessages'\n\n/**\n * Bank CSV upload (Spec C). Posts the file to `/api/billing/payments/import`\n * and shows the batch summary (counts per outcome + first row errors).\n * Cmd/Ctrl+Enter uploads, Escape closes.\n */\n\nexport type ImportSummary = {\n importId: string\n fileName: string\n rowCount: number\n counts: Record<string, number>\n errors: Array<{ row: number; message: string }>\n}\n\nconst COUNT_KEYS = ['allocated', 'partially_allocated', 'matched', 'unmatched', 'duplicate', 'rejected'] as const\n\nexport function PaymentUploadDialog({\n open,\n onClose,\n onImported,\n}: {\n open: boolean\n onClose: () => void\n onImported: (summary: ImportSummary) => void\n}) {\n const t = useT()\n const [file, setFile] = React.useState<File | null>(null)\n const [uploading, setUploading] = React.useState(false)\n const [summary, setSummary] = React.useState<ImportSummary | null>(null)\n\n React.useEffect(() => {\n if (open) {\n setFile(null)\n setSummary(null)\n }\n }, [open])\n\n const countLabel: Record<(typeof COUNT_KEYS)[number], string> = {\n allocated: t('billing.payments.import.counts.allocated', 'Allocated'),\n partially_allocated: t('billing.payments.import.counts.partially_allocated', 'Partially allocated'),\n matched: t('billing.payments.import.counts.matched', 'Matched (credit)'),\n unmatched: t('billing.payments.import.counts.unmatched', 'Unmatched'),\n duplicate: t('billing.payments.import.counts.duplicate', 'Duplicates'),\n rejected: t('billing.payments.import.counts.rejected', 'Rejected rows'),\n }\n\n const upload = React.useCallback(async () => {\n if (!file || uploading) return\n setUploading(true)\n try {\n const form = new FormData()\n form.set('file', file)\n const call = await apiCall<ImportSummary & { error?: string }>('/api/billing/payments/import', { method: 'POST', body: form })\n if (!call.ok || !call.result?.importId) {\n flash(call.result?.error ?? t('billing.payments.import.failed', 'Import failed'), 'error')\n return\n }\n setSummary(call.result)\n onImported(call.result)\n } finally {\n setUploading(false)\n }\n }, [file, onImported, t, uploading])\n\n return (\n <Dialog open={open} onOpenChange={(next) => (!next ? onClose() : undefined)}>\n <DialogContent\n onKeyDown={(event) => {\n if ((event.metaKey || event.ctrlKey) && event.key === 'Enter') {\n event.preventDefault()\n if (!summary) void upload()\n else onClose()\n }\n }}\n >\n <DialogHeader>\n <DialogTitle>{t('billing.payments.import.title', 'Upload bank payments')}</DialogTitle>\n <DialogDescription>\n {t(\n 'billing.payments.import.help',\n 'CSV with the header date,amount,currency,reference,payer_name,payer_account. Payments are matched by the invoice number in the reference.',\n )}\n </DialogDescription>\n </DialogHeader>\n {summary ? (\n <div className=\"flex flex-col gap-3 text-sm\">\n <div className=\"text-muted-foreground\">\n {summary.fileName} \u00B7 {t('billing.payments.import.rows', 'rows')}: {summary.rowCount}\n </div>\n <div className=\"grid grid-cols-2 gap-2\">\n {COUNT_KEYS.map((key) => (\n <div key={key} className=\"flex items-center justify-between rounded-md border px-3 py-2\">\n <span className=\"text-muted-foreground\">{countLabel[key]}</span>\n <span className=\"font-medium tabular-nums\">{summary.counts[key] ?? 0}</span>\n </div>\n ))}\n </div>\n {summary.errors.length > 0 ? (\n <div className=\"max-h-40 overflow-auto rounded-md border p-2 text-xs\">\n {summary.errors.slice(0, 20).map((error) => (\n <div key={`${error.row}-${error.message}`}>\n {t('billing.payments.import.line', 'Line')} {error.row}: {error.message}\n </div>\n ))}\n </div>\n ) : null}\n </div>\n ) : (\n <Input type=\"file\" accept=\".csv,text/csv\" onChange={(event) => setFile(event.currentTarget.files?.[0] ?? null)} />\n )}\n <DialogFooter>\n <div className=\"flex w-full items-center justify-between gap-3\">\n <span className=\"text-xs text-muted-foreground\">\n <KbdShortcut keys={['Ctrl/\u2318', 'Enter']} /> \u00B7 <Kbd>Esc</Kbd>\n </span>\n <div className=\"flex items-center gap-2\">\n <Button type=\"button\" variant=\"outline\" onClick={onClose}>\n {summary ? t('billing.common.close', 'Close') : t('billing.common.cancel', 'Cancel')}\n </Button>\n {!summary ? (\n <Button type=\"button\" onClick={() => void upload()} disabled={!file || uploading}>\n {uploading ? t('billing.payments.import.uploading', 'Uploading\u2026') : t('billing.payments.import.action', 'Upload')}\n </Button>\n ) : null}\n </div>\n </div>\n </DialogFooter>\n </DialogContent>\n </Dialog>\n )\n}\n"],
5
+ "mappings": ";AA4FQ,SACE,KADF;AA3FR,YAAY,WAAW;AACvB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,cAAc;AACvB,SAAS,aAAa;AACtB,SAAS,KAAK,mBAAmB;AACjC,SAAS,YAAY;AACrB,SAAS,eAAe;AACxB,SAAS,aAAa;AAgBtB,MAAM,aAAa,CAAC,aAAa,uBAAuB,WAAW,aAAa,aAAa,UAAU;AAEhG,SAAS,oBAAoB;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AACF,GAIG;AACD,QAAM,IAAI,KAAK;AACf,QA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,OAAO,GAAG;AAAA,YAAE;AAAA,YAAG,oBAAC,OAAI,iBAAG;AAAA,aACvD;AAAA,UACA,qBAAC,SAAI,WAAU,2BACb;AAAA,gCAAC,UAAO,MAAK,UAAS,SAAQ,WAAU,SAAS,SAC9C,oBAAU,EAAE,wBAAwB,OAAO,IAAI,EAAE,yBAAyB,QAAQ,GACrF;AAAA,YACC,CAAC,UACA,oBAAC,UAAO,MAAK,UAAS,SAAS,MAAM,KAAK,OAAO,GAAG,UAAU,CAAC,QAAQ,WACpE,sBAAY,EAAE,qCAAqC,iBAAY,IAAI,EAAE,kCAAkC,QAAQ,GAClH,IACE;AAAA,aACN;AAAA,WACF,GACF;AAAA;AAAA;AAAA,EACF,GACF;AAEJ;",
6
+ "names": []
7
+ }
@@ -0,0 +1,171 @@
1
+ "use client";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import * as React from "react";
4
+ import { useRouter } from "next/navigation";
5
+ import { useT } from "@open-mercato/shared/lib/i18n/context";
6
+ import { BillingDataTable as DataTable } from "./BillingDataTable.js";
7
+ import { Tag } from "@open-mercato/ui/primitives/tag";
8
+ import { readApiResultOrThrow } from "@open-mercato/ui/backend/utils/apiCall";
9
+ import { formatMoney } from "./InvoicesTable.js";
10
+ const PAYMENT_STATUS_VARIANT = {
11
+ allocated: "success",
12
+ partially_allocated: "info",
13
+ matched: "info",
14
+ unmatched: "warning",
15
+ ignored: "neutral",
16
+ converted_to_topup: "success"
17
+ };
18
+ function usePaymentLabels() {
19
+ const t = useT();
20
+ return React.useMemo(
21
+ () => ({
22
+ status: (status) => ({
23
+ unmatched: t("billing.payments.status.unmatched", "Unmatched"),
24
+ matched: t("billing.payments.status.matched", "Matched"),
25
+ partially_allocated: t("billing.payments.status.partially_allocated", "Partially allocated"),
26
+ allocated: t("billing.payments.status.allocated", "Allocated"),
27
+ ignored: t("billing.payments.status.ignored", "Ignored"),
28
+ converted_to_topup: t("billing.payments.status.converted_to_topup", "Converted to top-up")
29
+ })[status] ?? status,
30
+ reason: (reason) => reason ? {
31
+ no_reference: t("billing.payments.reason.no_reference", "No invoice number found"),
32
+ currency_mismatch: t("billing.payments.reason.currency_mismatch", "Currency differs from the invoice"),
33
+ invoice_already_paid: t("billing.payments.reason.invoice_already_paid", "Invoice already paid \u2014 kept as credit"),
34
+ prepaid_account: t("billing.payments.reason.prepaid_account", "Prepaid account \u2014 convert to a top-up"),
35
+ manual: t("billing.payments.reason.manual", "Entered or assigned manually")
36
+ }[reason] ?? reason : "\u2014"
37
+ }),
38
+ [t]
39
+ );
40
+ }
41
+ function PaymentsTable({ title, tableId, billAccountId, importId, pageSize = 25, reloadKey = 0, actions }) {
42
+ const t = useT();
43
+ const router = useRouter();
44
+ const labels = usePaymentLabels();
45
+ const [rows, setRows] = React.useState([]);
46
+ const [page, setPage] = React.useState(1);
47
+ const [filters, setFilters] = React.useState({});
48
+ const [search, setSearch] = React.useState("");
49
+ const [total, setTotal] = React.useState(0);
50
+ const [totalPages, setTotalPages] = React.useState(1);
51
+ const [loading, setLoading] = React.useState(true);
52
+ const [error, setError] = React.useState(null);
53
+ const filterDefs = React.useMemo(
54
+ () => [
55
+ {
56
+ id: "status",
57
+ label: t("billing.payments.filters.status", "Status"),
58
+ type: "select",
59
+ options: ["unmatched", "matched", "partially_allocated", "allocated", "ignored", "converted_to_topup"].map((value) => ({
60
+ value,
61
+ label: labels.status(value)
62
+ }))
63
+ }
64
+ ],
65
+ [labels, t]
66
+ );
67
+ const load = React.useCallback(async () => {
68
+ setLoading(true);
69
+ setError(null);
70
+ try {
71
+ const params = new URLSearchParams({ page: String(page), pageSize: String(Math.min(pageSize, 100)) });
72
+ if (billAccountId) params.set("billAccountId", billAccountId);
73
+ if (importId) params.set("importId", importId);
74
+ if (search.trim()) params.set("search", search.trim());
75
+ if (typeof filters.status === "string" && filters.status) params.set("status", filters.status);
76
+ const result = await readApiResultOrThrow(`/api/billing/payments?${params.toString()}`);
77
+ setRows(result.items ?? []);
78
+ setTotal(result.total ?? 0);
79
+ setTotalPages(result.totalPages ?? 1);
80
+ } catch (err) {
81
+ setError(err instanceof Error ? err.message : t("billing.payments.error.load", "Could not load payments"));
82
+ } finally {
83
+ setLoading(false);
84
+ }
85
+ }, [billAccountId, filters.status, importId, page, pageSize, search, t, reloadKey]);
86
+ React.useEffect(() => {
87
+ void load();
88
+ }, [load]);
89
+ const columns = React.useMemo(() => {
90
+ const cols = [
91
+ {
92
+ accessorKey: "received_at",
93
+ header: t("billing.payments.columns.received", "Received"),
94
+ cell: ({ row }) => row.original.received_at?.slice(0, 10) ?? "\u2014"
95
+ },
96
+ {
97
+ accessorKey: "amount",
98
+ header: t("billing.payments.columns.amount", "Amount"),
99
+ cell: ({ row }) => formatMoney(row.original.amount, row.original.currency_code)
100
+ },
101
+ {
102
+ accessorKey: "status",
103
+ header: t("billing.payments.columns.status", "Status"),
104
+ cell: ({ row }) => /* @__PURE__ */ jsx(Tag, { variant: PAYMENT_STATUS_VARIANT[row.original.status] ?? "default", children: labels.status(row.original.status) })
105
+ },
106
+ {
107
+ accessorKey: "unallocated_amount",
108
+ header: t("billing.payments.columns.unallocated", "Unallocated"),
109
+ cell: ({ row }) => formatMoney(row.original.unallocated_amount, row.original.currency_code)
110
+ },
111
+ {
112
+ accessorKey: "reference",
113
+ header: t("billing.payments.columns.reference", "Reference"),
114
+ cell: ({ row }) => row.original.reference ?? "\u2014",
115
+ meta: { truncate: true, maxWidth: "260px" }
116
+ },
117
+ {
118
+ accessorKey: "payer_name",
119
+ header: t("billing.payments.columns.payer", "Payer"),
120
+ cell: ({ row }) => row.original.payer_name ?? "\u2014",
121
+ meta: { truncate: true, maxWidth: "180px" }
122
+ }
123
+ ];
124
+ if (!billAccountId) {
125
+ cols.splice(3, 0, {
126
+ accessorKey: "bill_account_name",
127
+ header: t("billing.payments.columns.account", "Account"),
128
+ cell: ({ row }) => row.original.bill_account_name ?? "\u2014",
129
+ meta: { truncate: true, maxWidth: "200px" }
130
+ });
131
+ }
132
+ return cols;
133
+ }, [billAccountId, labels, t]);
134
+ return /* @__PURE__ */ jsx(
135
+ DataTable,
136
+ {
137
+ title,
138
+ actions,
139
+ refreshButton: { label: t("billing.common.refresh", "Refresh"), onRefresh: load, isRefreshing: loading },
140
+ perspective: { tableId },
141
+ columns,
142
+ data: rows,
143
+ error,
144
+ emptyState: t("billing.payments.empty", "No payments yet."),
145
+ isLoading: loading,
146
+ onRowClick: (row) => router.push(`/backend/billing/payments/${encodeURIComponent(row.id)}`),
147
+ pagination: { page, pageSize, total, totalPages, onPageChange: setPage },
148
+ filters: filterDefs,
149
+ filterValues: filters,
150
+ onFiltersApply: (next) => {
151
+ setPage(1);
152
+ setFilters(next);
153
+ },
154
+ onFiltersClear: () => {
155
+ setPage(1);
156
+ setFilters({});
157
+ },
158
+ searchValue: search,
159
+ onSearchChange: (next) => {
160
+ setPage(1);
161
+ setSearch(next);
162
+ }
163
+ }
164
+ );
165
+ }
166
+ export {
167
+ PAYMENT_STATUS_VARIANT,
168
+ PaymentsTable,
169
+ usePaymentLabels
170
+ };
171
+ //# sourceMappingURL=PaymentsTable.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/modules/billing/components/PaymentsTable.tsx"],
4
+ "sourcesContent": ["\"use client\"\nimport * as React from 'react'\nimport { useRouter } from 'next/navigation'\nimport type { LegacyColumnDef as ColumnDef } from '@tanstack/react-table/legacy'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport type { FilterDef, FilterValues } from '@open-mercato/ui/backend/FilterBar'\nimport { BillingDataTable as DataTable } from './BillingDataTable'\nimport { Tag } from '@open-mercato/ui/primitives/tag'\nimport { readApiResultOrThrow } from '@open-mercato/ui/backend/utils/apiCall'\nimport { formatMoney } from './InvoicesTable'\n\n/**\n * Billing payments table (Spec C) \u2014 shared by the Payments list page and the\n * Payments section of a billing account. `billAccountId` / `importId` pin\n * the list; row click opens the payment.\n */\n\nexport type PaymentRow = {\n id: string\n received_at: string\n amount: string\n currency_code: string\n reference: string | null\n payer_name: string | null\n source: string\n import_id: string | null\n bill_account_id: string | null\n bill_account_name: string | null\n status: string\n unallocated_amount: string\n match_reason: string | null\n}\n\ntype ListResponse = { items: PaymentRow[]; total: number; totalPages: number }\n\nexport const PAYMENT_STATUS_VARIANT: Record<string, 'success' | 'warning' | 'error' | 'neutral' | 'info' | 'default'> = {\n allocated: 'success',\n partially_allocated: 'info',\n matched: 'info',\n unmatched: 'warning',\n ignored: 'neutral',\n converted_to_topup: 'success',\n}\n\nexport function usePaymentLabels() {\n const t = useT()\n return React.useMemo(\n () => ({\n status: (status: string) =>\n ({\n unmatched: t('billing.payments.status.unmatched', 'Unmatched'),\n matched: t('billing.payments.status.matched', 'Matched'),\n partially_allocated: t('billing.payments.status.partially_allocated', 'Partially allocated'),\n allocated: t('billing.payments.status.allocated', 'Allocated'),\n ignored: t('billing.payments.status.ignored', 'Ignored'),\n converted_to_topup: t('billing.payments.status.converted_to_topup', 'Converted to top-up'),\n })[status] ?? status,\n reason: (reason: string | null) =>\n reason\n ? ({\n no_reference: t('billing.payments.reason.no_reference', 'No invoice number found'),\n currency_mismatch: t('billing.payments.reason.currency_mismatch', 'Currency differs from the invoice'),\n invoice_already_paid: t('billing.payments.reason.invoice_already_paid', 'Invoice already paid \u2014 kept as credit'),\n prepaid_account: t('billing.payments.reason.prepaid_account', 'Prepaid account \u2014 convert to a top-up'),\n manual: t('billing.payments.reason.manual', 'Entered or assigned manually'),\n })[reason] ?? reason\n : '\u2014',\n }),\n [t],\n )\n}\n\nexport type PaymentsTableProps = {\n title: string\n tableId: string\n billAccountId?: string\n importId?: string\n pageSize?: number\n /** Bumped by the host to force a reload (e.g. after an upload). */\n reloadKey?: number\n actions?: React.ReactNode\n}\n\nexport function PaymentsTable({ title, tableId, billAccountId, importId, pageSize = 25, reloadKey = 0, actions }: PaymentsTableProps) {\n const t = useT()\n const router = useRouter()\n const labels = usePaymentLabels()\n const [rows, setRows] = React.useState<PaymentRow[]>([])\n const [page, setPage] = React.useState(1)\n const [filters, setFilters] = React.useState<FilterValues>({})\n const [search, setSearch] = React.useState('')\n const [total, setTotal] = React.useState(0)\n const [totalPages, setTotalPages] = React.useState(1)\n const [loading, setLoading] = React.useState(true)\n const [error, setError] = React.useState<string | null>(null)\n\n const filterDefs = React.useMemo<FilterDef[]>(\n () => [\n {\n id: 'status',\n label: t('billing.payments.filters.status', 'Status'),\n type: 'select',\n options: ['unmatched', 'matched', 'partially_allocated', 'allocated', 'ignored', 'converted_to_topup'].map((value) => ({\n value,\n label: labels.status(value),\n })),\n },\n ],\n [labels, t],\n )\n\n const load = React.useCallback(async () => {\n setLoading(true)\n setError(null)\n try {\n const params = new URLSearchParams({ page: String(page), pageSize: String(Math.min(pageSize, 100)) })\n if (billAccountId) params.set('billAccountId', billAccountId)\n if (importId) params.set('importId', importId)\n if (search.trim()) params.set('search', search.trim())\n if (typeof filters.status === 'string' && filters.status) params.set('status', filters.status)\n const result = await readApiResultOrThrow<ListResponse>(`/api/billing/payments?${params.toString()}`)\n setRows(result.items ?? [])\n setTotal(result.total ?? 0)\n setTotalPages(result.totalPages ?? 1)\n } catch (err) {\n setError(err instanceof Error ? err.message : t('billing.payments.error.load', 'Could not load payments'))\n } finally {\n setLoading(false)\n }\n // reloadKey forces a refetch from the host.\n }, [billAccountId, filters.status, importId, page, pageSize, search, t, reloadKey]) // eslint-disable-line react-hooks/exhaustive-deps\n\n React.useEffect(() => {\n void load()\n }, [load])\n\n const columns = React.useMemo<ColumnDef<PaymentRow>[]>(() => {\n const cols: ColumnDef<PaymentRow>[] = [\n {\n accessorKey: 'received_at',\n header: t('billing.payments.columns.received', 'Received'),\n cell: ({ row }) => row.original.received_at?.slice(0, 10) ?? '\u2014',\n },\n {\n accessorKey: 'amount',\n header: t('billing.payments.columns.amount', 'Amount'),\n cell: ({ row }) => formatMoney(row.original.amount, row.original.currency_code),\n },\n {\n accessorKey: 'status',\n header: t('billing.payments.columns.status', 'Status'),\n cell: ({ row }) => <Tag variant={PAYMENT_STATUS_VARIANT[row.original.status] ?? 'default'}>{labels.status(row.original.status)}</Tag>,\n },\n {\n accessorKey: 'unallocated_amount',\n header: t('billing.payments.columns.unallocated', 'Unallocated'),\n cell: ({ row }) => formatMoney(row.original.unallocated_amount, row.original.currency_code),\n },\n {\n accessorKey: 'reference',\n header: t('billing.payments.columns.reference', 'Reference'),\n cell: ({ row }) => row.original.reference ?? '\u2014',\n meta: { truncate: true, maxWidth: '260px' },\n },\n {\n accessorKey: 'payer_name',\n header: t('billing.payments.columns.payer', 'Payer'),\n cell: ({ row }) => row.original.payer_name ?? '\u2014',\n meta: { truncate: true, maxWidth: '180px' },\n },\n ]\n if (!billAccountId) {\n cols.splice(3, 0, {\n accessorKey: 'bill_account_name',\n header: t('billing.payments.columns.account', 'Account'),\n cell: ({ row }) => row.original.bill_account_name ?? '\u2014',\n meta: { truncate: true, maxWidth: '200px' },\n })\n }\n return cols\n }, [billAccountId, labels, t])\n\n return (\n <DataTable\n title={title}\n actions={actions}\n refreshButton={{ label: t('billing.common.refresh', 'Refresh'), onRefresh: load, isRefreshing: loading }}\n perspective={{ tableId }}\n columns={columns}\n data={rows}\n error={error}\n emptyState={t('billing.payments.empty', 'No payments yet.')}\n isLoading={loading}\n onRowClick={(row) => router.push(`/backend/billing/payments/${encodeURIComponent(row.id)}`)}\n pagination={{ page, pageSize, total, totalPages, onPageChange: setPage }}\n filters={filterDefs}\n filterValues={filters}\n onFiltersApply={(next) => {\n setPage(1)\n setFilters(next)\n }}\n onFiltersClear={() => {\n setPage(1)\n setFilters({})\n }}\n searchValue={search}\n onSearchChange={(next) => {\n setPage(1)\n setSearch(next)\n }}\n />\n )\n}\n"],
5
+ "mappings": ";AAuJ2B;AAtJ3B,YAAY,WAAW;AACvB,SAAS,iBAAiB;AAE1B,SAAS,YAAY;AAErB,SAAS,oBAAoB,iBAAiB;AAC9C,SAAS,WAAW;AACpB,SAAS,4BAA4B;AACrC,SAAS,mBAAmB;AA0BrB,MAAM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