@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
@@ -0,0 +1,509 @@
1
+ import { Download, Loader2, RefreshCcw, Save } from "lucide-react";
2
+ import { useEffect, useState } from "react";
3
+ import type SDK from "@spaceinvoices/js-sdk";
4
+ import type { ComponentTranslationProps } from "@/ui/lib/translation";
5
+ import { createTranslation } from "@/ui/lib/translation";
6
+ import { SloveniaTaxProfileStep, type SloveniaTaxProfileFormState } from "./slovenia-tax-profile-step";
7
+ import { SloveniaYearlyReviewStep } from "./slovenia-yearly-review-step";
8
+ import { Button } from "../ui/button";
9
+
10
+ type SloveniaYearlyExportFormProps = {
11
+ sdk: SDK;
12
+ entityId: string;
13
+ onSuccess?: (fileName: string) => void;
14
+ onError?: (error: Error) => void;
15
+ } & ComponentTranslationProps;
16
+
17
+ type TaxReportsApi = SDK["taxReports"];
18
+ type ProfileResponse = Awaited<ReturnType<TaxReportsApi["getSloveniaTaxProfile"]>>;
19
+ type DraftResponse = Awaited<ReturnType<TaxReportsApi["reviewSloveniaYearlyNormiraniReport"]>>;
20
+ type ManualValues = DraftResponse["manual_values"];
21
+ type UpdateProfileBody = Parameters<TaxReportsApi["updateSloveniaTaxProfile"]>[0];
22
+
23
+ const translations = {
24
+ en: {
25
+ "slovenia-yearly.title": "Yearly eDavki Report",
26
+ "slovenia-yearly.save-profile": "Save profile",
27
+ "slovenia-yearly.review": "Review yearly report",
28
+ "slovenia-yearly.refresh": "Refresh review",
29
+ "slovenia-yearly.export": "Download DDD-DDD XML",
30
+ "slovenia-yearly.loading": "Loading profile...",
31
+ "slovenia-yearly.saving": "Saving profile...",
32
+ "slovenia-yearly.reviewing": "Building review...",
33
+ "slovenia-yearly.exporting": "Generating XML...",
34
+ "slovenia-yearly.errors.load-profile": "Failed to load Slovenia tax profile",
35
+ "slovenia-yearly.errors.save-profile": "Failed to save Slovenia tax profile",
36
+ "slovenia-yearly.errors.review": "Failed to build yearly review",
37
+ "slovenia-yearly.errors.export": "Failed to export yearly XML",
38
+ "slovenia-yearly.unsupported.business-form-required": "Business form is required before export is available.",
39
+ "slovenia-yearly.unsupported.regime-required": "Income tax regime is required before export is available.",
40
+ "slovenia-yearly.unsupported.tax-residency-required": "Tax residency is required before export is available.",
41
+ "slovenia-yearly.unsupported.insurance-basis-required": "Insurance basis is required before export is available.",
42
+ "slovenia-yearly.unsupported.non-resident": "Only resident yearly export is supported in v1.",
43
+ "slovenia-yearly.unsupported.business-form":
44
+ "This profile is stored for future use, but only s.p. yearly export is supported in v1.",
45
+ "slovenia-yearly.unsupported.regime": "Only normirani yearly export is supported in v1.",
46
+ "slovenia-yearly.profile.year.label": "Tax year",
47
+ "slovenia-yearly.profile.business-form.label": "Business form",
48
+ "slovenia-yearly.profile.business-form.placeholder": "Select business form",
49
+ "slovenia-yearly.profile.business-form.options.sp": "s.p.",
50
+ "slovenia-yearly.profile.business-form.options.doo": "d.o.o.",
51
+ "slovenia-yearly.profile.business-form.options.dno": "d.n.o.",
52
+ "slovenia-yearly.profile.business-form.options.club": "Društvo / club",
53
+ "slovenia-yearly.profile.regime.label": "Income tax regime",
54
+ "slovenia-yearly.profile.regime.placeholder": "Select tax regime",
55
+ "slovenia-yearly.profile.regime.options.normirani": "Normirani",
56
+ "slovenia-yearly.profile.regime.options.dejanski": "Dejanski",
57
+ "slovenia-yearly.profile.residency.label": "Tax residency",
58
+ "slovenia-yearly.profile.residency.placeholder": "Select residency",
59
+ "slovenia-yearly.profile.residency.options.resident": "Resident",
60
+ "slovenia-yearly.profile.residency.options.non_resident": "Non-resident",
61
+ "slovenia-yearly.profile.vat-profile.label": "VAT profile",
62
+ "slovenia-yearly.profile.vat-profile.placeholder": "Optional",
63
+ "slovenia-yearly.profile.vat-profile.options.standard": "Standard VAT subject",
64
+ "slovenia-yearly.profile.vat-profile.options.special_vat_identified": "Special VAT subject",
65
+ "slovenia-yearly.profile.insurance-basis.label": "Insurance basis",
66
+ "slovenia-yearly.profile.insurance-basis.placeholder": "Select insurance basis",
67
+ "slovenia-yearly.profile.insurance-basis.options.full_time_self_employed": "Full-time self-employed",
68
+ "slovenia-yearly.profile.insurance-basis.options.other": "Other",
69
+ "slovenia-yearly.profile.activity-code.label": "Activity code",
70
+ "slovenia-yearly.profile.activity-code.placeholder": "62.010",
71
+ "slovenia-yearly.profile.registration-number.label": "Registration number",
72
+ "slovenia-yearly.profile.registration-number.placeholder": "Optional",
73
+ "slovenia-yearly.profile.unsupported.title": "Stored, but not exportable yet",
74
+ "slovenia-yearly.review.summary.adjusted-revenue": "Adjusted revenue",
75
+ "slovenia-yearly.review.summary.normative-expenses": "Normative expenses",
76
+ "slovenia-yearly.review.summary.income-tax": "Income tax",
77
+ "slovenia-yearly.review.rules.title": "Applied rules",
78
+ "slovenia-yearly.review.installments.title": "Installments",
79
+ "slovenia-yearly.review.installments.advance-tax": "Advance tax amount",
80
+ "slovenia-yearly.review.installments.monthly": "Monthly installment",
81
+ "slovenia-yearly.review.installments.quarterly": "Quarterly installment",
82
+ "slovenia-yearly.review.warnings.review-required": "Review required",
83
+ "slovenia-yearly.review.warnings.check-before-export": "Check before export",
84
+ "slovenia-yearly.review.issues.official-guidance": "Official guidance",
85
+ "slovenia-yearly.review.issues.affected-documents": "Affected documents",
86
+ "slovenia-yearly.review.issues.document-type.invoice": "Invoice",
87
+ "slovenia-yearly.review.issues.document-type.credit-note": "Credit note",
88
+ "slovenia-yearly.review.issues.open-document": "Open document",
89
+ "slovenia-yearly.review.issues.fields.date": "Date",
90
+ "slovenia-yearly.review.issues.fields.customer": "Customer",
91
+ "slovenia-yearly.review.issues.fields.country": "Country",
92
+ "slovenia-yearly.review.issues.fields.tax-number": "Tax number",
93
+ "slovenia-yearly.review.issues.fields.currency": "Currency",
94
+ "slovenia-yearly.review.manual.withholding-tax": "Withholding tax amount",
95
+ "slovenia-yearly.review.manual.foreign-tax-credit": "Foreign tax credit amount",
96
+ "slovenia-yearly.review.manual.prior-advance-income-tax": "Prior advance income tax amount",
97
+ "slovenia-yearly.review.manual.revenue-adjustment-decrease": "Revenue adjustment decrease",
98
+ "slovenia-yearly.review.manual.revenue-adjustment-increase": "Revenue adjustment increase",
99
+ },
100
+ sl: {
101
+ "slovenia-yearly.title": "Letno poročilo za eDavke",
102
+ "slovenia-yearly.save-profile": "Shrani profil",
103
+ "slovenia-yearly.review": "Preglej letno poročilo",
104
+ "slovenia-yearly.refresh": "Osveži pregled",
105
+ "slovenia-yearly.export": "Prenesi DDD-DDD XML",
106
+ "slovenia-yearly.loading": "Nalaganje profila...",
107
+ "slovenia-yearly.saving": "Shranjevanje profila...",
108
+ "slovenia-yearly.reviewing": "Priprava pregleda...",
109
+ "slovenia-yearly.exporting": "Generiranje XML ...",
110
+ "slovenia-yearly.errors.load-profile": "Nalaganje slovenskega davčnega profila ni uspelo",
111
+ "slovenia-yearly.errors.save-profile": "Shranjevanje slovenskega davčnega profila ni uspelo",
112
+ "slovenia-yearly.errors.review": "Priprava letnega pregleda ni uspela",
113
+ "slovenia-yearly.errors.export": "Izvoz letnega XML ni uspel",
114
+ "slovenia-yearly.unsupported.business-form-required": "Pred izvozom je treba določiti pravno obliko.",
115
+ "slovenia-yearly.unsupported.regime-required": "Pred izvozom je treba določiti dohodninski režim.",
116
+ "slovenia-yearly.unsupported.tax-residency-required": "Pred izvozom je treba določiti davčno rezidentstvo.",
117
+ "slovenia-yearly.unsupported.insurance-basis-required": "Pred izvozom je treba določiti zavarovalno podlago.",
118
+ "slovenia-yearly.unsupported.non-resident": "V prvi različici je podprt samo letni izvoz za rezidente.",
119
+ "slovenia-yearly.unsupported.business-form":
120
+ "Ta profil se shrani za prihodnjo uporabo, vendar je v prvi različici podprt samo letni izvoz za s.p.",
121
+ "slovenia-yearly.unsupported.regime": "V prvi različici je podprt samo letni izvoz za normirance.",
122
+ "slovenia-yearly.profile.year.label": "Davčno leto",
123
+ "slovenia-yearly.profile.business-form.label": "Pravna oblika",
124
+ "slovenia-yearly.profile.business-form.placeholder": "Izberi pravno obliko",
125
+ "slovenia-yearly.profile.business-form.options.sp": "s.p.",
126
+ "slovenia-yearly.profile.business-form.options.doo": "d.o.o.",
127
+ "slovenia-yearly.profile.business-form.options.dno": "d.n.o.",
128
+ "slovenia-yearly.profile.business-form.options.club": "Društvo",
129
+ "slovenia-yearly.profile.regime.label": "Dohodninski režim",
130
+ "slovenia-yearly.profile.regime.placeholder": "Izberi režim",
131
+ "slovenia-yearly.profile.regime.options.normirani": "Normirani",
132
+ "slovenia-yearly.profile.regime.options.dejanski": "Dejanski",
133
+ "slovenia-yearly.profile.residency.label": "Davčno rezidentstvo",
134
+ "slovenia-yearly.profile.residency.placeholder": "Izberi rezidentstvo",
135
+ "slovenia-yearly.profile.residency.options.resident": "Rezident",
136
+ "slovenia-yearly.profile.residency.options.non_resident": "Nerezident",
137
+ "slovenia-yearly.profile.vat-profile.label": "DDV profil",
138
+ "slovenia-yearly.profile.vat-profile.placeholder": "Neobvezno",
139
+ "slovenia-yearly.profile.vat-profile.options.standard": "Običajni DDV zavezanec",
140
+ "slovenia-yearly.profile.vat-profile.options.special_vat_identified": "Posebni DDV zavezanec",
141
+ "slovenia-yearly.profile.insurance-basis.label": "Zavarovalna podlaga",
142
+ "slovenia-yearly.profile.insurance-basis.placeholder": "Izberi zavarovalno podlago",
143
+ "slovenia-yearly.profile.insurance-basis.options.full_time_self_employed": "Polni s.p.",
144
+ "slovenia-yearly.profile.insurance-basis.options.other": "Drugo",
145
+ "slovenia-yearly.profile.activity-code.label": "Šifra dejavnosti",
146
+ "slovenia-yearly.profile.activity-code.placeholder": "62.010",
147
+ "slovenia-yearly.profile.registration-number.label": "Matična številka",
148
+ "slovenia-yearly.profile.registration-number.placeholder": "Neobvezno",
149
+ "slovenia-yearly.profile.unsupported.title": "Shranjeno, vendar še ni mogoče izvoziti",
150
+ "slovenia-yearly.review.summary.adjusted-revenue": "Prilagojeni prihodki",
151
+ "slovenia-yearly.review.summary.normative-expenses": "Normirani odhodki",
152
+ "slovenia-yearly.review.summary.income-tax": "Dohodnina",
153
+ "slovenia-yearly.review.rules.title": "Uporabljena pravila",
154
+ "slovenia-yearly.review.installments.title": "Akontacije",
155
+ "slovenia-yearly.review.installments.advance-tax": "Znesek akontacije",
156
+ "slovenia-yearly.review.installments.monthly": "Mesečni obrok",
157
+ "slovenia-yearly.review.installments.quarterly": "Četrtletni obrok",
158
+ "slovenia-yearly.review.warnings.review-required": "Potreben pregled",
159
+ "slovenia-yearly.review.warnings.check-before-export": "Preveri pred izvozom",
160
+ "slovenia-yearly.review.issues.official-guidance": "Uradna navodila",
161
+ "slovenia-yearly.review.issues.affected-documents": "Zadevni dokumenti",
162
+ "slovenia-yearly.review.issues.document-type.invoice": "Račun",
163
+ "slovenia-yearly.review.issues.document-type.credit-note": "Dobropis",
164
+ "slovenia-yearly.review.issues.open-document": "Odpri dokument",
165
+ "slovenia-yearly.review.issues.fields.date": "Datum",
166
+ "slovenia-yearly.review.issues.fields.customer": "Kupec",
167
+ "slovenia-yearly.review.issues.fields.country": "Država",
168
+ "slovenia-yearly.review.issues.fields.tax-number": "Davčna številka",
169
+ "slovenia-yearly.review.issues.fields.currency": "Valuta",
170
+ "slovenia-yearly.review.manual.withholding-tax": "Znesek davčnega odtegljaja",
171
+ "slovenia-yearly.review.manual.foreign-tax-credit": "Znesek tujega davčnega dobropisa",
172
+ "slovenia-yearly.review.manual.prior-advance-income-tax": "Predhodno plačana akontacija dohodnine",
173
+ "slovenia-yearly.review.manual.revenue-adjustment-decrease": "Znižanje prihodkov",
174
+ "slovenia-yearly.review.manual.revenue-adjustment-increase": "Povečanje prihodkov",
175
+ },
176
+ hr: {
177
+ "slovenia-yearly.title": "Godišnje eDavki izvješće",
178
+ "slovenia-yearly.save-profile": "Spremi profil",
179
+ "slovenia-yearly.review": "Pregledaj godišnje izvješće",
180
+ "slovenia-yearly.refresh": "Osvježi pregled",
181
+ "slovenia-yearly.export": "Preuzmi DDD-DDD XML",
182
+ "slovenia-yearly.loading": "Učitavanje profila...",
183
+ "slovenia-yearly.saving": "Spremanje profila...",
184
+ "slovenia-yearly.reviewing": "Priprema pregleda...",
185
+ "slovenia-yearly.exporting": "Generiranje XML-a...",
186
+ "slovenia-yearly.errors.load-profile": "Učitavanje slovenskog poreznog profila nije uspjelo",
187
+ "slovenia-yearly.errors.save-profile": "Spremanje slovenskog poreznog profila nije uspjelo",
188
+ "slovenia-yearly.errors.review": "Priprema godišnjeg pregleda nije uspjela",
189
+ "slovenia-yearly.errors.export": "Izvoz godišnjeg XML-a nije uspio",
190
+ "slovenia-yearly.unsupported.business-form-required": "Prije izvoza potrebno je odabrati pravni oblik.",
191
+ "slovenia-yearly.unsupported.regime-required": "Prije izvoza potrebno je odabrati porezni režim.",
192
+ "slovenia-yearly.unsupported.tax-residency-required": "Prije izvoza potrebno je odabrati poreznu rezidentnost.",
193
+ "slovenia-yearly.unsupported.insurance-basis-required": "Prije izvoza potrebno je odabrati osnovu osiguranja.",
194
+ "slovenia-yearly.unsupported.non-resident": "U prvoj verziji podržan je samo godišnji izvoz za rezidente.",
195
+ "slovenia-yearly.unsupported.business-form":
196
+ "Ovaj profil se sprema za buduću upotrebu, ali je u prvoj verziji podržan samo godišnji izvoz za s.p.",
197
+ "slovenia-yearly.unsupported.regime": "U prvoj verziji podržan je samo godišnji izvoz za normirance.",
198
+ "slovenia-yearly.profile.year.label": "Porezna godina",
199
+ "slovenia-yearly.profile.business-form.label": "Pravni oblik",
200
+ "slovenia-yearly.profile.business-form.placeholder": "Odaberi pravni oblik",
201
+ "slovenia-yearly.profile.business-form.options.sp": "s.p.",
202
+ "slovenia-yearly.profile.business-form.options.doo": "d.o.o.",
203
+ "slovenia-yearly.profile.business-form.options.dno": "d.n.o.",
204
+ "slovenia-yearly.profile.business-form.options.club": "Udruga",
205
+ "slovenia-yearly.profile.regime.label": "Porezni režim",
206
+ "slovenia-yearly.profile.regime.placeholder": "Odaberi režim",
207
+ "slovenia-yearly.profile.regime.options.normirani": "Normirani",
208
+ "slovenia-yearly.profile.regime.options.dejanski": "Dejanski",
209
+ "slovenia-yearly.profile.residency.label": "Porezna rezidentnost",
210
+ "slovenia-yearly.profile.residency.placeholder": "Odaberi rezidentnost",
211
+ "slovenia-yearly.profile.residency.options.resident": "Rezident",
212
+ "slovenia-yearly.profile.residency.options.non_resident": "Nerezident",
213
+ "slovenia-yearly.profile.vat-profile.label": "PDV profil",
214
+ "slovenia-yearly.profile.vat-profile.placeholder": "Opcionalno",
215
+ "slovenia-yearly.profile.vat-profile.options.standard": "Standardni PDV obveznik",
216
+ "slovenia-yearly.profile.vat-profile.options.special_vat_identified": "Posebni PDV obveznik",
217
+ "slovenia-yearly.profile.insurance-basis.label": "Osnova osiguranja",
218
+ "slovenia-yearly.profile.insurance-basis.placeholder": "Odaberi osnovu osiguranja",
219
+ "slovenia-yearly.profile.insurance-basis.options.full_time_self_employed": "Puni samostalni obrt",
220
+ "slovenia-yearly.profile.insurance-basis.options.other": "Drugo",
221
+ "slovenia-yearly.profile.activity-code.label": "Šifra djelatnosti",
222
+ "slovenia-yearly.profile.activity-code.placeholder": "62.010",
223
+ "slovenia-yearly.profile.registration-number.label": "Matični broj",
224
+ "slovenia-yearly.profile.registration-number.placeholder": "Opcionalno",
225
+ "slovenia-yearly.profile.unsupported.title": "Spremljeno, ali još nije moguće izvesti",
226
+ "slovenia-yearly.review.summary.adjusted-revenue": "Prilagođeni prihodi",
227
+ "slovenia-yearly.review.summary.normative-expenses": "Normirani troškovi",
228
+ "slovenia-yearly.review.summary.income-tax": "Porez na dohodak",
229
+ "slovenia-yearly.review.rules.title": "Primijenjena pravila",
230
+ "slovenia-yearly.review.installments.title": "Akontacije",
231
+ "slovenia-yearly.review.installments.advance-tax": "Iznos akontacije",
232
+ "slovenia-yearly.review.installments.monthly": "Mjesečni obrok",
233
+ "slovenia-yearly.review.installments.quarterly": "Tromjesečni obrok",
234
+ "slovenia-yearly.review.warnings.review-required": "Potreban pregled",
235
+ "slovenia-yearly.review.warnings.check-before-export": "Provjeri prije izvoza",
236
+ "slovenia-yearly.review.issues.official-guidance": "Službene upute",
237
+ "slovenia-yearly.review.issues.affected-documents": "Povezani dokumenti",
238
+ "slovenia-yearly.review.issues.document-type.invoice": "Račun",
239
+ "slovenia-yearly.review.issues.document-type.credit-note": "Odobrenje",
240
+ "slovenia-yearly.review.issues.open-document": "Otvori dokument",
241
+ "slovenia-yearly.review.issues.fields.date": "Datum",
242
+ "slovenia-yearly.review.issues.fields.customer": "Kupac",
243
+ "slovenia-yearly.review.issues.fields.country": "Država",
244
+ "slovenia-yearly.review.issues.fields.tax-number": "Porezni broj",
245
+ "slovenia-yearly.review.issues.fields.currency": "Valuta",
246
+ "slovenia-yearly.review.manual.withholding-tax": "Iznos poreza po odbitku",
247
+ "slovenia-yearly.review.manual.foreign-tax-credit": "Iznos inozemnog poreznog kredita",
248
+ "slovenia-yearly.review.manual.prior-advance-income-tax": "Prethodno plaćena akontacija poreza na dohodak",
249
+ "slovenia-yearly.review.manual.revenue-adjustment-decrease": "Smanjenje prihoda",
250
+ "slovenia-yearly.review.manual.revenue-adjustment-increase": "Povećanje prihoda",
251
+ },
252
+ } as const;
253
+
254
+ function getDefaultYear(): number {
255
+ return new Date().getFullYear() - 1;
256
+ }
257
+
258
+ function createDefaultProfileForm(): SloveniaTaxProfileFormState {
259
+ return {
260
+ business_form: "sp",
261
+ income_tax_regime: "normirani",
262
+ vat_profile: "",
263
+ tax_residency: "resident",
264
+ activity_code: "",
265
+ registration_number: "",
266
+ normiranec_insurance_basis: "full_time_self_employed",
267
+ };
268
+ }
269
+
270
+ function getUnsupportedReasonKey(form: SloveniaTaxProfileFormState): string | null {
271
+ if (!form.business_form) return "slovenia-yearly.unsupported.business-form-required";
272
+ if (!form.income_tax_regime) return "slovenia-yearly.unsupported.regime-required";
273
+ if (!form.tax_residency) return "slovenia-yearly.unsupported.tax-residency-required";
274
+ if (!form.normiranec_insurance_basis) return "slovenia-yearly.unsupported.insurance-basis-required";
275
+ if (form.tax_residency !== "resident") return "slovenia-yearly.unsupported.non-resident";
276
+ if (form.business_form !== "sp") return "slovenia-yearly.unsupported.business-form";
277
+ if (form.income_tax_regime !== "normirani") return "slovenia-yearly.unsupported.regime";
278
+ return null;
279
+ }
280
+
281
+ function profileToForm(profile: ProfileResponse): SloveniaTaxProfileFormState {
282
+ return {
283
+ business_form: profile.business_form ?? "sp",
284
+ income_tax_regime: profile.income_tax_regime ?? "normirani",
285
+ vat_profile: profile.vat_profile ?? "",
286
+ tax_residency: profile.tax_residency ?? "resident",
287
+ activity_code: profile.yearly_reporting.activity_code ?? "",
288
+ registration_number: profile.yearly_reporting.registration_number ?? "",
289
+ normiranec_insurance_basis: profile.yearly_reporting.normiranec_insurance_basis ?? "full_time_self_employed",
290
+ };
291
+ }
292
+
293
+ export function SloveniaYearlyExportForm({
294
+ sdk,
295
+ entityId,
296
+ t: translateFn,
297
+ namespace,
298
+ locale,
299
+ onSuccess,
300
+ onError,
301
+ }: SloveniaYearlyExportFormProps) {
302
+ const t = createTranslation({ t: translateFn, namespace, locale, translations });
303
+ const [year, setYear] = useState(getDefaultYear);
304
+ const [profileForm, setProfileForm] = useState<SloveniaTaxProfileFormState>(createDefaultProfileForm);
305
+ const [draft, setDraft] = useState<DraftResponse | null>(null);
306
+ const [manualValues, setManualValues] = useState<ManualValues>({
307
+ withholding_tax_amount: 0,
308
+ foreign_tax_credit_amount: 0,
309
+ prior_advance_income_tax_amount: 0,
310
+ revenue_adjustment_decrease: 0,
311
+ revenue_adjustment_increase: 0,
312
+ });
313
+ const [isLoadingProfile, setIsLoadingProfile] = useState(true);
314
+ const [isSavingProfile, setIsSavingProfile] = useState(false);
315
+ const [isReviewing, setIsReviewing] = useState(false);
316
+ const [isExporting, setIsExporting] = useState(false);
317
+
318
+ useEffect(() => {
319
+ let isMounted = true;
320
+
321
+ const loadProfile = async () => {
322
+ setIsLoadingProfile(true);
323
+
324
+ try {
325
+ const profile = await sdk.taxReports.getSloveniaTaxProfile({
326
+ entity_id: entityId,
327
+ });
328
+
329
+ if (!isMounted) return;
330
+ setProfileForm(profileToForm(profile));
331
+ } catch (error) {
332
+ onError?.(error instanceof Error ? error : new Error(t("slovenia-yearly.errors.load-profile")));
333
+ } finally {
334
+ if (isMounted) {
335
+ setIsLoadingProfile(false);
336
+ }
337
+ }
338
+ };
339
+
340
+ void loadProfile();
341
+
342
+ return () => {
343
+ isMounted = false;
344
+ };
345
+ }, [entityId, onError, sdk.taxReports]);
346
+
347
+ const unsupportedReasonKey = getUnsupportedReasonKey(profileForm);
348
+ const unsupportedReason = unsupportedReasonKey ? t(unsupportedReasonKey) : null;
349
+ const yearOptions = Array.from({ length: 4 }, (_, index) => getDefaultYear() + 1 - index);
350
+
351
+ const saveProfile = async (): Promise<ProfileResponse> => {
352
+ setIsSavingProfile(true);
353
+
354
+ try {
355
+ const payload: UpdateProfileBody = {
356
+ business_form: profileForm.business_form || undefined,
357
+ income_tax_regime: profileForm.income_tax_regime || undefined,
358
+ vat_profile: profileForm.vat_profile || undefined,
359
+ tax_residency: profileForm.tax_residency || undefined,
360
+ yearly_reporting: {
361
+ activity_code: profileForm.activity_code || null,
362
+ registration_number: profileForm.registration_number || null,
363
+ normiranec_insurance_basis: profileForm.normiranec_insurance_basis || null,
364
+ },
365
+ };
366
+
367
+ const profile = await sdk.taxReports.updateSloveniaTaxProfile(payload, {
368
+ entity_id: entityId,
369
+ });
370
+
371
+ setProfileForm(profileToForm(profile));
372
+ return profile;
373
+ } catch (error) {
374
+ throw error instanceof Error ? error : new Error(t("slovenia-yearly.errors.save-profile"));
375
+ } finally {
376
+ setIsSavingProfile(false);
377
+ }
378
+ };
379
+
380
+ const handleReview = async () => {
381
+ try {
382
+ const profile = await saveProfile();
383
+
384
+ if (!profile.supported_exports.yearly_normirani) {
385
+ setDraft(null);
386
+ return;
387
+ }
388
+
389
+ setIsReviewing(true);
390
+ const response = await sdk.taxReports.reviewSloveniaYearlyNormiraniReport(
391
+ {
392
+ year,
393
+ },
394
+ { entity_id: entityId },
395
+ );
396
+
397
+ setDraft(response);
398
+ setManualValues(response.manual_values);
399
+ } catch (error) {
400
+ onError?.(error instanceof Error ? error : new Error(t("slovenia-yearly.errors.review")));
401
+ } finally {
402
+ setIsReviewing(false);
403
+ }
404
+ };
405
+
406
+ const handleExport = async () => {
407
+ setIsExporting(true);
408
+
409
+ try {
410
+ const blob = await sdk.taxReports.exportSloveniaYearlyNormiraniReport(
411
+ {
412
+ year,
413
+ manual_values: manualValues,
414
+ },
415
+ { entity_id: entityId },
416
+ );
417
+
418
+ const fileName = `DDD-DDD_${year}.xml`;
419
+ const downloadUrl = window.URL.createObjectURL(blob);
420
+ const link = document.createElement("a");
421
+ link.href = downloadUrl;
422
+ link.download = fileName;
423
+ document.body.appendChild(link);
424
+ link.click();
425
+ setTimeout(() => {
426
+ document.body.removeChild(link);
427
+ window.URL.revokeObjectURL(downloadUrl);
428
+ }, 1000);
429
+
430
+ onSuccess?.(fileName);
431
+ } catch (error) {
432
+ onError?.(error instanceof Error ? error : new Error(t("slovenia-yearly.errors.export")));
433
+ } finally {
434
+ setIsExporting(false);
435
+ }
436
+ };
437
+
438
+ return (
439
+ <div className="space-y-6">
440
+ {isLoadingProfile ? (
441
+ <div className="text-muted-foreground text-sm">{t("slovenia-yearly.loading")}</div>
442
+ ) : (
443
+ <>
444
+ <SloveniaTaxProfileStep
445
+ form={profileForm}
446
+ t={t}
447
+ onFieldChange={(field, value) => {
448
+ setProfileForm((current) => ({ ...current, [field]: value }));
449
+ }}
450
+ unsupportedReason={unsupportedReason}
451
+ year={year}
452
+ onYearChange={setYear}
453
+ yearOptions={yearOptions}
454
+ />
455
+
456
+ <div className="flex flex-wrap gap-3">
457
+ <Button onClick={handleReview} disabled={isSavingProfile || isReviewing}>
458
+ {isSavingProfile || isReviewing ? (
459
+ <>
460
+ <Loader2 className="mr-2 h-4 w-4 animate-spin" />
461
+ {isSavingProfile ? t("slovenia-yearly.saving") : t("slovenia-yearly.reviewing")}
462
+ </>
463
+ ) : unsupportedReason ? (
464
+ <>
465
+ <Save className="mr-2 h-4 w-4" />
466
+ {t("slovenia-yearly.save-profile")}
467
+ </>
468
+ ) : draft ? (
469
+ <>
470
+ <RefreshCcw className="mr-2 h-4 w-4" />
471
+ {t("slovenia-yearly.refresh")}
472
+ </>
473
+ ) : (
474
+ t("slovenia-yearly.review")
475
+ )}
476
+ </Button>
477
+
478
+ {draft && !unsupportedReason && (
479
+ <Button onClick={handleExport} disabled={isExporting} variant="outline">
480
+ {isExporting ? (
481
+ <>
482
+ <Loader2 className="mr-2 h-4 w-4 animate-spin" />
483
+ {t("slovenia-yearly.exporting")}
484
+ </>
485
+ ) : (
486
+ <>
487
+ <Download className="mr-2 h-4 w-4" />
488
+ {t("slovenia-yearly.export")}
489
+ </>
490
+ )}
491
+ </Button>
492
+ )}
493
+ </div>
494
+
495
+ {draft && !unsupportedReason && (
496
+ <SloveniaYearlyReviewStep
497
+ draft={draft}
498
+ manualValues={manualValues}
499
+ t={t}
500
+ onManualValueChange={(field, value) => {
501
+ setManualValues((current: ManualValues) => ({ ...current, [field]: value }));
502
+ }}
503
+ />
504
+ )}
505
+ </>
506
+ )}
507
+ </div>
508
+ );
509
+ }