@spaceinvoices/react-ui 0.4.7 → 0.4.10
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 +1 -1
- package/src/common/autocomplete.tsx +69 -6
- package/src/components/advance-invoices/create/create-advance-invoice-form.tsx +124 -285
- package/src/components/advance-invoices/create/locales/de.ts +2 -1
- package/src/components/advance-invoices/create/locales/es.ts +2 -1
- package/src/components/advance-invoices/create/locales/fr.ts +2 -1
- package/src/components/advance-invoices/create/locales/hr.ts +2 -1
- package/src/components/advance-invoices/create/locales/it.ts +2 -1
- package/src/components/advance-invoices/create/locales/nl.ts +2 -1
- package/src/components/advance-invoices/create/locales/pl.ts +2 -1
- package/src/components/advance-invoices/create/locales/pt.ts +2 -1
- package/src/components/advance-invoices/create/locales/sl.ts +2 -1
- package/src/components/advance-invoices/list/list-table.tsx +10 -3
- package/src/components/advance-invoices/list/locales/de.ts +2 -0
- package/src/components/advance-invoices/list/locales/en.ts +1 -0
- package/src/components/advance-invoices/list/locales/es.ts +1 -0
- package/src/components/advance-invoices/list/locales/fr.ts +1 -0
- package/src/components/advance-invoices/list/locales/hr.ts +1 -0
- package/src/components/advance-invoices/list/locales/it.ts +1 -0
- package/src/components/advance-invoices/list/locales/nl.ts +1 -0
- package/src/components/advance-invoices/list/locales/pl.ts +1 -0
- package/src/components/advance-invoices/list/locales/pt.ts +1 -0
- package/src/components/advance-invoices/list/locales/sl.ts +1 -0
- package/src/components/advance-invoices/list/use-advance-invoice-download.ts +1 -12
- package/src/components/credit-notes/create/create-credit-note-form.tsx +116 -238
- package/src/components/credit-notes/create/locales/de.ts +2 -1
- package/src/components/credit-notes/create/locales/es.ts +2 -1
- package/src/components/credit-notes/create/locales/fr.ts +2 -1
- package/src/components/credit-notes/create/locales/hr.ts +2 -1
- package/src/components/credit-notes/create/locales/it.ts +2 -1
- package/src/components/credit-notes/create/locales/nl.ts +2 -1
- package/src/components/credit-notes/create/locales/pl.ts +2 -1
- package/src/components/credit-notes/create/locales/pt.ts +2 -1
- package/src/components/credit-notes/create/locales/sl.ts +2 -1
- package/src/components/credit-notes/list/list-table.tsx +6 -3
- package/src/components/credit-notes/list/use-credit-note-download.ts +1 -12
- package/src/components/customers/customer-autocomplete.tsx +64 -11
- package/src/components/customers/customer-list-table/customer-list-table.tsx +3 -2
- package/src/components/dashboard/collection-rate-card/collection-rate-card.tsx +9 -1
- package/src/components/dashboard/collection-rate-card/locales/bg.ts +3 -0
- package/src/components/dashboard/collection-rate-card/locales/cs.ts +3 -0
- package/src/components/dashboard/collection-rate-card/locales/et.ts +3 -0
- package/src/components/dashboard/collection-rate-card/locales/fi.ts +3 -0
- package/src/components/dashboard/collection-rate-card/locales/is.ts +3 -0
- package/src/components/dashboard/collection-rate-card/locales/nb.ts +3 -0
- package/src/components/dashboard/collection-rate-card/locales/sk.ts +3 -0
- package/src/components/dashboard/collection-rate-card/locales/sv.ts +3 -0
- package/src/components/dashboard/invoice-status-chart/invoice-status-chart.tsx +10 -2
- package/src/components/dashboard/invoice-status-chart/locales/bg.ts +10 -0
- package/src/components/dashboard/invoice-status-chart/locales/cs.ts +10 -0
- package/src/components/dashboard/invoice-status-chart/locales/de.ts +1 -0
- package/src/components/dashboard/invoice-status-chart/locales/es.ts +1 -0
- package/src/components/dashboard/invoice-status-chart/locales/et.ts +10 -0
- package/src/components/dashboard/invoice-status-chart/locales/fi.ts +10 -0
- package/src/components/dashboard/invoice-status-chart/locales/fr.ts +1 -0
- package/src/components/dashboard/invoice-status-chart/locales/hr.ts +1 -0
- package/src/components/dashboard/invoice-status-chart/locales/is.ts +10 -0
- package/src/components/dashboard/invoice-status-chart/locales/it.ts +1 -0
- package/src/components/dashboard/invoice-status-chart/locales/nb.ts +10 -0
- package/src/components/dashboard/invoice-status-chart/locales/nl.ts +1 -0
- package/src/components/dashboard/invoice-status-chart/locales/pl.ts +1 -0
- package/src/components/dashboard/invoice-status-chart/locales/pt.ts +1 -0
- package/src/components/dashboard/invoice-status-chart/locales/sk.ts +10 -0
- package/src/components/dashboard/invoice-status-chart/locales/sl.ts +1 -0
- package/src/components/dashboard/invoice-status-chart/locales/sv.ts +10 -0
- package/src/components/dashboard/payment-methods-chart/locales/bg.ts +12 -0
- package/src/components/dashboard/payment-methods-chart/locales/cs.ts +12 -0
- package/src/components/dashboard/payment-methods-chart/locales/et.ts +12 -0
- package/src/components/dashboard/payment-methods-chart/locales/fi.ts +12 -0
- package/src/components/dashboard/payment-methods-chart/locales/is.ts +12 -0
- package/src/components/dashboard/payment-methods-chart/locales/nb.ts +12 -0
- package/src/components/dashboard/payment-methods-chart/locales/sk.ts +12 -0
- package/src/components/dashboard/payment-methods-chart/locales/sv.ts +12 -0
- package/src/components/dashboard/payment-methods-chart/payment-methods-chart.tsx +9 -1
- package/src/components/dashboard/payment-trend-chart/locales/bg.ts +6 -0
- package/src/components/dashboard/payment-trend-chart/locales/cs.ts +6 -0
- package/src/components/dashboard/payment-trend-chart/locales/de.ts +1 -0
- package/src/components/dashboard/payment-trend-chart/locales/es.ts +1 -0
- package/src/components/dashboard/payment-trend-chart/locales/et.ts +6 -0
- package/src/components/dashboard/payment-trend-chart/locales/fi.ts +6 -0
- package/src/components/dashboard/payment-trend-chart/locales/fr.ts +1 -0
- package/src/components/dashboard/payment-trend-chart/locales/hr.ts +1 -0
- package/src/components/dashboard/payment-trend-chart/locales/is.ts +6 -0
- package/src/components/dashboard/payment-trend-chart/locales/it.ts +1 -0
- package/src/components/dashboard/payment-trend-chart/locales/nb.ts +6 -0
- package/src/components/dashboard/payment-trend-chart/locales/nl.ts +1 -0
- package/src/components/dashboard/payment-trend-chart/locales/pl.ts +1 -0
- package/src/components/dashboard/payment-trend-chart/locales/pt.ts +1 -0
- package/src/components/dashboard/payment-trend-chart/locales/sk.ts +6 -0
- package/src/components/dashboard/payment-trend-chart/locales/sl.ts +1 -0
- package/src/components/dashboard/payment-trend-chart/locales/sv.ts +6 -0
- package/src/components/dashboard/payment-trend-chart/payment-trend-chart.tsx +15 -8
- package/src/components/dashboard/revenue-trend-chart/locales/bg.ts +6 -0
- package/src/components/dashboard/revenue-trend-chart/locales/cs.ts +6 -0
- package/src/components/dashboard/revenue-trend-chart/locales/de.ts +1 -0
- package/src/components/dashboard/revenue-trend-chart/locales/es.ts +1 -0
- package/src/components/dashboard/revenue-trend-chart/locales/et.ts +6 -0
- package/src/components/dashboard/revenue-trend-chart/locales/fi.ts +6 -0
- package/src/components/dashboard/revenue-trend-chart/locales/fr.ts +1 -0
- package/src/components/dashboard/revenue-trend-chart/locales/hr.ts +1 -0
- package/src/components/dashboard/revenue-trend-chart/locales/is.ts +6 -0
- package/src/components/dashboard/revenue-trend-chart/locales/it.ts +1 -0
- package/src/components/dashboard/revenue-trend-chart/locales/nb.ts +6 -0
- package/src/components/dashboard/revenue-trend-chart/locales/nl.ts +1 -0
- package/src/components/dashboard/revenue-trend-chart/locales/pl.ts +1 -0
- package/src/components/dashboard/revenue-trend-chart/locales/pt.ts +1 -0
- package/src/components/dashboard/revenue-trend-chart/locales/sk.ts +6 -0
- package/src/components/dashboard/revenue-trend-chart/locales/sl.ts +1 -0
- package/src/components/dashboard/revenue-trend-chart/locales/sv.ts +6 -0
- package/src/components/dashboard/revenue-trend-chart/revenue-trend-chart.tsx +15 -8
- package/src/components/dashboard/tax-collected-card/locales.ts +110 -0
- package/src/components/dashboard/tax-collected-card/tax-collected-card.tsx +8 -2
- package/src/components/dashboard/tax-collected-card/use-tax-collected.ts +4 -4
- package/src/components/dashboard/top-customers-chart/locales/bg.ts +7 -0
- package/src/components/dashboard/top-customers-chart/locales/cs.ts +7 -0
- package/src/components/dashboard/top-customers-chart/locales/de.ts +2 -0
- package/src/components/dashboard/top-customers-chart/locales/es.ts +2 -0
- package/src/components/dashboard/top-customers-chart/locales/et.ts +7 -0
- package/src/components/dashboard/top-customers-chart/locales/fi.ts +7 -0
- package/src/components/dashboard/top-customers-chart/locales/fr.ts +2 -0
- package/src/components/dashboard/top-customers-chart/locales/hr.ts +2 -0
- package/src/components/dashboard/top-customers-chart/locales/is.ts +7 -0
- package/src/components/dashboard/top-customers-chart/locales/it.ts +2 -0
- package/src/components/dashboard/top-customers-chart/locales/nb.ts +7 -0
- package/src/components/dashboard/top-customers-chart/locales/nl.ts +2 -0
- package/src/components/dashboard/top-customers-chart/locales/pl.ts +2 -0
- package/src/components/dashboard/top-customers-chart/locales/pt.ts +2 -0
- package/src/components/dashboard/top-customers-chart/locales/sk.ts +7 -0
- package/src/components/dashboard/top-customers-chart/locales/sl.ts +2 -0
- package/src/components/dashboard/top-customers-chart/locales/sv.ts +7 -0
- package/src/components/dashboard/top-customers-chart/top-customers-chart.tsx +23 -12
- package/src/components/delivery-notes/create/create-delivery-note-form.tsx +33 -20
- package/src/components/delivery-notes/create/locales/de.ts +2 -1
- package/src/components/delivery-notes/create/locales/es.ts +2 -1
- package/src/components/delivery-notes/create/locales/fr.ts +2 -1
- package/src/components/delivery-notes/create/locales/hr.ts +2 -1
- package/src/components/delivery-notes/create/locales/it.ts +2 -1
- package/src/components/delivery-notes/create/locales/nl.ts +2 -1
- package/src/components/delivery-notes/create/locales/pl.ts +2 -1
- package/src/components/delivery-notes/create/locales/pt.ts +2 -1
- package/src/components/delivery-notes/create/locales/sl.ts +2 -1
- package/src/components/delivery-notes/list/list-table.tsx +22 -13
- package/src/components/delivery-notes/list/locales/de.ts +2 -0
- package/src/components/delivery-notes/list/locales/en.ts +1 -0
- package/src/components/delivery-notes/list/locales/es.ts +1 -0
- package/src/components/delivery-notes/list/locales/fr.ts +1 -0
- package/src/components/delivery-notes/list/locales/hr.ts +1 -0
- package/src/components/delivery-notes/list/locales/it.ts +1 -0
- package/src/components/delivery-notes/list/locales/nl.ts +1 -0
- package/src/components/delivery-notes/list/locales/pl.ts +1 -0
- package/src/components/delivery-notes/list/locales/pt.ts +1 -0
- package/src/components/delivery-notes/list/locales/sl.ts +1 -0
- package/src/components/delivery-notes/list/use-delivery-note-download.ts +1 -12
- package/src/components/documents/create/document-add-item-form.tsx +28 -16
- package/src/components/documents/create/document-add-item-tax-rate-field.tsx +12 -2
- package/src/components/documents/create/document-items-section.tsx +70 -39
- package/src/components/documents/create/document-recipient-section.tsx +10 -1
- package/src/components/documents/create/live-preview.tsx +113 -15
- package/src/components/documents/create/prepare-document-submission.ts +35 -16
- package/src/components/documents/create/use-document-customer-form.ts +14 -3
- package/src/components/documents/documents.hooks.ts +7 -2
- package/src/components/documents/shared/document-preview-display.tsx +136 -67
- package/src/components/documents/shared/scaled-document-preview.tsx +45 -5
- package/src/components/documents/view/document-actions-bar.tsx +284 -182
- package/src/components/documents/view/document-activities-list.tsx +3 -0
- package/src/components/documents/view/document-payments-list.tsx +3 -0
- package/src/components/documents/view/locales/de.ts +8 -0
- package/src/components/documents/view/locales/es.ts +8 -0
- package/src/components/documents/view/locales/fr.ts +8 -0
- package/src/components/documents/view/locales/hr.ts +8 -0
- package/src/components/documents/view/locales/it.ts +8 -0
- package/src/components/documents/view/locales/nl.ts +8 -0
- package/src/components/documents/view/locales/pl.ts +8 -0
- package/src/components/documents/view/locales/pt.ts +8 -0
- package/src/components/documents/view/locales/sl.ts +8 -0
- package/src/components/documents/view/use-document-download.ts +14 -25
- package/src/components/entities/create-entity-form.tsx +101 -16
- package/src/components/entities/entity-settings-form/locales/de.ts +6 -3
- package/src/components/entities/entity-settings-form/locales/es.ts +6 -3
- package/src/components/entities/entity-settings-form/locales/fr.ts +6 -3
- package/src/components/entities/entity-settings-form/locales/hr.ts +4 -2
- package/src/components/entities/entity-settings-form/locales/it.ts +6 -3
- package/src/components/entities/entity-settings-form/locales/nl.ts +6 -3
- package/src/components/entities/entity-settings-form/locales/pl.ts +6 -2
- package/src/components/entities/entity-settings-form/locales/pt.ts +6 -3
- package/src/components/entities/entity-settings-form/locales/sl.ts +4 -2
- package/src/components/entities/fina-settings-form/fina-operator-required-dialog.tsx +3 -3
- package/src/components/entities/fina-settings-form/fina-settings-form.tsx +78 -124
- package/src/components/entities/fina-settings-form/sections/certificate-settings-section.tsx +8 -1
- package/src/components/entities/fina-settings-form/sections/premises-management-section.tsx +14 -2
- package/src/components/entities/fina-settings-form/sections/register-premise-dialog.tsx +7 -2
- package/src/components/entities/furs-settings-form/furs-settings-form.tsx +56 -130
- package/src/components/entities/furs-settings-form/sections/certificate-settings-section.tsx +8 -1
- package/src/components/entities/furs-settings-form/sections/enable-fiscalization-section.tsx +1 -0
- package/src/components/entities/furs-settings-form/sections/general-settings-section.tsx +15 -2
- package/src/components/entities/furs-settings-form/sections/premises-management-section.tsx +20 -3
- package/src/components/entities/furs-settings-form/sections/register-premise-dialog.tsx +38 -12
- package/src/components/entities/settings/eslog-settings-form.tsx +13 -1
- package/src/components/entities/settings/pdf-template-selector/demo-invoice-data.ts +3 -22
- package/src/components/entities/shared/fiscalization-step-flow.ts +77 -0
- package/src/components/entities/shared/fiscalization-step-tabs.tsx +71 -0
- package/src/components/estimates/create/create-estimate-form.tsx +34 -21
- package/src/components/estimates/create/locales/de.ts +2 -1
- package/src/components/estimates/create/locales/es.ts +2 -1
- package/src/components/estimates/create/locales/fr.ts +2 -1
- package/src/components/estimates/create/locales/hr.ts +2 -1
- package/src/components/estimates/create/locales/it.ts +2 -1
- package/src/components/estimates/create/locales/nl.ts +2 -1
- package/src/components/estimates/create/locales/pl.ts +2 -1
- package/src/components/estimates/create/locales/pt.ts +2 -1
- package/src/components/estimates/create/locales/sl.ts +2 -1
- package/src/components/estimates/list/list-table.tsx +23 -14
- package/src/components/estimates/list/locales/de.ts +2 -0
- package/src/components/estimates/list/locales/en.ts +1 -0
- package/src/components/estimates/list/locales/es.ts +1 -0
- package/src/components/estimates/list/locales/fr.ts +1 -0
- package/src/components/estimates/list/locales/hr.ts +1 -0
- package/src/components/estimates/list/locales/it.ts +1 -0
- package/src/components/estimates/list/locales/nl.ts +1 -0
- package/src/components/estimates/list/locales/pl.ts +1 -0
- package/src/components/estimates/list/locales/pt.ts +1 -0
- package/src/components/estimates/list/locales/sl.ts +1 -0
- package/src/components/estimates/list/use-estimate-download.ts +1 -12
- package/src/components/export/document-export-form.tsx +33 -7
- package/src/components/export/sales-per-item-export-form.tsx +23 -7
- package/src/components/invoices/create/create-invoice-form.tsx +295 -329
- package/src/components/invoices/create/locales/de.ts +2 -1
- package/src/components/invoices/create/locales/es.ts +2 -1
- package/src/components/invoices/create/locales/fr.ts +2 -1
- package/src/components/invoices/create/locales/hr.ts +2 -1
- package/src/components/invoices/create/locales/it.ts +2 -1
- package/src/components/invoices/create/locales/nl.ts +2 -1
- package/src/components/invoices/create/locales/pl.ts +2 -1
- package/src/components/invoices/create/locales/pt.ts +2 -1
- package/src/components/invoices/create/locales/sl.ts +2 -1
- package/src/components/invoices/create/prepare-invoice-submission.ts +0 -8
- package/src/components/invoices/list/list-table.tsx +7 -4
- package/src/components/invoices/list/use-invoice-download.ts +1 -11
- package/src/components/invoices/send-email-dialog/locales/de.ts +2 -0
- package/src/components/invoices/send-email-dialog/locales/es.ts +2 -0
- package/src/components/invoices/send-email-dialog/locales/fr.ts +2 -0
- package/src/components/invoices/send-email-dialog/locales/hr.ts +2 -0
- package/src/components/invoices/send-email-dialog/locales/it.ts +2 -0
- package/src/components/invoices/send-email-dialog/locales/nl.ts +2 -0
- package/src/components/invoices/send-email-dialog/locales/pl.ts +2 -0
- package/src/components/invoices/send-email-dialog/locales/pt.ts +2 -0
- package/src/components/invoices/send-email-dialog/locales/sl.ts +2 -0
- package/src/components/invoices/send-email-dialog/send-email-dialog.tsx +77 -8
- package/src/components/invoices/view/eslog-info-display.tsx +17 -1
- package/src/components/invoices/view/fiscalization-status-card.tsx +7 -3
- package/src/components/items/item-combobox.tsx +26 -6
- package/src/components/items/item-list-table/item-list-table.tsx +5 -2
- package/src/components/payments/list/list-table.tsx +14 -4
- package/src/components/recurring-invoices/list/list-table.tsx +7 -4
- package/src/components/request-logs/locales.ts +412 -0
- package/src/components/request-logs/request-log-detail.tsx +37 -21
- package/src/components/request-logs/request-log-list-table.tsx +57 -11
- package/src/components/table/data-table.tsx +5 -2
- package/src/components/table/date-cell.tsx +3 -1
- package/src/components/table/filter-bar.tsx +14 -2
- package/src/components/table/hooks/use-table-query.ts +1 -1
- package/src/components/table/locales.ts +1116 -0
- package/src/components/table/search-input.tsx +12 -3
- package/src/components/table/selection-toolbar.tsx +23 -6
- package/src/components/table/table-empty-state.tsx +43 -3
- package/src/components/table/table-no-results.tsx +3 -3
- package/src/components/table/table-pagination.tsx +4 -3
- package/src/components/table/types.ts +1 -0
- package/src/components/tax-reports/index.ts +1 -0
- package/src/components/tax-reports/kir-export-form.tsx +46 -8
- package/src/components/tax-reports/slovenia-tax-profile-step.tsx +191 -0
- package/src/components/tax-reports/slovenia-yearly-export-form.tsx +509 -0
- package/src/components/tax-reports/slovenia-yearly-review-step.tsx +253 -0
- package/src/components/tax-reports/slovenia-yearly-summary.tsx +19 -0
- package/src/components/taxes/tax-list-table/tax-list-table.tsx +3 -2
- package/src/components/ui/sticky-form-footer.tsx +7 -1
- package/src/components/webhook-logs/index.ts +6 -0
- package/src/components/webhook-logs/locales.ts +392 -0
- package/src/components/webhook-logs/webhook-delivery-detail.tsx +255 -0
- package/src/components/webhook-logs/webhook-delivery-list-table.tsx +278 -0
- package/src/components/wl-subscription/index.ts +1 -0
- package/src/components/wl-subscription/locked-feature.tsx +1 -0
- package/src/components/wl-subscription/paywall.tsx +193 -0
- package/src/components/wl-subscription/upgrade-modal.tsx +93 -29
- package/src/generate-schemas.ts +10 -5
- package/src/generated/schemas/customer.ts +2 -0
- package/src/generated/schemas/entity.ts +34 -0
- package/src/generated/schemas/me.ts +20 -1
- package/src/generated/schemas/renderadvanceinvoicepreview_body.ts +40 -34
- package/src/generated/schemas/rendercreditnotepreview_body.ts +42 -36
- package/src/generated/schemas/renderdeliverynotepreview_body.ts +23 -13
- package/src/generated/schemas/renderestimatepreview_body.ts +23 -13
- package/src/generated/schemas/renderinvoicepreview_body.ts +40 -34
- package/src/generated/schemas/sendemail_body.ts +44 -0
- package/src/generated/schemas/startpdfexport_body.ts +91 -1
- package/src/generated/schemas/webhook.ts +10 -0
- package/src/hooks/use-duplicate-document.ts +51 -13
- package/src/hooks/use-eslog-validation.ts +59 -0
- package/src/hooks/use-premise-selection.ts +186 -0
- package/src/lib/browser-cookies.ts +4 -4
- package/src/lib/date-fns-locale.ts +48 -0
- package/src/lib/fiscalization-options.ts +81 -0
- package/src/lib/locale.ts +38 -0
- package/src/lib/template-variables.tsx +1 -1
- package/src/lib/translation.ts +14 -3
- package/src/providers/entities-context.tsx +1 -0
- package/src/providers/entities-provider.tsx +102 -3
- package/src/providers/form-footer-context.tsx +37 -4
- package/src/providers/sdk-provider.tsx +7 -2
- package/src/providers/white-label-provider.tsx +4 -1
- package/src/providers/wl-subscription-provider.tsx +90 -3
|
@@ -23,6 +23,7 @@ const DocumentEntity = z
|
|
|
23
23
|
tax_number: z.union([z.string(), z.null()]),
|
|
24
24
|
tax_number_2: z.union([z.string(), z.null()]),
|
|
25
25
|
company_number: z.union([z.string(), z.null()]),
|
|
26
|
+
peppol_id: z.union([z.string(), z.null()]),
|
|
26
27
|
is_end_consumer: z.union([z.boolean(), z.null()]),
|
|
27
28
|
bank_account: z.union([
|
|
28
29
|
z
|
|
@@ -30,13 +31,13 @@ const DocumentEntity = z
|
|
|
30
31
|
type: z
|
|
31
32
|
.enum(["iban", "us_domestic", "uk_domestic", "other"])
|
|
32
33
|
.default("iban"),
|
|
33
|
-
name: z.string(),
|
|
34
|
-
bank_name: z.string(),
|
|
35
|
-
iban: z.string(),
|
|
36
|
-
account_number: z.string(),
|
|
37
|
-
bic: z.string(),
|
|
38
|
-
routing_number: z.string(),
|
|
39
|
-
sort_code: z.string(),
|
|
34
|
+
name: z.union([z.string(), z.null()]),
|
|
35
|
+
bank_name: z.union([z.string(), z.null()]),
|
|
36
|
+
iban: z.union([z.string(), z.null()]),
|
|
37
|
+
account_number: z.union([z.string(), z.null()]),
|
|
38
|
+
bic: z.union([z.string(), z.null()]),
|
|
39
|
+
routing_number: z.union([z.string(), z.null()]),
|
|
40
|
+
sort_code: z.union([z.string(), z.null()]),
|
|
40
41
|
})
|
|
41
42
|
.partial()
|
|
42
43
|
.passthrough(),
|
|
@@ -51,7 +52,7 @@ const DocumentEntity = z
|
|
|
51
52
|
const CreateDocumentCustomer = DocumentEntity.and(
|
|
52
53
|
z.union([
|
|
53
54
|
z
|
|
54
|
-
.object({ save_customer: z.boolean().
|
|
55
|
+
.object({ save_customer: z.union([z.boolean(), z.null()]) })
|
|
55
56
|
.partial()
|
|
56
57
|
.passthrough(),
|
|
57
58
|
z.null(),
|
|
@@ -91,6 +92,15 @@ const PartialDeliveryNotePreview = z.object({
|
|
|
91
92
|
price: z.number(),
|
|
92
93
|
gross_price: z.number(),
|
|
93
94
|
description: z.string(),
|
|
95
|
+
unit: z.string(),
|
|
96
|
+
discounts: z.array(
|
|
97
|
+
z
|
|
98
|
+
.object({
|
|
99
|
+
value: z.number(),
|
|
100
|
+
type: z.enum(["percent", "amount"]).optional(),
|
|
101
|
+
})
|
|
102
|
+
.passthrough()
|
|
103
|
+
),
|
|
94
104
|
taxes: z.array(
|
|
95
105
|
z
|
|
96
106
|
.object({ rate: z.number(), tax_id: z.string() })
|
|
@@ -111,7 +121,7 @@ const PartialDeliveryNotePreview = z.object({
|
|
|
111
121
|
// Dependency schema for renderdeliverynotepreview_body
|
|
112
122
|
const DocumentItemTax = z
|
|
113
123
|
.object({
|
|
114
|
-
rate: z.number(),
|
|
124
|
+
rate: z.union([z.number(), z.null()]),
|
|
115
125
|
tax_id: z.union([z.string(), z.null()]),
|
|
116
126
|
classification: z.union([z.string(), z.null()]),
|
|
117
127
|
reverse_charge: z.union([z.boolean(), z.null()]),
|
|
@@ -131,17 +141,17 @@ const LineDiscount = z.object({
|
|
|
131
141
|
const CreateDocumentItem = z
|
|
132
142
|
.object({
|
|
133
143
|
type: z.union([z.literal("separator"), z.null()]),
|
|
134
|
-
name: z.string().
|
|
144
|
+
name: z.union([z.string(), z.null()]),
|
|
135
145
|
description: z.union([z.string(), z.null()]),
|
|
136
|
-
price: z.number(),
|
|
146
|
+
price: z.union([z.number(), z.null()]),
|
|
137
147
|
gross_price: z.union([z.number(), z.null()]),
|
|
138
|
-
quantity: z.
|
|
148
|
+
quantity: z.union([z.number(), z.null()]),
|
|
139
149
|
unit: z.union([z.string(), z.null()]),
|
|
140
150
|
taxes: z.array(DocumentItemTax),
|
|
141
151
|
discounts: z.array(LineDiscount).max(5),
|
|
142
152
|
item_id: z.union([z.string(), z.null()]),
|
|
143
153
|
metadata: z.union([z.record(z.string(), z.any()), z.null()]),
|
|
144
|
-
save_item: z.boolean().
|
|
154
|
+
save_item: z.union([z.boolean(), z.null()]),
|
|
145
155
|
})
|
|
146
156
|
.partial();
|
|
147
157
|
|
|
@@ -23,6 +23,7 @@ const DocumentEntity = z
|
|
|
23
23
|
tax_number: z.union([z.string(), z.null()]),
|
|
24
24
|
tax_number_2: z.union([z.string(), z.null()]),
|
|
25
25
|
company_number: z.union([z.string(), z.null()]),
|
|
26
|
+
peppol_id: z.union([z.string(), z.null()]),
|
|
26
27
|
is_end_consumer: z.union([z.boolean(), z.null()]),
|
|
27
28
|
bank_account: z.union([
|
|
28
29
|
z
|
|
@@ -30,13 +31,13 @@ const DocumentEntity = z
|
|
|
30
31
|
type: z
|
|
31
32
|
.enum(["iban", "us_domestic", "uk_domestic", "other"])
|
|
32
33
|
.default("iban"),
|
|
33
|
-
name: z.string(),
|
|
34
|
-
bank_name: z.string(),
|
|
35
|
-
iban: z.string(),
|
|
36
|
-
account_number: z.string(),
|
|
37
|
-
bic: z.string(),
|
|
38
|
-
routing_number: z.string(),
|
|
39
|
-
sort_code: z.string(),
|
|
34
|
+
name: z.union([z.string(), z.null()]),
|
|
35
|
+
bank_name: z.union([z.string(), z.null()]),
|
|
36
|
+
iban: z.union([z.string(), z.null()]),
|
|
37
|
+
account_number: z.union([z.string(), z.null()]),
|
|
38
|
+
bic: z.union([z.string(), z.null()]),
|
|
39
|
+
routing_number: z.union([z.string(), z.null()]),
|
|
40
|
+
sort_code: z.union([z.string(), z.null()]),
|
|
40
41
|
})
|
|
41
42
|
.partial()
|
|
42
43
|
.passthrough(),
|
|
@@ -51,7 +52,7 @@ const DocumentEntity = z
|
|
|
51
52
|
const CreateDocumentCustomer = DocumentEntity.and(
|
|
52
53
|
z.union([
|
|
53
54
|
z
|
|
54
|
-
.object({ save_customer: z.boolean().
|
|
55
|
+
.object({ save_customer: z.union([z.boolean(), z.null()]) })
|
|
55
56
|
.partial()
|
|
56
57
|
.passthrough(),
|
|
57
58
|
z.null(),
|
|
@@ -92,6 +93,15 @@ const PartialEstimatePreview = z.object({
|
|
|
92
93
|
price: z.number(),
|
|
93
94
|
gross_price: z.number(),
|
|
94
95
|
description: z.string(),
|
|
96
|
+
unit: z.string(),
|
|
97
|
+
discounts: z.array(
|
|
98
|
+
z
|
|
99
|
+
.object({
|
|
100
|
+
value: z.number(),
|
|
101
|
+
type: z.enum(["percent", "amount"]).optional(),
|
|
102
|
+
})
|
|
103
|
+
.passthrough()
|
|
104
|
+
),
|
|
95
105
|
taxes: z.array(
|
|
96
106
|
z
|
|
97
107
|
.object({ rate: z.number(), tax_id: z.string() })
|
|
@@ -111,7 +121,7 @@ const PartialEstimatePreview = z.object({
|
|
|
111
121
|
// Dependency schema for renderestimatepreview_body
|
|
112
122
|
const DocumentItemTax = z
|
|
113
123
|
.object({
|
|
114
|
-
rate: z.number(),
|
|
124
|
+
rate: z.union([z.number(), z.null()]),
|
|
115
125
|
tax_id: z.union([z.string(), z.null()]),
|
|
116
126
|
classification: z.union([z.string(), z.null()]),
|
|
117
127
|
reverse_charge: z.union([z.boolean(), z.null()]),
|
|
@@ -131,17 +141,17 @@ const LineDiscount = z.object({
|
|
|
131
141
|
const CreateDocumentItem = z
|
|
132
142
|
.object({
|
|
133
143
|
type: z.union([z.literal("separator"), z.null()]),
|
|
134
|
-
name: z.string().
|
|
144
|
+
name: z.union([z.string(), z.null()]),
|
|
135
145
|
description: z.union([z.string(), z.null()]),
|
|
136
|
-
price: z.number(),
|
|
146
|
+
price: z.union([z.number(), z.null()]),
|
|
137
147
|
gross_price: z.union([z.number(), z.null()]),
|
|
138
|
-
quantity: z.
|
|
148
|
+
quantity: z.union([z.number(), z.null()]),
|
|
139
149
|
unit: z.union([z.string(), z.null()]),
|
|
140
150
|
taxes: z.array(DocumentItemTax),
|
|
141
151
|
discounts: z.array(LineDiscount).max(5),
|
|
142
152
|
item_id: z.union([z.string(), z.null()]),
|
|
143
153
|
metadata: z.union([z.record(z.string(), z.any()), z.null()]),
|
|
144
|
-
save_item: z.boolean().
|
|
154
|
+
save_item: z.union([z.boolean(), z.null()]),
|
|
145
155
|
})
|
|
146
156
|
.partial();
|
|
147
157
|
|
|
@@ -23,6 +23,7 @@ const DocumentEntity = z
|
|
|
23
23
|
tax_number: z.union([z.string(), z.null()]),
|
|
24
24
|
tax_number_2: z.union([z.string(), z.null()]),
|
|
25
25
|
company_number: z.union([z.string(), z.null()]),
|
|
26
|
+
peppol_id: z.union([z.string(), z.null()]),
|
|
26
27
|
is_end_consumer: z.union([z.boolean(), z.null()]),
|
|
27
28
|
bank_account: z.union([
|
|
28
29
|
z
|
|
@@ -30,13 +31,13 @@ const DocumentEntity = z
|
|
|
30
31
|
type: z
|
|
31
32
|
.enum(["iban", "us_domestic", "uk_domestic", "other"])
|
|
32
33
|
.default("iban"),
|
|
33
|
-
name: z.string(),
|
|
34
|
-
bank_name: z.string(),
|
|
35
|
-
iban: z.string(),
|
|
36
|
-
account_number: z.string(),
|
|
37
|
-
bic: z.string(),
|
|
38
|
-
routing_number: z.string(),
|
|
39
|
-
sort_code: z.string(),
|
|
34
|
+
name: z.union([z.string(), z.null()]),
|
|
35
|
+
bank_name: z.union([z.string(), z.null()]),
|
|
36
|
+
iban: z.union([z.string(), z.null()]),
|
|
37
|
+
account_number: z.union([z.string(), z.null()]),
|
|
38
|
+
bic: z.union([z.string(), z.null()]),
|
|
39
|
+
routing_number: z.union([z.string(), z.null()]),
|
|
40
|
+
sort_code: z.union([z.string(), z.null()]),
|
|
40
41
|
})
|
|
41
42
|
.partial()
|
|
42
43
|
.passthrough(),
|
|
@@ -51,7 +52,7 @@ const DocumentEntity = z
|
|
|
51
52
|
const CreateDocumentCustomer = DocumentEntity.and(
|
|
52
53
|
z.union([
|
|
53
54
|
z
|
|
54
|
-
.object({ save_customer: z.boolean().
|
|
55
|
+
.object({ save_customer: z.union([z.boolean(), z.null()]) })
|
|
55
56
|
.partial()
|
|
56
57
|
.passthrough(),
|
|
57
58
|
z.null(),
|
|
@@ -63,28 +64,24 @@ const CreateDocumentCustomer = DocumentEntity.and(
|
|
|
63
64
|
const CreateFinaInvoiceData = z.union([
|
|
64
65
|
z
|
|
65
66
|
.object({
|
|
66
|
-
business_premise_name: z
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
"paypal",
|
|
83
|
-
"crypto",
|
|
84
|
-
"coupon",
|
|
85
|
-
"other",
|
|
67
|
+
business_premise_name: z.union([z.string(), z.null()]),
|
|
68
|
+
electronic_device_name: z.union([z.string(), z.null()]),
|
|
69
|
+
operator_oib: z.union([z.string(), z.null()]),
|
|
70
|
+
operator_label: z.union([z.string(), z.null()]),
|
|
71
|
+
payment_type: z.union([
|
|
72
|
+
z.enum([
|
|
73
|
+
"cash",
|
|
74
|
+
"card",
|
|
75
|
+
"online",
|
|
76
|
+
"bank_transfer",
|
|
77
|
+
"paypal",
|
|
78
|
+
"crypto",
|
|
79
|
+
"coupon",
|
|
80
|
+
"other",
|
|
81
|
+
]),
|
|
82
|
+
z.null(),
|
|
86
83
|
]),
|
|
87
|
-
subsequent_submit: z.boolean(),
|
|
84
|
+
subsequent_submit: z.union([z.boolean(), z.null()]),
|
|
88
85
|
})
|
|
89
86
|
.partial(),
|
|
90
87
|
z.null(),
|
|
@@ -122,6 +119,15 @@ const PartialInvoicePreview = z.object({
|
|
|
122
119
|
price: z.number(),
|
|
123
120
|
gross_price: z.number(),
|
|
124
121
|
description: z.string(),
|
|
122
|
+
unit: z.string(),
|
|
123
|
+
discounts: z.array(
|
|
124
|
+
z
|
|
125
|
+
.object({
|
|
126
|
+
value: z.number(),
|
|
127
|
+
type: z.enum(["percent", "amount"]).optional(),
|
|
128
|
+
})
|
|
129
|
+
.passthrough()
|
|
130
|
+
),
|
|
125
131
|
taxes: z.array(
|
|
126
132
|
z
|
|
127
133
|
.object({ rate: z.number(), tax_id: z.string() })
|
|
@@ -143,7 +149,7 @@ const PartialInvoicePreview = z.object({
|
|
|
143
149
|
// Dependency schema for renderinvoicepreview_body
|
|
144
150
|
const DocumentItemTax = z
|
|
145
151
|
.object({
|
|
146
|
-
rate: z.number(),
|
|
152
|
+
rate: z.union([z.number(), z.null()]),
|
|
147
153
|
tax_id: z.union([z.string(), z.null()]),
|
|
148
154
|
classification: z.union([z.string(), z.null()]),
|
|
149
155
|
reverse_charge: z.union([z.boolean(), z.null()]),
|
|
@@ -163,17 +169,17 @@ const LineDiscount = z.object({
|
|
|
163
169
|
const CreateDocumentItem = z
|
|
164
170
|
.object({
|
|
165
171
|
type: z.union([z.literal("separator"), z.null()]),
|
|
166
|
-
name: z.string().
|
|
172
|
+
name: z.union([z.string(), z.null()]),
|
|
167
173
|
description: z.union([z.string(), z.null()]),
|
|
168
|
-
price: z.number(),
|
|
174
|
+
price: z.union([z.number(), z.null()]),
|
|
169
175
|
gross_price: z.union([z.number(), z.null()]),
|
|
170
|
-
quantity: z.
|
|
176
|
+
quantity: z.union([z.number(), z.null()]),
|
|
171
177
|
unit: z.union([z.string(), z.null()]),
|
|
172
178
|
taxes: z.array(DocumentItemTax),
|
|
173
179
|
discounts: z.array(LineDiscount).max(5),
|
|
174
180
|
item_id: z.union([z.string(), z.null()]),
|
|
175
181
|
metadata: z.union([z.record(z.string(), z.any()), z.null()]),
|
|
176
|
-
save_item: z.boolean().
|
|
182
|
+
save_item: z.union([z.boolean(), z.null()]),
|
|
177
183
|
})
|
|
178
184
|
.partial();
|
|
179
185
|
|
|
@@ -16,6 +16,50 @@ const sendEmailSchemaDefinition = z.object({
|
|
|
16
16
|
document_id: z.string().optional(),
|
|
17
17
|
attach_pdf: z.boolean().optional().default(false),
|
|
18
18
|
attach_eslog: z.boolean().optional().default(false),
|
|
19
|
+
locale: z
|
|
20
|
+
.enum([
|
|
21
|
+
"en-US",
|
|
22
|
+
"de-DE",
|
|
23
|
+
"it-IT",
|
|
24
|
+
"fr-FR",
|
|
25
|
+
"es-ES",
|
|
26
|
+
"sl-SI",
|
|
27
|
+
"pt-PT",
|
|
28
|
+
"nl-NL",
|
|
29
|
+
"pl-PL",
|
|
30
|
+
"hr-HR",
|
|
31
|
+
"sv-SE",
|
|
32
|
+
"fi-FI",
|
|
33
|
+
"et-EE",
|
|
34
|
+
"bg-BG",
|
|
35
|
+
"cs-CZ",
|
|
36
|
+
"sk-SK",
|
|
37
|
+
"nb-NO",
|
|
38
|
+
"is-IS",
|
|
39
|
+
])
|
|
40
|
+
.optional(),
|
|
41
|
+
language: z
|
|
42
|
+
.enum([
|
|
43
|
+
"en-US",
|
|
44
|
+
"de-DE",
|
|
45
|
+
"it-IT",
|
|
46
|
+
"fr-FR",
|
|
47
|
+
"es-ES",
|
|
48
|
+
"sl-SI",
|
|
49
|
+
"pt-PT",
|
|
50
|
+
"nl-NL",
|
|
51
|
+
"pl-PL",
|
|
52
|
+
"hr-HR",
|
|
53
|
+
"sv-SE",
|
|
54
|
+
"fi-FI",
|
|
55
|
+
"et-EE",
|
|
56
|
+
"bg-BG",
|
|
57
|
+
"cs-CZ",
|
|
58
|
+
"sk-SK",
|
|
59
|
+
"nb-NO",
|
|
60
|
+
"is-IS",
|
|
61
|
+
])
|
|
62
|
+
.optional(),
|
|
19
63
|
});
|
|
20
64
|
|
|
21
65
|
// Type for send email operation
|
|
@@ -10,7 +10,53 @@ import { z } from 'zod';
|
|
|
10
10
|
|
|
11
11
|
// Dependency schema for startpdfexport_body
|
|
12
12
|
const PdfExportByDocumentIds = z
|
|
13
|
-
.object({
|
|
13
|
+
.object({
|
|
14
|
+
document_ids: z.array(z.string()).min(1),
|
|
15
|
+
locale: z
|
|
16
|
+
.enum([
|
|
17
|
+
"en-US",
|
|
18
|
+
"de-DE",
|
|
19
|
+
"it-IT",
|
|
20
|
+
"fr-FR",
|
|
21
|
+
"es-ES",
|
|
22
|
+
"sl-SI",
|
|
23
|
+
"pt-PT",
|
|
24
|
+
"nl-NL",
|
|
25
|
+
"pl-PL",
|
|
26
|
+
"hr-HR",
|
|
27
|
+
"sv-SE",
|
|
28
|
+
"fi-FI",
|
|
29
|
+
"et-EE",
|
|
30
|
+
"bg-BG",
|
|
31
|
+
"cs-CZ",
|
|
32
|
+
"sk-SK",
|
|
33
|
+
"nb-NO",
|
|
34
|
+
"is-IS",
|
|
35
|
+
])
|
|
36
|
+
.optional(),
|
|
37
|
+
language: z
|
|
38
|
+
.enum([
|
|
39
|
+
"en",
|
|
40
|
+
"de",
|
|
41
|
+
"sl",
|
|
42
|
+
"it",
|
|
43
|
+
"fr",
|
|
44
|
+
"es",
|
|
45
|
+
"pt",
|
|
46
|
+
"nl",
|
|
47
|
+
"pl",
|
|
48
|
+
"hr",
|
|
49
|
+
"sv",
|
|
50
|
+
"fi",
|
|
51
|
+
"et",
|
|
52
|
+
"bg",
|
|
53
|
+
"cs",
|
|
54
|
+
"sk",
|
|
55
|
+
"nb",
|
|
56
|
+
"is",
|
|
57
|
+
])
|
|
58
|
+
.optional(),
|
|
59
|
+
})
|
|
14
60
|
.passthrough();
|
|
15
61
|
|
|
16
62
|
|
|
@@ -30,6 +76,50 @@ const PdfExportByDateRange = z
|
|
|
30
76
|
.min(1),
|
|
31
77
|
date_from: z.string().optional(),
|
|
32
78
|
date_to: z.string().optional(),
|
|
79
|
+
locale: z
|
|
80
|
+
.enum([
|
|
81
|
+
"en-US",
|
|
82
|
+
"de-DE",
|
|
83
|
+
"it-IT",
|
|
84
|
+
"fr-FR",
|
|
85
|
+
"es-ES",
|
|
86
|
+
"sl-SI",
|
|
87
|
+
"pt-PT",
|
|
88
|
+
"nl-NL",
|
|
89
|
+
"pl-PL",
|
|
90
|
+
"hr-HR",
|
|
91
|
+
"sv-SE",
|
|
92
|
+
"fi-FI",
|
|
93
|
+
"et-EE",
|
|
94
|
+
"bg-BG",
|
|
95
|
+
"cs-CZ",
|
|
96
|
+
"sk-SK",
|
|
97
|
+
"nb-NO",
|
|
98
|
+
"is-IS",
|
|
99
|
+
])
|
|
100
|
+
.optional(),
|
|
101
|
+
language: z
|
|
102
|
+
.enum([
|
|
103
|
+
"en",
|
|
104
|
+
"de",
|
|
105
|
+
"sl",
|
|
106
|
+
"it",
|
|
107
|
+
"fr",
|
|
108
|
+
"es",
|
|
109
|
+
"pt",
|
|
110
|
+
"nl",
|
|
111
|
+
"pl",
|
|
112
|
+
"hr",
|
|
113
|
+
"sv",
|
|
114
|
+
"fi",
|
|
115
|
+
"et",
|
|
116
|
+
"bg",
|
|
117
|
+
"cs",
|
|
118
|
+
"sk",
|
|
119
|
+
"nb",
|
|
120
|
+
"is",
|
|
121
|
+
])
|
|
122
|
+
.optional(),
|
|
33
123
|
})
|
|
34
124
|
.passthrough();
|
|
35
125
|
|
|
@@ -91,6 +91,11 @@ const createWebhookSchemaDefinition = z.object({
|
|
|
91
91
|
"delivery_note.voided",
|
|
92
92
|
"delivery_note.deleted",
|
|
93
93
|
"delivery_note.restored",
|
|
94
|
+
"e_invoicing.submission.created",
|
|
95
|
+
"e_invoicing.submission.delivered",
|
|
96
|
+
"e_invoicing.submission.failed",
|
|
97
|
+
"e_invoicing.supplier.onboarded",
|
|
98
|
+
"e_invoicing.supplier.rejected",
|
|
94
99
|
])
|
|
95
100
|
)
|
|
96
101
|
.min(1),
|
|
@@ -186,6 +191,11 @@ const updateWebhookSchemaDefinition = z
|
|
|
186
191
|
"delivery_note.voided",
|
|
187
192
|
"delivery_note.deleted",
|
|
188
193
|
"delivery_note.restored",
|
|
194
|
+
"e_invoicing.submission.created",
|
|
195
|
+
"e_invoicing.submission.delivered",
|
|
196
|
+
"e_invoicing.submission.failed",
|
|
197
|
+
"e_invoicing.supplier.onboarded",
|
|
198
|
+
"e_invoicing.supplier.rejected",
|
|
189
199
|
])
|
|
190
200
|
)
|
|
191
201
|
.min(1),
|
|
@@ -15,6 +15,13 @@ import { useQuery } from "@tanstack/react-query";
|
|
|
15
15
|
import { useEntities } from "@/ui/providers/entities-context";
|
|
16
16
|
import { useSDK } from "@/ui/providers/sdk-provider";
|
|
17
17
|
|
|
18
|
+
const DUPLICATE_TIMING_EVENT = "si:duplicate-timing";
|
|
19
|
+
|
|
20
|
+
function emitDuplicateDebug(detail: Record<string, unknown>) {
|
|
21
|
+
if (!import.meta.env.DEV || typeof window === "undefined") return;
|
|
22
|
+
window.dispatchEvent(new CustomEvent(DUPLICATE_TIMING_EVENT, { detail }));
|
|
23
|
+
}
|
|
24
|
+
|
|
18
25
|
export type DocumentType = "invoice" | "estimate" | "credit_note" | "advance_invoice" | "delivery_note";
|
|
19
26
|
type Document = Invoice | Estimate | CreditNote | AdvanceInvoice | DeliveryNote;
|
|
20
27
|
type CreateRequest =
|
|
@@ -127,9 +134,21 @@ function transformDocumentForDuplication(source: Document, targetType: DocumentT
|
|
|
127
134
|
// Number - leave empty for auto-generation
|
|
128
135
|
// Do NOT copy: number, totals, taxes, payments, furs, eslog, vies, shareable_id
|
|
129
136
|
// Link back to source document when converting (e.g., delivery note → invoice)
|
|
130
|
-
|
|
137
|
+
// Skip linking if source is a draft (drafts have no number/fiscalization)
|
|
138
|
+
...(isConversion && !(source as any).is_draft ? { linked_documents: [source.id] } : {}),
|
|
131
139
|
};
|
|
132
140
|
|
|
141
|
+
// Copy service dates when source is an invoice (available on invoices and credit notes)
|
|
142
|
+
if (sourceType === "invoice" || sourceType === "credit_note") {
|
|
143
|
+
const sourceDoc = source as any;
|
|
144
|
+
if (sourceDoc.date_service) {
|
|
145
|
+
(baseData as any).date_service = sourceDoc.date_service;
|
|
146
|
+
}
|
|
147
|
+
if (sourceDoc.date_service_to) {
|
|
148
|
+
(baseData as any).date_service_to = sourceDoc.date_service_to;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
133
152
|
return baseData;
|
|
134
153
|
}
|
|
135
154
|
|
|
@@ -192,6 +211,13 @@ export function useDuplicateDocument({
|
|
|
192
211
|
throw new Error("Source document ID and entity ID are required");
|
|
193
212
|
}
|
|
194
213
|
|
|
214
|
+
const startedAt = performance.now();
|
|
215
|
+
emitDuplicateDebug({
|
|
216
|
+
stage: "request_started",
|
|
217
|
+
sourceId,
|
|
218
|
+
sourceType,
|
|
219
|
+
targetType,
|
|
220
|
+
});
|
|
195
221
|
// Fetch source document based on its type
|
|
196
222
|
let source: Document;
|
|
197
223
|
if (sourceType === "invoice") {
|
|
@@ -215,22 +241,34 @@ export function useDuplicateDocument({
|
|
|
215
241
|
|
|
216
242
|
// Build source document summaries for conversions (different source → target type)
|
|
217
243
|
const isConversion = sourceType !== targetType;
|
|
218
|
-
const sourceDocuments: LinkedDocumentSummary[] =
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
244
|
+
const sourceDocuments: LinkedDocumentSummary[] =
|
|
245
|
+
isConversion && !(source as any).is_draft
|
|
246
|
+
? [
|
|
247
|
+
{
|
|
248
|
+
id: source.id,
|
|
249
|
+
type: sourceType,
|
|
250
|
+
number: (source as any).number || "",
|
|
251
|
+
date: (source as any).date || "",
|
|
252
|
+
total_with_tax: (source as any).total_with_tax ?? 0,
|
|
253
|
+
currency_code: (source as any).currency_code || "",
|
|
254
|
+
},
|
|
255
|
+
]
|
|
256
|
+
: [];
|
|
257
|
+
|
|
258
|
+
emitDuplicateDebug({
|
|
259
|
+
stage: "request_succeeded",
|
|
260
|
+
sourceId,
|
|
261
|
+
sourceType,
|
|
262
|
+
targetType,
|
|
263
|
+
elapsedMs: Number((performance.now() - startedAt).toFixed(1)),
|
|
264
|
+
});
|
|
230
265
|
|
|
231
266
|
return { initialValues, sourceDocuments };
|
|
232
267
|
},
|
|
233
268
|
enabled: enabled && !!sourceId && !!activeEntity?.id && !!sourceType,
|
|
269
|
+
retry: false,
|
|
270
|
+
refetchOnWindowFocus: false,
|
|
271
|
+
refetchOnReconnect: false,
|
|
234
272
|
});
|
|
235
273
|
|
|
236
274
|
return {
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared hook for eSLOG validation state.
|
|
3
|
+
*
|
|
4
|
+
* Encapsulates the eSLOG availability check, enabled toggle, and
|
|
5
|
+
* entity error tracking duplicated across invoice and advance invoice forms.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { useEffect, useState } from "react";
|
|
9
|
+
|
|
10
|
+
type EslogError = { field: string; message: string };
|
|
11
|
+
|
|
12
|
+
type Entity = {
|
|
13
|
+
country_code?: string;
|
|
14
|
+
settings?: Record<string, any>;
|
|
15
|
+
} | null;
|
|
16
|
+
|
|
17
|
+
export type EslogValidationResult = {
|
|
18
|
+
/** Whether eSLOG is available (SI entity + setting enabled) */
|
|
19
|
+
isAvailable: boolean;
|
|
20
|
+
/** Current enabled state (undefined until initialized) */
|
|
21
|
+
isEnabled: boolean | undefined;
|
|
22
|
+
/** Toggle eSLOG validation on/off */
|
|
23
|
+
setEnabled: (v: boolean) => void;
|
|
24
|
+
/** Entity-level errors that require settings updates */
|
|
25
|
+
entityErrors: EslogError[];
|
|
26
|
+
/** Update entity errors (e.g. from validation results) */
|
|
27
|
+
setEntityErrors: (errors: EslogError[]) => void;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export function useEslogValidation(activeEntity: Entity): EslogValidationResult {
|
|
31
|
+
const isSlovenianEntity = activeEntity?.country_code === "SI";
|
|
32
|
+
const entityEslogEnabled = !!(activeEntity?.settings as any)?.eslog_validation_enabled;
|
|
33
|
+
const isAvailable = isSlovenianEntity && entityEslogEnabled;
|
|
34
|
+
|
|
35
|
+
const [isEnabled, setEnabled] = useState<boolean | undefined>(undefined);
|
|
36
|
+
const [entityErrors, setEntityErrors] = useState<EslogError[]>([]);
|
|
37
|
+
|
|
38
|
+
// Auto-enable when available and not yet initialized
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
if (isAvailable && isEnabled === undefined) {
|
|
41
|
+
setEnabled(true);
|
|
42
|
+
}
|
|
43
|
+
}, [isAvailable, isEnabled]);
|
|
44
|
+
|
|
45
|
+
// Clear entity errors when disabled
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
if (!isEnabled) {
|
|
48
|
+
setEntityErrors([]);
|
|
49
|
+
}
|
|
50
|
+
}, [isEnabled]);
|
|
51
|
+
|
|
52
|
+
return {
|
|
53
|
+
isAvailable,
|
|
54
|
+
isEnabled,
|
|
55
|
+
setEnabled,
|
|
56
|
+
entityErrors,
|
|
57
|
+
setEntityErrors,
|
|
58
|
+
};
|
|
59
|
+
}
|