@spaceinvoices/react-ui 0.4.8 → 0.4.11

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 (276) hide show
  1. package/README.md +24 -8
  2. package/cli/dist/index.js +89 -26
  3. package/package.json +4 -1
  4. package/spaceinvoices.schema.json +6 -1
  5. package/src/common/autocomplete.tsx +69 -6
  6. package/src/components/advance-invoices/create/create-advance-invoice-form.tsx +124 -285
  7. package/src/components/advance-invoices/list/list-table.tsx +10 -3
  8. package/src/components/advance-invoices/list/locales/de.ts +2 -0
  9. package/src/components/advance-invoices/list/locales/en.ts +1 -0
  10. package/src/components/advance-invoices/list/locales/es.ts +1 -0
  11. package/src/components/advance-invoices/list/locales/fr.ts +1 -0
  12. package/src/components/advance-invoices/list/locales/hr.ts +1 -0
  13. package/src/components/advance-invoices/list/locales/it.ts +1 -0
  14. package/src/components/advance-invoices/list/locales/nl.ts +1 -0
  15. package/src/components/advance-invoices/list/locales/pl.ts +1 -0
  16. package/src/components/advance-invoices/list/locales/pt.ts +1 -0
  17. package/src/components/advance-invoices/list/locales/sl.ts +1 -0
  18. package/src/components/advance-invoices/list/use-advance-invoice-download.ts +1 -12
  19. package/src/components/credit-notes/create/create-credit-note-form.tsx +116 -238
  20. package/src/components/credit-notes/list/list-table.tsx +6 -3
  21. package/src/components/credit-notes/list/use-credit-note-download.ts +1 -12
  22. package/src/components/customers/customer-autocomplete.tsx +64 -11
  23. package/src/components/customers/customer-list-table/customer-list-table.tsx +3 -2
  24. package/src/components/dashboard/collection-rate-card/collection-rate-card.tsx +9 -1
  25. package/src/components/dashboard/collection-rate-card/locales/bg.ts +3 -0
  26. package/src/components/dashboard/collection-rate-card/locales/cs.ts +3 -0
  27. package/src/components/dashboard/collection-rate-card/locales/et.ts +3 -0
  28. package/src/components/dashboard/collection-rate-card/locales/fi.ts +3 -0
  29. package/src/components/dashboard/collection-rate-card/locales/is.ts +3 -0
  30. package/src/components/dashboard/collection-rate-card/locales/nb.ts +3 -0
  31. package/src/components/dashboard/collection-rate-card/locales/sk.ts +3 -0
  32. package/src/components/dashboard/collection-rate-card/locales/sv.ts +3 -0
  33. package/src/components/dashboard/invoice-status-chart/invoice-status-chart.tsx +10 -2
  34. package/src/components/dashboard/invoice-status-chart/locales/bg.ts +10 -0
  35. package/src/components/dashboard/invoice-status-chart/locales/cs.ts +10 -0
  36. package/src/components/dashboard/invoice-status-chart/locales/de.ts +1 -0
  37. package/src/components/dashboard/invoice-status-chart/locales/es.ts +1 -0
  38. package/src/components/dashboard/invoice-status-chart/locales/et.ts +10 -0
  39. package/src/components/dashboard/invoice-status-chart/locales/fi.ts +10 -0
  40. package/src/components/dashboard/invoice-status-chart/locales/fr.ts +1 -0
  41. package/src/components/dashboard/invoice-status-chart/locales/hr.ts +1 -0
  42. package/src/components/dashboard/invoice-status-chart/locales/is.ts +10 -0
  43. package/src/components/dashboard/invoice-status-chart/locales/it.ts +1 -0
  44. package/src/components/dashboard/invoice-status-chart/locales/nb.ts +10 -0
  45. package/src/components/dashboard/invoice-status-chart/locales/nl.ts +1 -0
  46. package/src/components/dashboard/invoice-status-chart/locales/pl.ts +1 -0
  47. package/src/components/dashboard/invoice-status-chart/locales/pt.ts +1 -0
  48. package/src/components/dashboard/invoice-status-chart/locales/sk.ts +10 -0
  49. package/src/components/dashboard/invoice-status-chart/locales/sl.ts +1 -0
  50. package/src/components/dashboard/invoice-status-chart/locales/sv.ts +10 -0
  51. package/src/components/dashboard/payment-methods-chart/locales/bg.ts +12 -0
  52. package/src/components/dashboard/payment-methods-chart/locales/cs.ts +12 -0
  53. package/src/components/dashboard/payment-methods-chart/locales/et.ts +12 -0
  54. package/src/components/dashboard/payment-methods-chart/locales/fi.ts +12 -0
  55. package/src/components/dashboard/payment-methods-chart/locales/is.ts +12 -0
  56. package/src/components/dashboard/payment-methods-chart/locales/nb.ts +12 -0
  57. package/src/components/dashboard/payment-methods-chart/locales/sk.ts +12 -0
  58. package/src/components/dashboard/payment-methods-chart/locales/sv.ts +12 -0
  59. package/src/components/dashboard/payment-methods-chart/payment-methods-chart.tsx +9 -1
  60. package/src/components/dashboard/payment-trend-chart/locales/bg.ts +6 -0
  61. package/src/components/dashboard/payment-trend-chart/locales/cs.ts +6 -0
  62. package/src/components/dashboard/payment-trend-chart/locales/de.ts +1 -0
  63. package/src/components/dashboard/payment-trend-chart/locales/es.ts +1 -0
  64. package/src/components/dashboard/payment-trend-chart/locales/et.ts +6 -0
  65. package/src/components/dashboard/payment-trend-chart/locales/fi.ts +6 -0
  66. package/src/components/dashboard/payment-trend-chart/locales/fr.ts +1 -0
  67. package/src/components/dashboard/payment-trend-chart/locales/hr.ts +1 -0
  68. package/src/components/dashboard/payment-trend-chart/locales/is.ts +6 -0
  69. package/src/components/dashboard/payment-trend-chart/locales/it.ts +1 -0
  70. package/src/components/dashboard/payment-trend-chart/locales/nb.ts +6 -0
  71. package/src/components/dashboard/payment-trend-chart/locales/nl.ts +1 -0
  72. package/src/components/dashboard/payment-trend-chart/locales/pl.ts +1 -0
  73. package/src/components/dashboard/payment-trend-chart/locales/pt.ts +1 -0
  74. package/src/components/dashboard/payment-trend-chart/locales/sk.ts +6 -0
  75. package/src/components/dashboard/payment-trend-chart/locales/sl.ts +1 -0
  76. package/src/components/dashboard/payment-trend-chart/locales/sv.ts +6 -0
  77. package/src/components/dashboard/payment-trend-chart/payment-trend-chart.tsx +15 -8
  78. package/src/components/dashboard/revenue-trend-chart/locales/bg.ts +6 -0
  79. package/src/components/dashboard/revenue-trend-chart/locales/cs.ts +6 -0
  80. package/src/components/dashboard/revenue-trend-chart/locales/de.ts +1 -0
  81. package/src/components/dashboard/revenue-trend-chart/locales/es.ts +1 -0
  82. package/src/components/dashboard/revenue-trend-chart/locales/et.ts +6 -0
  83. package/src/components/dashboard/revenue-trend-chart/locales/fi.ts +6 -0
  84. package/src/components/dashboard/revenue-trend-chart/locales/fr.ts +1 -0
  85. package/src/components/dashboard/revenue-trend-chart/locales/hr.ts +1 -0
  86. package/src/components/dashboard/revenue-trend-chart/locales/is.ts +6 -0
  87. package/src/components/dashboard/revenue-trend-chart/locales/it.ts +1 -0
  88. package/src/components/dashboard/revenue-trend-chart/locales/nb.ts +6 -0
  89. package/src/components/dashboard/revenue-trend-chart/locales/nl.ts +1 -0
  90. package/src/components/dashboard/revenue-trend-chart/locales/pl.ts +1 -0
  91. package/src/components/dashboard/revenue-trend-chart/locales/pt.ts +1 -0
  92. package/src/components/dashboard/revenue-trend-chart/locales/sk.ts +6 -0
  93. package/src/components/dashboard/revenue-trend-chart/locales/sl.ts +1 -0
  94. package/src/components/dashboard/revenue-trend-chart/locales/sv.ts +6 -0
  95. package/src/components/dashboard/revenue-trend-chart/revenue-trend-chart.tsx +15 -8
  96. package/src/components/dashboard/tax-collected-card/locales.ts +110 -0
  97. package/src/components/dashboard/tax-collected-card/tax-collected-card.tsx +8 -2
  98. package/src/components/dashboard/tax-collected-card/use-tax-collected.ts +4 -4
  99. package/src/components/dashboard/top-customers-chart/locales/bg.ts +7 -0
  100. package/src/components/dashboard/top-customers-chart/locales/cs.ts +7 -0
  101. package/src/components/dashboard/top-customers-chart/locales/de.ts +2 -0
  102. package/src/components/dashboard/top-customers-chart/locales/es.ts +2 -0
  103. package/src/components/dashboard/top-customers-chart/locales/et.ts +7 -0
  104. package/src/components/dashboard/top-customers-chart/locales/fi.ts +7 -0
  105. package/src/components/dashboard/top-customers-chart/locales/fr.ts +2 -0
  106. package/src/components/dashboard/top-customers-chart/locales/hr.ts +2 -0
  107. package/src/components/dashboard/top-customers-chart/locales/is.ts +7 -0
  108. package/src/components/dashboard/top-customers-chart/locales/it.ts +2 -0
  109. package/src/components/dashboard/top-customers-chart/locales/nb.ts +7 -0
  110. package/src/components/dashboard/top-customers-chart/locales/nl.ts +2 -0
  111. package/src/components/dashboard/top-customers-chart/locales/pl.ts +2 -0
  112. package/src/components/dashboard/top-customers-chart/locales/pt.ts +2 -0
  113. package/src/components/dashboard/top-customers-chart/locales/sk.ts +7 -0
  114. package/src/components/dashboard/top-customers-chart/locales/sl.ts +2 -0
  115. package/src/components/dashboard/top-customers-chart/locales/sv.ts +7 -0
  116. package/src/components/dashboard/top-customers-chart/top-customers-chart.tsx +23 -12
  117. package/src/components/delivery-notes/create/create-delivery-note-form.tsx +33 -20
  118. package/src/components/delivery-notes/list/list-table.tsx +22 -13
  119. package/src/components/delivery-notes/list/locales/de.ts +2 -0
  120. package/src/components/delivery-notes/list/locales/en.ts +1 -0
  121. package/src/components/delivery-notes/list/locales/es.ts +1 -0
  122. package/src/components/delivery-notes/list/locales/fr.ts +1 -0
  123. package/src/components/delivery-notes/list/locales/hr.ts +1 -0
  124. package/src/components/delivery-notes/list/locales/it.ts +1 -0
  125. package/src/components/delivery-notes/list/locales/nl.ts +1 -0
  126. package/src/components/delivery-notes/list/locales/pl.ts +1 -0
  127. package/src/components/delivery-notes/list/locales/pt.ts +1 -0
  128. package/src/components/delivery-notes/list/locales/sl.ts +1 -0
  129. package/src/components/delivery-notes/list/use-delivery-note-download.ts +1 -12
  130. package/src/components/documents/create/document-add-item-form.tsx +28 -16
  131. package/src/components/documents/create/document-add-item-tax-rate-field.tsx +12 -2
  132. package/src/components/documents/create/document-items-section.tsx +70 -39
  133. package/src/components/documents/create/document-recipient-section.tsx +10 -1
  134. package/src/components/documents/create/live-preview.tsx +113 -15
  135. package/src/components/documents/create/prepare-document-submission.ts +35 -16
  136. package/src/components/documents/create/use-document-customer-form.ts +14 -3
  137. package/src/components/documents/documents.hooks.ts +7 -2
  138. package/src/components/documents/shared/document-preview-display.tsx +136 -67
  139. package/src/components/documents/shared/scaled-document-preview.tsx +45 -5
  140. package/src/components/documents/view/document-actions-bar.tsx +284 -182
  141. package/src/components/documents/view/document-activities-list.tsx +3 -0
  142. package/src/components/documents/view/document-payments-list.tsx +3 -0
  143. package/src/components/documents/view/locales/de.ts +8 -0
  144. package/src/components/documents/view/locales/es.ts +8 -0
  145. package/src/components/documents/view/locales/fr.ts +8 -0
  146. package/src/components/documents/view/locales/hr.ts +8 -0
  147. package/src/components/documents/view/locales/it.ts +8 -0
  148. package/src/components/documents/view/locales/nl.ts +8 -0
  149. package/src/components/documents/view/locales/pl.ts +8 -0
  150. package/src/components/documents/view/locales/pt.ts +8 -0
  151. package/src/components/documents/view/locales/sl.ts +8 -0
  152. package/src/components/documents/view/use-document-download.ts +14 -25
  153. package/src/components/entities/create-entity-form.tsx +101 -16
  154. package/src/components/entities/entity-settings-form/entity-settings-form.tsx +10 -10
  155. package/src/components/entities/entity-settings-form/locales/de.ts +10 -0
  156. package/src/components/entities/entity-settings-form/locales/es.ts +10 -0
  157. package/src/components/entities/entity-settings-form/locales/fr.ts +10 -0
  158. package/src/components/entities/entity-settings-form/locales/hr.ts +10 -0
  159. package/src/components/entities/entity-settings-form/locales/it.ts +10 -0
  160. package/src/components/entities/entity-settings-form/locales/nl.ts +10 -0
  161. package/src/components/entities/entity-settings-form/locales/pl.ts +10 -0
  162. package/src/components/entities/entity-settings-form/locales/pt.ts +10 -0
  163. package/src/components/entities/entity-settings-form/locales/sl.ts +10 -0
  164. package/src/components/entities/fina-settings-form/fina-operator-required-dialog.tsx +3 -3
  165. package/src/components/entities/fina-settings-form/fina-settings-form.tsx +78 -124
  166. package/src/components/entities/fina-settings-form/sections/certificate-settings-section.tsx +8 -1
  167. package/src/components/entities/fina-settings-form/sections/premises-management-section.tsx +14 -2
  168. package/src/components/entities/fina-settings-form/sections/register-premise-dialog.tsx +7 -2
  169. package/src/components/entities/furs-settings-form/furs-settings-form.tsx +56 -130
  170. package/src/components/entities/furs-settings-form/sections/certificate-settings-section.tsx +8 -1
  171. package/src/components/entities/furs-settings-form/sections/enable-fiscalization-section.tsx +1 -0
  172. package/src/components/entities/furs-settings-form/sections/general-settings-section.tsx +15 -2
  173. package/src/components/entities/furs-settings-form/sections/premises-management-section.tsx +20 -3
  174. package/src/components/entities/furs-settings-form/sections/register-premise-dialog.tsx +38 -12
  175. package/src/components/entities/settings/defaults-settings-form.tsx +6 -6
  176. package/src/components/entities/settings/eslog-settings-form.tsx +13 -1
  177. package/src/components/entities/settings/pdf-template-selector/demo-invoice-data.ts +3 -22
  178. package/src/components/entities/shared/fiscalization-step-flow.ts +77 -0
  179. package/src/components/entities/shared/fiscalization-step-tabs.tsx +71 -0
  180. package/src/components/estimates/create/create-estimate-form.tsx +34 -21
  181. package/src/components/estimates/list/list-table.tsx +23 -14
  182. package/src/components/estimates/list/locales/de.ts +2 -0
  183. package/src/components/estimates/list/locales/en.ts +1 -0
  184. package/src/components/estimates/list/locales/es.ts +1 -0
  185. package/src/components/estimates/list/locales/fr.ts +1 -0
  186. package/src/components/estimates/list/locales/hr.ts +1 -0
  187. package/src/components/estimates/list/locales/it.ts +1 -0
  188. package/src/components/estimates/list/locales/nl.ts +1 -0
  189. package/src/components/estimates/list/locales/pl.ts +1 -0
  190. package/src/components/estimates/list/locales/pt.ts +1 -0
  191. package/src/components/estimates/list/locales/sl.ts +1 -0
  192. package/src/components/estimates/list/use-estimate-download.ts +1 -12
  193. package/src/components/export/document-export-form.tsx +33 -7
  194. package/src/components/export/sales-per-item-export-form.tsx +23 -7
  195. package/src/components/invoices/create/create-invoice-form.tsx +295 -329
  196. package/src/components/invoices/create/prepare-invoice-submission.ts +0 -8
  197. package/src/components/invoices/list/list-table.tsx +7 -4
  198. package/src/components/invoices/list/use-invoice-download.ts +1 -11
  199. package/src/components/invoices/send-email-dialog/locales/de.ts +20 -0
  200. package/src/components/invoices/send-email-dialog/locales/es.ts +20 -0
  201. package/src/components/invoices/send-email-dialog/locales/fr.ts +20 -0
  202. package/src/components/invoices/send-email-dialog/locales/hr.ts +20 -0
  203. package/src/components/invoices/send-email-dialog/locales/it.ts +20 -0
  204. package/src/components/invoices/send-email-dialog/locales/nl.ts +20 -0
  205. package/src/components/invoices/send-email-dialog/locales/pl.ts +20 -0
  206. package/src/components/invoices/send-email-dialog/locales/pt.ts +20 -0
  207. package/src/components/invoices/send-email-dialog/locales/sl.ts +20 -0
  208. package/src/components/invoices/send-email-dialog/send-email-dialog.tsx +77 -8
  209. package/src/components/invoices/view/eslog-info-display.tsx +17 -1
  210. package/src/components/invoices/view/fiscalization-status-card.tsx +7 -3
  211. package/src/components/items/item-combobox.tsx +26 -6
  212. package/src/components/items/item-list-table/item-list-table.tsx +5 -2
  213. package/src/components/payments/create-payment-form/index.ts +1 -0
  214. package/src/components/payments/list/list-table.tsx +14 -4
  215. package/src/components/recurring-invoices/list/list-table.tsx +7 -4
  216. package/src/components/request-logs/locales.ts +412 -0
  217. package/src/components/request-logs/request-log-detail.tsx +37 -21
  218. package/src/components/request-logs/request-log-list-table.tsx +57 -11
  219. package/src/components/table/data-table.tsx +5 -2
  220. package/src/components/table/date-cell.tsx +3 -1
  221. package/src/components/table/filter-bar.tsx +14 -2
  222. package/src/components/table/hooks/use-table-query.ts +1 -1
  223. package/src/components/table/locales.ts +1116 -0
  224. package/src/components/table/search-input.tsx +12 -3
  225. package/src/components/table/selection-toolbar.tsx +23 -6
  226. package/src/components/table/table-empty-state.tsx +43 -3
  227. package/src/components/table/table-no-results.tsx +3 -3
  228. package/src/components/table/table-pagination.tsx +4 -3
  229. package/src/components/table/types.ts +1 -0
  230. package/src/components/tax-reports/index.ts +1 -0
  231. package/src/components/tax-reports/kir-export-form.tsx +46 -8
  232. package/src/components/tax-reports/slovenia-tax-profile-step.tsx +191 -0
  233. package/src/components/tax-reports/slovenia-yearly-export-form.tsx +509 -0
  234. package/src/components/tax-reports/slovenia-yearly-review-step.tsx +253 -0
  235. package/src/components/tax-reports/slovenia-yearly-summary.tsx +19 -0
  236. package/src/components/taxes/tax-list-table/tax-list-table.tsx +3 -2
  237. package/src/components/ui/sidebar.tsx +3 -2
  238. package/src/components/ui/sticky-form-footer.tsx +7 -1
  239. package/src/components/webhook-logs/index.ts +6 -0
  240. package/src/components/webhook-logs/locales.ts +392 -0
  241. package/src/components/webhook-logs/webhook-delivery-detail.tsx +255 -0
  242. package/src/components/webhook-logs/webhook-delivery-list-table.tsx +278 -0
  243. package/src/components/wl-subscription/index.ts +1 -0
  244. package/src/components/wl-subscription/locked-feature.tsx +1 -0
  245. package/src/components/wl-subscription/paywall.tsx +193 -0
  246. package/src/components/wl-subscription/upgrade-modal.tsx +93 -29
  247. package/src/generate-schemas.ts +12 -7
  248. package/src/generated/schemas/customer.ts +2 -0
  249. package/src/generated/schemas/entity.ts +134 -0
  250. package/src/generated/schemas/exportsloveniayearlynormiranireport_body.ts +27 -0
  251. package/src/generated/schemas/index.ts +2 -0
  252. package/src/generated/schemas/me.ts +20 -1
  253. package/src/generated/schemas/renderadvanceinvoicepreview_body.ts +40 -34
  254. package/src/generated/schemas/rendercreditnotepreview_body.ts +42 -36
  255. package/src/generated/schemas/renderdeliverynotepreview_body.ts +23 -13
  256. package/src/generated/schemas/renderestimatepreview_body.ts +23 -13
  257. package/src/generated/schemas/renderinvoicepreview_body.ts +40 -34
  258. package/src/generated/schemas/sendemail_body.ts +44 -0
  259. package/src/generated/schemas/sloveniataxprofile.ts +42 -0
  260. package/src/generated/schemas/startpdfexport_body.ts +91 -1
  261. package/src/generated/schemas/webhook.ts +10 -0
  262. package/src/hooks/use-duplicate-document.ts +51 -13
  263. package/src/hooks/use-eslog-validation.ts +59 -0
  264. package/src/hooks/use-premise-selection.ts +186 -0
  265. package/src/lib/browser-cookies.ts +4 -4
  266. package/src/lib/date-fns-locale.ts +48 -0
  267. package/src/lib/fiscalization-options.ts +81 -0
  268. package/src/lib/locale.ts +38 -0
  269. package/src/lib/template-variables.tsx +1 -1
  270. package/src/lib/translation.ts +14 -3
  271. package/src/providers/entities-context.tsx +1 -0
  272. package/src/providers/entities-provider.tsx +102 -3
  273. package/src/providers/form-footer-context.tsx +37 -4
  274. package/src/providers/sdk-provider.tsx +7 -2
  275. package/src/providers/white-label-provider.tsx +4 -1
  276. package/src/providers/wl-subscription-provider.tsx +90 -3
