@spaceinvoices/react-ui 0.4.10 → 0.4.12
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/README.md +24 -8
- package/cli/dist/index.js +89 -26
- package/package.json +6 -2
- package/registry.json +30 -31
- package/spaceinvoices.schema.json +6 -1
- package/src/common/autocomplete.tsx +41 -25
- 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 +2 -3
- package/src/components/advance-invoices/create/create-advance-invoice-form.tsx +290 -69
- package/src/components/advance-invoices/create/locales/bg.ts +48 -0
- package/src/components/advance-invoices/create/locales/cs.ts +48 -0
- package/src/components/advance-invoices/create/locales/en.ts +48 -0
- package/src/components/advance-invoices/create/locales/et.ts +48 -0
- package/src/components/advance-invoices/create/locales/fi.ts +48 -0
- package/src/components/advance-invoices/create/locales/hr.ts +17 -17
- package/src/components/advance-invoices/create/locales/is.ts +48 -0
- package/src/components/advance-invoices/create/locales/nb.ts +48 -0
- package/src/components/advance-invoices/create/locales/sk.ts +48 -0
- package/src/components/advance-invoices/create/locales/sl.ts +9 -7
- package/src/components/advance-invoices/create/locales/sv.ts +48 -0
- package/src/components/advance-invoices/create/prepare-advance-invoice-submission.ts +16 -2
- package/src/components/advance-invoices/list/list-row-actions.tsx +48 -16
- package/src/components/advance-invoices/list/list-table.tsx +33 -8
- 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 +211 -22
- package/src/components/credit-notes/create/locales/bg.ts +87 -0
- package/src/components/credit-notes/create/locales/cs.ts +87 -0
- package/src/components/credit-notes/create/locales/en.ts +87 -0
- package/src/components/credit-notes/create/locales/et.ts +87 -0
- package/src/components/credit-notes/create/locales/fi.ts +87 -0
- package/src/components/credit-notes/create/locales/hr.ts +24 -24
- package/src/components/credit-notes/create/locales/is.ts +87 -0
- package/src/components/credit-notes/create/locales/nb.ts +87 -0
- package/src/components/credit-notes/create/locales/sk.ts +87 -0
- package/src/components/credit-notes/create/locales/sl.ts +9 -9
- package/src/components/credit-notes/create/locales/sv.ts +87 -0
- package/src/components/credit-notes/create/prepare-credit-note-submission.ts +32 -0
- package/src/components/credit-notes/credit-notes.hooks.ts +15 -3
- package/src/components/credit-notes/list/list-row-actions.tsx +19 -7
- package/src/components/credit-notes/list/list-table.tsx +58 -7
- 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 +61 -31
- package/src/components/delivery-notes/create/locales/bg.ts +68 -0
- package/src/components/delivery-notes/create/locales/cs.ts +68 -0
- package/src/components/delivery-notes/create/locales/en.ts +68 -0
- package/src/components/delivery-notes/create/locales/et.ts +68 -0
- package/src/components/delivery-notes/create/locales/fi.ts +68 -0
- package/src/components/delivery-notes/create/locales/hr.ts +6 -6
- package/src/components/delivery-notes/create/locales/is.ts +68 -0
- package/src/components/delivery-notes/create/locales/nb.ts +68 -0
- package/src/components/delivery-notes/create/locales/sk.ts +68 -0
- package/src/components/delivery-notes/create/locales/sl.ts +5 -5
- package/src/components/delivery-notes/create/locales/sv.ts +68 -0
- package/src/components/delivery-notes/delivery-notes.hooks.ts +20 -3
- package/src/components/delivery-notes/list/list-row-actions.tsx +62 -16
- package/src/components/delivery-notes/list/list-table.tsx +42 -9
- 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/document-add-item-form.tsx +256 -147
- package/src/components/documents/create/document-add-item-tax-rate-field.tsx +2 -1
- package/src/components/documents/create/document-details-section.tsx +30 -12
- package/src/components/documents/create/document-item-validation.ts +50 -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/linked-documents-info.tsx +4 -3
- package/src/components/documents/create/live-preview.tsx +19 -15
- package/src/components/documents/create/mark-as-paid-section.tsx +77 -20
- package/src/components/documents/create/payment-rows.ts +291 -0
- package/src/components/documents/create/prepare-document-submission.ts +24 -13
- 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 +343 -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 +241 -62
- package/src/components/documents/view/document-activities-list.tsx +23 -11
- package/src/components/documents/view/document-details-card.tsx +7 -27
- 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 +13 -0
- 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 +13 -0
- 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 +131 -75
- package/src/components/entities/entity-settings-form/input-with-preview.tsx +28 -4
- package/src/components/entities/entity-settings-form/locales/bg.ts +199 -0
- package/src/components/entities/entity-settings-form/locales/cs.ts +199 -0
- package/src/components/entities/entity-settings-form/locales/de.ts +18 -3
- package/src/components/entities/entity-settings-form/locales/en.ts +199 -0
- package/src/components/entities/entity-settings-form/locales/es.ts +18 -3
- package/src/components/entities/entity-settings-form/locales/et.ts +198 -0
- package/src/components/entities/entity-settings-form/locales/fi.ts +199 -0
- package/src/components/entities/entity-settings-form/locales/fr.ts +18 -3
- package/src/components/entities/entity-settings-form/locales/hr.ts +26 -11
- package/src/components/entities/entity-settings-form/locales/is.ts +199 -0
- package/src/components/entities/entity-settings-form/locales/it.ts +18 -3
- package/src/components/entities/entity-settings-form/locales/nb.ts +199 -0
- package/src/components/entities/entity-settings-form/locales/nl.ts +18 -3
- package/src/components/entities/entity-settings-form/locales/pl.ts +18 -3
- package/src/components/entities/entity-settings-form/locales/pt.ts +18 -3
- package/src/components/entities/entity-settings-form/locales/sk.ts +199 -0
- package/src/components/entities/entity-settings-form/locales/sl.ts +30 -15
- package/src/components/entities/entity-settings-form/locales/sv.ts +205 -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 +112 -9
- 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 +21 -6
- package/src/components/estimates/create/create-estimate-form.tsx +70 -34
- package/src/components/estimates/create/locales/bg.ts +76 -0
- package/src/components/estimates/create/locales/cs.ts +76 -0
- package/src/components/estimates/create/locales/en.ts +76 -0
- package/src/components/estimates/create/locales/et.ts +76 -0
- package/src/components/estimates/create/locales/fi.ts +76 -0
- package/src/components/estimates/create/locales/hr.ts +8 -8
- package/src/components/estimates/create/locales/is.ts +76 -0
- package/src/components/estimates/create/locales/nb.ts +76 -0
- package/src/components/estimates/create/locales/sk.ts +76 -0
- package/src/components/estimates/create/locales/sl.ts +8 -8
- package/src/components/estimates/create/locales/sv.ts +76 -0
- package/src/components/estimates/create/prepare-estimate-submission.ts +4 -1
- package/src/components/estimates/estimates.hooks.ts +15 -3
- package/src/components/estimates/list/list-row-actions.tsx +34 -7
- package/src/components/estimates/list/list-table.tsx +78 -10
- package/src/components/estimates/list/locales/bg.ts +38 -0
- package/src/components/estimates/list/locales/cs.ts +38 -0
- package/src/components/estimates/list/locales/en.ts +27 -2
- package/src/components/estimates/list/locales/et.ts +38 -0
- package/src/components/estimates/list/locales/fi.ts +38 -0
- package/src/components/estimates/list/locales/hr.ts +2 -2
- package/src/components/estimates/list/locales/is.ts +38 -0
- package/src/components/estimates/list/locales/nb.ts +38 -0
- package/src/components/estimates/list/locales/sk.ts +38 -0
- package/src/components/estimates/list/locales/sv.ts +38 -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 +294 -76
- package/src/components/invoices/create/eslog-validation.ts +97 -8
- package/src/components/invoices/create/locales/bg.ts +164 -0
- package/src/components/invoices/create/locales/cs.ts +164 -0
- package/src/components/invoices/create/locales/de.ts +24 -0
- package/src/components/invoices/create/locales/en.ts +164 -0
- package/src/components/invoices/create/locales/es.ts +24 -0
- package/src/components/invoices/create/locales/et.ts +164 -0
- package/src/components/invoices/create/locales/fi.ts +164 -0
- package/src/components/invoices/create/locales/fr.ts +23 -0
- package/src/components/invoices/create/locales/hr.ts +32 -9
- package/src/components/invoices/create/locales/is.ts +164 -0
- package/src/components/invoices/create/locales/it.ts +24 -0
- package/src/components/invoices/create/locales/nb.ts +164 -0
- package/src/components/invoices/create/locales/nl.ts +23 -0
- package/src/components/invoices/create/locales/pl.ts +23 -0
- package/src/components/invoices/create/locales/pt.ts +24 -0
- package/src/components/invoices/create/locales/sk.ts +164 -0
- package/src/components/invoices/create/locales/sl.ts +32 -9
- package/src/components/invoices/create/locales/sv.ts +166 -0
- package/src/components/invoices/create/prepare-invoice-submission.ts +19 -2
- package/src/components/invoices/invoices-furs.hooks.ts +11 -8
- package/src/components/invoices/invoices.hooks.ts +27 -10
- package/src/components/invoices/list/list-row-actions.tsx +54 -21
- package/src/components/invoices/list/list-table.tsx +92 -11
- 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 +58 -0
- package/src/components/invoices/send-email-dialog/locales/cs.ts +58 -0
- package/src/components/invoices/send-email-dialog/locales/de.ts +39 -0
- package/src/components/invoices/send-email-dialog/locales/en.ts +58 -0
- package/src/components/invoices/send-email-dialog/locales/es.ts +39 -0
- package/src/components/invoices/send-email-dialog/locales/et.ts +58 -0
- package/src/components/invoices/send-email-dialog/locales/fi.ts +58 -0
- package/src/components/invoices/send-email-dialog/locales/fr.ts +39 -0
- package/src/components/invoices/send-email-dialog/locales/hr.ts +39 -0
- package/src/components/invoices/send-email-dialog/locales/is.ts +58 -0
- package/src/components/invoices/send-email-dialog/locales/it.ts +39 -0
- package/src/components/invoices/send-email-dialog/locales/nb.ts +58 -0
- package/src/components/invoices/send-email-dialog/locales/nl.ts +39 -0
- package/src/components/invoices/send-email-dialog/locales/pl.ts +39 -0
- package/src/components/invoices/send-email-dialog/locales/pt.ts +39 -0
- package/src/components/invoices/send-email-dialog/locales/sk.ts +58 -0
- package/src/components/invoices/send-email-dialog/locales/sl.ts +39 -0
- package/src/components/invoices/send-email-dialog/locales/sv.ts +58 -0
- package/src/components/invoices/send-email-dialog/send-email-dialog.tsx +188 -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 +51 -18
- 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 +11 -7
- package/src/components/payments/create-payment-form/index.ts +1 -0
- 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 +5 -1
- 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 +23 -17
- 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 +3 -5
- package/src/components/recurring-invoices/list/list-table.tsx +10 -7
- package/src/components/recurring-invoices/list/locales/bg.ts +28 -0
- package/src/components/recurring-invoices/list/locales/cs.ts +28 -0
- package/src/components/recurring-invoices/list/locales/en.ts +23 -0
- package/src/components/recurring-invoices/list/locales/et.ts +28 -0
- package/src/components/recurring-invoices/list/locales/fi.ts +28 -0
- package/src/components/recurring-invoices/list/locales/is.ts +28 -0
- package/src/components/recurring-invoices/list/locales/nb.ts +28 -0
- package/src/components/recurring-invoices/list/locales/sk.ts +28 -0
- package/src/components/recurring-invoices/list/locales/sv.ts +28 -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 +21 -10
- package/src/components/tax-reports/slovenia-vod-export-form.tsx +452 -0
- package/src/components/tax-reports/slovenia-yearly-export-form.tsx +17 -16
- package/src/components/tax-reports/slovenia-yearly-review-step.tsx +40 -18
- 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 -2
- package/src/components/ui/progress.tsx +6 -4
- package/src/components/ui/select.tsx +118 -1
- package/src/components/ui/sidebar.tsx +3 -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 +17 -7
- package/src/generated/schemas/account_webhook.ts +43 -0
- package/src/generated/schemas/accountwebhook.ts +67 -0
- package/src/generated/schemas/entity.ts +343 -4
- package/src/generated/schemas/exportsloveniavodxml_body.ts +16 -0
- package/src/generated/schemas/exportsloveniayearlynormiranireport_body.ts +27 -0
- package/src/generated/schemas/furssettings.ts +1 -0
- package/src/generated/schemas/incomingpurchasedocument.ts +198 -0
- package/src/generated/schemas/incomingpurchasedocumentpayment.ts +38 -0
- package/src/generated/schemas/index.ts +12 -0
- package/src/generated/schemas/item.ts +36 -0
- package/src/generated/schemas/me.ts +23 -19
- package/src/generated/schemas/order.ts +2 -0
- package/src/generated/schemas/orderintegration.ts +8 -4
- package/src/generated/schemas/payment.ts +5 -0
- package/src/generated/schemas/ptatcudseries.ts +30 -0
- package/src/generated/schemas/renderadvanceinvoicepreview_body.ts +35 -3
- package/src/generated/schemas/rendercreditnotepreview_body.ts +35 -3
- package/src/generated/schemas/renderdeliverynotepreview_body.ts +12 -5
- package/src/generated/schemas/renderestimatepreview_body.ts +38 -5
- package/src/generated/schemas/renderinvoicepreview_body.ts +39 -5
- package/src/generated/schemas/senddocument_body.ts +1 -0
- package/src/generated/schemas/sendemail_body.ts +67 -39
- package/src/generated/schemas/sloveniataxprofile.ts +118 -0
- package/src/generated/schemas/starteslogexport_body.ts +33 -0
- package/src/generated/schemas/startpdfexport_body.ts +94 -78
- package/src/generated/schemas/supplier.ts +59 -0
- package/src/generated/schemas/syncshopifyorders_body.ts +20 -0
- package/src/generated/schemas/tax.ts +2 -0
- package/src/generated/schemas/uploadfile_body.ts +1 -0
- package/src/generated/schemas/userptsettings.ts +26 -0
- package/src/generated/schemas/voidinvoice_body.ts +20 -0
- package/src/generated/schemas/webhook.ts +2 -0
- package/src/hooks/create-resource-hooks.ts +22 -19
- package/src/hooks/use-duplicate-document.ts +10 -8
- 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/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 +95 -0
- package/src/lib/pt-document-input.ts +67 -0
- package/src/lib/schemas/shared.ts +1 -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 +144 -10
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
import type { PriceModesMap } from "./document-items-section";
|
|
2
|
+
|
|
3
|
+
export const REGULAR_PAYMENT_TYPES = ["cash", "bank_transfer", "card", "check", "other"] as const;
|
|
4
|
+
|
|
5
|
+
export type RegularPaymentType = (typeof REGULAR_PAYMENT_TYPES)[number];
|
|
6
|
+
|
|
7
|
+
export type DraftPaymentRow = {
|
|
8
|
+
id?: string;
|
|
9
|
+
type: RegularPaymentType | null;
|
|
10
|
+
amount: string;
|
|
11
|
+
amountTouched: boolean;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export type SerializedPaymentRow = {
|
|
15
|
+
type: RegularPaymentType;
|
|
16
|
+
amount: number;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export type PaymentRowsEvaluation = {
|
|
20
|
+
payments: SerializedPaymentRow[];
|
|
21
|
+
totalAmount: number;
|
|
22
|
+
hasTypeError: boolean;
|
|
23
|
+
hasAmountError: boolean;
|
|
24
|
+
exceedsTotal: boolean;
|
|
25
|
+
requiresFullAmount: boolean;
|
|
26
|
+
totalMatchesExactly: boolean;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export type PaymentRowsValidationMode = "partial_allowed" | "full_required";
|
|
30
|
+
|
|
31
|
+
export type PaymentRowsValidation = {
|
|
32
|
+
typeError?: string;
|
|
33
|
+
amountError?: string;
|
|
34
|
+
totalError?: string;
|
|
35
|
+
payments: SerializedPaymentRow[];
|
|
36
|
+
totalAmount: number;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export function getPaymentValidationMessage(
|
|
40
|
+
evaluation: PaymentRowsEvaluation,
|
|
41
|
+
options?: { requireFullAmount?: boolean },
|
|
42
|
+
): string | undefined {
|
|
43
|
+
if (evaluation.hasTypeError) {
|
|
44
|
+
return "Please select a payment type";
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (evaluation.exceedsTotal) {
|
|
48
|
+
return "Payment amounts cannot exceed the document total";
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (options?.requireFullAmount && !evaluation.totalMatchesExactly) {
|
|
52
|
+
return "Advance invoices must be fully paid";
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (evaluation.hasAmountError) {
|
|
56
|
+
return "Payment amount must be greater than 0";
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function getFirstValidPaymentType(paymentRows: DraftPaymentRow[]): RegularPaymentType | undefined {
|
|
63
|
+
return paymentRows.find((row) => isValidPaymentTypeSelection(row.type))?.type ?? undefined;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function createEmptyPaymentRow(): DraftPaymentRow {
|
|
67
|
+
return { id: crypto.randomUUID(), type: null, amount: "", amountTouched: false };
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function coercePaymentRowsToType(paymentRows: DraftPaymentRow[], type: RegularPaymentType): DraftPaymentRow[] {
|
|
71
|
+
if (paymentRows.length === 0) {
|
|
72
|
+
return [{ ...createEmptyPaymentRow(), type }];
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return paymentRows.map((row) => ({
|
|
76
|
+
...row,
|
|
77
|
+
type,
|
|
78
|
+
}));
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export function isValidPaymentTypeSelection(value: string | null | undefined): value is RegularPaymentType {
|
|
82
|
+
return REGULAR_PAYMENT_TYPES.includes(value as RegularPaymentType);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export function roundCurrency(amount: number): number {
|
|
86
|
+
return Math.round((amount + Number.EPSILON) * 100) / 100;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export function formatAmountInput(amount: number | null): string {
|
|
90
|
+
if (amount == null || !Number.isFinite(amount)) return "";
|
|
91
|
+
return amount.toFixed(2);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export function parsePaymentAmount(value: string): number | null {
|
|
95
|
+
const trimmed = value.trim();
|
|
96
|
+
if (!trimmed) return null;
|
|
97
|
+
|
|
98
|
+
const normalized = trimmed.replace(",", ".");
|
|
99
|
+
const parsed = Number(normalized);
|
|
100
|
+
if (!Number.isFinite(parsed)) return null;
|
|
101
|
+
|
|
102
|
+
return roundCurrency(parsed);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export function calculateDocumentTotal(items: any[] | undefined, priceModes: PriceModesMap = {}): number {
|
|
106
|
+
if (!items?.length) return 0;
|
|
107
|
+
|
|
108
|
+
const total = items.reduce((sum, item, index) => {
|
|
109
|
+
if (!item || item.type === "separator") return sum;
|
|
110
|
+
|
|
111
|
+
const quantity = Number(item.quantity ?? 0);
|
|
112
|
+
const price = Number(item.price ?? 0);
|
|
113
|
+
if (!Number.isFinite(quantity) || !Number.isFinite(price) || quantity <= 0 || price <= 0) {
|
|
114
|
+
return sum;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const lineBase = quantity * price;
|
|
118
|
+
const isGrossPrice = priceModes[index] ?? false;
|
|
119
|
+
const taxMultiplier =
|
|
120
|
+
1 +
|
|
121
|
+
(Array.isArray(item.taxes)
|
|
122
|
+
? item.taxes.reduce((taxSum: number, tax: any) => taxSum + Number(tax?.rate ?? 0), 0) / 100
|
|
123
|
+
: 0);
|
|
124
|
+
|
|
125
|
+
return sum + (isGrossPrice ? lineBase : lineBase * taxMultiplier);
|
|
126
|
+
}, 0);
|
|
127
|
+
|
|
128
|
+
return roundCurrency(total);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export function derivePaymentAmounts(paymentRows: DraftPaymentRow[], documentTotal: number): Array<number | null> {
|
|
132
|
+
const resolved = Array<number | null>(paymentRows.length).fill(null);
|
|
133
|
+
const untouchedIndexes: number[] = [];
|
|
134
|
+
let touchedTotal = 0;
|
|
135
|
+
|
|
136
|
+
paymentRows.forEach((row, index) => {
|
|
137
|
+
if (!row.amountTouched) {
|
|
138
|
+
untouchedIndexes.push(index);
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const parsed = parsePaymentAmount(row.amount);
|
|
143
|
+
resolved[index] = parsed;
|
|
144
|
+
if (parsed != null) {
|
|
145
|
+
touchedTotal += parsed;
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
const roundedTotal = roundCurrency(documentTotal);
|
|
150
|
+
const remaining = roundCurrency(roundedTotal - touchedTotal);
|
|
151
|
+
|
|
152
|
+
if (untouchedIndexes.length === 0) {
|
|
153
|
+
return resolved;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (remaining <= 0) {
|
|
157
|
+
untouchedIndexes.forEach((index) => {
|
|
158
|
+
resolved[index] = 0;
|
|
159
|
+
});
|
|
160
|
+
return resolved;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
const equalShare = roundCurrency(remaining / untouchedIndexes.length);
|
|
164
|
+
let allocated = 0;
|
|
165
|
+
|
|
166
|
+
untouchedIndexes.forEach((index, arrayIndex) => {
|
|
167
|
+
if (arrayIndex === untouchedIndexes.length - 1) {
|
|
168
|
+
resolved[index] = roundCurrency(remaining - allocated);
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
resolved[index] = equalShare;
|
|
173
|
+
allocated = roundCurrency(allocated + equalShare);
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
return resolved;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export const derivePaymentRowAmounts = derivePaymentAmounts;
|
|
180
|
+
|
|
181
|
+
export function getDisplayPaymentAmount(row: DraftPaymentRow, derivedAmount: number | null): string {
|
|
182
|
+
return row.amountTouched ? row.amount : formatAmountInput(derivedAmount);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export function getRecordedPaymentTotal(paymentRows: DraftPaymentRow[], documentTotal: number): number {
|
|
186
|
+
const resolvedAmounts = derivePaymentAmounts(paymentRows, documentTotal);
|
|
187
|
+
return roundCurrency(
|
|
188
|
+
resolvedAmounts.reduce<number>((sum, amount) => sum + (amount != null && amount > 0 ? amount : 0), 0),
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export function evaluatePaymentRows(
|
|
193
|
+
paymentRows: DraftPaymentRow[],
|
|
194
|
+
documentTotal: number,
|
|
195
|
+
options?: { requireFullAmount?: boolean },
|
|
196
|
+
): PaymentRowsEvaluation {
|
|
197
|
+
const resolvedAmounts = derivePaymentAmounts(paymentRows, documentTotal);
|
|
198
|
+
const payments: SerializedPaymentRow[] = [];
|
|
199
|
+
let hasTypeError = false;
|
|
200
|
+
let hasAmountError = false;
|
|
201
|
+
|
|
202
|
+
paymentRows.forEach((row, index) => {
|
|
203
|
+
if (!isValidPaymentTypeSelection(row.type)) {
|
|
204
|
+
hasTypeError = true;
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
const amount = resolvedAmounts[index];
|
|
209
|
+
if (amount == null || amount <= 0) {
|
|
210
|
+
hasAmountError = true;
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
payments.push({ type: row.type, amount });
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
const totalAmount = roundCurrency(payments.reduce((sum, payment) => sum + payment.amount, 0));
|
|
218
|
+
const roundedTotal = roundCurrency(documentTotal);
|
|
219
|
+
const exceedsTotal = totalAmount > roundedTotal;
|
|
220
|
+
const requireFullAmount = options?.requireFullAmount === true;
|
|
221
|
+
const totalMatchesExactly = totalAmount === roundedTotal;
|
|
222
|
+
|
|
223
|
+
if (exceedsTotal) {
|
|
224
|
+
hasAmountError = true;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
if (requireFullAmount && !totalMatchesExactly) {
|
|
228
|
+
hasAmountError = true;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
return {
|
|
232
|
+
payments,
|
|
233
|
+
totalAmount,
|
|
234
|
+
hasTypeError,
|
|
235
|
+
hasAmountError,
|
|
236
|
+
exceedsTotal,
|
|
237
|
+
requiresFullAmount: requireFullAmount,
|
|
238
|
+
totalMatchesExactly,
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
export function validatePaymentRows(
|
|
243
|
+
paymentRows: DraftPaymentRow[],
|
|
244
|
+
documentTotal: number,
|
|
245
|
+
mode: PaymentRowsValidationMode,
|
|
246
|
+
): PaymentRowsValidation {
|
|
247
|
+
const evaluation = evaluatePaymentRows(paymentRows, documentTotal, {
|
|
248
|
+
requireFullAmount: mode === "full_required",
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
if (evaluation.hasTypeError) {
|
|
252
|
+
return {
|
|
253
|
+
payments: evaluation.payments,
|
|
254
|
+
totalAmount: evaluation.totalAmount,
|
|
255
|
+
typeError: "Please select a payment type",
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
if (evaluation.exceedsTotal) {
|
|
260
|
+
return {
|
|
261
|
+
payments: evaluation.payments,
|
|
262
|
+
totalAmount: evaluation.totalAmount,
|
|
263
|
+
totalError: "Payment amounts cannot exceed the document total",
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
if (mode === "full_required" && !evaluation.totalMatchesExactly) {
|
|
268
|
+
return {
|
|
269
|
+
payments: evaluation.payments,
|
|
270
|
+
totalAmount: evaluation.totalAmount,
|
|
271
|
+
totalError: "Advance invoices must be fully paid",
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
if (evaluation.hasAmountError) {
|
|
276
|
+
return {
|
|
277
|
+
payments: evaluation.payments,
|
|
278
|
+
totalAmount: evaluation.totalAmount,
|
|
279
|
+
amountError: "Payment amount must be greater than 0",
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
return {
|
|
284
|
+
payments: evaluation.payments,
|
|
285
|
+
totalAmount: evaluation.totalAmount,
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
export function serializePaymentRows(paymentRows: DraftPaymentRow[], documentTotal: number): SerializedPaymentRow[] {
|
|
290
|
+
return evaluatePaymentRows(paymentRows, documentTotal).payments;
|
|
291
|
+
}
|
|
@@ -33,6 +33,8 @@ type PrepareDocumentOptions = {
|
|
|
33
33
|
markAsPaid?: boolean;
|
|
34
34
|
/** For invoices/credit notes: payment types when markAsPaid is true */
|
|
35
35
|
paymentTypes?: string[];
|
|
36
|
+
/** Structured payments when amounts were already normalized by the form layer */
|
|
37
|
+
payments?: Array<{ type: string; amount?: number }>;
|
|
36
38
|
/** Document type for specific date handling */
|
|
37
39
|
documentType: "invoice" | "estimate" | "credit_note" | "advance_invoice" | "delivery_note";
|
|
38
40
|
/** Secondary date field value (date_due for invoices, date_valid_till for estimates) */
|
|
@@ -157,8 +159,12 @@ export function prepareDocumentSubmission<T extends BaseDocumentValues>(
|
|
|
157
159
|
taxes: item.taxes
|
|
158
160
|
?.map((tax: any) => {
|
|
159
161
|
if (tax.tax_id) {
|
|
160
|
-
//
|
|
161
|
-
return {
|
|
162
|
+
// Preserve PT exemption metadata while still allowing the API to resolve the tax rate by tax_id.
|
|
163
|
+
return {
|
|
164
|
+
tax_id: tax.tax_id,
|
|
165
|
+
...(tax.pt_exemption_code ? { pt_exemption_code: tax.pt_exemption_code } : {}),
|
|
166
|
+
...(tax.pt_exemption_reason ? { pt_exemption_reason: tax.pt_exemption_reason } : {}),
|
|
167
|
+
};
|
|
162
168
|
}
|
|
163
169
|
return tax;
|
|
164
170
|
})
|
|
@@ -170,7 +176,7 @@ export function prepareDocumentSubmission<T extends BaseDocumentValues>(
|
|
|
170
176
|
|
|
171
177
|
// Build payload with date conversions
|
|
172
178
|
// Destructure to exclude fields we handle explicitly (number is always server-generated)
|
|
173
|
-
const { number: _number, note, payment_terms, reference, signature, ...restValues } = nextValues as any;
|
|
179
|
+
const { number: _number, note, payment_terms, reference, signature, pt: _pt, ...restValues } = nextValues as any;
|
|
174
180
|
const payload: any = {
|
|
175
181
|
...restValues,
|
|
176
182
|
...(note?.trim() && { note: note.trim() }),
|
|
@@ -201,16 +207,21 @@ export function prepareDocumentSubmission<T extends BaseDocumentValues>(
|
|
|
201
207
|
}
|
|
202
208
|
|
|
203
209
|
// Handle markAsPaid for invoices and credit notes
|
|
204
|
-
if (
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
210
|
+
if (options.documentType !== "estimate" && options.markAsPaid) {
|
|
211
|
+
const serializedPayments =
|
|
212
|
+
options.payments?.map((payment) => ({
|
|
213
|
+
...payment,
|
|
214
|
+
date: payload.date ?? undefined,
|
|
215
|
+
})) ??
|
|
216
|
+
options.paymentTypes?.map((type: string) => ({
|
|
217
|
+
type,
|
|
218
|
+
date: payload.date ?? undefined,
|
|
219
|
+
})) ??
|
|
220
|
+
[];
|
|
221
|
+
|
|
222
|
+
if (serializedPayments.length > 0) {
|
|
223
|
+
payload.payments = serializedPayments;
|
|
224
|
+
}
|
|
214
225
|
}
|
|
215
226
|
|
|
216
227
|
// Remove UI-only fields from payload
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export function scrollToFirstInvalidField(formId: string) {
|
|
2
|
+
if (typeof document === "undefined") {
|
|
3
|
+
return;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
const form = document.getElementById(formId);
|
|
7
|
+
if (!form) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const scrollToInvalidField = () => {
|
|
12
|
+
const errorTarget = form.querySelector<HTMLElement>('[data-form-error-summary="true"], [aria-invalid="true"]');
|
|
13
|
+
if (!errorTarget) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
errorTarget.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
18
|
+
|
|
19
|
+
if (errorTarget.matches('[aria-invalid="true"]') && typeof errorTarget.focus === "function") {
|
|
20
|
+
errorTarget.focus({ preventScroll: true });
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
requestAnimationFrame(() => {
|
|
25
|
+
requestAnimationFrame(scrollToInvalidField);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
@@ -15,56 +15,7 @@ import {
|
|
|
15
15
|
DropdownMenuTrigger,
|
|
16
16
|
} from "@/ui/components/ui/dropdown-menu";
|
|
17
17
|
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/ui/components/ui/tooltip";
|
|
18
|
-
|
|
19
|
-
const TEMPLATE_VARIABLES = [
|
|
20
|
-
{
|
|
21
|
-
category: "Entity",
|
|
22
|
-
variables: [
|
|
23
|
-
{ code: "{entity_name}", label: "Company name" },
|
|
24
|
-
{ code: "{entity_email}", label: "Email address" },
|
|
25
|
-
{ code: "{entity_address}", label: "Address" },
|
|
26
|
-
{ code: "{entity_post_code}", label: "Post code" },
|
|
27
|
-
{ code: "{entity_city}", label: "City" },
|
|
28
|
-
{ code: "{entity_country}", label: "Country" },
|
|
29
|
-
{ code: "{entity_tax_number}", label: "Tax number" },
|
|
30
|
-
{ code: "{entity_company_number}", label: "Company number" },
|
|
31
|
-
],
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
category: "Document",
|
|
35
|
-
variables: [
|
|
36
|
-
{ code: "{document_number}", label: "Invoice number" },
|
|
37
|
-
{ code: "{document_date}", label: "Invoice date" },
|
|
38
|
-
{ code: "{document_due_date}", label: "Due date" },
|
|
39
|
-
{ code: "{document_total}", label: "Total amount" },
|
|
40
|
-
{ code: "{document_currency}", label: "Currency" },
|
|
41
|
-
],
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
category: "Customer",
|
|
45
|
-
variables: [
|
|
46
|
-
{ code: "{customer_name}", label: "Customer name" },
|
|
47
|
-
{ code: "{customer_email}", label: "Customer email" },
|
|
48
|
-
],
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
category: "Bank Account",
|
|
52
|
-
variables: [
|
|
53
|
-
{ code: "{bank_account}", label: "Full account info" },
|
|
54
|
-
{ code: "{bank_account.iban}", label: "IBAN" },
|
|
55
|
-
{ code: "{bank_account.bank_name}", label: "Bank name" },
|
|
56
|
-
{ code: "{bank_account.bic}", label: "BIC/SWIFT" },
|
|
57
|
-
{ code: "{bank_account.account_number}", label: "Account number" },
|
|
58
|
-
],
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
category: "Other",
|
|
62
|
-
variables: [
|
|
63
|
-
{ code: "{current_date}", label: "Today's date" },
|
|
64
|
-
{ code: "{current_year}", label: "Current year" },
|
|
65
|
-
],
|
|
66
|
-
},
|
|
67
|
-
];
|
|
18
|
+
import { getTemplateVariableGroups } from "@/ui/lib/template-variables";
|
|
68
19
|
|
|
69
20
|
interface SmartCodeInsertButtonProps {
|
|
70
21
|
/** Reference to the textarea element */
|
|
@@ -80,6 +31,7 @@ interface SmartCodeInsertButtonProps {
|
|
|
80
31
|
export function SmartCodeInsertButton({ textareaRef, onInsert, value, t }: SmartCodeInsertButtonProps) {
|
|
81
32
|
// Store cursor position for when textarea loses focus before dropdown opens
|
|
82
33
|
const cursorPositionRef = useRef<number>(0);
|
|
34
|
+
const templateVariables = getTemplateVariableGroups(t);
|
|
83
35
|
|
|
84
36
|
const insertVariable = useCallback(
|
|
85
37
|
(code: string) => {
|
|
@@ -121,10 +73,10 @@ export function SmartCodeInsertButton({ textareaRef, onInsert, value, t }: Smart
|
|
|
121
73
|
</Tooltip>
|
|
122
74
|
</TooltipProvider>
|
|
123
75
|
<DropdownMenuContent align="end" className="w-72">
|
|
124
|
-
{
|
|
76
|
+
{templateVariables.map((group, groupIndex) => (
|
|
125
77
|
<div key={group.category}>
|
|
126
78
|
{groupIndex > 0 && <DropdownMenuSeparator />}
|
|
127
|
-
<DropdownMenuLabel className="text-muted-foreground text-xs">{
|
|
79
|
+
<DropdownMenuLabel className="text-muted-foreground text-xs">{group.category}</DropdownMenuLabel>
|
|
128
80
|
<DropdownMenuGroup>
|
|
129
81
|
{group.variables.map((variable) => (
|
|
130
82
|
<DropdownMenuItem
|
|
@@ -133,7 +85,7 @@ export function SmartCodeInsertButton({ textareaRef, onInsert, value, t }: Smart
|
|
|
133
85
|
className="flex cursor-pointer items-center whitespace-nowrap"
|
|
134
86
|
>
|
|
135
87
|
<code className="mr-2 shrink-0 rounded bg-muted px-1 py-0.5 font-mono text-xs">{variable.code}</code>
|
|
136
|
-
<span className="text-muted-foreground text-xs">{
|
|
88
|
+
<span className="text-muted-foreground text-xs">{variable.label}</span>
|
|
137
89
|
</DropdownMenuItem>
|
|
138
90
|
))}
|
|
139
91
|
</DropdownMenuGroup>
|
|
@@ -26,17 +26,6 @@ export type DocumentFormWithCustomer = FieldValues & {
|
|
|
26
26
|
customer?: CustomerData | null;
|
|
27
27
|
};
|
|
28
28
|
|
|
29
|
-
/**
|
|
30
|
-
* Type-safe setValue wrapper for document forms.
|
|
31
|
-
*/
|
|
32
|
-
function _setFormValue<TForm extends FieldValues>(
|
|
33
|
-
form: UseFormReturn<TForm>,
|
|
34
|
-
name: Path<TForm>,
|
|
35
|
-
value: PathValue<TForm, Path<TForm>>,
|
|
36
|
-
) {
|
|
37
|
-
form.setValue(name, value);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
29
|
/**
|
|
41
30
|
* Shared hook for managing customer selection and form state in document forms.
|
|
42
31
|
* Used by invoices, estimates, credit notes, and advance invoices.
|
|
@@ -85,6 +74,20 @@ export function useDocumentCustomerForm<TForm extends DocumentFormWithCustomer>(
|
|
|
85
74
|
|
|
86
75
|
const handleCustomerSelect = (customerId: string, customer: CustomerData) => {
|
|
87
76
|
const isNewCustomer = !customerId || customerId === "";
|
|
77
|
+
const customerFieldPaths = [
|
|
78
|
+
"customer.name",
|
|
79
|
+
"customer.address",
|
|
80
|
+
"customer.address_2",
|
|
81
|
+
"customer.post_code",
|
|
82
|
+
"customer.city",
|
|
83
|
+
"customer.state",
|
|
84
|
+
"customer.country",
|
|
85
|
+
"customer.tax_number",
|
|
86
|
+
"customer.is_end_consumer",
|
|
87
|
+
] as Path<TForm>[];
|
|
88
|
+
const setCustomerFieldValue = <K extends Path<TForm>>(name: K, value: PathValue<TForm, K>) => {
|
|
89
|
+
form.setValue(name, value, { shouldDirty: true, shouldTouch: true, shouldValidate: true });
|
|
90
|
+
};
|
|
88
91
|
|
|
89
92
|
// Helper to convert empty/null to undefined for optional fields,
|
|
90
93
|
// but keep empty string for required fields (name) so form shows them
|
|
@@ -98,19 +101,41 @@ export function useDocumentCustomerForm<TForm extends DocumentFormWithCustomer>(
|
|
|
98
101
|
if (isNewCustomer) {
|
|
99
102
|
// New customer - clear customer_id and set customer data
|
|
100
103
|
setValue("customer_id" as Path<TForm>, undefined as PathValue<TForm, Path<TForm>>);
|
|
101
|
-
|
|
102
|
-
"customer" as Path<TForm>,
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
104
|
+
setCustomerFieldValue(
|
|
105
|
+
"customer.name" as Path<TForm>,
|
|
106
|
+
toFormValue(customer.name, true) as PathValue<TForm, Path<TForm>>,
|
|
107
|
+
);
|
|
108
|
+
setCustomerFieldValue(
|
|
109
|
+
"customer.address" as Path<TForm>,
|
|
110
|
+
toFormValue(customer.address) as PathValue<TForm, Path<TForm>>,
|
|
111
|
+
);
|
|
112
|
+
setCustomerFieldValue(
|
|
113
|
+
"customer.address_2" as Path<TForm>,
|
|
114
|
+
toFormValue(customer.address_2) as PathValue<TForm, Path<TForm>>,
|
|
115
|
+
);
|
|
116
|
+
setCustomerFieldValue(
|
|
117
|
+
"customer.post_code" as Path<TForm>,
|
|
118
|
+
toFormValue(customer.post_code) as PathValue<TForm, Path<TForm>>,
|
|
119
|
+
);
|
|
120
|
+
setCustomerFieldValue(
|
|
121
|
+
"customer.city" as Path<TForm>,
|
|
122
|
+
toFormValue(customer.city) as PathValue<TForm, Path<TForm>>,
|
|
123
|
+
);
|
|
124
|
+
setCustomerFieldValue(
|
|
125
|
+
"customer.state" as Path<TForm>,
|
|
126
|
+
toFormValue(customer.state) as PathValue<TForm, Path<TForm>>,
|
|
127
|
+
);
|
|
128
|
+
setCustomerFieldValue(
|
|
129
|
+
"customer.country" as Path<TForm>,
|
|
130
|
+
toFormValue(customer.country) as PathValue<TForm, Path<TForm>>,
|
|
131
|
+
);
|
|
132
|
+
setCustomerFieldValue(
|
|
133
|
+
"customer.tax_number" as Path<TForm>,
|
|
134
|
+
toFormValue(customer.tax_number) as PathValue<TForm, Path<TForm>>,
|
|
135
|
+
);
|
|
136
|
+
setCustomerFieldValue(
|
|
137
|
+
"customer.is_end_consumer" as Path<TForm>,
|
|
138
|
+
(customer.is_end_consumer ?? undefined) as PathValue<TForm, Path<TForm>>,
|
|
114
139
|
);
|
|
115
140
|
setOriginalCustomer(null);
|
|
116
141
|
setSelectedCustomerId(undefined);
|
|
@@ -131,12 +156,36 @@ export function useDocumentCustomerForm<TForm extends DocumentFormWithCustomer>(
|
|
|
131
156
|
is_end_consumer: customer.is_end_consumer ?? undefined,
|
|
132
157
|
};
|
|
133
158
|
|
|
134
|
-
|
|
159
|
+
setCustomerFieldValue("customer.name" as Path<TForm>, customerData.name as PathValue<TForm, Path<TForm>>);
|
|
160
|
+
setCustomerFieldValue("customer.address" as Path<TForm>, customerData.address as PathValue<TForm, Path<TForm>>);
|
|
161
|
+
setCustomerFieldValue(
|
|
162
|
+
"customer.address_2" as Path<TForm>,
|
|
163
|
+
customerData.address_2 as PathValue<TForm, Path<TForm>>,
|
|
164
|
+
);
|
|
165
|
+
setCustomerFieldValue(
|
|
166
|
+
"customer.post_code" as Path<TForm>,
|
|
167
|
+
customerData.post_code as PathValue<TForm, Path<TForm>>,
|
|
168
|
+
);
|
|
169
|
+
setCustomerFieldValue("customer.city" as Path<TForm>, customerData.city as PathValue<TForm, Path<TForm>>);
|
|
170
|
+
setCustomerFieldValue("customer.state" as Path<TForm>, customerData.state as PathValue<TForm, Path<TForm>>);
|
|
171
|
+
setCustomerFieldValue("customer.country" as Path<TForm>, customerData.country as PathValue<TForm, Path<TForm>>);
|
|
172
|
+
setCustomerFieldValue(
|
|
173
|
+
"customer.tax_number" as Path<TForm>,
|
|
174
|
+
customerData.tax_number as PathValue<TForm, Path<TForm>>,
|
|
175
|
+
);
|
|
176
|
+
setCustomerFieldValue(
|
|
177
|
+
"customer.is_end_consumer" as Path<TForm>,
|
|
178
|
+
customerData.is_end_consumer as PathValue<TForm, Path<TForm>>,
|
|
179
|
+
);
|
|
135
180
|
setOriginalCustomer(customerData);
|
|
136
181
|
setSelectedCustomerId(customerId);
|
|
137
182
|
setShouldFocusName(false);
|
|
138
183
|
}
|
|
139
184
|
|
|
185
|
+
form.clearErrors(["customer_id" as Path<TForm>, ...customerFieldPaths]);
|
|
186
|
+
if (form.formState.isSubmitted) {
|
|
187
|
+
void form.trigger();
|
|
188
|
+
}
|
|
140
189
|
setShowCustomerForm(true);
|
|
141
190
|
};
|
|
142
191
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { documents } from "@spaceinvoices/js-sdk";
|
|
1
2
|
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
2
|
-
import { useSDK } from "@/ui/providers/sdk-provider";
|
|
3
3
|
|
|
4
4
|
// Document type union for API calls
|
|
5
5
|
export type DocumentType = "invoice" | "estimate" | "credit_note" | "advance_invoice" | "delivery_note";
|
|
@@ -35,7 +35,6 @@ type FinalizeDocumentVariables = {
|
|
|
35
35
|
* Assigns a document number and runs fiscalization (if applicable)
|
|
36
36
|
*/
|
|
37
37
|
export function useFinalizeDocument(options: FinalizeDocumentOptions) {
|
|
38
|
-
const { sdk } = useSDK();
|
|
39
38
|
const queryClient = useQueryClient();
|
|
40
39
|
|
|
41
40
|
return useMutation({
|
|
@@ -43,7 +42,7 @@ export function useFinalizeDocument(options: FinalizeDocumentOptions) {
|
|
|
43
42
|
const body: Record<string, unknown> = {};
|
|
44
43
|
if (furs) body.furs = furs;
|
|
45
44
|
if (fina) body.fina = fina;
|
|
46
|
-
return
|
|
45
|
+
return documents.finalizeDocument(documentId, body, { type: documentType });
|
|
47
46
|
},
|
|
48
47
|
onSuccess: (data, variables) => {
|
|
49
48
|
// Invalidate list cache
|
|
@@ -83,12 +82,11 @@ type DeleteDraftDocumentVariables = {
|
|
|
83
82
|
* Only draft documents can be deleted
|
|
84
83
|
*/
|
|
85
84
|
export function useDeleteDraftDocument(options: DeleteDraftDocumentOptions) {
|
|
86
|
-
const { sdk } = useSDK();
|
|
87
85
|
const queryClient = useQueryClient();
|
|
88
86
|
|
|
89
87
|
return useMutation({
|
|
90
88
|
mutationFn: async ({ documentId, documentType }: DeleteDraftDocumentVariables) => {
|
|
91
|
-
return
|
|
89
|
+
return documents.delete(documentId, { type: documentType });
|
|
92
90
|
},
|
|
93
91
|
onSuccess: (_, variables) => {
|
|
94
92
|
// Invalidate list cache
|
|
@@ -15,6 +15,7 @@ export { prepareDocumentSubmission } from "./create/prepare-document-submission"
|
|
|
15
15
|
export { useDocumentCustomerForm } from "./create/use-document-customer-form";
|
|
16
16
|
// Preview components
|
|
17
17
|
export { default as DocumentPreview } from "./document-preview";
|
|
18
|
+
export { PublicDocumentSummary } from "./public";
|
|
18
19
|
export { ScaledDocumentPreview } from "./shared/scaled-document-preview";
|
|
19
20
|
export { useA4Scaling } from "./shared/use-a4-scaling";
|
|
20
21
|
// Types
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { PublicDocumentSummary } from "./public-document-summary";
|