@spaceinvoices/react-ui 0.4.12 → 0.4.32

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 (334) hide show
  1. package/cli/dist/index.js +1 -1
  2. package/package.json +1 -1
  3. package/src/common/autocomplete.tsx +7 -1
  4. package/src/components/advance-invoices/advance-invoices.hooks.ts +35 -44
  5. package/src/components/advance-invoices/create/create-advance-invoice-form.tsx +190 -73
  6. package/src/components/advance-invoices/create/locales/bg.ts +17 -9
  7. package/src/components/advance-invoices/create/locales/cs.ts +17 -9
  8. package/src/components/advance-invoices/create/locales/de.ts +15 -7
  9. package/src/components/advance-invoices/create/locales/en.ts +15 -7
  10. package/src/components/advance-invoices/create/locales/es.ts +15 -7
  11. package/src/components/advance-invoices/create/locales/et.ts +17 -9
  12. package/src/components/advance-invoices/create/locales/fi.ts +18 -10
  13. package/src/components/advance-invoices/create/locales/fr.ts +16 -8
  14. package/src/components/advance-invoices/create/locales/hr.ts +15 -7
  15. package/src/components/advance-invoices/create/locales/is.ts +17 -9
  16. package/src/components/advance-invoices/create/locales/it.ts +15 -7
  17. package/src/components/advance-invoices/create/locales/nb.ts +17 -9
  18. package/src/components/advance-invoices/create/locales/nl.ts +15 -7
  19. package/src/components/advance-invoices/create/locales/pl.ts +17 -9
  20. package/src/components/advance-invoices/create/locales/pt.ts +16 -8
  21. package/src/components/advance-invoices/create/locales/sk.ts +17 -9
  22. package/src/components/advance-invoices/create/locales/sl.ts +14 -5
  23. package/src/components/advance-invoices/create/locales/sv.ts +17 -9
  24. package/src/components/advance-invoices/create/prepare-advance-invoice-submission.ts +47 -1
  25. package/src/components/advance-invoices/list/list-table.tsx +2 -1
  26. package/src/components/credit-notes/create/create-credit-note-form.tsx +254 -85
  27. package/src/components/credit-notes/create/locales/bg.ts +22 -8
  28. package/src/components/credit-notes/create/locales/cs.ts +22 -8
  29. package/src/components/credit-notes/create/locales/de.ts +20 -7
  30. package/src/components/credit-notes/create/locales/en.ts +19 -5
  31. package/src/components/credit-notes/create/locales/es.ts +20 -7
  32. package/src/components/credit-notes/create/locales/et.ts +22 -8
  33. package/src/components/credit-notes/create/locales/fi.ts +23 -9
  34. package/src/components/credit-notes/create/locales/fr.ts +21 -8
  35. package/src/components/credit-notes/create/locales/hr.ts +20 -7
  36. package/src/components/credit-notes/create/locales/is.ts +22 -8
  37. package/src/components/credit-notes/create/locales/it.ts +20 -7
  38. package/src/components/credit-notes/create/locales/nb.ts +22 -8
  39. package/src/components/credit-notes/create/locales/nl.ts +20 -7
  40. package/src/components/credit-notes/create/locales/pl.ts +22 -9
  41. package/src/components/credit-notes/create/locales/pt.ts +21 -8
  42. package/src/components/credit-notes/create/locales/sk.ts +22 -8
  43. package/src/components/credit-notes/create/locales/sl.ts +19 -5
  44. package/src/components/credit-notes/create/locales/sv.ts +22 -8
  45. package/src/components/credit-notes/create/prepare-credit-note-submission.ts +35 -1
  46. package/src/components/credit-notes/credit-notes.hooks.ts +21 -2
  47. package/src/components/credit-notes/list/list-table.tsx +2 -1
  48. package/src/components/delivery-notes/create/create-delivery-note-form.tsx +133 -30
  49. package/src/components/delivery-notes/create/locales/bg.ts +1 -0
  50. package/src/components/delivery-notes/create/locales/cs.ts +1 -0
  51. package/src/components/delivery-notes/create/locales/de.ts +1 -0
  52. package/src/components/delivery-notes/create/locales/en.ts +1 -0
  53. package/src/components/delivery-notes/create/locales/es.ts +1 -0
  54. package/src/components/delivery-notes/create/locales/et.ts +1 -0
  55. package/src/components/delivery-notes/create/locales/fi.ts +1 -0
  56. package/src/components/delivery-notes/create/locales/fr.ts +1 -0
  57. package/src/components/delivery-notes/create/locales/hr.ts +1 -0
  58. package/src/components/delivery-notes/create/locales/is.ts +1 -0
  59. package/src/components/delivery-notes/create/locales/it.ts +1 -0
  60. package/src/components/delivery-notes/create/locales/nb.ts +1 -0
  61. package/src/components/delivery-notes/create/locales/nl.ts +1 -0
  62. package/src/components/delivery-notes/create/locales/pl.ts +1 -0
  63. package/src/components/delivery-notes/create/locales/pt.ts +1 -0
  64. package/src/components/delivery-notes/create/locales/sk.ts +1 -0
  65. package/src/components/delivery-notes/create/locales/sl.ts +1 -0
  66. package/src/components/delivery-notes/create/locales/sv.ts +1 -0
  67. package/src/components/delivery-notes/create/prepare-delivery-note-submission.ts +34 -1
  68. package/src/components/delivery-notes/delivery-notes.hooks.ts +15 -1
  69. package/src/components/delivery-notes/list/list-table.tsx +2 -1
  70. package/src/components/documents/create/custom-create-template.ts +151 -0
  71. package/src/components/documents/create/document-add-item-form.tsx +12 -8
  72. package/src/components/documents/create/document-add-item-tax-rate-field.tsx +1 -2
  73. package/src/components/documents/create/document-date-validation.ts +111 -0
  74. package/src/components/documents/create/document-details-section.tsx +93 -48
  75. package/src/components/documents/create/document-form-item.ts +67 -0
  76. package/src/components/documents/create/document-item-validation.ts +6 -2
  77. package/src/components/documents/create/form-types.ts +2 -2
  78. package/src/components/documents/create/linked-documents-info.tsx +2 -11
  79. package/src/components/documents/create/live-preview.tsx +3 -3
  80. package/src/components/documents/create/mark-as-paid-section.tsx +14 -11
  81. package/src/components/documents/create/payment-rows.ts +30 -0
  82. package/src/components/documents/create/prepare-document-submission.ts +143 -103
  83. package/src/components/documents/create/prepare-preview-data.ts +12 -0
  84. package/src/components/documents/create/preserved-expected-total.ts +90 -0
  85. package/src/components/documents/public/public-document-summary.tsx +6 -13
  86. package/src/components/documents/view/document-actions-bar.tsx +10 -1
  87. package/src/components/documents/view/document-details-card.tsx +4 -12
  88. package/src/components/documents/view/document-relations-list.tsx +4 -4
  89. package/src/components/documents/view/locales/bg.ts +8 -8
  90. package/src/components/documents/view/locales/cs.ts +8 -8
  91. package/src/components/documents/view/locales/de.ts +1 -1
  92. package/src/components/documents/view/locales/en.ts +14 -14
  93. package/src/components/documents/view/locales/es.ts +1 -1
  94. package/src/components/documents/view/locales/et.ts +8 -8
  95. package/src/components/documents/view/locales/fi.ts +10 -10
  96. package/src/components/documents/view/locales/fr.ts +1 -1
  97. package/src/components/documents/view/locales/hr.ts +6 -6
  98. package/src/components/documents/view/locales/is.ts +8 -8
  99. package/src/components/documents/view/locales/it.ts +1 -1
  100. package/src/components/documents/view/locales/nb.ts +8 -8
  101. package/src/components/documents/view/locales/nl.ts +1 -1
  102. package/src/components/documents/view/locales/pl.ts +1 -1
  103. package/src/components/documents/view/locales/pt.ts +1 -1
  104. package/src/components/documents/view/locales/sk.ts +8 -8
  105. package/src/components/documents/view/locales/sl.ts +9 -9
  106. package/src/components/documents/view/locales/sv.ts +1 -1
  107. package/src/components/documents/view/use-document-download.ts +2 -2
  108. package/src/components/entities/entity-settings-form/locales/bg.ts +7 -0
  109. package/src/components/entities/entity-settings-form/locales/cs.ts +7 -0
  110. package/src/components/entities/entity-settings-form/locales/de.ts +9 -0
  111. package/src/components/entities/entity-settings-form/locales/en.ts +7 -0
  112. package/src/components/entities/entity-settings-form/locales/es.ts +7 -0
  113. package/src/components/entities/entity-settings-form/locales/et.ts +7 -0
  114. package/src/components/entities/entity-settings-form/locales/fi.ts +7 -0
  115. package/src/components/entities/entity-settings-form/locales/fr.ts +7 -0
  116. package/src/components/entities/entity-settings-form/locales/hr.ts +7 -0
  117. package/src/components/entities/entity-settings-form/locales/is.ts +7 -0
  118. package/src/components/entities/entity-settings-form/locales/it.ts +7 -0
  119. package/src/components/entities/entity-settings-form/locales/nb.ts +7 -0
  120. package/src/components/entities/entity-settings-form/locales/nl.ts +7 -0
  121. package/src/components/entities/entity-settings-form/locales/pl.ts +7 -0
  122. package/src/components/entities/entity-settings-form/locales/pt.ts +7 -0
  123. package/src/components/entities/entity-settings-form/locales/sk.ts +7 -0
  124. package/src/components/entities/entity-settings-form/locales/sl.ts +12 -4
  125. package/src/components/entities/entity-settings-form/locales/sv.ts +7 -0
  126. package/src/components/entities/settings/tax-rules-settings-form.tsx +36 -0
  127. package/src/components/estimates/create/create-estimate-form.tsx +196 -47
  128. package/src/components/estimates/create/locales/bg.ts +6 -5
  129. package/src/components/estimates/create/locales/cs.ts +6 -5
  130. package/src/components/estimates/create/locales/de.ts +4 -3
  131. package/src/components/estimates/create/locales/en.ts +4 -3
  132. package/src/components/estimates/create/locales/es.ts +4 -3
  133. package/src/components/estimates/create/locales/et.ts +6 -5
  134. package/src/components/estimates/create/locales/fi.ts +9 -8
  135. package/src/components/estimates/create/locales/fr.ts +4 -3
  136. package/src/components/estimates/create/locales/hr.ts +7 -6
  137. package/src/components/estimates/create/locales/is.ts +6 -5
  138. package/src/components/estimates/create/locales/it.ts +4 -3
  139. package/src/components/estimates/create/locales/nb.ts +6 -5
  140. package/src/components/estimates/create/locales/nl.ts +4 -3
  141. package/src/components/estimates/create/locales/pl.ts +4 -3
  142. package/src/components/estimates/create/locales/pt.ts +4 -3
  143. package/src/components/estimates/create/locales/sk.ts +6 -5
  144. package/src/components/estimates/create/locales/sl.ts +7 -6
  145. package/src/components/estimates/create/locales/sv.ts +6 -5
  146. package/src/components/estimates/create/prepare-estimate-submission.ts +37 -3
  147. package/src/components/estimates/estimates.hooks.ts +11 -2
  148. package/src/components/estimates/list/list-table.tsx +11 -1
  149. package/src/components/estimates/list/locales/bg.ts +2 -0
  150. package/src/components/estimates/list/locales/cs.ts +2 -0
  151. package/src/components/estimates/list/locales/de.ts +2 -0
  152. package/src/components/estimates/list/locales/en.ts +2 -0
  153. package/src/components/estimates/list/locales/es.ts +2 -0
  154. package/src/components/estimates/list/locales/et.ts +2 -0
  155. package/src/components/estimates/list/locales/fi.ts +2 -0
  156. package/src/components/estimates/list/locales/fr.ts +2 -0
  157. package/src/components/estimates/list/locales/hr.ts +7 -5
  158. package/src/components/estimates/list/locales/is.ts +2 -0
  159. package/src/components/estimates/list/locales/it.ts +2 -0
  160. package/src/components/estimates/list/locales/nb.ts +2 -0
  161. package/src/components/estimates/list/locales/nl.ts +2 -0
  162. package/src/components/estimates/list/locales/pl.ts +2 -0
  163. package/src/components/estimates/list/locales/pt.ts +2 -0
  164. package/src/components/estimates/list/locales/sk.ts +2 -0
  165. package/src/components/estimates/list/locales/sl.ts +9 -7
  166. package/src/components/estimates/list/locales/sv.ts +2 -0
  167. package/src/components/invoices/create/create-invoice-form.tsx +231 -60
  168. package/src/components/invoices/create/locales/bg.ts +23 -14
  169. package/src/components/invoices/create/locales/cs.ts +23 -14
  170. package/src/components/invoices/create/locales/de.ts +17 -9
  171. package/src/components/invoices/create/locales/en.ts +16 -7
  172. package/src/components/invoices/create/locales/es.ts +18 -9
  173. package/src/components/invoices/create/locales/et.ts +23 -14
  174. package/src/components/invoices/create/locales/fi.ts +24 -15
  175. package/src/components/invoices/create/locales/fr.ts +19 -11
  176. package/src/components/invoices/create/locales/hr.ts +18 -9
  177. package/src/components/invoices/create/locales/is.ts +23 -14
  178. package/src/components/invoices/create/locales/it.ts +19 -11
  179. package/src/components/invoices/create/locales/nb.ts +23 -14
  180. package/src/components/invoices/create/locales/nl.ts +19 -10
  181. package/src/components/invoices/create/locales/pl.ts +19 -11
  182. package/src/components/invoices/create/locales/pt.ts +19 -10
  183. package/src/components/invoices/create/locales/sk.ts +23 -14
  184. package/src/components/invoices/create/locales/sl.ts +17 -9
  185. package/src/components/invoices/create/locales/sv.ts +17 -8
  186. package/src/components/invoices/create/prepare-invoice-submission.ts +55 -1
  187. package/src/components/invoices/invoices.hooks.ts +11 -2
  188. package/src/components/invoices/list/list-table.tsx +2 -1
  189. package/src/components/invoices/send-email-dialog/locales/bg.ts +5 -0
  190. package/src/components/invoices/send-email-dialog/locales/cs.ts +5 -0
  191. package/src/components/invoices/send-email-dialog/locales/de.ts +5 -0
  192. package/src/components/invoices/send-email-dialog/locales/en.ts +5 -0
  193. package/src/components/invoices/send-email-dialog/locales/es.ts +5 -0
  194. package/src/components/invoices/send-email-dialog/locales/et.ts +5 -0
  195. package/src/components/invoices/send-email-dialog/locales/fi.ts +5 -0
  196. package/src/components/invoices/send-email-dialog/locales/fr.ts +5 -0
  197. package/src/components/invoices/send-email-dialog/locales/hr.ts +8 -3
  198. package/src/components/invoices/send-email-dialog/locales/is.ts +5 -0
  199. package/src/components/invoices/send-email-dialog/locales/it.ts +5 -0
  200. package/src/components/invoices/send-email-dialog/locales/nb.ts +5 -0
  201. package/src/components/invoices/send-email-dialog/locales/nl.ts +5 -0
  202. package/src/components/invoices/send-email-dialog/locales/pl.ts +5 -0
  203. package/src/components/invoices/send-email-dialog/locales/pt.ts +5 -0
  204. package/src/components/invoices/send-email-dialog/locales/sk.ts +5 -0
  205. package/src/components/invoices/send-email-dialog/locales/sl.ts +8 -3
  206. package/src/components/invoices/send-email-dialog/locales/sv.ts +5 -0
  207. package/src/components/invoices/send-email-dialog/send-email-dialog.tsx +2 -1
  208. package/src/components/items/item-combobox.tsx +4 -4
  209. package/src/components/payments/create-payment-form/create-payment-form.tsx +5 -2
  210. package/src/components/payments/edit-payment-form/edit-payment-form.tsx +5 -1
  211. package/src/components/recurring-invoices/create-recurring-invoice-form/create-recurring-invoice-form.tsx +98 -22
  212. package/src/components/recurring-invoices/create-recurring-invoice-form/locales/bg.ts +26 -26
  213. package/src/components/recurring-invoices/create-recurring-invoice-form/locales/cs.ts +25 -25
  214. package/src/components/recurring-invoices/create-recurring-invoice-form/locales/et.ts +26 -26
  215. package/src/components/recurring-invoices/create-recurring-invoice-form/locales/fi.ts +36 -36
  216. package/src/components/recurring-invoices/create-recurring-invoice-form/locales/is.ts +26 -26
  217. package/src/components/recurring-invoices/create-recurring-invoice-form/locales/nb.ts +26 -26
  218. package/src/components/recurring-invoices/create-recurring-invoice-form/locales/sk.ts +25 -25
  219. package/src/components/recurring-invoices/create-recurring-invoice-form/locales/sv.ts +26 -26
  220. package/src/components/recurring-invoices/list/list-row-actions.tsx +9 -1
  221. package/src/components/recurring-invoices/list/list-table.tsx +53 -5
  222. package/src/components/recurring-invoices/list/locales/bg.ts +4 -0
  223. package/src/components/recurring-invoices/list/locales/cs.ts +4 -0
  224. package/src/components/recurring-invoices/list/locales/de.ts +4 -0
  225. package/src/components/recurring-invoices/list/locales/en.ts +4 -0
  226. package/src/components/recurring-invoices/list/locales/es.ts +4 -0
  227. package/src/components/recurring-invoices/list/locales/et.ts +4 -0
  228. package/src/components/recurring-invoices/list/locales/fi.ts +4 -0
  229. package/src/components/recurring-invoices/list/locales/fr.ts +4 -0
  230. package/src/components/recurring-invoices/list/locales/hr.ts +4 -0
  231. package/src/components/recurring-invoices/list/locales/is.ts +4 -0
  232. package/src/components/recurring-invoices/list/locales/it.ts +4 -0
  233. package/src/components/recurring-invoices/list/locales/nb.ts +4 -0
  234. package/src/components/recurring-invoices/list/locales/nl.ts +4 -0
  235. package/src/components/recurring-invoices/list/locales/pl.ts +4 -0
  236. package/src/components/recurring-invoices/list/locales/pt.ts +4 -0
  237. package/src/components/recurring-invoices/list/locales/sk.ts +4 -0
  238. package/src/components/recurring-invoices/list/locales/sl.ts +4 -0
  239. package/src/components/recurring-invoices/list/locales/sv.ts +4 -0
  240. package/src/components/tax-reports/slovenia-tax-profile-step.tsx +4 -1
  241. package/src/components/tax-reports/slovenia-yearly-export-form.tsx +3 -0
  242. package/src/components/tax-reports/slovenia-yearly-review-step.tsx +2 -1
  243. package/src/components/ui/form.tsx +5 -13
  244. package/src/components/ui/select.tsx +0 -1
  245. package/src/components/ui/sidebar.tsx +2 -2
  246. package/src/generate-schemas.ts +132 -99
  247. package/src/generated/schemas/acceptentityinvitation_body.ts +4 -3
  248. package/src/generated/schemas/accountwebhook.ts +4 -8
  249. package/src/generated/schemas/addentityuser_body.ts +4 -3
  250. package/src/generated/schemas/advanceinvoice.ts +167 -168
  251. package/src/generated/schemas/authorizeshopify_body.ts +4 -3
  252. package/src/generated/schemas/calculatedocumentpreview.ts +120 -0
  253. package/src/generated/schemas/checktransactiontype.ts +35 -0
  254. package/src/generated/schemas/creditnote.ts +203 -76
  255. package/src/generated/schemas/customadvanceinvoice.ts +172 -165
  256. package/src/generated/schemas/customcreditnote.ts +183 -155
  257. package/src/generated/schemas/customdeliverynote.ts +166 -0
  258. package/src/generated/schemas/customer.ts +4 -8
  259. package/src/generated/schemas/customestimate.ts +123 -97
  260. package/src/generated/schemas/customincomingpurchasedocument.ts +142 -0
  261. package/src/generated/schemas/custominvoice.ts +183 -154
  262. package/src/generated/schemas/deliverynote.ts +124 -79
  263. package/src/generated/schemas/einvoice.ts +19 -0
  264. package/src/generated/schemas/einvoicingsettings.ts +21 -0
  265. package/src/generated/schemas/einvoicingsupplier.ts +45 -0
  266. package/src/generated/schemas/entity.ts +44 -40
  267. package/src/generated/schemas/entityapikey.ts +1 -3
  268. package/src/generated/schemas/entityuserrole.ts +1 -3
  269. package/src/generated/schemas/estimate.ts +120 -127
  270. package/src/generated/schemas/exportsloveniavodxml_body.ts +4 -3
  271. package/src/generated/schemas/exportsloveniayearlynormiranireport_body.ts +4 -3
  272. package/src/generated/schemas/finadevice.ts +15 -0
  273. package/src/generated/schemas/finalizedocument.ts +52 -0
  274. package/src/generated/schemas/finapremise.ts +15 -0
  275. package/src/generated/schemas/finasettings.ts +1 -3
  276. package/src/generated/schemas/furselectronicdevice.ts +15 -0
  277. package/src/generated/schemas/furssettings.ts +1 -3
  278. package/src/generated/schemas/image.ts +15 -0
  279. package/src/generated/schemas/incomingpurchasedocument.ts +7 -27
  280. package/src/generated/schemas/incomingpurchasedocumentattachment.ts +15 -0
  281. package/src/generated/schemas/incomingpurchasedocumentpayment.ts +1 -3
  282. package/src/generated/schemas/index.ts +20 -5
  283. package/src/generated/schemas/invoice.ts +182 -183
  284. package/src/generated/schemas/item.ts +6 -10
  285. package/src/generated/schemas/legacymigrationauth.ts +18 -0
  286. package/src/generated/schemas/me.ts +2 -24
  287. package/src/generated/schemas/migrationjob.ts +20 -0
  288. package/src/generated/schemas/order.ts +4 -8
  289. package/src/generated/schemas/orderintegration.ts +4 -8
  290. package/src/generated/schemas/payment.ts +4 -8
  291. package/src/generated/schemas/ptatcudseries.ts +1 -3
  292. package/src/generated/schemas/queryentitystats.ts +15 -0
  293. package/src/generated/schemas/recurringinvoice.ts +4 -8
  294. package/src/generated/schemas/registerfursmovablepremise_body.ts +1 -3
  295. package/src/generated/schemas/registerfursrealestatepremise_body.ts +1 -3
  296. package/src/generated/schemas/renderadvanceinvoicepreview_body.ts +10 -16
  297. package/src/generated/schemas/rendercreditnotepreview_body.ts +10 -16
  298. package/src/generated/schemas/renderdeliverynotepreview_body.ts +9 -5
  299. package/src/generated/schemas/renderestimatepreview_body.ts +11 -7
  300. package/src/generated/schemas/renderinvoicepreview_body.ts +10 -16
  301. package/src/generated/schemas/reviewsloveniayearlynormiranireport.ts +15 -0
  302. package/src/generated/schemas/searcheinvoicingcustomer.ts +18 -0
  303. package/src/generated/schemas/senddocument_body.ts +1 -3
  304. package/src/generated/schemas/sendemail_body.ts +2 -24
  305. package/src/generated/schemas/sloveniataxprofile.ts +8 -10
  306. package/src/generated/schemas/starteslogexport_body.ts +4 -3
  307. package/src/generated/schemas/startpdfexport_body.ts +8 -87
  308. package/src/generated/schemas/stripeappconnect_body.ts +4 -3
  309. package/src/generated/schemas/stripeappcreateinvoice_body.ts +4 -6
  310. package/src/generated/schemas/stripeappmarketplaceauthorize.ts +15 -0
  311. package/src/generated/schemas/stripeappupdatesettings_body.ts +6 -6
  312. package/src/generated/schemas/supplier.ts +4 -8
  313. package/src/generated/schemas/syncshopifyorders_body.ts +4 -3
  314. package/src/generated/schemas/tax.ts +6 -8
  315. package/src/generated/schemas/uploadfile_body.ts +1 -3
  316. package/src/generated/schemas/uploadfurscertificate_body.ts +6 -6
  317. package/src/generated/schemas/userfinasettings.ts +1 -3
  318. package/src/generated/schemas/userfurssettings.ts +1 -3
  319. package/src/generated/schemas/userptsettings.ts +1 -3
  320. package/src/generated/schemas/voidinvoice_body.ts +8 -3
  321. package/src/generated/schemas/webhook.ts +4 -8
  322. package/src/generated/schemas/wlsubscriptionbillingemail.ts +17 -0
  323. package/src/hooks/use-duplicate-document.ts +74 -32
  324. package/src/lib/date-only.ts +58 -0
  325. package/src/lib/document-display.ts +18 -0
  326. package/src/lib/payment-display.ts +5 -3
  327. package/src/lib/schemas/shared.ts +11 -0
  328. package/src/providers/wl-subscription-provider.tsx +5 -0
  329. package/src/generated/schemas/account_webhook.ts +0 -43
  330. package/src/generated/schemas/previewadvanceinvoice_body.ts +0 -354
  331. package/src/generated/schemas/previewestimate_body.ts +0 -309
  332. package/src/generated/schemas/registerfinamovablepremise_body.ts +0 -26
  333. package/src/generated/schemas/registerfinarealestatepremise_body.ts +0 -37
  334. package/src/generated/schemas/renderdocument_body.ts +0 -594
