@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,134 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { cn } from "@voyant-travel/ui/lib/utils";
|
|
4
|
+
import { useState } from "react";
|
|
5
|
+
import { useFinanceUiMessagesOrDefault } from "../i18n/index.js";
|
|
6
|
+
import { useInvoice, useInvoiceAttachmentMutation, useInvoiceAttachments, useInvoiceCreditNotes, useInvoiceLineItemMutation, useInvoiceLineItems, useInvoiceMutation, useInvoiceNoteMutation, useInvoiceNotes, useInvoicePayments, useVoyantFinanceContext, } from "../index.js";
|
|
7
|
+
import { InvoiceAttachmentsCard, InvoiceCreditNotesCard, InvoiceLineItemsCard, InvoiceLinksCard, InvoicePaymentsCard, InvoiceSummaryCard, } from "./invoice-detail-page/cards.js";
|
|
8
|
+
import { InvoiceDetailHeader } from "./invoice-detail-page/header.js";
|
|
9
|
+
import { InvoiceAttachmentDialog, InvoiceNoteDialog, InvoiceNotesCard, } from "./invoice-detail-page/notes-dialogs.js";
|
|
10
|
+
import { InvoiceDetailLoading, InvoiceDetailState } from "./invoice-detail-page/primitives.js";
|
|
11
|
+
import { InvoiceDialog } from "./invoice-dialog.js";
|
|
12
|
+
function withApiBaseUrl(baseUrl, path) {
|
|
13
|
+
const trimmedBase = baseUrl.endsWith("/") ? baseUrl.slice(0, -1) : baseUrl;
|
|
14
|
+
const normalizedPath = path.startsWith("/") ? path : `/${path}`;
|
|
15
|
+
return `${trimmedBase}${normalizedPath}`;
|
|
16
|
+
}
|
|
17
|
+
function getDefaultInvoiceAttachmentDownloadHref(baseUrl, attachment) {
|
|
18
|
+
return withApiBaseUrl(baseUrl, `/v1/admin/finance/invoice-attachments/${attachment.id}/download`);
|
|
19
|
+
}
|
|
20
|
+
function renderInvoiceDetailIntegrationContent(content, context) {
|
|
21
|
+
return typeof content === "function" ? content(context) : content;
|
|
22
|
+
}
|
|
23
|
+
export function InvoiceDetailPage({ id, className, onBack, onDeleted, onBookingOpen, onPersonOpen, onOrganizationOpen, onLineItemCreate, onLineItemEdit, onPaymentCreate, onConverted, onCreditNoteCreate, getAttachmentDownloadHref, renderInvoiceNoteDialog, slots, }) {
|
|
24
|
+
const { baseUrl } = useVoyantFinanceContext();
|
|
25
|
+
const messages = useFinanceUiMessagesOrDefault();
|
|
26
|
+
const [editOpen, setEditOpen] = useState(false);
|
|
27
|
+
const [attachmentOpen, setAttachmentOpen] = useState(false);
|
|
28
|
+
const [editingAttachment, setEditingAttachment] = useState();
|
|
29
|
+
const [noteOpen, setNoteOpen] = useState(false);
|
|
30
|
+
const [actionError, setActionError] = useState(null);
|
|
31
|
+
const invoiceQuery = useInvoice(id);
|
|
32
|
+
const invoice = invoiceQuery.data?.data;
|
|
33
|
+
const lineItemsQuery = useInvoiceLineItems(id, { enabled: Boolean(invoice) });
|
|
34
|
+
const paymentsQuery = useInvoicePayments(id, { enabled: Boolean(invoice) });
|
|
35
|
+
const creditNotesQuery = useInvoiceCreditNotes(id, { enabled: Boolean(invoice) });
|
|
36
|
+
const attachmentsQuery = useInvoiceAttachments(id, { enabled: Boolean(invoice) });
|
|
37
|
+
const notesQuery = useInvoiceNotes(id, { enabled: Boolean(invoice) });
|
|
38
|
+
const { convertToInvoice, remove: removeInvoice, voidInvoice } = useInvoiceMutation();
|
|
39
|
+
const { remove: removeLineItem } = useInvoiceLineItemMutation(id);
|
|
40
|
+
const { remove: removeAttachment } = useInvoiceAttachmentMutation(id);
|
|
41
|
+
const addNote = useInvoiceNoteMutation(id);
|
|
42
|
+
if (invoiceQuery.isPending) {
|
|
43
|
+
return _jsx(InvoiceDetailLoading, { className: className });
|
|
44
|
+
}
|
|
45
|
+
if (invoiceQuery.isError || !invoice) {
|
|
46
|
+
return (_jsx(InvoiceDetailState, { className: className, message: invoiceQuery.isError
|
|
47
|
+
? invoiceQuery.error instanceof Error
|
|
48
|
+
? invoiceQuery.error.message
|
|
49
|
+
: messages.invoiceDetailPage.states.loadFailed
|
|
50
|
+
: messages.invoiceDetailPage.states.notFound, onBack: onBack }));
|
|
51
|
+
}
|
|
52
|
+
const lineItems = lineItemsQuery.data?.data ?? [];
|
|
53
|
+
const payments = paymentsQuery.data?.data ?? [];
|
|
54
|
+
const creditNotes = creditNotesQuery.data?.data ?? [];
|
|
55
|
+
const attachments = attachmentsQuery.data?.data ?? [];
|
|
56
|
+
const notes = notesQuery.data?.data ?? [];
|
|
57
|
+
const integrationsContent = renderInvoiceDetailIntegrationContent(slots?.integrationsContent, {
|
|
58
|
+
invoice,
|
|
59
|
+
});
|
|
60
|
+
const handleCreateNote = async (nextContent) => {
|
|
61
|
+
const content = nextContent.trim();
|
|
62
|
+
if (!content)
|
|
63
|
+
return;
|
|
64
|
+
await addNote.mutateAsync({ content });
|
|
65
|
+
setNoteOpen(false);
|
|
66
|
+
void notesQuery.refetch();
|
|
67
|
+
};
|
|
68
|
+
return (_jsxs("div", { "data-slot": "invoice-detail-page", className: cn("flex flex-col gap-6 p-6", className), children: [_jsx(InvoiceDetailHeader, { invoice: invoice, onBack: onBack, onEdit: () => setEditOpen(true), deletePending: removeInvoice.isPending, convertPending: convertToInvoice.isPending, voidPending: voidInvoice.isPending, onConvert: async () => {
|
|
69
|
+
try {
|
|
70
|
+
setActionError(null);
|
|
71
|
+
const converted = await convertToInvoice.mutateAsync({ id });
|
|
72
|
+
onConverted?.(converted, invoice);
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
setActionError(error instanceof Error
|
|
76
|
+
? error.message
|
|
77
|
+
: messages.invoiceDetailPage.actions.mutationFailed);
|
|
78
|
+
}
|
|
79
|
+
}, onVoid: async (reason) => {
|
|
80
|
+
try {
|
|
81
|
+
setActionError(null);
|
|
82
|
+
await voidInvoice.mutateAsync({ id, input: { reason } });
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
setActionError(error instanceof Error
|
|
86
|
+
? error.message
|
|
87
|
+
: messages.invoiceDetailPage.actions.mutationFailed);
|
|
88
|
+
}
|
|
89
|
+
}, onDelete: async () => {
|
|
90
|
+
try {
|
|
91
|
+
setActionError(null);
|
|
92
|
+
await removeInvoice.mutateAsync(id);
|
|
93
|
+
onDeleted?.();
|
|
94
|
+
onBack?.();
|
|
95
|
+
}
|
|
96
|
+
catch (error) {
|
|
97
|
+
setActionError(error instanceof Error
|
|
98
|
+
? error.message
|
|
99
|
+
: messages.invoiceDetailPage.actions.mutationFailed);
|
|
100
|
+
}
|
|
101
|
+
} }), actionError ? (_jsx("div", { className: "rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-destructive text-sm", children: actionError })) : null, slots?.afterHeader, _jsxs("div", { className: "grid gap-4 md:grid-cols-2", children: [_jsx(InvoiceSummaryCard, { invoice: invoice }), _jsx(InvoiceLinksCard, { invoice: invoice, onBookingOpen: onBookingOpen, onPersonOpen: onPersonOpen, onOrganizationOpen: onOrganizationOpen })] }), integrationsContent ? (_jsx("div", { "data-slot": "invoice-integrations-content", className: "grid gap-3", children: integrationsContent })) : null, slots?.afterSummary, slots?.lineItemsContent !== undefined ? (slots.lineItemsContent) : (_jsx(InvoiceLineItemsCard, { invoice: invoice, lineItems: lineItems, pending: lineItemsQuery.isPending, deletePending: removeLineItem.isPending, onCreate: onLineItemCreate, onEdit: onLineItemEdit, onDelete: async (lineItemId) => {
|
|
102
|
+
try {
|
|
103
|
+
setActionError(null);
|
|
104
|
+
await removeLineItem.mutateAsync(lineItemId);
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
setActionError(error instanceof Error
|
|
108
|
+
? error.message
|
|
109
|
+
: messages.invoiceDetailPage.actions.mutationFailed);
|
|
110
|
+
}
|
|
111
|
+
} })), slots?.afterLineItems, slots?.paymentsContent !== undefined ? (slots.paymentsContent) : (_jsx(InvoicePaymentsCard, { invoice: invoice, payments: payments, pending: paymentsQuery.isPending, onCreate: onPaymentCreate })), slots?.afterPayments, slots?.creditNotesContent !== undefined ? (slots.creditNotesContent) : (_jsx(InvoiceCreditNotesCard, { invoice: invoice, creditNotes: creditNotes, pending: creditNotesQuery.isPending, onCreate: onCreditNoteCreate })), slots?.afterCreditNotes, slots?.attachmentsContent !== undefined ? (slots.attachmentsContent) : (_jsx(InvoiceAttachmentsCard, { invoice: invoice, attachments: attachments, pending: attachmentsQuery.isPending, deletePending: removeAttachment.isPending, getDownloadHref: getAttachmentDownloadHref ??
|
|
112
|
+
((attachment) => getDefaultInvoiceAttachmentDownloadHref(baseUrl, attachment)), onCreate: () => {
|
|
113
|
+
setEditingAttachment(undefined);
|
|
114
|
+
setAttachmentOpen(true);
|
|
115
|
+
}, onEdit: (attachment) => {
|
|
116
|
+
setEditingAttachment(attachment);
|
|
117
|
+
setAttachmentOpen(true);
|
|
118
|
+
}, onDelete: async (attachmentId) => {
|
|
119
|
+
await removeAttachment.mutateAsync(attachmentId);
|
|
120
|
+
} })), slots?.afterAttachments, slots?.notesContent !== undefined ? (slots.notesContent) : (_jsx(InvoiceNotesCard, { notes: notes, pending: notesQuery.isPending, addPending: addNote.isPending, onCreate: () => setNoteOpen(true) })), slots?.afterNotes, _jsx(InvoiceDialog, { open: editOpen, onOpenChange: setEditOpen, invoice: invoice }), _jsx(InvoiceAttachmentDialog, { open: attachmentOpen, onOpenChange: setAttachmentOpen, invoiceId: id, attachment: editingAttachment, onSuccess: () => {
|
|
121
|
+
setAttachmentOpen(false);
|
|
122
|
+
setEditingAttachment(undefined);
|
|
123
|
+
void attachmentsQuery.refetch();
|
|
124
|
+
} }), renderInvoiceNoteDialog ? (renderInvoiceNoteDialog({
|
|
125
|
+
open: noteOpen,
|
|
126
|
+
onOpenChange: setNoteOpen,
|
|
127
|
+
pending: addNote.isPending,
|
|
128
|
+
onSubmit: handleCreateNote,
|
|
129
|
+
})) : (_jsx(InvoiceNoteDialog, { open: noteOpen, onOpenChange: setNoteOpen, pending: addNote.isPending, onSubmit: handleCreateNote })), slots?.dialogs] }));
|
|
130
|
+
}
|
|
131
|
+
export { InvoiceAttachmentsCard, InvoiceCreditNotesCard, InvoiceLineItemsCard, InvoiceLinksCard, InvoicePaymentsCard, InvoiceSummaryCard, } from "./invoice-detail-page/cards.js";
|
|
132
|
+
export { InvoiceDetailHeader } from "./invoice-detail-page/header.js";
|
|
133
|
+
export { InvoiceNoteDialog, InvoiceNotesCard, } from "./invoice-detail-page/notes-dialogs.js";
|
|
134
|
+
export { creditNoteStatusVariant, DetailLink, DetailRow, EmptyRow, formatPaymentMethod, InvoiceDetailLoading, InvoiceDetailState, InvoiceSection, invoiceStatusVariant, invoiceTypeVariant, LoadingRow, Money, paymentStatusVariant, } from "./invoice-detail-page/primitives.js";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type InvoiceRecord } from "../index.js";
|
|
2
|
+
export interface InvoiceDialogProps {
|
|
3
|
+
open: boolean;
|
|
4
|
+
onOpenChange: (open: boolean) => void;
|
|
5
|
+
invoice?: InvoiceRecord;
|
|
6
|
+
onSuccess?: (invoice: InvoiceRecord) => void;
|
|
7
|
+
}
|
|
8
|
+
export declare function InvoiceDialog({ open, onOpenChange, invoice, onSuccess }: InvoiceDialogProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
//# sourceMappingURL=invoice-dialog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invoice-dialog.d.ts","sourceRoot":"","sources":["../../src/components/invoice-dialog.tsx"],"names":[],"mappings":"AA4BA,OAAO,EAAE,KAAK,aAAa,EAAsB,MAAM,aAAa,CAAA;AAuBpE,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,OAAO,CAAA;IACb,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAA;IACrC,OAAO,CAAC,EAAE,aAAa,CAAA;IACvB,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,IAAI,CAAA;CAC7C;AASD,wBAAgB,aAAa,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,SAAS,EAAE,EAAE,kBAAkB,2CAyR3F"}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { BookingCombobox } from "@voyant-travel/bookings-react/ui";
|
|
3
|
+
import { Button, Dialog, DialogBody, DialogContent, DialogFooter, DialogHeader, DialogTitle, Input, Label, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, Textarea, } from "@voyant-travel/ui/components";
|
|
4
|
+
import { CurrencyCombobox } from "@voyant-travel/ui/components/currency-combobox";
|
|
5
|
+
import { CurrencyInput } from "@voyant-travel/ui/components/currency-input";
|
|
6
|
+
import { DatePicker } from "@voyant-travel/ui/components/date-picker";
|
|
7
|
+
import { zodResolver } from "@voyant-travel/ui/lib/zod-resolver";
|
|
8
|
+
import { Loader2 } from "lucide-react";
|
|
9
|
+
import { useEffect } from "react";
|
|
10
|
+
import { useForm } from "react-hook-form";
|
|
11
|
+
import { z } from "zod/v4";
|
|
12
|
+
import { useFinanceUiMessagesOrDefault } from "../i18n/index.js";
|
|
13
|
+
import { invoiceStatuses } from "../i18n/messages.js";
|
|
14
|
+
import { useInvoiceMutation } from "../index.js";
|
|
15
|
+
function createInvoiceFormSchema(messages) {
|
|
16
|
+
return z.object({
|
|
17
|
+
invoiceNumber: z.string().min(1, messages.invoiceDialog.validation.invoiceNumberRequired),
|
|
18
|
+
bookingId: z.string().min(1, messages.invoiceDialog.validation.bookingIdRequired),
|
|
19
|
+
personId: z.string().optional().nullable(),
|
|
20
|
+
organizationId: z.string().optional().nullable(),
|
|
21
|
+
status: z.enum(invoiceStatuses),
|
|
22
|
+
currency: z.string().min(3).max(3, messages.invoiceDialog.validation.currencyIsoCode),
|
|
23
|
+
subtotalCents: z.coerce.number().int().min(0).default(0),
|
|
24
|
+
taxCents: z.coerce.number().int().min(0).default(0),
|
|
25
|
+
totalCents: z.coerce.number().int().min(0).default(0),
|
|
26
|
+
issueDate: z.string().min(1, messages.invoiceDialog.validation.issueDateRequired),
|
|
27
|
+
dueDate: z.string().min(1, messages.invoiceDialog.validation.dueDateRequired),
|
|
28
|
+
notes: z.string().optional().nullable(),
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
function generateInvoiceNumber() {
|
|
32
|
+
const now = new Date();
|
|
33
|
+
const y = now.getFullYear();
|
|
34
|
+
const seq = String(Math.floor(Math.random() * 9000) + 1000);
|
|
35
|
+
return `INV-${y}-${seq}`;
|
|
36
|
+
}
|
|
37
|
+
export function InvoiceDialog({ open, onOpenChange, invoice, onSuccess }) {
|
|
38
|
+
const isEditing = Boolean(invoice);
|
|
39
|
+
const { create, update } = useInvoiceMutation();
|
|
40
|
+
const messages = useFinanceUiMessagesOrDefault();
|
|
41
|
+
const invoiceFormSchema = createInvoiceFormSchema(messages);
|
|
42
|
+
const form = useForm({
|
|
43
|
+
resolver: zodResolver(invoiceFormSchema),
|
|
44
|
+
defaultValues: {
|
|
45
|
+
invoiceNumber: "",
|
|
46
|
+
bookingId: "",
|
|
47
|
+
personId: "",
|
|
48
|
+
organizationId: "",
|
|
49
|
+
status: "draft",
|
|
50
|
+
currency: "EUR", // i18n-literal-ok domain default currency
|
|
51
|
+
subtotalCents: 0,
|
|
52
|
+
taxCents: 0,
|
|
53
|
+
totalCents: 0,
|
|
54
|
+
issueDate: "",
|
|
55
|
+
dueDate: "",
|
|
56
|
+
notes: "",
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
if (open && invoice) {
|
|
61
|
+
form.reset({
|
|
62
|
+
invoiceNumber: invoice.invoiceNumber,
|
|
63
|
+
bookingId: invoice.bookingId,
|
|
64
|
+
personId: invoice.personId ?? "",
|
|
65
|
+
organizationId: invoice.organizationId ?? "",
|
|
66
|
+
status: invoice.status,
|
|
67
|
+
currency: invoice.currency,
|
|
68
|
+
subtotalCents: invoice.subtotalCents,
|
|
69
|
+
taxCents: invoice.taxCents,
|
|
70
|
+
totalCents: invoice.totalCents,
|
|
71
|
+
issueDate: invoice.issueDate,
|
|
72
|
+
dueDate: invoice.dueDate,
|
|
73
|
+
notes: invoice.notes ?? "",
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
else if (open) {
|
|
77
|
+
const today = new Date().toISOString().split("T")[0];
|
|
78
|
+
form.reset({
|
|
79
|
+
invoiceNumber: generateInvoiceNumber(),
|
|
80
|
+
bookingId: "",
|
|
81
|
+
personId: "",
|
|
82
|
+
organizationId: "",
|
|
83
|
+
status: "draft",
|
|
84
|
+
currency: "EUR", // i18n-literal-ok domain default currency
|
|
85
|
+
subtotalCents: 0,
|
|
86
|
+
taxCents: 0,
|
|
87
|
+
totalCents: 0,
|
|
88
|
+
issueDate: today,
|
|
89
|
+
dueDate: "",
|
|
90
|
+
notes: "",
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
}, [open, invoice, form]);
|
|
94
|
+
const onSubmit = async (values) => {
|
|
95
|
+
const payload = {
|
|
96
|
+
invoiceNumber: values.invoiceNumber,
|
|
97
|
+
bookingId: values.bookingId,
|
|
98
|
+
personId: values.personId || null,
|
|
99
|
+
organizationId: values.organizationId || null,
|
|
100
|
+
status: values.status,
|
|
101
|
+
currency: values.currency,
|
|
102
|
+
subtotalCents: values.subtotalCents,
|
|
103
|
+
taxCents: values.taxCents,
|
|
104
|
+
totalCents: values.totalCents,
|
|
105
|
+
paidCents: invoice?.paidCents ?? 0,
|
|
106
|
+
balanceDueCents: typeof invoice?.paidCents === "number"
|
|
107
|
+
? values.totalCents - invoice.paidCents
|
|
108
|
+
: values.totalCents,
|
|
109
|
+
issueDate: values.issueDate,
|
|
110
|
+
dueDate: values.dueDate,
|
|
111
|
+
notes: values.notes || null,
|
|
112
|
+
};
|
|
113
|
+
const saved = isEditing
|
|
114
|
+
? await update.mutateAsync({ id: invoice.id, input: payload })
|
|
115
|
+
: await create.mutateAsync(payload);
|
|
116
|
+
onOpenChange(false);
|
|
117
|
+
onSuccess?.(saved);
|
|
118
|
+
};
|
|
119
|
+
const isSubmitting = create.isPending || update.isPending;
|
|
120
|
+
return (_jsx(Dialog, { open: open, onOpenChange: onOpenChange, children: _jsxs(DialogContent, { size: "lg", children: [_jsx(DialogHeader, { children: _jsx(DialogTitle, { children: isEditing ? messages.invoiceDialog.titles.edit : messages.invoiceDialog.titles.create }) }), _jsxs("form", { onSubmit: form.handleSubmit(onSubmit), children: [_jsxs(DialogBody, { className: "grid gap-4", children: [_jsxs("div", { className: "grid grid-cols-2 gap-4", children: [_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: messages.invoiceDialog.fields.invoiceNumber }), _jsx(Input, { ...form.register("invoiceNumber"), placeholder: messages.invoiceDialog.placeholders.invoiceNumber }), form.formState.errors.invoiceNumber ? (_jsx("p", { className: "text-xs text-destructive", children: form.formState.errors.invoiceNumber.message })) : null] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: messages.invoiceDialog.fields.status }), _jsxs(Select, { items: invoiceStatuses.map((value) => ({
|
|
121
|
+
label: messages.common.invoiceStatusLabels[value],
|
|
122
|
+
value,
|
|
123
|
+
})), value: form.watch("status"), onValueChange: (value) => form.setValue("status", value), children: [_jsx(SelectTrigger, { className: "w-full", children: _jsx(SelectValue, {}) }), _jsx(SelectContent, { children: invoiceStatuses.map((status) => (_jsx(SelectItem, { value: status, children: messages.common.invoiceStatusLabels[status] }, status))) })] })] })] }), _jsxs("div", { className: "grid grid-cols-2 gap-4", children: [_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: messages.invoiceDialog.fields.bookingId }), _jsx(BookingCombobox, { value: form.watch("bookingId") || null, onChange: (next) => form.setValue("bookingId", next ?? "", {
|
|
124
|
+
shouldDirty: true,
|
|
125
|
+
shouldValidate: true,
|
|
126
|
+
}), placeholder: messages.invoiceDialog.placeholders.bookingId }), form.formState.errors.bookingId ? (_jsx("p", { className: "text-xs text-destructive", children: form.formState.errors.bookingId.message })) : null] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: messages.invoiceDialog.fields.currency }), _jsx(CurrencyCombobox, { value: form.watch("currency") || null, onChange: (next) => form.setValue("currency", next ?? "EUR" /* i18n-literal-ok domain default currency */, {
|
|
127
|
+
shouldValidate: true,
|
|
128
|
+
shouldDirty: true,
|
|
129
|
+
}) })] })] }), _jsxs("div", { className: "grid grid-cols-3 gap-4", children: [_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: messages.invoiceDialog.fields.subtotalCents }), _jsx(CurrencyInput, { value: form.watch("subtotalCents"), onChange: (next) => form.setValue("subtotalCents", next ?? 0, {
|
|
130
|
+
shouldDirty: true,
|
|
131
|
+
shouldValidate: true,
|
|
132
|
+
}), currency: form.watch("currency") })] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: messages.invoiceDialog.fields.taxCents }), _jsx(CurrencyInput, { value: form.watch("taxCents"), onChange: (next) => form.setValue("taxCents", next ?? 0, {
|
|
133
|
+
shouldDirty: true,
|
|
134
|
+
shouldValidate: true,
|
|
135
|
+
}), currency: form.watch("currency") })] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: messages.invoiceDialog.fields.totalCents }), _jsx(CurrencyInput, { value: form.watch("totalCents"), onChange: (next) => form.setValue("totalCents", next ?? 0, {
|
|
136
|
+
shouldDirty: true,
|
|
137
|
+
shouldValidate: true,
|
|
138
|
+
}), currency: form.watch("currency") })] })] }), _jsxs("div", { className: "grid grid-cols-2 gap-4", children: [_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: messages.invoiceDialog.fields.issueDate }), _jsx(DatePicker, { value: form.watch("issueDate") || null, onChange: (nextValue) => form.setValue("issueDate", nextValue ?? "", {
|
|
139
|
+
shouldDirty: true,
|
|
140
|
+
shouldValidate: true,
|
|
141
|
+
}), placeholder: messages.invoiceDialog.placeholders.issueDate, className: "w-full" }), form.formState.errors.issueDate ? (_jsx("p", { className: "text-xs text-destructive", children: form.formState.errors.issueDate.message })) : null] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: messages.invoiceDialog.fields.dueDate }), _jsx(DatePicker, { value: form.watch("dueDate") || null, onChange: (nextValue) => form.setValue("dueDate", nextValue ?? "", {
|
|
142
|
+
shouldDirty: true,
|
|
143
|
+
shouldValidate: true,
|
|
144
|
+
}), placeholder: messages.invoiceDialog.placeholders.dueDate, className: "w-full" }), form.formState.errors.dueDate ? (_jsx("p", { className: "text-xs text-destructive", children: form.formState.errors.dueDate.message })) : null] })] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: messages.invoiceDialog.fields.notes }), _jsx(Textarea, { ...form.register("notes"), placeholder: messages.invoiceDialog.placeholders.notes })] })] }), _jsxs(DialogFooter, { children: [_jsx(Button, { type: "button", variant: "ghost", onClick: () => onOpenChange(false), children: messages.common.cancel }), _jsxs(Button, { type: "submit", disabled: isSubmitting, children: [isSubmitting ? _jsx(Loader2, { className: "mr-2 h-4 w-4 animate-spin" }) : null, isEditing ? messages.common.saveChanges : messages.invoiceDialog.actions.create] })] })] })] }) }));
|
|
145
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type InvoiceNumberSeriesRecord } from "../index.js";
|
|
2
|
+
export interface InvoiceNumberSeriesDialogProps {
|
|
3
|
+
open: boolean;
|
|
4
|
+
onOpenChange: (open: boolean) => void;
|
|
5
|
+
series?: InvoiceNumberSeriesRecord;
|
|
6
|
+
onSuccess?: () => void;
|
|
7
|
+
}
|
|
8
|
+
export declare function InvoiceNumberSeriesDialog({ open, onOpenChange, series, onSuccess, }: InvoiceNumberSeriesDialogProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
//# sourceMappingURL=invoice-number-series-dialog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invoice-number-series-dialog.d.ts","sourceRoot":"","sources":["../../src/components/invoice-number-series-dialog.tsx"],"names":[],"mappings":"AA0BA,OAAO,EACL,KAAK,yBAAyB,EAG/B,MAAM,aAAa,CAAA;AAyBpB,MAAM,WAAW,8BAA8B;IAC7C,IAAI,EAAE,OAAO,CAAA;IACb,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAA;IACrC,MAAM,CAAC,EAAE,yBAAyB,CAAA;IAClC,SAAS,CAAC,EAAE,MAAM,IAAI,CAAA;CACvB;AAoBD,wBAAgB,yBAAyB,CAAC,EACxC,IAAI,EACJ,YAAY,EACZ,MAAM,EACN,SAAS,GACV,EAAE,8BAA8B,2CAqPhC"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Button, Dialog, DialogBody, DialogContent, DialogFooter, DialogHeader, DialogTitle, Input, Label, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, Switch, } from "@voyant-travel/ui/components";
|
|
4
|
+
import { zodResolver } from "@voyant-travel/ui/lib/zod-resolver";
|
|
5
|
+
import { Loader2 } from "lucide-react";
|
|
6
|
+
import { useEffect } from "react";
|
|
7
|
+
import { useForm } from "react-hook-form";
|
|
8
|
+
import { z } from "zod/v4";
|
|
9
|
+
import { useFinanceUiMessagesOrDefault } from "../i18n/index.js";
|
|
10
|
+
import { invoiceNumberResetStrategies, invoiceNumberSeriesScopes } from "../i18n/messages.js";
|
|
11
|
+
import { useInvoiceNumberSeriesMutation, } from "../index.js";
|
|
12
|
+
import { formatInvoiceNumberSeriesSample } from "./invoice-number-series-format.js";
|
|
13
|
+
const seriesFormSchema = z.object({
|
|
14
|
+
code: z.string().min(1, "codeRequired").max(100),
|
|
15
|
+
name: z.string().min(1, "nameRequired").max(255),
|
|
16
|
+
prefix: z.string().max(50).default(""),
|
|
17
|
+
separator: z.string().max(10).default(""),
|
|
18
|
+
padLength: z.coerce
|
|
19
|
+
.number()
|
|
20
|
+
.int("padLengthInvalid")
|
|
21
|
+
.min(0, "padLengthInvalid")
|
|
22
|
+
.max(20, "padLengthInvalid"),
|
|
23
|
+
currentSequence: z.coerce.number().int("currentSequenceInvalid").min(0, "currentSequenceInvalid"),
|
|
24
|
+
resetStrategy: z.enum(invoiceNumberResetStrategies),
|
|
25
|
+
scope: z.enum(invoiceNumberSeriesScopes),
|
|
26
|
+
isDefault: z.boolean(),
|
|
27
|
+
externalProvider: z.string().max(100).optional(),
|
|
28
|
+
externalConfigKey: z.string().max(100).optional(),
|
|
29
|
+
active: z.boolean(),
|
|
30
|
+
});
|
|
31
|
+
function emptyToNull(value) {
|
|
32
|
+
const trimmed = value?.trim();
|
|
33
|
+
return trimmed ? trimmed : null;
|
|
34
|
+
}
|
|
35
|
+
function resolveValidation(messages, code) {
|
|
36
|
+
const validation = messages.invoiceNumberSeriesDialog.validation;
|
|
37
|
+
if (!code)
|
|
38
|
+
return "";
|
|
39
|
+
if (code === "codeRequired")
|
|
40
|
+
return validation.codeRequired;
|
|
41
|
+
if (code === "nameRequired")
|
|
42
|
+
return validation.nameRequired;
|
|
43
|
+
if (code === "padLengthInvalid")
|
|
44
|
+
return validation.padLengthInvalid;
|
|
45
|
+
if (code === "currentSequenceInvalid")
|
|
46
|
+
return validation.currentSequenceInvalid;
|
|
47
|
+
return code;
|
|
48
|
+
}
|
|
49
|
+
export function InvoiceNumberSeriesDialog({ open, onOpenChange, series, onSuccess, }) {
|
|
50
|
+
const messages = useFinanceUiMessagesOrDefault();
|
|
51
|
+
const dialog = messages.invoiceNumberSeriesDialog;
|
|
52
|
+
const page = messages.invoiceNumberSeriesPage;
|
|
53
|
+
const isEditing = !!series;
|
|
54
|
+
const { create, update } = useInvoiceNumberSeriesMutation();
|
|
55
|
+
const form = useForm({
|
|
56
|
+
resolver: zodResolver(seriesFormSchema),
|
|
57
|
+
defaultValues: {
|
|
58
|
+
code: "",
|
|
59
|
+
name: "",
|
|
60
|
+
prefix: "INV",
|
|
61
|
+
separator: "-",
|
|
62
|
+
padLength: 4,
|
|
63
|
+
currentSequence: 0,
|
|
64
|
+
resetStrategy: "never",
|
|
65
|
+
scope: "invoice",
|
|
66
|
+
isDefault: false,
|
|
67
|
+
externalProvider: "",
|
|
68
|
+
externalConfigKey: "",
|
|
69
|
+
active: true,
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
if (!open)
|
|
74
|
+
return;
|
|
75
|
+
if (series) {
|
|
76
|
+
form.reset({
|
|
77
|
+
code: series.code,
|
|
78
|
+
name: series.name,
|
|
79
|
+
prefix: series.prefix,
|
|
80
|
+
separator: series.separator,
|
|
81
|
+
padLength: series.padLength,
|
|
82
|
+
currentSequence: series.currentSequence,
|
|
83
|
+
resetStrategy: series.resetStrategy,
|
|
84
|
+
scope: series.scope,
|
|
85
|
+
isDefault: series.isDefault,
|
|
86
|
+
externalProvider: series.externalProvider ?? "",
|
|
87
|
+
externalConfigKey: series.externalConfigKey ?? "",
|
|
88
|
+
active: series.active,
|
|
89
|
+
});
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
form.reset();
|
|
93
|
+
}, [form, open, series]);
|
|
94
|
+
const onSubmit = async (values) => {
|
|
95
|
+
const payload = {
|
|
96
|
+
code: values.code.trim(),
|
|
97
|
+
name: values.name.trim(),
|
|
98
|
+
prefix: values.prefix,
|
|
99
|
+
separator: values.separator,
|
|
100
|
+
padLength: values.padLength,
|
|
101
|
+
currentSequence: values.currentSequence,
|
|
102
|
+
resetStrategy: values.resetStrategy,
|
|
103
|
+
scope: values.scope,
|
|
104
|
+
isDefault: values.isDefault,
|
|
105
|
+
externalProvider: emptyToNull(values.externalProvider),
|
|
106
|
+
externalConfigKey: emptyToNull(values.externalConfigKey),
|
|
107
|
+
active: values.active,
|
|
108
|
+
};
|
|
109
|
+
if (series) {
|
|
110
|
+
await update.mutateAsync({ id: series.id, input: payload });
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
await create.mutateAsync(payload);
|
|
114
|
+
}
|
|
115
|
+
onSuccess?.();
|
|
116
|
+
};
|
|
117
|
+
const prefix = form.watch("prefix") ?? "";
|
|
118
|
+
const separator = form.watch("separator") ?? "";
|
|
119
|
+
const currentSequence = Number(form.watch("currentSequence") ?? 0);
|
|
120
|
+
const padLength = Number(form.watch("padLength") ?? 4);
|
|
121
|
+
const preview = formatInvoiceNumberSeriesSample({
|
|
122
|
+
prefix,
|
|
123
|
+
separator,
|
|
124
|
+
currentSequence: Number.isFinite(currentSequence) ? currentSequence : 0,
|
|
125
|
+
padLength: Number.isFinite(padLength) ? padLength : 4,
|
|
126
|
+
});
|
|
127
|
+
return (_jsx(Dialog, { open: open, onOpenChange: onOpenChange, children: _jsxs(DialogContent, { size: "lg", children: [_jsx(DialogHeader, { children: _jsx(DialogTitle, { children: isEditing ? dialog.titleEdit : dialog.titleNew }) }), _jsxs("form", { onSubmit: form.handleSubmit(onSubmit), children: [_jsxs(DialogBody, { className: "grid gap-4", children: [_jsxs("div", { className: "grid gap-4 md:grid-cols-2", children: [_jsx(FieldError, { label: dialog.fields.code, error: form.formState.errors.code?.message, children: _jsx(Input, { ...form.register("code"), placeholder: dialog.placeholders.code }) }), _jsx(FieldError, { label: dialog.fields.name, error: form.formState.errors.name?.message, children: _jsx(Input, { ...form.register("name"), placeholder: dialog.placeholders.name }) })] }), _jsxs("div", { className: "grid gap-4 md:grid-cols-4", children: [_jsx(FieldError, { label: dialog.fields.prefix, error: form.formState.errors.prefix?.message, children: _jsx(Input, { ...form.register("prefix"), placeholder: dialog.placeholders.prefix }) }), _jsx(FieldError, { label: dialog.fields.separator, error: form.formState.errors.separator?.message, children: _jsx(Input, { ...form.register("separator"), placeholder: dialog.placeholders.separator }) }), _jsx(FieldError, { label: dialog.fields.padLength, error: form.formState.errors.padLength?.message, children: _jsx(Input, { ...form.register("padLength"), type: "number", min: 0, max: 20 }) }), _jsx(FieldError, { label: dialog.fields.currentSequence, error: form.formState.errors.currentSequence?.message, children: _jsx(Input, { ...form.register("currentSequence"), type: "number", min: 0 }) })] }), _jsxs("div", { className: "rounded-md border bg-muted/30 p-3", children: [_jsx("div", { className: "text-sm font-medium", children: dialog.help.previewLabel }), _jsx("div", { className: "mt-1 font-mono text-sm", children: preview }), _jsx("p", { className: "mt-1 text-xs text-muted-foreground", children: dialog.help.previewSample })] }), _jsxs("div", { className: "grid gap-4 md:grid-cols-2", children: [_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: dialog.fields.resetStrategy }), _jsxs(Select, { value: form.watch("resetStrategy"), onValueChange: (value) => form.setValue("resetStrategy", value), children: [_jsx(SelectTrigger, { className: "w-full", children: _jsx(SelectValue, {}) }), _jsx(SelectContent, { children: invoiceNumberResetStrategies.map((value) => (_jsx(SelectItem, { value: value, children: page.resetStrategyLabels[value] }, value))) })] })] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: dialog.fields.scope }), _jsxs(Select, { value: form.watch("scope"), onValueChange: (value) => form.setValue("scope", value), children: [_jsx(SelectTrigger, { className: "w-full", children: _jsx(SelectValue, {}) }), _jsx(SelectContent, { children: invoiceNumberSeriesScopes.map((value) => (_jsx(SelectItem, { value: value, children: page.scopeLabels[value] }, value))) })] })] })] }), _jsxs("div", { className: "grid gap-4 md:grid-cols-2", children: [_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: dialog.fields.externalProvider }), _jsx(Input, { ...form.register("externalProvider"), placeholder: dialog.placeholders.externalProvider }), _jsx("p", { className: "text-xs text-muted-foreground", children: dialog.help.external })] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: dialog.fields.externalConfigKey }), _jsx(Input, { ...form.register("externalConfigKey"), placeholder: dialog.placeholders.externalConfigKey })] })] }), _jsxs("div", { className: "grid gap-3 rounded-md border p-3 md:grid-cols-2", children: [_jsx(SwitchField, { label: dialog.fields.isDefault, help: dialog.help.default, checked: form.watch("isDefault"), onCheckedChange: (checked) => form.setValue("isDefault", checked) }), _jsx(SwitchField, { label: dialog.fields.active, checked: form.watch("active"), onCheckedChange: (checked) => form.setValue("active", checked) })] })] }), _jsxs(DialogFooter, { children: [_jsx(Button, { type: "button", variant: "ghost", onClick: () => onOpenChange(false), children: messages.common.cancel }), _jsxs(Button, { type: "submit", disabled: form.formState.isSubmitting, children: [form.formState.isSubmitting ? (_jsx(Loader2, { className: "mr-2 h-4 w-4 animate-spin" })) : null, isEditing ? messages.common.saveChanges : dialog.actions.create] })] })] })] }) }));
|
|
128
|
+
function FieldError({ children, error, label, }) {
|
|
129
|
+
return (_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: label }), children, error ? (_jsx("p", { className: "text-xs text-destructive", children: resolveValidation(messages, error) })) : null] }));
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
function SwitchField({ checked, help, label, onCheckedChange, }) {
|
|
133
|
+
return (_jsxs("div", { className: "flex items-start gap-3", children: [_jsx(Switch, { checked: checked, onCheckedChange: onCheckedChange }), _jsxs("div", { className: "space-y-1", children: [_jsx(Label, { children: label }), help ? _jsx("p", { className: "text-xs text-muted-foreground", children: help }) : null] })] }));
|
|
134
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { InvoiceNumberSeriesRecord } from "../index.js";
|
|
2
|
+
export declare function formatInvoiceNumberSeriesSample(series: Pick<InvoiceNumberSeriesRecord, "currentSequence" | "padLength" | "prefix" | "separator">): string;
|
|
3
|
+
//# sourceMappingURL=invoice-number-series-format.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invoice-number-series-format.d.ts","sourceRoot":"","sources":["../../src/components/invoice-number-series-format.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAA;AAE5D,wBAAgB,+BAA+B,CAC7C,MAAM,EAAE,IAAI,CAAC,yBAAyB,EAAE,iBAAiB,GAAG,WAAW,GAAG,QAAQ,GAAG,WAAW,CAAC,UAIlG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invoice-number-series-page.d.ts","sourceRoot":"","sources":["../../src/components/invoice-number-series-page.tsx"],"names":[],"mappings":"AAgCA,MAAM,WAAW,4BAA4B;IAC3C,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAQD,wBAAgB,uBAAuB,CAAC,EAAE,SAAS,EAAE,GAAE,4BAAiC,2CAoLvF"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { formatMessage } from "@voyant-travel/i18n";
|
|
4
|
+
import { Badge, Button, Label, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "@voyant-travel/ui/components";
|
|
5
|
+
import { cn } from "@voyant-travel/ui/lib/utils";
|
|
6
|
+
import { Loader2, Pencil, Plus, Trash2 } from "lucide-react";
|
|
7
|
+
import { useState } from "react";
|
|
8
|
+
import { useFinanceUiMessagesOrDefault } from "../i18n/index.js";
|
|
9
|
+
import { invoiceNumberSeriesScopes } from "../i18n/messages.js";
|
|
10
|
+
import { useInvoiceNumberSeries, useInvoiceNumberSeriesMutation, } from "../index.js";
|
|
11
|
+
import { InvoiceNumberSeriesDialog } from "./invoice-number-series-dialog.js";
|
|
12
|
+
import { formatInvoiceNumberSeriesSample } from "./invoice-number-series-format.js";
|
|
13
|
+
const SCOPE_ALL = "__all__";
|
|
14
|
+
const ACTIVE_ALL = "__all__";
|
|
15
|
+
const ACTIVE_ONLY = "active";
|
|
16
|
+
const INACTIVE_ONLY = "inactive";
|
|
17
|
+
function activeFilterToBoolean(value) {
|
|
18
|
+
if (value === ACTIVE_ONLY)
|
|
19
|
+
return true;
|
|
20
|
+
if (value === INACTIVE_ONLY)
|
|
21
|
+
return false;
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
export function InvoiceNumberSeriesPage({ className } = {}) {
|
|
25
|
+
const messages = useFinanceUiMessagesOrDefault();
|
|
26
|
+
const page = messages.invoiceNumberSeriesPage;
|
|
27
|
+
const [scope, setScope] = useState(SCOPE_ALL);
|
|
28
|
+
const [active, setActive] = useState(ACTIVE_ALL);
|
|
29
|
+
const [dialogOpen, setDialogOpen] = useState(false);
|
|
30
|
+
const [editingSeries, setEditingSeries] = useState();
|
|
31
|
+
const activeFilter = activeFilterToBoolean(active);
|
|
32
|
+
const { data, isPending, isError, refetch } = useInvoiceNumberSeries({
|
|
33
|
+
limit: 100,
|
|
34
|
+
offset: 0,
|
|
35
|
+
...(scope === SCOPE_ALL ? {} : { scope: scope }),
|
|
36
|
+
...(activeFilter === undefined ? {} : { active: activeFilter }),
|
|
37
|
+
});
|
|
38
|
+
const { remove } = useInvoiceNumberSeriesMutation();
|
|
39
|
+
const rows = data?.data ?? [];
|
|
40
|
+
return (_jsxs("div", { className: cn("flex flex-col gap-6 p-6", className), children: [_jsxs("div", { className: "flex flex-wrap items-start justify-between gap-3", children: [_jsxs("div", { children: [_jsx("h1", { className: "text-2xl font-bold tracking-tight", children: page.title }), _jsx("p", { className: "text-sm text-muted-foreground", children: page.description })] }), _jsxs(Button, { onClick: () => {
|
|
41
|
+
setEditingSeries(undefined);
|
|
42
|
+
setDialogOpen(true);
|
|
43
|
+
}, children: [_jsx(Plus, { className: "mr-2 h-4 w-4" }), page.actions.create] })] }), _jsxs("div", { className: "flex flex-wrap items-end gap-3", children: [_jsxs("div", { className: "flex min-w-48 flex-col gap-1.5", children: [_jsx(Label, { children: page.filters.scopeLabel }), _jsxs(Select, { value: scope, onValueChange: (value) => setScope(value ?? SCOPE_ALL), children: [_jsx(SelectTrigger, { className: "w-full", children: _jsx(SelectValue, {}) }), _jsxs(SelectContent, { children: [_jsx(SelectItem, { value: SCOPE_ALL, children: page.filters.scopeAll }), invoiceNumberSeriesScopes.map((value) => (_jsx(SelectItem, { value: value, children: page.scopeLabels[value] }, value)))] })] })] }), _jsxs("div", { className: "flex min-w-48 flex-col gap-1.5", children: [_jsx(Label, { children: page.filters.activeLabel }), _jsxs(Select, { value: active, onValueChange: (value) => setActive(value ?? ACTIVE_ALL), children: [_jsx(SelectTrigger, { className: "w-full", children: _jsx(SelectValue, {}) }), _jsxs(SelectContent, { children: [_jsx(SelectItem, { value: ACTIVE_ALL, children: page.filters.activeAll }), _jsx(SelectItem, { value: ACTIVE_ONLY, children: page.filters.activeOnly }), _jsx(SelectItem, { value: INACTIVE_ONLY, children: page.filters.inactiveOnly })] })] })] })] }), isPending ? (_jsx("div", { className: "flex items-center justify-center py-12", children: _jsx(Loader2, { className: "h-6 w-6 animate-spin text-muted-foreground" }) })) : null, !isPending && isError ? (_jsx("div", { className: "rounded-md border border-destructive/30 bg-destructive/5 p-4 text-sm text-destructive", children: page.loadFailed })) : null, !isPending && !isError && rows.length === 0 ? (_jsx("div", { className: "rounded-md border border-dashed p-8 text-center", children: _jsx("p", { className: "text-sm text-muted-foreground", children: page.empty }) })) : null, !isPending && !isError && rows.length > 0 ? (_jsx("div", { className: "overflow-hidden rounded border bg-background", children: _jsx("div", { className: "overflow-x-auto", children: _jsxs("table", { className: "w-full text-sm", children: [_jsx("thead", { children: _jsxs("tr", { className: "border-b text-muted-foreground", children: [_jsx("th", { className: "p-3 text-left font-medium", children: page.columns.code }), _jsx("th", { className: "p-3 text-left font-medium", children: page.columns.name }), _jsx("th", { className: "p-3 text-left font-medium", children: page.columns.prefix }), _jsx("th", { className: "p-3 text-left font-medium", children: page.columns.current }), _jsx("th", { className: "p-3 text-left font-medium", children: page.columns.reset }), _jsx("th", { className: "p-3 text-left font-medium", children: page.columns.scope }), _jsx("th", { className: "p-3 text-left font-medium", children: page.columns.default }), _jsx("th", { className: "p-3 text-left font-medium", children: page.columns.status }), _jsx("th", { className: "p-3 text-left font-medium", children: page.columns.external }), _jsx("th", { className: "w-20 p-3" })] }) }), _jsx("tbody", { children: rows.map((series) => (_jsxs("tr", { className: "border-b last:border-b-0", children: [_jsx("td", { className: "p-3 font-mono", children: series.code }), _jsx("td", { className: "p-3", children: series.name }), _jsx("td", { className: "p-3 font-mono", children: formatInvoiceNumberSeriesSample(series) }), _jsx("td", { className: "p-3 font-mono", children: series.currentSequence }), _jsx("td", { className: "p-3", children: page.resetStrategyLabels[series.resetStrategy] }), _jsx("td", { className: "p-3", children: _jsx(Badge, { variant: "outline", children: page.scopeLabels[series.scope] }) }), _jsx("td", { className: "p-3", children: _jsx(Badge, { variant: series.isDefault ? "default" : "secondary", children: series.isDefault ? page.default : page.notDefault }) }), _jsx("td", { className: "p-3", children: _jsx(Badge, { variant: series.active ? "default" : "secondary", children: series.active ? page.active : page.inactive }) }), _jsx("td", { className: "p-3", children: series.externalProvider ? (_jsxs("span", { className: "font-mono text-xs", children: [series.externalProvider, series.externalConfigKey ? `/${series.externalConfigKey}` : ""] })) : (_jsx("span", { className: "text-muted-foreground", children: page.noExternalProvider })) }), _jsx("td", { className: "p-3", children: _jsxs("div", { className: "flex items-center gap-1", children: [_jsx("button", { type: "button", onClick: () => {
|
|
44
|
+
setEditingSeries(series);
|
|
45
|
+
setDialogOpen(true);
|
|
46
|
+
}, className: "text-muted-foreground hover:text-foreground", children: _jsx(Pencil, { className: "h-3.5 w-3.5" }) }), _jsx("button", { type: "button", onClick: () => {
|
|
47
|
+
if (confirm(formatMessage(page.deleteConfirm, { name: series.name }))) {
|
|
48
|
+
remove.mutate(series.id, { onSuccess: () => void refetch() });
|
|
49
|
+
}
|
|
50
|
+
}, className: "text-muted-foreground hover:text-destructive", children: _jsx(Trash2, { className: "h-3.5 w-3.5" }) })] }) })] }, series.id))) })] }) }) })) : null, _jsx(InvoiceNumberSeriesDialog, { open: dialogOpen, onOpenChange: setDialogOpen, series: editingSeries, onSuccess: () => {
|
|
51
|
+
setDialogOpen(false);
|
|
52
|
+
setEditingSeries(undefined);
|
|
53
|
+
void refetch();
|
|
54
|
+
} })] }));
|
|
55
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export declare const invoiceStatusVariant: Record<string, "default" | "secondary" | "outline" | "destructive">;
|
|
2
|
+
export declare function formatInvoiceAmount(cents: number, currency: string): string;
|
|
3
|
+
interface SortHeaderProps<TField extends string> {
|
|
4
|
+
label: string;
|
|
5
|
+
field: TField;
|
|
6
|
+
sortBy: string;
|
|
7
|
+
sortDir: "asc" | "desc";
|
|
8
|
+
onSort: (field: TField) => void;
|
|
9
|
+
}
|
|
10
|
+
export declare function SortHeader<TField extends string>({ label, field, sortBy, sortDir, onSort, }: SortHeaderProps<TField>): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export declare function PaginationBar({ shown, total, page, pageCount, onPrevious, onNext, canGoBack, canGoForward, }: {
|
|
12
|
+
shown: number;
|
|
13
|
+
total: number;
|
|
14
|
+
page: number;
|
|
15
|
+
pageCount: number;
|
|
16
|
+
onPrevious: () => void;
|
|
17
|
+
onNext: () => void;
|
|
18
|
+
canGoBack: boolean;
|
|
19
|
+
canGoForward: boolean;
|
|
20
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
export declare function InvoiceRowSkeleton({ rows }: {
|
|
22
|
+
rows: number;
|
|
23
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=invoice-table-parts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invoice-table-parts.d.ts","sourceRoot":"","sources":["../../src/components/invoice-table-parts.tsx"],"names":[],"mappings":"AAQA,eAAO,MAAM,oBAAoB,EAAE,MAAM,CACvC,MAAM,EACN,SAAS,GAAG,WAAW,GAAG,SAAS,GAAG,aAAa,CASpD,CAAA;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE3E;AAED,UAAU,eAAe,CAAC,MAAM,SAAS,MAAM;IAC7C,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,KAAK,GAAG,MAAM,CAAA;IACvB,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;CAChC;AAED,wBAAgB,UAAU,CAAC,MAAM,SAAS,MAAM,EAAE,EAChD,KAAK,EACL,KAAK,EACL,MAAM,EACN,OAAO,EACP,MAAM,GACP,EAAE,eAAe,CAAC,MAAM,CAAC,2CAgBzB;AAED,wBAAgB,aAAa,CAAC,EAC5B,KAAK,EACL,KAAK,EACL,IAAI,EACJ,SAAS,EACT,UAAU,EACV,MAAM,EACN,SAAS,EACT,YAAY,GACb,EAAE;IACD,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,EAAE,MAAM,IAAI,CAAA;IACtB,MAAM,EAAE,MAAM,IAAI,CAAA;IAClB,SAAS,EAAE,OAAO,CAAA;IAClB,YAAY,EAAE,OAAO,CAAA;CACtB,2CAiBA;AAED,wBAAgB,kBAAkB,CAAC,EAAE,IAAI,EAAE,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,2CA+B5D"}
|
|
@@ -0,0 +1,32 @@
|
|
|
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 } from "@voyant-travel/ui/components/button";
|
|
4
|
+
import { Skeleton } from "@voyant-travel/ui/components/skeleton";
|
|
5
|
+
import { TableCell, TableRow } from "@voyant-travel/ui/components/table";
|
|
6
|
+
import { ArrowDown, ArrowUp, ArrowUpDown } from "lucide-react";
|
|
7
|
+
import { useFinanceUiMessagesOrDefault } from "../i18n/index.js";
|
|
8
|
+
export const invoiceStatusVariant = {
|
|
9
|
+
draft: "outline",
|
|
10
|
+
pending_external_allocation: "outline",
|
|
11
|
+
issued: "secondary",
|
|
12
|
+
partially_paid: "secondary",
|
|
13
|
+
paid: "default",
|
|
14
|
+
overdue: "destructive",
|
|
15
|
+
void: "destructive",
|
|
16
|
+
};
|
|
17
|
+
export function formatInvoiceAmount(cents, currency) {
|
|
18
|
+
return `${(cents / 100).toFixed(2)} ${currency}`;
|
|
19
|
+
}
|
|
20
|
+
export function SortHeader({ label, field, sortBy, sortDir, onSort, }) {
|
|
21
|
+
const active = sortBy === field;
|
|
22
|
+
const Icon = active ? (sortDir === "asc" ? ArrowUp : ArrowDown) : ArrowUpDown;
|
|
23
|
+
return (_jsxs("button", { type: "button", onClick: () => onSort(field), className: "-ml-2 inline-flex h-8 items-center gap-1 rounded-sm px-2 hover:bg-muted/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring", children: [_jsx("span", { children: label }), _jsx(Icon, { className: `size-3.5 ${active ? "text-foreground" : "text-muted-foreground/60"}`, "aria-hidden": true })] }));
|
|
24
|
+
}
|
|
25
|
+
export function PaginationBar({ shown, total, page, pageCount, onPrevious, onNext, canGoBack, canGoForward, }) {
|
|
26
|
+
const messages = useFinanceUiMessagesOrDefault();
|
|
27
|
+
const f = messages.invoicesPage.pagination;
|
|
28
|
+
return (_jsxs("div", { className: "flex items-center justify-between text-sm text-muted-foreground", children: [_jsx("span", { children: formatMessage(f.showing, { count: shown, total }) }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Button, { variant: "outline", size: "sm", disabled: !canGoBack, onClick: onPrevious, children: f.previous }), _jsx("span", { children: formatMessage(f.page, { page, pageCount }) }), _jsx(Button, { variant: "outline", size: "sm", disabled: !canGoForward, onClick: onNext, children: f.next })] })] }));
|
|
29
|
+
}
|
|
30
|
+
export function InvoiceRowSkeleton({ rows }) {
|
|
31
|
+
return (_jsx(_Fragment, { children: Array.from({ length: rows }).map((_, idx) => (_jsxs(TableRow, { children: [_jsx(TableCell, { children: _jsx(Skeleton, { className: "size-4" }) }), _jsx(TableCell, { children: _jsx(Skeleton, { className: "h-4 w-32" }) }), _jsx(TableCell, { children: _jsx(Skeleton, { className: "h-5 w-20 rounded-full" }) }), _jsx(TableCell, { children: _jsx(Skeleton, { className: "h-4 w-24" }) }), _jsx(TableCell, { children: _jsx(Skeleton, { className: "h-4 w-24" }) }), _jsx(TableCell, { children: _jsx(Skeleton, { className: "h-4 w-24" }) }), _jsx(TableCell, { children: _jsx(Skeleton, { className: "h-4 w-24" }) })] }, `skeleton-${idx}`))) }));
|
|
32
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invoices-page-skeleton.d.ts","sourceRoot":"","sources":["../../src/components/invoices-page-skeleton.tsx"],"names":[],"mappings":"AAcA,wBAAgB,qBAAqB,CAAC,EAAE,IAAQ,EAAE,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,2CAiCpE;AAED,wBAAgB,oBAAoB,4CAgBnC"}
|