@spaceinvoices/react-ui 0.4.12 → 0.4.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/dist/index.js +1 -1
- package/package.json +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 +189 -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 +253 -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 +132 -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 +114 -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 +195 -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 +230 -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 +61 -30
- 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.31");
|
|
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,27 @@ 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),
|
|
265
315
|
}
|
|
266
316
|
: {}),
|
|
267
317
|
}))
|
|
@@ -276,9 +326,12 @@ export default function CreateAdvanceInvoiceForm({
|
|
|
276
326
|
],
|
|
277
327
|
currency_code: initialValues?.currency_code || activeEntity?.currency_code || "EUR",
|
|
278
328
|
reference: (initialValues as any)?.reference ?? "",
|
|
279
|
-
note: initialValues?.note ?? defaultNote,
|
|
280
|
-
tax_clause: "",
|
|
281
|
-
footer: (initialValues as any)?.footer ?? defaultFooter,
|
|
329
|
+
note: initialValues?.note ?? (isEditMode ? "" : defaultNote),
|
|
330
|
+
tax_clause: (initialValues as any)?.tax_clause ?? "",
|
|
331
|
+
footer: (initialValues as any)?.footer ?? (isEditMode ? "" : defaultFooter),
|
|
332
|
+
signature:
|
|
333
|
+
(initialValues as any)?.signature ??
|
|
334
|
+
(isEditMode ? "" : (activeEntity?.settings as any)?.default_document_signature || ""),
|
|
282
335
|
pt: ((initialValues as any)?.pt as PtDocumentInputForm | undefined) ?? undefined,
|
|
283
336
|
},
|
|
284
337
|
});
|
|
@@ -296,13 +349,13 @@ export default function CreateAdvanceInvoiceForm({
|
|
|
296
349
|
const previousMarkAsPaidRef = useRef(markAsPaid);
|
|
297
350
|
|
|
298
351
|
useEffect(() => {
|
|
299
|
-
if (skipPreferenceInitializedRef.current || furs.isLoading) return;
|
|
352
|
+
if (skipPreferenceInitializedRef.current || furs.isLoading || isEditMode) return;
|
|
300
353
|
|
|
301
354
|
skipPreferenceInitializedRef.current = true;
|
|
302
355
|
if (furs.settings?.default_skip_fiscalization === true) {
|
|
303
356
|
setSkipFiscalization(true);
|
|
304
357
|
}
|
|
305
|
-
}, [furs.isLoading, furs.settings?.default_skip_fiscalization]);
|
|
358
|
+
}, [furs.isLoading, furs.settings?.default_skip_fiscalization, isEditMode]);
|
|
306
359
|
|
|
307
360
|
useEffect(() => {
|
|
308
361
|
const skipJustEnabled = skipFiscalization && !previousSkipFiscalizationRef.current;
|
|
@@ -345,6 +398,10 @@ export default function CreateAdvanceInvoiceForm({
|
|
|
345
398
|
// Update header action with FURS and e-SLOG toggle buttons
|
|
346
399
|
useEffect(() => {
|
|
347
400
|
if (!onHeaderActionChange) return;
|
|
401
|
+
if (isEditMode) {
|
|
402
|
+
onHeaderActionChange(null);
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
348
405
|
|
|
349
406
|
if (furs.isLoading || fina.isLoading) {
|
|
350
407
|
onHeaderActionChange(null);
|
|
@@ -444,6 +501,7 @@ export default function CreateAdvanceInvoiceForm({
|
|
|
444
501
|
eslog.isAvailable,
|
|
445
502
|
eslog.isEnabled,
|
|
446
503
|
eslog.setEnabled,
|
|
504
|
+
isEditMode,
|
|
447
505
|
onHeaderActionChange,
|
|
448
506
|
t,
|
|
449
507
|
]);
|
|
@@ -538,19 +596,22 @@ export default function CreateAdvanceInvoiceForm({
|
|
|
538
596
|
const { data: nextNumberData, isLoading: isNextNumberLoading } = useNextDocumentNumber(entityId, "advance_invoice", {
|
|
539
597
|
businessPremiseName: activePremiseNameForNumber,
|
|
540
598
|
electronicDeviceName: activeDeviceNameForNumber,
|
|
541
|
-
enabled:
|
|
599
|
+
enabled:
|
|
600
|
+
!!entityId && !furs.isLoading && furs.isSelectionReady && !fina.isLoading && fina.isSelectionReady && !isEditMode,
|
|
542
601
|
});
|
|
543
602
|
|
|
544
603
|
// Overall loading state
|
|
545
|
-
const isFormDataLoading =
|
|
546
|
-
|
|
604
|
+
const isFormDataLoading = isEditMode
|
|
605
|
+
? false
|
|
606
|
+
: furs.isLoading || !furs.isSelectionReady || fina.isLoading || !fina.isSelectionReady || isNextNumberLoading;
|
|
547
607
|
|
|
548
608
|
// Pre-fill advance invoice number from preview
|
|
549
609
|
useEffect(() => {
|
|
610
|
+
if (isEditMode) return;
|
|
550
611
|
if (nextNumberData?.number) {
|
|
551
612
|
form.setValue("number", nextNumberData.number);
|
|
552
613
|
}
|
|
553
|
-
}, [nextNumberData?.number, form]);
|
|
614
|
+
}, [nextNumberData?.number, form, isEditMode]);
|
|
554
615
|
|
|
555
616
|
// Auto-populate tax_clause from entity settings when transaction type changes
|
|
556
617
|
const effectiveTransactionType = transactionType ?? "domestic";
|
|
@@ -558,13 +619,14 @@ export default function CreateAdvanceInvoiceForm({
|
|
|
558
619
|
useEffect(() => {
|
|
559
620
|
if (effectiveTransactionType === prevTransactionTypeRef.current) return;
|
|
560
621
|
prevTransactionTypeRef.current = effectiveTransactionType;
|
|
622
|
+
if (isEditMode) return;
|
|
561
623
|
|
|
562
624
|
const taxClauseDefaults = (activeEntity?.settings as any)?.tax_clause_defaults;
|
|
563
625
|
if (!taxClauseDefaults) return;
|
|
564
626
|
|
|
565
627
|
const clause = taxClauseDefaults[effectiveTransactionType] ?? "";
|
|
566
628
|
form.setValue("tax_clause", clause);
|
|
567
|
-
}, [effectiveTransactionType, activeEntity, form]);
|
|
629
|
+
}, [effectiveTransactionType, activeEntity, form, isEditMode]);
|
|
568
630
|
|
|
569
631
|
// Customer form management
|
|
570
632
|
const {
|
|
@@ -587,11 +649,40 @@ export default function CreateAdvanceInvoiceForm({
|
|
|
587
649
|
},
|
|
588
650
|
onError,
|
|
589
651
|
});
|
|
652
|
+
const { mutate: createCustomAdvanceInvoice, isPending: isCreateCustomPending } = useCreateCustomAdvanceInvoice({
|
|
653
|
+
entityId,
|
|
654
|
+
onSuccess: (data) => {
|
|
655
|
+
furs.saveCombo();
|
|
656
|
+
fina.saveCombo();
|
|
657
|
+
onSuccess?.(data);
|
|
658
|
+
},
|
|
659
|
+
onError,
|
|
660
|
+
});
|
|
661
|
+
const { mutate: updateAdvanceInvoice, isPending: isUpdatePending } = useUpdateAdvanceInvoice({
|
|
662
|
+
entityId,
|
|
663
|
+
onSuccess,
|
|
664
|
+
onError,
|
|
665
|
+
});
|
|
590
666
|
|
|
591
667
|
// Shared submit logic for both regular save and save as draft
|
|
592
668
|
const submitAdvanceInvoice = useCallback(
|
|
593
669
|
(values: CreateAdvanceInvoiceFormValues, isDraft: boolean) => {
|
|
594
|
-
if (!isDraft && eslog.isEnabled && eslogEntityErrorsRef.current.length > 0) {
|
|
670
|
+
if (!isEditMode && !isDraft && eslog.isEnabled && eslogEntityErrorsRef.current.length > 0) {
|
|
671
|
+
return;
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
if (isEditMode) {
|
|
675
|
+
if (!documentId) {
|
|
676
|
+
throw new Error("Advance invoice edit mode requires a documentId");
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
const updatePayload = prepareAdvanceInvoiceUpdateSubmission(values, {
|
|
680
|
+
originalCustomer,
|
|
681
|
+
wasCustomerFormShown: showCustomerForm,
|
|
682
|
+
priceModes: priceModesRef.current,
|
|
683
|
+
}) as UpdateAdvanceInvoice;
|
|
684
|
+
|
|
685
|
+
updateAdvanceInvoice({ id: documentId, data: updatePayload });
|
|
595
686
|
return;
|
|
596
687
|
}
|
|
597
688
|
|
|
@@ -634,21 +725,40 @@ export default function CreateAdvanceInvoiceForm({
|
|
|
634
725
|
originalCustomer,
|
|
635
726
|
wasCustomerFormShown: showCustomerForm,
|
|
636
727
|
markAsPaid: isDraft ? false : markAsPaid,
|
|
637
|
-
payments:
|
|
728
|
+
payments: serializePaymentRowsForApi(paymentRows, paymentDocumentTotal, {
|
|
729
|
+
preserveUntouchedAmounts: true,
|
|
730
|
+
}),
|
|
638
731
|
furs: fursOptions,
|
|
639
732
|
fina: finaOptions,
|
|
640
733
|
eslog: eslogOptions,
|
|
641
734
|
priceModes: priceModesRef.current,
|
|
642
735
|
isDraft,
|
|
643
736
|
});
|
|
737
|
+
const preservedExpectedTotalWithTax = getPreservedExpectedTotalWithTax(values);
|
|
738
|
+
if (preservedExpectedTotalWithTax !== undefined) {
|
|
739
|
+
(payload as any).expected_total_with_tax = preservedExpectedTotalWithTax;
|
|
740
|
+
} else {
|
|
741
|
+
delete (payload as any).expected_total_with_tax;
|
|
742
|
+
}
|
|
644
743
|
|
|
645
|
-
|
|
744
|
+
if (customCreateTemplate && financialInputsMatchSource(values)) {
|
|
745
|
+
delete (payload as any).expected_total_with_tax;
|
|
746
|
+
createCustomAdvanceInvoice(applyCustomCreateTemplate(payload as any, customCreateTemplate));
|
|
747
|
+
} else {
|
|
748
|
+
createAdvanceInvoice(payload);
|
|
749
|
+
}
|
|
646
750
|
},
|
|
647
751
|
[
|
|
648
752
|
createAdvanceInvoice,
|
|
753
|
+
createCustomAdvanceInvoice,
|
|
754
|
+
customCreateTemplate,
|
|
755
|
+
documentId,
|
|
649
756
|
eslog,
|
|
650
757
|
furs,
|
|
651
758
|
fina,
|
|
759
|
+
financialInputsMatchSource,
|
|
760
|
+
getPreservedExpectedTotalWithTax,
|
|
761
|
+
isEditMode,
|
|
652
762
|
useFinaNumbering,
|
|
653
763
|
markAsPaid,
|
|
654
764
|
originalCustomer,
|
|
@@ -657,6 +767,7 @@ export default function CreateAdvanceInvoiceForm({
|
|
|
657
767
|
showCustomerForm,
|
|
658
768
|
skipFiscalization,
|
|
659
769
|
operatorPrefill,
|
|
770
|
+
updateAdvanceInvoice,
|
|
660
771
|
],
|
|
661
772
|
);
|
|
662
773
|
|
|
@@ -680,20 +791,22 @@ export default function CreateAdvanceInvoiceForm({
|
|
|
680
791
|
|
|
681
792
|
useFormFooterRegistration({
|
|
682
793
|
formId: "create-advance-invoice-form",
|
|
683
|
-
isPending,
|
|
794
|
+
isPending: isPending || isCreateCustomPending || isUpdatePending,
|
|
684
795
|
isDirty: form.formState.isDirty || !!initialValues,
|
|
685
|
-
label: t("Save"),
|
|
686
|
-
secondaryAction:
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
796
|
+
label: isEditMode ? t("Update") : t("Save"),
|
|
797
|
+
secondaryAction:
|
|
798
|
+
allowDrafts && !isEditMode
|
|
799
|
+
? {
|
|
800
|
+
label: t("Save as Draft"),
|
|
801
|
+
onClick: handleSaveAsDraft,
|
|
802
|
+
isPending: isDraftPending,
|
|
803
|
+
}
|
|
804
|
+
: undefined,
|
|
693
805
|
});
|
|
694
806
|
|
|
695
807
|
// Set default note, footer, and signature from entity settings (advance invoices don't have payment terms)
|
|
696
808
|
useEffect(() => {
|
|
809
|
+
if (isEditMode) return;
|
|
697
810
|
const entityDefaultNote =
|
|
698
811
|
(activeEntity?.settings as any)?.default_advance_invoice_note ||
|
|
699
812
|
(activeEntity?.settings as any)?.default_invoice_note;
|
|
@@ -708,7 +821,7 @@ export default function CreateAdvanceInvoiceForm({
|
|
|
708
821
|
if (entityDefaultSignature && !form.getValues("signature")) {
|
|
709
822
|
form.setValue("signature", entityDefaultSignature);
|
|
710
823
|
}
|
|
711
|
-
}, [activeEntity, form]);
|
|
824
|
+
}, [activeEntity, form, isEditMode]);
|
|
712
825
|
|
|
713
826
|
// Auto-add tax field for tax subject entities
|
|
714
827
|
useEffect(() => {
|
|
@@ -720,28 +833,29 @@ export default function CreateAdvanceInvoiceForm({
|
|
|
720
833
|
}
|
|
721
834
|
}, [activeEntity?.is_tax_subject, form]);
|
|
722
835
|
|
|
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
|
-
|
|
836
|
+
const buildPreviewPayload = useCallback(
|
|
837
|
+
(values: CreateAdvanceInvoiceFormValues): AdvanceInvoicePreviewPayload => {
|
|
838
|
+
const preservedExpectedTotalWithTax = getPreservedExpectedTotalWithTax(values);
|
|
839
|
+
return {
|
|
840
|
+
number: values.number,
|
|
841
|
+
date: values.date,
|
|
842
|
+
customer_id: values.customer_id,
|
|
843
|
+
customer: values.customer,
|
|
844
|
+
items: prepareDocumentItems(values.items, priceModesRef.current),
|
|
845
|
+
currency_code: values.currency_code,
|
|
846
|
+
reference: values.reference,
|
|
847
|
+
note: values.note,
|
|
848
|
+
tax_clause: values.tax_clause,
|
|
849
|
+
signature: values.signature,
|
|
850
|
+
footer: values.footer,
|
|
851
|
+
...(preservedExpectedTotalWithTax !== undefined
|
|
852
|
+
? { expected_total_with_tax: preservedExpectedTotalWithTax }
|
|
853
|
+
: {}),
|
|
854
|
+
...(normalizePtDocumentInput(values.pt) ? { pt: normalizePtDocumentInput(values.pt) } : {}),
|
|
855
|
+
};
|
|
856
|
+
},
|
|
857
|
+
[getPreservedExpectedTotalWithTax],
|
|
858
|
+
);
|
|
745
859
|
|
|
746
860
|
const emitPreviewPayload = useCallback((payload: AdvanceInvoicePreviewPayload) => {
|
|
747
861
|
const callback = onChangeRef.current;
|
|
@@ -862,7 +976,7 @@ export default function CreateAdvanceInvoiceForm({
|
|
|
862
976
|
t={t}
|
|
863
977
|
locale={locale}
|
|
864
978
|
fursInline={
|
|
865
|
-
furs.isEnabled && furs.hasPremises
|
|
979
|
+
!isEditMode && furs.isEnabled && furs.hasPremises
|
|
866
980
|
? {
|
|
867
981
|
premises: furs.activePremises.map((p) => ({
|
|
868
982
|
id: p.id,
|
|
@@ -881,7 +995,7 @@ export default function CreateAdvanceInvoiceForm({
|
|
|
881
995
|
: undefined
|
|
882
996
|
}
|
|
883
997
|
finaInline={
|
|
884
|
-
useFinaNumbering
|
|
998
|
+
!isEditMode && useFinaNumbering
|
|
885
999
|
? {
|
|
886
1000
|
premises: fina.activePremises.map((p: any) => ({
|
|
887
1001
|
id: p.id,
|
|
@@ -900,24 +1014,26 @@ export default function CreateAdvanceInvoiceForm({
|
|
|
900
1014
|
}
|
|
901
1015
|
>
|
|
902
1016
|
{/* 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
|
-
|
|
1017
|
+
{!isEditMode && (
|
|
1018
|
+
<MarkAsPaidSection
|
|
1019
|
+
checked={markAsPaid}
|
|
1020
|
+
onCheckedChange={(checked) => {
|
|
1021
|
+
setMarkAsPaid(checked);
|
|
1022
|
+
setPaymentValidationMessage(undefined);
|
|
1023
|
+
}}
|
|
1024
|
+
paymentRows={paymentRows}
|
|
1025
|
+
onPaymentRowsChange={(rows) => {
|
|
1026
|
+
setPaymentRows(rows);
|
|
1027
|
+
setPaymentValidationMessage(undefined);
|
|
1028
|
+
}}
|
|
1029
|
+
documentTotal={paymentDocumentTotal}
|
|
1030
|
+
t={t}
|
|
1031
|
+
alwaysShowPaymentType={!!fina.isActive}
|
|
1032
|
+
forced
|
|
1033
|
+
validationMessage={paymentValidationMessage}
|
|
1034
|
+
requireFullPayment
|
|
1035
|
+
/>
|
|
1036
|
+
)}
|
|
921
1037
|
{detailsExtras}
|
|
922
1038
|
</DocumentDetailsSection>
|
|
923
1039
|
</div>
|