@@ -0,0 +1,58 @@
1
+ const DATE_ONLY_PATTERN = /^\d{4}-\d{2}-\d{2}$/;
2
+ const LEADING_DATE_ONLY_PATTERN = /^(\d{4}-\d{2}-\d{2})(?:$|T)/;
3
+
4
+ export function toLocalDateOnlyString(date: Date): string {
5
+ const year = date.getFullYear();
6
+ const month = String(date.getMonth() + 1).padStart(2, "0");
7
+ const day = String(date.getDate()).padStart(2, "0");
8
+ return `${year}-${month}-${day}`;
9
+ }
10
+
11
+ export function normalizeDateOnlyInput(value: string | undefined): string | undefined {
12
+ if (!value) return undefined;
13
+ if (DATE_ONLY_PATTERN.test(value)) return value;
14
+
15
+ const utcMidnightMatch = value.match(/^(\d{4}-\d{2}-\d{2})T00:00:00(?:\.000)?Z$/);
16
+ if (utcMidnightMatch) {
17
+ return utcMidnightMatch[1];
18
+ }
19
+
20
+ const date = new Date(value);
21
+ if (Number.isNaN(date.getTime())) {
22
+ return value;
23
+ }
24
+
25
+ return toLocalDateOnlyString(date);
26
+ }
27
+
28
+ export function toUtcMidnightIsoString(value: string | undefined): string | undefined {
29
+ const dateOnly = normalizeDateOnlyInput(value);
30
+ return dateOnly ? `${dateOnly}T00:00:00.000Z` : undefined;
31
+ }
32
+
33
+ export function extractDateOnlyToken(value: string | undefined): string | undefined {
34
+ return value?.match(LEADING_DATE_ONLY_PATTERN)?.[1];
35
+ }
36
+
37
+ export function formatDateOnlyForDisplay(
38
+ value: Date | string | null | undefined,
39
+ locale: string,
40
+ options: Intl.DateTimeFormatOptions = {
41
+ year: "numeric",
42
+ month: "short",
43
+ day: "numeric",
44
+ },
45
+ ): string {
46
+ if (!value) return "-";
47
+
48
+ const normalized = typeof value === "string" ? normalizeDateOnlyInput(value) ?? extractDateOnlyToken(value) : undefined;
49
+ const dateOnly = normalized ?? (value instanceof Date ? toLocalDateOnlyString(value) : undefined);
50
+
51
+ if (!dateOnly) {
52
+ return typeof value === "string" ? value : "-";
53
+ }
54
+
55
+ return new Intl.DateTimeFormat(locale, { ...options, timeZone: "UTC" }).format(
56
+ new Date(`${dateOnly}T00:00:00.000Z`),
57
+ );
58
+ }
@@ -0,0 +1,18 @@
1
+ type TranslateFn = (key: string) => string;
2
+
3
+ type DraftDocumentLike = {
4
+ number?: string | null;
5
+ is_draft?: boolean | null;
6
+ };
7
+
8
+ export function isBackendDraftNumber(number: string | null | undefined): boolean {
9
+ return typeof number === "string" && number.trim().toLowerCase().startsWith("draft-");
10
+ }
11
+
12
+ export function getDisplayDocumentNumber(document: DraftDocumentLike, t: TranslateFn, fallback = "-"): string {
13
+ if (document.is_draft || isBackendDraftNumber(document.number)) {
14
+ return t("Draft");
15
+ }
16
+
17
+ return document.number?.trim() || fallback;
18
+ }
@@ -1,3 +1,5 @@
1
+ import { getDisplayDocumentNumber } from "@/ui/lib/document-display";
2
+
1
3
  type TranslateFn = (key: string) => string;
