@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
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import type { CreateDeliveryNoteRequest } from "@spaceinvoices/js-sdk";
|
|
2
2
|
import type { CreateDeliveryNoteSchema } from "@/ui/generated/schemas";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
buildDocumentBasePayload,
|
|
5
|
+
cleanupEmptyCustomerId,
|
|
6
|
+
prepareDocumentCustomerData,
|
|
7
|
+
prepareDocumentItems,
|
|
8
|
+
prepareDocumentSubmission,
|
|
9
|
+
} from "../../documents/create/prepare-document-submission";
|
|
4
10
|
import type { CustomerData } from "../../documents/create/use-document-customer-form";
|
|
5
11
|
|
|
6
12
|
/** Map of item index to gross price mode */
|
|
@@ -36,3 +42,30 @@ export function prepareDeliveryNoteSubmission(
|
|
|
36
42
|
...(options.hidePrices !== undefined && { hide_prices: options.hidePrices }),
|
|
37
43
|
};
|
|
38
44
|
}
|
|
45
|
+
|
|
46
|
+
export function prepareDeliveryNoteUpdateSubmission(
|
|
47
|
+
values: CreateDeliveryNoteSchema,
|
|
48
|
+
options: Pick<PrepareOptions, "originalCustomer" | "priceModes" | "hidePrices">,
|
|
49
|
+
): Record<string, unknown> {
|
|
50
|
+
const nextValues: any = {
|
|
51
|
+
...values,
|
|
52
|
+
customer: values.customer ? { ...values.customer } : values.customer,
|
|
53
|
+
items: values.items
|
|
54
|
+
? values.items.map((item: any) => ({ ...item, taxes: item?.taxes ? [...item.taxes] : item?.taxes }))
|
|
55
|
+
: values.items,
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
prepareDocumentCustomerData(nextValues, {
|
|
59
|
+
originalCustomer: options.originalCustomer,
|
|
60
|
+
wasCustomerFormShown: true,
|
|
61
|
+
});
|
|
62
|
+
cleanupEmptyCustomerId(nextValues);
|
|
63
|
+
nextValues.items = prepareDocumentItems(nextValues.items, options.priceModes ?? {});
|
|
64
|
+
|
|
65
|
+
return {
|
|
66
|
+
...buildDocumentBasePayload(nextValues, {
|
|
67
|
+
documentType: "delivery_note",
|
|
68
|
+
}),
|
|
69
|
+
...(options.hidePrices !== undefined ? { hide_prices: options.hidePrices } : {}),
|
|
70
|
+
};
|
|
71
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
CreateDeliveryNoteRequest,
|
|
3
|
+
CustomCreateDeliveryNote,
|
|
3
4
|
DeliveryNote,
|
|
4
5
|
SDKMethodOptions,
|
|
5
6
|
UpdateDeliveryNote,
|
|
@@ -29,4 +30,17 @@ const {
|
|
|
29
30
|
DELIVERY_NOTES_CACHE_KEY,
|
|
30
31
|
);
|
|
31
32
|
|
|
32
|
-
|
|
33
|
+
const { useCreateResource: useCreateCustomDeliveryNote } = createResourceHooks<
|
|
34
|
+
DeliveryNote,
|
|
35
|
+
CustomCreateDeliveryNote,
|
|
36
|
+
UpdateDeliveryNote
|
|
37
|
+
>(
|
|
38
|
+
{
|
|
39
|
+
create: deliveryNotes.createCustom,
|
|
40
|
+
update: deliveryNotes.update,
|
|
41
|
+
delete: voidDeliveryNote,
|
|
42
|
+
},
|
|
43
|
+
DELIVERY_NOTES_CACHE_KEY,
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
export { useCreateCustomDeliveryNote, useCreateDeliveryNote, useDeleteDeliveryNote, useUpdateDeliveryNote };
|
|
@@ -15,6 +15,7 @@ import type {
|
|
|
15
15
|
} from "@/ui/components/table/types";
|
|
16
16
|
import { Badge } from "@/ui/components/ui/badge";
|
|
17
17
|
import { Button } from "@/ui/components/ui/button";
|
|
18
|
+
import { getDisplayDocumentNumber } from "@/ui/lib/document-display";
|
|
18
19
|
import { createTranslation } from "@/ui/lib/translation";
|
|
19
20
|
|
|
20
21
|
import DeliveryNoteListRowActions from "./list-row-actions";
|
|
@@ -180,7 +181,7 @@ export default function DeliveryNoteListTable({
|
|
|
180
181
|
cell: (deliveryNote) => (
|
|
181
182
|
<div className="flex items-center gap-2">
|
|
182
183
|
<Button variant="link" className="cursor-pointer py-0 underline" onClick={() => onRowClick?.(deliveryNote)}>
|
|
183
|
-
{deliveryNote
|
|
184
|
+
{getDisplayDocumentNumber(deliveryNote as DeliveryNote & { is_draft?: boolean }, t)}
|
|
184
185
|
</Button>
|
|
185
186
|
{(deliveryNote as any).is_draft && (
|
|
186
187
|
<Badge
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
type CustomCreateTemplate = {
|
|
2
|
+
items: any[];
|
|
3
|
+
total: number;
|
|
4
|
+
total_with_tax: number;
|
|
5
|
+
total_discount?: number | null;
|
|
6
|
+
taxes?: any[];
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
function round2(value: number): number {
|
|
10
|
+
return Math.round(value * 100) / 100;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function sanitizeItemTaxes(taxes: any[] | undefined): any[] {
|
|
14
|
+
return (taxes ?? []).map((tax) => ({
|
|
15
|
+
tax_id: tax?.tax_id ?? undefined,
|
|
16
|
+
rate: tax?.rate ?? undefined,
|
|
17
|
+
classification: tax?.classification ?? undefined,
|
|
18
|
+
reverse_charge: tax?.reverse_charge ?? false,
|
|
19
|
+
pt_exemption_code: tax?.pt_exemption_code ?? undefined,
|
|
20
|
+
pt_exemption_reason: tax?.pt_exemption_reason ?? undefined,
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function sanitizeDiscounts(discounts: any[] | undefined): any[] {
|
|
25
|
+
return (discounts ?? []).map((discount) => ({
|
|
26
|
+
value: discount?.value,
|
|
27
|
+
type: discount?.type ?? undefined,
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function getTaxIdentityKey(tax: any): string {
|
|
32
|
+
return JSON.stringify({
|
|
33
|
+
rate: tax?.rate ?? null,
|
|
34
|
+
reverse_charge: tax?.reverse_charge ?? false,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function collectResolvedItemTaxIds(items: any[] | undefined): Map<string, Set<string>> {
|
|
39
|
+
const taxIdsByKey = new Map<string, Set<string>>();
|
|
40
|
+
|
|
41
|
+
for (const item of items ?? []) {
|
|
42
|
+
if (item?.type === "separator") continue;
|
|
43
|
+
|
|
44
|
+
for (const tax of item?.taxes ?? []) {
|
|
45
|
+
if (!tax?.tax_id) continue;
|
|
46
|
+
|
|
47
|
+
const key = getTaxIdentityKey(tax);
|
|
48
|
+
const existing = taxIdsByKey.get(key);
|
|
49
|
+
if (existing) {
|
|
50
|
+
existing.add(tax.tax_id);
|
|
51
|
+
} else {
|
|
52
|
+
taxIdsByKey.set(key, new Set([tax.tax_id]));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return taxIdsByKey;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function toCustomCreateItem(item: any): any {
|
|
61
|
+
if (item?.type === "separator") {
|
|
62
|
+
return {
|
|
63
|
+
type: "separator",
|
|
64
|
+
name: item?.name,
|
|
65
|
+
description: item?.description ?? undefined,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return {
|
|
70
|
+
type: item?.type ?? undefined,
|
|
71
|
+
item_id: item?.item_id ?? undefined,
|
|
72
|
+
name: item?.name,
|
|
73
|
+
description: item?.description ?? undefined,
|
|
74
|
+
classification: item?.classification ?? undefined,
|
|
75
|
+
price: item?.price ?? undefined,
|
|
76
|
+
gross_price: item?.gross_price ?? undefined,
|
|
77
|
+
quantity: item?.quantity ?? undefined,
|
|
78
|
+
unit: item?.unit ?? undefined,
|
|
79
|
+
taxes: sanitizeItemTaxes(item?.taxes),
|
|
80
|
+
discounts: sanitizeDiscounts(item?.discounts),
|
|
81
|
+
total: item?.total ?? undefined,
|
|
82
|
+
total_with_tax: item?.total_with_tax ?? undefined,
|
|
83
|
+
metadata: item?.metadata ?? undefined,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function sanitizeSummaryTaxes(taxes: any[] | undefined, items?: any[]): any[] {
|
|
88
|
+
const resolvedItemTaxIds = collectResolvedItemTaxIds(items);
|
|
89
|
+
|
|
90
|
+
return (taxes ?? []).map((tax) => ({
|
|
91
|
+
tax_id:
|
|
92
|
+
tax?.tax_id ??
|
|
93
|
+
(() => {
|
|
94
|
+
const candidates = resolvedItemTaxIds.get(getTaxIdentityKey(tax));
|
|
95
|
+
if (!candidates || candidates.size !== 1) return undefined;
|
|
96
|
+
return Array.from(candidates)[0];
|
|
97
|
+
})(),
|
|
98
|
+
rate: tax?.rate ?? null,
|
|
99
|
+
base: tax?.base ?? 0,
|
|
100
|
+
amount: tax?.amount ?? 0,
|
|
101
|
+
reverse_charge: tax?.reverse_charge ?? false,
|
|
102
|
+
}));
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function getSummaryTaxKey(tax: any): string {
|
|
106
|
+
return JSON.stringify({
|
|
107
|
+
tax_id: tax?.tax_id ?? null,
|
|
108
|
+
rate: tax?.rate ?? null,
|
|
109
|
+
reverse_charge: tax?.reverse_charge ?? false,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export function sumSummaryTaxes(documents: Array<{ taxes?: any[]; items?: any[] }>): any[] {
|
|
114
|
+
const aggregated = new Map<string, any>();
|
|
115
|
+
|
|
116
|
+
for (const document of documents) {
|
|
117
|
+
for (const tax of sanitizeSummaryTaxes(document.taxes, document.items)) {
|
|
118
|
+
const key = getSummaryTaxKey(tax);
|
|
119
|
+
const existing = aggregated.get(key);
|
|
120
|
+
if (existing) {
|
|
121
|
+
existing.base = round2(existing.base + tax.base);
|
|
122
|
+
existing.amount = round2(existing.amount + tax.amount);
|
|
123
|
+
} else {
|
|
124
|
+
aggregated.set(key, { ...tax });
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return Array.from(aggregated.values());
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export function buildCustomCreateTemplateFromDocument(document: any): CustomCreateTemplate {
|
|
133
|
+
return {
|
|
134
|
+
items: (document?.items ?? []).map(toCustomCreateItem),
|
|
135
|
+
total: document?.total ?? 0,
|
|
136
|
+
total_with_tax: document?.total_with_tax ?? 0,
|
|
137
|
+
total_discount: document?.total_discount ?? 0,
|
|
138
|
+
taxes: sanitizeSummaryTaxes(document?.taxes, document?.items),
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export function applyCustomCreateTemplate<T extends Record<string, any>>(payload: T, template: CustomCreateTemplate): T {
|
|
143
|
+
return {
|
|
144
|
+
...payload,
|
|
145
|
+
items: template.items,
|
|
146
|
+
total: template.total,
|
|
147
|
+
total_with_tax: template.total_with_tax,
|
|
148
|
+
total_discount: template.total_discount ?? 0,
|
|
149
|
+
taxes: template.taxes ?? [],
|
|
150
|
+
};
|
|
151
|
+
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { Item } from "@spaceinvoices/js-sdk";
|
|
2
2
|
import { ChevronDown, ChevronUp, DollarSign, Minus, Percent, Plus, PlusIcon, Trash2 } from "lucide-react";
|
|
3
3
|
import { useEffect, useState } from "react";
|
|
4
|
-
import type { Control, UseFormReturn } from "react-hook-form";
|
|
5
4
|
import { useWatch } from "react-hook-form";
|
|
6
5
|
|
|
7
6
|
import { ItemCombobox } from "@/ui/components/items/item-combobox";
|
|
@@ -25,7 +24,7 @@ import DocumentAddItemTaxRateField from "./document-add-item-tax-rate-field";
|
|
|
25
24
|
|
|
26
25
|
type DocumentAddItemFormProps = {
|
|
27
26
|
index: number;
|
|
28
|
-
control:
|
|
27
|
+
control: any;
|
|
29
28
|
documentType?: "invoice" | "estimate" | "credit_note" | "advance_invoice" | "delivery_note";
|
|
30
29
|
entityId: string;
|
|
31
30
|
currencyCode?: string;
|
|
@@ -36,7 +35,7 @@ type DocumentAddItemFormProps = {
|
|
|
36
35
|
showRemove: boolean;
|
|
37
36
|
showMoveUp: boolean;
|
|
38
37
|
showMoveDown: boolean;
|
|
39
|
-
form:
|
|
38
|
+
form: any;
|
|
40
39
|
t: (key: string) => string;
|
|
41
40
|
/** When true, tax controls are disabled (e.g., for VIES reverse charge) */
|
|
42
41
|
taxesDisabled?: boolean;
|
|
@@ -216,7 +215,7 @@ export default function DocumentAddItemForm({
|
|
|
216
215
|
<FormItem>
|
|
217
216
|
<FormLabel className="text-muted-foreground text-xs">{t("Section header")}</FormLabel>
|
|
218
217
|
<FormControl>
|
|
219
|
-
<Input placeholder={t("Section title...")} {...field} />
|
|
218
|
+
<Input placeholder={t("Section title...")} {...field} value={field.value ?? ""} />
|
|
220
219
|
</FormControl>
|
|
221
220
|
<FormMessage />
|
|
222
221
|
</FormItem>
|
|
@@ -240,7 +239,7 @@ export default function DocumentAddItemForm({
|
|
|
240
239
|
render={({ field }) => (
|
|
241
240
|
<FormItem>
|
|
242
241
|
<FormControl>
|
|
243
|
-
<Textarea placeholder={t("Description")} {...field} />
|
|
242
|
+
<Textarea placeholder={t("Description")} {...field} value={field.value ?? ""} />
|
|
244
243
|
</FormControl>
|
|
245
244
|
<FormMessage />
|
|
246
245
|
</FormItem>
|
|
@@ -280,7 +279,7 @@ export default function DocumentAddItemForm({
|
|
|
280
279
|
<FormControl>
|
|
281
280
|
<ItemCombobox
|
|
282
281
|
entityId={entityId}
|
|
283
|
-
value={field.value}
|
|
282
|
+
value={field.value ?? ""}
|
|
284
283
|
onSelect={handleItemSelect}
|
|
285
284
|
onCommitInlineName={setInlineItemName}
|
|
286
285
|
onInlineInputChange={setInlineItemName}
|
|
@@ -430,7 +429,7 @@ export default function DocumentAddItemForm({
|
|
|
430
429
|
<FormItem className="col-span-1 lg:col-span-2">
|
|
431
430
|
<FormLabel>{t("Unit")}</FormLabel>
|
|
432
431
|
<FormControl>
|
|
433
|
-
<Input {...field} disabled={lockPortugalSavedItemFields} />
|
|
432
|
+
<Input {...field} value={field.value ?? ""} disabled={lockPortugalSavedItemFields} />
|
|
434
433
|
</FormControl>
|
|
435
434
|
<FormMessage />
|
|
436
435
|
</FormItem>
|
|
@@ -542,7 +541,12 @@ export default function DocumentAddItemForm({
|
|
|
542
541
|
render={({ field }) => (
|
|
543
542
|
<FormItem>
|
|
544
543
|
<FormControl>
|
|
545
|
-
<Textarea
|
|
544
|
+
<Textarea
|
|
545
|
+
placeholder={t("Description")}
|
|
546
|
+
{...field}
|
|
547
|
+
value={field.value ?? ""}
|
|
548
|
+
disabled={lockPortugalSavedItemFields}
|
|
549
|
+
/>
|
|
546
550
|
</FormControl>
|
|
547
551
|
<FormMessage />
|
|
548
552
|
</FormItem>
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { Tax } from "@spaceinvoices/js-sdk";
|
|
2
2
|
import { Plus, Trash2 } from "lucide-react";
|
|
3
3
|
import { useEffect } from "react";
|
|
4
|
-
import type { Control } from "react-hook-form";
|
|
5
4
|
import { useFormContext, useWatch } from "react-hook-form";
|
|
6
5
|
import { Button } from "@/ui/components/ui/button";
|
|
7
6
|
import { FormControl, FormField, FormItem, FormLabel, FormMessage } from "@/ui/components/ui/form";
|
|
@@ -36,7 +35,7 @@ function getCurrentRate(tax: Tax): number {
|
|
|
36
35
|
type DocumentAddItemTaxRateFieldProps = {
|
|
37
36
|
index: number;
|
|
38
37
|
taxIndex: number;
|
|
39
|
-
control:
|
|
38
|
+
control: any;
|
|
40
39
|
entityId: string;
|
|
41
40
|
onRemove: () => void;
|
|
42
41
|
onAddNewTax?: () => void;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { normalizeDateOnlyInput } from "../../../lib/date-only";
|
|
3
|
+
|
|
4
|
+
type DocumentDateValues = {
|
|
5
|
+
date?: string | null;
|
|
6
|
+
date_due?: string | null;
|
|
7
|
+
date_valid_till?: string | null;
|
|
8
|
+
date_service?: string | null;
|
|
9
|
+
date_service_to?: string | null;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const messages = {
|
|
13
|
+
dateInFuture: "Document date cannot be in the future.",
|
|
14
|
+
serviceDateAfterIssueDate: "Service date cannot be later than the issue date.",
|
|
15
|
+
serviceDateToAfterIssueDate: "Service period end date cannot be later than the issue date.",
|
|
16
|
+
serviceDateToBeforeServiceDate: "Service period end date must be on or after the service start date.",
|
|
17
|
+
dueDateBeforeIssueDate: "Due date must be on or after the issue date.",
|
|
18
|
+
validTillBeforeIssueDate: "Valid until date must be on or after the issue date.",
|
|
19
|
+
} as const;
|
|
20
|
+
|
|
21
|
+
function compareDateOnly(left: string, right: string): number {
|
|
22
|
+
if (left === right) return 0;
|
|
23
|
+
return left < right ? -1 : 1;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function getTodayDateOnly(): string {
|
|
27
|
+
return normalizeDateOnlyInput(new Date().toISOString()) ?? "";
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function addCustomIssue(
|
|
31
|
+
ctx: z.RefinementCtx,
|
|
32
|
+
path: string[],
|
|
33
|
+
message: string,
|
|
34
|
+
condition: boolean,
|
|
35
|
+
) {
|
|
36
|
+
if (!condition) return;
|
|
37
|
+
|
|
38
|
+
ctx.addIssue({
|
|
39
|
+
code: z.ZodIssueCode.custom,
|
|
40
|
+
path,
|
|
41
|
+
message,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function applyBaseDocumentDateRules(value: DocumentDateValues, ctx: z.RefinementCtx) {
|
|
46
|
+
const date = normalizeDateOnlyInput(value.date ?? undefined);
|
|
47
|
+
addCustomIssue(ctx, ["date"], messages.dateInFuture, !!date && compareDateOnly(date, getTodayDateOnly()) > 0);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function applyInvoiceLikeServiceDateRules(value: DocumentDateValues, ctx: z.RefinementCtx) {
|
|
51
|
+
const date = normalizeDateOnlyInput(value.date ?? undefined);
|
|
52
|
+
const dateService = normalizeDateOnlyInput(value.date_service ?? undefined);
|
|
53
|
+
const dateServiceTo = normalizeDateOnlyInput(value.date_service_to ?? undefined);
|
|
54
|
+
|
|
55
|
+
addCustomIssue(
|
|
56
|
+
ctx,
|
|
57
|
+
["date_service"],
|
|
58
|
+
messages.serviceDateAfterIssueDate,
|
|
59
|
+
!!date && !!dateService && compareDateOnly(dateService, date) > 0,
|
|
60
|
+
);
|
|
61
|
+
addCustomIssue(
|
|
62
|
+
ctx,
|
|
63
|
+
["date_service_to"],
|
|
64
|
+
messages.serviceDateToAfterIssueDate,
|
|
65
|
+
!!date && !!dateServiceTo && compareDateOnly(dateServiceTo, date) > 0,
|
|
66
|
+
);
|
|
67
|
+
addCustomIssue(
|
|
68
|
+
ctx,
|
|
69
|
+
["date_service_to"],
|
|
70
|
+
messages.serviceDateToBeforeServiceDate,
|
|
71
|
+
!!dateService && !!dateServiceTo && compareDateOnly(dateServiceTo, dateService) < 0,
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function withInvoiceIssueDateValidation<T extends z.ZodTypeAny>(schema: T) {
|
|
76
|
+
return schema.superRefine((value, ctx) => {
|
|
77
|
+
const document = value as DocumentDateValues;
|
|
78
|
+
applyBaseDocumentDateRules(document, ctx);
|
|
79
|
+
applyInvoiceLikeServiceDateRules(document, ctx);
|
|
80
|
+
|
|
81
|
+
const date = normalizeDateOnlyInput(document.date ?? undefined);
|
|
82
|
+
const dateDue = normalizeDateOnlyInput(document.date_due ?? undefined);
|
|
83
|
+
|
|
84
|
+
addCustomIssue(ctx, ["date_due"], messages.dueDateBeforeIssueDate, !!date && !!dateDue && compareDateOnly(dateDue, date) < 0);
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export function withCreditNoteIssueDateValidation<T extends z.ZodTypeAny>(schema: T) {
|
|
89
|
+
return schema.superRefine((value, ctx) => {
|
|
90
|
+
const document = value as DocumentDateValues;
|
|
91
|
+
applyBaseDocumentDateRules(document, ctx);
|
|
92
|
+
applyInvoiceLikeServiceDateRules(document, ctx);
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export function withEstimateIssueDateValidation<T extends z.ZodTypeAny>(schema: T) {
|
|
97
|
+
return schema.superRefine((value, ctx) => {
|
|
98
|
+
const document = value as DocumentDateValues;
|
|
99
|
+
applyBaseDocumentDateRules(document, ctx);
|
|
100
|
+
|
|
101
|
+
const date = normalizeDateOnlyInput(document.date ?? undefined);
|
|
102
|
+
const validTill = normalizeDateOnlyInput(document.date_valid_till ?? undefined);
|
|
103
|
+
|
|
104
|
+
addCustomIssue(
|
|
105
|
+
ctx,
|
|
106
|
+
["date_valid_till"],
|
|
107
|
+
messages.validTillBeforeIssueDate,
|
|
108
|
+
!!date && !!validTill && compareDateOnly(validTill, date) < 0,
|
|
109
|
+
);
|
|
110
|
+
});
|
|
111
|
+
}
|