@voyant-travel/finance-react 0.119.5
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/LICENSE +201 -0
- package/README.md +75 -0
- package/dist/admin/booking-invoices-widget.d.ts +19 -0
- package/dist/admin/booking-invoices-widget.d.ts.map +1 -0
- package/dist/admin/booking-invoices-widget.js +204 -0
- package/dist/admin/booking-payment-policy-widget.d.ts +21 -0
- package/dist/admin/booking-payment-policy-widget.d.ts.map +1 -0
- package/dist/admin/booking-payment-policy-widget.js +128 -0
- package/dist/admin/booking-pending-payment-sessions-widget.d.ts +24 -0
- package/dist/admin/booking-pending-payment-sessions-widget.d.ts.map +1 -0
- package/dist/admin/booking-pending-payment-sessions-widget.js +139 -0
- package/dist/admin/credit-note-dialog.d.ts +9 -0
- package/dist/admin/credit-note-dialog.d.ts.map +1 -0
- package/dist/admin/credit-note-dialog.js +70 -0
- package/dist/admin/finance-shared.d.ts +7 -0
- package/dist/admin/finance-shared.d.ts.map +1 -0
- package/dist/admin/finance-shared.js +30 -0
- package/dist/admin/index.d.ts +99 -0
- package/dist/admin/index.d.ts.map +1 -0
- package/dist/admin/index.js +286 -0
- package/dist/admin/invoice-detail-host.d.ts +19 -0
- package/dist/admin/invoice-detail-host.d.ts.map +1 -0
- package/dist/admin/invoice-detail-host.js +147 -0
- package/dist/admin/invoice-detail-sections.d.ts +31 -0
- package/dist/admin/invoice-detail-sections.d.ts.map +1 -0
- package/dist/admin/invoice-detail-sections.js +109 -0
- package/dist/admin/invoice-detail-skeleton.d.ts +11 -0
- package/dist/admin/invoice-detail-skeleton.d.ts.map +1 -0
- package/dist/admin/invoice-detail-skeleton.js +33 -0
- package/dist/admin/line-item-dialog.d.ts +10 -0
- package/dist/admin/line-item-dialog.d.ts.map +1 -0
- package/dist/admin/line-item-dialog.js +91 -0
- package/dist/admin/pages/invoice-detail.d.ts +8 -0
- package/dist/admin/pages/invoice-detail.d.ts.map +1 -0
- package/dist/admin/pages/invoice-detail.js +11 -0
- package/dist/admin/pages/invoices-index.d.ts +8 -0
- package/dist/admin/pages/invoices-index.d.ts.map +1 -0
- package/dist/admin/pages/invoices-index.js +14 -0
- package/dist/admin/pages/payment-detail.d.ts +8 -0
- package/dist/admin/pages/payment-detail.d.ts.map +1 -0
- package/dist/admin/pages/payment-detail.js +11 -0
- package/dist/admin/pages/payments-index.d.ts +9 -0
- package/dist/admin/pages/payments-index.d.ts.map +1 -0
- package/dist/admin/pages/payments-index.js +21 -0
- package/dist/admin/pages/profitability.d.ts +10 -0
- package/dist/admin/pages/profitability.d.ts.map +1 -0
- package/dist/admin/pages/profitability.js +32 -0
- package/dist/admin/pages/supplier-invoice-detail.d.ts +20 -0
- package/dist/admin/pages/supplier-invoice-detail.d.ts.map +1 -0
- package/dist/admin/pages/supplier-invoice-detail.js +102 -0
- package/dist/admin/pages/supplier-invoices-index.d.ts +9 -0
- package/dist/admin/pages/supplier-invoices-index.d.ts.map +1 -0
- package/dist/admin/pages/supplier-invoices-index.js +16 -0
- package/dist/admin/payment-detail-host.d.ts +12 -0
- package/dist/admin/payment-detail-host.d.ts.map +1 -0
- package/dist/admin/payment-detail-host.js +108 -0
- package/dist/admin/payment-detail-skeleton.d.ts +8 -0
- package/dist/admin/payment-detail-skeleton.d.ts.map +1 -0
- package/dist/admin/payment-detail-skeleton.js +15 -0
- package/dist/admin/payment-dialog.d.ts +9 -0
- package/dist/admin/payment-dialog.d.ts.map +1 -0
- package/dist/admin/payment-dialog.js +99 -0
- package/dist/admin/record-payment-dialog.d.ts +16 -0
- package/dist/admin/record-payment-dialog.d.ts.map +1 -0
- package/dist/admin/record-payment-dialog.js +219 -0
- package/dist/admin/supplier-payment-policy-widget.d.ts +18 -0
- package/dist/admin/supplier-payment-policy-widget.d.ts.map +1 -0
- package/dist/admin/supplier-payment-policy-widget.js +31 -0
- package/dist/admin/use-supplier-picker.d.ts +19 -0
- package/dist/admin/use-supplier-picker.d.ts.map +1 -0
- package/dist/admin/use-supplier-picker.js +30 -0
- package/dist/checkout-components/collect-payment-dialog.d.ts +45 -0
- package/dist/checkout-components/collect-payment-dialog.d.ts.map +1 -0
- package/dist/checkout-components/collect-payment-dialog.js +121 -0
- package/dist/checkout-components/payment-link-landing-page.d.ts +76 -0
- package/dist/checkout-components/payment-link-landing-page.d.ts.map +1 -0
- package/dist/checkout-components/payment-link-landing-page.js +173 -0
- package/dist/checkout-components/payment-step.d.ts +42 -0
- package/dist/checkout-components/payment-step.d.ts.map +1 -0
- package/dist/checkout-components/payment-step.js +113 -0
- package/dist/checkout-hooks/index.d.ts +5 -0
- package/dist/checkout-hooks/index.d.ts.map +1 -0
- package/dist/checkout-hooks/index.js +4 -0
- package/dist/checkout-hooks/use-checkout-payment-link-config.d.ts +20 -0
- package/dist/checkout-hooks/use-checkout-payment-link-config.d.ts.map +1 -0
- package/dist/checkout-hooks/use-checkout-payment-link-config.js +26 -0
- package/dist/checkout-hooks/use-collect-payment.d.ts +227 -0
- package/dist/checkout-hooks/use-collect-payment.d.ts.map +1 -0
- package/dist/checkout-hooks/use-collect-payment.js +80 -0
- package/dist/checkout-hooks/use-initiate-checkout-collection.d.ts +308 -0
- package/dist/checkout-hooks/use-initiate-checkout-collection.d.ts.map +1 -0
- package/dist/checkout-hooks/use-initiate-checkout-collection.js +35 -0
- package/dist/checkout-hooks/use-preview-checkout-collection.d.ts +65 -0
- package/dist/checkout-hooks/use-preview-checkout-collection.d.ts.map +1 -0
- package/dist/checkout-hooks/use-preview-checkout-collection.js +27 -0
- package/dist/checkout-i18n/en.d.ts +3 -0
- package/dist/checkout-i18n/en.d.ts.map +1 -0
- package/dist/checkout-i18n/en.js +127 -0
- package/dist/checkout-i18n/index.d.ts +5 -0
- package/dist/checkout-i18n/index.d.ts.map +1 -0
- package/dist/checkout-i18n/index.js +3 -0
- package/dist/checkout-i18n/messages.d.ts +121 -0
- package/dist/checkout-i18n/messages.d.ts.map +1 -0
- package/dist/checkout-i18n/messages.js +1 -0
- package/dist/checkout-i18n/provider.d.ts +26 -0
- package/dist/checkout-i18n/provider.d.ts.map +1 -0
- package/dist/checkout-i18n/provider.js +41 -0
- package/dist/checkout-i18n/ro.d.ts +3 -0
- package/dist/checkout-i18n/ro.d.ts.map +1 -0
- package/dist/checkout-i18n/ro.js +127 -0
- package/dist/checkout-types.d.ts +53 -0
- package/dist/checkout-types.d.ts.map +1 -0
- package/dist/checkout-types.js +1 -0
- package/dist/checkout-ui.d.ts +7 -0
- package/dist/checkout-ui.d.ts.map +1 -0
- package/dist/checkout-ui.js +4 -0
- package/dist/checkout.d.ts +5 -0
- package/dist/checkout.d.ts.map +1 -0
- package/dist/checkout.js +3 -0
- package/dist/client.d.ts +16 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +79 -0
- package/dist/components/accountant-portal/body.d.ts +8 -0
- package/dist/components/accountant-portal/body.d.ts.map +1 -0
- package/dist/components/accountant-portal/body.js +114 -0
- package/dist/components/accountant-portal/widgets.d.ts +13 -0
- package/dist/components/accountant-portal/widgets.d.ts.map +1 -0
- package/dist/components/accountant-portal/widgets.js +27 -0
- package/dist/components/accountant-portal.d.ts +10 -0
- package/dist/components/accountant-portal.d.ts.map +1 -0
- package/dist/components/accountant-portal.js +22 -0
- package/dist/components/accountant-share-dialog.d.ts +6 -0
- package/dist/components/accountant-share-dialog.d.ts.map +1 -0
- package/dist/components/accountant-share-dialog.js +53 -0
- package/dist/components/async-combobox.d.ts +33 -0
- package/dist/components/async-combobox.d.ts.map +1 -0
- package/dist/components/async-combobox.js +100 -0
- package/dist/components/booking-invoice-dialog.d.ts +63 -0
- package/dist/components/booking-invoice-dialog.d.ts.map +1 -0
- package/dist/components/booking-invoice-dialog.js +383 -0
- package/dist/components/cost-categories-page.d.ts +5 -0
- package/dist/components/cost-categories-page.d.ts.map +1 -0
- package/dist/components/cost-categories-page.js +30 -0
- package/dist/components/invoice-action-ledger-card.d.ts +15 -0
- package/dist/components/invoice-action-ledger-card.d.ts.map +1 -0
- package/dist/components/invoice-action-ledger-card.js +76 -0
- package/dist/components/invoice-bulk-actions.d.ts +10 -0
- package/dist/components/invoice-bulk-actions.d.ts.map +1 -0
- package/dist/components/invoice-bulk-actions.js +19 -0
- package/dist/components/invoice-detail-page/cards.d.ts +44 -0
- package/dist/components/invoice-detail-page/cards.d.ts.map +1 -0
- package/dist/components/invoice-detail-page/cards.js +43 -0
- package/dist/components/invoice-detail-page/header.d.ts +15 -0
- package/dist/components/invoice-detail-page/header.d.ts.map +1 -0
- package/dist/components/invoice-detail-page/header.js +30 -0
- package/dist/components/invoice-detail-page/notes-dialogs.d.ts +28 -0
- package/dist/components/invoice-detail-page/notes-dialogs.d.ts.map +1 -0
- package/dist/components/invoice-detail-page/notes-dialogs.js +104 -0
- package/dist/components/invoice-detail-page/primitives.d.ts +47 -0
- package/dist/components/invoice-detail-page/primitives.d.ts.map +1 -0
- package/dist/components/invoice-detail-page/primitives.js +76 -0
- package/dist/components/invoice-detail-page-with-action-ledger.d.ts +7 -0
- package/dist/components/invoice-detail-page-with-action-ledger.d.ts.map +1 -0
- package/dist/components/invoice-detail-page-with-action-ledger.js +11 -0
- package/dist/components/invoice-detail-page.d.ts +46 -0
- package/dist/components/invoice-detail-page.d.ts.map +1 -0
- package/dist/components/invoice-detail-page.js +134 -0
- package/dist/components/invoice-dialog.d.ts +9 -0
- package/dist/components/invoice-dialog.d.ts.map +1 -0
- package/dist/components/invoice-dialog.js +145 -0
- package/dist/components/invoice-number-series-dialog.d.ts +9 -0
- package/dist/components/invoice-number-series-dialog.d.ts.map +1 -0
- package/dist/components/invoice-number-series-dialog.js +134 -0
- package/dist/components/invoice-number-series-format.d.ts +3 -0
- package/dist/components/invoice-number-series-format.d.ts.map +1 -0
- package/dist/components/invoice-number-series-format.js +4 -0
- package/dist/components/invoice-number-series-page.d.ts +5 -0
- package/dist/components/invoice-number-series-page.d.ts.map +1 -0
- package/dist/components/invoice-number-series-page.js +55 -0
- package/dist/components/invoice-table-parts.d.ts +25 -0
- package/dist/components/invoice-table-parts.d.ts.map +1 -0
- package/dist/components/invoice-table-parts.js +32 -0
- package/dist/components/invoices-page-skeleton.d.ts +5 -0
- package/dist/components/invoices-page-skeleton.d.ts.map +1 -0
- package/dist/components/invoices-page-skeleton.js +13 -0
- package/dist/components/invoices-page.d.ts +6 -0
- package/dist/components/invoices-page.d.ts.map +1 -0
- package/dist/components/invoices-page.js +145 -0
- package/dist/components/payment-detail-page.d.ts +47 -0
- package/dist/components/payment-detail-page.d.ts.map +1 -0
- package/dist/components/payment-detail-page.js +90 -0
- package/dist/components/payment-policy-form.d.ts +49 -0
- package/dist/components/payment-policy-form.d.ts.map +1 -0
- package/dist/components/payment-policy-form.js +82 -0
- package/dist/components/payments-page/controls.d.ts +23 -0
- package/dist/components/payments-page/controls.d.ts.map +1 -0
- package/dist/components/payments-page/controls.js +20 -0
- package/dist/components/payments-page-skeleton.d.ts +5 -0
- package/dist/components/payments-page-skeleton.d.ts.map +1 -0
- package/dist/components/payments-page-skeleton.js +13 -0
- package/dist/components/payments-page.d.ts +20 -0
- package/dist/components/payments-page.d.ts.map +1 -0
- package/dist/components/payments-page.js +143 -0
- package/dist/components/profitability-page/sections.d.ts +24 -0
- package/dist/components/profitability-page/sections.d.ts.map +1 -0
- package/dist/components/profitability-page/sections.js +43 -0
- package/dist/components/profitability-page.d.ts +13 -0
- package/dist/components/profitability-page.d.ts.map +1 -0
- package/dist/components/profitability-page.js +175 -0
- package/dist/components/record-booking-payment-dialog/shared.d.ts +54 -0
- package/dist/components/record-booking-payment-dialog/shared.d.ts.map +1 -0
- package/dist/components/record-booking-payment-dialog/shared.js +47 -0
- package/dist/components/record-booking-payment-dialog.d.ts +4 -0
- package/dist/components/record-booking-payment-dialog.d.ts.map +1 -0
- package/dist/components/record-booking-payment-dialog.js +256 -0
- package/dist/components/supplier-invoice-detail-page/dialogs.d.ts +34 -0
- package/dist/components/supplier-invoice-detail-page/dialogs.d.ts.map +1 -0
- package/dist/components/supplier-invoice-detail-page/dialogs.js +119 -0
- package/dist/components/supplier-invoice-detail-page/shared.d.ts +64 -0
- package/dist/components/supplier-invoice-detail-page/shared.d.ts.map +1 -0
- package/dist/components/supplier-invoice-detail-page/shared.js +70 -0
- package/dist/components/supplier-invoice-detail-page.d.ts +4 -0
- package/dist/components/supplier-invoice-detail-page.d.ts.map +1 -0
- package/dist/components/supplier-invoice-detail-page.js +101 -0
- package/dist/components/supplier-invoice-form-dialog.d.ts +45 -0
- package/dist/components/supplier-invoice-form-dialog.d.ts.map +1 -0
- package/dist/components/supplier-invoice-form-dialog.js +102 -0
- package/dist/components/supplier-invoices-page.d.ts +14 -0
- package/dist/components/supplier-invoices-page.d.ts.map +1 -0
- package/dist/components/supplier-invoices-page.js +69 -0
- package/dist/components/supplier-payment-dialog.d.ts +7 -0
- package/dist/components/supplier-payment-dialog.d.ts.map +1 -0
- package/dist/components/supplier-payment-dialog.js +103 -0
- package/dist/components/taxes-page/policy-profile-sheet.d.ts +8 -0
- package/dist/components/taxes-page/policy-profile-sheet.d.ts.map +1 -0
- package/dist/components/taxes-page/policy-profile-sheet.js +52 -0
- package/dist/components/taxes-page/policy-rule-sheet.d.ts +10 -0
- package/dist/components/taxes-page/policy-rule-sheet.d.ts.map +1 -0
- package/dist/components/taxes-page/policy-rule-sheet.js +137 -0
- package/dist/components/taxes-page/shared.d.ts +128 -0
- package/dist/components/taxes-page/shared.d.ts.map +1 -0
- package/dist/components/taxes-page/shared.js +288 -0
- package/dist/components/taxes-page/sheets.d.ts +4 -0
- package/dist/components/taxes-page/sheets.d.ts.map +1 -0
- package/dist/components/taxes-page/sheets.js +3 -0
- package/dist/components/taxes-page/tax-sheet.d.ts +9 -0
- package/dist/components/taxes-page/tax-sheet.d.ts.map +1 -0
- package/dist/components/taxes-page/tax-sheet.js +108 -0
- package/dist/components/taxes-page.d.ts +4 -0
- package/dist/components/taxes-page.d.ts.map +1 -0
- package/dist/components/taxes-page.js +165 -0
- package/dist/hooks/index.d.ts +53 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +52 -0
- package/dist/hooks/use-accountant-share-mutation.d.ts +20 -0
- package/dist/hooks/use-accountant-share-mutation.d.ts.map +1 -0
- package/dist/hooks/use-accountant-share-mutation.js +27 -0
- package/dist/hooks/use-accountant-shares.d.ts +13 -0
- package/dist/hooks/use-accountant-shares.d.ts.map +1 -0
- package/dist/hooks/use-accountant-shares.js +8 -0
- package/dist/hooks/use-admin-booking-payments.d.ts +30 -0
- package/dist/hooks/use-admin-booking-payments.d.ts.map +1 -0
- package/dist/hooks/use-admin-booking-payments.js +18 -0
- package/dist/hooks/use-all-payments.d.ts +35 -0
- package/dist/hooks/use-all-payments.d.ts.map +1 -0
- package/dist/hooks/use-all-payments.js +12 -0
- package/dist/hooks/use-booking-guarantees.d.ts +82 -0
- package/dist/hooks/use-booking-guarantees.d.ts.map +1 -0
- package/dist/hooks/use-booking-guarantees.js +46 -0
- package/dist/hooks/use-booking-payment-schedule-regenerate-mutation.d.ts +44 -0
- package/dist/hooks/use-booking-payment-schedule-regenerate-mutation.d.ts.map +1 -0
- package/dist/hooks/use-booking-payment-schedule-regenerate-mutation.js +27 -0
- package/dist/hooks/use-booking-payment-schedules.d.ts +63 -0
- package/dist/hooks/use-booking-payment-schedules.d.ts.map +1 -0
- package/dist/hooks/use-booking-payment-schedules.js +47 -0
- package/dist/hooks/use-cost-categories.d.ts +14 -0
- package/dist/hooks/use-cost-categories.d.ts.map +1 -0
- package/dist/hooks/use-cost-categories.js +9 -0
- package/dist/hooks/use-cost-category-mutation.d.ts +31 -0
- package/dist/hooks/use-cost-category-mutation.d.ts.map +1 -0
- package/dist/hooks/use-cost-category-mutation.js +27 -0
- package/dist/hooks/use-departure-profitability.d.ts +56 -0
- package/dist/hooks/use-departure-profitability.d.ts.map +1 -0
- package/dist/hooks/use-departure-profitability.js +12 -0
- package/dist/hooks/use-finance-action-ledger.d.ts +94 -0
- package/dist/hooks/use-finance-action-ledger.d.ts.map +1 -0
- package/dist/hooks/use-finance-action-ledger.js +20 -0
- package/dist/hooks/use-invoice-attachment-mutation.d.ts +43 -0
- package/dist/hooks/use-invoice-attachment-mutation.d.ts.map +1 -0
- package/dist/hooks/use-invoice-attachment-mutation.js +39 -0
- package/dist/hooks/use-invoice-attachments.d.ts +18 -0
- package/dist/hooks/use-invoice-attachments.d.ts.map +1 -0
- package/dist/hooks/use-invoice-attachments.js +12 -0
- package/dist/hooks/use-invoice-bulk-status-mutation.d.ts +51 -0
- package/dist/hooks/use-invoice-bulk-status-mutation.d.ts.map +1 -0
- package/dist/hooks/use-invoice-bulk-status-mutation.js +66 -0
- package/dist/hooks/use-invoice-credit-note-mutation.d.ts +38 -0
- package/dist/hooks/use-invoice-credit-note-mutation.d.ts.map +1 -0
- package/dist/hooks/use-invoice-credit-note-mutation.js +35 -0
- package/dist/hooks/use-invoice-credit-notes.d.ts +17 -0
- package/dist/hooks/use-invoice-credit-notes.d.ts.map +1 -0
- package/dist/hooks/use-invoice-credit-notes.js +12 -0
- package/dist/hooks/use-invoice-fx-rate.d.ts +19 -0
- package/dist/hooks/use-invoice-fx-rate.d.ts.map +1 -0
- package/dist/hooks/use-invoice-fx-rate.js +13 -0
- package/dist/hooks/use-invoice-line-item-mutation.d.ts +40 -0
- package/dist/hooks/use-invoice-line-item-mutation.d.ts.map +1 -0
- package/dist/hooks/use-invoice-line-item-mutation.js +42 -0
- package/dist/hooks/use-invoice-line-items.d.ts +17 -0
- package/dist/hooks/use-invoice-line-items.d.ts.map +1 -0
- package/dist/hooks/use-invoice-line-items.js +12 -0
- package/dist/hooks/use-invoice-mutation.d.ts +225 -0
- package/dist/hooks/use-invoice-mutation.d.ts.map +1 -0
- package/dist/hooks/use-invoice-mutation.js +121 -0
- package/dist/hooks/use-invoice-note-mutation.d.ts +11 -0
- package/dist/hooks/use-invoice-note-mutation.d.ts.map +1 -0
- package/dist/hooks/use-invoice-note-mutation.js +23 -0
- package/dist/hooks/use-invoice-notes.d.ts +13 -0
- package/dist/hooks/use-invoice-notes.d.ts.map +1 -0
- package/dist/hooks/use-invoice-notes.js +12 -0
- package/dist/hooks/use-invoice-number-series-mutation.d.ts +62 -0
- package/dist/hooks/use-invoice-number-series-mutation.d.ts.map +1 -0
- package/dist/hooks/use-invoice-number-series-mutation.js +39 -0
- package/dist/hooks/use-invoice-number-series.d.ts +28 -0
- package/dist/hooks/use-invoice-number-series.d.ts.map +1 -0
- package/dist/hooks/use-invoice-number-series.js +12 -0
- package/dist/hooks/use-invoice-payment-mutation.d.ts +29 -0
- package/dist/hooks/use-invoice-payment-mutation.d.ts.map +1 -0
- package/dist/hooks/use-invoice-payment-mutation.js +35 -0
- package/dist/hooks/use-invoice-payments.d.ts +21 -0
- package/dist/hooks/use-invoice-payments.d.ts.map +1 -0
- package/dist/hooks/use-invoice-payments.js +12 -0
- package/dist/hooks/use-invoice.d.ts +32 -0
- package/dist/hooks/use-invoice.d.ts.map +1 -0
- package/dist/hooks/use-invoice.js +12 -0
- package/dist/hooks/use-invoices.d.ts +36 -0
- package/dist/hooks/use-invoices.d.ts.map +1 -0
- package/dist/hooks/use-invoices.js +12 -0
- package/dist/hooks/use-payment-mutation.d.ts +57 -0
- package/dist/hooks/use-payment-mutation.d.ts.map +1 -0
- package/dist/hooks/use-payment-mutation.js +59 -0
- package/dist/hooks/use-payment-session-mutation.d.ts +205 -0
- package/dist/hooks/use-payment-session-mutation.d.ts.map +1 -0
- package/dist/hooks/use-payment-session-mutation.js +38 -0
- package/dist/hooks/use-payment-sessions.d.ts +97 -0
- package/dist/hooks/use-payment-sessions.d.ts.map +1 -0
- package/dist/hooks/use-payment-sessions.js +17 -0
- package/dist/hooks/use-payment.d.ts +31 -0
- package/dist/hooks/use-payment.d.ts.map +1 -0
- package/dist/hooks/use-payment.js +12 -0
- package/dist/hooks/use-product-profitability.d.ts +52 -0
- package/dist/hooks/use-product-profitability.d.ts.map +1 -0
- package/dist/hooks/use-product-profitability.js +12 -0
- package/dist/hooks/use-public-booking-documents.d.ts +29 -0
- package/dist/hooks/use-public-booking-documents.d.ts.map +1 -0
- package/dist/hooks/use-public-booking-documents.js +12 -0
- package/dist/hooks/use-public-booking-payment-options.d.ts +47 -0
- package/dist/hooks/use-public-booking-payment-options.d.ts.map +1 -0
- package/dist/hooks/use-public-booking-payment-options.js +12 -0
- package/dist/hooks/use-public-booking-payments.d.ts +24 -0
- package/dist/hooks/use-public-booking-payments.d.ts.map +1 -0
- package/dist/hooks/use-public-booking-payments.js +12 -0
- package/dist/hooks/use-public-finance-document-by-reference.d.ts +27 -0
- package/dist/hooks/use-public-finance-document-by-reference.d.ts.map +1 -0
- package/dist/hooks/use-public-finance-document-by-reference.js +12 -0
- package/dist/hooks/use-public-payment-session-mutation.d.ts +82 -0
- package/dist/hooks/use-public-payment-session-mutation.d.ts.map +1 -0
- package/dist/hooks/use-public-payment-session-mutation.js +33 -0
- package/dist/hooks/use-public-payment-session.d.ts +73 -0
- package/dist/hooks/use-public-payment-session.d.ts.map +1 -0
- package/dist/hooks/use-public-payment-session.js +12 -0
- package/dist/hooks/use-public-voucher-validation-mutation.d.ts +23 -0
- package/dist/hooks/use-public-voucher-validation-mutation.d.ts.map +1 -0
- package/dist/hooks/use-public-voucher-validation-mutation.js +17 -0
- package/dist/hooks/use-supplier-invoice-attachments.d.ts +17 -0
- package/dist/hooks/use-supplier-invoice-attachments.d.ts.map +1 -0
- package/dist/hooks/use-supplier-invoice-attachments.js +12 -0
- package/dist/hooks/use-supplier-invoice-mutation.d.ts +353 -0
- package/dist/hooks/use-supplier-invoice-mutation.d.ts.map +1 -0
- package/dist/hooks/use-supplier-invoice-mutation.js +81 -0
- package/dist/hooks/use-supplier-invoice-payments.d.ts +26 -0
- package/dist/hooks/use-supplier-invoice-payments.d.ts.map +1 -0
- package/dist/hooks/use-supplier-invoice-payments.js +12 -0
- package/dist/hooks/use-supplier-invoice.d.ts +65 -0
- package/dist/hooks/use-supplier-invoice.d.ts.map +1 -0
- package/dist/hooks/use-supplier-invoice.js +12 -0
- package/dist/hooks/use-supplier-invoices.d.ts +36 -0
- package/dist/hooks/use-supplier-invoices.d.ts.map +1 -0
- package/dist/hooks/use-supplier-invoices.js +12 -0
- package/dist/hooks/use-supplier-payment-mutation.d.ts +55 -0
- package/dist/hooks/use-supplier-payment-mutation.d.ts.map +1 -0
- package/dist/hooks/use-supplier-payment-mutation.js +35 -0
- package/dist/hooks/use-supplier-payments.d.ts +27 -0
- package/dist/hooks/use-supplier-payments.d.ts.map +1 -0
- package/dist/hooks/use-supplier-payments.js +12 -0
- package/dist/hooks/use-traveler-profitability.d.ts +24 -0
- package/dist/hooks/use-traveler-profitability.d.ts.map +1 -0
- package/dist/hooks/use-traveler-profitability.js +11 -0
- package/dist/hooks/use-voucher-mutation.d.ts +105 -0
- package/dist/hooks/use-voucher-mutation.d.ts.map +1 -0
- package/dist/hooks/use-voucher-mutation.js +50 -0
- package/dist/hooks/use-voucher.d.ts +38 -0
- package/dist/hooks/use-voucher.d.ts.map +1 -0
- package/dist/hooks/use-voucher.js +17 -0
- package/dist/hooks/use-vouchers.d.ts +34 -0
- package/dist/hooks/use-vouchers.d.ts.map +1 -0
- package/dist/hooks/use-vouchers.js +18 -0
- package/dist/i18n/en/invoices.d.ts +278 -0
- package/dist/i18n/en/invoices.d.ts.map +1 -0
- package/dist/i18n/en/invoices.js +277 -0
- package/dist/i18n/en/numberingAndPayments.d.ts +387 -0
- package/dist/i18n/en/numberingAndPayments.d.ts.map +1 -0
- package/dist/i18n/en/numberingAndPayments.js +386 -0
- package/dist/i18n/en/profitability.d.ts +147 -0
- package/dist/i18n/en/profitability.d.ts.map +1 -0
- package/dist/i18n/en/profitability.js +146 -0
- package/dist/i18n/en/suppliers.d.ts +187 -0
- package/dist/i18n/en/suppliers.d.ts.map +1 -0
- package/dist/i18n/en/suppliers.js +186 -0
- package/dist/i18n/en.d.ts +998 -0
- package/dist/i18n/en.d.ts.map +1 -0
- package/dist/i18n/en.js +22 -0
- package/dist/i18n/index.d.ts +5 -0
- package/dist/i18n/index.d.ts.map +1 -0
- package/dist/i18n/index.js +3 -0
- package/dist/i18n/messages/core.d.ts +18 -0
- package/dist/i18n/messages/core.d.ts.map +1 -0
- package/dist/i18n/messages/core.js +30 -0
- package/dist/i18n/messages/invoices.d.ts +252 -0
- package/dist/i18n/messages/invoices.d.ts.map +1 -0
- package/dist/i18n/messages/invoices.js +1 -0
- package/dist/i18n/messages/numberingAndPayments.d.ts +277 -0
- package/dist/i18n/messages/numberingAndPayments.d.ts.map +1 -0
- package/dist/i18n/messages/numberingAndPayments.js +1 -0
- package/dist/i18n/messages/profitability.d.ts +151 -0
- package/dist/i18n/messages/profitability.d.ts.map +1 -0
- package/dist/i18n/messages/profitability.js +1 -0
- package/dist/i18n/messages/suppliers.d.ts +167 -0
- package/dist/i18n/messages/suppliers.d.ts.map +1 -0
- package/dist/i18n/messages/suppliers.js +1 -0
- package/dist/i18n/messages.d.ts +29 -0
- package/dist/i18n/messages.d.ts.map +1 -0
- package/dist/i18n/messages.js +1 -0
- package/dist/i18n/provider.d.ts +2018 -0
- package/dist/i18n/provider.d.ts.map +1 -0
- package/dist/i18n/provider.js +44 -0
- package/dist/i18n/ro/invoices.d.ts +278 -0
- package/dist/i18n/ro/invoices.d.ts.map +1 -0
- package/dist/i18n/ro/invoices.js +277 -0
- package/dist/i18n/ro/numberingAndPayments.d.ts +387 -0
- package/dist/i18n/ro/numberingAndPayments.d.ts.map +1 -0
- package/dist/i18n/ro/numberingAndPayments.js +386 -0
- package/dist/i18n/ro/profitability.d.ts +147 -0
- package/dist/i18n/ro/profitability.d.ts.map +1 -0
- package/dist/i18n/ro/profitability.js +146 -0
- package/dist/i18n/ro/suppliers.d.ts +187 -0
- package/dist/i18n/ro/suppliers.d.ts.map +1 -0
- package/dist/i18n/ro/suppliers.js +186 -0
- package/dist/i18n/ro.d.ts +998 -0
- package/dist/i18n/ro.d.ts.map +1 -0
- package/dist/i18n/ro.js +22 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/operations.d.ts +484 -0
- package/dist/operations.d.ts.map +1 -0
- package/dist/operations.js +52 -0
- package/dist/provider.d.ts +2 -0
- package/dist/provider.d.ts.map +1 -0
- package/dist/provider.js +1 -0
- package/dist/query-keys.d.ts +195 -0
- package/dist/query-keys.d.ts.map +1 -0
- package/dist/query-keys.js +49 -0
- package/dist/query-options/public-reporting.d.ts +2129 -0
- package/dist/query-options/public-reporting.d.ts.map +1 -0
- package/dist/query-options/public-reporting.js +193 -0
- package/dist/query-options-action-ledger.d.ts +382 -0
- package/dist/query-options-action-ledger.d.ts.map +1 -0
- package/dist/query-options-action-ledger.js +36 -0
- package/dist/query-options.d.ts +2057 -0
- package/dist/query-options.d.ts.map +1 -0
- package/dist/query-options.js +328 -0
- package/dist/schemas/accountant.d.ts +168 -0
- package/dist/schemas/accountant.d.ts.map +1 -0
- package/dist/schemas/accountant.js +53 -0
- package/dist/schemas/action-ledger.d.ts +206 -0
- package/dist/schemas/action-ledger.d.ts.map +1 -0
- package/dist/schemas/action-ledger.js +83 -0
- package/dist/schemas/common.d.ts +17 -0
- package/dist/schemas/common.d.ts.map +1 -0
- package/dist/schemas/common.js +10 -0
- package/dist/schemas/invoice.d.ts +1451 -0
- package/dist/schemas/invoice.d.ts.map +1 -0
- package/dist/schemas/invoice.js +438 -0
- package/dist/schemas/profitability.d.ts +333 -0
- package/dist/schemas/profitability.d.ts.map +1 -0
- package/dist/schemas/profitability.js +84 -0
- package/dist/schemas/public.d.ts +481 -0
- package/dist/schemas/public.d.ts.map +1 -0
- package/dist/schemas/public.js +9 -0
- package/dist/schemas/responses.d.ts +632 -0
- package/dist/schemas/responses.d.ts.map +1 -0
- package/dist/schemas/responses.js +27 -0
- package/dist/schemas/supplier.d.ts +226 -0
- package/dist/schemas/supplier.d.ts.map +1 -0
- package/dist/schemas/supplier.js +103 -0
- package/dist/schemas/vouchers.d.ts +283 -0
- package/dist/schemas/vouchers.d.ts.map +1 -0
- package/dist/schemas/vouchers.js +49 -0
- package/dist/schemas.d.ts +10 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/schemas.js +9 -0
- package/dist/ui.d.ts +27 -0
- package/dist/ui.d.ts.map +1 -0
- package/dist/ui.js +26 -0
- package/package.json +181 -0
- package/src/styles.css +12 -0
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { formatMessage } from "@voyant-travel/i18n";
|
|
4
|
+
import { Button, Dialog, DialogContent, DialogHeader, DialogTitle, Input, Label, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, Switch, Textarea, } from "@voyant-travel/ui/components";
|
|
5
|
+
import { CurrencyCombobox } from "@voyant-travel/ui/components/currency-combobox";
|
|
6
|
+
import { CurrencyInput } from "@voyant-travel/ui/components/currency-input";
|
|
7
|
+
import { DatePicker } from "@voyant-travel/ui/components/date-picker";
|
|
8
|
+
import { Loader2 } from "lucide-react";
|
|
9
|
+
import * as React from "react";
|
|
10
|
+
import { useFinanceUiMessagesOrDefault } from "../i18n/index.js";
|
|
11
|
+
import { useInvoiceFxRate, useInvoiceMutation, useInvoicePaymentMutation, useInvoices, usePaymentMutation, } from "../index.js";
|
|
12
|
+
import { buildInitialFormState, deriveBaseAmountCents, formatAmount, formatCommissionPercent, formatFxRateInput, formatRateDisplay, normalizeCurrency, PAYMENT_METHODS, PAYMENT_STATUSES, parseFxRate, } from "./record-booking-payment-dialog/shared.js";
|
|
13
|
+
export function RecordBookingPaymentDialog({ open, onOpenChange, bookingId, defaultCurrency = "EUR", onRecorded, editingPayment = null, }) {
|
|
14
|
+
const messages = useFinanceUiMessagesOrDefault();
|
|
15
|
+
const dialog = messages.recordBookingPaymentDialog;
|
|
16
|
+
const methodLabels = messages.common.paymentMethodLabels;
|
|
17
|
+
const statusLabels = messages.common.supplierPaymentStatusLabels;
|
|
18
|
+
const isEditing = Boolean(editingPayment);
|
|
19
|
+
const invoicesQuery = useInvoices({ bookingId, enabled: open });
|
|
20
|
+
const invoices = invoicesQuery.data?.data ?? [];
|
|
21
|
+
// Operator records a payment AGAINST money still owed. Paid / voided
|
|
22
|
+
// invoices have no remaining balance to settle, so they don't belong
|
|
23
|
+
// in the picker — keep the surface focused on what's actionable.
|
|
24
|
+
const selectableInvoices = invoices.filter((inv) => inv.status !== "void" && inv.balanceDueCents > 0);
|
|
25
|
+
const [state, setState] = React.useState(() => buildInitialFormState(defaultCurrency));
|
|
26
|
+
const [submitError, setSubmitError] = React.useState(null);
|
|
27
|
+
const [convertProformaAfter, setConvertProformaAfter] = React.useState(false);
|
|
28
|
+
const convertProformaTouchedRef = React.useRef(false);
|
|
29
|
+
const initializedRef = React.useRef(false);
|
|
30
|
+
// Reset on close; in edit mode, prefill from the snapshot once the
|
|
31
|
+
// invoices list loads. In create mode the operator picks an invoice
|
|
32
|
+
// explicitly — selecting one fills amount/currency from the row.
|
|
33
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: one-shot init guarded by `initializedRef`; we intentionally don't re-fire when the derived `selectableInvoices[0]` reference changes
|
|
34
|
+
React.useEffect(() => {
|
|
35
|
+
if (!open) {
|
|
36
|
+
initializedRef.current = false;
|
|
37
|
+
setSubmitError(null);
|
|
38
|
+
setConvertProformaAfter(false);
|
|
39
|
+
convertProformaTouchedRef.current = false;
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
if (!initializedRef.current && !invoicesQuery.isLoading) {
|
|
43
|
+
if (editingPayment) {
|
|
44
|
+
setState({
|
|
45
|
+
...buildInitialFormState(defaultCurrency),
|
|
46
|
+
invoiceId: editingPayment.invoiceId,
|
|
47
|
+
amountCents: editingPayment.amountCents,
|
|
48
|
+
currency: editingPayment.currency,
|
|
49
|
+
paymentMethod: editingPayment.paymentMethod,
|
|
50
|
+
status: editingPayment.status,
|
|
51
|
+
paymentDate: editingPayment.paymentDate,
|
|
52
|
+
referenceNumber: editingPayment.referenceNumber ?? "",
|
|
53
|
+
notes: editingPayment.notes ?? "",
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
// Auto-select the first outstanding invoice so the operator
|
|
58
|
+
// doesn't have to click the picker when there's only one
|
|
59
|
+
// option (the common case). The user can still re-pick from
|
|
60
|
+
// the dropdown.
|
|
61
|
+
const target = selectableInvoices[0];
|
|
62
|
+
setState({
|
|
63
|
+
...buildInitialFormState(defaultCurrency),
|
|
64
|
+
invoiceId: target?.id ?? "",
|
|
65
|
+
amountCents: target?.balanceDueCents ?? 0,
|
|
66
|
+
currency: target?.currency ?? defaultCurrency,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
initializedRef.current = true;
|
|
70
|
+
}
|
|
71
|
+
}, [open, invoicesQuery.isLoading, defaultCurrency, editingPayment]);
|
|
72
|
+
const selectedInvoice = invoices.find((inv) => inv.id === state.invoiceId) ?? null;
|
|
73
|
+
const invoiceCurrency = selectedInvoice?.currency ?? "";
|
|
74
|
+
const normalizedInvoiceCurrency = normalizeCurrency(invoiceCurrency);
|
|
75
|
+
const paymentCurrency = normalizeCurrency(state.currency);
|
|
76
|
+
const isCrossCurrency = Boolean(normalizedInvoiceCurrency && paymentCurrency && normalizedInvoiceCurrency !== paymentCurrency);
|
|
77
|
+
const requiresBaseAmount = isCrossCurrency && state.status === "completed";
|
|
78
|
+
const createMutation = useInvoicePaymentMutation(state.invoiceId);
|
|
79
|
+
const { update: updateMutation } = usePaymentMutation();
|
|
80
|
+
const { convertToInvoice: convertProformaMutation } = useInvoiceMutation();
|
|
81
|
+
// Only offer the proforma→invoice conversion when (a) recording a
|
|
82
|
+
// brand-new payment (not editing), (b) the selected invoice is a
|
|
83
|
+
// proforma, (c) the payment is being marked completed (a pending or
|
|
84
|
+
// failed payment shouldn't trigger conversion).
|
|
85
|
+
const isProformaSelected = selectedInvoice?.invoiceType === "proforma";
|
|
86
|
+
const canConvertProformaAfter = !isEditing && isProformaSelected && state.status === "completed";
|
|
87
|
+
const isPending = isEditing ? updateMutation.isPending : createMutation.isPending;
|
|
88
|
+
const fxRateQuery = useInvoiceFxRate({
|
|
89
|
+
baseCurrency: normalizedInvoiceCurrency || undefined,
|
|
90
|
+
quoteCurrency: paymentCurrency || undefined,
|
|
91
|
+
date: state.paymentDate || undefined,
|
|
92
|
+
enabled: open && isCrossCurrency,
|
|
93
|
+
});
|
|
94
|
+
const autoFxData = fxRateQuery.data?.data;
|
|
95
|
+
const autoEffectiveRate = typeof autoFxData?.effectiveRate === "number" && autoFxData.effectiveRate > 0
|
|
96
|
+
? autoFxData.effectiveRate
|
|
97
|
+
: null;
|
|
98
|
+
const autoRawRate = typeof autoFxData?.rate === "number" && autoFxData.rate > 0 ? autoFxData.rate : null;
|
|
99
|
+
const autoCommissionBps = autoFxData?.fxCommissionBps ?? 0;
|
|
100
|
+
const manualRate = state.fxOverride ? parseFxRate(state.fxRate) : null;
|
|
101
|
+
const effectiveFxRate = state.fxOverride ? manualRate : autoEffectiveRate;
|
|
102
|
+
const baseAmountCents = isCrossCurrency
|
|
103
|
+
? (deriveBaseAmountCents(state.amountCents, effectiveFxRate) ?? 0)
|
|
104
|
+
: 0;
|
|
105
|
+
const autoRateUnavailable = isCrossCurrency &&
|
|
106
|
+
!state.fxOverride &&
|
|
107
|
+
!fxRateQuery.isFetching &&
|
|
108
|
+
!autoEffectiveRate &&
|
|
109
|
+
fxRateQuery.isFetched;
|
|
110
|
+
// Heuristic: prefill the "Convert proforma to invoice" switch ON
|
|
111
|
+
// only when this payment will close the proforma — i.e. the entered
|
|
112
|
+
// amount (in invoice currency, directly or via FX) covers the
|
|
113
|
+
// invoice's remaining balance. Partial payments stay off since the
|
|
114
|
+
// proforma still has balance due after recording. The operator can
|
|
115
|
+
// override either way; once they toggle, we freeze the choice.
|
|
116
|
+
const fullyCoversInvoiceBalance = selectedInvoice != null &&
|
|
117
|
+
selectedInvoice.balanceDueCents > 0 &&
|
|
118
|
+
(isCrossCurrency
|
|
119
|
+
? baseAmountCents > 0 && baseAmountCents >= selectedInvoice.balanceDueCents
|
|
120
|
+
: state.amountCents > 0 && state.amountCents >= selectedInvoice.balanceDueCents);
|
|
121
|
+
React.useEffect(() => {
|
|
122
|
+
if (convertProformaTouchedRef.current)
|
|
123
|
+
return;
|
|
124
|
+
setConvertProformaAfter(canConvertProformaAfter && fullyCoversInvoiceBalance);
|
|
125
|
+
}, [canConvertProformaAfter, fullyCoversInvoiceBalance]);
|
|
126
|
+
const set = (key, value) => setState((prev) => ({ ...prev, [key]: value }));
|
|
127
|
+
const setPaymentCurrency = (currency) => {
|
|
128
|
+
const nextCurrency = normalizeCurrency(currency) || normalizedInvoiceCurrency || defaultCurrency;
|
|
129
|
+
setState((prev) => {
|
|
130
|
+
const previousCurrency = normalizeCurrency(prev.currency);
|
|
131
|
+
const sameCurrency = previousCurrency === nextCurrency;
|
|
132
|
+
const nextIsCrossCurrency = Boolean(normalizedInvoiceCurrency) && nextCurrency !== normalizedInvoiceCurrency;
|
|
133
|
+
return {
|
|
134
|
+
...prev,
|
|
135
|
+
amountCents: nextIsCrossCurrency &&
|
|
136
|
+
previousCurrency === normalizedInvoiceCurrency &&
|
|
137
|
+
prev.amountCents === selectedInvoice?.balanceDueCents
|
|
138
|
+
? 0
|
|
139
|
+
: prev.amountCents,
|
|
140
|
+
currency: nextCurrency,
|
|
141
|
+
fxOverride: sameCurrency ? prev.fxOverride : false,
|
|
142
|
+
fxRate: sameCurrency ? prev.fxRate : "",
|
|
143
|
+
};
|
|
144
|
+
});
|
|
145
|
+
};
|
|
146
|
+
const toggleOverride = (next) => {
|
|
147
|
+
setState((prev) => ({
|
|
148
|
+
...prev,
|
|
149
|
+
fxOverride: next,
|
|
150
|
+
fxRate: next && !prev.fxRate && autoEffectiveRate
|
|
151
|
+
? formatFxRateInput(autoEffectiveRate)
|
|
152
|
+
: prev.fxRate,
|
|
153
|
+
}));
|
|
154
|
+
};
|
|
155
|
+
const handleSubmit = async (event) => {
|
|
156
|
+
event.preventDefault();
|
|
157
|
+
setSubmitError(null);
|
|
158
|
+
if (!state.invoiceId) {
|
|
159
|
+
setSubmitError(dialog.validation.invoiceRequired);
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
if (state.amountCents <= 0) {
|
|
163
|
+
setSubmitError(dialog.validation.amountMinimum);
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
if (requiresBaseAmount && baseAmountCents <= 0) {
|
|
167
|
+
setSubmitError(dialog.validation.baseAmountRequired);
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
const payload = {
|
|
171
|
+
amountCents: state.amountCents,
|
|
172
|
+
currency: isCrossCurrency
|
|
173
|
+
? paymentCurrency || state.currency
|
|
174
|
+
: invoiceCurrency || state.currency,
|
|
175
|
+
baseCurrency: isCrossCurrency ? invoiceCurrency : null,
|
|
176
|
+
baseAmountCents: isCrossCurrency && baseAmountCents > 0 ? baseAmountCents : null,
|
|
177
|
+
paymentMethod: state.paymentMethod,
|
|
178
|
+
status: state.status,
|
|
179
|
+
paymentDate: state.paymentDate,
|
|
180
|
+
referenceNumber: state.referenceNumber.trim() === "" ? null : state.referenceNumber.trim(),
|
|
181
|
+
notes: state.notes.trim() === "" ? null : state.notes.trim(),
|
|
182
|
+
};
|
|
183
|
+
try {
|
|
184
|
+
if (isEditing && editingPayment) {
|
|
185
|
+
await updateMutation.mutateAsync({ id: editingPayment.id, input: payload });
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
await createMutation.mutateAsync(payload);
|
|
189
|
+
// The proforma → final invoice conversion is the last step so a
|
|
190
|
+
// failure here doesn't roll back the payment (it's already in).
|
|
191
|
+
// Server-side `convert-to-invoice` voids the proforma, creates
|
|
192
|
+
// the final invoice, and moves payments onto it — exactly what
|
|
193
|
+
// the operator would otherwise do by hand from the Invoices tab.
|
|
194
|
+
if (canConvertProformaAfter && convertProformaAfter && selectedInvoice) {
|
|
195
|
+
await convertProformaMutation.mutateAsync({ id: selectedInvoice.id });
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
onOpenChange(false);
|
|
199
|
+
onRecorded?.();
|
|
200
|
+
}
|
|
201
|
+
catch (err) {
|
|
202
|
+
setSubmitError(err instanceof Error ? err.message : dialog.validation.recordFailed);
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
const showEmptyState = !isEditing && !invoicesQuery.isLoading && selectableInvoices.length === 0;
|
|
206
|
+
return (_jsx(Dialog, { open: open, onOpenChange: onOpenChange, children: _jsxs(DialogContent, { size: "lg", className: "gap-0 p-0", children: [_jsx(DialogHeader, { className: "border-b px-6 py-4", children: _jsx(DialogTitle, { children: isEditing ? dialog.editTitle : dialog.title }) }), showEmptyState ? (_jsxs(_Fragment, { children: [_jsx("div", { className: "px-6 py-6", children: _jsx("p", { className: "text-sm text-muted-foreground", children: dialog.noInvoices }) }), _jsx("div", { className: "flex items-center justify-end gap-2 px-6 pb-6", children: _jsx(Button, { type: "button", variant: "outline", onClick: () => onOpenChange(false), children: messages.common.cancel }) })] })) : (_jsxs("form", { onSubmit: handleSubmit, children: [_jsxs("div", { className: "flex flex-col gap-5 px-6 py-5", children: [_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { htmlFor: "record-invoice", children: dialog.fields.invoice }), invoicesQuery.isLoading ? (_jsx("p", { className: "text-sm text-muted-foreground", children: dialog.loadingInvoices })) : (_jsxs(Select, { value: state.invoiceId, disabled: isEditing, onValueChange: (value) => {
|
|
207
|
+
const id = value ?? "";
|
|
208
|
+
const next = invoices.find((inv) => inv.id === id);
|
|
209
|
+
setState((prev) => ({
|
|
210
|
+
...prev,
|
|
211
|
+
invoiceId: id,
|
|
212
|
+
amountCents: next?.balanceDueCents ?? prev.amountCents,
|
|
213
|
+
currency: next?.currency ?? prev.currency,
|
|
214
|
+
fxOverride: false,
|
|
215
|
+
fxRate: "",
|
|
216
|
+
}));
|
|
217
|
+
}, children: [_jsx(SelectTrigger, { id: "record-invoice", className: "w-full", children: _jsx(SelectValue, { placeholder: dialog.placeholders.invoice }) }), _jsx(SelectContent, { children: selectableInvoices.map((inv) => (_jsx(SelectItem, { value: inv.id, children: formatMessage(dialog.invoiceOption, {
|
|
218
|
+
number: inv.invoiceNumber,
|
|
219
|
+
status: inv.status,
|
|
220
|
+
balance: formatAmount(inv.balanceDueCents),
|
|
221
|
+
currency: inv.currency,
|
|
222
|
+
}) }, inv.id))) })] }))] }), _jsxs("div", { className: "grid gap-4 sm:grid-cols-3", children: [_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { htmlFor: "record-amount", children: dialog.fields.amountCents }), _jsx(CurrencyInput, { id: "record-amount", value: state.amountCents, onChange: (next) => set("amountCents", next ?? 0), currency: state.currency })] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: dialog.fields.currency }), _jsx(CurrencyCombobox, { value: state.currency || null, onChange: (next) => setPaymentCurrency(next ?? selectedInvoice?.currency ?? defaultCurrency), placeholder: dialog.placeholders.currency })] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { htmlFor: "record-date", children: dialog.fields.paymentDate }), _jsx(DatePicker, { value: state.paymentDate || null, onChange: (next) => set("paymentDate", next ?? ""), className: "w-full" })] })] }), isCrossCurrency ? (_jsxs("div", { className: "rounded-md border bg-muted/20 p-3", children: [_jsxs("div", { className: "flex items-start justify-between gap-3", children: [_jsxs("div", { className: "space-y-1", children: [_jsx("h3", { className: "text-sm font-medium", children: dialog.fx.title }), fxRateQuery.isFetching ? (_jsx("p", { className: "text-xs text-muted-foreground", children: dialog.fx.loadingRate })) : autoRateUnavailable ? (_jsx("p", { className: "text-xs text-destructive", children: formatMessage(dialog.fx.rateUnavailable, {
|
|
223
|
+
invoiceCurrency,
|
|
224
|
+
paymentCurrency,
|
|
225
|
+
}) })) : effectiveFxRate && baseAmountCents > 0 ? (_jsxs(_Fragment, { children: [_jsx("p", { className: "text-sm", children: formatMessage(dialog.fx.summary, {
|
|
226
|
+
amount: formatAmount(state.amountCents),
|
|
227
|
+
paymentCurrency,
|
|
228
|
+
baseAmount: formatAmount(baseAmountCents),
|
|
229
|
+
invoiceCurrency,
|
|
230
|
+
rate: formatRateDisplay(effectiveFxRate),
|
|
231
|
+
}) }), !state.fxOverride && autoCommissionBps > 0 ? (_jsx("p", { className: "text-xs text-muted-foreground", children: formatMessage(dialog.fx.commissionNote, {
|
|
232
|
+
rawRate: autoRawRate ? formatRateDisplay(autoRawRate) : "",
|
|
233
|
+
commission: formatCommissionPercent(autoCommissionBps),
|
|
234
|
+
invoiceCurrency,
|
|
235
|
+
paymentCurrency,
|
|
236
|
+
}) })) : !state.fxOverride && autoRawRate ? (_jsx("p", { className: "text-xs text-muted-foreground", children: dialog.fx.source })) : null] })) : (_jsx("p", { className: "text-xs text-muted-foreground", children: formatMessage(dialog.fx.help, {
|
|
237
|
+
invoiceCurrency,
|
|
238
|
+
paymentCurrency,
|
|
239
|
+
}) }))] }), _jsx(Button, { type: "button", variant: "ghost", size: "sm", onClick: () => toggleOverride(!state.fxOverride), children: state.fxOverride ? dialog.fx.useAuto : dialog.fx.override })] }), state.fxOverride || autoRateUnavailable ? (_jsxs("div", { className: "mt-3 flex flex-col gap-2 sm:max-w-xs", children: [_jsx(Label, { htmlFor: "record-fx-rate", children: formatMessage(dialog.fields.fxRate, {
|
|
240
|
+
invoiceCurrency,
|
|
241
|
+
paymentCurrency,
|
|
242
|
+
}) }), _jsx(Input, { id: "record-fx-rate", value: state.fxRate, onChange: (event) => setState((prev) => ({
|
|
243
|
+
...prev,
|
|
244
|
+
fxOverride: true,
|
|
245
|
+
fxRate: event.target.value,
|
|
246
|
+
})), inputMode: "decimal", placeholder: formatMessage(dialog.placeholders.fxRate, {
|
|
247
|
+
invoiceCurrency,
|
|
248
|
+
paymentCurrency,
|
|
249
|
+
}) })] })) : null] })) : null, _jsxs("div", { className: "grid gap-4 sm:grid-cols-2", children: [_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: dialog.fields.status }), _jsxs(Select, { value: state.status, onValueChange: (value) => set("status", (value ?? "completed")), children: [_jsx(SelectTrigger, { className: "w-full", children: _jsx(SelectValue, {}) }), _jsx(SelectContent, { children: PAYMENT_STATUSES.map((value) => (_jsx(SelectItem, { value: value, children: statusLabels[value] }, value))) })] })] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: dialog.fields.paymentMethod }), _jsxs(Select, { value: state.paymentMethod, onValueChange: (value) => set("paymentMethod", (value ?? "bank_transfer")), children: [_jsx(SelectTrigger, { className: "w-full", children: _jsx(SelectValue, {}) }), _jsx(SelectContent, { children: PAYMENT_METHODS.map((value) => (_jsx(SelectItem, { value: value, children: methodLabels[value] }, value))) })] })] })] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { htmlFor: "record-ref", children: dialog.fields.referenceNumber }), _jsx(Input, { id: "record-ref", value: state.referenceNumber, onChange: (event) => set("referenceNumber", event.target.value), placeholder: dialog.placeholders.referenceNumber })] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { htmlFor: "record-notes", children: dialog.fields.notes }), _jsx(Textarea, { id: "record-notes", value: state.notes, onChange: (event) => set("notes", event.target.value), rows: 3 })] }), canConvertProformaAfter ? (_jsxs("div", { className: "flex items-start justify-between gap-3 rounded-md border bg-muted/20 px-4 py-3", children: [_jsxs("div", { className: "flex flex-col gap-1", children: [_jsx(Label, { htmlFor: "record-convert-proforma", className: "cursor-pointer", onClick: () => setConvertProformaAfter((v) => !v), children: dialog.fields.convertProformaAfter }), _jsx("p", { className: "text-xs text-muted-foreground", children: dialog.fields.convertProformaAfterHint })] }), _jsx(Switch, { id: "record-convert-proforma", checked: convertProformaAfter, onCheckedChange: (next) => {
|
|
250
|
+
convertProformaTouchedRef.current = true;
|
|
251
|
+
setConvertProformaAfter(next);
|
|
252
|
+
} })] })) : null, submitError ? _jsx("p", { className: "text-sm text-destructive", children: submitError }) : null] }), _jsxs("div", { className: "flex items-center justify-end gap-2 px-6 pb-6", children: [_jsx(Button, { type: "button", variant: "outline", onClick: () => onOpenChange(false), children: messages.common.cancel }), _jsxs(Button, { type: "submit", disabled: isPending ||
|
|
253
|
+
!state.invoiceId ||
|
|
254
|
+
state.amountCents <= 0 ||
|
|
255
|
+
(requiresBaseAmount && baseAmountCents <= 0), children: [isPending ? _jsx(Loader2, { className: "mr-2 h-4 w-4 animate-spin" }) : null, isEditing ? dialog.actions.save : dialog.actions.record] })] })] }))] }) }));
|
|
256
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { SupplierCostAllocationInput, SupplierCostAllocationRecord, SupplierInvoiceLineInput, SupplierInvoiceLineRecord } from "../../index.js";
|
|
2
|
+
import { type AsyncComboboxOption } from "../async-combobox.js";
|
|
3
|
+
import { type SupplierInvoiceTargetSearch } from "./shared.js";
|
|
4
|
+
export declare function LineDialog({ open, line, currency, pending, onOpenChange, onSubmit, }: {
|
|
5
|
+
open: boolean;
|
|
6
|
+
line: SupplierInvoiceLineRecord | null;
|
|
7
|
+
currency: string;
|
|
8
|
+
pending: boolean;
|
|
9
|
+
onOpenChange: (open: boolean) => void;
|
|
10
|
+
onSubmit: (input: SupplierInvoiceLineInput) => void;
|
|
11
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export declare function AllocationDialog({ open, allocation, currency, pending, searchTargets, listDeparturesForProduct, onOpenChange, onSubmit, }: {
|
|
13
|
+
open: boolean;
|
|
14
|
+
allocation: SupplierCostAllocationRecord | null;
|
|
15
|
+
currency: string;
|
|
16
|
+
pending: boolean;
|
|
17
|
+
searchTargets?: SupplierInvoiceTargetSearch;
|
|
18
|
+
listDeparturesForProduct?: (productId: string, query: string) => Promise<AsyncComboboxOption[]>;
|
|
19
|
+
onOpenChange: (open: boolean) => void;
|
|
20
|
+
onSubmit: (input: SupplierCostAllocationInput) => void;
|
|
21
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
export declare function PaymentDialog({ open, currency, pending, onOpenChange, onSubmit, }: {
|
|
23
|
+
open: boolean;
|
|
24
|
+
currency: string;
|
|
25
|
+
pending: boolean;
|
|
26
|
+
onOpenChange: (open: boolean) => void;
|
|
27
|
+
onSubmit: (input: {
|
|
28
|
+
amountCents: number;
|
|
29
|
+
paymentMethod: string;
|
|
30
|
+
status: "completed";
|
|
31
|
+
paymentDate: string;
|
|
32
|
+
}) => void;
|
|
33
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
34
|
+
//# sourceMappingURL=dialogs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dialogs.d.ts","sourceRoot":"","sources":["../../../src/components/supplier-invoice-detail-page/dialogs.tsx"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAEV,2BAA2B,EAC3B,4BAA4B,EAC5B,wBAAwB,EACxB,yBAAyB,EAC1B,MAAM,gBAAgB,CAAA;AAEvB,OAAO,EAAiB,KAAK,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAC9E,OAAO,EAIL,KAAK,2BAA2B,EAKjC,MAAM,aAAa,CAAA;AAEpB,wBAAgB,UAAU,CAAC,EACzB,IAAI,EACJ,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,YAAY,EACZ,QAAQ,GACT,EAAE;IACD,IAAI,EAAE,OAAO,CAAA;IACb,IAAI,EAAE,yBAAyB,GAAG,IAAI,CAAA;IACtC,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,OAAO,CAAA;IAChB,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAA;IACrC,QAAQ,EAAE,CAAC,KAAK,EAAE,wBAAwB,KAAK,IAAI,CAAA;CACpD,2CAiGA;AAID,wBAAgB,gBAAgB,CAAC,EAC/B,IAAI,EACJ,UAAU,EACV,QAAQ,EACR,OAAO,EACP,aAAa,EACb,wBAAwB,EACxB,YAAY,EACZ,QAAQ,GACT,EAAE;IACD,IAAI,EAAE,OAAO,CAAA;IACb,UAAU,EAAE,4BAA4B,GAAG,IAAI,CAAA;IAC/C,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,OAAO,CAAA;IAChB,aAAa,CAAC,EAAE,2BAA2B,CAAA;IAC3C,wBAAwB,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAAA;IAC/F,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAA;IACrC,QAAQ,EAAE,CAAC,KAAK,EAAE,2BAA2B,KAAK,IAAI,CAAA;CACvD,2CAkIA;AAID,wBAAgB,aAAa,CAAC,EAC5B,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,YAAY,EACZ,QAAQ,GACT,EAAE;IACD,IAAI,EAAE,OAAO,CAAA;IACb,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,OAAO,CAAA;IAChB,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAA;IACrC,QAAQ,EAAE,CAAC,KAAK,EAAE;QAChB,WAAW,EAAE,MAAM,CAAA;QACnB,aAAa,EAAE,MAAM,CAAA;QACrB,MAAM,EAAE,WAAW,CAAA;QACnB,WAAW,EAAE,MAAM,CAAA;KACpB,KAAK,IAAI,CAAA;CACX,2CAsEA"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { formatMessage } from "@voyant-travel/i18n";
|
|
3
|
+
import { Button, Dialog, DialogBody, DialogContent, DialogFooter, DialogHeader, DialogTitle, Input, Label, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "@voyant-travel/ui/components";
|
|
4
|
+
import { DatePicker } from "@voyant-travel/ui/components/date-picker";
|
|
5
|
+
import { useState } from "react";
|
|
6
|
+
import { useFinanceUiMessagesOrDefault } from "../../i18n/index.js";
|
|
7
|
+
import { useCostCategories } from "../../index.js";
|
|
8
|
+
import { AsyncCombobox } from "../async-combobox.js";
|
|
9
|
+
import { LINE_CATEGORY_NONE, PAYMENT_METHODS, SEARCHABLE_TARGETS, TARGET_TYPES, targetIdFor, toCents, } from "./shared.js";
|
|
10
|
+
export function LineDialog({ open, line, currency, pending, onOpenChange, onSubmit, }) {
|
|
11
|
+
const t = useFinanceUiMessagesOrDefault().supplierInvoiceDetail.lineForm;
|
|
12
|
+
const categories = useCostCategories().data?.data ?? [];
|
|
13
|
+
const [description, setDescription] = useState("");
|
|
14
|
+
const [serviceType, setServiceType] = useState("other");
|
|
15
|
+
const [costCategoryId, setCostCategoryId] = useState("");
|
|
16
|
+
const [quantity, setQuantity] = useState("1");
|
|
17
|
+
const [unit, setUnit] = useState("");
|
|
18
|
+
const [tax, setTax] = useState("");
|
|
19
|
+
const [total, setTotal] = useState("");
|
|
20
|
+
// Seed when (re)opened for a specific line.
|
|
21
|
+
const seedKey = open ? (line?.id ?? "new") : "closed";
|
|
22
|
+
const [seeded, setSeeded] = useState("closed");
|
|
23
|
+
if (seedKey !== seeded) {
|
|
24
|
+
setSeeded(seedKey);
|
|
25
|
+
setDescription(line?.description ?? "");
|
|
26
|
+
setServiceType(line?.serviceType ?? "other");
|
|
27
|
+
setCostCategoryId(line?.costCategoryId ?? "");
|
|
28
|
+
setQuantity(String(line?.quantity ?? 1));
|
|
29
|
+
setUnit(line ? (line.unitAmountCents / 100).toFixed(2) : "");
|
|
30
|
+
setTax(line ? (line.taxAmountCents / 100).toFixed(2) : "");
|
|
31
|
+
setTotal(line ? (line.totalAmountCents / 100).toFixed(2) : "");
|
|
32
|
+
}
|
|
33
|
+
const submit = () => {
|
|
34
|
+
if (!description.trim())
|
|
35
|
+
return;
|
|
36
|
+
onSubmit({
|
|
37
|
+
description: description.trim(),
|
|
38
|
+
serviceType,
|
|
39
|
+
costCategoryId: costCategoryId || null,
|
|
40
|
+
quantity: Math.max(1, Number.parseInt(quantity, 10) || 1),
|
|
41
|
+
unitAmountCents: toCents(unit),
|
|
42
|
+
taxAmountCents: toCents(tax),
|
|
43
|
+
totalAmountCents: toCents(total),
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
return (_jsx(Dialog, { open: open, onOpenChange: onOpenChange, children: _jsxs(DialogContent, { className: "sm:max-w-md", children: [_jsx(DialogHeader, { children: _jsx(DialogTitle, { children: line ? t.editTitle : t.addTitle }) }), _jsxs(DialogBody, { className: "grid grid-cols-2 gap-3", children: [_jsxs("div", { className: "col-span-2 flex flex-col gap-2", children: [_jsx(Label, { children: t.description }), _jsx(Input, { value: description, onChange: (e) => setDescription(e.target.value) })] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: t.costCategory }), _jsxs(Select, { value: costCategoryId || LINE_CATEGORY_NONE, onValueChange: (v) => setCostCategoryId(v === LINE_CATEGORY_NONE ? "" : (v ?? "")), children: [_jsx(SelectTrigger, { className: "w-full", children: _jsx(SelectValue, {}) }), _jsxs(SelectContent, { children: [_jsx(SelectItem, { value: LINE_CATEGORY_NONE, children: t.costCategoryNone }), categories.map((c) => (_jsx(SelectItem, { value: c.id, children: c.name }, c.id)))] })] })] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: t.quantity }), _jsx(Input, { inputMode: "numeric", value: quantity, onChange: (e) => setQuantity(e.target.value) })] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: `${t.unitAmount} (${currency})` }), _jsx(Input, { inputMode: "decimal", value: unit, onChange: (e) => setUnit(e.target.value) })] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: `${t.taxAmount} (${currency})` }), _jsx(Input, { inputMode: "decimal", value: tax, onChange: (e) => setTax(e.target.value) })] }), _jsxs("div", { className: "col-span-2 flex flex-col gap-2", children: [_jsx(Label, { children: `${t.total} (${currency})` }), _jsx(Input, { inputMode: "decimal", value: total, onChange: (e) => setTotal(e.target.value) })] })] }), _jsx(DialogFooter, { children: _jsx(Button, { type: "button", disabled: !description.trim() || pending, onClick: submit, children: t.save }) })] }) }));
|
|
47
|
+
}
|
|
48
|
+
// ---------- allocation dialog ----------
|
|
49
|
+
export function AllocationDialog({ open, allocation, currency, pending, searchTargets, listDeparturesForProduct, onOpenChange, onSubmit, }) {
|
|
50
|
+
const t = useFinanceUiMessagesOrDefault().supplierInvoiceDetail.allocation;
|
|
51
|
+
const [targetType, setTargetType] = useState("departure");
|
|
52
|
+
const [targetId, setTargetId] = useState("");
|
|
53
|
+
const [productId, setProductId] = useState("");
|
|
54
|
+
const [amount, setAmount] = useState("");
|
|
55
|
+
const seedKey = open ? (allocation?.id ?? "new") : "closed";
|
|
56
|
+
const [seeded, setSeeded] = useState("closed");
|
|
57
|
+
if (seedKey !== seeded) {
|
|
58
|
+
setSeeded(seedKey);
|
|
59
|
+
setTargetType(allocation?.targetType ?? "departure");
|
|
60
|
+
setTargetId(allocation
|
|
61
|
+
? (allocation.departureId ??
|
|
62
|
+
allocation.productId ??
|
|
63
|
+
allocation.bookingId ??
|
|
64
|
+
allocation.travelerId ??
|
|
65
|
+
"")
|
|
66
|
+
: "");
|
|
67
|
+
setProductId(allocation?.productId ?? "");
|
|
68
|
+
setAmount(allocation ? (allocation.amountCents / 100).toFixed(2) : "");
|
|
69
|
+
}
|
|
70
|
+
// Two-step departure picker (pick product → departure) when wired.
|
|
71
|
+
const twoStepDeparture = targetType === "departure" && Boolean(searchTargets) && Boolean(listDeparturesForProduct);
|
|
72
|
+
const submit = () => {
|
|
73
|
+
if (!amount)
|
|
74
|
+
return;
|
|
75
|
+
onSubmit({
|
|
76
|
+
targetType,
|
|
77
|
+
amountCents: toCents(amount),
|
|
78
|
+
splitMethod: "manual",
|
|
79
|
+
...targetIdFor(targetType, targetId.trim()),
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
return (_jsx(Dialog, { open: open, onOpenChange: onOpenChange, children: _jsxs(DialogContent, { className: "sm:max-w-md", children: [_jsx(DialogHeader, { children: _jsx(DialogTitle, { children: t.add }) }), _jsxs(DialogBody, { className: "grid grid-cols-2 gap-3", children: [_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: t.target }), _jsxs(Select, { value: targetType, onValueChange: (v) => {
|
|
83
|
+
setTargetType(v ?? "departure");
|
|
84
|
+
setTargetId("");
|
|
85
|
+
}, children: [_jsx(SelectTrigger, { className: "w-full", children: _jsx(SelectValue, {}) }), _jsx(SelectContent, { children: TARGET_TYPES.map((value) => (_jsx(SelectItem, { value: value, children: t.targetTypeLabels[value] }, value))) })] })] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: formatMessage(t.amountLabel, { currency }) }), _jsx(Input, { inputMode: "decimal", value: amount, onChange: (e) => setAmount(e.target.value) })] }), targetType === "unattributed" ? null : twoStepDeparture ? (_jsxs(_Fragment, { children: [_jsxs("div", { className: "col-span-2 flex flex-col gap-2", children: [_jsx(Label, { children: t.targetTypeLabels.product }), _jsx(AsyncCombobox, { value: productId || null, onChange: (v) => {
|
|
86
|
+
setProductId(v ?? "");
|
|
87
|
+
setTargetId("");
|
|
88
|
+
}, search: (query) => searchTargets?.("product", query) ?? Promise.resolve([]) })] }), _jsxs("div", { className: "col-span-2 flex flex-col gap-2", children: [_jsx(Label, { children: t.targetTypeLabels.departure }), _jsx(AsyncCombobox, { value: targetId || null, onChange: (v) => setTargetId(v ?? ""), disabled: !productId, search: (query) => productId
|
|
89
|
+
? (listDeparturesForProduct?.(productId, query) ?? Promise.resolve([]))
|
|
90
|
+
: Promise.resolve([]) })] })] })) : (_jsxs("div", { className: "col-span-2 flex flex-col gap-2", children: [_jsx(Label, { children: t.targetTypeLabels[targetType] }), searchTargets && SEARCHABLE_TARGETS.has(targetType) ? (_jsx(AsyncCombobox, { value: targetId || null, onChange: (v) => setTargetId(v ?? ""), search: (query) => searchTargets(targetType, query) })) : (_jsx(Input, { value: targetId, onChange: (e) => setTargetId(e.target.value) }))] }))] }), _jsx(DialogFooter, { children: _jsx(Button, { type: "button", disabled: !amount || (targetType !== "unattributed" && !targetId.trim()) || pending, onClick: submit, children: pending ? t.saving : t.save }) })] }) }));
|
|
91
|
+
}
|
|
92
|
+
// ---------- payment dialog ----------
|
|
93
|
+
export function PaymentDialog({ open, currency, pending, onOpenChange, onSubmit, }) {
|
|
94
|
+
const t = useFinanceUiMessagesOrDefault().supplierInvoiceDetail.payments;
|
|
95
|
+
const [amount, setAmount] = useState("");
|
|
96
|
+
const [method, setMethod] = useState("bank_transfer");
|
|
97
|
+
const [date, setDate] = useState("");
|
|
98
|
+
const seedKey = open ? "open" : "closed";
|
|
99
|
+
const [seeded, setSeeded] = useState("closed");
|
|
100
|
+
if (seedKey !== seeded) {
|
|
101
|
+
setSeeded(seedKey);
|
|
102
|
+
if (open) {
|
|
103
|
+
setAmount("");
|
|
104
|
+
setMethod("bank_transfer");
|
|
105
|
+
setDate("");
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
const submit = () => {
|
|
109
|
+
if (!amount)
|
|
110
|
+
return;
|
|
111
|
+
onSubmit({
|
|
112
|
+
amountCents: toCents(amount),
|
|
113
|
+
paymentMethod: method,
|
|
114
|
+
status: "completed",
|
|
115
|
+
paymentDate: date || new Date().toISOString().slice(0, 10),
|
|
116
|
+
});
|
|
117
|
+
};
|
|
118
|
+
return (_jsx(Dialog, { open: open, onOpenChange: onOpenChange, children: _jsxs(DialogContent, { className: "sm:max-w-md", children: [_jsx(DialogHeader, { children: _jsx(DialogTitle, { children: t.recordTitle }) }), _jsxs(DialogBody, { className: "grid grid-cols-2 gap-3", children: [_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: formatMessage(t.amountLabel, { currency }) }), _jsx(Input, { inputMode: "decimal", value: amount, onChange: (e) => setAmount(e.target.value) })] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: t.methodLabel }), _jsxs(Select, { value: method, onValueChange: (v) => setMethod(v ?? "other"), children: [_jsx(SelectTrigger, { className: "w-full", children: _jsx(SelectValue, {}) }), _jsx(SelectContent, { children: PAYMENT_METHODS.map((m) => (_jsx(SelectItem, { value: m, children: t.methodLabels[m] }, m))) })] })] }), _jsxs("div", { className: "col-span-2 flex flex-col gap-2", children: [_jsx(Label, { children: t.dateLabel }), _jsx(DatePicker, { value: date || null, onChange: (v) => setDate(v ?? ""), className: "w-full" })] })] }), _jsx(DialogFooter, { children: _jsx(Button, { type: "button", disabled: !amount || pending, onClick: submit, children: pending ? t.recording : t.record }) })] }) }));
|
|
119
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { SupplierCostAllocationInput, SupplierCostAllocationRecord, SupplierInvoiceLineInput, SupplierInvoiceLineRecord, SupplierInvoiceStatus } from "../../index.js";
|
|
2
|
+
import type { AsyncComboboxOption } from "../async-combobox.js";
|
|
3
|
+
import type { SupplierInvoiceExtraction } from "../supplier-invoice-form-dialog.js";
|
|
4
|
+
export type SupplierInvoiceTargetSearch = (targetType: "departure" | "product" | "booking" | "traveler", query: string) => Promise<AsyncComboboxOption[]>;
|
|
5
|
+
export declare const STATUS_VARIANT: Record<SupplierInvoiceStatus, "default" | "secondary" | "destructive" | "outline">;
|
|
6
|
+
export declare const TARGET_TYPES: readonly ["departure", "product", "booking", "traveler", "unattributed"];
|
|
7
|
+
export type TargetType = (typeof TARGET_TYPES)[number];
|
|
8
|
+
/**
|
|
9
|
+
* Target types that support search-and-select; others fall back to a text id.
|
|
10
|
+
* Departure search is product-centric (search a product → pick its dated slot),
|
|
11
|
+
* wired by the host. Travelers have no global search, so they stay raw-id.
|
|
12
|
+
*/
|
|
13
|
+
export declare const SEARCHABLE_TARGETS: Set<"traveler" | "booking" | "product" | "departure" | "unattributed">;
|
|
14
|
+
export declare const LINE_CATEGORY_NONE = "__none__";
|
|
15
|
+
export declare const PAYMENT_METHODS: readonly ["bank_transfer", "credit_card", "cash", "cheque", "other"];
|
|
16
|
+
export declare function toCents(major: string): number;
|
|
17
|
+
export declare function targetIdFor(targetType: TargetType, targetId: string): Partial<SupplierCostAllocationInput>;
|
|
18
|
+
export declare function allocationToInput(a: SupplierCostAllocationRecord): SupplierCostAllocationInput;
|
|
19
|
+
export declare function lineToInput(line: SupplierInvoiceLineRecord): SupplierInvoiceLineInput;
|
|
20
|
+
export interface SupplierInvoiceAttachmentUpload {
|
|
21
|
+
storageKey: string;
|
|
22
|
+
mimeType?: string | null;
|
|
23
|
+
fileSize?: number | null;
|
|
24
|
+
}
|
|
25
|
+
export interface SupplierInvoiceDetailPageProps {
|
|
26
|
+
id: string;
|
|
27
|
+
className?: string;
|
|
28
|
+
/** Breadcrumb root link + post-delete navigation back to the list. */
|
|
29
|
+
onBack?: () => void;
|
|
30
|
+
/** Operator wires this to open the document download endpoint. */
|
|
31
|
+
onDownloadDocument?: () => void;
|
|
32
|
+
/**
|
|
33
|
+
* Upload a file's bytes to durable storage (R2) and return its location.
|
|
34
|
+
* The template owns the upload endpoint (e.g. `/api/v1/uploads`). When
|
|
35
|
+
* omitted, the attachment upload control is hidden.
|
|
36
|
+
*/
|
|
37
|
+
uploadFile?: (file: File) => Promise<SupplierInvoiceAttachmentUpload>;
|
|
38
|
+
/** Operator wires this to open an attachment's download endpoint. */
|
|
39
|
+
onDownloadAttachment?: (attachmentId: string) => void;
|
|
40
|
+
/**
|
|
41
|
+
* Resolve searchable options for an allocation target (departure / product /
|
|
42
|
+
* booking). When provided, those targets use a search-and-select combobox in
|
|
43
|
+
* the allocation dialog instead of a raw id field.
|
|
44
|
+
*/
|
|
45
|
+
searchTargets?: SupplierInvoiceTargetSearch;
|
|
46
|
+
/**
|
|
47
|
+
* List a product's departures for the two-step departure picker (pick product,
|
|
48
|
+
* then departure). When provided alongside `searchTargets`, departure
|
|
49
|
+
* allocation uses product → departure selects instead of a flat list.
|
|
50
|
+
*/
|
|
51
|
+
listDeparturesForProduct?: (productId: string, query: string) => Promise<AsyncComboboxOption[]>;
|
|
52
|
+
/** Optional invoice-extraction extension point for the edit dialog. */
|
|
53
|
+
extractFromFile?: (file: File) => Promise<SupplierInvoiceExtraction>;
|
|
54
|
+
/** Search suppliers for the edit dialog's supplier picker. */
|
|
55
|
+
searchSuppliers?: (query: string) => Promise<AsyncComboboxOption[]>;
|
|
56
|
+
/** Create a supplier inline from the edit dialog's supplier picker. */
|
|
57
|
+
createSupplier?: (name: string) => Promise<AsyncComboboxOption | null>;
|
|
58
|
+
}
|
|
59
|
+
export declare function formatFileSize(bytes: number | null): string;
|
|
60
|
+
export declare function Field({ label, value }: {
|
|
61
|
+
label: string;
|
|
62
|
+
value: string;
|
|
63
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
64
|
+
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../../src/components/supplier-invoice-detail-page/shared.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,2BAA2B,EAC3B,4BAA4B,EAC5B,wBAAwB,EACxB,yBAAyB,EACzB,qBAAqB,EACtB,MAAM,gBAAgB,CAAA;AACvB,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAC/D,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAA;AAEnF,MAAM,MAAM,2BAA2B,GAAG,CACxC,UAAU,EAAE,WAAW,GAAG,SAAS,GAAG,SAAS,GAAG,UAAU,EAC5D,KAAK,EAAE,MAAM,KACV,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAAA;AAEnC,eAAO,MAAM,cAAc,EAAE,MAAM,CACjC,qBAAqB,EACrB,SAAS,GAAG,WAAW,GAAG,aAAa,GAAG,SAAS,CASpD,CAAA;AAED,eAAO,MAAM,YAAY,0EAA2E,CAAA;AACpG,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAA;AAEtD;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,wEAA2D,CAAA;AAE1F,eAAO,MAAM,kBAAkB,aAAa,CAAA;AAE5C,eAAO,MAAM,eAAe,sEAAuE,CAAA;AAEnG,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAG7C;AAED,wBAAgB,WAAW,CACzB,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,2BAA2B,CAAC,CAatC;AAED,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,4BAA4B,GAAG,2BAA2B,CAO9F;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,yBAAyB,GAAG,wBAAwB,CAYrF;AAED,MAAM,WAAW,+BAA+B;IAC9C,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CACzB;AAED,MAAM,WAAW,8BAA8B;IAC7C,EAAE,EAAE,MAAM,CAAA;IACV,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,sEAAsE;IACtE,MAAM,CAAC,EAAE,MAAM,IAAI,CAAA;IACnB,kEAAkE;IAClE,kBAAkB,CAAC,EAAE,MAAM,IAAI,CAAA;IAC/B;;;;OAIG;IACH,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,+BAA+B,CAAC,CAAA;IACrE,qEAAqE;IACrE,oBAAoB,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,IAAI,CAAA;IACrD;;;;OAIG;IACH,aAAa,CAAC,EAAE,2BAA2B,CAAA;IAC3C;;;;OAIG;IACH,wBAAwB,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAAA;IAC/F,uEAAuE;IACvE,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,yBAAyB,CAAC,CAAA;IACpE,8DAA8D;IAC9D,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAAA;IACnE,uEAAuE;IACvE,cAAc,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAAA;CACvE;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAK3D;AAED,wBAAgB,KAAK,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,2CAOvE"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
export const STATUS_VARIANT = {
|
|
3
|
+
draft: "outline",
|
|
4
|
+
received: "secondary",
|
|
5
|
+
approved: "secondary",
|
|
6
|
+
partially_paid: "default",
|
|
7
|
+
paid: "default",
|
|
8
|
+
disputed: "destructive",
|
|
9
|
+
void: "outline",
|
|
10
|
+
};
|
|
11
|
+
export const TARGET_TYPES = ["departure", "product", "booking", "traveler", "unattributed"];
|
|
12
|
+
/**
|
|
13
|
+
* Target types that support search-and-select; others fall back to a text id.
|
|
14
|
+
* Departure search is product-centric (search a product → pick its dated slot),
|
|
15
|
+
* wired by the host. Travelers have no global search, so they stay raw-id.
|
|
16
|
+
*/
|
|
17
|
+
export const SEARCHABLE_TARGETS = new Set(["departure", "product", "booking"]);
|
|
18
|
+
export const LINE_CATEGORY_NONE = "__none__";
|
|
19
|
+
export const PAYMENT_METHODS = ["bank_transfer", "credit_card", "cash", "cheque", "other"];
|
|
20
|
+
export function toCents(major) {
|
|
21
|
+
const n = Number.parseFloat(major);
|
|
22
|
+
return Number.isFinite(n) ? Math.round(n * 100) : 0;
|
|
23
|
+
}
|
|
24
|
+
export function targetIdFor(targetType, targetId) {
|
|
25
|
+
switch (targetType) {
|
|
26
|
+
case "departure":
|
|
27
|
+
return { departureId: targetId };
|
|
28
|
+
case "product":
|
|
29
|
+
return { productId: targetId };
|
|
30
|
+
case "booking":
|
|
31
|
+
return { bookingId: targetId };
|
|
32
|
+
case "traveler":
|
|
33
|
+
return { travelerId: targetId };
|
|
34
|
+
default:
|
|
35
|
+
return {};
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export function allocationToInput(a) {
|
|
39
|
+
return {
|
|
40
|
+
targetType: a.targetType,
|
|
41
|
+
amountCents: a.amountCents,
|
|
42
|
+
splitMethod: a.splitMethod,
|
|
43
|
+
...targetIdFor(a.targetType, a.departureId ?? a.productId ?? a.bookingId ?? a.travelerId ?? ""),
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
export function lineToInput(line) {
|
|
47
|
+
return {
|
|
48
|
+
description: line.description,
|
|
49
|
+
serviceType: line.serviceType,
|
|
50
|
+
supplierServiceId: line.supplierServiceId,
|
|
51
|
+
quantity: line.quantity,
|
|
52
|
+
unitAmountCents: line.unitAmountCents,
|
|
53
|
+
taxRateBps: line.taxRateBps,
|
|
54
|
+
taxAmountCents: line.taxAmountCents,
|
|
55
|
+
totalAmountCents: line.totalAmountCents,
|
|
56
|
+
sortOrder: line.sortOrder,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
export function formatFileSize(bytes) {
|
|
60
|
+
if (bytes == null)
|
|
61
|
+
return "—";
|
|
62
|
+
if (bytes < 1024)
|
|
63
|
+
return `${bytes} B`;
|
|
64
|
+
if (bytes < 1024 * 1024)
|
|
65
|
+
return `${(bytes / 1024).toFixed(1)} KB`;
|
|
66
|
+
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
67
|
+
}
|
|
68
|
+
export function Field({ label, value }) {
|
|
69
|
+
return (_jsxs("div", { className: "flex flex-col", children: [_jsx("span", { className: "text-xs text-muted-foreground", children: label }), _jsx("span", { className: "text-sm font-medium tabular-nums", children: value })] }));
|
|
70
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { SupplierInvoiceDetailPageProps } from "./supplier-invoice-detail-page/shared.js";
|
|
2
|
+
export declare function SupplierInvoiceDetailPage({ id, className, onBack, onDownloadDocument, uploadFile, onDownloadAttachment, searchTargets, listDeparturesForProduct, extractFromFile, searchSuppliers, createSupplier, }: SupplierInvoiceDetailPageProps): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
export type { SupplierInvoiceAttachmentUpload, SupplierInvoiceDetailPageProps, SupplierInvoiceTargetSearch, } from "./supplier-invoice-detail-page/shared.js";
|
|
4
|
+
//# sourceMappingURL=supplier-invoice-detail-page.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"supplier-invoice-detail-page.d.ts","sourceRoot":"","sources":["../../src/components/supplier-invoice-detail-page.tsx"],"names":[],"mappings":"AAgDA,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,0CAA0C,CAAA;AAU9F,wBAAgB,yBAAyB,CAAC,EACxC,EAAE,EACF,SAAS,EACT,MAAM,EACN,kBAAkB,EAClB,UAAU,EACV,oBAAoB,EACpB,aAAa,EACb,wBAAwB,EACxB,eAAe,EACf,eAAe,EACf,cAAc,GACf,EAAE,8BAA8B,2CA4dhC;AAID,YAAY,EACV,+BAA+B,EAC/B,8BAA8B,EAC9B,2BAA2B,GAC5B,MAAM,0CAA0C,CAAA"}
|