2
4
 
3
5
  const AUTO_APPLIED_CREDIT_NOTE_TEMPLATE = "Auto-applied credit note for voided invoice {number}";
@@ -62,7 +64,7 @@ export function getPaymentDocumentDisplay(payment: PaymentDocumentLike): Payment
62
64
  if (payment.Invoice) {
63
65
  return {
64
66
  id: payment.Invoice.id,
65
- label: payment.Invoice.number,
67
+ label: getDisplayDocumentNumber(payment.Invoice, (key) => key),
66
68
  isNavigable: true,
67
69
  };
68
70
  }
@@ -70,7 +72,7 @@ export function getPaymentDocumentDisplay(payment: PaymentDocumentLike): Payment
70
72
  if (payment.CreditNote) {
71
73
  return {
72
74
  id: payment.CreditNote.id,
73
- label: payment.CreditNote.number,
75
+ label: getDisplayDocumentNumber(payment.CreditNote, (key) => key),
74
76
  isNavigable: true,
75
77
  };
76
78
  }
@@ -78,7 +80,7 @@ export function getPaymentDocumentDisplay(payment: PaymentDocumentLike): Payment
78
80
  if (payment.AdvanceInvoice) {
79
81
  return {
80
82
  id: payment.AdvanceInvoice.id,
81
- label: payment.AdvanceInvoice.number,
83
+ label: getDisplayDocumentNumber(payment.AdvanceInvoice, (key) => key),
82
84
  isNavigable: true,
83
85
  };
84
86
  }