@@ -48,6 +48,8 @@ export default {
48
48
  "Retry Fiscalization": "Retry Fiscalization",
49
49
  "Some selected documents don't have failed fiscalization": "Some selected documents don't have failed fiscalization",
50
50
  "Copy to Invoice": "In Rechnung kopieren",
51
+ "Finalize draft documents before copying to invoice":
52
+ "Entwurfsdokumente abschließen, bevor Sie in eine Rechnung kopieren",
51
53
  Void: "Stornieren",
52
54
  "Cannot void an advance invoice linked to an invoice":
53
55
  "Stornierung einer mit einer Rechnung verknüpften Anzahlungsrechnung nicht möglich",
@@ -14,6 +14,7 @@ export default {
14
14
  "Retry Fiscalization": "Retry Fiscalization",
15
15
  "Some selected documents don't have failed fiscalization": "Some selected documents don't have failed fiscalization",
16
16
  "Copy to Invoice": "Copy to Invoice",
17
+ "Finalize draft documents before copying to invoice": "Finalize draft documents before copying to invoice",
17
18
  Void: "Void",
18
19
  "Cannot void an advance invoice linked to an invoice": "Cannot void an advance invoice linked to an invoice",
19
20
  } as const;
@@ -48,6 +48,7 @@ export default {
48
48
  "Retry Fiscalization": "Retry Fiscalization",
49
49
  "Some selected documents don't have failed fiscalization": "Some selected documents don't have failed fiscalization",
50
50
  "Copy to Invoice": "Copiar a factura",
51
+ "Finalize draft documents before copying to invoice": "Finalice los borradores antes de copiar a factura",
51
52
  Void: "Anular",
52
53
  "Cannot void an advance invoice linked to an invoice":
53
54
  "No se puede anular una factura anticipada vinculada a una factura",
@@ -48,6 +48,7 @@ export default {
48
48
  "Retry Fiscalization": "Retry Fiscalization",
49
49
  "Some selected documents don't have failed fiscalization": "Some selected documents don't have failed fiscalization",
50
50
  "Copy to Invoice": "Copier vers facture",
51
+ "Finalize draft documents before copying to invoice": "Finalisez les brouillons avant de copier en facture",
51
52
  Void: "Annuler",
52
53
  "Cannot void an advance invoice linked to an invoice":
53
54
  "Impossible d'annuler une facture d'acompte liée à une facture",
@@ -48,6 +48,7 @@ export default {
48
48
  "Retry Fiscalization": "Ponovi fiskalizaciju",
49
49
  "Some selected documents don't have failed fiscalization": "Neki odabrani dokumenti nemaju neuspjelu fiskalizaciju",
50
50
  "Copy to Invoice": "Kopiraj u račun",
51
+ "Finalize draft documents before copying to invoice": "Dovršite skice dokumenata prije kopiranja u račun",
51
52
  Void: "Storniraj",
52
53
  "Cannot void an advance invoice linked to an invoice": "Nije moguće poništiti avansni račun povezan s računom",
53
54
  } as const;
@@ -48,6 +48,7 @@ export default {
48
48
  "Retry Fiscalization": "Retry Fiscalization",
49
49
  "Some selected documents don't have failed fiscalization": "Some selected documents don't have failed fiscalization",
50
50
  "Copy to Invoice": "Copia in fattura",
51
+ "Finalize draft documents before copying to invoice": "Finalizzare i documenti bozza prima di copiare in fattura",
51
52
  Void: "Annulla",
52
53
  "Cannot void an advance invoice linked to an invoice":
53
54
  "Impossibile annullare una fattura anticipata collegata a una fattura",
@@ -48,6 +48,7 @@ export default {
48
48
  "Retry Fiscalization": "Retry Fiscalization",
49
49
  "Some selected documents don't have failed fiscalization": "Some selected documents don't have failed fiscalization",
50
50
  "Copy to Invoice": "Kopieer naar factuur",
51
+ "Finalize draft documents before copying to invoice": "Rond conceptdocumenten af voordat u naar factuur kopieert",
51
52
  Void: "Nietig verklaren",
52
53
  "Cannot void an advance invoice linked to an invoice":
53
54
  "Kan een voorschotfactuur gekoppeld aan een factuur niet ongeldig maken",
@@ -48,6 +48,7 @@ export default {
48
48
  "Retry Fiscalization": "Retry Fiscalization",
49
49
  "Some selected documents don't have failed fiscalization": "Some selected documents don't have failed fiscalization",
50
50
  "Copy to Invoice": "Kopiuj do faktury",
51
+ "Finalize draft documents before copying to invoice": "Sfinalizuj wersje robocze przed skopiowaniem do faktury",
51
52
  Void: "Anuluj",
52
53
  "Cannot void an advance invoice linked to an invoice": "Nie można anulować faktury zaliczkowej powiązanej z fakturą",
53
54
  } as const;
@@ -48,6 +48,7 @@ export default {
48
48
  "Retry Fiscalization": "Retry Fiscalization",
49
49
  "Some selected documents don't have failed fiscalization": "Some selected documents don't have failed fiscalization",
50
50
  "Copy to Invoice": "Copiar para fatura",
51
+ "Finalize draft documents before copying to invoice": "Finalize os rascunhos antes de copiar para fatura",
51
52
  Void: "Anular",
52
53
  "Cannot void an advance invoice linked to an invoice":
53
54
  "Não é possível anular uma fatura antecipada vinculada a uma fatura",
@@ -48,6 +48,7 @@ export default {
48
48
  "Retry Fiscalization": "Ponovi fiskalizacijo",
49
49
  "Some selected documents don't have failed fiscalization": "Nekateri izbrani dokumenti nimajo neuspele fiskalizacije",
50
50
  "Copy to Invoice": "Kopiraj v račun",
51
+ "Finalize draft documents before copying to invoice": "Dokončajte osnutke dokumentov pred kopiranjem v račun",
51
52
  Void: "Storniraj",
52
53
  "Cannot void an advance invoice linked to an invoice": "Ni mogoče razveljaviti predračuna, ki je povezan z računom",
53
54
  } as const;
@@ -33,19 +33,8 @@ export function useAdvanceInvoiceDownload({
33
33
  onDownloadStart?.();
34
34
 
35
35
  try {
36
- // SDK signature: renderPdf(id, params?, SDKMethodOptions?)
37
- // entity_id goes in SDKMethodOptions (last arg), not params
38
- // Note: renderPdf is on invoices module but works with any document ID
39
- const blob = await sdk.invoices.renderPdf(advanceInvoice.id, {}, { entity_id: activeEntity.id });
40
- const downloadUrl = window.URL.createObjectURL(blob);
41
- const link = document.createElement("a");
42
- link.href = downloadUrl;
43
36
  const fileName = `${t("Advance Invoice")} ${advanceInvoice.number}.pdf`;
44
- link.download = fileName;
45
- document.body.appendChild(link);
46
- link.click();
47
- document.body.removeChild(link);
48
- window.URL.revokeObjectURL(downloadUrl);
37
+ await sdk.invoices.downloadPdf(advanceInvoice.id, fileName, {}, { entity_id: activeEntity.id });
49
38
 
50
39
  onDownloadSuccess?.(fileName);
51
40
  } catch (error) {
@@ -9,7 +9,9 @@ import { Form } from "@/ui/components/ui/form";
9
9
  import { Skeleton } from "@/ui/components/ui/skeleton";
10
10
  import { createCreditNoteSchema } from "@/ui/generated/schemas";
11
11
  import { useNextDocumentNumber } from "@/ui/hooks/use-next-document-number";
12
+ import { usePremiseSelection } from "@/ui/hooks/use-premise-selection";
12
13
  import { useTransactionTypeCheck } from "@/ui/hooks/use-transaction-type-check";
14
+ import { buildFinaOptions, buildFursOptions } from "@/ui/lib/fiscalization-options";
13
15
  import type { ComponentTranslationProps } from "@/ui/lib/translation";
14
16
  import { createTranslation } from "@/ui/lib/translation";
15
17
  import { useEntities } from "@/ui/providers/entities-context";
@@ -29,15 +31,7 @@ import { MarkAsPaidSection } from "../../documents/create/mark-as-paid-section";
29
31
  import { prepareDocumentSubmission } from "../../documents/create/prepare-document-submission";
30
32
  import { useDocumentCustomerForm } from "../../documents/create/use-document-customer-form";
31
33
  import type { DocumentTypes } from "../../documents/types";
32
- import { useFinaPremises, useFinaSettings } from "../../entities/fina-settings-form/fina-settings.hooks";
33
- import { useFursPremises, useFursSettings } from "../../entities/furs-settings-form/furs-settings.hooks";
34
- import {
35
- getLastUsedFinaCombo,
36
- getLastUsedFursCombo,
37
- setLastUsedFinaCombo,
38
- setLastUsedFursCombo,
39
- useCreateCreditNote,
40
- } from "../credit-notes.hooks";
34
+ import { useCreateCreditNote } from "../credit-notes.hooks";
41
35
  import de from "./locales/de";
42
36
  import es from "./locales/es";
43
37
  import fr from "./locales/fr";
@@ -102,44 +96,21 @@ export default function CreateCreditNoteForm({
102
96
  const queryClient = useQueryClient();
103
97
 
104
98
  // ============================================================================
105
- // FURS Settings & Premises
106
- // ============================================================================
107
- const { data: fursSettings, isLoading: isFursSettingsLoading } = useFursSettings(entityId);
108
- const { data: fursPremises, isLoading: isFursPremisesLoading } = useFursPremises(entityId, {
109
- enabled: fursSettings?.enabled === true,
110
- });
111
-
112
- const isFursLoading = isFursSettingsLoading || (fursSettings?.enabled && isFursPremisesLoading);
113
- const isFursEnabled = fursSettings?.enabled === true;
114
- const activePremises = useMemo(() => fursPremises?.filter((p) => p.is_active) || [], [fursPremises]);
115
- const hasFursPremises = activePremises.length > 0;
116
-
117
- // FURS premise/device selection state
118
- const [selectedPremiseName, setSelectedPremiseName] = useState<string | undefined>();
119
- const [selectedDeviceName, setSelectedDeviceName] = useState<string | undefined>();
120
-
121
- // ============================================================================
122
- // FINA Settings & Premises
99
+ // FURS & FINA Premise Selection (shared hook)
123
100
  // ============================================================================
124
- const { data: finaSettings, isLoading: isFinaSettingsLoading } = useFinaSettings(entityId);
125
- const { data: finaPremises, isLoading: isFinaPremisesLoading } = useFinaPremises(entityId, {
126
- enabled: finaSettings?.enabled === true,
127
- });
128
-
129
- const isFinaLoading = isFinaSettingsLoading || (finaSettings?.enabled && isFinaPremisesLoading);
130
- const isFinaEnabled = finaSettings?.enabled === true;
131
- const activeFinaPremises = useMemo(() => finaPremises?.filter((p: any) => p.is_active) || [], [finaPremises]);
132
- const hasFinaPremises = activeFinaPremises.length > 0;
133
-
134
- // FINA premise/device selection state (no skip - all FINA credit notes must be fiscalized)
135
- const [selectedFinaBusinessPremiseName, setSelectedFinaBusinessPremiseName] = useState<string | undefined>();
136
- const [selectedFinaElectronicDeviceName, setSelectedFinaElectronicDeviceName] = useState<string | undefined>();
101
+ const furs = usePremiseSelection({ entityId, type: "furs" });
102
+ const fina = usePremiseSelection({ entityId, type: "fina" });
137
103
 
138
104
  // UI-only state (not part of API schema)
139
105
  const [markAsPaid, setMarkAsPaid] = useState(false);
140
106
  const [paymentTypes, setPaymentTypes] = useState<string[]>(["bank_transfer"]);
141
107
  const [isDraftPending, setIsDraftPending] = useState(false);
142
108
 
109
+ // Service date type state (single date or range)
110
+ const [serviceDateType, setServiceDateType] = useState<"single" | "range">(
111
+ initialValues && (initialValues as any).date_service_to ? "range" : "single",
112
+ );
113
+
143
114
  // Price modes per item (gross vs net) - collected from component state at submit
144
115
  const initialPriceModes = useMemo(() => {
145
116
  if (!initialValues?.items) return {};
@@ -150,112 +121,6 @@ export default function CreateCreditNoteForm({
150
121
  }, [initialValues?.items]);
151
122
  const priceModesRef = useRef<PriceModesMap>(initialPriceModes);
152
123
 
153
- // Get active FURS devices for selected premise
154
- const activeDevices = useMemo(() => {
155
- if (!selectedPremiseName) return [];
156
- const premise = activePremises.find((p) => p.business_premise_name === selectedPremiseName);
157
- return premise?.Devices?.filter((d) => d.is_active) || [];
158
- }, [activePremises, selectedPremiseName]);
159
-
160
- // Initialize FURS selection from localStorage or first active combo
161
- useEffect(() => {
162
- if (!isFursEnabled || !hasFursPremises || selectedPremiseName) return;
163
-
164
- const lastUsed = getLastUsedFursCombo(entityId);
165
- if (lastUsed) {
166
- const premise = activePremises.find((p) => p.business_premise_name === lastUsed.business_premise_name);
167
- const device = premise?.Devices?.find(
168
- (d) => d.electronic_device_name === lastUsed.electronic_device_name && d.is_active,
169
- );
170
- if (premise && device) {
171
- setSelectedPremiseName(lastUsed.business_premise_name);
172
- setSelectedDeviceName(lastUsed.electronic_device_name);
173
- return;
174
- }
175
- }
176
-
177
- const firstPremise = activePremises[0];
178
- const firstDevice = firstPremise?.Devices?.find((d) => d.is_active);
179
- if (firstPremise && firstDevice) {
180
- setSelectedPremiseName(firstPremise.business_premise_name);
181
- setSelectedDeviceName(firstDevice.electronic_device_name);
182
- }
183
- }, [isFursEnabled, hasFursPremises, activePremises, entityId, selectedPremiseName]);
184
-
185
- // When FURS premise changes, select first active device
186
- useEffect(() => {
187
- if (!selectedPremiseName) return;
188
- const premise = activePremises.find((p) => p.business_premise_name === selectedPremiseName);
189
- const firstDevice = premise?.Devices?.find((d) => d.is_active);
190
- if (firstDevice && selectedDeviceName !== firstDevice.electronic_device_name) {
191
- const currentDeviceInPremise = premise?.Devices?.find(
192
- (d) => d.electronic_device_name === selectedDeviceName && d.is_active,
193
- );
194
- if (!currentDeviceInPremise) {
195
- setSelectedDeviceName(firstDevice.electronic_device_name);
196
- }
197
- }
198
- }, [selectedPremiseName, activePremises, selectedDeviceName]);
199
-
200
- // FURS selection ready and active checks
201
- const isFursSelectionReady = !isFursEnabled || !hasFursPremises || (!!selectedPremiseName && !!selectedDeviceName);
202
- const isFursActive = isFursEnabled && hasFursPremises && selectedPremiseName && selectedDeviceName;
203
-
204
- // Get active FINA devices for selected premise
205
- const activeFinaDevices = useMemo(() => {
206
- if (!selectedFinaBusinessPremiseName) return [];
207
- const premise = activeFinaPremises.find((p: any) => p.business_premise_name === selectedFinaBusinessPremiseName);
208
- return premise?.Devices?.filter((d: any) => d.is_active) || [];
209
- }, [activeFinaPremises, selectedFinaBusinessPremiseName]);
210
-
211
- // Initialize FINA selection from localStorage or first active combo
212
- useEffect(() => {
213
- if (!isFinaEnabled || !hasFinaPremises || selectedFinaBusinessPremiseName) return;
214
-
215
- const lastUsed = getLastUsedFinaCombo(entityId);
216
- if (lastUsed) {
217
- const premise = activeFinaPremises.find((p: any) => p.business_premise_name === lastUsed.business_premise_name);
218
- const device = premise?.Devices?.find(
219
- (d: any) => d.electronic_device_name === lastUsed.electronic_device_name && d.is_active,
220
- );
221
- if (premise && device) {
222
- setSelectedFinaBusinessPremiseName(lastUsed.business_premise_name);
223
- setSelectedFinaElectronicDeviceName(lastUsed.electronic_device_name);
224
- return;
225
- }
226
- }
227
-
228
- const firstPremise = activeFinaPremises[0];
229
- const firstDevice = firstPremise?.Devices?.find((d: any) => d.is_active);
230
- if (firstPremise && firstDevice) {
231
- setSelectedFinaBusinessPremiseName(firstPremise.business_premise_name);
232
- setSelectedFinaElectronicDeviceName(firstDevice.electronic_device_name);
233
- }
234
- }, [isFinaEnabled, hasFinaPremises, activeFinaPremises, entityId, selectedFinaBusinessPremiseName]);
235
-
236
- // When FINA premise changes, select first active device
237
- useEffect(() => {
238
- if (!selectedFinaBusinessPremiseName) return;
239
- const premise = activeFinaPremises.find((p: any) => p.business_premise_name === selectedFinaBusinessPremiseName);
240
- const firstDevice = premise?.Devices?.find((d: any) => d.is_active);
241
- if (firstDevice && selectedFinaElectronicDeviceName !== firstDevice.electronic_device_name) {
242
- const currentDeviceInPremise = premise?.Devices?.find(
243
- (d: any) => d.electronic_device_name === selectedFinaElectronicDeviceName && d.is_active,
244
- );
245
- if (!currentDeviceInPremise) {
246
- setSelectedFinaElectronicDeviceName(firstDevice.electronic_device_name);
247
- }
248
- }
249
- }, [selectedFinaBusinessPremiseName, activeFinaPremises, selectedFinaElectronicDeviceName]);
250
-
251
- // FINA selection ready and active checks
252
- const isFinaSelectionReady =
253
- !isFinaEnabled || !hasFinaPremises || (!!selectedFinaBusinessPremiseName && !!selectedFinaElectronicDeviceName);
254
- const isFinaActive =
255
- isFinaEnabled && hasFinaPremises && selectedFinaBusinessPremiseName && selectedFinaElectronicDeviceName;
256
-
257
- // No header action for credit notes - FINA can't be skipped
258
-
259
124
  // Get default payment terms and footer from entity settings
260
125
  const defaultPaymentTerms = (activeEntity?.settings as any)?.default_credit_note_payment_terms || "";
261
126
  const defaultFooter = (activeEntity?.settings as any)?.document_footer || "";
@@ -292,6 +157,7 @@ export default function CreateCreditNoteForm({
292
157
  taxes: [],
293
158
  },
294
159
  ],
160
+ date_service: (initialValues as any)?.date_service || new Date().toISOString(),
295
161
  currency_code: initialValues?.currency_code || activeEntity?.currency_code || "EUR",
296
162
  reference: (initialValues as any)?.reference ?? "",
297
163
  note: initialValues?.note ?? "",
@@ -304,6 +170,9 @@ export default function CreateCreditNoteForm({
304
170
  const formValues = useWatch({
305
171
  control: form.control,
306
172
  });
173
+ const onChangeRef = useRef(onChange);
174
+ onChangeRef.current = onChange;
175
+ const prevPayloadRef = useRef("");
307
176
 
308
177
  // ============================================================================
309
178
  // VIES Check - determine if reverse charge applies
@@ -324,35 +193,35 @@ export default function CreateCreditNoteForm({
324
193
  });
325
194
 
326
195
  // FINA numbering guard: use FINA numbering for domestic transactions (or all if unified numbering is on)
327
- const finaUnifiedNumbering = finaSettings?.unified_numbering !== false;
196
+ const finaUnifiedNumbering = fina.settings?.unified_numbering !== false;
328
197
  const useFinaNumbering =
329
- !!isFinaActive && (finaUnifiedNumbering || transactionType == null || transactionType === "domestic");
330
- const isFinaNonDomestic = !!isFinaActive && !useFinaNumbering;
198
+ !!fina.isActive && (finaUnifiedNumbering || transactionType == null || transactionType === "domestic");
199
+ const isFinaNonDomestic = !!fina.isActive && !useFinaNumbering;
331
200
 
332
201
  // ============================================================================
333
202
  // Next Credit Note Number Preview
334
203
  // ============================================================================
335
204
  // Use same premise/device params for both FURS and FINA (entity is either one, never both)
336
- const activePremiseNameForNumber = isFursActive
337
- ? selectedPremiseName
205
+ const activePremiseNameForNumber = furs.isActive
206
+ ? furs.selectedPremiseName
338
207
  : useFinaNumbering
339
- ? selectedFinaBusinessPremiseName
208
+ ? fina.selectedPremiseName
340
209
  : undefined;
341
- const activeDeviceNameForNumber = isFursActive
342
- ? selectedDeviceName
210
+ const activeDeviceNameForNumber = furs.isActive
211
+ ? furs.selectedDeviceName
343
212
  : useFinaNumbering
344
- ? selectedFinaElectronicDeviceName
213
+ ? fina.selectedDeviceName
345
214
  : undefined;
346
215
 
347
216
  const { data: nextNumberData, isLoading: isNextNumberLoading } = useNextDocumentNumber(entityId, "credit_note", {
348
217
  businessPremiseName: activePremiseNameForNumber,
349
218
  electronicDeviceName: activeDeviceNameForNumber,
350
- enabled: !!entityId && !isFursLoading && isFursSelectionReady && !isFinaLoading && isFinaSelectionReady,
219
+ enabled: !!entityId && !furs.isLoading && furs.isSelectionReady && !fina.isLoading && fina.isSelectionReady,
351
220
  });
352
221
 
353
222
  // Overall loading state
354
223
  const isFormDataLoading =
355
- isFursLoading || !isFursSelectionReady || isFinaLoading || !isFinaSelectionReady || isNextNumberLoading;
224
+ furs.isLoading || !furs.isSelectionReady || fina.isLoading || !fina.isSelectionReady || isNextNumberLoading;
356
225
 
357
226
  // Auto-populate tax_clause from entity settings when transaction type changes
358
227
  const effectiveTransactionType = transactionType ?? "domestic";
@@ -368,6 +237,13 @@ export default function CreateCreditNoteForm({
368
237
  form.setValue("tax_clause", clause);
369
238
  }, [effectiveTransactionType, activeEntity, form]);
370
239
 
240
+ // Clear date_service_to when switching from range to single
241
+ useEffect(() => {
242
+ if (serviceDateType === "single") {
243
+ form.setValue("date_service_to", undefined);
244
+ }
245
+ }, [serviceDateType, form]);
246
+
371
247
  // Extract customer management logic into a shared hook
372
248
  const {
373
249
  originalCustomer,
@@ -389,20 +265,9 @@ export default function CreateCreditNoteForm({
389
265
  const { mutate: createCreditNote, isPending } = useCreateCreditNote({
390
266
  entityId,
391
267
  onSuccess: (data) => {
392
- // Save FURS combo to localStorage on successful creation
393
- if (isFursActive && selectedPremiseName && selectedDeviceName) {
394
- setLastUsedFursCombo(entityId, {
395
- business_premise_name: selectedPremiseName,
396
- electronic_device_name: selectedDeviceName,
397
- });
398
- }
399
- // Save FINA combo to localStorage on successful creation
400
- if (isFinaActive && selectedFinaBusinessPremiseName && selectedFinaElectronicDeviceName) {
401
- setLastUsedFinaCombo(entityId, {
402
- business_premise_name: selectedFinaBusinessPremiseName,
403
- electronic_device_name: selectedFinaElectronicDeviceName,
404
- });
405
- }
268
+ // Save FURS/FINA combos to localStorage on successful creation
269
+ furs.saveCombo();
270
+ fina.saveCombo();
406
271
  // Invalidate customers cache when a customer was created/linked
407
272
  if (data.customer_id) {
408
273
  queryClient.invalidateQueries({ queryKey: [CUSTOMERS_CACHE_KEY] });
@@ -416,20 +281,21 @@ export default function CreateCreditNoteForm({
416
281
  const submitCreditNote = useCallback(
417
282
  (values: CreateCreditNoteFormValues, isDraft: boolean) => {
418
283
  // Build FURS options (skip for drafts; no skip toggle for credit notes)
419
- const fursOptions =
420
- !isDraft && isFursEnabled && selectedPremiseName && selectedDeviceName
421
- ? { business_premise_name: selectedPremiseName, electronic_device_name: selectedDeviceName }
422
- : undefined;
284
+ const fursOptions = buildFursOptions({
285
+ isDraft,
286
+ isEnabled: furs.isEnabled,
287
+ premiseName: furs.selectedPremiseName,
288
+ deviceName: furs.selectedDeviceName,
289
+ });
423
290
 
424
291
  // Build FINA options (skip for drafts; FINA can't be skipped)
425
- const finaOptions =
426
- !isDraft && useFinaNumbering && selectedFinaBusinessPremiseName && selectedFinaElectronicDeviceName
427
- ? {
428
- business_premise_name: selectedFinaBusinessPremiseName,
429
- electronic_device_name: selectedFinaElectronicDeviceName,
430
- payment_type: paymentTypes[0],
431
- }
432
- : undefined;
292
+ const finaOptions = buildFinaOptions({
293
+ isDraft,
294
+ useFinaNumbering,
295
+ premiseName: fina.selectedPremiseName,
296
+ deviceName: fina.selectedDeviceName,
297
+ paymentType: paymentTypes[0],
298
+ });
433
299
 
434
300
  const payload = prepareDocumentSubmission(values, {
435
301
  originalCustomer,
@@ -453,19 +319,7 @@ export default function CreateCreditNoteForm({
453
319
 
454
320
  createCreditNote(payload as CreateCreditNoteRequest);
455
321
  },
456
- [
457
- createCreditNote,
458
- isFursEnabled,
459
- useFinaNumbering,
460
- markAsPaid,
461
- originalCustomer,
462
- paymentTypes,
463
- selectedDeviceName,
464
- selectedFinaElectronicDeviceName,
465
- selectedFinaBusinessPremiseName,
466
- selectedPremiseName,
467
- showCustomerForm,
468
- ],
322
+ [createCreditNote, furs, fina, useFinaNumbering, markAsPaid, originalCustomer, paymentTypes, showCustomerForm],
469
323
  );
470
324
 
471
325
  // Handle save as draft
@@ -524,36 +378,49 @@ export default function CreateCreditNoteForm({
524
378
  }
525
379
  }, [activeEntity?.is_tax_subject, form]);
526
380
 
381
+ const buildPreviewPayload = useCallback((values: CreateCreditNoteFormValues): CreditNotePreviewPayload => {
382
+ const currentItems = values.items || [];
383
+
384
+ const transformedItems = currentItems.map((item: any, index: number) => {
385
+ const { price, ...rest } = item;
386
+ const isGross = priceModesRef.current[index] ?? false;
387
+ return isGross ? { ...rest, gross_price: price } : { ...rest, price };
388
+ });
389
+
390
+ return {
391
+ number: values.number,
392
+ date: values.date,
393
+ date_service: (values as any).date_service,
394
+ date_service_to: (values as any).date_service_to,
395
+ customer_id: values.customer_id,
396
+ customer: values.customer,
397
+ items: transformedItems,
398
+ currency_code: values.currency_code,
399
+ reference: values.reference,
400
+ note: values.note,
401
+ payment_terms: values.payment_terms,
402
+ signature: values.signature,
403
+ };
404
+ }, []);
405
+
406
+ const emitPreviewPayload = useCallback((payload: CreditNotePreviewPayload) => {
407
+ const callback = onChangeRef.current;
408
+ if (!callback) return;
409
+
410
+ const payloadStr = JSON.stringify(payload);
411
+ if (payloadStr === prevPayloadRef.current) return;
412
+ prevPayloadRef.current = payloadStr;
413
+
414
+ callback(payload);
415
+ }, []);
416
+
527
417
  useEffect(() => {
528
- if (onChange) {
529
- const currentItems = form.getValues("items") || [];
530
-
531
- // Transform items to use gross_price when price mode is gross
532
- const transformedItems = currentItems.map((item: any, index: number) => {
533
- const { price, ...rest } = item;
534
- const isGross = priceModesRef.current[index] ?? false;
535
- if (isGross) {
536
- return { ...rest, gross_price: price };
537
- }
538
- return { ...rest, price };
539
- });
418
+ emitPreviewPayload(buildPreviewPayload(formValues as CreateCreditNoteFormValues));
419
+ }, [buildPreviewPayload, emitPreviewPayload, formValues]);
540
420
 
541
- // Build preview payload (includes number for display)
542
- const payload: CreditNotePreviewPayload = {
543
- number: formValues.number,
544
- date: formValues.date,
545
- customer_id: formValues.customer_id,
546
- customer: formValues.customer,
547
- items: transformedItems,
548
- currency_code: formValues.currency_code,
549
- reference: formValues.reference,
550
- note: formValues.note,
551
- payment_terms: formValues.payment_terms,
552
- signature: formValues.signature,
553
- };
554
- onChange(payload);
555
- }
556
- }, [formValues, onChange, form]);
421
+ const emitCurrentPreviewPayload = useCallback(() => {
422
+ emitPreviewPayload(buildPreviewPayload(form.getValues()));
423
+ }, [buildPreviewPayload, emitPreviewPayload, form]);
557
424
 
558
425
  const onSubmit = (values: CreateCreditNoteFormValues) => {
559
426
  submitCreditNote(values, false);
@@ -629,32 +496,42 @@ export default function CreateCreditNoteForm({
629
496
  documentType={_type}
630
497
  t={t}
631
498
  fursInline={
632
- isFursEnabled && hasFursPremises
499
+ furs.isEnabled && furs.hasPremises
633
500
  ? {
634
- premises: activePremises.map((p) => ({ id: p.id, business_premise_name: p.business_premise_name })),
635
- devices: activeDevices.map((d) => ({ id: d.id, electronic_device_name: d.electronic_device_name })),
636
- selectedPremise: selectedPremiseName,
637
- selectedDevice: selectedDeviceName,
638
- onPremiseChange: setSelectedPremiseName,
639
- onDeviceChange: setSelectedDeviceName,
501
+ premises: furs.activePremises.map((p) => ({
502
+ id: p.id,
503
+ business_premise_name: p.business_premise_name,
504
+ })),
505
+ devices: furs.activeDevices.map((d) => ({
506
+ id: (d as any).id,
507
+ electronic_device_name: d.electronic_device_name,
508
+ })),
509
+ selectedPremise: furs.selectedPremiseName,
510
+ selectedDevice: furs.selectedDeviceName,
511
+ onPremiseChange: furs.setSelectedPremiseName,
512
+ onDeviceChange: furs.setSelectedDeviceName,
640
513
  }
641
514
  : undefined
642
515
  }
516
+ serviceDate={{
517
+ dateType: serviceDateType,
518
+ onDateTypeChange: setServiceDateType,
519
+ }}
643
520
  finaInline={
644
521
  useFinaNumbering
645
522
  ? {
646
- premises: activeFinaPremises.map((p: any) => ({
523
+ premises: fina.activePremises.map((p: any) => ({
647
524
  id: p.id,
648
525
  business_premise_name: p.business_premise_name,
649
526
  })),
650
- devices: activeFinaDevices.map((d: any) => ({
527
+ devices: fina.activeDevices.map((d: any) => ({
651
528
  id: d.id,
652
529
  electronic_device_name: d.electronic_device_name,
653
530
  })),
654
- selectedPremise: selectedFinaBusinessPremiseName,
655
- selectedDevice: selectedFinaElectronicDeviceName,
656
- onPremiseChange: setSelectedFinaBusinessPremiseName,
657
- onDeviceChange: setSelectedFinaElectronicDeviceName,
531
+ selectedPremise: fina.selectedPremiseName,
532
+ selectedDevice: fina.selectedDeviceName,
533
+ onPremiseChange: fina.setSelectedPremiseName,
534
+ onDeviceChange: fina.setSelectedDeviceName,
658
535
  }
659
536
  : undefined
660
537
  }
@@ -666,7 +543,7 @@ export default function CreateCreditNoteForm({
666
543
  paymentTypes={paymentTypes}
667
544
  onPaymentTypesChange={setPaymentTypes}
668
545
  t={t}
669
- alwaysShowPaymentType={!!isFinaActive}
546
+ alwaysShowPaymentType={!!fina.isActive}
670
547
  />
671
548
  </DocumentDetailsSection>
672
549
  </div>
@@ -683,6 +560,7 @@ export default function CreateCreditNoteForm({
683
560
  maxTaxesPerItem={activeEntity?.country_rules?.max_taxes_per_item}
684
561
  priceModesRef={priceModesRef}
685
562
  initialPriceModes={initialPriceModes}
563
+ onItemsStateChange={emitCurrentPreviewPayload}
686
564
  taxesDisabled={reverseChargeApplies}
687
565
  taxesDisabledMessage={
688
566
  reverseChargeApplies ? t("Reverse charge - tax exempt EU B2B sale") : viesWarning ? viesWarning : undefined
@@ -4,6 +4,7 @@ import { useCallback, useMemo, useState } from "react";
4
4
  import { DataTable } from "@/ui/components/table/data-table";
5
5
  import { FormattedDate } from "@/ui/components/table/date-cell";
6
6
  import { useTableFetch } from "@/ui/components/table/hooks/use-table-fetch";
7
+ import { withTableTranslations } from "@/ui/components/table/locales";
7
8
  import { SelectionToolbar } from "@/ui/components/table/selection-toolbar";
8
9
  import type {
9
10
  Column,
@@ -31,7 +32,7 @@ import pl from "./locales/pl";
31
32
  import pt from "./locales/pt";
32
33
  import sl from "./locales/sl";
33
34
 
34
- const translations = {
35
+ const translations = withTableTranslations({
35
36
  en,
36
37
  sl,
37
38
  de,
@@ -42,12 +43,13 @@ const translations = {
42
43
  nl,
43
44
  pl,
44
45
  hr,
45
- } as const;
46
+ } as const);
46
47
 
47
48
  type CreditNoteListTableProps = {
48
49
  t?: (key: string) => string;
49
50
  namespace?: string;
50
51
  locale?: string;
52
+ translationLocale?: string;
51
53
  entityId?: string;
52
54
  onView?: (creditNote: CreditNote) => void;
53
55
  onAddPayment?: (creditNote: CreditNote) => void;
@@ -84,6 +86,7 @@ export default function CreditNoteListTable({
84
86
  }: CreditNoteListTableProps) {
85
87
  const t = createTranslation({
86
88
  translations,
89
+ locale: i18nProps.translationLocale ?? i18nProps.locale,
87
90
  ...i18nProps,
88
91
  });
89
92
 
@@ -209,7 +212,7 @@ export default function CreditNoteListTable({
209
212
  {
210
213
  id: "date",
211
214
  header: t("Date"),
212
- cell: (creditNote) => <FormattedDate date={creditNote.date} />,
215
+ cell: (creditNote) => <FormattedDate date={creditNote.date} locale={i18nProps.locale} />,
213
216
  },
214
217
  {
215
218
  id: "total",