@spaceinvoices/react-ui 0.4.12 → 0.4.32
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 +7 -1
- package/src/components/advance-invoices/advance-invoices.hooks.ts +35 -44
- package/src/components/advance-invoices/create/create-advance-invoice-form.tsx +190 -73
- package/src/components/advance-invoices/create/locales/bg.ts +17 -9
- package/src/components/advance-invoices/create/locales/cs.ts +17 -9
- package/src/components/advance-invoices/create/locales/de.ts +15 -7
- package/src/components/advance-invoices/create/locales/en.ts +15 -7
- package/src/components/advance-invoices/create/locales/es.ts +15 -7
- package/src/components/advance-invoices/create/locales/et.ts +17 -9
- package/src/components/advance-invoices/create/locales/fi.ts +18 -10
- package/src/components/advance-invoices/create/locales/fr.ts +16 -8
- package/src/components/advance-invoices/create/locales/hr.ts +15 -7
- package/src/components/advance-invoices/create/locales/is.ts +17 -9
- package/src/components/advance-invoices/create/locales/it.ts +15 -7
- package/src/components/advance-invoices/create/locales/nb.ts +17 -9
- package/src/components/advance-invoices/create/locales/nl.ts +15 -7
- package/src/components/advance-invoices/create/locales/pl.ts +17 -9
- package/src/components/advance-invoices/create/locales/pt.ts +16 -8
- package/src/components/advance-invoices/create/locales/sk.ts +17 -9
- package/src/components/advance-invoices/create/locales/sl.ts +14 -5
- package/src/components/advance-invoices/create/locales/sv.ts +17 -9
- package/src/components/advance-invoices/create/prepare-advance-invoice-submission.ts +47 -1
- package/src/components/advance-invoices/list/list-table.tsx +2 -1
- package/src/components/credit-notes/create/create-credit-note-form.tsx +254 -85
- package/src/components/credit-notes/create/locales/bg.ts +22 -8
- package/src/components/credit-notes/create/locales/cs.ts +22 -8
- package/src/components/credit-notes/create/locales/de.ts +20 -7
- package/src/components/credit-notes/create/locales/en.ts +19 -5
- package/src/components/credit-notes/create/locales/es.ts +20 -7
- package/src/components/credit-notes/create/locales/et.ts +22 -8
- package/src/components/credit-notes/create/locales/fi.ts +23 -9
- package/src/components/credit-notes/create/locales/fr.ts +21 -8
- package/src/components/credit-notes/create/locales/hr.ts +20 -7
- package/src/components/credit-notes/create/locales/is.ts +22 -8
- package/src/components/credit-notes/create/locales/it.ts +20 -7
- package/src/components/credit-notes/create/locales/nb.ts +22 -8
- package/src/components/credit-notes/create/locales/nl.ts +20 -7
- package/src/components/credit-notes/create/locales/pl.ts +22 -9
- package/src/components/credit-notes/create/locales/pt.ts +21 -8
- package/src/components/credit-notes/create/locales/sk.ts +22 -8
- package/src/components/credit-notes/create/locales/sl.ts +19 -5
- package/src/components/credit-notes/create/locales/sv.ts +22 -8
- package/src/components/credit-notes/create/prepare-credit-note-submission.ts +35 -1
- package/src/components/credit-notes/credit-notes.hooks.ts +21 -2
- package/src/components/credit-notes/list/list-table.tsx +2 -1
- package/src/components/delivery-notes/create/create-delivery-note-form.tsx +133 -30
- package/src/components/delivery-notes/create/locales/bg.ts +1 -0
- package/src/components/delivery-notes/create/locales/cs.ts +1 -0
- package/src/components/delivery-notes/create/locales/de.ts +1 -0
- package/src/components/delivery-notes/create/locales/en.ts +1 -0
- package/src/components/delivery-notes/create/locales/es.ts +1 -0
- package/src/components/delivery-notes/create/locales/et.ts +1 -0
- package/src/components/delivery-notes/create/locales/fi.ts +1 -0
- package/src/components/delivery-notes/create/locales/fr.ts +1 -0
- package/src/components/delivery-notes/create/locales/hr.ts +1 -0
- package/src/components/delivery-notes/create/locales/is.ts +1 -0
- package/src/components/delivery-notes/create/locales/it.ts +1 -0
- package/src/components/delivery-notes/create/locales/nb.ts +1 -0
- package/src/components/delivery-notes/create/locales/nl.ts +1 -0
- package/src/components/delivery-notes/create/locales/pl.ts +1 -0
- package/src/components/delivery-notes/create/locales/pt.ts +1 -0
- package/src/components/delivery-notes/create/locales/sk.ts +1 -0
- package/src/components/delivery-notes/create/locales/sl.ts +1 -0
- package/src/components/delivery-notes/create/locales/sv.ts +1 -0
- package/src/components/delivery-notes/create/prepare-delivery-note-submission.ts +34 -1
- package/src/components/delivery-notes/delivery-notes.hooks.ts +15 -1
- package/src/components/delivery-notes/list/list-table.tsx +2 -1
- package/src/components/documents/create/custom-create-template.ts +151 -0
- package/src/components/documents/create/document-add-item-form.tsx +12 -8
- package/src/components/documents/create/document-add-item-tax-rate-field.tsx +1 -2
- package/src/components/documents/create/document-date-validation.ts +111 -0
- package/src/components/documents/create/document-details-section.tsx +93 -48
- package/src/components/documents/create/document-form-item.ts +67 -0
- package/src/components/documents/create/document-item-validation.ts +6 -2
- package/src/components/documents/create/form-types.ts +2 -2
- package/src/components/documents/create/linked-documents-info.tsx +2 -11
- package/src/components/documents/create/live-preview.tsx +3 -3
- package/src/components/documents/create/mark-as-paid-section.tsx +14 -11
- package/src/components/documents/create/payment-rows.ts +30 -0
- package/src/components/documents/create/prepare-document-submission.ts +143 -103
- package/src/components/documents/create/prepare-preview-data.ts +12 -0
- package/src/components/documents/create/preserved-expected-total.ts +90 -0
- package/src/components/documents/public/public-document-summary.tsx +6 -13
- package/src/components/documents/view/document-actions-bar.tsx +10 -1
- package/src/components/documents/view/document-details-card.tsx +4 -12
- package/src/components/documents/view/document-relations-list.tsx +4 -4
- package/src/components/documents/view/locales/bg.ts +8 -8
- package/src/components/documents/view/locales/cs.ts +8 -8
- package/src/components/documents/view/locales/de.ts +1 -1
- package/src/components/documents/view/locales/en.ts +14 -14
- package/src/components/documents/view/locales/es.ts +1 -1
- package/src/components/documents/view/locales/et.ts +8 -8
- package/src/components/documents/view/locales/fi.ts +10 -10
- package/src/components/documents/view/locales/fr.ts +1 -1
- package/src/components/documents/view/locales/hr.ts +6 -6
- package/src/components/documents/view/locales/is.ts +8 -8
- package/src/components/documents/view/locales/it.ts +1 -1
- package/src/components/documents/view/locales/nb.ts +8 -8
- package/src/components/documents/view/locales/nl.ts +1 -1
- package/src/components/documents/view/locales/pl.ts +1 -1
- package/src/components/documents/view/locales/pt.ts +1 -1
- package/src/components/documents/view/locales/sk.ts +8 -8
- package/src/components/documents/view/locales/sl.ts +9 -9
- package/src/components/documents/view/locales/sv.ts +1 -1
- package/src/components/documents/view/use-document-download.ts +2 -2
- package/src/components/entities/entity-settings-form/locales/bg.ts +7 -0
- package/src/components/entities/entity-settings-form/locales/cs.ts +7 -0
- package/src/components/entities/entity-settings-form/locales/de.ts +9 -0
- package/src/components/entities/entity-settings-form/locales/en.ts +7 -0
- package/src/components/entities/entity-settings-form/locales/es.ts +7 -0
- package/src/components/entities/entity-settings-form/locales/et.ts +7 -0
- package/src/components/entities/entity-settings-form/locales/fi.ts +7 -0
- package/src/components/entities/entity-settings-form/locales/fr.ts +7 -0
- package/src/components/entities/entity-settings-form/locales/hr.ts +7 -0
- package/src/components/entities/entity-settings-form/locales/is.ts +7 -0
- package/src/components/entities/entity-settings-form/locales/it.ts +7 -0
- package/src/components/entities/entity-settings-form/locales/nb.ts +7 -0
- package/src/components/entities/entity-settings-form/locales/nl.ts +7 -0
- package/src/components/entities/entity-settings-form/locales/pl.ts +7 -0
- package/src/components/entities/entity-settings-form/locales/pt.ts +7 -0
- package/src/components/entities/entity-settings-form/locales/sk.ts +7 -0
- package/src/components/entities/entity-settings-form/locales/sl.ts +12 -4
- package/src/components/entities/entity-settings-form/locales/sv.ts +7 -0
- package/src/components/entities/settings/tax-rules-settings-form.tsx +36 -0
- package/src/components/estimates/create/create-estimate-form.tsx +196 -47
- package/src/components/estimates/create/locales/bg.ts +6 -5
- package/src/components/estimates/create/locales/cs.ts +6 -5
- package/src/components/estimates/create/locales/de.ts +4 -3
- package/src/components/estimates/create/locales/en.ts +4 -3
- package/src/components/estimates/create/locales/es.ts +4 -3
- package/src/components/estimates/create/locales/et.ts +6 -5
- package/src/components/estimates/create/locales/fi.ts +9 -8
- package/src/components/estimates/create/locales/fr.ts +4 -3
- package/src/components/estimates/create/locales/hr.ts +7 -6
- package/src/components/estimates/create/locales/is.ts +6 -5
- package/src/components/estimates/create/locales/it.ts +4 -3
- package/src/components/estimates/create/locales/nb.ts +6 -5
- package/src/components/estimates/create/locales/nl.ts +4 -3
- package/src/components/estimates/create/locales/pl.ts +4 -3
- package/src/components/estimates/create/locales/pt.ts +4 -3
- package/src/components/estimates/create/locales/sk.ts +6 -5
- package/src/components/estimates/create/locales/sl.ts +7 -6
- package/src/components/estimates/create/locales/sv.ts +6 -5
- package/src/components/estimates/create/prepare-estimate-submission.ts +37 -3
- package/src/components/estimates/estimates.hooks.ts +11 -2
- package/src/components/estimates/list/list-table.tsx +11 -1
- package/src/components/estimates/list/locales/bg.ts +2 -0
- package/src/components/estimates/list/locales/cs.ts +2 -0
- package/src/components/estimates/list/locales/de.ts +2 -0
- package/src/components/estimates/list/locales/en.ts +2 -0
- package/src/components/estimates/list/locales/es.ts +2 -0
- package/src/components/estimates/list/locales/et.ts +2 -0
- package/src/components/estimates/list/locales/fi.ts +2 -0
- package/src/components/estimates/list/locales/fr.ts +2 -0
- package/src/components/estimates/list/locales/hr.ts +7 -5
- package/src/components/estimates/list/locales/is.ts +2 -0
- package/src/components/estimates/list/locales/it.ts +2 -0
- package/src/components/estimates/list/locales/nb.ts +2 -0
- package/src/components/estimates/list/locales/nl.ts +2 -0
- package/src/components/estimates/list/locales/pl.ts +2 -0
- package/src/components/estimates/list/locales/pt.ts +2 -0
- package/src/components/estimates/list/locales/sk.ts +2 -0
- package/src/components/estimates/list/locales/sl.ts +9 -7
- package/src/components/estimates/list/locales/sv.ts +2 -0
- package/src/components/invoices/create/create-invoice-form.tsx +231 -60
- package/src/components/invoices/create/locales/bg.ts +23 -14
- package/src/components/invoices/create/locales/cs.ts +23 -14
- package/src/components/invoices/create/locales/de.ts +17 -9
- package/src/components/invoices/create/locales/en.ts +16 -7
- package/src/components/invoices/create/locales/es.ts +18 -9
- package/src/components/invoices/create/locales/et.ts +23 -14
- package/src/components/invoices/create/locales/fi.ts +24 -15
- package/src/components/invoices/create/locales/fr.ts +19 -11
- package/src/components/invoices/create/locales/hr.ts +18 -9
- package/src/components/invoices/create/locales/is.ts +23 -14
- package/src/components/invoices/create/locales/it.ts +19 -11
- package/src/components/invoices/create/locales/nb.ts +23 -14
- package/src/components/invoices/create/locales/nl.ts +19 -10
- package/src/components/invoices/create/locales/pl.ts +19 -11
- package/src/components/invoices/create/locales/pt.ts +19 -10
- package/src/components/invoices/create/locales/sk.ts +23 -14
- package/src/components/invoices/create/locales/sl.ts +17 -9
- package/src/components/invoices/create/locales/sv.ts +17 -8
- package/src/components/invoices/create/prepare-invoice-submission.ts +55 -1
- package/src/components/invoices/invoices.hooks.ts +11 -2
- package/src/components/invoices/list/list-table.tsx +2 -1
- package/src/components/invoices/send-email-dialog/locales/bg.ts +5 -0
- package/src/components/invoices/send-email-dialog/locales/cs.ts +5 -0
- package/src/components/invoices/send-email-dialog/locales/de.ts +5 -0
- package/src/components/invoices/send-email-dialog/locales/en.ts +5 -0
- package/src/components/invoices/send-email-dialog/locales/es.ts +5 -0
- package/src/components/invoices/send-email-dialog/locales/et.ts +5 -0
- package/src/components/invoices/send-email-dialog/locales/fi.ts +5 -0
- package/src/components/invoices/send-email-dialog/locales/fr.ts +5 -0
- package/src/components/invoices/send-email-dialog/locales/hr.ts +8 -3
- package/src/components/invoices/send-email-dialog/locales/is.ts +5 -0
- package/src/components/invoices/send-email-dialog/locales/it.ts +5 -0
- package/src/components/invoices/send-email-dialog/locales/nb.ts +5 -0
- package/src/components/invoices/send-email-dialog/locales/nl.ts +5 -0
- package/src/components/invoices/send-email-dialog/locales/pl.ts +5 -0
- package/src/components/invoices/send-email-dialog/locales/pt.ts +5 -0
- package/src/components/invoices/send-email-dialog/locales/sk.ts +5 -0
- package/src/components/invoices/send-email-dialog/locales/sl.ts +8 -3
- package/src/components/invoices/send-email-dialog/locales/sv.ts +5 -0
- package/src/components/invoices/send-email-dialog/send-email-dialog.tsx +2 -1
- package/src/components/items/item-combobox.tsx +4 -4
- package/src/components/payments/create-payment-form/create-payment-form.tsx +5 -2
- package/src/components/payments/edit-payment-form/edit-payment-form.tsx +5 -1
- package/src/components/recurring-invoices/create-recurring-invoice-form/create-recurring-invoice-form.tsx +98 -22
- package/src/components/recurring-invoices/create-recurring-invoice-form/locales/bg.ts +26 -26
- package/src/components/recurring-invoices/create-recurring-invoice-form/locales/cs.ts +25 -25
- package/src/components/recurring-invoices/create-recurring-invoice-form/locales/et.ts +26 -26
- package/src/components/recurring-invoices/create-recurring-invoice-form/locales/fi.ts +36 -36
- package/src/components/recurring-invoices/create-recurring-invoice-form/locales/is.ts +26 -26
- package/src/components/recurring-invoices/create-recurring-invoice-form/locales/nb.ts +26 -26
- package/src/components/recurring-invoices/create-recurring-invoice-form/locales/sk.ts +25 -25
- package/src/components/recurring-invoices/create-recurring-invoice-form/locales/sv.ts +26 -26
- package/src/components/recurring-invoices/list/list-row-actions.tsx +9 -1
- package/src/components/recurring-invoices/list/list-table.tsx +53 -5
- package/src/components/recurring-invoices/list/locales/bg.ts +4 -0
- package/src/components/recurring-invoices/list/locales/cs.ts +4 -0
- package/src/components/recurring-invoices/list/locales/de.ts +4 -0
- package/src/components/recurring-invoices/list/locales/en.ts +4 -0
- package/src/components/recurring-invoices/list/locales/es.ts +4 -0
- package/src/components/recurring-invoices/list/locales/et.ts +4 -0
- package/src/components/recurring-invoices/list/locales/fi.ts +4 -0
- package/src/components/recurring-invoices/list/locales/fr.ts +4 -0
- package/src/components/recurring-invoices/list/locales/hr.ts +4 -0
- package/src/components/recurring-invoices/list/locales/is.ts +4 -0
- package/src/components/recurring-invoices/list/locales/it.ts +4 -0
- package/src/components/recurring-invoices/list/locales/nb.ts +4 -0
- package/src/components/recurring-invoices/list/locales/nl.ts +4 -0
- package/src/components/recurring-invoices/list/locales/pl.ts +4 -0
- package/src/components/recurring-invoices/list/locales/pt.ts +4 -0
- package/src/components/recurring-invoices/list/locales/sk.ts +4 -0
- package/src/components/recurring-invoices/list/locales/sl.ts +4 -0
- package/src/components/recurring-invoices/list/locales/sv.ts +4 -0
- package/src/components/tax-reports/slovenia-tax-profile-step.tsx +4 -1
- package/src/components/tax-reports/slovenia-yearly-export-form.tsx +3 -0
- package/src/components/tax-reports/slovenia-yearly-review-step.tsx +2 -1
- package/src/components/ui/form.tsx +5 -13
- package/src/components/ui/select.tsx +0 -1
- package/src/components/ui/sidebar.tsx +2 -2
- package/src/generate-schemas.ts +132 -99
- package/src/generated/schemas/acceptentityinvitation_body.ts +4 -3
- package/src/generated/schemas/accountwebhook.ts +4 -8
- package/src/generated/schemas/addentityuser_body.ts +4 -3
- package/src/generated/schemas/advanceinvoice.ts +167 -168
- package/src/generated/schemas/authorizeshopify_body.ts +4 -3
- package/src/generated/schemas/calculatedocumentpreview.ts +120 -0
- package/src/generated/schemas/checktransactiontype.ts +35 -0
- package/src/generated/schemas/creditnote.ts +203 -76
- package/src/generated/schemas/customadvanceinvoice.ts +172 -165
- package/src/generated/schemas/customcreditnote.ts +183 -155
- package/src/generated/schemas/customdeliverynote.ts +166 -0
- package/src/generated/schemas/customer.ts +4 -8
- package/src/generated/schemas/customestimate.ts +123 -97
- package/src/generated/schemas/customincomingpurchasedocument.ts +142 -0
- package/src/generated/schemas/custominvoice.ts +183 -154
- package/src/generated/schemas/deliverynote.ts +124 -79
- package/src/generated/schemas/einvoice.ts +19 -0
- package/src/generated/schemas/einvoicingsettings.ts +21 -0
- package/src/generated/schemas/einvoicingsupplier.ts +45 -0
- package/src/generated/schemas/entity.ts +44 -40
- package/src/generated/schemas/entityapikey.ts +1 -3
- package/src/generated/schemas/entityuserrole.ts +1 -3
- package/src/generated/schemas/estimate.ts +120 -127
- package/src/generated/schemas/exportsloveniavodxml_body.ts +4 -3
- package/src/generated/schemas/exportsloveniayearlynormiranireport_body.ts +4 -3
- package/src/generated/schemas/finadevice.ts +15 -0
- package/src/generated/schemas/finalizedocument.ts +52 -0
- package/src/generated/schemas/finapremise.ts +15 -0
- package/src/generated/schemas/finasettings.ts +1 -3
- package/src/generated/schemas/furselectronicdevice.ts +15 -0
- package/src/generated/schemas/furssettings.ts +1 -3
- package/src/generated/schemas/image.ts +15 -0
- package/src/generated/schemas/incomingpurchasedocument.ts +7 -27
- package/src/generated/schemas/incomingpurchasedocumentattachment.ts +15 -0
- package/src/generated/schemas/incomingpurchasedocumentpayment.ts +1 -3
- package/src/generated/schemas/index.ts +20 -5
- package/src/generated/schemas/invoice.ts +182 -183
- package/src/generated/schemas/item.ts +6 -10
- package/src/generated/schemas/legacymigrationauth.ts +18 -0
- package/src/generated/schemas/me.ts +2 -24
- package/src/generated/schemas/migrationjob.ts +20 -0
- package/src/generated/schemas/order.ts +4 -8
- package/src/generated/schemas/orderintegration.ts +4 -8
- package/src/generated/schemas/payment.ts +4 -8
- package/src/generated/schemas/ptatcudseries.ts +1 -3
- package/src/generated/schemas/queryentitystats.ts +15 -0
- package/src/generated/schemas/recurringinvoice.ts +4 -8
- package/src/generated/schemas/registerfursmovablepremise_body.ts +1 -3
- package/src/generated/schemas/registerfursrealestatepremise_body.ts +1 -3
- package/src/generated/schemas/renderadvanceinvoicepreview_body.ts +10 -16
- package/src/generated/schemas/rendercreditnotepreview_body.ts +10 -16
- package/src/generated/schemas/renderdeliverynotepreview_body.ts +9 -5
- package/src/generated/schemas/renderestimatepreview_body.ts +11 -7
- package/src/generated/schemas/renderinvoicepreview_body.ts +10 -16
- package/src/generated/schemas/reviewsloveniayearlynormiranireport.ts +15 -0
- package/src/generated/schemas/searcheinvoicingcustomer.ts +18 -0
- package/src/generated/schemas/senddocument_body.ts +1 -3
- package/src/generated/schemas/sendemail_body.ts +2 -24
- package/src/generated/schemas/sloveniataxprofile.ts +8 -10
- package/src/generated/schemas/starteslogexport_body.ts +4 -3
- package/src/generated/schemas/startpdfexport_body.ts +8 -87
- package/src/generated/schemas/stripeappconnect_body.ts +4 -3
- package/src/generated/schemas/stripeappcreateinvoice_body.ts +4 -6
- package/src/generated/schemas/stripeappmarketplaceauthorize.ts +15 -0
- package/src/generated/schemas/stripeappupdatesettings_body.ts +6 -6
- package/src/generated/schemas/supplier.ts +4 -8
- package/src/generated/schemas/syncshopifyorders_body.ts +4 -3
- package/src/generated/schemas/tax.ts +6 -8
- package/src/generated/schemas/uploadfile_body.ts +1 -3
- package/src/generated/schemas/uploadfurscertificate_body.ts +6 -6
- package/src/generated/schemas/userfinasettings.ts +1 -3
- package/src/generated/schemas/userfurssettings.ts +1 -3
- package/src/generated/schemas/userptsettings.ts +1 -3
- package/src/generated/schemas/voidinvoice_body.ts +8 -3
- package/src/generated/schemas/webhook.ts +4 -8
- package/src/generated/schemas/wlsubscriptionbillingemail.ts +17 -0
- package/src/hooks/use-duplicate-document.ts +74 -32
- package/src/lib/date-only.ts +58 -0
- package/src/lib/document-display.ts +18 -0
- package/src/lib/payment-display.ts +5 -3
- package/src/lib/schemas/shared.ts +11 -0
- package/src/providers/wl-subscription-provider.tsx +5 -0
- package/src/generated/schemas/account_webhook.ts +0 -43
- package/src/generated/schemas/previewadvanceinvoice_body.ts +0 -354
- package/src/generated/schemas/previewestimate_body.ts +0 -309
- package/src/generated/schemas/registerfinamovablepremise_body.ts +0 -26
- package/src/generated/schemas/registerfinarealestatepremise_body.ts +0 -37
- package/src/generated/schemas/renderdocument_body.ts +0 -594
package/cli/dist/index.js
CHANGED
|
@@ -933,7 +933,7 @@ async function list(options = {}) {
|
|
|
933
933
|
|
|
934
934
|
// cli/src/index.ts
|
|
935
935
|
var program = new Command();
|
|
936
|
-
program.name("spaceinvoices-ui").description("CLI for adding Space Invoices React UI components to your project").version("0.4.
|
|
936
|
+
program.name("spaceinvoices-ui").description("CLI for adding Space Invoices React UI components to your project").version("0.4.32");
|
|
937
937
|
program.option("--local <path>", "Use local registry from specified path (for development)");
|
|
938
938
|
program.command("init").description("Initialize Space Invoices UI in your project").option("-y, --yes", "Skip prompts and use defaults").option("-f, --force", "Overwrite existing configuration").option("--cwd <path>", "Working directory (defaults to current directory)").action(async (options) => {
|
|
939
939
|
const globalOpts = program.opts();
|
package/package.json
CHANGED
|
@@ -196,7 +196,13 @@ export function Autocomplete({
|
|
|
196
196
|
aria-invalid={ariaInvalid || undefined}
|
|
197
197
|
/>
|
|
198
198
|
<Popover.Portal>
|
|
199
|
-
<Popover.Positioner
|
|
199
|
+
<Popover.Positioner
|
|
200
|
+
anchor={inputRef}
|
|
201
|
+
align="start"
|
|
202
|
+
sideOffset={4}
|
|
203
|
+
positionMethod="fixed"
|
|
204
|
+
className="isolate z-50"
|
|
205
|
+
>
|
|
200
206
|
<Popover.Popup
|
|
201
207
|
initialFocus={false}
|
|
202
208
|
finalFocus={false}
|
|
@@ -1,42 +1,46 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
AdvanceInvoice,
|
|
3
|
+
CreateAdvanceInvoiceRequest,
|
|
4
|
+
CustomCreateAdvanceInvoice,
|
|
5
|
+
SDKMethodOptions,
|
|
6
|
+
UpdateAdvanceInvoice,
|
|
7
|
+
} from "@spaceinvoices/js-sdk";
|
|
2
8
|
import { advanceInvoices } from "@spaceinvoices/js-sdk";
|
|
3
|
-
import {
|
|
4
|
-
import { NEXT_DOCUMENT_NUMBER_CACHE_KEY } from "@/ui/hooks/use-next-document-number";
|
|
9
|
+
import { createResourceHooks } from "@/ui/hooks/create-resource-hooks";
|
|
5
10
|
|
|
6
|
-
// Define constants for cache keys
|
|
7
11
|
export const ADVANCE_INVOICES_CACHE_KEY = "advance-invoices";
|
|
8
12
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
// ============================================================================
|
|
12
|
-
|
|
13
|
-
type UseCreateAdvanceInvoiceOptions = {
|
|
14
|
-
entityId: string;
|
|
15
|
-
onSuccess?: (data: AdvanceInvoice) => void;
|
|
16
|
-
onError?: (error: unknown) => void;
|
|
13
|
+
const voidAdvanceInvoice = async (id: string, options?: SDKMethodOptions): Promise<void> => {
|
|
14
|
+
await advanceInvoices.void(id, {}, options);
|
|
17
15
|
};
|
|
18
16
|
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
const {
|
|
18
|
+
useCreateResource: useCreateAdvanceInvoice,
|
|
19
|
+
useUpdateResource: useUpdateAdvanceInvoice,
|
|
20
|
+
useDeleteResource: useDeleteAdvanceInvoice,
|
|
21
|
+
} = createResourceHooks<AdvanceInvoice, CreateAdvanceInvoiceRequest, UpdateAdvanceInvoice>(
|
|
22
|
+
{
|
|
23
|
+
create: advanceInvoices.create,
|
|
24
|
+
update: advanceInvoices.update,
|
|
25
|
+
delete: voidAdvanceInvoice,
|
|
26
|
+
},
|
|
27
|
+
ADVANCE_INVOICES_CACHE_KEY,
|
|
28
|
+
);
|
|
21
29
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
});
|
|
35
|
-
}
|
|
30
|
+
const { useCreateResource: useCreateCustomAdvanceInvoice } = createResourceHooks<
|
|
31
|
+
AdvanceInvoice,
|
|
32
|
+
CustomCreateAdvanceInvoice,
|
|
33
|
+
UpdateAdvanceInvoice
|
|
34
|
+
>(
|
|
35
|
+
{
|
|
36
|
+
create: advanceInvoices.createCustom,
|
|
37
|
+
update: advanceInvoices.update,
|
|
38
|
+
delete: voidAdvanceInvoice,
|
|
39
|
+
},
|
|
40
|
+
ADVANCE_INVOICES_CACHE_KEY,
|
|
41
|
+
);
|
|
36
42
|
|
|
37
|
-
|
|
38
|
-
// FURS Last-Used Combo (localStorage) - Reuse from invoices
|
|
39
|
-
// ============================================================================
|
|
43
|
+
export { useCreateAdvanceInvoice, useCreateCustomAdvanceInvoice, useDeleteAdvanceInvoice, useUpdateAdvanceInvoice };
|
|
40
44
|
|
|
41
45
|
const FURS_ADV_LAST_USED_KEY = "si:furs:adv:last-used";
|
|
42
46
|
|
|
@@ -45,10 +49,6 @@ export type FursCombo = {
|
|
|
45
49
|
electronic_device_name: string;
|
|
46
50
|
};
|
|
47
51
|
|
|
48
|
-
/**
|
|
49
|
-
* Get last-used FURS premise/device combo from localStorage for advance invoices
|
|
50
|
-
* @param entityId - Entity ID (combos are stored per-entity)
|
|
51
|
-
*/
|
|
52
52
|
export function getLastUsedFursCombo(entityId: string): FursCombo | null {
|
|
53
53
|
if (typeof window === "undefined") return null;
|
|
54
54
|
try {
|
|
@@ -59,11 +59,6 @@ export function getLastUsedFursCombo(entityId: string): FursCombo | null {
|
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
/**
|
|
63
|
-
* Save last-used FURS premise/device combo to localStorage for advance invoices
|
|
64
|
-
* @param entityId - Entity ID
|
|
65
|
-
* @param combo - FURS premise/device combo
|
|
66
|
-
*/
|
|
67
62
|
export function setLastUsedFursCombo(entityId: string, combo: FursCombo): void {
|
|
68
63
|
if (typeof window === "undefined") return;
|
|
69
64
|
try {
|
|
@@ -73,10 +68,6 @@ export function setLastUsedFursCombo(entityId: string, combo: FursCombo): void {
|
|
|
73
68
|
}
|
|
74
69
|
}
|
|
75
70
|
|
|
76
|
-
// ============================================================================
|
|
77
|
-
// FINA Last-Used Combo (localStorage) for advance invoices
|
|
78
|
-
// ============================================================================
|
|
79
|
-
|
|
80
71
|
const FINA_ADV_LAST_USED_KEY = "hr:fina:adv:last-used";
|
|
81
72
|
|
|
82
73
|
export type FinaCombo = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { zodResolver } from "@hookform/resolvers/zod";
|
|
2
|
-
import type { AdvanceInvoice, CreateAdvanceInvoiceRequest } from "@spaceinvoices/js-sdk";
|
|
2
|
+
import type { AdvanceInvoice, CreateAdvanceInvoiceRequest, UpdateAdvanceInvoice } from "@spaceinvoices/js-sdk";
|
|
3
3
|
import { AlertCircle, Check, FileCode2, X } from "lucide-react";
|
|
4
4
|
import type { ReactNode } from "react";
|
|
5
5
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
@@ -27,6 +27,7 @@ import {
|
|
|
27
27
|
type PtDocumentInputForm,
|
|
28
28
|
ptDocumentInputFormSchema,
|
|
29
29
|
} from "@/ui/lib/pt-document-input";
|
|
30
|
+
import { normalizeLineItemDiscountsForForm } from "@/ui/lib/schemas/shared";
|
|
30
31
|
import type { ComponentTranslationProps } from "@/ui/lib/translation";
|
|
31
32
|
import { createTranslation } from "@/ui/lib/translation";
|
|
32
33
|
import { cn } from "@/ui/lib/utils";
|
|
@@ -49,9 +50,12 @@ import {
|
|
|
49
50
|
createEmptyPaymentRow,
|
|
50
51
|
type DraftPaymentRow,
|
|
51
52
|
getFirstValidPaymentType,
|
|
52
|
-
|
|
53
|
+
serializePaymentRowsForApi,
|
|
53
54
|
validatePaymentRows,
|
|
54
55
|
} from "../../documents/create/payment-rows";
|
|
56
|
+
import { prepareDocumentItems } from "../../documents/create/prepare-document-submission";
|
|
57
|
+
import { applyCustomCreateTemplate } from "../../documents/create/custom-create-template";
|
|
58
|
+
import { financialInputsMatchInitial, resolvePreservedExpectedTotal } from "../../documents/create/preserved-expected-total";
|
|
55
59
|
import { scrollToFirstInvalidField } from "../../documents/create/scroll-to-first-invalid-field";
|
|
56
60
|
import { useDocumentCustomerForm } from "../../documents/create/use-document-customer-form";
|
|
57
61
|
import type { DocumentTypes } from "../../documents/types";
|
|
@@ -72,7 +76,7 @@ import invoiceNl from "../../invoices/create/locales/nl";
|
|
|
72
76
|
import invoicePl from "../../invoices/create/locales/pl";
|
|
73
77
|
import invoicePt from "../../invoices/create/locales/pt";
|
|
74
78
|
import invoiceSl from "../../invoices/create/locales/sl";
|
|
75
|
-
import { useCreateAdvanceInvoice } from "../advance-invoices.hooks";
|
|
79
|
+
import { useCreateAdvanceInvoice, useCreateCustomAdvanceInvoice, useUpdateAdvanceInvoice } from "../advance-invoices.hooks";
|
|
76
80
|
import de from "./locales/de";
|
|
77
81
|
import es from "./locales/es";
|
|
78
82
|
import fr from "./locales/fr";
|
|
@@ -82,7 +86,10 @@ import nl from "./locales/nl";
|
|
|
82
86
|
import pl from "./locales/pl";
|
|
83
87
|
import pt from "./locales/pt";
|
|
84
88
|
import sl from "./locales/sl";
|
|
85
|
-
import {
|
|
89
|
+
import {
|
|
90
|
+
prepareAdvanceInvoiceSubmission,
|
|
91
|
+
prepareAdvanceInvoiceUpdateSubmission,
|
|
92
|
+
} from "./prepare-advance-invoice-submission";
|
|
86
93
|
|
|
87
94
|
const translations = {
|
|
88
95
|
sl: { ...invoiceSl, ...sl },
|
|
@@ -125,6 +132,8 @@ type CreateAdvanceInvoiceFormProps = {
|
|
|
125
132
|
initialValues?: Partial<CreateAdvanceInvoiceRequest>;
|
|
126
133
|
/** Whether draft actions should be available in the UI */
|
|
127
134
|
allowDrafts?: boolean;
|
|
135
|
+
mode?: "create" | "edit";
|
|
136
|
+
documentId?: string;
|
|
128
137
|
/** Optional app-level content rendered inside the details section. */
|
|
129
138
|
detailsExtras?: ReactNode;
|
|
130
139
|
/** Request-scoped operator override for embed fiscalization flows. */
|
|
@@ -142,6 +151,8 @@ export default function CreateAdvanceInvoiceForm({
|
|
|
142
151
|
onHeaderActionChange,
|
|
143
152
|
initialValues,
|
|
144
153
|
allowDrafts = true,
|
|
154
|
+
mode = "create",
|
|
155
|
+
documentId,
|
|
145
156
|
detailsExtras,
|
|
146
157
|
operatorPrefill,
|
|
147
158
|
translationLocale,
|
|
@@ -158,6 +169,7 @@ export default function CreateAdvanceInvoiceForm({
|
|
|
158
169
|
});
|
|
159
170
|
|
|
160
171
|
const { activeEntity } = useEntities();
|
|
172
|
+
const isEditMode = mode === "edit";
|
|
161
173
|
|
|
162
174
|
// Advance invoices have their own default note setting.
|
|
163
175
|
// Note: Advance invoices don't have payment terms - they are documents requesting payment.
|
|
@@ -193,6 +205,36 @@ export default function CreateAdvanceInvoiceForm({
|
|
|
193
205
|
}, {} as PriceModesMap);
|
|
194
206
|
}, [initialValues?.items]);
|
|
195
207
|
const priceModesRef = useRef<PriceModesMap>(initialPriceModes);
|
|
208
|
+
const customCreateTemplate = (initialValues as any)?._custom_create_template;
|
|
209
|
+
const financialInputsMatchSource = useCallback(
|
|
210
|
+
(values: { items?: any[]; currency_code?: string; calculation_mode?: string | null }) =>
|
|
211
|
+
financialInputsMatchInitial({
|
|
212
|
+
initialItems: initialValues?.items,
|
|
213
|
+
currentItems: values.items,
|
|
214
|
+
initialCurrencyCode: initialValues?.currency_code,
|
|
215
|
+
currentCurrencyCode: values.currency_code,
|
|
216
|
+
initialCalculationMode: (initialValues as any)?.calculation_mode ?? null,
|
|
217
|
+
currentCalculationMode: values.calculation_mode ?? null,
|
|
218
|
+
initialPriceModes,
|
|
219
|
+
currentPriceModes: priceModesRef.current,
|
|
220
|
+
}),
|
|
221
|
+
[initialPriceModes, initialValues],
|
|
222
|
+
);
|
|
223
|
+
const getPreservedExpectedTotalWithTax = useCallback(
|
|
224
|
+
(values: { items?: any[]; currency_code?: string; calculation_mode?: string | null }) =>
|
|
225
|
+
resolvePreservedExpectedTotal({
|
|
226
|
+
initialExpectedTotalWithTax: (initialValues as any)?._preserved_expected_total_with_tax,
|
|
227
|
+
initialItems: initialValues?.items,
|
|
228
|
+
currentItems: values.items,
|
|
229
|
+
initialCurrencyCode: initialValues?.currency_code,
|
|
230
|
+
currentCurrencyCode: values.currency_code,
|
|
231
|
+
initialCalculationMode: (initialValues as any)?.calculation_mode ?? null,
|
|
232
|
+
currentCalculationMode: values.calculation_mode ?? null,
|
|
233
|
+
initialPriceModes,
|
|
234
|
+
currentPriceModes: priceModesRef.current,
|
|
235
|
+
}),
|
|
236
|
+
[initialPriceModes, initialValues],
|
|
237
|
+
);
|
|
196
238
|
|
|
197
239
|
const baseResolver = useMemo(
|
|
198
240
|
() => zodResolver(createAdvanceInvoiceFormSchema) as Resolver<CreateAdvanceInvoiceFormValues>,
|
|
@@ -200,12 +242,14 @@ export default function CreateAdvanceInvoiceForm({
|
|
|
200
242
|
);
|
|
201
243
|
const eslogResolverStateRef = useRef({
|
|
202
244
|
activeEntity,
|
|
245
|
+
isEditMode,
|
|
203
246
|
isEnabled: eslog.isEnabled === true,
|
|
204
247
|
translate: t,
|
|
205
248
|
setEntityErrors: eslog.setEntityErrors,
|
|
206
249
|
});
|
|
207
250
|
eslogResolverStateRef.current = {
|
|
208
251
|
activeEntity,
|
|
252
|
+
isEditMode,
|
|
209
253
|
isEnabled: eslog.isEnabled === true,
|
|
210
254
|
translate: t,
|
|
211
255
|
setEntityErrors: eslog.setEntityErrors,
|
|
@@ -214,7 +258,8 @@ export default function CreateAdvanceInvoiceForm({
|
|
|
214
258
|
() => async (values, context, options) => {
|
|
215
259
|
const result = await baseResolver(values, context, options);
|
|
216
260
|
const resolverState = eslogResolverStateRef.current;
|
|
217
|
-
const shouldValidateEslog =
|
|
261
|
+
const shouldValidateEslog =
|
|
262
|
+
eslogValidationModeRef.current === "submit" && !resolverState.isEditMode && resolverState.isEnabled;
|
|
218
263
|
|
|
219
264
|
if (!shouldValidateEslog) {
|
|
220
265
|
eslogEntityErrorsRef.current = [];
|
|
@@ -246,22 +291,28 @@ export default function CreateAdvanceInvoiceForm({
|
|
|
246
291
|
const form = useForm<CreateAdvanceInvoiceFormValues>({
|
|
247
292
|
resolver,
|
|
248
293
|
defaultValues: {
|
|
249
|
-
number:
|
|
294
|
+
number: (initialValues as any)?.number ?? "",
|
|
295
|
+
calculation_mode: (initialValues as any)?.calculation_mode ?? undefined,
|
|
250
296
|
date: initialValues?.date || new Date().toISOString(),
|
|
251
297
|
customer_id: initialValues?.customer_id ?? undefined,
|
|
252
298
|
// Cast customer to form schema type (API type may have additional fields)
|
|
253
299
|
customer: (initialValues?.customer as CreateAdvanceInvoiceFormValues["customer"]) ?? undefined,
|
|
254
300
|
items: initialValues?.items?.length
|
|
255
301
|
? initialValues.items.map((item: any) => ({
|
|
256
|
-
type: item.type,
|
|
302
|
+
type: item.type ?? undefined,
|
|
257
303
|
name: item.name || "",
|
|
258
304
|
description: item.description || "",
|
|
259
305
|
...(item.type !== "separator"
|
|
260
306
|
? {
|
|
307
|
+
item_id: item.item_id ?? undefined,
|
|
261
308
|
quantity: item.quantity ?? 1,
|
|
262
|
-
// Use gross_price if set, otherwise use price
|
|
263
309
|
price: item.gross_price ?? item.price,
|
|
310
|
+
gross_price: item.gross_price ?? undefined,
|
|
311
|
+
unit: item.unit ?? undefined,
|
|
312
|
+
classification: item.classification ?? undefined,
|
|
264
313
|
taxes: item.taxes || [],
|
|
314
|
+
discounts: normalizeLineItemDiscountsForForm(item.discounts),
|
|
315
|
+
metadata: item.metadata ?? undefined,
|
|
265
316
|
}
|
|
266
317
|
: {}),
|
|
267
318
|
}))
|
|
@@ -276,9 +327,12 @@ export default function CreateAdvanceInvoiceForm({
|
|
|
276
327
|
],
|
|
277
328
|
currency_code: initialValues?.currency_code || activeEntity?.currency_code || "EUR",
|
|
278
329
|
reference: (initialValues as any)?.reference ?? "",
|
|
279
|
-
note: initialValues?.note ?? defaultNote,
|
|
280
|
-
tax_clause: "",
|
|
281
|
-
footer: (initialValues as any)?.footer ?? defaultFooter,
|
|
330
|
+
note: initialValues?.note ?? (isEditMode ? "" : defaultNote),
|
|
331
|
+
tax_clause: (initialValues as any)?.tax_clause ?? "",
|
|
332
|
+
footer: (initialValues as any)?.footer ?? (isEditMode ? "" : defaultFooter),
|
|
333
|
+
signature:
|
|
334
|
+
(initialValues as any)?.signature ??
|
|
335
|
+
(isEditMode ? "" : (activeEntity?.settings as any)?.default_document_signature || ""),
|
|
282
336
|
pt: ((initialValues as any)?.pt as PtDocumentInputForm | undefined) ?? undefined,
|
|
283
337
|
},
|
|
284
338
|
});
|
|
@@ -296,13 +350,13 @@ export default function CreateAdvanceInvoiceForm({
|
|
|
296
350
|
const previousMarkAsPaidRef = useRef(markAsPaid);
|
|
297
351
|
|
|
298
352
|
useEffect(() => {
|
|
299
|
-
if (skipPreferenceInitializedRef.current || furs.isLoading) return;
|
|
353
|
+
if (skipPreferenceInitializedRef.current || furs.isLoading || isEditMode) return;
|
|
300
354
|
|
|
301
355
|
skipPreferenceInitializedRef.current = true;
|
|
302
356
|
if (furs.settings?.default_skip_fiscalization === true) {
|
|
303
357
|
setSkipFiscalization(true);
|
|
304
358
|
}
|
|
305
|
-
}, [furs.isLoading, furs.settings?.default_skip_fiscalization]);
|
|
359
|
+
}, [furs.isLoading, furs.settings?.default_skip_fiscalization, isEditMode]);
|
|
306
360
|
|
|
307
361
|
useEffect(() => {
|
|
308
362
|
const skipJustEnabled = skipFiscalization && !previousSkipFiscalizationRef.current;
|
|
@@ -345,6 +399,10 @@ export default function CreateAdvanceInvoiceForm({
|
|
|
345
399
|
// Update header action with FURS and e-SLOG toggle buttons
|
|
346
400
|
useEffect(() => {
|
|
347
401
|
if (!onHeaderActionChange) return;
|
|
402
|
+
if (isEditMode) {
|
|
403
|
+
onHeaderActionChange(null);
|
|
404
|
+
return;
|
|
405
|
+
}
|
|
348
406
|
|
|
349
407
|
if (furs.isLoading || fina.isLoading) {
|
|
350
408
|
onHeaderActionChange(null);
|
|
@@ -444,6 +502,7 @@ export default function CreateAdvanceInvoiceForm({
|
|
|
444
502
|
eslog.isAvailable,
|
|
445
503
|
eslog.isEnabled,
|
|
446
504
|
eslog.setEnabled,
|
|
505
|
+
isEditMode,
|
|
447
506
|
onHeaderActionChange,
|
|
448
507
|
t,
|
|
449
508
|
]);
|
|
@@ -538,19 +597,22 @@ export default function CreateAdvanceInvoiceForm({
|
|
|
538
597
|
const { data: nextNumberData, isLoading: isNextNumberLoading } = useNextDocumentNumber(entityId, "advance_invoice", {
|
|
539
598
|
businessPremiseName: activePremiseNameForNumber,
|
|
540
599
|
electronicDeviceName: activeDeviceNameForNumber,
|
|
541
|
-
enabled:
|
|
600
|
+
enabled:
|
|
601
|
+
!!entityId && !furs.isLoading && furs.isSelectionReady && !fina.isLoading && fina.isSelectionReady && !isEditMode,
|
|
542
602
|
});
|
|
543
603
|
|
|
544
604
|
// Overall loading state
|
|
545
|
-
const isFormDataLoading =
|
|
546
|
-
|
|
605
|
+
const isFormDataLoading = isEditMode
|
|
606
|
+
? false
|
|
607
|
+
: furs.isLoading || !furs.isSelectionReady || fina.isLoading || !fina.isSelectionReady || isNextNumberLoading;
|
|
547
608
|
|
|
548
609
|
// Pre-fill advance invoice number from preview
|
|
549
610
|
useEffect(() => {
|
|
611
|
+
if (isEditMode) return;
|
|
550
612
|
if (nextNumberData?.number) {
|
|
551
613
|
form.setValue("number", nextNumberData.number);
|
|
552
614
|
}
|
|
553
|
-
}, [nextNumberData?.number, form]);
|
|
615
|
+
}, [nextNumberData?.number, form, isEditMode]);
|
|
554
616
|
|
|
555
617
|
// Auto-populate tax_clause from entity settings when transaction type changes
|
|
556
618
|
const effectiveTransactionType = transactionType ?? "domestic";
|
|
@@ -558,13 +620,14 @@ export default function CreateAdvanceInvoiceForm({
|
|
|
558
620
|
useEffect(() => {
|
|
559
621
|
if (effectiveTransactionType === prevTransactionTypeRef.current) return;
|
|
560
622
|
prevTransactionTypeRef.current = effectiveTransactionType;
|
|
623
|
+
if (isEditMode) return;
|
|
561
624
|
|
|
562
625
|
const taxClauseDefaults = (activeEntity?.settings as any)?.tax_clause_defaults;
|
|
563
626
|
if (!taxClauseDefaults) return;
|
|
564
627
|
|
|
565
628
|
const clause = taxClauseDefaults[effectiveTransactionType] ?? "";
|
|
566
629
|
form.setValue("tax_clause", clause);
|
|
567
|
-
}, [effectiveTransactionType, activeEntity, form]);
|
|
630
|
+
}, [effectiveTransactionType, activeEntity, form, isEditMode]);
|
|
568
631
|
|
|
569
632
|
// Customer form management
|
|
570
633
|
const {
|
|
@@ -587,11 +650,40 @@ export default function CreateAdvanceInvoiceForm({
|
|
|
587
650
|
},
|
|
588
651
|
onError,
|
|
589
652
|
});
|
|
653
|
+
const { mutate: createCustomAdvanceInvoice, isPending: isCreateCustomPending } = useCreateCustomAdvanceInvoice({
|
|
654
|
+
entityId,
|
|
655
|
+
onSuccess: (data) => {
|
|
656
|
+
furs.saveCombo();
|
|
657
|
+
fina.saveCombo();
|
|
658
|
+
onSuccess?.(data);
|
|
659
|
+
},
|
|
660
|
+
onError,
|
|
661
|
+
});
|
|
662
|
+
const { mutate: updateAdvanceInvoice, isPending: isUpdatePending } = useUpdateAdvanceInvoice({
|
|
663
|
+
entityId,
|
|
664
|
+
onSuccess,
|
|
665
|
+
onError,
|
|
666
|
+
});
|
|
590
667
|
|
|
591
668
|
// Shared submit logic for both regular save and save as draft
|
|
592
669
|
const submitAdvanceInvoice = useCallback(
|
|
593
670
|
(values: CreateAdvanceInvoiceFormValues, isDraft: boolean) => {
|
|
594
|
-
if (!isDraft && eslog.isEnabled && eslogEntityErrorsRef.current.length > 0) {
|
|
671
|
+
if (!isEditMode && !isDraft && eslog.isEnabled && eslogEntityErrorsRef.current.length > 0) {
|
|
672
|
+
return;
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
if (isEditMode) {
|
|
676
|
+
if (!documentId) {
|
|
677
|
+
throw new Error("Advance invoice edit mode requires a documentId");
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
const updatePayload = prepareAdvanceInvoiceUpdateSubmission(values, {
|
|
681
|
+
originalCustomer,
|
|
682
|
+
wasCustomerFormShown: showCustomerForm,
|
|
683
|
+
priceModes: priceModesRef.current,
|
|
684
|
+
}) as UpdateAdvanceInvoice;
|
|
685
|
+
|
|
686
|
+
updateAdvanceInvoice({ id: documentId, data: updatePayload });
|
|
595
687
|
return;
|
|
596
688
|
}
|
|
597
689
|
|
|
@@ -634,21 +726,40 @@ export default function CreateAdvanceInvoiceForm({
|
|
|
634
726
|
originalCustomer,
|
|
635
727
|
wasCustomerFormShown: showCustomerForm,
|
|
636
728
|
markAsPaid: isDraft ? false : markAsPaid,
|
|
637
|
-
payments:
|
|
729
|
+
payments: serializePaymentRowsForApi(paymentRows, paymentDocumentTotal, {
|
|
730
|
+
preserveUntouchedAmounts: true,
|
|
731
|
+
}),
|
|
638
732
|
furs: fursOptions,
|
|
639
733
|
fina: finaOptions,
|
|
640
734
|
eslog: eslogOptions,
|
|
641
735
|
priceModes: priceModesRef.current,
|
|
642
736
|
isDraft,
|
|
643
737
|
});
|
|
738
|
+
const preservedExpectedTotalWithTax = getPreservedExpectedTotalWithTax(values);
|
|
739
|
+
if (preservedExpectedTotalWithTax !== undefined) {
|
|
740
|
+
(payload as any).expected_total_with_tax = preservedExpectedTotalWithTax;
|
|
741
|
+
} else {
|
|
742
|
+
delete (payload as any).expected_total_with_tax;
|
|
743
|
+
}
|
|
644
744
|
|
|
645
|
-
|
|
745
|
+
if (customCreateTemplate && financialInputsMatchSource(values)) {
|
|
746
|
+
delete (payload as any).expected_total_with_tax;
|
|
747
|
+
createCustomAdvanceInvoice(applyCustomCreateTemplate(payload as any, customCreateTemplate));
|
|
748
|
+
} else {
|
|
749
|
+
createAdvanceInvoice(payload);
|
|
750
|
+
}
|
|
646
751
|
},
|
|
647
752
|
[
|
|
648
753
|
createAdvanceInvoice,
|
|
754
|
+
createCustomAdvanceInvoice,
|
|
755
|
+
customCreateTemplate,
|
|
756
|
+
documentId,
|
|
649
757
|
eslog,
|
|
650
758
|
furs,
|
|
651
759
|
fina,
|
|
760
|
+
financialInputsMatchSource,
|
|
761
|
+
getPreservedExpectedTotalWithTax,
|
|
762
|
+
isEditMode,
|
|
652
763
|
useFinaNumbering,
|
|
653
764
|
markAsPaid,
|
|
654
765
|
originalCustomer,
|
|
@@ -657,6 +768,7 @@ export default function CreateAdvanceInvoiceForm({
|
|
|
657
768
|
showCustomerForm,
|
|
658
769
|
skipFiscalization,
|
|
659
770
|
operatorPrefill,
|
|
771
|
+
updateAdvanceInvoice,
|
|
660
772
|
],
|
|
661
773
|
);
|
|
662
774
|
|
|
@@ -680,20 +792,22 @@ export default function CreateAdvanceInvoiceForm({
|
|
|
680
792
|
|
|
681
793
|
useFormFooterRegistration({
|
|
682
794
|
formId: "create-advance-invoice-form",
|
|
683
|
-
isPending,
|
|
795
|
+
isPending: isPending || isCreateCustomPending || isUpdatePending,
|
|
684
796
|
isDirty: form.formState.isDirty || !!initialValues,
|
|
685
|
-
label: t("Save"),
|
|
686
|
-
secondaryAction:
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
797
|
+
label: isEditMode ? t("Update") : t("Save"),
|
|
798
|
+
secondaryAction:
|
|
799
|
+
allowDrafts && !isEditMode
|
|
800
|
+
? {
|
|
801
|
+
label: t("Save as Draft"),
|
|
802
|
+
onClick: handleSaveAsDraft,
|
|
803
|
+
isPending: isDraftPending,
|
|
804
|
+
}
|
|
805
|
+
: undefined,
|
|
693
806
|
});
|
|
694
807
|
|
|
695
808
|
// Set default note, footer, and signature from entity settings (advance invoices don't have payment terms)
|
|
696
809
|
useEffect(() => {
|
|
810
|
+
if (isEditMode) return;
|
|
697
811
|
const entityDefaultNote =
|
|
698
812
|
(activeEntity?.settings as any)?.default_advance_invoice_note ||
|
|
699
813
|
(activeEntity?.settings as any)?.default_invoice_note;
|
|
@@ -708,7 +822,7 @@ export default function CreateAdvanceInvoiceForm({
|
|
|
708
822
|
if (entityDefaultSignature && !form.getValues("signature")) {
|
|
709
823
|
form.setValue("signature", entityDefaultSignature);
|
|
710
824
|
}
|
|
711
|
-
}, [activeEntity, form]);
|
|
825
|
+
}, [activeEntity, form, isEditMode]);
|
|
712
826
|
|
|
713
827
|
// Auto-add tax field for tax subject entities
|
|
714
828
|
useEffect(() => {
|
|
@@ -720,28 +834,29 @@ export default function CreateAdvanceInvoiceForm({
|
|
|
720
834
|
}
|
|
721
835
|
}, [activeEntity?.is_tax_subject, form]);
|
|
722
836
|
|
|
723
|
-
const buildPreviewPayload = useCallback(
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
}
|
|
744
|
-
|
|
837
|
+
const buildPreviewPayload = useCallback(
|
|
838
|
+
(values: CreateAdvanceInvoiceFormValues): AdvanceInvoicePreviewPayload => {
|
|
839
|
+
const preservedExpectedTotalWithTax = getPreservedExpectedTotalWithTax(values);
|
|
840
|
+
return {
|
|
841
|
+
number: values.number,
|
|
842
|
+
date: values.date,
|
|
843
|
+
customer_id: values.customer_id,
|
|
844
|
+
customer: values.customer,
|
|
845
|
+
items: prepareDocumentItems(values.items, priceModesRef.current),
|
|
846
|
+
currency_code: values.currency_code,
|
|
847
|
+
reference: values.reference,
|
|
848
|
+
note: values.note,
|
|
849
|
+
tax_clause: values.tax_clause,
|
|
850
|
+
signature: values.signature,
|
|
851
|
+
footer: values.footer,
|
|
852
|
+
...(preservedExpectedTotalWithTax !== undefined
|
|
853
|
+
? { expected_total_with_tax: preservedExpectedTotalWithTax }
|
|
854
|
+
: {}),
|
|
855
|
+
...(normalizePtDocumentInput(values.pt) ? { pt: normalizePtDocumentInput(values.pt) } : {}),
|
|
856
|
+
};
|
|
857
|
+
},
|
|
858
|
+
[getPreservedExpectedTotalWithTax],
|
|
859
|
+
);
|
|
745
860
|
|
|
746
861
|
const emitPreviewPayload = useCallback((payload: AdvanceInvoicePreviewPayload) => {
|
|
747
862
|
const callback = onChangeRef.current;
|
|
@@ -862,7 +977,7 @@ export default function CreateAdvanceInvoiceForm({
|
|
|
862
977
|
t={t}
|
|
863
978
|
locale={locale}
|
|
864
979
|
fursInline={
|
|
865
|
-
furs.isEnabled && furs.hasPremises
|
|
980
|
+
!isEditMode && furs.isEnabled && furs.hasPremises
|
|
866
981
|
? {
|
|
867
982
|
premises: furs.activePremises.map((p) => ({
|
|
868
983
|
id: p.id,
|
|
@@ -881,7 +996,7 @@ export default function CreateAdvanceInvoiceForm({
|
|
|
881
996
|
: undefined
|
|
882
997
|
}
|
|
883
998
|
finaInline={
|
|
884
|
-
useFinaNumbering
|
|
999
|
+
!isEditMode && useFinaNumbering
|
|
885
1000
|
? {
|
|
886
1001
|
premises: fina.activePremises.map((p: any) => ({
|
|
887
1002
|
id: p.id,
|
|
@@ -900,24 +1015,26 @@ export default function CreateAdvanceInvoiceForm({
|
|
|
900
1015
|
}
|
|
901
1016
|
>
|
|
902
1017
|
{/* Mark as paid section (UI-only state, not in form schema) */}
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
1018
|
+
{!isEditMode && (
|
|
1019
|
+
<MarkAsPaidSection
|
|
1020
|
+
checked={markAsPaid}
|
|
1021
|
+
onCheckedChange={(checked) => {
|
|
1022
|
+
setMarkAsPaid(checked);
|
|
1023
|
+
setPaymentValidationMessage(undefined);
|
|
1024
|
+
}}
|
|
1025
|
+
paymentRows={paymentRows}
|
|
1026
|
+
onPaymentRowsChange={(rows) => {
|
|
1027
|
+
setPaymentRows(rows);
|
|
1028
|
+
setPaymentValidationMessage(undefined);
|
|
1029
|
+
}}
|
|
1030
|
+
documentTotal={paymentDocumentTotal}
|
|
1031
|
+
t={t}
|
|
1032
|
+
alwaysShowPaymentType={!!fina.isActive}
|
|
1033
|
+
forced
|
|
1034
|
+
validationMessage={paymentValidationMessage}
|
|
1035
|
+
requireFullPayment
|
|
1036
|
+
/>
|
|
1037
|
+
)}
|
|
921
1038
|
{detailsExtras}
|
|
922
1039
|
</DocumentDetailsSection>
|
|
923
1040
|
</div>
|