@@ -44,6 +44,17 @@ export const discountSchema = z.object({
44
44
 
45
45
  export type DiscountFormData = z.infer<typeof discountSchema>;
46
46
 
47
+ export function normalizeLineItemDiscountsForForm(
48
+ discounts?: Array<{ value: number; type?: "percent" | "amount" | null }> | null,
49
+ ): DiscountFormData[] {
50
+ return (
51
+ discounts?.map((discount) => ({
52
+ value: discount.value,
53
+ type: discount.type ?? undefined,
54
+ })) ?? []
55
+ );
56
+ }
57
+
47
58
  /**
48
59
  * Line item schema with UI-only is_gross_price flag.
49
60
  *
@@ -59,6 +59,7 @@ export type CurrentSubscription = {
59
59
  payment_provider: "stripe" | "paypal" | "bank" | "braintree";
60
60
  bank_reference: string | null;
61
61
  billing_email: string | null;
62
+ coupon_code: string | null;
62
63
  trial_ends_at: string | null;
63
64
  trial_days_remaining: number | null;
64
65
  cancel_at: string | null;
@@ -119,6 +120,7 @@ type WLSubscriptionContextType = {
119
120
  activateSubscription: (
120
121
  planSlug: string,
121
122
  billingInterval: "monthly" | "yearly",
123
+ couponCode?: string | null,
122
124
  ) => Promise<{ invoice_id?: string | null; scheduled?: boolean }>;
123
125
  refresh: () => Promise<void>;
124
126
  };
@@ -151,6 +153,7 @@ const DEFAULT_SUBSCRIPTION: CurrentSubscription = {
151
153
  payment_provider: "stripe",
152
154
  bank_reference: null,
153
155
  billing_email: null,
156
+ coupon_code: null,
154
157
  trial_ends_at: null,
155
158
  trial_days_remaining: null,
156
159
  cancel_at: null,
@@ -378,6 +381,7 @@ export function WLSubscriptionProvider({ children, apiBaseUrl }: WLSubscriptionP
378
381
  async (
379
382
  planSlug: string,
380
383
  billingInterval: "monthly" | "yearly",
384
+ couponCode?: string | null,
381
385
  ): Promise<{ invoice_id?: string | null; scheduled?: boolean }> => {
382
386
  if (!entityId || !accessToken) {
383
387
  throw new Error("Not authenticated");
@@ -394,6 +398,7 @@ export function WLSubscriptionProvider({ children, apiBaseUrl }: WLSubscriptionP
394
398
  body: JSON.stringify({
395
399
  plan_slug: planSlug,
396
400
  billing_interval: billingInterval,
401
+ ...(couponCode !== undefined ? { coupon_code: couponCode } : {}),
397
402
  }),
398
403
  });
399
404
 
@@ -1,43 +0,0 @@
1
- /**
2
- * This file was manually added to mirror generated webhook account schemas.
3
- * Regenerate schemas when the generator supports account-webhooks.
4
- */
5
-
6
- import { z } from 'zod';
7
-
8
- const accountWebhookEvents = z.enum([
9
- "white_label_subscription.subscribed",
10
- "white_label_subscription.upgraded",
11
- "white_label_subscription.downgrade_scheduled",
12
- "white_label_subscription.downgraded",
13
- "white_label_subscription.cancellation_scheduled",
14
- "white_label_subscription.cancelled",
15
- "white_label_subscription.renewed",
16
- "white_label_subscription.expired",
17
- "white_label_subscription.payment_failed",
18
- ]);
19
-
20
- const createAccountWebhookSchemaDefinition = z.object({
21
- url: z.string().max(2048).url(),
22
- description: z.string().max(500).optional(),
23
- events: z.array(accountWebhookEvents).min(1),
24
- active: z.boolean().optional().default(true),
25
- metadata: z.union([z.record(z.string(), z.any()), z.null()]).optional(),
26
- });
27
-
28
- export type CreateAccountWebhookSchema = z.infer<typeof createAccountWebhookSchemaDefinition>;
29
-
30
- const updateAccountWebhookSchemaDefinition = z
31
- .object({
32
- url: z.string().max(2048).url(),
33
- description: z.union([z.string().max(500), z.null()]),
34
- events: z.array(accountWebhookEvents).min(1),
35
- active: z.boolean(),
36
- metadata: z.union([z.record(z.string(), z.any()), z.null()]),
37
- })
38
- .partial();
39
-
40
- export type UpdateAccountWebhookSchema = z.infer<typeof updateAccountWebhookSchemaDefinition>;
41
-
42
- export const createAccountWebhookSchema = createAccountWebhookSchemaDefinition;
43
- export const updateAccountWebhookSchema = updateAccountWebhookSchemaDefinition;
@@ -1,354 +0,0 @@
1
- /**
2
- * This file was automatically generated using 'bun generate-schemas'.
3
- * Do not edit this file manually. To update, run the generator again.
4
- * @generated
5
- */
6
-
7
- import { z } from 'zod';
8
-
9
- // Schemas for previewadvanceinvoice_body endpoints
10
-
11
- // Dependency schema for previewadvanceinvoice_body
12
- const LineDiscount = z.object({
13
- value: z.number().gte(0),
14
- type: z.enum(["percent", "amount"]).optional().default("percent"),
15
- });
16
-
17
-
18
- // Dependency schema for previewadvanceinvoice_body
19
- const CompleteDocumentPreview = z.object({
20
- is_draft: z.boolean().optional(),
21
- date: z
22
- .string()
23
- .regex(/^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2}(\.\d{3})?Z?)?$/)
24
- .optional(),
25
- issuer: z
26
- .object({
27
- name: z.union([z.string(), z.null()]),
28
- email: z.union([z.string(), z.null()]),
29
- address: z.union([z.string(), z.null()]),
30
- address_2: z.union([z.string(), z.null()]),
31
- post_code: z.union([z.string(), z.null()]),
32
- city: z.union([z.string(), z.null()]),
33
- state: z.union([z.string(), z.null()]),
34
- country: z.union([z.string(), z.null()]),
35
- country_code: z.union([z.string(), z.null()]),
36
- tax_number: z.union([z.string(), z.null()]),
37
- bank_account: z.union([
38
- z
39
- .object({
40
- type: z
41
- .enum(["iban", "us_domestic", "uk_domestic", "other"])
42
- .default("iban"),
43
- name: z.string(),
44
- bank_name: z.string(),
45
- iban: z.string(),
46
- account_number: z.string(),
47
- bic: z.string(),
48
- routing_number: z.string(),
49
- sort_code: z.string(),
50
- is_default: z.boolean(),
51
- })
52
- .partial()
53
- .passthrough(),
54
- z.null(),
55
- ]),
56
- })
57
- .partial()
58
- .passthrough()
59
- .optional(),
60
- customer_id: z.union([z.string(), z.null()]).optional(),
61
- customer: z
62
- .union([
63
- z
64
- .object({
65
- name: z.union([z.string(), z.null()]),
66
- email: z.union([z.string(), z.null()]),
67
- address: z.union([z.string(), z.null()]),
68
- address_2: z.union([z.string(), z.null()]),
69
- post_code: z.union([z.string(), z.null()]),
70
- city: z.union([z.string(), z.null()]),
71
- state: z.union([z.string(), z.null()]),
72
- country: z.union([z.string(), z.null()]),
73
- country_code: z.union([z.string(), z.null()]),
74
- tax_number: z.union([z.string(), z.null()]),
75
- bank_account: z.union([
76
- z
77
- .object({
78
- type: z
79
- .enum(["iban", "us_domestic", "uk_domestic", "other"])
80
- .default("iban"),
81
- name: z.string(),
82
- bank_name: z.string(),
83
- iban: z.string(),
84
- account_number: z.string(),
85
- bic: z.string(),
86
- routing_number: z.string(),
87
- sort_code: z.string(),
88
- is_default: z.boolean(),
89
- })
90
- .partial()
91
- .passthrough(),
92
- z.null(),
93
- ]),
94
- save_customer: z.boolean().default(true),
95
- })
96
- .partial()
97
- .passthrough(),
98
- z.null(),
99
- ])
100
- .optional(),
101
- note: z.union([z.string(), z.null()]).optional(),
102
- payment_terms: z.union([z.string(), z.null()]).optional(),
103
- currency_code: z.string().max(3).optional(),
104
- metadata: z
105
- .union([
106
- z.string(),
107
- z.number(),
108
- z.boolean(),
109
- z.null(),
110
- z.object({}).partial().passthrough(),
111
- z.array(z.unknown()),
112
- z.null(),
113
- ])
114
- .optional(),
115
- date_due: z.union([z.string(), z.null()]).optional(),
116
- date_service: z.union([z.string(), z.null()]).optional(),
117
- date_service_to: z.union([z.string(), z.null()]).optional(),
118
- items: z
119
- .array(
120
- z.object({
121
- name: z.string().min(1),
122
- description: z.union([z.string(), z.null()]).optional(),
123
- price: z.number().optional(),
124
- gross_price: z.number().optional(),
125
- quantity: z.number().gte(-140737488355328).lte(140737488355327),
126
- unit: z.union([z.string(), z.null()]).optional(),
127
- taxes: z
128
- .array(
129
- z
130
- .object({
131
- rate: z.number(),
132
- tax_id: z.string(),
133
- classification: z.string(),
134
- reverse_charge: z.boolean(),
135
- amount: z.number(),
136
- })
137
- .partial()
138
- )
139
- .optional(),
140
- discounts: z.array(LineDiscount).max(5).optional(),
141
- metadata: z
142
- .union([
143
- z.string(),
144
- z.number(),
145
- z.boolean(),
146
- z.null(),
147
- z.object({}).partial().passthrough(),
148
- z.array(z.unknown()),
149
- z.null(),
150
- ])
151
- .optional(),
152
- })
153
- )
154
- .min(1),
155
- linked_documents: z.array(z.string().min(1)).optional(),
156
- payment: z
157
- .union([
158
- z.object({
159
- credit_note_id: z.union([z.string(), z.null()]).optional(),
160
- advance_invoice_id: z.union([z.string(), z.null()]).optional(),
161
- amount: z.number().gt(0).optional(),
162
- type: z.string().max(20),
163
- date: z.string().optional(),
164
- reference: z.union([z.string(), z.null()]).optional(),
165
- note: z.union([z.string(), z.null()]).optional(),
166
- metadata: z.union([z.record(z.string(), z.any()), z.null()]).optional(),
167
- }),
168
- z.null(),
169
- ])
170
- .optional(),
171
- furs: z
172
- .union([
173
- z
174
- .object({
175
- business_premise_name: z.string().min(1),
176
- electronic_device_name: z.string().min(1),
177
- operator_tax_number: z.string(),
178
- operator_label: z.string(),
179
- skip: z.boolean(),
180
- })
181
- .partial(),
182
- z.null(),
183
- ])
184
- .optional(),
185
- eslog: z
186
- .union([
187
- z
188
- .object({ validation_enabled: z.union([z.boolean(), z.null()]) })
189
- .partial()
190
- .passthrough(),
191
- z.null(),
192
- ])
193
- .optional(),
194
- });
195
-
196
-
197
- // Dependency schema for previewadvanceinvoice_body
198
- const PartialDocumentPreview = z.object({
199
- is_draft: z.boolean().optional(),
200
- date: z
201
- .string()
202
- .regex(/^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2}(\.\d{3})?Z?)?$/)
203
- .optional(),
204
- issuer: z
205
- .object({
206
- name: z.union([z.string(), z.null()]),
207
- email: z.union([z.string(), z.null()]),
208
- address: z.union([z.string(), z.null()]),
209
- address_2: z.union([z.string(), z.null()]),
210
- post_code: z.union([z.string(), z.null()]),
211
- city: z.union([z.string(), z.null()]),
212
- state: z.union([z.string(), z.null()]),
213
- country: z.union([z.string(), z.null()]),
214
- country_code: z.union([z.string(), z.null()]),
215
- tax_number: z.union([z.string(), z.null()]),
216
- bank_account: z.union([
217
- z
218
- .object({
219
- type: z
220
- .enum(["iban", "us_domestic", "uk_domestic", "other"])
221
- .default("iban"),
222
- name: z.string(),
223
- bank_name: z.string(),
224
- iban: z.string(),
225
- account_number: z.string(),
226
- bic: z.string(),
227
- routing_number: z.string(),
228
- sort_code: z.string(),
229
- is_default: z.boolean(),
230
- })
231
- .partial()
232
- .passthrough(),
233
- z.null(),
234
- ]),
235
- })
236
- .partial()
237
- .passthrough()
238
- .optional(),
239
- customer_id: z.union([z.string(), z.null()]).optional(),
240
- customer: z
241
- .union([
242
- z
243
- .object({
244
- name: z.union([z.string(), z.null()]),
245
- email: z.union([z.string(), z.null()]),
246
- address: z.union([z.string(), z.null()]),
247
- address_2: z.union([z.string(), z.null()]),
248
- post_code: z.union([z.string(), z.null()]),
249
- city: z.union([z.string(), z.null()]),
250
- state: z.union([z.string(), z.null()]),
251
- country: z.union([z.string(), z.null()]),
252
- country_code: z.union([z.string(), z.null()]),
253
- tax_number: z.union([z.string(), z.null()]),
254
- bank_account: z.union([
255
- z
256
- .object({
257
- type: z
258
- .enum(["iban", "us_domestic", "uk_domestic", "other"])
259
- .default("iban"),
260
- name: z.string(),
261
- bank_name: z.string(),
262
- iban: z.string(),
263
- account_number: z.string(),
264
- bic: z.string(),
265
- routing_number: z.string(),
266
- sort_code: z.string(),
267
- is_default: z.boolean(),
268
- })
269
- .partial()
270
- .passthrough(),
271
- z.null(),
272
- ]),
273
- save_customer: z.boolean().default(true),
274
- })
275
- .partial()
276
- .passthrough(),
277
- z.null(),
278
- ])
279
- .optional(),
280
- note: z.union([z.string(), z.null()]).optional(),
281
- payment_terms: z.union([z.string(), z.null()]).optional(),
282
- currency_code: z.string().max(3).optional(),
283
- metadata: z
284
- .union([
285
- z.string(),
286
- z.number(),
287
- z.boolean(),
288
- z.null(),
289
- z.object({}).partial().passthrough(),
290
- z.array(z.unknown()),
291
- z.null(),
292
- ])
293
- .optional(),
294
- date_due: z.union([z.string(), z.null()]).optional(),
295
- date_service: z.union([z.string(), z.null()]).optional(),
296
- date_service_to: z.union([z.string(), z.null()]).optional(),
297
- items: z
298
- .array(
299
- z
300
- .object({
301
- name: z.string(),
302
- quantity: z.number(),
303
- price: z.number(),
304
- gross_price: z.number(),
305
- description: z.string(),
306
- taxes: z.array(
307
- z
308
- .object({ rate: z.number(), tax_id: z.string() })
309
- .partial()
310
- .passthrough()
311
- ),
312
- metadata: z.record(z.string(), z.any()),
313
- })
314
- .partial()
315
- .passthrough()
316
- )
317
- .min(1),
318
- linked_documents: z.array(z.string().min(1)).optional(),
319
- furs: z
320
- .union([
321
- z
322
- .object({
323
- business_premise_name: z.string().min(1),
324
- electronic_device_name: z.string().min(1),
325
- operator_tax_number: z.string(),
326
- operator_label: z.string(),
327
- skip: z.boolean(),
328
- })
329
- .partial(),
330
- z.null(),
331
- ])
332
- .optional(),
333
- eslog: z
334
- .union([
335
- z
336
- .object({ validation_enabled: z.union([z.boolean(), z.null()]) })
337
- .partial()
338
- .passthrough(),
339
- z.null(),
340
- ])
341
- .optional(),
342
- });
343
-
344
-
345
- // Schema for preview advanceinvoice operation
346
- const previewAdvanceInvoiceSchemaDefinition = z.union([
347
- PartialDocumentPreview,
348
- CompleteDocumentPreview,
349
- ]);
350
-
351
- // Type for preview advanceinvoice operation
352
- export type PreviewAdvanceInvoiceSchema = z.infer<typeof previewAdvanceInvoiceSchemaDefinition>;
353
-
354
- export const previewAdvanceInvoiceSchema = previewAdvanceInvoiceSchemaDefinition;