@spaceinvoices/react-ui 0.4.11 → 0.4.31
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.
- package/cli/dist/index.js +1 -1
- package/package.json +3 -2
- package/registry.json +30 -31
- package/src/common/autocomplete.tsx +48 -26
- package/src/components/activities/locales/bg.ts +21 -0
- package/src/components/activities/locales/cs.ts +21 -0
- package/src/components/activities/locales/en.ts +21 -0
- package/src/components/activities/locales/et.ts +21 -0
- package/src/components/activities/locales/fi.ts +21 -0
- package/src/components/activities/locales/is.ts +21 -0
- package/src/components/activities/locales/nb.ts +21 -0
- package/src/components/activities/locales/sk.ts +21 -0
- package/src/components/activities/locales/sv.ts +21 -0
- package/src/components/advance-invoices/advance-invoices.hooks.ts +36 -46
- package/src/components/advance-invoices/create/create-advance-invoice-form.tsx +452 -115
- package/src/components/advance-invoices/create/locales/bg.ts +56 -0
- package/src/components/advance-invoices/create/locales/cs.ts +56 -0
- package/src/components/advance-invoices/create/locales/de.ts +15 -7
- package/src/components/advance-invoices/create/locales/en.ts +56 -0
- package/src/components/advance-invoices/create/locales/es.ts +15 -7
- package/src/components/advance-invoices/create/locales/et.ts +56 -0
- package/src/components/advance-invoices/create/locales/fi.ts +56 -0
- package/src/components/advance-invoices/create/locales/fr.ts +16 -8
- package/src/components/advance-invoices/create/locales/hr.ts +29 -21
- package/src/components/advance-invoices/create/locales/is.ts +56 -0
- package/src/components/advance-invoices/create/locales/it.ts +15 -7
- package/src/components/advance-invoices/create/locales/nb.ts +56 -0
- package/src/components/advance-invoices/create/locales/nl.ts +15 -7
- package/src/components/advance-invoices/create/locales/pl.ts +17 -9
- package/src/components/advance-invoices/create/locales/pt.ts +16 -8
- package/src/components/advance-invoices/create/locales/sk.ts +56 -0
- package/src/components/advance-invoices/create/locales/sl.ts +23 -12
- package/src/components/advance-invoices/create/locales/sv.ts +56 -0
- package/src/components/advance-invoices/create/prepare-advance-invoice-submission.ts +62 -2
- package/src/components/advance-invoices/list/list-row-actions.tsx +48 -16
- package/src/components/advance-invoices/list/list-table.tsx +35 -9
- package/src/components/advance-invoices/list/locales/bg.ts +51 -0
- package/src/components/advance-invoices/list/locales/cs.ts +51 -0
- package/src/components/advance-invoices/list/locales/en.ts +33 -2
- package/src/components/advance-invoices/list/locales/et.ts +51 -0
- package/src/components/advance-invoices/list/locales/fi.ts +51 -0
- package/src/components/advance-invoices/list/locales/hr.ts +15 -15
- package/src/components/advance-invoices/list/locales/is.ts +51 -0
- package/src/components/advance-invoices/list/locales/nb.ts +51 -0
- package/src/components/advance-invoices/list/locales/sk.ts +51 -0
- package/src/components/advance-invoices/list/locales/sv.ts +51 -0
- package/src/components/advance-invoices/list/use-advance-invoice-download.ts +3 -5
- package/src/components/common/autocomplete-locales.ts +101 -0
- package/src/components/company-registry/company-registry.hooks.ts +3 -7
- package/src/components/credit-notes/create/create-credit-note-form.tsx +437 -80
- package/src/components/credit-notes/create/locales/bg.ts +101 -0
- package/src/components/credit-notes/create/locales/cs.ts +101 -0
- package/src/components/credit-notes/create/locales/de.ts +20 -7
- package/src/components/credit-notes/create/locales/en.ts +101 -0
- package/src/components/credit-notes/create/locales/es.ts +20 -7
- package/src/components/credit-notes/create/locales/et.ts +101 -0
- package/src/components/credit-notes/create/locales/fi.ts +101 -0
- package/src/components/credit-notes/create/locales/fr.ts +21 -8
- package/src/components/credit-notes/create/locales/hr.ts +41 -28
- package/src/components/credit-notes/create/locales/is.ts +101 -0
- package/src/components/credit-notes/create/locales/it.ts +20 -7
- package/src/components/credit-notes/create/locales/nb.ts +101 -0
- package/src/components/credit-notes/create/locales/nl.ts +20 -7
- package/src/components/credit-notes/create/locales/pl.ts +22 -9
- package/src/components/credit-notes/create/locales/pt.ts +21 -8
- package/src/components/credit-notes/create/locales/sk.ts +101 -0
- package/src/components/credit-notes/create/locales/sl.ts +28 -14
- package/src/components/credit-notes/create/locales/sv.ts +101 -0
- package/src/components/credit-notes/create/prepare-credit-note-submission.ts +66 -0
- package/src/components/credit-notes/credit-notes.hooks.ts +34 -3
- package/src/components/credit-notes/list/list-row-actions.tsx +19 -7
- package/src/components/credit-notes/list/list-table.tsx +60 -8
- package/src/components/credit-notes/list/locales/bg.ts +48 -0
- package/src/components/credit-notes/list/locales/cs.ts +48 -0
- package/src/components/credit-notes/list/locales/en.ts +31 -2
- package/src/components/credit-notes/list/locales/et.ts +48 -0
- package/src/components/credit-notes/list/locales/fi.ts +48 -0
- package/src/components/credit-notes/list/locales/hr.ts +12 -12
- package/src/components/credit-notes/list/locales/is.ts +48 -0
- package/src/components/credit-notes/list/locales/nb.ts +48 -0
- package/src/components/credit-notes/list/locales/sk.ts +48 -0
- package/src/components/credit-notes/list/locales/sv.ts +48 -0
- package/src/components/credit-notes/list/use-credit-note-download.ts +3 -5
- package/src/components/customers/create-customer-form/locales/bg.ts +21 -0
- package/src/components/customers/create-customer-form/locales/cs.ts +21 -0
- package/src/components/customers/create-customer-form/locales/en.ts +21 -0
- package/src/components/customers/create-customer-form/locales/et.ts +21 -0
- package/src/components/customers/create-customer-form/locales/fi.ts +21 -0
- package/src/components/customers/create-customer-form/locales/hr.ts +11 -11
- package/src/components/customers/create-customer-form/locales/is.ts +21 -0
- package/src/components/customers/create-customer-form/locales/nb.ts +21 -0
- package/src/components/customers/create-customer-form/locales/sk.ts +21 -0
- package/src/components/customers/create-customer-form/locales/sv.ts +21 -0
- package/src/components/customers/customer-autocomplete.tsx +32 -4
- package/src/components/customers/customer-list-table/customer-list-table.tsx +8 -6
- package/src/components/customers/customer-list-table/locales/bg.ts +25 -0
- package/src/components/customers/customer-list-table/locales/cs.ts +25 -0
- package/src/components/customers/customer-list-table/locales/en.ts +17 -2
- package/src/components/customers/customer-list-table/locales/et.ts +25 -0
- package/src/components/customers/customer-list-table/locales/fi.ts +25 -0
- package/src/components/customers/customer-list-table/locales/hr.ts +11 -11
- package/src/components/customers/customer-list-table/locales/is.ts +25 -0
- package/src/components/customers/customer-list-table/locales/nb.ts +25 -0
- package/src/components/customers/customer-list-table/locales/sk.ts +25 -0
- package/src/components/customers/customer-list-table/locales/sv.ts +25 -0
- package/src/components/customers/customers.hooks.ts +14 -17
- package/src/components/customers/edit-customer-form/locales/bg.ts +13 -0
- package/src/components/customers/edit-customer-form/locales/cs.ts +13 -0
- package/src/components/customers/edit-customer-form/locales/en.ts +13 -0
- package/src/components/customers/edit-customer-form/locales/et.ts +13 -0
- package/src/components/customers/edit-customer-form/locales/fi.ts +13 -0
- package/src/components/customers/edit-customer-form/locales/hr.ts +5 -5
- package/src/components/customers/edit-customer-form/locales/is.ts +13 -0
- package/src/components/customers/edit-customer-form/locales/nb.ts +13 -0
- package/src/components/customers/edit-customer-form/locales/sk.ts +13 -0
- package/src/components/customers/edit-customer-form/locales/sv.ts +13 -0
- package/src/components/dashboard/collection-rate-card/collection-rate-card.tsx +7 -6
- package/src/components/dashboard/collection-rate-card/locales/en.ts +3 -0
- package/src/components/dashboard/collection-rate-card/use-collection-rate.ts +8 -7
- package/src/components/dashboard/invoice-status-chart/invoice-status-chart.tsx +7 -4
- package/src/components/dashboard/invoice-status-chart/locales/bg.ts +5 -5
- package/src/components/dashboard/invoice-status-chart/locales/cs.ts +5 -5
- package/src/components/dashboard/invoice-status-chart/locales/de.ts +1 -1
- package/src/components/dashboard/invoice-status-chart/locales/en.ts +10 -0
- package/src/components/dashboard/invoice-status-chart/locales/es.ts +1 -1
- package/src/components/dashboard/invoice-status-chart/locales/et.ts +5 -5
- package/src/components/dashboard/invoice-status-chart/locales/fi.ts +5 -5
- package/src/components/dashboard/invoice-status-chart/locales/fr.ts +1 -1
- package/src/components/dashboard/invoice-status-chart/locales/hr.ts +5 -5
- package/src/components/dashboard/invoice-status-chart/locales/is.ts +5 -5
- package/src/components/dashboard/invoice-status-chart/locales/it.ts +1 -1
- package/src/components/dashboard/invoice-status-chart/locales/nb.ts +5 -5
- package/src/components/dashboard/invoice-status-chart/locales/nl.ts +1 -1
- package/src/components/dashboard/invoice-status-chart/locales/pl.ts +1 -1
- package/src/components/dashboard/invoice-status-chart/locales/pt.ts +1 -1
- package/src/components/dashboard/invoice-status-chart/locales/sk.ts +5 -5
- package/src/components/dashboard/invoice-status-chart/locales/sl.ts +1 -1
- package/src/components/dashboard/invoice-status-chart/locales/sv.ts +5 -5
- package/src/components/dashboard/payment-methods-chart/locales/bg.ts +5 -5
- package/src/components/dashboard/payment-methods-chart/locales/cs.ts +5 -5
- package/src/components/dashboard/payment-methods-chart/locales/en.ts +12 -0
- package/src/components/dashboard/payment-methods-chart/locales/et.ts +5 -5
- package/src/components/dashboard/payment-methods-chart/locales/fi.ts +6 -6
- package/src/components/dashboard/payment-methods-chart/locales/hr.ts +3 -3
- package/src/components/dashboard/payment-methods-chart/locales/is.ts +5 -5
- package/src/components/dashboard/payment-methods-chart/locales/nb.ts +5 -5
- package/src/components/dashboard/payment-methods-chart/locales/sk.ts +5 -5
- package/src/components/dashboard/payment-methods-chart/locales/sv.ts +5 -5
- package/src/components/dashboard/payment-methods-chart/payment-methods-chart.tsx +4 -3
- package/src/components/dashboard/payment-trend-chart/locales/bg.ts +1 -1
- package/src/components/dashboard/payment-trend-chart/locales/cs.ts +1 -1
- package/src/components/dashboard/payment-trend-chart/locales/en.ts +6 -0
- package/src/components/dashboard/payment-trend-chart/locales/et.ts +1 -1
- package/src/components/dashboard/payment-trend-chart/locales/fi.ts +1 -1
- package/src/components/dashboard/payment-trend-chart/locales/is.ts +1 -1
- package/src/components/dashboard/payment-trend-chart/locales/nb.ts +1 -1
- package/src/components/dashboard/payment-trend-chart/locales/sk.ts +1 -1
- package/src/components/dashboard/payment-trend-chart/locales/sv.ts +1 -1
- package/src/components/dashboard/payment-trend-chart/payment-trend-chart.tsx +4 -3
- package/src/components/dashboard/payment-trend-chart/use-payment-trend.ts +12 -9
- package/src/components/dashboard/revenue-card.tsx +3 -3
- package/src/components/dashboard/revenue-trend-chart/locales/bg.ts +1 -1
- package/src/components/dashboard/revenue-trend-chart/locales/cs.ts +1 -1
- package/src/components/dashboard/revenue-trend-chart/locales/en.ts +6 -0
- package/src/components/dashboard/revenue-trend-chart/locales/et.ts +1 -1
- package/src/components/dashboard/revenue-trend-chart/locales/fi.ts +1 -1
- package/src/components/dashboard/revenue-trend-chart/locales/is.ts +1 -1
- package/src/components/dashboard/revenue-trend-chart/locales/nb.ts +1 -1
- package/src/components/dashboard/revenue-trend-chart/locales/sk.ts +1 -1
- package/src/components/dashboard/revenue-trend-chart/locales/sv.ts +1 -1
- package/src/components/dashboard/revenue-trend-chart/revenue-trend-chart.tsx +4 -3
- package/src/components/dashboard/revenue-trend-chart/use-revenue-trend.ts +4 -3
- package/src/components/dashboard/shared/local-date.ts +11 -0
- package/src/components/dashboard/shared/use-revenue-data.ts +6 -5
- package/src/components/dashboard/shared/use-stats-query.ts +7 -11
- package/src/components/dashboard/stat-card.tsx +3 -3
- package/src/components/dashboard/tax-collected-card/tax-collected-card.tsx +11 -9
- package/src/components/dashboard/tax-collected-card/use-tax-collected.ts +3 -2
- package/src/components/dashboard/top-customers-chart/locales/bg.ts +2 -2
- package/src/components/dashboard/top-customers-chart/locales/cs.ts +2 -2
- package/src/components/dashboard/top-customers-chart/locales/en.ts +7 -0
- package/src/components/dashboard/top-customers-chart/locales/et.ts +2 -2
- package/src/components/dashboard/top-customers-chart/locales/fi.ts +2 -2
- package/src/components/dashboard/top-customers-chart/locales/is.ts +2 -2
- package/src/components/dashboard/top-customers-chart/locales/nb.ts +2 -2
- package/src/components/dashboard/top-customers-chart/locales/sk.ts +2 -2
- package/src/components/dashboard/top-customers-chart/locales/sv.ts +2 -2
- package/src/components/dashboard/top-customers-chart/top-customers-chart.tsx +4 -3
- package/src/components/dashboard/top-customers-chart/use-top-customers.ts +7 -20
- package/src/components/delivery-notes/create/create-delivery-note-form.tsx +179 -47
- package/src/components/delivery-notes/create/locales/bg.ts +69 -0
- package/src/components/delivery-notes/create/locales/cs.ts +69 -0
- package/src/components/delivery-notes/create/locales/de.ts +1 -0
- package/src/components/delivery-notes/create/locales/en.ts +69 -0
- package/src/components/delivery-notes/create/locales/es.ts +1 -0
- package/src/components/delivery-notes/create/locales/et.ts +69 -0
- package/src/components/delivery-notes/create/locales/fi.ts +69 -0
- package/src/components/delivery-notes/create/locales/fr.ts +1 -0
- package/src/components/delivery-notes/create/locales/hr.ts +7 -6
- package/src/components/delivery-notes/create/locales/is.ts +69 -0
- package/src/components/delivery-notes/create/locales/it.ts +1 -0
- package/src/components/delivery-notes/create/locales/nb.ts +69 -0
- package/src/components/delivery-notes/create/locales/nl.ts +1 -0
- package/src/components/delivery-notes/create/locales/pl.ts +1 -0
- package/src/components/delivery-notes/create/locales/pt.ts +1 -0
- package/src/components/delivery-notes/create/locales/sk.ts +69 -0
- package/src/components/delivery-notes/create/locales/sl.ts +6 -5
- package/src/components/delivery-notes/create/locales/sv.ts +69 -0
- package/src/components/delivery-notes/create/prepare-delivery-note-submission.ts +34 -1
- package/src/components/delivery-notes/delivery-notes.hooks.ts +34 -3
- package/src/components/delivery-notes/list/list-row-actions.tsx +62 -16
- package/src/components/delivery-notes/list/list-table.tsx +44 -10
- package/src/components/delivery-notes/list/locales/bg.ts +40 -0
- package/src/components/delivery-notes/list/locales/cs.ts +40 -0
- package/src/components/delivery-notes/list/locales/et.ts +40 -0
- package/src/components/delivery-notes/list/locales/fi.ts +40 -0
- package/src/components/delivery-notes/list/locales/is.ts +40 -0
- package/src/components/delivery-notes/list/locales/nb.ts +40 -0
- package/src/components/delivery-notes/list/locales/sk.ts +40 -0
- package/src/components/delivery-notes/list/locales/sv.ts +40 -0
- package/src/components/delivery-notes/list/use-delivery-note-download.ts +3 -5
- package/src/components/documents/create/custom-create-template.ts +114 -0
- package/src/components/documents/create/document-add-item-form.tsx +266 -153
- package/src/components/documents/create/document-add-item-tax-rate-field.tsx +3 -3
- package/src/components/documents/create/document-date-validation.ts +111 -0
- package/src/components/documents/create/document-details-section.tsx +117 -54
- package/src/components/documents/create/document-form-item.ts +67 -0
- package/src/components/documents/create/document-item-validation.ts +54 -0
- package/src/components/documents/create/document-items-section.tsx +44 -6
- package/src/components/documents/create/document-recipient-section.tsx +10 -2
- package/src/components/documents/create/form-types.ts +2 -2
- package/src/components/documents/create/linked-documents-info.tsx +6 -14
- package/src/components/documents/create/live-preview.tsx +22 -18
- package/src/components/documents/create/mark-as-paid-section.tsx +80 -20
- package/src/components/documents/create/payment-rows.ts +321 -0
- package/src/components/documents/create/prepare-document-submission.ts +160 -109
- package/src/components/documents/create/prepare-preview-data.ts +12 -0
- package/src/components/documents/create/preserved-expected-total.ts +90 -0
- package/src/components/documents/create/scroll-to-first-invalid-field.ts +27 -0
- package/src/components/documents/create/smart-code-insert-button.tsx +5 -53
- package/src/components/documents/create/use-document-customer-form.ts +74 -25
- package/src/components/documents/documents.hooks.ts +3 -5
- package/src/components/documents/index.ts +1 -0
- package/src/components/documents/public/index.ts +1 -0
- package/src/components/documents/public/public-document-summary.tsx +336 -0
- package/src/components/documents/shared/document-preview-display.tsx +65 -39
- package/src/components/documents/shared/index.ts +6 -1
- package/src/components/documents/shared/scaled-document-preview.tsx +33 -19
- package/src/components/documents/types.ts +24 -0
- package/src/components/documents/view/document-actions-bar.tsx +251 -63
- package/src/components/documents/view/document-activities-list.tsx +23 -11
- package/src/components/documents/view/document-details-card.tsx +11 -39
- package/src/components/documents/view/document-payments-list.tsx +114 -57
- package/src/components/documents/view/document-relations-list.tsx +26 -6
- package/src/components/documents/view/document-sidebar.tsx +25 -3
- package/src/components/documents/view/document-version-history.tsx +137 -0
- package/src/components/documents/view/index.ts +1 -0
- package/src/components/documents/view/locales/bg.ts +143 -0
- package/src/components/documents/view/locales/cs.ts +143 -0
- package/src/components/documents/view/locales/de.ts +13 -0
- package/src/components/documents/view/locales/en.ts +143 -0
- package/src/components/documents/view/locales/es.ts +13 -0
- package/src/components/documents/view/locales/et.ts +143 -0
- package/src/components/documents/view/locales/fi.ts +143 -0
- package/src/components/documents/view/locales/fr.ts +13 -0
- package/src/components/documents/view/locales/hr.ts +18 -5
- package/src/components/documents/view/locales/is.ts +143 -0
- package/src/components/documents/view/locales/it.ts +13 -0
- package/src/components/documents/view/locales/nb.ts +143 -0
- package/src/components/documents/view/locales/nl.ts +13 -0
- package/src/components/documents/view/locales/pl.ts +13 -0
- package/src/components/documents/view/locales/pt.ts +13 -0
- package/src/components/documents/view/locales/sk.ts +143 -0
- package/src/components/documents/view/locales/sl.ts +21 -8
- package/src/components/documents/view/locales/sv.ts +143 -0
- package/src/components/documents/view/use-document-download.ts +18 -17
- package/src/components/entities/create-entity-form.tsx +200 -12
- package/src/components/entities/entities.hooks.ts +15 -7
- package/src/components/entities/entity-settings-form/entity-settings-form.tsx +121 -65
- package/src/components/entities/entity-settings-form/input-with-preview.tsx +28 -4
- package/src/components/entities/entity-settings-form/locales/bg.ts +206 -0
- package/src/components/entities/entity-settings-form/locales/cs.ts +206 -0
- package/src/components/entities/entity-settings-form/locales/de.ts +17 -3
- package/src/components/entities/entity-settings-form/locales/en.ts +206 -0
- package/src/components/entities/entity-settings-form/locales/es.ts +15 -3
- package/src/components/entities/entity-settings-form/locales/et.ts +205 -0
- package/src/components/entities/entity-settings-form/locales/fi.ts +206 -0
- package/src/components/entities/entity-settings-form/locales/fr.ts +15 -3
- package/src/components/entities/entity-settings-form/locales/hr.ts +23 -11
- package/src/components/entities/entity-settings-form/locales/is.ts +206 -0
- package/src/components/entities/entity-settings-form/locales/it.ts +15 -3
- package/src/components/entities/entity-settings-form/locales/nb.ts +206 -0
- package/src/components/entities/entity-settings-form/locales/nl.ts +15 -3
- package/src/components/entities/entity-settings-form/locales/pl.ts +15 -3
- package/src/components/entities/entity-settings-form/locales/pt.ts +15 -3
- package/src/components/entities/entity-settings-form/locales/sk.ts +206 -0
- package/src/components/entities/entity-settings-form/locales/sl.ts +31 -18
- package/src/components/entities/entity-settings-form/locales/sv.ts +212 -0
- package/src/components/entities/fina-settings-form/fina-operator-required-dialog.tsx +34 -9
- package/src/components/entities/fina-settings-form/fina-settings-form.tsx +2 -0
- package/src/components/entities/fina-settings-form/fina-settings.hooks.ts +14 -45
- package/src/components/entities/fina-settings-form/locales/bg.ts +163 -0
- package/src/components/entities/fina-settings-form/locales/cs.ts +163 -0
- package/src/components/entities/fina-settings-form/locales/et.ts +163 -0
- package/src/components/entities/fina-settings-form/locales/fi.ts +163 -0
- package/src/components/entities/fina-settings-form/locales/hr.ts +11 -10
- package/src/components/entities/fina-settings-form/locales/is.ts +164 -0
- package/src/components/entities/fina-settings-form/locales/nb.ts +163 -0
- package/src/components/entities/fina-settings-form/locales/sk.ts +163 -0
- package/src/components/entities/fina-settings-form/locales/sl.ts +8 -7
- package/src/components/entities/fina-settings-form/locales/sv.ts +165 -0
- package/src/components/entities/furs-settings-form/furs-operator-required-dialog.tsx +34 -9
- package/src/components/entities/furs-settings-form/furs-settings-form.tsx +13 -1
- package/src/components/entities/furs-settings-form/furs-settings.hooks.ts +141 -42
- package/src/components/entities/furs-settings-form/locales/bg.ts +242 -0
- package/src/components/entities/furs-settings-form/locales/cs.ts +241 -0
- package/src/components/entities/furs-settings-form/locales/de.ts +42 -15
- package/src/components/entities/furs-settings-form/locales/en.ts +24 -0
- package/src/components/entities/furs-settings-form/locales/es.ts +42 -15
- package/src/components/entities/furs-settings-form/locales/et.ts +242 -0
- package/src/components/entities/furs-settings-form/locales/fi.ts +243 -0
- package/src/components/entities/furs-settings-form/locales/fr.ts +43 -15
- package/src/components/entities/furs-settings-form/locales/hr.ts +44 -19
- package/src/components/entities/furs-settings-form/locales/is.ts +242 -0
- package/src/components/entities/furs-settings-form/locales/it.ts +42 -15
- package/src/components/entities/furs-settings-form/locales/nb.ts +242 -0
- package/src/components/entities/furs-settings-form/locales/nl.ts +42 -15
- package/src/components/entities/furs-settings-form/locales/pl.ts +40 -15
- package/src/components/entities/furs-settings-form/locales/pt.ts +42 -15
- package/src/components/entities/furs-settings-form/locales/sk.ts +243 -0
- package/src/components/entities/furs-settings-form/locales/sl.ts +34 -10
- package/src/components/entities/furs-settings-form/locales/sv.ts +242 -0
- package/src/components/entities/furs-settings-form/sections/enable-fiscalization-section.tsx +11 -0
- package/src/components/entities/furs-settings-form/sections/furs-internal-act-download-card.tsx +111 -0
- package/src/components/entities/furs-settings-form/sections/general-settings-section.tsx +27 -0
- package/src/components/entities/furs-settings-form/sections/premises-management-section.tsx +23 -16
- package/src/components/entities/furs-settings-form/sections/register-premise-dialog.tsx +89 -31
- package/src/components/entities/settings/branding-settings-form.tsx +11 -30
- package/src/components/entities/settings/company-settings-form.tsx +2 -1
- package/src/components/entities/settings/defaults-settings-form.tsx +106 -3
- package/src/components/entities/settings/email-settings-form.tsx +245 -3
- package/src/components/entities/settings/eslog-settings-form.tsx +2 -1
- package/src/components/entities/settings/number-format-settings-form.tsx +2 -1
- package/src/components/entities/settings/pdf-template-selector/locales/bg.ts +20 -0
- package/src/components/entities/settings/pdf-template-selector/locales/cs.ts +20 -0
- package/src/components/entities/settings/pdf-template-selector/locales/en.ts +20 -0
- package/src/components/entities/settings/pdf-template-selector/locales/et.ts +19 -0
- package/src/components/entities/settings/pdf-template-selector/locales/fi.ts +20 -0
- package/src/components/entities/settings/pdf-template-selector/locales/is.ts +19 -0
- package/src/components/entities/settings/pdf-template-selector/locales/nb.ts +19 -0
- package/src/components/entities/settings/pdf-template-selector/locales/sk.ts +20 -0
- package/src/components/entities/settings/pdf-template-selector/locales/sv.ts +19 -0
- package/src/components/entities/settings/tax-rules-settings-form.tsx +57 -6
- package/src/components/estimates/create/create-estimate-form.tsx +250 -66
- package/src/components/estimates/create/locales/bg.ts +77 -0
- package/src/components/estimates/create/locales/cs.ts +77 -0
- package/src/components/estimates/create/locales/de.ts +4 -3
- package/src/components/estimates/create/locales/en.ts +77 -0
- package/src/components/estimates/create/locales/es.ts +4 -3
- package/src/components/estimates/create/locales/et.ts +77 -0
- package/src/components/estimates/create/locales/fi.ts +77 -0
- package/src/components/estimates/create/locales/fr.ts +4 -3
- package/src/components/estimates/create/locales/hr.ts +13 -12
- package/src/components/estimates/create/locales/is.ts +77 -0
- package/src/components/estimates/create/locales/it.ts +4 -3
- package/src/components/estimates/create/locales/nb.ts +77 -0
- package/src/components/estimates/create/locales/nl.ts +4 -3
- package/src/components/estimates/create/locales/pl.ts +4 -3
- package/src/components/estimates/create/locales/pt.ts +4 -3
- package/src/components/estimates/create/locales/sk.ts +77 -0
- package/src/components/estimates/create/locales/sl.ts +13 -12
- package/src/components/estimates/create/locales/sv.ts +77 -0
- package/src/components/estimates/create/prepare-estimate-submission.ts +41 -4
- package/src/components/estimates/estimates.hooks.ts +24 -3
- package/src/components/estimates/list/list-row-actions.tsx +34 -7
- package/src/components/estimates/list/list-table.tsx +89 -11
- package/src/components/estimates/list/locales/bg.ts +40 -0
- package/src/components/estimates/list/locales/cs.ts +40 -0
- package/src/components/estimates/list/locales/de.ts +2 -0
- package/src/components/estimates/list/locales/en.ts +29 -2
- package/src/components/estimates/list/locales/es.ts +2 -0
- package/src/components/estimates/list/locales/et.ts +40 -0
- package/src/components/estimates/list/locales/fi.ts +40 -0
- package/src/components/estimates/list/locales/fr.ts +2 -0
- package/src/components/estimates/list/locales/hr.ts +9 -7
- package/src/components/estimates/list/locales/is.ts +40 -0
- package/src/components/estimates/list/locales/it.ts +2 -0
- package/src/components/estimates/list/locales/nb.ts +40 -0
- package/src/components/estimates/list/locales/nl.ts +2 -0
- package/src/components/estimates/list/locales/pl.ts +2 -0
- package/src/components/estimates/list/locales/pt.ts +2 -0
- package/src/components/estimates/list/locales/sk.ts +40 -0
- package/src/components/estimates/list/locales/sl.ts +9 -7
- package/src/components/estimates/list/locales/sv.ts +40 -0
- package/src/components/estimates/list/use-estimate-download.ts +3 -5
- package/src/components/export/document-export-form.tsx +72 -15
- package/src/components/export/sales-per-item-export-form.tsx +3 -2
- package/src/components/invoices/create/create-invoice-form.tsx +500 -112
- package/src/components/invoices/create/eslog-validation.ts +97 -8
- package/src/components/invoices/create/locales/bg.ts +173 -0
- package/src/components/invoices/create/locales/cs.ts +173 -0
- package/src/components/invoices/create/locales/de.ts +41 -9
- package/src/components/invoices/create/locales/en.ts +173 -0
- package/src/components/invoices/create/locales/es.ts +42 -9
- package/src/components/invoices/create/locales/et.ts +173 -0
- package/src/components/invoices/create/locales/fi.ts +173 -0
- package/src/components/invoices/create/locales/fr.ts +42 -11
- package/src/components/invoices/create/locales/hr.ts +50 -18
- package/src/components/invoices/create/locales/is.ts +173 -0
- package/src/components/invoices/create/locales/it.ts +43 -11
- package/src/components/invoices/create/locales/nb.ts +173 -0
- package/src/components/invoices/create/locales/nl.ts +42 -10
- package/src/components/invoices/create/locales/pl.ts +42 -11
- package/src/components/invoices/create/locales/pt.ts +43 -10
- package/src/components/invoices/create/locales/sk.ts +173 -0
- package/src/components/invoices/create/locales/sl.ts +49 -18
- package/src/components/invoices/create/locales/sv.ts +175 -0
- package/src/components/invoices/create/prepare-invoice-submission.ts +73 -2
- package/src/components/invoices/invoices-furs.hooks.ts +11 -8
- package/src/components/invoices/invoices.hooks.ts +36 -10
- package/src/components/invoices/list/list-row-actions.tsx +54 -21
- package/src/components/invoices/list/list-table.tsx +94 -12
- package/src/components/invoices/list/locales/bg.ts +49 -0
- package/src/components/invoices/list/locales/cs.ts +49 -0
- package/src/components/invoices/list/locales/en.ts +34 -2
- package/src/components/invoices/list/locales/et.ts +49 -0
- package/src/components/invoices/list/locales/fi.ts +49 -0
- package/src/components/invoices/list/locales/is.ts +49 -0
- package/src/components/invoices/list/locales/nb.ts +49 -0
- package/src/components/invoices/list/locales/sk.ts +49 -0
- package/src/components/invoices/list/locales/sv.ts +49 -0
- package/src/components/invoices/list/use-invoice-download.ts +3 -5
- package/src/components/invoices/send-email-dialog/locales/bg.ts +63 -0
- package/src/components/invoices/send-email-dialog/locales/cs.ts +63 -0
- package/src/components/invoices/send-email-dialog/locales/de.ts +26 -0
- package/src/components/invoices/send-email-dialog/locales/en.ts +63 -0
- package/src/components/invoices/send-email-dialog/locales/es.ts +26 -0
- package/src/components/invoices/send-email-dialog/locales/et.ts +63 -0
- package/src/components/invoices/send-email-dialog/locales/fi.ts +63 -0
- package/src/components/invoices/send-email-dialog/locales/fr.ts +26 -0
- package/src/components/invoices/send-email-dialog/locales/hr.ts +26 -0
- package/src/components/invoices/send-email-dialog/locales/is.ts +63 -0
- package/src/components/invoices/send-email-dialog/locales/it.ts +26 -0
- package/src/components/invoices/send-email-dialog/locales/nb.ts +63 -0
- package/src/components/invoices/send-email-dialog/locales/nl.ts +26 -0
- package/src/components/invoices/send-email-dialog/locales/pl.ts +26 -0
- package/src/components/invoices/send-email-dialog/locales/pt.ts +26 -0
- package/src/components/invoices/send-email-dialog/locales/sk.ts +63 -0
- package/src/components/invoices/send-email-dialog/locales/sl.ts +26 -0
- package/src/components/invoices/send-email-dialog/locales/sv.ts +63 -0
- package/src/components/invoices/send-email-dialog/send-email-dialog.tsx +189 -93
- package/src/components/invoices/view/eslog-info-display.tsx +2 -0
- package/src/components/invoices/view/fiscalization-status-card.tsx +2 -0
- package/src/components/items/create-item-form/create-item-form.tsx +29 -0
- package/src/components/items/create-item-form/locales/bg.ts +13 -0
- package/src/components/items/create-item-form/locales/cs.ts +13 -0
- package/src/components/items/create-item-form/locales/et.ts +13 -0
- package/src/components/items/create-item-form/locales/fi.ts +13 -0
- package/src/components/items/create-item-form/locales/is.ts +13 -0
- package/src/components/items/create-item-form/locales/nb.ts +13 -0
- package/src/components/items/create-item-form/locales/sk.ts +13 -0
- package/src/components/items/create-item-form/locales/sv.ts +13 -0
- package/src/components/items/edit-item-form/edit-item-form.tsx +39 -1
- package/src/components/items/edit-item-form/locales/bg.ts +12 -0
- package/src/components/items/edit-item-form/locales/cs.ts +12 -0
- package/src/components/items/edit-item-form/locales/en.ts +12 -0
- package/src/components/items/edit-item-form/locales/et.ts +12 -0
- package/src/components/items/edit-item-form/locales/fi.ts +12 -0
- package/src/components/items/edit-item-form/locales/is.ts +12 -0
- package/src/components/items/edit-item-form/locales/nb.ts +12 -0
- package/src/components/items/edit-item-form/locales/sk.ts +12 -0
- package/src/components/items/edit-item-form/locales/sv.ts +12 -0
- package/src/components/items/item-combobox.tsx +55 -22
- package/src/components/items/item-list-table/item-list-table.tsx +47 -23
- package/src/components/items/item-list-table/locales/bg.ts +16 -0
- package/src/components/items/item-list-table/locales/cs.ts +16 -0
- package/src/components/items/item-list-table/locales/en.ts +4 -3
- package/src/components/items/item-list-table/locales/et.ts +16 -0
- package/src/components/items/item-list-table/locales/fi.ts +16 -0
- package/src/components/items/item-list-table/locales/is.ts +16 -0
- package/src/components/items/item-list-table/locales/nb.ts +16 -0
- package/src/components/items/item-list-table/locales/sk.ts +16 -0
- package/src/components/items/item-list-table/locales/sv.ts +16 -0
- package/src/components/items/items.hooks.ts +15 -15
- package/src/components/payments/create-payment-form/create-payment-form.tsx +16 -9
- package/src/components/payments/create-payment-form/locales/bg.ts +20 -0
- package/src/components/payments/create-payment-form/locales/cs.ts +20 -0
- package/src/components/payments/create-payment-form/locales/en.ts +20 -0
- package/src/components/payments/create-payment-form/locales/et.ts +20 -0
- package/src/components/payments/create-payment-form/locales/fi.ts +20 -0
- package/src/components/payments/create-payment-form/locales/hr.ts +2 -2
- package/src/components/payments/create-payment-form/locales/is.ts +20 -0
- package/src/components/payments/create-payment-form/locales/nb.ts +20 -0
- package/src/components/payments/create-payment-form/locales/sk.ts +20 -0
- package/src/components/payments/create-payment-form/locales/sl.ts +4 -4
- package/src/components/payments/create-payment-form/locales/sv.ts +20 -0
- package/src/components/payments/edit-payment-form/edit-payment-form.tsx +10 -2
- package/src/components/payments/edit-payment-form/locales/bg.ts +20 -0
- package/src/components/payments/edit-payment-form/locales/cs.ts +20 -0
- package/src/components/payments/edit-payment-form/locales/en.ts +20 -0
- package/src/components/payments/edit-payment-form/locales/et.ts +20 -0
- package/src/components/payments/edit-payment-form/locales/fi.ts +20 -0
- package/src/components/payments/edit-payment-form/locales/hr.ts +2 -2
- package/src/components/payments/edit-payment-form/locales/is.ts +20 -0
- package/src/components/payments/edit-payment-form/locales/nb.ts +20 -0
- package/src/components/payments/edit-payment-form/locales/sk.ts +20 -0
- package/src/components/payments/edit-payment-form/locales/sl.ts +4 -4
- package/src/components/payments/edit-payment-form/locales/sv.ts +20 -0
- package/src/components/payments/list/list-row-actions.tsx +10 -2
- package/src/components/payments/list/list-table.tsx +51 -45
- package/src/components/payments/list/locales/bg.ts +42 -0
- package/src/components/payments/list/locales/cs.ts +42 -0
- package/src/components/payments/list/locales/de.ts +18 -0
- package/src/components/payments/list/locales/en.ts +37 -2
- package/src/components/payments/list/locales/es.ts +18 -0
- package/src/components/payments/list/locales/et.ts +42 -0
- package/src/components/payments/list/locales/fi.ts +42 -0
- package/src/components/payments/list/locales/fr.ts +18 -0
- package/src/components/payments/list/locales/hr.ts +18 -0
- package/src/components/payments/list/locales/is.ts +42 -0
- package/src/components/payments/list/locales/it.ts +18 -0
- package/src/components/payments/list/locales/nb.ts +42 -0
- package/src/components/payments/list/locales/nl.ts +18 -0
- package/src/components/payments/list/locales/pl.ts +18 -0
- package/src/components/payments/list/locales/pt.ts +18 -0
- package/src/components/payments/list/locales/sk.ts +42 -0
- package/src/components/payments/list/locales/sl.ts +18 -1
- package/src/components/payments/list/locales/sv.ts +42 -0
- package/src/components/payments/payments.hooks.ts +13 -6
- package/src/components/recurring-invoices/create-recurring-invoice-form/create-recurring-invoice-form.tsx +121 -39
- package/src/components/recurring-invoices/create-recurring-invoice-form/locales/bg.ts +44 -0
- package/src/components/recurring-invoices/create-recurring-invoice-form/locales/cs.ts +44 -0
- package/src/components/recurring-invoices/create-recurring-invoice-form/locales/en.ts +44 -0
- package/src/components/recurring-invoices/create-recurring-invoice-form/locales/et.ts +44 -0
- package/src/components/recurring-invoices/create-recurring-invoice-form/locales/fi.ts +44 -0
- package/src/components/recurring-invoices/create-recurring-invoice-form/locales/hr.ts +6 -6
- package/src/components/recurring-invoices/create-recurring-invoice-form/locales/is.ts +44 -0
- package/src/components/recurring-invoices/create-recurring-invoice-form/locales/nb.ts +44 -0
- package/src/components/recurring-invoices/create-recurring-invoice-form/locales/sk.ts +44 -0
- package/src/components/recurring-invoices/create-recurring-invoice-form/locales/sl.ts +4 -4
- package/src/components/recurring-invoices/create-recurring-invoice-form/locales/sv.ts +44 -0
- package/src/components/recurring-invoices/list/list-row-actions.tsx +12 -6
- package/src/components/recurring-invoices/list/list-table.tsx +63 -12
- package/src/components/recurring-invoices/list/locales/bg.ts +32 -0
- package/src/components/recurring-invoices/list/locales/cs.ts +32 -0
- package/src/components/recurring-invoices/list/locales/de.ts +4 -0
- package/src/components/recurring-invoices/list/locales/en.ts +27 -0
- package/src/components/recurring-invoices/list/locales/es.ts +4 -0
- package/src/components/recurring-invoices/list/locales/et.ts +32 -0
- package/src/components/recurring-invoices/list/locales/fi.ts +32 -0
- package/src/components/recurring-invoices/list/locales/fr.ts +4 -0
- package/src/components/recurring-invoices/list/locales/hr.ts +4 -0
- package/src/components/recurring-invoices/list/locales/is.ts +32 -0
- package/src/components/recurring-invoices/list/locales/it.ts +4 -0
- package/src/components/recurring-invoices/list/locales/nb.ts +32 -0
- package/src/components/recurring-invoices/list/locales/nl.ts +4 -0
- package/src/components/recurring-invoices/list/locales/pl.ts +4 -0
- package/src/components/recurring-invoices/list/locales/pt.ts +4 -0
- package/src/components/recurring-invoices/list/locales/sk.ts +32 -0
- package/src/components/recurring-invoices/list/locales/sl.ts +4 -0
- package/src/components/recurring-invoices/list/locales/sv.ts +32 -0
- package/src/components/recurring-invoices/recurring-invoices.hooks.ts +11 -8
- package/src/components/request-logs/request-log-detail.tsx +30 -23
- package/src/components/request-logs/request-log-list-table.tsx +88 -45
- package/src/components/table/README.md +47 -9
- package/src/components/table/data-table.tsx +232 -92
- package/src/components/table/filter-bar.tsx +1 -1
- package/src/components/table/filter-panel.tsx +51 -22
- package/src/components/table/hooks/use-table-state.ts +64 -11
- package/src/components/table/index.ts +3 -0
- package/src/components/table/locales.ts +119 -4
- package/src/components/table/selection-toolbar.tsx +65 -9
- package/src/components/table/sorting.ts +80 -0
- package/src/components/table/table-skeleton.tsx +15 -9
- package/src/components/table/types.ts +17 -0
- package/src/components/tax-reports/index.ts +8 -0
- package/src/components/tax-reports/kir-export-form.tsx +4 -5
- package/src/components/tax-reports/slovenia-accounting-mappings-fields.tsx +271 -0
- package/src/components/tax-reports/slovenia-tax-profile-step.tsx +25 -11
- package/src/components/tax-reports/slovenia-vod-export-form.tsx +452 -0
- package/src/components/tax-reports/slovenia-yearly-export-form.tsx +20 -16
- package/src/components/tax-reports/slovenia-yearly-review-step.tsx +42 -19
- package/src/components/taxes/create-tax-form/create-tax-form.tsx +48 -2
- package/src/components/taxes/create-tax-form/locales/bg.ts +8 -0
- package/src/components/taxes/create-tax-form/locales/cs.ts +8 -0
- package/src/components/taxes/create-tax-form/locales/et.ts +8 -0
- package/src/components/taxes/create-tax-form/locales/fi.ts +8 -0
- package/src/components/taxes/create-tax-form/locales/is.ts +8 -0
- package/src/components/taxes/create-tax-form/locales/nb.ts +8 -0
- package/src/components/taxes/create-tax-form/locales/sk.ts +8 -0
- package/src/components/taxes/create-tax-form/locales/sv.ts +8 -0
- package/src/components/taxes/edit-tax-form/edit-tax-form.tsx +80 -11
- package/src/components/taxes/edit-tax-form/locales/bg.ts +6 -0
- package/src/components/taxes/edit-tax-form/locales/cs.ts +6 -0
- package/src/components/taxes/edit-tax-form/locales/en.ts +6 -0
- package/src/components/taxes/edit-tax-form/locales/et.ts +6 -0
- package/src/components/taxes/edit-tax-form/locales/fi.ts +6 -0
- package/src/components/taxes/edit-tax-form/locales/is.ts +6 -0
- package/src/components/taxes/edit-tax-form/locales/nb.ts +6 -0
- package/src/components/taxes/edit-tax-form/locales/sk.ts +6 -0
- package/src/components/taxes/edit-tax-form/locales/sv.ts +6 -0
- package/src/components/taxes/tax-list-table/locales/bg.ts +17 -0
- package/src/components/taxes/tax-list-table/locales/cs.ts +17 -0
- package/src/components/taxes/tax-list-table/locales/en.ts +4 -3
- package/src/components/taxes/tax-list-table/locales/et.ts +17 -0
- package/src/components/taxes/tax-list-table/locales/fi.ts +17 -0
- package/src/components/taxes/tax-list-table/locales/is.ts +17 -0
- package/src/components/taxes/tax-list-table/locales/nb.ts +17 -0
- package/src/components/taxes/tax-list-table/locales/sk.ts +17 -0
- package/src/components/taxes/tax-list-table/locales/sv.ts +17 -0
- package/src/components/taxes/tax-list-table/tax-list-table.tsx +53 -19
- package/src/components/taxes/taxes.hooks.ts +53 -12
- package/src/components/ui/badge.tsx +1 -1
- package/src/components/ui/button.tsx +1 -1
- package/src/components/ui/drawer.tsx +2 -2
- package/src/components/ui/form.tsx +118 -10
- package/src/components/ui/progress.tsx +6 -4
- package/src/components/ui/select.tsx +118 -2
- package/src/components/ui/sidebar.tsx +2 -2
- package/src/components/ui/sonner.tsx +17 -36
- package/src/components/ui/sticky-form-footer.tsx +6 -1
- package/src/components/ui/tooltip.tsx +15 -2
- package/src/components/webhook-logs/webhook-delivery-detail.tsx +22 -22
- package/src/components/webhook-logs/webhook-delivery-list-table.tsx +92 -17
- package/src/components/wl-subscription/locked-feature.tsx +11 -10
- package/src/components/wl-subscription/paywall.tsx +184 -72
- package/src/components/wl-subscription/upgrade-modal.tsx +28 -31
- package/src/generate-schemas.ts +146 -103
- package/src/generated/schemas/acceptentityinvitation_body.ts +4 -3
- package/src/generated/schemas/accountwebhook.ts +63 -0
- package/src/generated/schemas/addentityuser_body.ts +4 -3
- package/src/generated/schemas/advanceinvoice.ts +167 -168
- package/src/generated/schemas/authorizeshopify_body.ts +4 -3
- package/src/generated/schemas/calculatedocumentpreview.ts +120 -0
- package/src/generated/schemas/checktransactiontype.ts +35 -0
- package/src/generated/schemas/creditnote.ts +203 -76
- package/src/generated/schemas/customadvanceinvoice.ts +172 -165
- package/src/generated/schemas/customcreditnote.ts +183 -155
- package/src/generated/schemas/customdeliverynote.ts +166 -0
- package/src/generated/schemas/customer.ts +4 -8
- package/src/generated/schemas/customestimate.ts +123 -97
- package/src/generated/schemas/customincomingpurchasedocument.ts +142 -0
- package/src/generated/schemas/custominvoice.ts +183 -154
- package/src/generated/schemas/deliverynote.ts +124 -79
- package/src/generated/schemas/einvoice.ts +19 -0
- package/src/generated/schemas/einvoicingsettings.ts +21 -0
- package/src/generated/schemas/einvoicingsupplier.ts +45 -0
- package/src/generated/schemas/entity.ts +267 -24
- package/src/generated/schemas/entityapikey.ts +1 -3
- package/src/generated/schemas/entityuserrole.ts +1 -3
- package/src/generated/schemas/estimate.ts +120 -127
- package/src/generated/schemas/exportsloveniavodxml_body.ts +17 -0
- package/src/generated/schemas/exportsloveniayearlynormiranireport_body.ts +4 -3
- package/src/generated/schemas/finadevice.ts +15 -0
- package/src/generated/schemas/finalizedocument.ts +52 -0
- package/src/generated/schemas/finapremise.ts +15 -0
- package/src/generated/schemas/finasettings.ts +1 -3
- package/src/generated/schemas/furselectronicdevice.ts +15 -0
- package/src/generated/schemas/furssettings.ts +2 -3
- package/src/generated/schemas/image.ts +15 -0
- package/src/generated/schemas/incomingpurchasedocument.ts +178 -0
- package/src/generated/schemas/incomingpurchasedocumentattachment.ts +15 -0
- package/src/generated/schemas/incomingpurchasedocumentpayment.ts +36 -0
- package/src/generated/schemas/index.ts +30 -5
- package/src/generated/schemas/invoice.ts +182 -183
- package/src/generated/schemas/item.ts +35 -3
- package/src/generated/schemas/legacymigrationauth.ts +18 -0
- package/src/generated/schemas/me.ts +4 -22
- package/src/generated/schemas/migrationjob.ts +20 -0
- package/src/generated/schemas/order.ts +6 -8
- package/src/generated/schemas/orderintegration.ts +12 -12
- package/src/generated/schemas/payment.ts +9 -8
- package/src/generated/schemas/ptatcudseries.ts +28 -0
- package/src/generated/schemas/queryentitystats.ts +15 -0
- package/src/generated/schemas/recurringinvoice.ts +4 -8
- package/src/generated/schemas/registerfursmovablepremise_body.ts +1 -3
- package/src/generated/schemas/registerfursrealestatepremise_body.ts +1 -3
- package/src/generated/schemas/renderadvanceinvoicepreview_body.ts +42 -16
- package/src/generated/schemas/rendercreditnotepreview_body.ts +42 -16
- package/src/generated/schemas/renderdeliverynotepreview_body.ts +19 -8
- package/src/generated/schemas/renderestimatepreview_body.ts +45 -8
- package/src/generated/schemas/renderinvoicepreview_body.ts +46 -18
- package/src/generated/schemas/reviewsloveniayearlynormiranireport.ts +15 -0
- package/src/generated/schemas/searcheinvoicingcustomer.ts +18 -0
- package/src/generated/schemas/senddocument_body.ts +2 -3
- package/src/generated/schemas/sendemail_body.ts +48 -42
- package/src/generated/schemas/sloveniataxprofile.ts +98 -24
- package/src/generated/schemas/starteslogexport_body.ts +34 -0
- package/src/generated/schemas/startpdfexport_body.ts +18 -81
- package/src/generated/schemas/stripeappconnect_body.ts +4 -3
- package/src/generated/schemas/stripeappcreateinvoice_body.ts +4 -6
- package/src/generated/schemas/stripeappmarketplaceauthorize.ts +15 -0
- package/src/generated/schemas/stripeappupdatesettings_body.ts +6 -6
- package/src/generated/schemas/supplier.ts +55 -0
- package/src/generated/schemas/syncshopifyorders_body.ts +21 -0
- package/src/generated/schemas/tax.ts +8 -8
- package/src/generated/schemas/uploadfile_body.ts +2 -3
- package/src/generated/schemas/uploadfurscertificate_body.ts +6 -6
- package/src/generated/schemas/userfinasettings.ts +1 -3
- package/src/generated/schemas/userfurssettings.ts +1 -3
- package/src/generated/schemas/userptsettings.ts +24 -0
- package/src/generated/schemas/voidinvoice_body.ts +25 -0
- package/src/generated/schemas/webhook.ts +6 -8
- package/src/generated/schemas/wlsubscriptionbillingemail.ts +17 -0
- package/src/hooks/create-resource-hooks.ts +22 -19
- package/src/hooks/use-duplicate-document.ts +71 -38
- package/src/hooks/use-eslog-validation.ts +5 -1
- package/src/hooks/use-next-document-number.ts +13 -6
- package/src/hooks/use-resolved-entity-id.ts +14 -0
- package/src/hooks/use-resource-mutation.ts +11 -30
- package/src/hooks/use-transaction-type-check.ts +3 -8
- package/src/lib/browser-cookies.ts +1 -1
- package/src/lib/country-capabilities.ts +114 -0
- package/src/lib/date-fns-locale.ts +1 -20
- package/src/lib/date-only.ts +58 -0
- package/src/lib/document-display.ts +18 -0
- package/src/lib/eslog-export.ts +32 -0
- package/src/lib/fiscalization-options.ts +21 -1
- package/src/lib/formatting.ts +27 -0
- package/src/lib/furs-error-utils.ts +29 -0
- package/src/lib/locale.ts +4 -0
- package/src/lib/payment-display.ts +97 -0
- package/src/lib/pt-document-input.ts +67 -0
- package/src/lib/schemas/shared.ts +12 -0
- package/src/lib/template-variables.tsx +102 -4
- package/src/lib/translation.ts +51 -33
- package/src/lib/white-label-capabilities.ts +626 -0
- package/src/lib/zod-validation-message.ts +291 -0
- package/src/providers/entities-provider.tsx +32 -14
- package/src/providers/sdk-provider.tsx +112 -12
- package/src/providers/space-invoices-provider.tsx +129 -0
- package/src/providers/white-label-provider.tsx +96 -4
- package/src/providers/wl-subscription-provider.tsx +149 -10
- package/src/generated/schemas/previewadvanceinvoice_body.ts +0 -354
- package/src/generated/schemas/previewestimate_body.ts +0 -309
- package/src/generated/schemas/registerfinamovablepremise_body.ts +0 -26
- package/src/generated/schemas/registerfinarealestatepremise_body.ts +0 -37
- package/src/generated/schemas/renderdocument_body.ts +0 -594
|
@@ -9,20 +9,32 @@ import { useForm, useWatch } from "react-hook-form";
|
|
|
9
9
|
import type { z } from "zod";
|
|
10
10
|
import { Alert, AlertDescription, AlertTitle } from "@/ui/components/ui/alert";
|
|
11
11
|
import { Button } from "@/ui/components/ui/button";
|
|
12
|
-
import { Form } from "@/ui/components/ui/form";
|
|
12
|
+
import { Form, FormRoot } from "@/ui/components/ui/form";
|
|
13
13
|
import { Skeleton } from "@/ui/components/ui/skeleton";
|
|
14
14
|
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/ui/components/ui/tooltip";
|
|
15
15
|
import { createInvoiceSchema } from "@/ui/generated/schemas";
|
|
16
16
|
import { useEslogValidation } from "@/ui/hooks/use-eslog-validation";
|
|
17
17
|
import { usePremiseSelection } from "@/ui/hooks/use-premise-selection";
|
|
18
18
|
import { useTransactionTypeCheck } from "@/ui/hooks/use-transaction-type-check";
|
|
19
|
-
import {
|
|
19
|
+
import {
|
|
20
|
+
buildEslogOptions,
|
|
21
|
+
buildFinaOptions,
|
|
22
|
+
buildFursOptions,
|
|
23
|
+
type FiscalizationOperatorOverride,
|
|
24
|
+
} from "@/ui/lib/fiscalization-options";
|
|
25
|
+
import {
|
|
26
|
+
normalizePtDocumentInput,
|
|
27
|
+
type PtDocumentInputForm,
|
|
28
|
+
ptDocumentInputFormSchema,
|
|
29
|
+
} from "@/ui/lib/pt-document-input";
|
|
30
|
+
import { normalizeLineItemDiscountsForForm } from "@/ui/lib/schemas/shared";
|
|
20
31
|
import type { ComponentTranslationProps } from "@/ui/lib/translation";
|
|
21
32
|
import { createTranslation } from "@/ui/lib/translation";
|
|
22
33
|
import { cn } from "@/ui/lib/utils";
|
|
23
34
|
import { useEntities } from "@/ui/providers/entities-context";
|
|
24
35
|
import { useFormFooterRegistration } from "@/ui/providers/form-footer-context";
|
|
25
36
|
import { CUSTOMERS_CACHE_KEY } from "../../customers/customers.hooks";
|
|
37
|
+
import { withInvoiceIssueDateValidation } from "../../documents/create/document-date-validation";
|
|
26
38
|
import {
|
|
27
39
|
DocumentDetailsSection,
|
|
28
40
|
DocumentFooterField,
|
|
@@ -31,13 +43,34 @@ import {
|
|
|
31
43
|
DocumentSignatureField,
|
|
32
44
|
DocumentTaxClauseField,
|
|
33
45
|
} from "../../documents/create/document-details-section";
|
|
46
|
+
import { withRequiredDocumentItemFields } from "../../documents/create/document-item-validation";
|
|
34
47
|
import { DocumentItemsSection, type PriceModesMap } from "../../documents/create/document-items-section";
|
|
35
48
|
import { DocumentRecipientSection } from "../../documents/create/document-recipient-section";
|
|
36
49
|
import { type LinkedDocumentSummary, LinkedDocumentsInfo } from "../../documents/create/linked-documents-info";
|
|
37
50
|
import { MarkAsPaidSection } from "../../documents/create/mark-as-paid-section";
|
|
51
|
+
import {
|
|
52
|
+
calculateDocumentTotal,
|
|
53
|
+
coercePaymentRowsToType,
|
|
54
|
+
createEmptyPaymentRow,
|
|
55
|
+
type DraftPaymentRow,
|
|
56
|
+
getFirstValidPaymentType,
|
|
57
|
+
serializePaymentRows,
|
|
58
|
+
validatePaymentRows,
|
|
59
|
+
} from "../../documents/create/payment-rows";
|
|
60
|
+
import { prepareDocumentItems } from "../../documents/create/prepare-document-submission";
|
|
61
|
+
import { applyCustomCreateTemplate } from "../../documents/create/custom-create-template";
|
|
62
|
+
import { financialInputsMatchInitial, resolvePreservedExpectedTotal } from "../../documents/create/preserved-expected-total";
|
|
63
|
+
import { scrollToFirstInvalidField } from "../../documents/create/scroll-to-first-invalid-field";
|
|
38
64
|
import type { DocumentTypes } from "../../documents/types";
|
|
39
|
-
import { useCreateInvoice, useNextInvoiceNumber, useUpdateInvoice } from "../invoices.hooks";
|
|
40
|
-
import {
|
|
65
|
+
import { useCreateCustomInvoice, useCreateInvoice, useNextInvoiceNumber, useUpdateInvoice } from "../invoices.hooks";
|
|
66
|
+
import {
|
|
67
|
+
buildEslogFieldErrors,
|
|
68
|
+
getEntityErrors,
|
|
69
|
+
getFormFieldErrors,
|
|
70
|
+
mergeFieldErrors,
|
|
71
|
+
translateEslogValidationError,
|
|
72
|
+
validateEslogForm,
|
|
73
|
+
} from "./eslog-validation";
|
|
41
74
|
import de from "./locales/de";
|
|
42
75
|
import es from "./locales/es";
|
|
43
76
|
import fr from "./locales/fr";
|
|
@@ -47,7 +80,7 @@ import nl from "./locales/nl";
|
|
|
47
80
|
import pl from "./locales/pl";
|
|
48
81
|
import pt from "./locales/pt";
|
|
49
82
|
import sl from "./locales/sl";
|
|
50
|
-
import { prepareInvoiceSubmission } from "./prepare-invoice-submission";
|
|
83
|
+
import { prepareInvoiceSubmission, prepareInvoiceUpdateSubmission } from "./prepare-invoice-submission";
|
|
51
84
|
import { useInvoiceCustomerForm } from "./use-invoice-customer-form";
|
|
52
85
|
|
|
53
86
|
function calculateDueDate(dateIso: string, days: number): string {
|
|
@@ -56,6 +89,19 @@ function calculateDueDate(dateIso: string, days: number): string {
|
|
|
56
89
|
return date.toISOString();
|
|
57
90
|
}
|
|
58
91
|
|
|
92
|
+
function isSameCalendarDate(left: string | Date | undefined, right: string | Date): boolean {
|
|
93
|
+
if (!left) return false;
|
|
94
|
+
|
|
95
|
+
const leftDate = new Date(left);
|
|
96
|
+
const rightDate = new Date(right);
|
|
97
|
+
|
|
98
|
+
return (
|
|
99
|
+
leftDate.getFullYear() === rightDate.getFullYear() &&
|
|
100
|
+
leftDate.getMonth() === rightDate.getMonth() &&
|
|
101
|
+
leftDate.getDate() === rightDate.getDate()
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
|
|
59
105
|
const DUE_DAYS_PRESETS = [0, 7, 14, 30, 60, 90] as const;
|
|
60
106
|
|
|
61
107
|
const translations = {
|
|
@@ -72,18 +118,26 @@ const translations = {
|
|
|
72
118
|
|
|
73
119
|
const DUPLICATE_PREVIEW_SETTLE_MS = 120;
|
|
74
120
|
const DUPLICATE_PREVIEW_MIN_DELAY_MS = 260;
|
|
121
|
+
const FORM_ID = "create-invoice-form";
|
|
122
|
+
const createInvoiceFormSchema = withInvoiceIssueDateValidation(
|
|
123
|
+
withRequiredDocumentItemFields(
|
|
124
|
+
createInvoiceSchema.extend({
|
|
125
|
+
pt: ptDocumentInputFormSchema.optional(),
|
|
126
|
+
}),
|
|
127
|
+
),
|
|
128
|
+
);
|
|
75
129
|
|
|
76
130
|
function emitInvoiceCreateDebug(_detail: Record<string, unknown>) {
|
|
77
131
|
if (!import.meta.env.DEV || typeof window === "undefined") return;
|
|
78
132
|
}
|
|
79
133
|
|
|
80
134
|
// Form values: extend schema with local-only fields (number is for display, not sent to API)
|
|
81
|
-
type CreateInvoiceFormValues = z.infer<typeof
|
|
135
|
+
type CreateInvoiceFormValues = z.infer<typeof createInvoiceFormSchema> & {
|
|
82
136
|
number?: string;
|
|
83
137
|
};
|
|
84
138
|
|
|
85
139
|
/** Preview payload extends request with display-only fields */
|
|
86
|
-
type InvoicePreviewPayload = Partial<CreateInvoiceRequest> & { number?: string };
|
|
140
|
+
type InvoicePreviewPayload = Partial<CreateInvoiceRequest> & { id?: string; number?: string; pt?: PtDocumentInputForm };
|
|
87
141
|
|
|
88
142
|
type DocumentAddFormProps = {
|
|
89
143
|
type: DocumentTypes;
|
|
@@ -103,6 +157,13 @@ type DocumentAddFormProps = {
|
|
|
103
157
|
mode?: "create" | "edit";
|
|
104
158
|
/** Document ID for edit mode */
|
|
105
159
|
documentId?: string;
|
|
160
|
+
/** Whether draft actions should be available in the UI */
|
|
161
|
+
allowDrafts?: boolean;
|
|
162
|
+
/** Optional app-level content rendered inside the details section. */
|
|
163
|
+
detailsExtras?: ReactNode;
|
|
164
|
+
/** Request-scoped operator override for embed fiscalization flows. */
|
|
165
|
+
operatorPrefill?: FiscalizationOperatorOverride;
|
|
166
|
+
translationLocale?: string;
|
|
106
167
|
} & ComponentTranslationProps;
|
|
107
168
|
|
|
108
169
|
function buildInvoiceFormValues({
|
|
@@ -111,30 +172,40 @@ function buildInvoiceFormValues({
|
|
|
111
172
|
defaultInvoiceNote,
|
|
112
173
|
defaultPaymentTerms,
|
|
113
174
|
defaultFooter,
|
|
175
|
+
defaultSignature,
|
|
114
176
|
defaultInvoiceDueDays,
|
|
177
|
+
isEditMode,
|
|
115
178
|
}: {
|
|
116
179
|
initialValues?: Partial<CreateInvoiceRequest> & { number?: string };
|
|
117
180
|
currencyCode?: string;
|
|
118
181
|
defaultInvoiceNote: string;
|
|
119
182
|
defaultPaymentTerms: string;
|
|
120
183
|
defaultFooter: string;
|
|
184
|
+
defaultSignature: string;
|
|
121
185
|
defaultInvoiceDueDays: number;
|
|
186
|
+
isEditMode: boolean;
|
|
122
187
|
}): CreateInvoiceFormValues {
|
|
123
188
|
return {
|
|
124
189
|
number: initialValues?.number || "",
|
|
190
|
+
calculation_mode: (initialValues as any)?.calculation_mode ?? undefined,
|
|
125
191
|
date: initialValues?.date || new Date().toISOString(),
|
|
126
192
|
customer_id: initialValues?.customer_id ?? undefined,
|
|
127
193
|
customer: (initialValues?.customer as CreateInvoiceFormValues["customer"]) ?? undefined,
|
|
128
194
|
items: initialValues?.items?.length
|
|
129
195
|
? initialValues.items.map((item: any) => ({
|
|
130
|
-
type: item.type,
|
|
196
|
+
type: item.type ?? undefined,
|
|
131
197
|
name: item.name || "",
|
|
132
198
|
description: item.description || "",
|
|
133
199
|
...(item.type !== "separator"
|
|
134
200
|
? {
|
|
201
|
+
item_id: item.item_id,
|
|
202
|
+
classification: item.classification ?? undefined,
|
|
203
|
+
unit: item.unit ?? undefined,
|
|
135
204
|
quantity: item.quantity ?? 1,
|
|
136
205
|
price: item.gross_price ?? item.price,
|
|
206
|
+
gross_price: item.gross_price ?? undefined,
|
|
137
207
|
taxes: item.taxes || [],
|
|
208
|
+
discounts: normalizeLineItemDiscountsForForm(item.discounts),
|
|
138
209
|
}
|
|
139
210
|
: {}),
|
|
140
211
|
}))
|
|
@@ -149,15 +220,22 @@ function buildInvoiceFormValues({
|
|
|
149
220
|
],
|
|
150
221
|
currency_code: initialValues?.currency_code || currencyCode || "EUR",
|
|
151
222
|
reference: (initialValues as any)?.reference ?? "",
|
|
152
|
-
note: initialValues?.note ?? defaultInvoiceNote,
|
|
223
|
+
note: initialValues?.note ?? (isEditMode ? "" : defaultInvoiceNote),
|
|
153
224
|
tax_clause: (initialValues as any)?.tax_clause ?? "",
|
|
154
|
-
payment_terms: initialValues?.payment_terms ?? defaultPaymentTerms,
|
|
155
|
-
footer: (initialValues as any)?.footer ?? defaultFooter,
|
|
225
|
+
payment_terms: initialValues?.payment_terms ?? (isEditMode ? "" : defaultPaymentTerms),
|
|
226
|
+
footer: (initialValues as any)?.footer ?? (isEditMode ? "" : defaultFooter),
|
|
227
|
+
signature: (initialValues as any)?.signature ?? (isEditMode ? "" : defaultSignature),
|
|
156
228
|
date_due:
|
|
157
229
|
initialValues?.date_due ||
|
|
158
|
-
|
|
159
|
-
|
|
230
|
+
(isEditMode
|
|
231
|
+
? undefined
|
|
232
|
+
: calculateDueDate(initialValues?.date || new Date().toISOString(), defaultInvoiceDueDays)),
|
|
233
|
+
date_service:
|
|
234
|
+
(initialValues as any)?.date_service ??
|
|
235
|
+
(isEditMode ? undefined : (initialValues?.date ?? new Date().toISOString())),
|
|
236
|
+
date_service_to: (initialValues as any)?.date_service_to ?? undefined,
|
|
160
237
|
linked_documents: (initialValues as any)?.linked_documents,
|
|
238
|
+
pt: ((initialValues as any)?.pt as PtDocumentInputForm | undefined) ?? undefined,
|
|
161
239
|
};
|
|
162
240
|
}
|
|
163
241
|
|
|
@@ -174,6 +252,10 @@ export default function CreateInvoiceForm({
|
|
|
174
252
|
forceLinkedDocuments,
|
|
175
253
|
mode = "create",
|
|
176
254
|
documentId,
|
|
255
|
+
allowDrafts = true,
|
|
256
|
+
detailsExtras,
|
|
257
|
+
operatorPrefill,
|
|
258
|
+
translationLocale,
|
|
177
259
|
t: translateProp,
|
|
178
260
|
namespace,
|
|
179
261
|
locale,
|
|
@@ -182,6 +264,7 @@ export default function CreateInvoiceForm({
|
|
|
182
264
|
t: translateProp,
|
|
183
265
|
namespace,
|
|
184
266
|
locale,
|
|
267
|
+
translationLocale,
|
|
185
268
|
translations,
|
|
186
269
|
});
|
|
187
270
|
|
|
@@ -193,6 +276,7 @@ export default function CreateInvoiceForm({
|
|
|
193
276
|
const defaultInvoiceNote = (activeEntity?.settings as any)?.default_invoice_note || "";
|
|
194
277
|
const defaultPaymentTerms = (activeEntity?.settings as any)?.default_invoice_payment_terms || "";
|
|
195
278
|
const defaultFooter = (activeEntity?.settings as any)?.document_footer || "";
|
|
279
|
+
const defaultSignature = (activeEntity?.settings as any)?.default_document_signature || "";
|
|
196
280
|
const defaultInvoiceDueDays = (activeEntity?.settings as any)?.default_invoice_due_days ?? 30;
|
|
197
281
|
|
|
198
282
|
// ============================================================================
|
|
@@ -206,10 +290,14 @@ export default function CreateInvoiceForm({
|
|
|
206
290
|
// e-SLOG Validation (shared hook)
|
|
207
291
|
// ============================================================================
|
|
208
292
|
const eslog = useEslogValidation(activeEntity);
|
|
293
|
+
const eslogValidationModeRef = useRef<"submit" | "draft">("submit");
|
|
294
|
+
const eslogEntityErrorsRef = useRef(eslog.entityErrors);
|
|
295
|
+
eslogEntityErrorsRef.current = eslog.entityErrors;
|
|
209
296
|
|
|
210
297
|
// UI-only state (not part of API schema)
|
|
211
298
|
const [markAsPaid, setMarkAsPaid] = useState(false);
|
|
212
|
-
const [
|
|
299
|
+
const [paymentRows, setPaymentRows] = useState<DraftPaymentRow[]>([createEmptyPaymentRow()]);
|
|
300
|
+
const [paymentValidationMessage, setPaymentValidationMessage] = useState<string | undefined>();
|
|
213
301
|
const [isDraftPending, setIsDraftPending] = useState(false);
|
|
214
302
|
|
|
215
303
|
// Service date type state (single date or range)
|
|
@@ -233,6 +321,36 @@ export default function CreateInvoiceForm({
|
|
|
233
321
|
}, {} as PriceModesMap);
|
|
234
322
|
}, [initialValues?.items]);
|
|
235
323
|
const priceModesRef = useRef<PriceModesMap>(initialPriceModes);
|
|
324
|
+
const customCreateTemplate = (initialValues as any)?._custom_create_template;
|
|
325
|
+
const financialInputsMatchSource = useCallback(
|
|
326
|
+
(values: { items?: any[]; currency_code?: string; calculation_mode?: string | null }) =>
|
|
327
|
+
financialInputsMatchInitial({
|
|
328
|
+
initialItems: initialValues?.items,
|
|
329
|
+
currentItems: values.items,
|
|
330
|
+
initialCurrencyCode: initialValues?.currency_code,
|
|
331
|
+
currentCurrencyCode: values.currency_code,
|
|
332
|
+
initialCalculationMode: (initialValues as any)?.calculation_mode ?? null,
|
|
333
|
+
currentCalculationMode: values.calculation_mode ?? null,
|
|
334
|
+
initialPriceModes,
|
|
335
|
+
currentPriceModes: priceModesRef.current,
|
|
336
|
+
}),
|
|
337
|
+
[initialPriceModes, initialValues],
|
|
338
|
+
);
|
|
339
|
+
const getPreservedExpectedTotalWithTax = useCallback(
|
|
340
|
+
(values: { items?: any[]; currency_code?: string; calculation_mode?: string | null }) =>
|
|
341
|
+
resolvePreservedExpectedTotal({
|
|
342
|
+
initialExpectedTotalWithTax: (initialValues as any)?._preserved_expected_total_with_tax,
|
|
343
|
+
initialItems: initialValues?.items,
|
|
344
|
+
currentItems: values.items,
|
|
345
|
+
initialCurrencyCode: initialValues?.currency_code,
|
|
346
|
+
currentCurrencyCode: values.currency_code,
|
|
347
|
+
initialCalculationMode: (initialValues as any)?.calculation_mode ?? null,
|
|
348
|
+
currentCalculationMode: values.calculation_mode ?? null,
|
|
349
|
+
initialPriceModes,
|
|
350
|
+
currentPriceModes: priceModesRef.current,
|
|
351
|
+
}),
|
|
352
|
+
[initialPriceModes, initialValues],
|
|
353
|
+
);
|
|
236
354
|
|
|
237
355
|
const formDefaultValues = useMemo(
|
|
238
356
|
() =>
|
|
@@ -242,7 +360,9 @@ export default function CreateInvoiceForm({
|
|
|
242
360
|
defaultInvoiceNote,
|
|
243
361
|
defaultPaymentTerms,
|
|
244
362
|
defaultFooter,
|
|
363
|
+
defaultSignature,
|
|
245
364
|
defaultInvoiceDueDays,
|
|
365
|
+
isEditMode,
|
|
246
366
|
}),
|
|
247
367
|
[
|
|
248
368
|
activeEntity?.currency_code,
|
|
@@ -250,25 +370,123 @@ export default function CreateInvoiceForm({
|
|
|
250
370
|
defaultInvoiceDueDays,
|
|
251
371
|
defaultInvoiceNote,
|
|
252
372
|
defaultPaymentTerms,
|
|
373
|
+
defaultSignature,
|
|
253
374
|
initialValues,
|
|
375
|
+
isEditMode,
|
|
254
376
|
],
|
|
255
377
|
);
|
|
256
378
|
|
|
379
|
+
const baseResolver = useMemo(() => zodResolver(createInvoiceFormSchema) as Resolver<CreateInvoiceFormValues>, []);
|
|
380
|
+
const eslogResolverStateRef = useRef({
|
|
381
|
+
activeEntity,
|
|
382
|
+
isEnabled: eslog.isEnabled === true,
|
|
383
|
+
isEditMode,
|
|
384
|
+
translate: t,
|
|
385
|
+
setEntityErrors: eslog.setEntityErrors,
|
|
386
|
+
});
|
|
387
|
+
eslogResolverStateRef.current = {
|
|
388
|
+
activeEntity,
|
|
389
|
+
isEnabled: eslog.isEnabled === true,
|
|
390
|
+
isEditMode,
|
|
391
|
+
translate: t,
|
|
392
|
+
setEntityErrors: eslog.setEntityErrors,
|
|
393
|
+
};
|
|
394
|
+
const resolver = useMemo<Resolver<CreateInvoiceFormValues>>(
|
|
395
|
+
() => async (values, context, options) => {
|
|
396
|
+
const result = await baseResolver(values, context, options);
|
|
397
|
+
const resolverState = eslogResolverStateRef.current;
|
|
398
|
+
const shouldValidateEslog =
|
|
399
|
+
eslogValidationModeRef.current === "submit" && !resolverState.isEditMode && resolverState.isEnabled;
|
|
400
|
+
|
|
401
|
+
if (!shouldValidateEslog) {
|
|
402
|
+
eslogEntityErrorsRef.current = [];
|
|
403
|
+
resolverState.setEntityErrors([]);
|
|
404
|
+
return result;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
const validationErrors = validateEslogForm(values as any, resolverState.activeEntity);
|
|
408
|
+
const entityErrors = getEntityErrors(validationErrors);
|
|
409
|
+
eslogEntityErrorsRef.current = entityErrors;
|
|
410
|
+
resolverState.setEntityErrors(entityErrors);
|
|
411
|
+
|
|
412
|
+
const fieldErrors = getFormFieldErrors(validationErrors);
|
|
413
|
+
if (fieldErrors.length === 0) {
|
|
414
|
+
return result;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
const mergedErrors = mergeFieldErrors(
|
|
418
|
+
result.errors,
|
|
419
|
+
buildEslogFieldErrors<CreateInvoiceFormValues>(fieldErrors, resolverState.translate),
|
|
420
|
+
);
|
|
421
|
+
|
|
422
|
+
return {
|
|
423
|
+
values: {},
|
|
424
|
+
errors: mergedErrors,
|
|
425
|
+
};
|
|
426
|
+
},
|
|
427
|
+
[baseResolver],
|
|
428
|
+
);
|
|
429
|
+
|
|
257
430
|
const form = useForm<CreateInvoiceFormValues>({
|
|
258
|
-
|
|
259
|
-
resolver: zodResolver(createInvoiceSchema) as Resolver<CreateInvoiceFormValues>,
|
|
431
|
+
resolver,
|
|
260
432
|
defaultValues: formDefaultValues,
|
|
261
433
|
});
|
|
262
434
|
|
|
263
|
-
|
|
264
|
-
const
|
|
435
|
+
const watchedItems = useWatch({ control: form.control, name: "items" });
|
|
436
|
+
const paymentDocumentTotal = useMemo(
|
|
437
|
+
() => calculateDocumentTotal((watchedItems as any[]) ?? [], priceModesRef.current),
|
|
438
|
+
[watchedItems],
|
|
439
|
+
);
|
|
440
|
+
const hasExplicitNonBankTransferPayment =
|
|
441
|
+
markAsPaid && paymentRows.some((row) => row.type != null && row.type !== "bank_transfer");
|
|
442
|
+
const skipPreferenceInitializedRef = useRef(false);
|
|
443
|
+
const skipPaymentCoercionPendingRef = useRef(false);
|
|
444
|
+
const previousSkipFiscalizationRef = useRef(skipFiscalization);
|
|
445
|
+
const previousMarkAsPaidRef = useRef(markAsPaid);
|
|
446
|
+
|
|
447
|
+
useEffect(() => {
|
|
448
|
+
if (skipPreferenceInitializedRef.current || furs.isLoading || isEditMode) return;
|
|
449
|
+
|
|
450
|
+
skipPreferenceInitializedRef.current = true;
|
|
451
|
+
if (furs.settings?.default_skip_fiscalization === true) {
|
|
452
|
+
setSkipFiscalization(true);
|
|
453
|
+
}
|
|
454
|
+
}, [furs.isLoading, furs.settings?.default_skip_fiscalization, isEditMode]);
|
|
265
455
|
|
|
266
|
-
// Auto-disable skip when it becomes invalid (e.g., user changes payment type to cash)
|
|
267
456
|
useEffect(() => {
|
|
268
|
-
|
|
457
|
+
const skipJustEnabled = skipFiscalization && !previousSkipFiscalizationRef.current;
|
|
458
|
+
const paidJustEnabled = markAsPaid && !previousMarkAsPaidRef.current;
|
|
459
|
+
|
|
460
|
+
if (skipFiscalization && markAsPaid && (skipJustEnabled || paidJustEnabled)) {
|
|
461
|
+
const nextPaymentRows = coercePaymentRowsToType(paymentRows, "bank_transfer");
|
|
462
|
+
const hasChanged = nextPaymentRows.some((row, index) => row.type !== paymentRows[index]?.type);
|
|
463
|
+
|
|
464
|
+
if (hasChanged) {
|
|
465
|
+
skipPaymentCoercionPendingRef.current = true;
|
|
466
|
+
setPaymentRows(nextPaymentRows);
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
previousSkipFiscalizationRef.current = skipFiscalization;
|
|
471
|
+
previousMarkAsPaidRef.current = markAsPaid;
|
|
472
|
+
}, [markAsPaid, paymentRows, skipFiscalization]);
|
|
473
|
+
|
|
474
|
+
// Auto-disable skip when the user explicitly changes payment away from bank transfer.
|
|
475
|
+
useEffect(() => {
|
|
476
|
+
if (skipPaymentCoercionPendingRef.current) return;
|
|
477
|
+
|
|
478
|
+
if (hasExplicitNonBankTransferPayment && skipFiscalization) {
|
|
269
479
|
setSkipFiscalization(false);
|
|
270
480
|
}
|
|
271
|
-
}, [
|
|
481
|
+
}, [hasExplicitNonBankTransferPayment, skipFiscalization]);
|
|
482
|
+
|
|
483
|
+
useEffect(() => {
|
|
484
|
+
if (!skipPaymentCoercionPendingRef.current) return;
|
|
485
|
+
|
|
486
|
+
if (!markAsPaid || paymentRows.every((row) => row.type === "bank_transfer")) {
|
|
487
|
+
skipPaymentCoercionPendingRef.current = false;
|
|
488
|
+
}
|
|
489
|
+
}, [markAsPaid, paymentRows]);
|
|
272
490
|
|
|
273
491
|
// Clear date_service_to when switching from range to single
|
|
274
492
|
useEffect(() => {
|
|
@@ -323,6 +541,10 @@ export default function CreateInvoiceForm({
|
|
|
323
541
|
const useFinaNumbering =
|
|
324
542
|
!!fina.isActive && (finaUnifiedNumbering || transactionType == null || transactionType === "domestic");
|
|
325
543
|
const isFinaNonDomestic = !!fina.isActive && !useFinaNumbering;
|
|
544
|
+
const isFiscalizationDateLocked = !isEditMode && (isFursActive || useFinaNumbering);
|
|
545
|
+
const fiscalizationDateLockReason = useFinaNumbering
|
|
546
|
+
? t("FINA fiscalized invoices always use the current date")
|
|
547
|
+
: t("FURS fiscalized invoices always use the current date");
|
|
326
548
|
|
|
327
549
|
// ============================================================================
|
|
328
550
|
// Next Invoice Number Preview
|
|
@@ -354,22 +576,42 @@ export default function CreateInvoiceForm({
|
|
|
354
576
|
: furs.isLoading || !furs.isSelectionReady || fina.isLoading || !fina.isSelectionReady || isNextNumberLoading;
|
|
355
577
|
|
|
356
578
|
// Update header action with FURS and e-SLOG toggle buttons
|
|
579
|
+
const headerActionSignatureRef = useRef<string | null>(null);
|
|
357
580
|
useEffect(() => {
|
|
358
581
|
if (!onHeaderActionChange) return;
|
|
359
582
|
|
|
360
583
|
// Don't set header action while loading or in edit mode (FURS/FINA/e-SLOG not editable)
|
|
361
584
|
if (furs.isLoading || fina.isLoading || isEditMode) {
|
|
585
|
+
if (headerActionSignatureRef.current === null) return;
|
|
586
|
+
headerActionSignatureRef.current = null;
|
|
362
587
|
onHeaderActionChange(null);
|
|
363
588
|
return;
|
|
364
589
|
}
|
|
365
590
|
|
|
366
591
|
const showFursToggle = furs.isEnabled && furs.hasPremises;
|
|
367
592
|
const showEslogToggle = eslog.isAvailable;
|
|
593
|
+
const isFursChecked = !skipFiscalization;
|
|
594
|
+
const isEslogChecked = eslog.isEnabled === true;
|
|
595
|
+
const headerActionSignature =
|
|
596
|
+
showFursToggle || showEslogToggle
|
|
597
|
+
? JSON.stringify({
|
|
598
|
+
showFursToggle,
|
|
599
|
+
showEslogToggle,
|
|
600
|
+
isFursChecked,
|
|
601
|
+
isEslogChecked,
|
|
602
|
+
eslogLabel: t("e-SLOG"),
|
|
603
|
+
eslogEnabledDescription: t("Click to skip e-SLOG validation for this invoice"),
|
|
604
|
+
eslogDisabledDescription: t("Click to enable e-SLOG validation"),
|
|
605
|
+
fiscalizationLabel: t("Fiscally verify"),
|
|
606
|
+
fiscalizationEnabledDescription: t("Click to skip fiscalization for this invoice"),
|
|
607
|
+
fiscalizationDisabledDescription: t("Click to enable fiscalization"),
|
|
608
|
+
})
|
|
609
|
+
: null;
|
|
610
|
+
|
|
611
|
+
if (headerActionSignatureRef.current === headerActionSignature) return;
|
|
612
|
+
headerActionSignatureRef.current = headerActionSignature;
|
|
368
613
|
|
|
369
614
|
if (showFursToggle || showEslogToggle) {
|
|
370
|
-
const isFursChecked = !skipFiscalization;
|
|
371
|
-
const isEslogChecked = eslog.isEnabled === true;
|
|
372
|
-
|
|
373
615
|
onHeaderActionChange(
|
|
374
616
|
<div className="flex items-center gap-2">
|
|
375
617
|
{/* e-SLOG toggle */}
|
|
@@ -417,10 +659,9 @@ export default function CreateInvoiceForm({
|
|
|
417
659
|
size="sm"
|
|
418
660
|
className={cn(
|
|
419
661
|
"h-8 cursor-pointer gap-2",
|
|
420
|
-
!canSkipFiscalization && "cursor-not-allowed opacity-50",
|
|
421
662
|
!isFursChecked && "text-destructive hover:text-destructive",
|
|
422
663
|
)}
|
|
423
|
-
onClick={() =>
|
|
664
|
+
onClick={() => setSkipFiscalization(!skipFiscalization)}
|
|
424
665
|
>
|
|
425
666
|
<div
|
|
426
667
|
className={cn(
|
|
@@ -436,11 +677,9 @@ export default function CreateInvoiceForm({
|
|
|
436
677
|
</Button>
|
|
437
678
|
</TooltipTrigger>
|
|
438
679
|
<TooltipContent side="bottom" className="max-w-xs">
|
|
439
|
-
{
|
|
440
|
-
?
|
|
441
|
-
|
|
442
|
-
: t("Click to enable fiscalization")
|
|
443
|
-
: t("Cannot skip fiscalization for cash payments")}
|
|
680
|
+
{isFursChecked
|
|
681
|
+
? t("Click to skip fiscalization for this invoice")
|
|
682
|
+
: t("Click to enable fiscalization")}
|
|
444
683
|
</TooltipContent>
|
|
445
684
|
</Tooltip>
|
|
446
685
|
</TooltipProvider>
|
|
@@ -456,7 +695,6 @@ export default function CreateInvoiceForm({
|
|
|
456
695
|
furs.isEnabled,
|
|
457
696
|
furs.hasPremises,
|
|
458
697
|
skipFiscalization,
|
|
459
|
-
canSkipFiscalization,
|
|
460
698
|
eslog.isAvailable,
|
|
461
699
|
eslog.isEnabled,
|
|
462
700
|
eslog.setEnabled,
|
|
@@ -472,12 +710,67 @@ export default function CreateInvoiceForm({
|
|
|
472
710
|
}
|
|
473
711
|
}, [nextNumberData?.number, form]);
|
|
474
712
|
|
|
713
|
+
useEffect(() => {
|
|
714
|
+
if (!isFiscalizationDateLocked) return;
|
|
715
|
+
|
|
716
|
+
const today = new Date();
|
|
717
|
+
if (isSameCalendarDate(form.getValues("date"), today)) return;
|
|
718
|
+
|
|
719
|
+
form.setValue("date", today.toISOString(), {
|
|
720
|
+
shouldDirty: true,
|
|
721
|
+
shouldTouch: false,
|
|
722
|
+
shouldValidate: true,
|
|
723
|
+
});
|
|
724
|
+
}, [form, isFiscalizationDateLocked]);
|
|
725
|
+
|
|
475
726
|
// Watch fields needed for document note/payment terms preview
|
|
476
727
|
const watchedNumber = useWatch({ control: form.control, name: "number" });
|
|
477
728
|
const watchedDate = useWatch({ control: form.control, name: "date" });
|
|
478
729
|
const watchedDateDue = useWatch({ control: form.control, name: "date_due" });
|
|
479
730
|
const watchedCurrencyCode = useWatch({ control: form.control, name: "currency_code" });
|
|
480
731
|
const watchedCustomer = useWatch({ control: form.control, name: "customer" });
|
|
732
|
+
const watchedValidationSnapshot = useMemo(
|
|
733
|
+
() =>
|
|
734
|
+
JSON.stringify({
|
|
735
|
+
date: watchedDate,
|
|
736
|
+
date_due: watchedDateDue,
|
|
737
|
+
currency_code: watchedCurrencyCode,
|
|
738
|
+
customer: watchedCustomer,
|
|
739
|
+
items: watchedItems,
|
|
740
|
+
}),
|
|
741
|
+
[watchedCurrencyCode, watchedCustomer, watchedDate, watchedDateDue, watchedItems],
|
|
742
|
+
);
|
|
743
|
+
const lastRevalidatedSnapshotRef = useRef<string | null>(null);
|
|
744
|
+
|
|
745
|
+
useEffect(() => {
|
|
746
|
+
if (!form.formState.isSubmitted || form.formState.isSubmitting) {
|
|
747
|
+
return;
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
const hasErrors = Object.keys(form.formState.errors).length > 0 || eslog.entityErrors.length > 0;
|
|
751
|
+
if (!hasErrors) {
|
|
752
|
+
lastRevalidatedSnapshotRef.current = watchedValidationSnapshot;
|
|
753
|
+
return;
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
if (lastRevalidatedSnapshotRef.current === watchedValidationSnapshot) {
|
|
757
|
+
return;
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
lastRevalidatedSnapshotRef.current = watchedValidationSnapshot;
|
|
761
|
+
const timeoutId = window.setTimeout(() => {
|
|
762
|
+
void form.trigger();
|
|
763
|
+
}, 0);
|
|
764
|
+
|
|
765
|
+
return () => window.clearTimeout(timeoutId);
|
|
766
|
+
}, [
|
|
767
|
+
eslog.entityErrors.length,
|
|
768
|
+
form,
|
|
769
|
+
form.formState.errors,
|
|
770
|
+
form.formState.isSubmitted,
|
|
771
|
+
form.formState.isSubmitting,
|
|
772
|
+
watchedValidationSnapshot,
|
|
773
|
+
]);
|
|
481
774
|
|
|
482
775
|
// Croatian invoice validation:
|
|
483
776
|
// - Domestic/3w B2C requires FINA
|
|
@@ -522,16 +815,23 @@ export default function CreateInvoiceForm({
|
|
|
522
815
|
// Auto-populate tax_clause from entity settings when transaction type changes
|
|
523
816
|
const effectiveTransactionType = transactionType ?? "domestic";
|
|
524
817
|
const prevTransactionTypeRef = useRef<string | undefined>(undefined);
|
|
818
|
+
const prevTaxClauseHydrationVersionRef = useRef<number | undefined>(undefined);
|
|
819
|
+
const [taxClauseHydrationVersion, setTaxClauseHydrationVersion] = useState(0);
|
|
525
820
|
useEffect(() => {
|
|
526
|
-
if (
|
|
821
|
+
if (isEditMode) return;
|
|
822
|
+
const transactionTypeChanged = effectiveTransactionType !== prevTransactionTypeRef.current;
|
|
823
|
+
const hydrationVersionChanged = taxClauseHydrationVersion !== prevTaxClauseHydrationVersionRef.current;
|
|
824
|
+
if (!transactionTypeChanged && !hydrationVersionChanged) return;
|
|
825
|
+
|
|
527
826
|
prevTransactionTypeRef.current = effectiveTransactionType;
|
|
827
|
+
prevTaxClauseHydrationVersionRef.current = taxClauseHydrationVersion;
|
|
528
828
|
|
|
529
829
|
const taxClauseDefaults = (activeEntity?.settings as any)?.tax_clause_defaults;
|
|
530
830
|
if (!taxClauseDefaults) return;
|
|
531
831
|
|
|
532
832
|
const clause = taxClauseDefaults[effectiveTransactionType] ?? "";
|
|
533
833
|
form.setValue("tax_clause", clause);
|
|
534
|
-
}, [effectiveTransactionType,
|
|
834
|
+
}, [activeEntity, effectiveTransactionType, form, isEditMode, taxClauseHydrationVersion]);
|
|
535
835
|
|
|
536
836
|
// Extract customer management logic into a custom hook
|
|
537
837
|
const {
|
|
@@ -560,6 +860,19 @@ export default function CreateInvoiceForm({
|
|
|
560
860
|
onError,
|
|
561
861
|
});
|
|
562
862
|
|
|
863
|
+
const { mutate: createCustomInvoice, isPending: isCreateCustomPending } = useCreateCustomInvoice({
|
|
864
|
+
entityId,
|
|
865
|
+
onSuccess: (data) => {
|
|
866
|
+
furs.saveCombo();
|
|
867
|
+
fina.saveCombo();
|
|
868
|
+
if (data.customer_id) {
|
|
869
|
+
queryClient.invalidateQueries({ queryKey: [CUSTOMERS_CACHE_KEY] });
|
|
870
|
+
}
|
|
871
|
+
onSuccess?.(data);
|
|
872
|
+
},
|
|
873
|
+
onError,
|
|
874
|
+
});
|
|
875
|
+
|
|
563
876
|
const { mutate: updateInvoice, isPending: isUpdatePending } = useUpdateInvoice({
|
|
564
877
|
entityId,
|
|
565
878
|
onSuccess: (data) => {
|
|
@@ -574,7 +887,7 @@ export default function CreateInvoiceForm({
|
|
|
574
887
|
onError,
|
|
575
888
|
});
|
|
576
889
|
|
|
577
|
-
const isPending = isCreatePending || isUpdatePending;
|
|
890
|
+
const isPending = isCreatePending || isCreateCustomPending || isUpdatePending;
|
|
578
891
|
|
|
579
892
|
// Shared submit logic for both regular save and save as draft
|
|
580
893
|
const submitInvoice = useCallback(
|
|
@@ -582,23 +895,8 @@ export default function CreateInvoiceForm({
|
|
|
582
895
|
// Block Croatian domestic B2B and domestic B2C without FINA
|
|
583
896
|
if (finaValidationError) return;
|
|
584
897
|
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
const validationErrors = validateEslogForm(values as any, activeEntity);
|
|
588
|
-
|
|
589
|
-
if (validationErrors.length > 0) {
|
|
590
|
-
const entityErrors = getEntityErrors(validationErrors);
|
|
591
|
-
const formErrors = getFormFieldErrors(validationErrors);
|
|
592
|
-
eslog.setEntityErrors(entityErrors);
|
|
593
|
-
for (const error of formErrors) {
|
|
594
|
-
form.setError(error.field as any, {
|
|
595
|
-
type: "eslog",
|
|
596
|
-
message: error.message,
|
|
597
|
-
});
|
|
598
|
-
}
|
|
599
|
-
return;
|
|
600
|
-
}
|
|
601
|
-
eslog.setEntityErrors([]);
|
|
898
|
+
if (!isDraft && !isEditMode && eslog.isEnabled && eslogEntityErrorsRef.current.length > 0) {
|
|
899
|
+
return;
|
|
602
900
|
}
|
|
603
901
|
|
|
604
902
|
// Build FURS options (skip for drafts and edit mode)
|
|
@@ -609,6 +907,7 @@ export default function CreateInvoiceForm({
|
|
|
609
907
|
skipFiscalization,
|
|
610
908
|
premiseName: furs.selectedPremiseName,
|
|
611
909
|
deviceName: furs.selectedDeviceName,
|
|
910
|
+
operator: operatorPrefill,
|
|
612
911
|
});
|
|
613
912
|
|
|
614
913
|
// Build FINA options (skip for drafts, edit mode, and non-domestic transactions)
|
|
@@ -618,7 +917,8 @@ export default function CreateInvoiceForm({
|
|
|
618
917
|
isEditMode,
|
|
619
918
|
premiseName: fina.selectedPremiseName,
|
|
620
919
|
deviceName: fina.selectedDeviceName,
|
|
621
|
-
paymentType:
|
|
920
|
+
paymentType: getFirstValidPaymentType(paymentRows),
|
|
921
|
+
operator: operatorPrefill,
|
|
622
922
|
});
|
|
623
923
|
|
|
624
924
|
// Build e-SLOG options (skip for drafts and edit mode)
|
|
@@ -629,50 +929,83 @@ export default function CreateInvoiceForm({
|
|
|
629
929
|
isEnabled: eslog.isEnabled,
|
|
630
930
|
});
|
|
631
931
|
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
paymentTypes,
|
|
637
|
-
furs: fursOptions,
|
|
638
|
-
fina: finaOptions,
|
|
639
|
-
eslog: eslogOptions,
|
|
640
|
-
priceModes: priceModesRef.current,
|
|
641
|
-
isDraft,
|
|
642
|
-
});
|
|
932
|
+
if (!isDraft && !isEditMode && markAsPaid) {
|
|
933
|
+
const paymentValidation = validatePaymentRows(paymentRows, paymentDocumentTotal, "partial_allowed");
|
|
934
|
+
const paymentMessage =
|
|
935
|
+
paymentValidation.typeError ?? paymentValidation.amountError ?? paymentValidation.totalError;
|
|
643
936
|
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
937
|
+
if (paymentMessage) {
|
|
938
|
+
setPaymentValidationMessage(paymentMessage);
|
|
939
|
+
return;
|
|
940
|
+
}
|
|
647
941
|
}
|
|
648
942
|
|
|
649
943
|
if (isEditMode && documentId) {
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
944
|
+
const updatePayload = prepareInvoiceUpdateSubmission(values as any, {
|
|
945
|
+
originalCustomer,
|
|
946
|
+
wasCustomerFormShown: showCustomerForm,
|
|
947
|
+
eslog: eslogOptions,
|
|
948
|
+
priceModes: priceModesRef.current,
|
|
949
|
+
}) as any;
|
|
950
|
+
|
|
951
|
+
if (forceLinkedDocuments) {
|
|
952
|
+
updatePayload.force_linked_documents = true;
|
|
953
|
+
}
|
|
954
|
+
|
|
653
955
|
updateInvoice({ id: documentId, data: updatePayload });
|
|
654
956
|
} else {
|
|
655
|
-
|
|
957
|
+
const payload = prepareInvoiceSubmission(values as any, {
|
|
958
|
+
originalCustomer,
|
|
959
|
+
wasCustomerFormShown: showCustomerForm,
|
|
960
|
+
markAsPaid: isDraft ? false : markAsPaid,
|
|
961
|
+
payments: serializePaymentRows(paymentRows, paymentDocumentTotal),
|
|
962
|
+
furs: fursOptions,
|
|
963
|
+
fina: finaOptions,
|
|
964
|
+
eslog: eslogOptions,
|
|
965
|
+
priceModes: priceModesRef.current,
|
|
966
|
+
isDraft,
|
|
967
|
+
});
|
|
968
|
+
const preservedExpectedTotalWithTax = getPreservedExpectedTotalWithTax(values);
|
|
969
|
+
if (preservedExpectedTotalWithTax !== undefined) {
|
|
970
|
+
(payload as any).expected_total_with_tax = preservedExpectedTotalWithTax;
|
|
971
|
+
} else {
|
|
972
|
+
delete (payload as any).expected_total_with_tax;
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
if (forceLinkedDocuments) {
|
|
976
|
+
(payload as any).force_linked_documents = true;
|
|
977
|
+
}
|
|
978
|
+
|
|
979
|
+
if (customCreateTemplate && financialInputsMatchSource(values)) {
|
|
980
|
+
delete (payload as any).expected_total_with_tax;
|
|
981
|
+
createCustomInvoice(applyCustomCreateTemplate(payload as any, customCreateTemplate));
|
|
982
|
+
} else {
|
|
983
|
+
createInvoice(payload);
|
|
984
|
+
}
|
|
656
985
|
}
|
|
657
986
|
},
|
|
658
987
|
[
|
|
659
|
-
activeEntity,
|
|
660
988
|
createInvoice,
|
|
989
|
+
createCustomInvoice,
|
|
661
990
|
updateInvoice,
|
|
991
|
+
customCreateTemplate,
|
|
662
992
|
documentId,
|
|
663
993
|
eslog,
|
|
664
994
|
finaValidationError,
|
|
665
995
|
fina,
|
|
666
996
|
forceLinkedDocuments,
|
|
667
|
-
form,
|
|
668
997
|
furs,
|
|
669
998
|
isEditMode,
|
|
670
999
|
useFinaNumbering,
|
|
671
1000
|
markAsPaid,
|
|
672
1001
|
originalCustomer,
|
|
673
|
-
|
|
1002
|
+
paymentDocumentTotal,
|
|
1003
|
+
paymentRows,
|
|
674
1004
|
showCustomerForm,
|
|
675
1005
|
skipFiscalization,
|
|
1006
|
+
operatorPrefill,
|
|
1007
|
+
financialInputsMatchSource,
|
|
1008
|
+
getPreservedExpectedTotalWithTax,
|
|
676
1009
|
],
|
|
677
1010
|
);
|
|
678
1011
|
|
|
@@ -680,12 +1013,16 @@ export default function CreateInvoiceForm({
|
|
|
680
1013
|
const handleSaveAsDraft = useCallback(async () => {
|
|
681
1014
|
setIsDraftPending(true);
|
|
682
1015
|
try {
|
|
1016
|
+
eslogValidationModeRef.current = "draft";
|
|
683
1017
|
const isValid = await form.trigger();
|
|
684
1018
|
if (isValid) {
|
|
685
1019
|
const values = form.getValues();
|
|
686
1020
|
submitInvoice(values, true);
|
|
1021
|
+
} else {
|
|
1022
|
+
scrollToFirstInvalidField(FORM_ID);
|
|
687
1023
|
}
|
|
688
1024
|
} finally {
|
|
1025
|
+
eslogValidationModeRef.current = "submit";
|
|
689
1026
|
setIsDraftPending(false);
|
|
690
1027
|
}
|
|
691
1028
|
}, [form, submitInvoice]);
|
|
@@ -696,14 +1033,14 @@ export default function CreateInvoiceForm({
|
|
|
696
1033
|
const saveLabel = isEditMode ? t("Update") : t("Save");
|
|
697
1034
|
const secondaryAction = useMemo(
|
|
698
1035
|
() =>
|
|
699
|
-
isEditMode
|
|
1036
|
+
isEditMode || !allowDrafts
|
|
700
1037
|
? undefined
|
|
701
1038
|
: {
|
|
702
1039
|
label: draftLabel,
|
|
703
1040
|
onClick: handleSaveAsDraft,
|
|
704
1041
|
isPending: isDraftPending,
|
|
705
1042
|
},
|
|
706
|
-
[draftLabel, handleSaveAsDraft, isDraftPending, isEditMode],
|
|
1043
|
+
[allowDrafts, draftLabel, handleSaveAsDraft, isDraftPending, isEditMode],
|
|
707
1044
|
);
|
|
708
1045
|
|
|
709
1046
|
// Watch isDirty to get stable reference
|
|
@@ -721,6 +1058,7 @@ export default function CreateInvoiceForm({
|
|
|
721
1058
|
// Track if initial setup has been done
|
|
722
1059
|
const initialSetupDoneRef = useRef(false);
|
|
723
1060
|
const hasInitialValues = !!initialValues;
|
|
1061
|
+
const hasInitialDueDate = !!initialValues?.date_due;
|
|
724
1062
|
const duplicateHydrationStartedAtRef = useRef<number | null>(hasInitialValues ? performance.now() : null);
|
|
725
1063
|
const duplicateHydrationLoggedRef = useRef(false);
|
|
726
1064
|
const appliedInitialValuesSignatureRef = useRef<string | null>(null);
|
|
@@ -736,6 +1074,7 @@ export default function CreateInvoiceForm({
|
|
|
736
1074
|
duplicateHydrationStartedAtRef.current = performance.now();
|
|
737
1075
|
duplicateHydrationLoggedRef.current = false;
|
|
738
1076
|
form.reset(formDefaultValues);
|
|
1077
|
+
setTaxClauseHydrationVersion((currentVersion) => currentVersion + 1);
|
|
739
1078
|
priceModesRef.current = initialPriceModes;
|
|
740
1079
|
}, [form, formDefaultValues, hasInitialValues, initialPriceModes]);
|
|
741
1080
|
|
|
@@ -745,6 +1084,26 @@ export default function CreateInvoiceForm({
|
|
|
745
1084
|
if (initialSetupDoneRef.current) return;
|
|
746
1085
|
if (!activeEntity) return;
|
|
747
1086
|
|
|
1087
|
+
if (isEditMode) {
|
|
1088
|
+
if (activeEntity.is_tax_subject) {
|
|
1089
|
+
const items = form.getValues("items") || [];
|
|
1090
|
+
if (items.length > 0 && (!items[0].taxes || items[0].taxes.length === 0)) {
|
|
1091
|
+
form.setValue("items.0.taxes", [{ tax_id: undefined }]);
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
1094
|
+
|
|
1095
|
+
initialSetupDoneRef.current = true;
|
|
1096
|
+
if (hasInitialValues && duplicateHydrationStartedAtRef.current && !duplicateHydrationLoggedRef.current) {
|
|
1097
|
+
duplicateHydrationLoggedRef.current = true;
|
|
1098
|
+
emitInvoiceCreateDebug({
|
|
1099
|
+
stage: "entity_defaults_applied",
|
|
1100
|
+
hasInitialValues: true,
|
|
1101
|
+
elapsedMs: Number((performance.now() - duplicateHydrationStartedAtRef.current).toFixed(1)),
|
|
1102
|
+
});
|
|
1103
|
+
}
|
|
1104
|
+
return;
|
|
1105
|
+
}
|
|
1106
|
+
|
|
748
1107
|
const entityDefaultNote = (activeEntity.settings as any)?.default_invoice_note;
|
|
749
1108
|
if (entityDefaultNote && !form.getValues("note")) {
|
|
750
1109
|
form.setValue("note", entityDefaultNote);
|
|
@@ -757,13 +1116,12 @@ export default function CreateInvoiceForm({
|
|
|
757
1116
|
if (entityDefaultFooter && !form.getValues("footer")) {
|
|
758
1117
|
form.setValue("footer", entityDefaultFooter);
|
|
759
1118
|
}
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
form.setValue("signature", entityDefaultSignature);
|
|
1119
|
+
if (defaultSignature && !form.getValues("signature")) {
|
|
1120
|
+
form.setValue("signature", defaultSignature);
|
|
763
1121
|
}
|
|
764
1122
|
|
|
765
1123
|
// Auto-populate due date and due days type from entity settings when entity loads async
|
|
766
|
-
if (!isEditMode && !
|
|
1124
|
+
if (!isEditMode && !hasInitialDueDate) {
|
|
767
1125
|
const dueDays = (activeEntity.settings as any)?.default_invoice_due_days ?? 30;
|
|
768
1126
|
const currentDate = form.getValues("date");
|
|
769
1127
|
if (currentDate) {
|
|
@@ -789,7 +1147,7 @@ export default function CreateInvoiceForm({
|
|
|
789
1147
|
elapsedMs: Number((performance.now() - duplicateHydrationStartedAtRef.current).toFixed(1)),
|
|
790
1148
|
});
|
|
791
1149
|
}
|
|
792
|
-
}, [activeEntity, form, hasInitialValues,
|
|
1150
|
+
}, [activeEntity, defaultSignature, form, hasInitialDueDate, hasInitialValues, initialValues, isEditMode]);
|
|
793
1151
|
|
|
794
1152
|
// Recalculate due date when document date changes (skip in edit mode and custom due days)
|
|
795
1153
|
const prevDateRef = useRef(form.getValues("date"));
|
|
@@ -820,28 +1178,38 @@ export default function CreateInvoiceForm({
|
|
|
820
1178
|
}
|
|
821
1179
|
}, [hasInitialValues]);
|
|
822
1180
|
|
|
823
|
-
const buildPreviewPayload = useCallback(
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
const
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
1181
|
+
const buildPreviewPayload = useCallback(
|
|
1182
|
+
(formValues: any): InvoicePreviewPayload => {
|
|
1183
|
+
const preservedExpectedTotalWithTax = getPreservedExpectedTotalWithTax(formValues);
|
|
1184
|
+
const previewItems = formValues.items?.map((item: any) => {
|
|
1185
|
+
const { id: _id, ...rest } = item;
|
|
1186
|
+
return rest;
|
|
1187
|
+
});
|
|
1188
|
+
return {
|
|
1189
|
+
number: formValues.number,
|
|
1190
|
+
date: formValues.date,
|
|
1191
|
+
date_service: formValues.date_service,
|
|
1192
|
+
date_service_to: formValues.date_service_to,
|
|
1193
|
+
customer_id: formValues.customer_id,
|
|
1194
|
+
customer: formValues.customer,
|
|
1195
|
+
items: prepareDocumentItems(previewItems, priceModesRef.current),
|
|
1196
|
+
currency_code: formValues.currency_code,
|
|
1197
|
+
linked_documents: formValues.linked_documents,
|
|
1198
|
+
...(forceLinkedDocuments ? { force_linked_documents: true } : {}),
|
|
1199
|
+
reference: formValues.reference,
|
|
1200
|
+
note: formValues.note,
|
|
1201
|
+
payment_terms: formValues.payment_terms,
|
|
1202
|
+
tax_clause: formValues.tax_clause,
|
|
1203
|
+
footer: formValues.footer,
|
|
1204
|
+
signature: formValues.signature,
|
|
1205
|
+
...(preservedExpectedTotalWithTax !== undefined
|
|
1206
|
+
? { expected_total_with_tax: preservedExpectedTotalWithTax }
|
|
1207
|
+
: {}),
|
|
1208
|
+
...(normalizePtDocumentInput(formValues.pt) ? { pt: normalizePtDocumentInput(formValues.pt) } : {}),
|
|
1209
|
+
};
|
|
1210
|
+
},
|
|
1211
|
+
[forceLinkedDocuments, getPreservedExpectedTotalWithTax],
|
|
1212
|
+
);
|
|
845
1213
|
|
|
846
1214
|
const emitCurrentPreviewPayload = useCallback(() => {
|
|
847
1215
|
if (!onChange) return;
|
|
@@ -927,7 +1295,7 @@ export default function CreateInvoiceForm({
|
|
|
927
1295
|
return (
|
|
928
1296
|
<div className="space-y-8">
|
|
929
1297
|
{/* Recipient + Details columns */}
|
|
930
|
-
<div className="flex w-full flex-col md:flex-row md:gap-6">
|
|
1298
|
+
<div className="flex w-full flex-col gap-8 md:flex-row md:gap-6">
|
|
931
1299
|
{/* Recipient section skeleton */}
|
|
932
1300
|
<div className="flex-1 space-y-4">
|
|
933
1301
|
<Skeleton className="h-7 w-24" />
|
|
@@ -989,10 +1357,10 @@ export default function CreateInvoiceForm({
|
|
|
989
1357
|
|
|
990
1358
|
return (
|
|
991
1359
|
<Form {...form}>
|
|
992
|
-
<
|
|
1360
|
+
<FormRoot id={FORM_ID} onSubmit={form.handleSubmit(onSubmit)} className="space-y-8">
|
|
993
1361
|
{/* Croatian domestic invoice validation errors */}
|
|
994
1362
|
{finaValidationError && (
|
|
995
|
-
<Alert variant="destructive">
|
|
1363
|
+
<Alert variant="destructive" data-form-error-summary="true">
|
|
996
1364
|
<AlertCircle className="h-4 w-4" />
|
|
997
1365
|
<AlertTitle>{finaValidationError}</AlertTitle>
|
|
998
1366
|
</Alert>
|
|
@@ -1000,7 +1368,7 @@ export default function CreateInvoiceForm({
|
|
|
1000
1368
|
|
|
1001
1369
|
{/* e-SLOG entity-level validation errors */}
|
|
1002
1370
|
{eslog.entityErrors.length > 0 && (
|
|
1003
|
-
<Alert variant="destructive">
|
|
1371
|
+
<Alert variant="destructive" data-form-error-summary="true">
|
|
1004
1372
|
<AlertCircle className="h-4 w-4" />
|
|
1005
1373
|
<AlertTitle>{t("e-SLOG Validation Failed")}</AlertTitle>
|
|
1006
1374
|
<AlertDescription>
|
|
@@ -1008,7 +1376,7 @@ export default function CreateInvoiceForm({
|
|
|
1008
1376
|
<ul className="list-disc space-y-1 pl-4">
|
|
1009
1377
|
{eslog.entityErrors.map((error) => (
|
|
1010
1378
|
<li key={error.field} className="text-sm">
|
|
1011
|
-
{error
|
|
1379
|
+
{translateEslogValidationError(error, t)}
|
|
1012
1380
|
</li>
|
|
1013
1381
|
))}
|
|
1014
1382
|
</ul>
|
|
@@ -1028,11 +1396,13 @@ export default function CreateInvoiceForm({
|
|
|
1028
1396
|
initialCustomerName={initialCustomerName}
|
|
1029
1397
|
showEndConsumerToggle={isCroatianEntity && (isDomesticTransaction || is3wTransaction)}
|
|
1030
1398
|
t={t}
|
|
1399
|
+
locale={locale}
|
|
1031
1400
|
/>
|
|
1032
1401
|
<DocumentDetailsSection
|
|
1033
1402
|
control={form.control}
|
|
1034
1403
|
documentType={_type}
|
|
1035
1404
|
t={t}
|
|
1405
|
+
locale={locale}
|
|
1036
1406
|
fursInline={
|
|
1037
1407
|
// Hide FURS selector in edit mode - fiscalization is set at creation only
|
|
1038
1408
|
!isEditMode && furs.isEnabled && furs.hasPremises
|
|
@@ -1079,31 +1449,49 @@ export default function CreateInvoiceForm({
|
|
|
1079
1449
|
dueDaysType,
|
|
1080
1450
|
onDueDaysTypeChange: handleDueDaysTypeChange,
|
|
1081
1451
|
}}
|
|
1452
|
+
dateLock={{
|
|
1453
|
+
isLocked: isFiscalizationDateLocked,
|
|
1454
|
+
reason: fiscalizationDateLockReason,
|
|
1455
|
+
}}
|
|
1082
1456
|
>
|
|
1083
1457
|
{/* Invoice-specific: Mark as paid section (UI-only state, not in form schema) */}
|
|
1084
1458
|
{/* Hide in edit mode - payments are managed separately */}
|
|
1085
1459
|
{!isEditMode && (
|
|
1086
1460
|
<MarkAsPaidSection
|
|
1087
1461
|
checked={markAsPaid}
|
|
1088
|
-
onCheckedChange={
|
|
1089
|
-
|
|
1090
|
-
|
|
1462
|
+
onCheckedChange={(checked) => {
|
|
1463
|
+
setMarkAsPaid(checked);
|
|
1464
|
+
setPaymentValidationMessage(undefined);
|
|
1465
|
+
}}
|
|
1466
|
+
paymentRows={paymentRows}
|
|
1467
|
+
onPaymentRowsChange={(rows) => {
|
|
1468
|
+
setPaymentRows(rows);
|
|
1469
|
+
setPaymentValidationMessage(undefined);
|
|
1470
|
+
}}
|
|
1471
|
+
documentTotal={paymentDocumentTotal}
|
|
1091
1472
|
t={t}
|
|
1092
1473
|
alwaysShowPaymentType={!!fina.isActive && requiresFinaFiscalization}
|
|
1474
|
+
validationMessage={paymentValidationMessage}
|
|
1093
1475
|
/>
|
|
1094
1476
|
)}
|
|
1477
|
+
{detailsExtras}
|
|
1095
1478
|
</DocumentDetailsSection>
|
|
1096
1479
|
</div>
|
|
1097
1480
|
|
|
1098
1481
|
<DocumentItemsSection
|
|
1099
1482
|
control={form.control}
|
|
1483
|
+
documentType={_type}
|
|
1100
1484
|
watch={form.watch}
|
|
1101
1485
|
setValue={form.setValue}
|
|
1486
|
+
clearErrors={form.clearErrors}
|
|
1487
|
+
trigger={form.trigger}
|
|
1488
|
+
isSubmitted={form.formState.isSubmitted}
|
|
1102
1489
|
getValues={form.getValues}
|
|
1103
1490
|
entityId={entityId}
|
|
1104
1491
|
currencyCode={activeEntity?.currency_code ?? undefined}
|
|
1105
1492
|
onAddNewTax={onAddNewTax}
|
|
1106
1493
|
t={t}
|
|
1494
|
+
locale={locale}
|
|
1107
1495
|
taxesDisabled={reverseChargeApplies}
|
|
1108
1496
|
taxesDisabledMessage={
|
|
1109
1497
|
reverseChargeApplies ? t("Reverse charge - tax exempt EU B2B sale") : viesWarning ? viesWarning : undefined
|
|
@@ -1185,7 +1573,7 @@ export default function CreateInvoiceForm({
|
|
|
1185
1573
|
{sourceDocuments && sourceDocuments.length > 0 && (
|
|
1186
1574
|
<LinkedDocumentsInfo documents={sourceDocuments} locale={locale || "en"} t={t} />
|
|
1187
1575
|
)}
|
|
1188
|
-
</
|
|
1576
|
+
</FormRoot>
|
|
1189
1577
|
</Form>
|
|
1190
1578
|
);
|
|
1191
1579
|
}
|