@dainamite/billing 0.20.0 → 0.22.0
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/CHANGELOG.md +103 -0
- package/dist/modules/billing/acl.js +13 -1
- package/dist/modules/billing/acl.js.map +2 -2
- package/dist/modules/billing/api/accounts/[id]/summary/route.js +52 -0
- package/dist/modules/billing/api/accounts/[id]/summary/route.js.map +7 -0
- package/dist/modules/billing/api/accounts/route.js +47 -4
- package/dist/modules/billing/api/accounts/route.js.map +2 -2
- package/dist/modules/billing/api/export/account/[id]/route.js +11 -7
- package/dist/modules/billing/api/export/account/[id]/route.js.map +2 -2
- package/dist/modules/billing/api/invoices/[id]/memos/route.js +54 -0
- package/dist/modules/billing/api/invoices/[id]/memos/route.js.map +7 -0
- package/dist/modules/billing/api/invoices/[id]/pdf/route.js +70 -0
- package/dist/modules/billing/api/invoices/[id]/pdf/route.js.map +7 -0
- package/dist/modules/billing/api/invoices/[id]/route.js +44 -24
- package/dist/modules/billing/api/invoices/[id]/route.js.map +2 -2
- package/dist/modules/billing/api/invoices/[id]/send/route.js +107 -0
- package/dist/modules/billing/api/invoices/[id]/send/route.js.map +7 -0
- package/dist/modules/billing/api/invoices/add-line/route.js +2 -2
- package/dist/modules/billing/api/invoices/add-line/route.js.map +2 -2
- package/dist/modules/billing/api/invoices/delete-draft/route.js +33 -0
- package/dist/modules/billing/api/invoices/delete-draft/route.js.map +7 -0
- package/dist/modules/billing/api/invoices/edit-line/route.js +2 -2
- package/dist/modules/billing/api/invoices/edit-line/route.js.map +2 -2
- package/dist/modules/billing/api/invoices/post/route.js +2 -2
- package/dist/modules/billing/api/invoices/post/route.js.map +2 -2
- package/dist/modules/billing/api/invoices/remove-line/route.js +2 -2
- package/dist/modules/billing/api/invoices/remove-line/route.js.map +2 -2
- package/dist/modules/billing/api/invoices/route.js +45 -46
- package/dist/modules/billing/api/invoices/route.js.map +2 -2
- package/dist/modules/billing/api/items/bulk/route.js +1 -1
- package/dist/modules/billing/api/items/bulk/route.js.map +2 -2
- package/dist/modules/billing/api/items/change-price/route.js +44 -0
- package/dist/modules/billing/api/items/change-price/route.js.map +7 -0
- package/dist/modules/billing/api/items/route.js +19 -7
- package/dist/modules/billing/api/items/route.js.map +2 -2
- package/dist/modules/billing/api/payment-imports/[id]/route.js +49 -0
- package/dist/modules/billing/api/payment-imports/[id]/route.js.map +7 -0
- package/dist/modules/billing/api/payment-imports/route.js +57 -0
- package/dist/modules/billing/api/payment-imports/route.js.map +7 -0
- package/dist/modules/billing/api/payments/[id]/route.js +60 -0
- package/dist/modules/billing/api/payments/[id]/route.js.map +7 -0
- package/dist/modules/billing/api/payments/allocate/route.js +35 -0
- package/dist/modules/billing/api/payments/allocate/route.js.map +7 -0
- package/dist/modules/billing/api/payments/assign/route.js +36 -0
- package/dist/modules/billing/api/payments/assign/route.js.map +7 -0
- package/dist/modules/billing/api/payments/convert-to-topup/route.js +35 -0
- package/dist/modules/billing/api/payments/convert-to-topup/route.js.map +7 -0
- package/dist/modules/billing/api/payments/ignore/route.js +35 -0
- package/dist/modules/billing/api/payments/ignore/route.js.map +7 -0
- package/dist/modules/billing/api/payments/import/route.js +63 -0
- package/dist/modules/billing/api/payments/import/route.js.map +7 -0
- package/dist/modules/billing/api/payments/restore/route.js +35 -0
- package/dist/modules/billing/api/payments/restore/route.js.map +7 -0
- package/dist/modules/billing/api/payments/route.js +114 -0
- package/dist/modules/billing/api/payments/route.js.map +7 -0
- package/dist/modules/billing/api/payments/unallocate/route.js +35 -0
- package/dist/modules/billing/api/payments/unallocate/route.js.map +7 -0
- package/dist/modules/billing/api/payments/unassign/route.js +35 -0
- package/dist/modules/billing/api/payments/unassign/route.js.map +7 -0
- package/dist/modules/billing/api/run-outcomes/route.js +43 -6
- package/dist/modules/billing/api/run-outcomes/route.js.map +2 -2
- package/dist/modules/billing/api/runs/[id]/post-drafts/route.js +61 -0
- package/dist/modules/billing/api/runs/[id]/post-drafts/route.js.map +7 -0
- package/dist/modules/billing/api/runs/[id]/route.js +53 -0
- package/dist/modules/billing/api/runs/[id]/route.js.map +7 -0
- package/dist/modules/billing/api/runs/retry-failed/route.js +1 -1
- package/dist/modules/billing/api/runs/retry-failed/route.js.map +2 -2
- package/dist/modules/billing/api/runs/route.js +9 -3
- package/dist/modules/billing/api/runs/route.js.map +2 -2
- package/dist/modules/billing/api/settings/number-preview/route.js +42 -0
- package/dist/modules/billing/api/settings/number-preview/route.js.map +7 -0
- package/dist/modules/billing/api/settings/route.js +92 -0
- package/dist/modules/billing/api/settings/route.js.map +7 -0
- package/dist/modules/billing/api/statements/route.js +3 -0
- package/dist/modules/billing/api/statements/route.js.map +2 -2
- package/dist/modules/billing/api/test-invoices/wipe/route.js +2 -2
- package/dist/modules/billing/api/test-invoices/wipe/route.js.map +2 -2
- package/dist/modules/billing/backend/billing/accounts/[id]/page.js +121 -232
- package/dist/modules/billing/backend/billing/accounts/[id]/page.js.map +2 -2
- package/dist/modules/billing/backend/billing/accounts/create/page.js +6 -0
- package/dist/modules/billing/backend/billing/accounts/create/page.js.map +2 -2
- package/dist/modules/billing/backend/billing/accounts/page.js +63 -4
- package/dist/modules/billing/backend/billing/accounts/page.js.map +2 -2
- package/dist/modules/billing/backend/billing/invoices/[id]/page.js +297 -65
- package/dist/modules/billing/backend/billing/invoices/[id]/page.js.map +3 -3
- package/dist/modules/billing/backend/billing/invoices/page.js +6 -172
- package/dist/modules/billing/backend/billing/invoices/page.js.map +2 -2
- package/dist/modules/billing/backend/billing/items/[id]/page.js +51 -7
- package/dist/modules/billing/backend/billing/items/[id]/page.js.map +2 -2
- package/dist/modules/billing/backend/billing/items/create/page.js +9 -6
- package/dist/modules/billing/backend/billing/items/create/page.js.map +2 -2
- package/dist/modules/billing/backend/billing/items/page.js +8 -2
- package/dist/modules/billing/backend/billing/items/page.js.map +2 -2
- package/dist/modules/billing/backend/billing/payments/[id]/page.js +297 -0
- package/dist/modules/billing/backend/billing/payments/[id]/page.js.map +7 -0
- package/dist/modules/billing/backend/billing/payments/[id]/page.meta.js +21 -0
- package/dist/modules/billing/backend/billing/payments/[id]/page.meta.js.map +7 -0
- package/dist/modules/billing/backend/billing/payments/imports/[id]/page.js +74 -0
- package/dist/modules/billing/backend/billing/payments/imports/[id]/page.js.map +7 -0
- package/dist/modules/billing/backend/billing/payments/imports/[id]/page.meta.js +21 -0
- package/dist/modules/billing/backend/billing/payments/imports/[id]/page.meta.js.map +7 -0
- package/dist/modules/billing/backend/billing/payments/page.js +58 -0
- package/dist/modules/billing/backend/billing/payments/page.js.map +7 -0
- package/dist/modules/billing/backend/billing/payments/page.meta.js +18 -0
- package/dist/modules/billing/backend/billing/payments/page.meta.js.map +7 -0
- package/dist/modules/billing/backend/billing/runs/[id]/page.js +49 -14
- package/dist/modules/billing/backend/billing/runs/[id]/page.js.map +2 -2
- package/dist/modules/billing/backend/billing/runs/page.js +58 -7
- package/dist/modules/billing/backend/billing/runs/page.js.map +2 -2
- package/dist/modules/billing/backend/billing/statements/[id]/page.js +61 -6
- package/dist/modules/billing/backend/billing/statements/[id]/page.js.map +2 -2
- package/dist/modules/billing/backend/billing/statements/page.js +1 -1
- package/dist/modules/billing/backend/billing/statements/page.js.map +2 -2
- package/dist/modules/billing/backend/billing/topups/page.js +1 -1
- package/dist/modules/billing/backend/billing/topups/page.js.map +2 -2
- package/dist/modules/billing/backend/billing/transactions/page.js +1 -1
- package/dist/modules/billing/backend/billing/transactions/page.js.map +2 -2
- package/dist/modules/billing/backend/billing/usage/create/page.js +3 -2
- package/dist/modules/billing/backend/billing/usage/create/page.js.map +2 -2
- package/dist/modules/billing/backend/config/billing/page.js +472 -0
- package/dist/modules/billing/backend/config/billing/page.js.map +7 -0
- package/dist/modules/billing/backend/config/billing/page.meta.js +19 -0
- package/dist/modules/billing/backend/config/billing/page.meta.js.map +7 -0
- package/dist/modules/billing/cli.js +22 -1
- package/dist/modules/billing/cli.js.map +2 -2
- package/dist/modules/billing/commands/accounts.js +6 -0
- package/dist/modules/billing/commands/accounts.js.map +2 -2
- package/dist/modules/billing/commands/index.js +3 -0
- package/dist/modules/billing/commands/index.js.map +2 -2
- package/dist/modules/billing/commands/invoices.js +269 -167
- package/dist/modules/billing/commands/invoices.js.map +2 -2
- package/dist/modules/billing/commands/items.js +108 -0
- package/dist/modules/billing/commands/items.js.map +2 -2
- package/dist/modules/billing/commands/memos.js +179 -0
- package/dist/modules/billing/commands/memos.js.map +7 -0
- package/dist/modules/billing/commands/payments.js +379 -0
- package/dist/modules/billing/commands/payments.js.map +7 -0
- package/dist/modules/billing/commands/runs.js +151 -4
- package/dist/modules/billing/commands/runs.js.map +2 -2
- package/dist/modules/billing/commands/settings.js +59 -0
- package/dist/modules/billing/commands/settings.js.map +7 -0
- package/dist/modules/billing/commands/topups.js +9 -2
- package/dist/modules/billing/commands/topups.js.map +2 -2
- package/dist/modules/billing/commands/transactions.js +2 -2
- package/dist/modules/billing/commands/transactions.js.map +2 -2
- package/dist/modules/billing/components/AccountForm.js +149 -42
- package/dist/modules/billing/components/AccountForm.js.map +2 -2
- package/dist/modules/billing/components/AccountInvoicesSection.js +64 -0
- package/dist/modules/billing/components/AccountInvoicesSection.js.map +7 -0
- package/dist/modules/billing/components/AccountPaymentsSection.js +43 -0
- package/dist/modules/billing/components/AccountPaymentsSection.js.map +7 -0
- package/dist/modules/billing/components/AccountPicker.js +56 -0
- package/dist/modules/billing/components/AccountPicker.js.map +7 -0
- package/dist/modules/billing/components/AllocatePaymentDialog.js +134 -0
- package/dist/modules/billing/components/AllocatePaymentDialog.js.map +7 -0
- package/dist/modules/billing/components/BillingDataTable.js +21 -0
- package/dist/modules/billing/components/BillingDataTable.js.map +7 -0
- package/dist/modules/billing/components/BillingSettingsLink.js +19 -0
- package/dist/modules/billing/components/BillingSettingsLink.js.map +7 -0
- package/dist/modules/billing/components/ChangeItemPriceDialog.js +158 -0
- package/dist/modules/billing/components/ChangeItemPriceDialog.js.map +7 -0
- package/dist/modules/billing/components/CreateMemoDialog.js +200 -0
- package/dist/modules/billing/components/CreateMemoDialog.js.map +7 -0
- package/dist/modules/billing/components/CustomerLabel.js +33 -0
- package/dist/modules/billing/components/CustomerLabel.js.map +7 -0
- package/dist/modules/billing/components/InvoicesTable.js +270 -0
- package/dist/modules/billing/components/InvoicesTable.js.map +7 -0
- package/dist/modules/billing/components/ItemForm.js +176 -44
- package/dist/modules/billing/components/ItemForm.js.map +2 -2
- package/dist/modules/billing/components/ItemPriceField.js +46 -0
- package/dist/modules/billing/components/ItemPriceField.js.map +7 -0
- package/dist/modules/billing/components/LineFormDialog.js +25 -2
- package/dist/modules/billing/components/LineFormDialog.js.map +2 -2
- package/dist/modules/billing/components/ManualPaymentDialog.js +122 -0
- package/dist/modules/billing/components/ManualPaymentDialog.js.map +7 -0
- package/dist/modules/billing/components/MoneyInput.js +14 -0
- package/dist/modules/billing/components/MoneyInput.js.map +7 -0
- package/dist/modules/billing/components/PaymentUploadDialog.js +115 -0
- package/dist/modules/billing/components/PaymentUploadDialog.js.map +7 -0
- package/dist/modules/billing/components/PaymentsTable.js +171 -0
- package/dist/modules/billing/components/PaymentsTable.js.map +7 -0
- package/dist/modules/billing/components/PostRunDraftsButton.js +105 -0
- package/dist/modules/billing/components/PostRunDraftsButton.js.map +7 -0
- package/dist/modules/billing/components/PrepaidPanel.js +14 -4
- package/dist/modules/billing/components/PrepaidPanel.js.map +2 -2
- package/dist/modules/billing/components/RunCyclesSection.js +209 -0
- package/dist/modules/billing/components/RunCyclesSection.js.map +7 -0
- package/dist/modules/billing/components/TestRunActions.js +127 -0
- package/dist/modules/billing/components/TestRunActions.js.map +7 -0
- package/dist/modules/billing/components/account/AccountItemsTab.js +157 -0
- package/dist/modules/billing/components/account/AccountItemsTab.js.map +7 -0
- package/dist/modules/billing/components/account/AccountRunBillingDialog.js +122 -0
- package/dist/modules/billing/components/account/AccountRunBillingDialog.js.map +7 -0
- package/dist/modules/billing/components/account/AccountRunsTab.js +152 -0
- package/dist/modules/billing/components/account/AccountRunsTab.js.map +7 -0
- package/dist/modules/billing/components/account/AccountStatementsTab.js +98 -0
- package/dist/modules/billing/components/account/AccountStatementsTab.js.map +7 -0
- package/dist/modules/billing/components/account/AccountSummaryCards.js +125 -0
- package/dist/modules/billing/components/account/AccountSummaryCards.js.map +7 -0
- package/dist/modules/billing/components/account/AccountUsageTab.js +91 -0
- package/dist/modules/billing/components/account/AccountUsageTab.js.map +7 -0
- package/dist/modules/billing/components/account/AccountView.js +73 -0
- package/dist/modules/billing/components/account/AccountView.js.map +7 -0
- package/dist/modules/billing/components/account/accountRow.js +39 -0
- package/dist/modules/billing/components/account/accountRow.js.map +7 -0
- package/dist/modules/billing/components/customerNames.js +42 -0
- package/dist/modules/billing/components/customerNames.js.map +7 -0
- package/dist/modules/billing/data/entities.js +560 -4
- package/dist/modules/billing/data/entities.js.map +2 -2
- package/dist/modules/billing/data/entityIds.js +10 -1
- package/dist/modules/billing/data/entityIds.js.map +2 -2
- package/dist/modules/billing/data/validators.js +269 -15
- package/dist/modules/billing/data/validators.js.map +2 -2
- package/dist/modules/billing/events.js +50 -0
- package/dist/modules/billing/events.js.map +2 -2
- package/dist/modules/billing/i18n/de.json +880 -0
- package/dist/modules/billing/i18n/en.json +457 -21
- package/dist/modules/billing/i18n/es.json +880 -0
- package/dist/modules/billing/i18n/pl.json +458 -22
- package/dist/modules/billing/index.js +6 -2
- package/dist/modules/billing/index.js.map +2 -2
- package/dist/modules/billing/lib/accountFinancials.js +58 -0
- package/dist/modules/billing/lib/accountFinancials.js.map +7 -0
- package/dist/modules/billing/lib/accountLock.js +14 -0
- package/dist/modules/billing/lib/accountLock.js.map +7 -0
- package/dist/modules/billing/lib/accountStatus.js +9 -7
- package/dist/modules/billing/lib/accountStatus.js.map +2 -2
- package/dist/modules/billing/lib/accountSummary.js +106 -0
- package/dist/modules/billing/lib/accountSummary.js.map +7 -0
- package/dist/modules/billing/lib/allocation.js +356 -0
- package/dist/modules/billing/lib/allocation.js.map +7 -0
- package/dist/modules/billing/lib/allocationEvents.js +22 -0
- package/dist/modules/billing/lib/allocationEvents.js.map +7 -0
- package/dist/modules/billing/lib/billPeriod.js +15 -1
- package/dist/modules/billing/lib/billPeriod.js.map +2 -2
- package/dist/modules/billing/lib/billRunEngine.js +237 -102
- package/dist/modules/billing/lib/billRunEngine.js.map +2 -2
- package/dist/modules/billing/lib/billingSettings.js +116 -0
- package/dist/modules/billing/lib/billingSettings.js.map +7 -0
- package/dist/modules/billing/lib/commandRoute.js +81 -0
- package/dist/modules/billing/lib/commandRoute.js.map +7 -0
- package/dist/modules/billing/lib/customerLookup.js +97 -0
- package/dist/modules/billing/lib/customerLookup.js.map +7 -0
- package/dist/modules/billing/lib/dateOnly.js +13 -0
- package/dist/modules/billing/lib/dateOnly.js.map +7 -0
- package/dist/modules/billing/lib/documentParties.js +16 -0
- package/dist/modules/billing/lib/documentParties.js.map +7 -0
- package/dist/modules/billing/lib/documentTypes.js +27 -0
- package/dist/modules/billing/lib/documentTypes.js.map +7 -0
- package/dist/modules/billing/lib/dueDate.js +18 -0
- package/dist/modules/billing/lib/dueDate.js.map +7 -0
- package/dist/modules/billing/lib/iban.js +29 -0
- package/dist/modules/billing/lib/iban.js.map +7 -0
- package/dist/modules/billing/lib/invoiceDelivery.js +133 -0
- package/dist/modules/billing/lib/invoiceDelivery.js.map +7 -0
- package/dist/modules/billing/lib/invoiceLanguages.js +28 -0
- package/dist/modules/billing/lib/invoiceLanguages.js.map +7 -0
- package/dist/modules/billing/lib/invoiceWriter.js +107 -99
- package/dist/modules/billing/lib/invoiceWriter.js.map +2 -2
- package/dist/modules/billing/lib/itemBillingState.js +27 -0
- package/dist/modules/billing/lib/itemBillingState.js.map +7 -0
- package/dist/modules/billing/lib/itemPriceChange.js +18 -0
- package/dist/modules/billing/lib/itemPriceChange.js.map +7 -0
- package/dist/modules/billing/lib/itemSelector.js.map +2 -2
- package/dist/modules/billing/lib/lineAmounts.js +32 -0
- package/dist/modules/billing/lib/lineAmounts.js.map +7 -0
- package/dist/modules/billing/lib/memoGuards.js +25 -0
- package/dist/modules/billing/lib/memoGuards.js.map +7 -0
- package/dist/modules/billing/lib/navigation.js +48 -0
- package/dist/modules/billing/lib/navigation.js.map +7 -0
- package/dist/modules/billing/lib/numbering.js +120 -0
- package/dist/modules/billing/lib/numbering.js.map +7 -0
- package/dist/modules/billing/lib/overdue.js +36 -0
- package/dist/modules/billing/lib/overdue.js.map +7 -0
- package/dist/modules/billing/lib/paymentCsv.js +125 -0
- package/dist/modules/billing/lib/paymentCsv.js.map +7 -0
- package/dist/modules/billing/lib/paymentGateway.js +15 -0
- package/dist/modules/billing/lib/paymentGateway.js.map +7 -0
- package/dist/modules/billing/lib/paymentImport.js +164 -0
- package/dist/modules/billing/lib/paymentImport.js.map +7 -0
- package/dist/modules/billing/lib/paymentMatcher.js +36 -0
- package/dist/modules/billing/lib/paymentMatcher.js.map +7 -0
- package/dist/modules/billing/lib/pdf/attachmentStore.js +46 -0
- package/dist/modules/billing/lib/pdf/attachmentStore.js.map +7 -0
- package/dist/modules/billing/lib/pdf/fonts/embeddedFonts.js +7 -0
- package/dist/modules/billing/lib/pdf/fonts/embeddedFonts.js.map +7 -0
- package/dist/modules/billing/lib/pdf/invoiceModel.js +194 -0
- package/dist/modules/billing/lib/pdf/invoiceModel.js.map +7 -0
- package/dist/modules/billing/lib/pdf/invoicePdf.js +165 -0
- package/dist/modules/billing/lib/pdf/invoicePdf.js.map +7 -0
- package/dist/modules/billing/lib/pdf/invoiceTemplate.js +276 -0
- package/dist/modules/billing/lib/pdf/invoiceTemplate.js.map +7 -0
- package/dist/modules/billing/lib/prepaidConfig.js +17 -25
- package/dist/modules/billing/lib/prepaidConfig.js.map +2 -2
- package/dist/modules/billing/lib/prepaidConsume.js +26 -7
- package/dist/modules/billing/lib/prepaidConsume.js.map +2 -2
- package/dist/modules/billing/lib/prepaidPeriodClose.js +277 -158
- package/dist/modules/billing/lib/prepaidPeriodClose.js.map +2 -2
- package/dist/modules/billing/lib/prepaidTaxPoint.js +37 -0
- package/dist/modules/billing/lib/prepaidTaxPoint.js.map +7 -0
- package/dist/modules/billing/lib/seeds/demo.js +51 -3
- package/dist/modules/billing/lib/seeds/demo.js.map +2 -2
- package/dist/modules/billing/lib/seeds/paymentsSample.js +93 -0
- package/dist/modules/billing/lib/seeds/paymentsSample.js.map +7 -0
- package/dist/modules/billing/lib/seeds/sellerSettings.js +41 -0
- package/dist/modules/billing/lib/seeds/sellerSettings.js.map +7 -0
- package/dist/modules/billing/lib/servicePeriods.js +121 -0
- package/dist/modules/billing/lib/servicePeriods.js.map +7 -0
- package/dist/modules/billing/lib/testRunCleanup.js +24 -0
- package/dist/modules/billing/lib/testRunCleanup.js.map +7 -0
- package/dist/modules/billing/lib/topupCapture.js +2 -2
- package/dist/modules/billing/lib/topupCapture.js.map +2 -2
- package/dist/modules/billing/lib/topupReceipt.js +58 -79
- package/dist/modules/billing/lib/topupReceipt.js.map +2 -2
- package/dist/modules/billing/lib/usageRater.js.map +1 -1
- package/dist/modules/billing/lib/usageRunner.js +14 -6
- package/dist/modules/billing/lib/usageRunner.js.map +2 -2
- package/dist/modules/billing/lib/vat.js +39 -0
- package/dist/modules/billing/lib/vat.js.map +7 -0
- package/dist/modules/billing/migrations/Migration20261114000000_billing_customer_kind.js +15 -0
- package/dist/modules/billing/migrations/Migration20261114000000_billing_customer_kind.js.map +7 -0
- package/dist/modules/billing/migrations/Migration20261114100000_billing_cycle_semantics.js +25 -0
- package/dist/modules/billing/migrations/Migration20261114100000_billing_cycle_semantics.js.map +7 -0
- package/dist/modules/billing/migrations/Migration20261115000000_billing_invoice_ledger.js +115 -0
- package/dist/modules/billing/migrations/Migration20261115000000_billing_invoice_ledger.js.map +7 -0
- package/dist/modules/billing/migrations/Migration20261116000000_billing_invoice_documents.js +47 -0
- package/dist/modules/billing/migrations/Migration20261116000000_billing_invoice_documents.js.map +7 -0
- package/dist/modules/billing/migrations/Migration20261117000000_billing_payments.js +89 -0
- package/dist/modules/billing/migrations/Migration20261117000000_billing_payments.js.map +7 -0
- package/dist/modules/billing/migrations/Migration20261118000000_billing_memos.js +17 -0
- package/dist/modules/billing/migrations/Migration20261118000000_billing_memos.js.map +7 -0
- package/dist/modules/billing/migrations/Migration20261119000000_billing_operator_feedback.js +27 -0
- package/dist/modules/billing/migrations/Migration20261119000000_billing_operator_feedback.js.map +7 -0
- package/dist/modules/billing/migrations/Migration20261120000000_billing_allocation_scope_indexes.js +29 -0
- package/dist/modules/billing/migrations/Migration20261120000000_billing_allocation_scope_indexes.js.map +7 -0
- package/dist/modules/billing/setup.js +7 -184
- package/dist/modules/billing/setup.js.map +2 -2
- package/dist/modules/billing/subscribers/credit-memo-auto-send.js +16 -0
- package/dist/modules/billing/subscribers/credit-memo-auto-send.js.map +7 -0
- package/dist/modules/billing/subscribers/debit-memo-apply-credit.js +16 -0
- package/dist/modules/billing/subscribers/debit-memo-apply-credit.js.map +7 -0
- package/dist/modules/billing/subscribers/debit-memo-auto-send.js +16 -0
- package/dist/modules/billing/subscribers/debit-memo-auto-send.js.map +7 -0
- package/dist/modules/billing/subscribers/invoice-apply-credit.js +34 -0
- package/dist/modules/billing/subscribers/invoice-apply-credit.js.map +7 -0
- package/dist/modules/billing/subscribers/invoice-auto-send.js +30 -0
- package/dist/modules/billing/subscribers/invoice-auto-send.js.map +7 -0
- package/dist/modules/billing/subscribers/payment-captured-to-paid.js +69 -33
- package/dist/modules/billing/subscribers/payment-captured-to-paid.js.map +2 -2
- package/dist/modules/billing/subscribers/prepaid-topup-captured.js +4 -6
- package/dist/modules/billing/subscribers/prepaid-topup-captured.js.map +2 -2
- package/generated/entities/billing_account/index.ts +3 -0
- package/generated/entities/billing_allocation/index.ts +18 -0
- package/generated/entities/billing_document_sequence/index.ts +11 -0
- package/generated/entities/billing_invoice/index.ts +38 -0
- package/generated/entities/billing_invoice_line/index.ts +24 -0
- package/generated/entities/billing_item/index.ts +4 -0
- package/generated/entities/billing_payment/index.ts +25 -0
- package/generated/entities/billing_payment_import/index.ts +14 -0
- package/generated/entities/billing_run/index.ts +0 -1
- package/generated/entities/billing_run_outcome/index.ts +1 -0
- package/generated/entities/billing_settings/index.ts +26 -0
- package/generated/entities/billing_statement/index.ts +1 -0
- package/generated/entities.ids.generated.ts +7 -0
- package/package.json +5 -1
- package/src/modules/billing/__integration__/TC-BILL-004.spec.ts +171 -0
- package/src/modules/billing/__integration__/TC-BILL-005.spec.ts +134 -0
- package/src/modules/billing/__integration__/TC-BILL-006.spec.ts +101 -0
- package/src/modules/billing/__integration__/TC-BILL-007.spec.ts +140 -0
- package/src/modules/billing/__integration__/TC-BILL-008.spec.ts +108 -0
- package/src/modules/billing/__integration__/TC-BILL-009.spec.ts +113 -0
- package/src/modules/billing/__integration__/TC-BILL-010.spec.ts +118 -0
- package/src/modules/billing/__integration__/TC-BILL-011.spec.ts +142 -0
- package/src/modules/billing/__integration__/TC-BILL-012.spec.ts +115 -0
- package/src/modules/billing/__integration__/TC-BILL-013.spec.ts +118 -0
- package/src/modules/billing/__integration__/sellerSettings.ts +24 -0
- package/src/modules/billing/__tests__/commands/invoices.test.ts +436 -354
- package/src/modules/billing/__tests__/commands/itemsBulk.test.ts +33 -0
- package/src/modules/billing/__tests__/commands/memos.test.ts +205 -0
- package/src/modules/billing/__tests__/commands/payments.test.ts +241 -0
- package/src/modules/billing/__tests__/commands/runsDelete.test.ts +146 -0
- package/src/modules/billing/__tests__/commands/runsPostDrafts.test.ts +106 -0
- package/src/modules/billing/__tests__/commands/topups.test.ts +11 -0
- package/src/modules/billing/__tests__/entityRegistry.test.ts +8 -1
- package/src/modules/billing/__tests__/helpers/prepaidMockEm.ts +28 -11
- package/src/modules/billing/__tests__/i18n/dictionaries.test.ts +64 -0
- package/src/modules/billing/__tests__/lib/accountFinancials.test.ts +53 -0
- package/src/modules/billing/__tests__/lib/accountSummary.test.ts +97 -0
- package/src/modules/billing/__tests__/lib/allocation.test.ts +319 -0
- package/src/modules/billing/__tests__/lib/billRunEngine.test.ts +228 -17
- package/src/modules/billing/__tests__/lib/billingSettings.test.ts +109 -0
- package/src/modules/billing/__tests__/lib/customerLookup.test.ts +156 -0
- package/src/modules/billing/__tests__/lib/dueDate.test.ts +35 -0
- package/src/modules/billing/__tests__/lib/iban.test.ts +38 -0
- package/src/modules/billing/__tests__/lib/invoiceDelivery.test.ts +206 -0
- package/src/modules/billing/__tests__/lib/invoiceLanguages.test.ts +49 -0
- package/src/modules/billing/__tests__/lib/invoiceWriter.test.ts +212 -10
- package/src/modules/billing/__tests__/lib/itemBillingState.test.ts +42 -0
- package/src/modules/billing/__tests__/lib/itemPriceChange.test.ts +165 -0
- package/src/modules/billing/__tests__/lib/lineAmounts.test.ts +86 -0
- package/src/modules/billing/__tests__/lib/navigation.test.ts +71 -0
- package/src/modules/billing/__tests__/lib/numbering.test.ts +91 -0
- package/src/modules/billing/__tests__/lib/overdue.test.ts +36 -0
- package/src/modules/billing/__tests__/lib/paymentCsv.test.ts +148 -0
- package/src/modules/billing/__tests__/lib/paymentImport.test.ts +113 -0
- package/src/modules/billing/__tests__/lib/paymentsSample.test.ts +73 -0
- package/src/modules/billing/__tests__/lib/pdf/invoicePdf.test.ts +269 -0
- package/src/modules/billing/__tests__/lib/pdf/invoicePdfService.test.ts +147 -0
- package/src/modules/billing/__tests__/lib/prepaidPeriodClose.test.ts +374 -98
- package/src/modules/billing/__tests__/lib/prepaidTaxPoint.test.ts +118 -0
- package/src/modules/billing/__tests__/lib/seedsDemo.test.ts +53 -2
- package/src/modules/billing/__tests__/lib/sellerSettings.test.ts +28 -0
- package/src/modules/billing/__tests__/lib/servicePeriods.test.ts +190 -0
- package/src/modules/billing/__tests__/lib/topupCapture.test.ts +6 -28
- package/src/modules/billing/__tests__/lib/topupReceipt.test.ts +21 -52
- package/src/modules/billing/__tests__/lib/vat.test.ts +51 -0
- package/src/modules/billing/__tests__/package-isolation.test.ts +22 -8
- package/src/modules/billing/__tests__/setup.test.ts +13 -4
- package/src/modules/billing/__tests__/validators.test.ts +197 -3
- package/src/modules/billing/acl.ts +12 -0
- package/src/modules/billing/api/accounts/[id]/summary/route.ts +62 -0
- package/src/modules/billing/api/accounts/route.ts +59 -4
- package/src/modules/billing/api/export/account/[id]/route.ts +13 -11
- package/src/modules/billing/api/invoices/[id]/memos/route.ts +63 -0
- package/src/modules/billing/api/invoices/[id]/pdf/route.ts +80 -0
- package/src/modules/billing/api/invoices/[id]/route.ts +57 -70
- package/src/modules/billing/api/invoices/[id]/send/route.ts +127 -0
- package/src/modules/billing/api/invoices/add-line/route.ts +2 -2
- package/src/modules/billing/api/invoices/delete-draft/route.ts +33 -0
- package/src/modules/billing/api/invoices/edit-line/route.ts +2 -2
- package/src/modules/billing/api/invoices/post/route.ts +7 -6
- package/src/modules/billing/api/invoices/remove-line/route.ts +2 -2
- package/src/modules/billing/api/invoices/route.ts +81 -86
- package/src/modules/billing/api/items/bulk/route.ts +2 -1
- package/src/modules/billing/api/items/change-price/route.ts +54 -0
- package/src/modules/billing/api/items/route.ts +23 -7
- package/src/modules/billing/api/payment-imports/[id]/route.ts +49 -0
- package/src/modules/billing/api/payment-imports/route.ts +57 -0
- package/src/modules/billing/api/payments/[id]/route.ts +63 -0
- package/src/modules/billing/api/payments/allocate/route.ts +35 -0
- package/src/modules/billing/api/payments/assign/route.ts +36 -0
- package/src/modules/billing/api/payments/convert-to-topup/route.ts +35 -0
- package/src/modules/billing/api/payments/ignore/route.ts +35 -0
- package/src/modules/billing/api/payments/import/route.ts +72 -0
- package/src/modules/billing/api/payments/restore/route.ts +35 -0
- package/src/modules/billing/api/payments/route.ts +147 -0
- package/src/modules/billing/api/payments/unallocate/route.ts +35 -0
- package/src/modules/billing/api/payments/unassign/route.ts +35 -0
- package/src/modules/billing/api/run-outcomes/route.ts +49 -6
- package/src/modules/billing/api/runs/[id]/post-drafts/route.ts +71 -0
- package/src/modules/billing/api/runs/[id]/route.ts +59 -0
- package/src/modules/billing/api/runs/retry-failed/route.ts +2 -1
- package/src/modules/billing/api/runs/route.ts +15 -7
- package/src/modules/billing/api/settings/number-preview/route.ts +46 -0
- package/src/modules/billing/api/settings/route.ts +116 -0
- package/src/modules/billing/api/statements/route.ts +5 -0
- package/src/modules/billing/api/test-invoices/wipe/route.ts +2 -2
- package/src/modules/billing/backend/billing/accounts/[id]/page.tsx +151 -372
- package/src/modules/billing/backend/billing/accounts/create/page.tsx +6 -0
- package/src/modules/billing/backend/billing/accounts/page.tsx +70 -4
- package/src/modules/billing/backend/billing/invoices/[id]/page.tsx +444 -95
- package/src/modules/billing/backend/billing/invoices/page.tsx +8 -227
- package/src/modules/billing/backend/billing/items/[id]/page.tsx +75 -6
- package/src/modules/billing/backend/billing/items/create/page.tsx +13 -8
- package/src/modules/billing/backend/billing/items/page.tsx +18 -2
- package/src/modules/billing/backend/billing/payments/[id]/page.meta.ts +19 -0
- package/src/modules/billing/backend/billing/payments/[id]/page.tsx +415 -0
- package/src/modules/billing/backend/billing/payments/imports/[id]/page.meta.ts +19 -0
- package/src/modules/billing/backend/billing/payments/imports/[id]/page.tsx +106 -0
- package/src/modules/billing/backend/billing/payments/page.meta.ts +16 -0
- package/src/modules/billing/backend/billing/payments/page.tsx +56 -0
- package/src/modules/billing/backend/billing/runs/[id]/page.tsx +49 -18
- package/src/modules/billing/backend/billing/runs/page.tsx +59 -8
- package/src/modules/billing/backend/billing/statements/[id]/page.tsx +86 -5
- package/src/modules/billing/backend/billing/statements/page.tsx +1 -1
- package/src/modules/billing/backend/billing/topups/page.tsx +1 -1
- package/src/modules/billing/backend/billing/transactions/page.tsx +1 -1
- package/src/modules/billing/backend/billing/usage/create/page.tsx +3 -2
- package/src/modules/billing/backend/config/billing/page.meta.ts +21 -0
- package/src/modules/billing/backend/config/billing/page.tsx +549 -0
- package/src/modules/billing/cli.ts +31 -1
- package/src/modules/billing/commands/accounts.ts +6 -0
- package/src/modules/billing/commands/index.ts +3 -0
- package/src/modules/billing/commands/invoices.ts +364 -231
- package/src/modules/billing/commands/items.ts +143 -0
- package/src/modules/billing/commands/memos.ts +218 -0
- package/src/modules/billing/commands/payments.ts +428 -0
- package/src/modules/billing/commands/runs.ts +205 -3
- package/src/modules/billing/commands/settings.ts +77 -0
- package/src/modules/billing/commands/topups.ts +12 -3
- package/src/modules/billing/commands/transactions.ts +2 -2
- package/src/modules/billing/components/AccountForm.tsx +199 -53
- package/src/modules/billing/components/AccountInvoicesSection.tsx +75 -0
- package/src/modules/billing/components/AccountPaymentsSection.tsx +42 -0
- package/src/modules/billing/components/AccountPicker.tsx +70 -0
- package/src/modules/billing/components/AllocatePaymentDialog.tsx +167 -0
- package/src/modules/billing/components/BillingDataTable.tsx +34 -0
- package/src/modules/billing/components/BillingSettingsLink.tsx +25 -0
- package/src/modules/billing/components/ChangeItemPriceDialog.tsx +180 -0
- package/src/modules/billing/components/CreateMemoDialog.tsx +232 -0
- package/src/modules/billing/components/CustomerLabel.tsx +53 -0
- package/src/modules/billing/components/InvoicesTable.tsx +344 -0
- package/src/modules/billing/components/ItemForm.tsx +233 -44
- package/src/modules/billing/components/ItemPriceField.tsx +81 -0
- package/src/modules/billing/components/LineFormDialog.tsx +25 -1
- package/src/modules/billing/components/ManualPaymentDialog.tsx +140 -0
- package/src/modules/billing/components/MoneyInput.tsx +26 -0
- package/src/modules/billing/components/PaymentUploadDialog.tsx +148 -0
- package/src/modules/billing/components/PaymentsTable.tsx +213 -0
- package/src/modules/billing/components/PostRunDraftsButton.tsx +129 -0
- package/src/modules/billing/components/PrepaidPanel.tsx +19 -6
- package/src/modules/billing/components/RunCyclesSection.tsx +298 -0
- package/src/modules/billing/components/TestRunActions.tsx +152 -0
- package/src/modules/billing/components/account/AccountItemsTab.tsx +192 -0
- package/src/modules/billing/components/account/AccountRunBillingDialog.tsx +147 -0
- package/src/modules/billing/components/account/AccountRunsTab.tsx +201 -0
- package/src/modules/billing/components/account/AccountStatementsTab.tsx +120 -0
- package/src/modules/billing/components/account/AccountSummaryCards.tsx +153 -0
- package/src/modules/billing/components/account/AccountUsageTab.tsx +122 -0
- package/src/modules/billing/components/account/AccountView.tsx +101 -0
- package/src/modules/billing/components/account/accountRow.ts +70 -0
- package/src/modules/billing/components/customerNames.ts +62 -0
- package/src/modules/billing/data/entities.ts +656 -6
- package/src/modules/billing/data/entityIds.ts +9 -0
- package/src/modules/billing/data/validators.ts +388 -8
- package/src/modules/billing/events.ts +56 -3
- package/src/modules/billing/i18n/de.json +880 -0
- package/src/modules/billing/i18n/en.json +457 -21
- package/src/modules/billing/i18n/es.json +880 -0
- package/src/modules/billing/i18n/pl.json +458 -22
- package/src/modules/billing/index.ts +6 -2
- package/src/modules/billing/lib/accountFinancials.ts +84 -0
- package/src/modules/billing/lib/accountLock.ts +32 -0
- package/src/modules/billing/lib/accountStatus.ts +11 -9
- package/src/modules/billing/lib/accountSummary.ts +172 -0
- package/src/modules/billing/lib/allocation.ts +515 -0
- package/src/modules/billing/lib/allocationEvents.ts +26 -0
- package/src/modules/billing/lib/billPeriod.ts +19 -0
- package/src/modules/billing/lib/billRunEngine.ts +350 -150
- package/src/modules/billing/lib/billingSettings.ts +145 -0
- package/src/modules/billing/lib/commandRoute.ts +112 -0
- package/src/modules/billing/lib/customerLookup.ts +157 -0
- package/src/modules/billing/lib/dateOnly.ts +22 -0
- package/src/modules/billing/lib/documentParties.ts +23 -0
- package/src/modules/billing/lib/documentTypes.ts +37 -0
- package/src/modules/billing/lib/dueDate.ts +26 -0
- package/src/modules/billing/lib/iban.ts +36 -0
- package/src/modules/billing/lib/invoiceDelivery.ts +196 -0
- package/src/modules/billing/lib/invoiceLanguages.ts +57 -0
- package/src/modules/billing/lib/invoiceWriter.ts +162 -148
- package/src/modules/billing/lib/itemBillingState.ts +67 -0
- package/src/modules/billing/lib/itemPriceChange.ts +56 -0
- package/src/modules/billing/lib/itemSelector.ts +4 -1
- package/src/modules/billing/lib/lineAmounts.ts +61 -0
- package/src/modules/billing/lib/memoGuards.ts +41 -0
- package/src/modules/billing/lib/navigation.ts +64 -0
- package/src/modules/billing/lib/numbering.ts +174 -0
- package/src/modules/billing/lib/overdue.ts +60 -0
- package/src/modules/billing/lib/paymentCsv.ts +171 -0
- package/src/modules/billing/lib/paymentGateway.ts +52 -0
- package/src/modules/billing/lib/paymentImport.ts +228 -0
- package/src/modules/billing/lib/paymentMatcher.ts +88 -0
- package/src/modules/billing/lib/pdf/attachmentStore.ts +60 -0
- package/src/modules/billing/lib/pdf/fonts/NotoSans-Bold.ttf +0 -0
- package/src/modules/billing/lib/pdf/fonts/NotoSans-Regular.ttf +0 -0
- package/src/modules/billing/lib/pdf/fonts/OFL.txt +93 -0
- package/src/modules/billing/lib/pdf/fonts/embeddedFonts.ts +9 -0
- package/src/modules/billing/lib/pdf/invoiceModel.ts +329 -0
- package/src/modules/billing/lib/pdf/invoicePdf.ts +220 -0
- package/src/modules/billing/lib/pdf/invoiceTemplate.ts +338 -0
- package/src/modules/billing/lib/prepaidConfig.ts +27 -36
- package/src/modules/billing/lib/prepaidConsume.ts +29 -6
- package/src/modules/billing/lib/prepaidPeriodClose.ts +407 -239
- package/src/modules/billing/lib/prepaidTaxPoint.ts +76 -0
- package/src/modules/billing/lib/seeds/demo.ts +79 -6
- package/src/modules/billing/lib/seeds/paymentsSample.ts +136 -0
- package/src/modules/billing/lib/seeds/sellerSettings.ts +78 -0
- package/src/modules/billing/lib/servicePeriods.ts +226 -0
- package/src/modules/billing/lib/testRunCleanup.ts +42 -0
- package/src/modules/billing/lib/topupCapture.ts +3 -4
- package/src/modules/billing/lib/topupReceipt.ts +70 -103
- package/src/modules/billing/lib/usageRater.ts +1 -1
- package/src/modules/billing/lib/usageRunner.ts +17 -5
- package/src/modules/billing/lib/vat.ts +56 -0
- package/src/modules/billing/migrations/Migration20261114000000_billing_customer_kind.ts +25 -0
- package/src/modules/billing/migrations/Migration20261114100000_billing_cycle_semantics.ts +37 -0
- package/src/modules/billing/migrations/Migration20261115000000_billing_invoice_ledger.ts +132 -0
- package/src/modules/billing/migrations/Migration20261116000000_billing_invoice_documents.ts +58 -0
- package/src/modules/billing/migrations/Migration20261117000000_billing_payments.ts +97 -0
- package/src/modules/billing/migrations/Migration20261118000000_billing_memos.ts +21 -0
- package/src/modules/billing/migrations/Migration20261119000000_billing_operator_feedback.ts +39 -0
- package/src/modules/billing/migrations/Migration20261120000000_billing_allocation_scope_indexes.ts +35 -0
- package/src/modules/billing/setup.ts +11 -237
- package/src/modules/billing/subscribers/credit-memo-auto-send.ts +15 -0
- package/src/modules/billing/subscribers/debit-memo-apply-credit.ts +15 -0
- package/src/modules/billing/subscribers/debit-memo-auto-send.ts +15 -0
- package/src/modules/billing/subscribers/invoice-apply-credit.ts +39 -0
- package/src/modules/billing/subscribers/invoice-auto-send.ts +46 -0
- package/src/modules/billing/subscribers/payment-captured-to-paid.ts +84 -62
- package/src/modules/billing/subscribers/prepaid-topup-captured.ts +4 -8
- package/dist/modules/billing/lib/invoiceStatus.js +0 -38
- package/dist/modules/billing/lib/invoiceStatus.js.map +0 -7
- package/src/modules/billing/__tests__/lib/invoiceStatus.test.ts +0 -97
- package/src/modules/billing/lib/invoiceStatus.ts +0 -61
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../src/modules/billing/backend/billing/payments/%5Bid%5D/page.tsx"],
|
|
4
|
+
"sourcesContent": ["\"use client\"\nimport * as React from 'react'\nimport Link from 'next/link'\nimport { useParams } from 'next/navigation'\nimport type { LegacyColumnDef as ColumnDef } from '@tanstack/react-table/legacy'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport { Page, PageBody } from '@open-mercato/ui/backend/Page'\nimport { FormHeader } from '@open-mercato/ui/backend/forms'\nimport { BillingDataTable as DataTable } from '../../../../components/BillingDataTable'\nimport { RowActions } from '@open-mercato/ui/backend/RowActions'\nimport { Tag } from '@open-mercato/ui/primitives/tag'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { Kbd, KbdShortcut } from '@open-mercato/ui/primitives/kbd'\nimport { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle } from '@open-mercato/ui/primitives/dialog'\nimport { ErrorMessage, LoadingMessage, RecordNotFoundState } from '@open-mercato/ui/backend/detail'\nimport { flash } from '@open-mercato/ui/backend/FlashMessages'\nimport { useConfirmDialog } from '@open-mercato/ui/backend/confirm-dialog'\nimport { apiCallOrThrow, readApiResultOrThrow } from '@open-mercato/ui/backend/utils/apiCall'\nimport { normalizeCrudServerError } from '@open-mercato/ui/backend/utils/serverErrors'\nimport { DetailCard, DetailField } from '../../../../components/DetailFields'\nimport { AccountPicker } from '../../../../components/AccountPicker'\nimport { AllocatePaymentDialog } from '../../../../components/AllocatePaymentDialog'\nimport { formatMoney } from '../../../../components/InvoicesTable'\nimport { PAYMENT_STATUS_VARIANT, usePaymentLabels } from '../../../../components/PaymentsTable'\nimport { accountHref, invoiceDetailHref } from '../../../../lib/navigation'\n\n/**\n * Payment detail (Spec C): fields, match reason, allocations (with\n * un-allocate) and the actions valid for the payment's status \u2014 assign to\n * an account, allocate, unassign, ignore / restore, convert to a top-up.\n */\n\ntype PaymentRecord = {\n id: string\n received_at: string\n amount: string\n currency_code: string\n reference: string | null\n payer_name: string | null\n payer_account: string | null\n source: string\n import_id: string | null\n bill_account_id: string | null\n bill_account_name: string | null\n bill_account_mode: string | null\n status: string\n unallocated_amount: string\n match_reason: string | null\n topup_id: string | null\n}\n\ntype AllocationRow = {\n id: string\n invoice_id: string\n invoice_number: string | null\n document_type: string | null\n invoice_status: string | null\n amount: string\n currency_code: string\n allocated_by: string\n created_at: string\n}\n\ntype DetailResponse = { payment: PaymentRecord; allocations: AllocationRow[] }\n\nfunction AccountActionDialog({\n open,\n title,\n confirmLabel,\n billingMode,\n currencyCode,\n initialAccountId,\n onClose,\n onConfirm,\n}: {\n open: boolean\n title: string\n confirmLabel: string\n billingMode: 'postpaid' | 'prepaid'\n currencyCode: string\n initialAccountId?: string | null\n onClose: () => void\n onConfirm: (billAccountId: string) => Promise<void>\n}) {\n const t = useT()\n const [accountId, setAccountId] = React.useState(initialAccountId ?? '')\n const [busy, setBusy] = React.useState(false)\n React.useEffect(() => {\n if (open) setAccountId(initialAccountId ?? '')\n }, [initialAccountId, open])\n const submit = async () => {\n if (!accountId || busy) return\n setBusy(true)\n try {\n await onConfirm(accountId)\n onClose()\n } finally {\n setBusy(false)\n }\n }\n return (\n <Dialog open={open} onOpenChange={(next) => (!next ? onClose() : undefined)}>\n <DialogContent\n onKeyDown={(event) => {\n if ((event.metaKey || event.ctrlKey) && event.key === 'Enter') {\n event.preventDefault()\n void submit()\n }\n }}\n >\n <DialogHeader>\n <DialogTitle>{title}</DialogTitle>\n </DialogHeader>\n <AccountPicker value={accountId} onChange={setAccountId} currencyCode={currencyCode} billingMode={billingMode} />\n <DialogFooter>\n <div className=\"flex w-full items-center justify-between gap-3\">\n <span className=\"text-xs text-muted-foreground\">\n <KbdShortcut keys={['Ctrl/\u2318', 'Enter']} /> \u00B7 <Kbd>Esc</Kbd>\n </span>\n <div className=\"flex items-center gap-2\">\n <Button type=\"button\" variant=\"outline\" onClick={onClose}>\n {t('billing.common.cancel', 'Cancel')}\n </Button>\n <Button type=\"button\" onClick={() => void submit()} disabled={!accountId || busy}>\n {confirmLabel}\n </Button>\n </div>\n </div>\n </DialogFooter>\n </DialogContent>\n </Dialog>\n )\n}\n\nexport default function PaymentDetailPage(props: { params?: { id?: string } }) {\n const t = useT()\n const labels = usePaymentLabels()\n // OM serves backend pages through a catch-all route \u2014 the dynamic `[id]`\n // segment arrives as a page prop; `useParams()` is only the fallback.\n const urlParams = useParams<{ id: string }>()\n const id = props.params?.id ?? urlParams?.id\n const { confirm, ConfirmDialogElement } = useConfirmDialog()\n const [data, setData] = React.useState<DetailResponse | null>(null)\n const [error, setError] = React.useState<string | null>(null)\n const [notFound, setNotFound] = React.useState(false)\n const [dialog, setDialog] = React.useState<'assign' | 'convert' | 'allocate' | null>(null)\n\n const load = React.useCallback(async () => {\n if (!id) return\n try {\n setData(await readApiResultOrThrow<DetailResponse>(`/api/billing/payments/${encodeURIComponent(id)}`))\n setError(null)\n } catch (err) {\n if ((err as { status?: number })?.status === 404) setNotFound(true)\n else setError(normalizeCrudServerError(err).message || t('billing.payments.detail.load_error', 'Could not load the payment'))\n }\n }, [id, t])\n\n React.useEffect(() => {\n void load()\n }, [load])\n\n const action = React.useCallback(\n async (path: string, body: Record<string, unknown>, success: string) => {\n try {\n await apiCallOrThrow(`/api/billing/payments/${path}`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(body),\n })\n flash(success, 'success')\n await load()\n } catch (err) {\n flash(normalizeCrudServerError(err).message || t('billing.payments.action_failed', 'The action failed'), 'error')\n }\n },\n [load, t],\n )\n\n const allocationColumns = React.useMemo<ColumnDef<AllocationRow>[]>(\n () => [\n {\n accessorKey: 'invoice_number',\n header: t('billing.payments.allocations.invoice', 'Invoice'),\n cell: ({ row }) => (\n <Link href={invoiceDetailHref(row.original.invoice_id)} className=\"text-primary hover:underline\">\n {row.original.invoice_number ?? row.original.invoice_id}\n </Link>\n ),\n },\n {\n accessorKey: 'amount',\n header: t('billing.payments.columns.amount', 'Amount'),\n cell: ({ row }) => formatMoney(row.original.amount, row.original.currency_code),\n },\n {\n accessorKey: 'allocated_by',\n header: t('billing.payments.allocations.by', 'How'),\n cell: ({ row }) =>\n ({\n auto: t('billing.payments.allocations.by.auto', 'Matched automatically'),\n credit: t('billing.payments.allocations.by.credit', 'Credit applied'),\n user: t('billing.payments.allocations.by.user', 'Manual'),\n gateway: t('billing.payments.allocations.by.gateway', 'Online payment'),\n })[row.original.allocated_by] ?? row.original.allocated_by,\n },\n {\n accessorKey: 'created_at',\n header: t('billing.payments.allocations.at', 'When'),\n cell: ({ row }) => new Date(row.original.created_at).toLocaleString(),\n },\n ],\n [t],\n )\n\n if (notFound) {\n return (\n <Page>\n <PageBody>\n <RecordNotFoundState label={t('billing.payments.not_found', 'Payment not found')} backHref=\"/backend/billing/payments\" backLabel={t('billing.payments.title', 'Payments')} />\n </PageBody>\n </Page>\n )\n }\n if (error) {\n return (\n <Page>\n <PageBody>\n <ErrorMessage label={error} />\n </PageBody>\n </Page>\n )\n }\n if (!data || !id) {\n return (\n <Page>\n <PageBody>\n <LoadingMessage label={t('billing.payments.detail.loading', 'Loading payment\u2026')} />\n </PageBody>\n </Page>\n )\n }\n\n const { payment, allocations } = data\n const unallocated = Number.parseFloat(payment.unallocated_amount)\n const hasAllocations = allocations.length > 0\n const isUnmatched = payment.status === 'unmatched'\n const canAllocate = Boolean(payment.bill_account_id) && ['matched', 'partially_allocated'].includes(payment.status) && unallocated > 0\n\n return (\n <Page>\n <FormHeader\n mode=\"detail\"\n backHref=\"/backend/billing/payments\"\n entityTypeLabel={t('billing.payments.detail.title', 'Payment')}\n title={formatMoney(payment.amount, payment.currency_code)}\n statusBadge={<Tag variant={PAYMENT_STATUS_VARIANT[payment.status] ?? 'default'}>{labels.status(payment.status)}</Tag>}\n actionsContent={\n <>\n {isUnmatched ? (\n <Button type=\"button\" onClick={() => setDialog('assign')}>\n {t('billing.payments.actions.assign', 'Assign to account')}\n </Button>\n ) : null}\n {canAllocate ? (\n <Button type=\"button\" onClick={() => setDialog('allocate')}>\n {t('billing.payments.actions.allocate', 'Allocate')}\n </Button>\n ) : null}\n {isUnmatched && unallocated === Number.parseFloat(payment.amount) ? (\n <Button type=\"button\" variant=\"outline\" onClick={() => setDialog('convert')}>\n {t('billing.payments.actions.convert', 'Convert to top-up')}\n </Button>\n ) : null}\n {payment.status === 'matched' && !hasAllocations ? (\n <Button\n type=\"button\"\n variant=\"outline\"\n onClick={() => void action('unassign', { paymentId: id }, t('billing.payments.actions.unassigned', 'Payment unassigned'))}\n >\n {t('billing.payments.actions.unassign', 'Unassign')}\n </Button>\n ) : null}\n {['unmatched', 'matched'].includes(payment.status) && !hasAllocations ? (\n <Button\n type=\"button\"\n variant=\"outline\"\n onClick={() => void action('ignore', { paymentId: id }, t('billing.payments.actions.ignored', 'Payment ignored'))}\n >\n {t('billing.payments.actions.ignore', 'Ignore')}\n </Button>\n ) : null}\n {payment.status === 'ignored' ? (\n <Button\n type=\"button\"\n variant=\"outline\"\n onClick={() => void action('restore', { paymentId: id }, t('billing.payments.actions.restored', 'Payment restored'))}\n >\n {t('billing.payments.actions.restore', 'Restore')}\n </Button>\n ) : null}\n </>\n }\n />\n <PageBody>\n <div className=\"space-y-6\">\n <DetailCard>\n <DetailField label={t('billing.payments.columns.received', 'Received')}>{payment.received_at?.slice(0, 10)}</DetailField>\n <DetailField label={t('billing.payments.columns.unallocated', 'Unallocated')}>\n {formatMoney(payment.unallocated_amount, payment.currency_code)}\n </DetailField>\n <DetailField label={t('billing.payments.columns.account', 'Account')}>\n {payment.bill_account_id ? (\n <Link href={accountHref(payment.bill_account_id)} className=\"text-primary hover:underline\">\n {payment.bill_account_name ?? payment.bill_account_id}\n </Link>\n ) : (\n '\u2014'\n )}\n </DetailField>\n <DetailField label={t('billing.payments.fields.match_reason', 'Match')}>{labels.reason(payment.match_reason)}</DetailField>\n <DetailField label={t('billing.payments.columns.reference', 'Reference')}>{payment.reference ?? '\u2014'}</DetailField>\n <DetailField label={t('billing.payments.columns.payer', 'Payer')}>\n {[payment.payer_name, payment.payer_account].filter(Boolean).join(' \u00B7 ') || '\u2014'}\n </DetailField>\n <DetailField label={t('billing.payments.fields.source', 'Source')}>\n {payment.import_id ? (\n <Link href={`/backend/billing/payments/imports/${payment.import_id}`} className=\"text-primary hover:underline\">\n {t('billing.payments.source.csv', 'Bank CSV')}\n </Link>\n ) : payment.source === 'gateway' ? (\n t('billing.payments.source.gateway', 'Online payment')\n ) : (\n t('billing.payments.source.manual', 'Manual entry')\n )}\n </DetailField>\n {payment.topup_id ? (\n <DetailField label={t('billing.payments.fields.topup', 'Top-up')}>\n <Link href={`/backend/billing/topups/${payment.topup_id}`} className=\"text-primary hover:underline\">\n {t('billing.payments.fields.topup_open', 'Open top-up')}\n </Link>\n </DetailField>\n ) : null}\n </DetailCard>\n\n <div>\n <h2 className=\"mb-2 text-base font-semibold\">{t('billing.payments.allocations.title', 'Allocations')}</h2>\n <DataTable\n columns={allocationColumns}\n data={allocations}\n isLoading={false}\n emptyState={t('billing.payments.allocations.empty', 'Not allocated to any invoice.')}\n rowActions={(row) => (\n <RowActions\n items={[\n {\n id: 'unallocate',\n label: t('billing.payments.allocations.remove', 'Un-allocate'),\n destructive: true,\n onSelect: () => {\n void confirm({\n title: t('billing.payments.allocations.remove_confirm', 'Remove this allocation?'),\n text: t('billing.payments.allocations.remove_text', 'The invoice becomes unpaid by this amount again.'),\n confirmText: t('billing.payments.allocations.remove', 'Un-allocate'),\n variant: 'destructive',\n }).then((ok) => {\n if (ok) void action('unallocate', { allocationId: row.id }, t('billing.payments.allocations.removed', 'Allocation removed'))\n })\n },\n },\n ]}\n />\n )}\n pagination={{ page: 1, pageSize: Math.max(allocations.length, 1), total: allocations.length, totalPages: 1, onPageChange: () => undefined }}\n />\n </div>\n </div>\n\n <AccountActionDialog\n open={dialog === 'assign'}\n title={t('billing.payments.actions.assign', 'Assign to account')}\n confirmLabel={t('billing.payments.actions.assign_confirm', 'Assign')}\n billingMode=\"postpaid\"\n currencyCode={payment.currency_code}\n onClose={() => setDialog(null)}\n onConfirm={(billAccountId) => action('assign', { paymentId: id, billAccountId }, t('billing.payments.actions.assigned', 'Payment assigned'))}\n />\n <AccountActionDialog\n open={dialog === 'convert'}\n title={t('billing.payments.actions.convert', 'Convert to top-up')}\n confirmLabel={t('billing.payments.actions.convert_confirm', 'Convert')}\n billingMode=\"prepaid\"\n currencyCode={payment.currency_code}\n initialAccountId={payment.bill_account_mode === 'prepaid' ? payment.bill_account_id : null}\n onClose={() => setDialog(null)}\n onConfirm={(billAccountId) =>\n action('convert-to-topup', { paymentId: id, billAccountId }, t('billing.payments.actions.converted', 'Top-up created'))\n }\n />\n {payment.bill_account_id ? (\n <AllocatePaymentDialog\n open={dialog === 'allocate'}\n onClose={() => setDialog(null)}\n onDone={() => void load()}\n paymentId={id}\n billAccountId={payment.bill_account_id}\n unallocated={unallocated}\n currencyCode={payment.currency_code}\n />\n ) : null}\n {ConfirmDialogElement}\n </PageBody>\n </Page>\n )\n}\n"],
|
|
5
|
+
"mappings": ";AA+GU,SAmJA,UAnJA,KAKE,YALF;AA9GV,YAAY,WAAW;AACvB,OAAO,UAAU;AACjB,SAAS,iBAAiB;AAE1B,SAAS,YAAY;AACrB,SAAS,MAAM,gBAAgB;AAC/B,SAAS,kBAAkB;AAC3B,SAAS,oBAAoB,iBAAiB;AAC9C,SAAS,kBAAkB;AAC3B,SAAS,WAAW;AACpB,SAAS,cAAc;AACvB,SAAS,KAAK,mBAAmB;AACjC,SAAS,QAAQ,eAAe,cAAc,cAAc,mBAAmB;AAC/E,SAAS,cAAc,gBAAgB,2BAA2B;AAClE,SAAS,aAAa;AACtB,SAAS,wBAAwB;AACjC,SAAS,gBAAgB,4BAA4B;AACrD,SAAS,gCAAgC;AACzC,SAAS,YAAY,mBAAmB;AACxC,SAAS,qBAAqB;AAC9B,SAAS,6BAA6B;AACtC,SAAS,mBAAmB;AAC5B,SAAS,wBAAwB,wBAAwB;AACzD,SAAS,aAAa,yBAAyB;AAyC/C,SAAS,oBAAoB;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GASG;AACD,QAAM,IAAI,KAAK;AACf,QAAM,CAAC,WAAW,YAAY,IAAI,MAAM,SAAS,oBAAoB,EAAE;AACvE,QAAM,CAAC,MAAM,OAAO,IAAI,MAAM,SAAS,KAAK;AAC5C,QAAM,UAAU,MAAM;AACpB,QAAI,KAAM,cAAa,oBAAoB,EAAE;AAAA,EAC/C,GAAG,CAAC,kBAAkB,IAAI,CAAC;AAC3B,QAAM,SAAS,YAAY;AACzB,QAAI,CAAC,aAAa,KAAM;AACxB,YAAQ,IAAI;AACZ,QAAI;AACF,YAAM,UAAU,SAAS;AACzB,cAAQ;AAAA,IACV,UAAE;A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MAAM,WAAW;AAAA,UACjB,OAAO,EAAE,mCAAmC,mBAAmB;AAAA,UAC/D,cAAc,EAAE,2CAA2C,QAAQ;AAAA,UACnE,aAAY;AAAA,UACZ,cAAc,QAAQ;AAAA,UACtB,SAAS,MAAM,UAAU,IAAI;AAAA,UAC7B,WAAW,CAAC,kBAAkB,OAAO,UAAU,EAAE,WAAW,IAAI,cAAc,GAAG,EAAE,qCAAqC,kBAAkB,CAAC;AAAA;AAAA,MAC7I;AAAA,MACA;AAAA,QAAC;AAAA;AAAA,UACC,MAAM,WAAW;AAAA,UACjB,OAAO,EAAE,oCAAoC,mBAAmB;AAAA,UAChE,cAAc,EAAE,4CAA4C,SAAS;AAAA,UACrE,aAAY;AAAA,UACZ,cAAc,QAAQ;AAAA,UACtB,kBAAkB,QAAQ,sBAAsB,YAAY,QAAQ,kBAAkB;AAAA,UACtF,SAAS,MAAM,UAAU,IAAI;AAAA,UAC7B,WAAW,CAAC,kBACV,OAAO,oBAAoB,EAAE,WAAW,IAAI,cAAc,GAAG,EAAE,sCAAsC,gBAAgB,CAAC;AAAA;AAAA,MAE1H;AAAA,MACC,QAAQ,kBACP;AAAA,QAAC;AAAA;AAAA,UACC,MAAM,WAAW;AAAA,UACjB,SAAS,MAAM,UAAU,IAAI;AAAA,UAC7B,QAAQ,MAAM,KAAK,KAAK;AAAA,UACxB,WAAW;AAAA,UACX,eAAe,QAAQ;AAAA,UACvB;AAAA,UACA,cAAc,QAAQ;AAAA;AAAA,MACxB,IACE;AAAA,MACH;AAAA,OACH;AAAA,KACF;AAEJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Landmark } from "lucide-react";
|
|
3
|
+
const paymentIcon = React.createElement(Landmark, { size: 16 });
|
|
4
|
+
const metadata = {
|
|
5
|
+
requireAuth: true,
|
|
6
|
+
requireFeatures: ["billing.payment.view"],
|
|
7
|
+
pageTitle: "Payment",
|
|
8
|
+
pageTitleKey: "billing.payments.detail.title",
|
|
9
|
+
pageGroup: "Billing",
|
|
10
|
+
pageGroupKey: "billing.nav.group",
|
|
11
|
+
navHidden: true,
|
|
12
|
+
icon: paymentIcon,
|
|
13
|
+
breadcrumb: [
|
|
14
|
+
{ label: "Payments", labelKey: "billing.payments.title", href: "/backend/billing/payments" },
|
|
15
|
+
{ label: "Payment", labelKey: "billing.payments.detail.title" }
|
|
16
|
+
]
|
|
17
|
+
};
|
|
18
|
+
export {
|
|
19
|
+
metadata
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=page.meta.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../src/modules/billing/backend/billing/payments/%5Bid%5D/page.meta.ts"],
|
|
4
|
+
"sourcesContent": ["import React from 'react'\nimport { Landmark } from 'lucide-react'\n\nconst paymentIcon = React.createElement(Landmark, { size: 16 })\n\nexport const metadata = {\n requireAuth: true,\n requireFeatures: ['billing.payment.view'],\n pageTitle: 'Payment',\n pageTitleKey: 'billing.payments.detail.title',\n pageGroup: 'Billing',\n pageGroupKey: 'billing.nav.group',\n navHidden: true,\n icon: paymentIcon,\n breadcrumb: [\n { label: 'Payments', labelKey: 'billing.payments.title', href: '/backend/billing/payments' },\n { label: 'Payment', labelKey: 'billing.payments.detail.title' },\n ],\n} as const\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,WAAW;AAClB,SAAS,gBAAgB;AAEzB,MAAM,cAAc,MAAM,cAAc,UAAU,EAAE,MAAM,GAAG,CAAC;AAEvD,MAAM,WAAW;AAAA,EACtB,aAAa;AAAA,EACb,iBAAiB,CAAC,sBAAsB;AAAA,EACxC,WAAW;AAAA,EACX,cAAc;AAAA,EACd,WAAW;AAAA,EACX,cAAc;AAAA,EACd,WAAW;AAAA,EACX,MAAM;AAAA,EACN,YAAY;AAAA,IACV,EAAE,OAAO,YAAY,UAAU,0BAA0B,MAAM,4BAA4B;AAAA,IAC3F,EAAE,OAAO,WAAW,UAAU,gCAAgC;AAAA,EAChE;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { useParams } from "next/navigation";
|
|
5
|
+
import { useT } from "@open-mercato/shared/lib/i18n/context";
|
|
6
|
+
import { Page, PageBody } from "@open-mercato/ui/backend/Page";
|
|
7
|
+
import { FormHeader } from "@open-mercato/ui/backend/forms";
|
|
8
|
+
import { ErrorMessage, LoadingMessage, RecordNotFoundState } from "@open-mercato/ui/backend/detail";
|
|
9
|
+
import { readApiResultOrThrow } from "@open-mercato/ui/backend/utils/apiCall";
|
|
10
|
+
import { normalizeCrudServerError } from "@open-mercato/ui/backend/utils/serverErrors";
|
|
11
|
+
import { Stat, StatCard } from "../../../../../components/DetailFields.js";
|
|
12
|
+
import { PaymentsTable } from "../../../../../components/PaymentsTable.js";
|
|
13
|
+
function PaymentImportPage(props) {
|
|
14
|
+
const t = useT();
|
|
15
|
+
const urlParams = useParams();
|
|
16
|
+
const id = props.params?.id ?? urlParams?.id;
|
|
17
|
+
const [record, setRecord] = React.useState(null);
|
|
18
|
+
const [error, setError] = React.useState(null);
|
|
19
|
+
const [notFound, setNotFound] = React.useState(false);
|
|
20
|
+
React.useEffect(() => {
|
|
21
|
+
if (!id) return;
|
|
22
|
+
readApiResultOrThrow(`/api/billing/payment-imports/${encodeURIComponent(id)}`).then((result) => setRecord(result.import)).catch((err) => {
|
|
23
|
+
const normalized = normalizeCrudServerError(err);
|
|
24
|
+
if (err?.status === 404) setNotFound(true);
|
|
25
|
+
else setError(normalized.message || t("billing.payments.import.load_error", "Could not load the import"));
|
|
26
|
+
});
|
|
27
|
+
}, [id, t]);
|
|
28
|
+
if (notFound) {
|
|
29
|
+
return /* @__PURE__ */ jsx(Page, { children: /* @__PURE__ */ jsx(PageBody, { children: /* @__PURE__ */ jsx(RecordNotFoundState, { label: t("billing.payments.import.not_found", "Import not found"), backHref: "/backend/billing/payments", backLabel: t("billing.payments.title", "Payments") }) }) });
|
|
30
|
+
}
|
|
31
|
+
if (error) {
|
|
32
|
+
return /* @__PURE__ */ jsx(Page, { children: /* @__PURE__ */ jsx(PageBody, { children: /* @__PURE__ */ jsx(ErrorMessage, { label: error }) }) });
|
|
33
|
+
}
|
|
34
|
+
if (!record || !id) {
|
|
35
|
+
return /* @__PURE__ */ jsx(Page, { children: /* @__PURE__ */ jsx(PageBody, { children: /* @__PURE__ */ jsx(LoadingMessage, { label: t("billing.payments.import.loading", "Loading import\u2026") }) }) });
|
|
36
|
+
}
|
|
37
|
+
const counts = record.counts ?? {};
|
|
38
|
+
return /* @__PURE__ */ jsxs(Page, { children: [
|
|
39
|
+
/* @__PURE__ */ jsx(
|
|
40
|
+
FormHeader,
|
|
41
|
+
{
|
|
42
|
+
mode: "detail",
|
|
43
|
+
backHref: "/backend/billing/payments",
|
|
44
|
+
entityTypeLabel: t("billing.payments.import.detail_title", "Payment import"),
|
|
45
|
+
title: record.file_name
|
|
46
|
+
}
|
|
47
|
+
),
|
|
48
|
+
/* @__PURE__ */ jsx(PageBody, { children: /* @__PURE__ */ jsxs("div", { className: "space-y-6", children: [
|
|
49
|
+
/* @__PURE__ */ jsxs(StatCard, { children: [
|
|
50
|
+
/* @__PURE__ */ jsx(Stat, { label: t("billing.payments.import.counts.allocated", "Allocated"), value: counts.allocated ?? 0 }),
|
|
51
|
+
/* @__PURE__ */ jsx(Stat, { label: t("billing.payments.import.counts.partially_allocated", "Partially allocated"), value: counts.partially_allocated ?? 0 }),
|
|
52
|
+
/* @__PURE__ */ jsx(Stat, { label: t("billing.payments.import.counts.matched", "Matched (credit)"), value: counts.matched ?? 0 }),
|
|
53
|
+
/* @__PURE__ */ jsx(Stat, { label: t("billing.payments.import.counts.unmatched", "Unmatched"), value: counts.unmatched ?? 0 }),
|
|
54
|
+
/* @__PURE__ */ jsx(Stat, { label: t("billing.payments.import.counts.duplicate", "Duplicates"), value: counts.duplicate ?? 0 }),
|
|
55
|
+
/* @__PURE__ */ jsx(Stat, { label: t("billing.payments.import.counts.rejected", "Rejected rows"), value: counts.rejected ?? 0 })
|
|
56
|
+
] }),
|
|
57
|
+
(record.errors ?? []).length > 0 ? /* @__PURE__ */ jsxs("div", { className: "rounded-lg border bg-card p-4 text-sm", children: [
|
|
58
|
+
/* @__PURE__ */ jsx("h2", { className: "mb-2 font-semibold", children: t("billing.payments.import.errors", "Rejected rows") }),
|
|
59
|
+
(record.errors ?? []).map((row) => /* @__PURE__ */ jsxs("div", { className: "text-muted-foreground", children: [
|
|
60
|
+
t("billing.payments.import.line", "Line"),
|
|
61
|
+
" ",
|
|
62
|
+
row.row,
|
|
63
|
+
": ",
|
|
64
|
+
row.message
|
|
65
|
+
] }, `${row.row}-${row.message}`))
|
|
66
|
+
] }) : null,
|
|
67
|
+
/* @__PURE__ */ jsx(PaymentsTable, { title: t("billing.payments.title", "Payments"), tableId: "billing-payment-import-payments", importId: id })
|
|
68
|
+
] }) })
|
|
69
|
+
] });
|
|
70
|
+
}
|
|
71
|
+
export {
|
|
72
|
+
PaymentImportPage as default
|
|
73
|
+
};
|
|
74
|
+
//# sourceMappingURL=page.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../../src/modules/billing/backend/billing/payments/imports/%5Bid%5D/page.tsx"],
|
|
4
|
+
"sourcesContent": ["\"use client\"\nimport * as React from 'react'\nimport { useParams } from 'next/navigation'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport { Page, PageBody } from '@open-mercato/ui/backend/Page'\nimport { FormHeader } from '@open-mercato/ui/backend/forms'\nimport { ErrorMessage, LoadingMessage, RecordNotFoundState } from '@open-mercato/ui/backend/detail'\nimport { readApiResultOrThrow } from '@open-mercato/ui/backend/utils/apiCall'\nimport { normalizeCrudServerError } from '@open-mercato/ui/backend/utils/serverErrors'\nimport { Stat, StatCard } from '../../../../../components/DetailFields'\nimport { PaymentsTable } from '../../../../../components/PaymentsTable'\n\n/** One CSV upload batch (Spec C, C-D4): counts per outcome, row errors and its payments. */\n\ntype ImportRecord = {\n id: string\n file_name: string\n row_count: number\n counts: Record<string, number> | null\n errors: Array<{ row: number; message: string }> | null\n created_at: string\n}\n\nexport default function PaymentImportPage(props: { params?: { id?: string } }) {\n const t = useT()\n // OM serves backend pages through a catch-all route \u2014 the dynamic `[id]`\n // segment arrives as a page prop; `useParams()` is only the fallback.\n const urlParams = useParams<{ id: string }>()\n const id = props.params?.id ?? urlParams?.id\n const [record, setRecord] = React.useState<ImportRecord | null>(null)\n const [error, setError] = React.useState<string | null>(null)\n const [notFound, setNotFound] = React.useState(false)\n\n React.useEffect(() => {\n if (!id) return\n readApiResultOrThrow<{ import: ImportRecord }>(`/api/billing/payment-imports/${encodeURIComponent(id)}`)\n .then((result) => setRecord(result.import))\n .catch((err) => {\n const normalized = normalizeCrudServerError(err)\n if ((err as { status?: number })?.status === 404) setNotFound(true)\n else setError(normalized.message || t('billing.payments.import.load_error', 'Could not load the import'))\n })\n }, [id, t])\n\n if (notFound) {\n return (\n <Page>\n <PageBody>\n <RecordNotFoundState label={t('billing.payments.import.not_found', 'Import not found')} backHref=\"/backend/billing/payments\" backLabel={t('billing.payments.title', 'Payments')} />\n </PageBody>\n </Page>\n )\n }\n if (error) {\n return (\n <Page>\n <PageBody>\n <ErrorMessage label={error} />\n </PageBody>\n </Page>\n )\n }\n if (!record || !id) {\n return (\n <Page>\n <PageBody>\n <LoadingMessage label={t('billing.payments.import.loading', 'Loading import\u2026')} />\n </PageBody>\n </Page>\n )\n }\n const counts = record.counts ?? {}\n return (\n <Page>\n <FormHeader\n mode=\"detail\"\n backHref=\"/backend/billing/payments\"\n entityTypeLabel={t('billing.payments.import.detail_title', 'Payment import')}\n title={record.file_name}\n />\n <PageBody>\n <div className=\"space-y-6\">\n <StatCard>\n <Stat label={t('billing.payments.import.counts.allocated', 'Allocated')} value={counts.allocated ?? 0} />\n <Stat label={t('billing.payments.import.counts.partially_allocated', 'Partially allocated')} value={counts.partially_allocated ?? 0} />\n <Stat label={t('billing.payments.import.counts.matched', 'Matched (credit)')} value={counts.matched ?? 0} />\n <Stat label={t('billing.payments.import.counts.unmatched', 'Unmatched')} value={counts.unmatched ?? 0} />\n <Stat label={t('billing.payments.import.counts.duplicate', 'Duplicates')} value={counts.duplicate ?? 0} />\n <Stat label={t('billing.payments.import.counts.rejected', 'Rejected rows')} value={counts.rejected ?? 0} />\n </StatCard>\n {(record.errors ?? []).length > 0 ? (\n <div className=\"rounded-lg border bg-card p-4 text-sm\">\n <h2 className=\"mb-2 font-semibold\">{t('billing.payments.import.errors', 'Rejected rows')}</h2>\n {(record.errors ?? []).map((row) => (\n <div key={`${row.row}-${row.message}`} className=\"text-muted-foreground\">\n {t('billing.payments.import.line', 'Line')} {row.row}: {row.message}\n </div>\n ))}\n </div>\n ) : null}\n <PaymentsTable title={t('billing.payments.title', 'Payments')} tableId=\"billing-payment-import-payments\" importId={id} />\n </div>\n </PageBody>\n </Page>\n )\n}\n"],
|
|
5
|
+
"mappings": ";AAgDU,cAkCA,YAlCA;AA/CV,YAAY,WAAW;AACvB,SAAS,iBAAiB;AAC1B,SAAS,YAAY;AACrB,SAAS,MAAM,gBAAgB;AAC/B,SAAS,kBAAkB;AAC3B,SAAS,cAAc,gBAAgB,2BAA2B;AAClE,SAAS,4BAA4B;AACrC,SAAS,gCAAgC;AACzC,SAAS,MAAM,gBAAgB;AAC/B,SAAS,qBAAqB;AAaf,SAAR,kBAAmC,OAAqC;AAC7E,QAAM,IAAI,KAAK;AAGf,QAAM,YAAY,UAA0B;AAC5C,QAAM,KAAK,MAAM,QAAQ,MAAM,WAAW;AAC1C,QAAM,CAAC,QAAQ,SAAS,IAAI,MAAM,SAA8B,IAAI;AACpE,QAAM,C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,QACvG,oBAAC,QAAK,OAAO,EAAE,sDAAsD,qBAAqB,GAAG,OAAO,OAAO,uBAAuB,GAAG;AAAA,QACrI,oBAAC,QAAK,OAAO,EAAE,0CAA0C,kBAAkB,GAAG,OAAO,OAAO,WAAW,GAAG;AAAA,QAC1G,oBAAC,QAAK,OAAO,EAAE,4CAA4C,WAAW,GAAG,OAAO,OAAO,aAAa,GAAG;AAAA,QACvG,oBAAC,QAAK,OAAO,EAAE,4CAA4C,YAAY,GAAG,OAAO,OAAO,aAAa,GAAG;AAAA,QACxG,oBAAC,QAAK,OAAO,EAAE,2CAA2C,eAAe,GAAG,OAAO,OAAO,YAAY,GAAG;AAAA,SAC3G;AAAA,OACE,OAAO,UAAU,CAAC,GAAG,SAAS,IAC9B,qBAAC,SAAI,WAAU,yCACb;AAAA,4BAAC,QAAG,WAAU,sBAAsB,YAAE,kCAAkC,eAAe,GAAE;AAAA,SACvF,OAAO,UAAU,CAAC,GAAG,IAAI,CAAC,QAC1B,qBAAC,SAAsC,WAAU,yBAC9C;AAAA,YAAE,gCAAgC,MAAM;AAAA,UAAE;AAAA,UAAE,IAAI;AAAA,UAAI;AAAA,UAAG,IAAI;AAAA,aADpD,GAAG,IAAI,GAAG,IAAI,IAAI,OAAO,EAEnC,CACD;AAAA,SACH,IACE;AAAA,MACJ,oBAAC,iBAAc,OAAO,EAAE,0BAA0B,UAAU,GAAG,SAAQ,mCAAkC,UAAU,IAAI;AAAA,OACzH,GACF;AAAA,KACF;AAEJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Landmark } from "lucide-react";
|
|
3
|
+
const importIcon = React.createElement(Landmark, { size: 16 });
|
|
4
|
+
const metadata = {
|
|
5
|
+
requireAuth: true,
|
|
6
|
+
requireFeatures: ["billing.payment.view"],
|
|
7
|
+
pageTitle: "Payment import",
|
|
8
|
+
pageTitleKey: "billing.payments.import.detail_title",
|
|
9
|
+
pageGroup: "Billing",
|
|
10
|
+
pageGroupKey: "billing.nav.group",
|
|
11
|
+
navHidden: true,
|
|
12
|
+
icon: importIcon,
|
|
13
|
+
breadcrumb: [
|
|
14
|
+
{ label: "Payments", labelKey: "billing.payments.title", href: "/backend/billing/payments" },
|
|
15
|
+
{ label: "Import", labelKey: "billing.payments.import.detail_title" }
|
|
16
|
+
]
|
|
17
|
+
};
|
|
18
|
+
export {
|
|
19
|
+
metadata
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=page.meta.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../../src/modules/billing/backend/billing/payments/imports/%5Bid%5D/page.meta.ts"],
|
|
4
|
+
"sourcesContent": ["import React from 'react'\nimport { Landmark } from 'lucide-react'\n\nconst importIcon = React.createElement(Landmark, { size: 16 })\n\nexport const metadata = {\n requireAuth: true,\n requireFeatures: ['billing.payment.view'],\n pageTitle: 'Payment import',\n pageTitleKey: 'billing.payments.import.detail_title',\n pageGroup: 'Billing',\n pageGroupKey: 'billing.nav.group',\n navHidden: true,\n icon: importIcon,\n breadcrumb: [\n { label: 'Payments', labelKey: 'billing.payments.title', href: '/backend/billing/payments' },\n { label: 'Import', labelKey: 'billing.payments.import.detail_title' },\n ],\n} as const\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,WAAW;AAClB,SAAS,gBAAgB;AAEzB,MAAM,aAAa,MAAM,cAAc,UAAU,EAAE,MAAM,GAAG,CAAC;AAEtD,MAAM,WAAW;AAAA,EACtB,aAAa;AAAA,EACb,iBAAiB,CAAC,sBAAsB;AAAA,EACxC,WAAW;AAAA,EACX,cAAc;AAAA,EACd,WAAW;AAAA,EACX,cAAc;AAAA,EACd,WAAW;AAAA,EACX,MAAM;AAAA,EACN,YAAY;AAAA,IACV,EAAE,OAAO,YAAY,UAAU,0BAA0B,MAAM,4BAA4B;AAAA,IAC3F,EAAE,OAAO,UAAU,UAAU,uCAAuC;AAAA,EACtE;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { useRouter } from "next/navigation";
|
|
5
|
+
import { Plus, Upload } from "lucide-react";
|
|
6
|
+
import { useT } from "@open-mercato/shared/lib/i18n/context";
|
|
7
|
+
import { Page, PageBody } from "@open-mercato/ui/backend/Page";
|
|
8
|
+
import { Button } from "@open-mercato/ui/primitives/button";
|
|
9
|
+
import { PaymentsTable } from "../../../components/PaymentsTable.js";
|
|
10
|
+
import { PaymentUploadDialog } from "../../../components/PaymentUploadDialog.js";
|
|
11
|
+
import { ManualPaymentDialog } from "../../../components/ManualPaymentDialog.js";
|
|
12
|
+
function BillingPaymentsPage() {
|
|
13
|
+
const t = useT();
|
|
14
|
+
const router = useRouter();
|
|
15
|
+
const [uploadOpen, setUploadOpen] = React.useState(false);
|
|
16
|
+
const [manualOpen, setManualOpen] = React.useState(false);
|
|
17
|
+
const [reloadKey, setReloadKey] = React.useState(0);
|
|
18
|
+
return /* @__PURE__ */ jsx(Page, { children: /* @__PURE__ */ jsxs(PageBody, { children: [
|
|
19
|
+
/* @__PURE__ */ jsx(
|
|
20
|
+
PaymentsTable,
|
|
21
|
+
{
|
|
22
|
+
title: t("billing.payments.title", "Payments"),
|
|
23
|
+
tableId: "billing-payments",
|
|
24
|
+
reloadKey,
|
|
25
|
+
actions: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
26
|
+
/* @__PURE__ */ jsxs(Button, { type: "button", variant: "outline", onClick: () => setManualOpen(true), children: [
|
|
27
|
+
/* @__PURE__ */ jsx(Plus, { size: 16 }),
|
|
28
|
+
t("billing.payments.manual.action", "Record payment")
|
|
29
|
+
] }),
|
|
30
|
+
/* @__PURE__ */ jsxs(Button, { type: "button", onClick: () => setUploadOpen(true), children: [
|
|
31
|
+
/* @__PURE__ */ jsx(Upload, { size: 16 }),
|
|
32
|
+
t("billing.payments.import.open", "Upload CSV")
|
|
33
|
+
] })
|
|
34
|
+
] })
|
|
35
|
+
}
|
|
36
|
+
),
|
|
37
|
+
/* @__PURE__ */ jsx(
|
|
38
|
+
PaymentUploadDialog,
|
|
39
|
+
{
|
|
40
|
+
open: uploadOpen,
|
|
41
|
+
onClose: () => setUploadOpen(false),
|
|
42
|
+
onImported: () => setReloadKey((k) => k + 1)
|
|
43
|
+
}
|
|
44
|
+
),
|
|
45
|
+
/* @__PURE__ */ jsx(
|
|
46
|
+
ManualPaymentDialog,
|
|
47
|
+
{
|
|
48
|
+
open: manualOpen,
|
|
49
|
+
onClose: () => setManualOpen(false),
|
|
50
|
+
onCreated: (paymentId) => router.push(`/backend/billing/payments/${encodeURIComponent(paymentId)}`)
|
|
51
|
+
}
|
|
52
|
+
)
|
|
53
|
+
] }) });
|
|
54
|
+
}
|
|
55
|
+
export {
|
|
56
|
+
BillingPaymentsPage as default
|
|
57
|
+
};
|
|
58
|
+
//# sourceMappingURL=page.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../src/modules/billing/backend/billing/payments/page.tsx"],
|
|
4
|
+
"sourcesContent": ["\"use client\"\nimport * as React from 'react'\nimport { useRouter } from 'next/navigation'\nimport { Plus, Upload } from 'lucide-react'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport { Page, PageBody } from '@open-mercato/ui/backend/Page'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { PaymentsTable } from '../../../components/PaymentsTable'\nimport { PaymentUploadDialog } from '../../../components/PaymentUploadDialog'\nimport { ManualPaymentDialog } from '../../../components/ManualPaymentDialog'\n\n/**\n * Payments (Spec C): the billing payment register. Upload a bank CSV (each\n * row becomes a payment, matched by invoice number), or record one manually.\n * Unmatched payments are fixed on the payment page.\n */\nexport default function BillingPaymentsPage() {\n const t = useT()\n const router = useRouter()\n const [uploadOpen, setUploadOpen] = React.useState(false)\n const [manualOpen, setManualOpen] = React.useState(false)\n const [reloadKey, setReloadKey] = React.useState(0)\n return (\n <Page>\n <PageBody>\n <PaymentsTable\n title={t('billing.payments.title', 'Payments')}\n tableId=\"billing-payments\"\n reloadKey={reloadKey}\n actions={\n <div className=\"flex items-center gap-2\">\n <Button type=\"button\" variant=\"outline\" onClick={() => setManualOpen(true)}>\n <Plus size={16} />\n {t('billing.payments.manual.action', 'Record payment')}\n </Button>\n <Button type=\"button\" onClick={() => setUploadOpen(true)}>\n <Upload size={16} />\n {t('billing.payments.import.open', 'Upload CSV')}\n </Button>\n </div>\n }\n />\n <PaymentUploadDialog\n open={uploadOpen}\n onClose={() => setUploadOpen(false)}\n onImported={() => setReloadKey((k) => k + 1)}\n />\n <ManualPaymentDialog\n open={manualOpen}\n onClose={() => setManualOpen(false)}\n onCreated={(paymentId) => router.push(`/backend/billing/payments/${encodeURIComponent(paymentId)}`)}\n />\n </PageBody>\n </Page>\n )\n}\n"],
|
|
5
|
+
"mappings": ";AA+Bc,SACE,KADF;AA9Bd,YAAY,WAAW;AACvB,SAAS,iBAAiB;AAC1B,SAAS,MAAM,cAAc;AAC7B,SAAS,YAAY;AACrB,SAAS,MAAM,gBAAgB;AAC/B,SAAS,cAAc;AACvB,SAAS,qBAAqB;AAC9B,SAAS,2BAA2B;AACpC,SAAS,2BAA2B;AAOrB,SAAR,sBAAuC;AAC5C,QAAM,IAAI,KAAK;AACf,QAAM,SAAS,UAAU;AACzB,QAAM,CAAC,YAAY,aAAa,IAAI,MAAM,SAAS,KAAK;AACxD,QAAM,CAAC,YAAY,aAAa,IAAI,MAAM,SAAS,KAAK;AACxD,QAAM,CAAC,WAAW,YAAY,IAAI,MAAM,SAAS,CAAC;AAClD,SACE,oBAAC,QACC,+BAAC,YACC;AAAA;AAAA,MAAC;AAAA;AAAA,QACC,OAAO,EAAE,0BAA0B,UAAU;AAAA,QAC7C,SAAQ;AAAA,QACR;AAAA,QACA,SACE,qBAAC,SAAI,WAAU,2BACb;AAAA,+BAAC,UAAO,MAAK,UAAS,SAAQ,WAAU,SAAS,MAAM,cAAc,IAAI,GACvE;AAAA,gCAAC,QAAK,MAAM,IAAI;AAAA,YACf,EAAE,kCAAkC,gBAAgB;AAAA,aACvD;AAAA,UACA,qBAAC,UAAO,MAAK,UAAS,SAAS,MAAM,cAAc,IAAI,GACrD;AAAA,gCAAC,UAAO,MAAM,IAAI;AAAA,YACjB,EAAE,gCAAgC,YAAY;AAAA,aACjD;AAAA,WACF;AAAA;AAAA,IAEJ;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACC,MAAM;AAAA,QACN,SAAS,MAAM,cAAc,KAAK;AAAA,QAClC,YAAY,MAAM,aAAa,CAAC,MAAM,IAAI,CAAC;AAAA;AAAA,IAC7C;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACC,MAAM;AAAA,QACN,SAAS,MAAM,cAAc,KAAK;AAAA,QAClC,WAAW,CAAC,cAAc,OAAO,KAAK,6BAA6B,mBAAmB,SAAS,CAAC,EAAE;AAAA;AAAA,IACpG;AAAA,KACF,GACF;AAEJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Landmark } from "lucide-react";
|
|
3
|
+
const paymentsIcon = React.createElement(Landmark, { size: 16 });
|
|
4
|
+
const metadata = {
|
|
5
|
+
requireAuth: true,
|
|
6
|
+
requireFeatures: ["billing.payment.view"],
|
|
7
|
+
pageTitle: "Payments",
|
|
8
|
+
pageTitleKey: "billing.payments.title",
|
|
9
|
+
pageGroup: "Billing",
|
|
10
|
+
pageGroupKey: "billing.nav.group",
|
|
11
|
+
pageOrder: 45,
|
|
12
|
+
icon: paymentsIcon,
|
|
13
|
+
breadcrumb: [{ label: "Payments", labelKey: "billing.payments.title" }]
|
|
14
|
+
};
|
|
15
|
+
export {
|
|
16
|
+
metadata
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=page.meta.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../src/modules/billing/backend/billing/payments/page.meta.ts"],
|
|
4
|
+
"sourcesContent": ["import React from 'react'\nimport { Landmark } from 'lucide-react'\n\nconst paymentsIcon = React.createElement(Landmark, { size: 16 })\n\nexport const metadata = {\n requireAuth: true,\n requireFeatures: ['billing.payment.view'],\n pageTitle: 'Payments',\n pageTitleKey: 'billing.payments.title',\n pageGroup: 'Billing',\n pageGroupKey: 'billing.nav.group',\n pageOrder: 45,\n icon: paymentsIcon,\n breadcrumb: [{ label: 'Payments', labelKey: 'billing.payments.title' }],\n} as const\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,WAAW;AAClB,SAAS,gBAAgB;AAEzB,MAAM,eAAe,MAAM,cAAc,UAAU,EAAE,MAAM,GAAG,CAAC;AAExD,MAAM,WAAW;AAAA,EACtB,aAAa;AAAA,EACb,iBAAiB,CAAC,sBAAsB;AAAA,EACxC,WAAW;AAAA,EACX,cAAc;AAAA,EACd,WAAW;AAAA,EACX,cAAc;AAAA,EACd,WAAW;AAAA,EACX,MAAM;AAAA,EACN,YAAY,CAAC,EAAE,OAAO,YAAY,UAAU,yBAAyB,CAAC;AACxE;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import Link from "next/link";
|
|
5
|
-
import { useParams } from "next/navigation";
|
|
5
|
+
import { useParams, useRouter } from "next/navigation";
|
|
6
6
|
import { useT } from "@open-mercato/shared/lib/i18n/context";
|
|
7
7
|
import { Page, PageBody, PageHeader } from "@open-mercato/ui/backend/Page";
|
|
8
8
|
import { FormHeader } from "@open-mercato/ui/backend/forms";
|
|
9
|
-
import { DataTable } from "
|
|
9
|
+
import { BillingDataTable as DataTable } from "../../../../components/BillingDataTable.js";
|
|
10
10
|
import { Tag } from "@open-mercato/ui/primitives/tag";
|
|
11
11
|
import { Button } from "@open-mercato/ui/primitives/button";
|
|
12
12
|
import { LoadingMessage, ErrorMessage } from "@open-mercato/ui/backend/detail";
|
|
@@ -17,6 +17,9 @@ import {
|
|
|
17
17
|
} from "@open-mercato/ui/backend/utils/apiCall";
|
|
18
18
|
import { normalizeCrudServerError } from "@open-mercato/ui/backend/utils/serverErrors";
|
|
19
19
|
import { billRunName } from "../../../../lib/billRunLabel.js";
|
|
20
|
+
import { RunCyclesSection } from "../../../../components/RunCyclesSection.js";
|
|
21
|
+
import { TestRunActions, billRunMode } from "../../../../components/TestRunActions.js";
|
|
22
|
+
import { PostRunDraftsButton } from "../../../../components/PostRunDraftsButton.js";
|
|
20
23
|
import {
|
|
21
24
|
DetailCard,
|
|
22
25
|
DetailField,
|
|
@@ -109,6 +112,7 @@ function BillRunDetailPage(props) {
|
|
|
109
112
|
React.useEffect(() => {
|
|
110
113
|
void loadOutcomes();
|
|
111
114
|
}, [loadOutcomes]);
|
|
115
|
+
const router = useRouter();
|
|
112
116
|
const failedCount = run?.summary?.accounts_failed ?? 0;
|
|
113
117
|
const handleRetryFailed = React.useCallback(async () => {
|
|
114
118
|
if (!run || failedCount === 0) return;
|
|
@@ -175,8 +179,9 @@ function BillRunDetailPage(props) {
|
|
|
175
179
|
accessorKey: "warnings",
|
|
176
180
|
header: t("billing.runs.outcomes.columns.warnings", "Warnings"),
|
|
177
181
|
cell: ({ row }) => {
|
|
178
|
-
|
|
179
|
-
|
|
182
|
+
const { skipped_items: _skipped, ...rest } = row.original.warnings ?? {};
|
|
183
|
+
if (Object.keys(rest).length === 0) return "\u2014";
|
|
184
|
+
return /* @__PURE__ */ jsx("span", { className: "font-mono text-xs", children: JSON.stringify(rest) });
|
|
180
185
|
}
|
|
181
186
|
}
|
|
182
187
|
],
|
|
@@ -203,20 +208,42 @@ function BillRunDetailPage(props) {
|
|
|
203
208
|
entityTypeLabel: t("billing.runs.detail.title", "Bill Run"),
|
|
204
209
|
title: billRunName(run.as_of_date),
|
|
205
210
|
statusBadge: /* @__PURE__ */ jsx(Tag, { variant: runStatusVariant(run.status), children: run.status }),
|
|
206
|
-
actionsContent:
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
211
|
+
actionsContent: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
212
|
+
failedCount > 0 ? /* @__PURE__ */ jsxs(Button, { disabled: retrying, onClick: handleRetryFailed, children: [
|
|
213
|
+
retrying ? t("billing.runs.retry.in_progress", "Retrying\u2026") : t("billing.runs.retry.action", "Retry failed accounts"),
|
|
214
|
+
` (${failedCount})`
|
|
215
|
+
] }) : null,
|
|
216
|
+
run.status !== "running" && billRunMode(run) === "real" ? /* @__PURE__ */ jsx(
|
|
217
|
+
PostRunDraftsButton,
|
|
218
|
+
{
|
|
219
|
+
runId: run.id,
|
|
220
|
+
onPosted: () => {
|
|
221
|
+
void loadRun();
|
|
222
|
+
void loadOutcomes();
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
) : null,
|
|
226
|
+
run.status !== "running" ? /* @__PURE__ */ jsx(
|
|
227
|
+
TestRunActions,
|
|
228
|
+
{
|
|
229
|
+
runId: run.id,
|
|
230
|
+
mode: billRunMode(run),
|
|
231
|
+
draftsCount: run.summary?.drafts_created,
|
|
232
|
+
onWiped: () => {
|
|
233
|
+
void loadRun();
|
|
234
|
+
void loadOutcomes();
|
|
235
|
+
},
|
|
236
|
+
onDeleted: () => router.push("/backend/billing/runs")
|
|
237
|
+
}
|
|
238
|
+
) : null
|
|
239
|
+
] })
|
|
210
240
|
}
|
|
211
241
|
),
|
|
212
242
|
/* @__PURE__ */ jsx(PageBody, { children: /* @__PURE__ */ jsxs("div", { className: "space-y-6", children: [
|
|
213
243
|
/* @__PURE__ */ jsxs(DetailCard, { children: [
|
|
214
244
|
/* @__PURE__ */ jsx(DetailField, { label: t("billing.runs.detail.field.run_id", "Run ID"), children: /* @__PURE__ */ jsx("span", { className: "font-mono text-xs", children: run.id }) }),
|
|
215
245
|
/* @__PURE__ */ jsx(DetailField, { label: t("billing.runs.detail.field.triggered_by", "Trigger"), children: run.triggered_by }),
|
|
216
|
-
/* @__PURE__ */ jsx(DetailField, { label: t("billing.runs.detail.field.mode", "Mode"), children: /* @__PURE__ */
|
|
217
|
-
run.dry_run ? /* @__PURE__ */ jsx(Tag, { variant: "warning", children: t("billing.runs.mode.dry_run", "Dry-run") }) : run.test_mode ? /* @__PURE__ */ jsx(Tag, { variant: "warning", children: t("billing.runs.mode.test", "Test") }) : /* @__PURE__ */ jsx(Tag, { variant: "default", children: t("billing.runs.mode.real", "Real") }),
|
|
218
|
-
run.catch_up ? /* @__PURE__ */ jsx(Tag, { variant: "default", children: t("billing.runs.mode.catch_up", "Catch-up") }) : null
|
|
219
|
-
] }) }),
|
|
246
|
+
/* @__PURE__ */ jsx(DetailField, { label: t("billing.runs.detail.field.mode", "Mode"), children: /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-1", children: run.dry_run ? /* @__PURE__ */ jsx(Tag, { variant: "warning", children: t("billing.runs.mode.dry_run", "Dry-run") }) : run.test_mode ? /* @__PURE__ */ jsx(Tag, { variant: "warning", children: t("billing.runs.mode.test", "Test") }) : /* @__PURE__ */ jsx(Tag, { variant: "default", children: t("billing.runs.mode.real", "Real") }) }) }),
|
|
220
247
|
/* @__PURE__ */ jsx(DetailField, { label: t("billing.runs.detail.field.as_of_date", "As-of date"), children: run.as_of_date?.slice(0, 10) ?? "\u2014" }),
|
|
221
248
|
/* @__PURE__ */ jsx(DetailField, { label: t("billing.runs.detail.field.started_at", "Started"), children: formatDate(run.started_at) }),
|
|
222
249
|
/* @__PURE__ */ jsx(DetailField, { label: t("billing.runs.detail.field.finished_at", "Finished"), children: formatDate(run.finished_at) }),
|
|
@@ -237,6 +264,13 @@ function BillRunDetailPage(props) {
|
|
|
237
264
|
value: run.summary.drafts_created ?? 0
|
|
238
265
|
}
|
|
239
266
|
),
|
|
267
|
+
/* @__PURE__ */ jsx(
|
|
268
|
+
Stat,
|
|
269
|
+
{
|
|
270
|
+
label: t("billing.runs.summary.cycles", "Cycles"),
|
|
271
|
+
value: run.summary.cycles_processed ?? 0
|
|
272
|
+
}
|
|
273
|
+
),
|
|
240
274
|
/* @__PURE__ */ jsx(
|
|
241
275
|
Stat,
|
|
242
276
|
{
|
|
@@ -283,7 +317,8 @@ function BillRunDetailPage(props) {
|
|
|
283
317
|
}
|
|
284
318
|
}
|
|
285
319
|
)
|
|
286
|
-
] })
|
|
320
|
+
] }),
|
|
321
|
+
/* @__PURE__ */ jsx(RunCyclesSection, { outcomes })
|
|
287
322
|
] }) })
|
|
288
323
|
] });
|
|
289
324
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../src/modules/billing/backend/billing/runs/%5Bid%5D/page.tsx"],
|
|
4
|
-
"sourcesContent": ["\"use client\"\nimport * as React from 'react'\nimport Link from 'next/link'\nimport { useParams } from 'next/navigation'\nimport type { LegacyColumnDef as ColumnDef } from '@tanstack/react-table/legacy'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport { Page, PageBody, PageHeader } from '@open-mercato/ui/backend/Page'\nimport { FormHeader } from '@open-mercato/ui/backend/forms'\nimport { DataTable } from '@open-mercato/ui/backend/DataTable'\nimport { Tag } from '@open-mercato/ui/primitives/tag'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { LoadingMessage, ErrorMessage } from '@open-mercato/ui/backend/detail'\nimport { flash } from '@open-mercato/ui/backend/FlashMessages'\nimport {\n apiCallOrThrow,\n readApiResultOrThrow,\n} from '@open-mercato/ui/backend/utils/apiCall'\nimport { normalizeCrudServerError } from '@open-mercato/ui/backend/utils/serverErrors'\nimport { billRunName } from '../../../../lib/billRunLabel'\nimport {\n DetailCard,\n DetailField,\n Stat,\n StatCard,\n} from '../../../../components/DetailFields'\n\n/**\n * Bill Run detail \u2014 header card + outcomes list.\n *\n * The \"Retry failed accounts\" button is enabled only when the run\n * has at least one failed outcome. It POSTs the\n * `billing.runs.retry_failed` endpoint, which creates a new run\n * scoped to those accounts (the new run shows up in the list at\n * `/backend/billing/runs`).\n */\n\n// API list rows are snake_case (see `api/runs/route.ts` +\n// `api/run-outcomes/route.ts` `fields`).\ntype BillRun = {\n id: string\n triggered_by: 'schedule' | 'manual'\n parent_run_id: string | null\n dry_run: boolean\n test_mode: boolean\n catch_up: boolean\n as_of_date: string\n started_at: string | null\n finished_at: string | null\n status: 'running' | 'completed' | 'partial_failure' | 'failed'\n summary: {\n accounts_processed?: number\n drafts_created?: number\n drafts_skipped_existing?: number\n accounts_failed?: number\n accounts_with_warnings?: number\n usage_records_rated?: number\n } | null\n organization_id: string\n tenant_id: string\n created_at: string\n updated_at: string\n}\n\ntype BillRunOutcome = {\n id: string\n bill_run_id: string\n bill_account_id: string\n bill_account_name: string | null\n status: 'success' | 'success_with_warnings' | 'skipped_existing_draft' | 'failed'\n error_message: string | null\n warnings: Record<string, unknown> | null\n draft_invoice_id: string | null\n invoice_number: string | null\n created_at: string\n}\n\ntype ListResponse<T> = {\n items: T[]\n total: number\n totalPages: number\n}\n\nfunction formatDate(value: string | null | undefined): string {\n if (!value) return '\u2014'\n const parsed = new Date(value)\n return Number.isNaN(parsed.getTime()) ? value : parsed.toLocaleString()\n}\n\nfunction runStatusVariant(\n status: BillRun['status'],\n): 'default' | 'success' | 'warning' | 'error' {\n switch (status) {\n case 'completed':\n return 'success'\n case 'partial_failure':\n return 'warning'\n case 'failed':\n return 'error'\n default:\n return 'default'\n }\n}\n\nfunction outcomeStatusVariant(\n status: BillRunOutcome['status'],\n): 'default' | 'success' | 'warning' | 'error' {\n switch (status) {\n case 'success':\n return 'success'\n case 'success_with_warnings':\n return 'warning'\n case 'failed':\n return 'error'\n case 'skipped_existing_draft':\n default:\n return 'default'\n }\n}\n\nexport default function BillRunDetailPage(props: { params?: { id?: string } }) {\n const t = useT()\n // OM serves backend pages through a catch-all route \u2014 the dynamic\n // `[id]` segment arrives as a page prop; `useParams()` is the fallback.\n const urlParams = useParams<{ id: string }>()\n const runId = (props.params?.id ?? urlParams?.id ?? '') as string\n\n const [run, setRun] = React.useState<BillRun | null>(null)\n const [runError, setRunError] = React.useState<string | null>(null)\n const [outcomes, setOutcomes] = React.useState<BillRunOutcome[]>([])\n const [outcomesPage, setOutcomesPage] = React.useState(1)\n const [outcomesTotal, setOutcomesTotal] = React.useState(0)\n const [outcomesTotalPages, setOutcomesTotalPages] = React.useState(1)\n const [outcomesLoading, setOutcomesLoading] = React.useState(true)\n const [retrying, setRetrying] = React.useState(false)\n\n const loadRun = React.useCallback(async () => {\n if (!runId) return\n setRunError(null)\n try {\n const result = await readApiResultOrThrow<ListResponse<BillRun>>(\n `/api/billing/runs?id=${runId}&pageSize=1`,\n )\n const found = result.items?.[0]\n if (!found) {\n setRunError(t('billing.runs.detail.error.not_found', 'Run not found'))\n setRun(null)\n return\n }\n setRun(found)\n } catch (err) {\n const { message } = normalizeCrudServerError(err)\n setRunError(message || t('billing.runs.detail.error.load', 'Failed to load run'))\n }\n }, [runId, t])\n\n const loadOutcomes = React.useCallback(async () => {\n if (!runId) return\n setOutcomesLoading(true)\n try {\n const params = new URLSearchParams({\n billRunId: runId,\n page: String(outcomesPage),\n pageSize: '50',\n })\n const result = await readApiResultOrThrow<ListResponse<BillRunOutcome>>(\n `/api/billing/run-outcomes?${params.toString()}`,\n )\n setOutcomes(result.items ?? [])\n setOutcomesTotal(result.total ?? 0)\n setOutcomesTotalPages(result.totalPages ?? 1)\n } finally {\n setOutcomesLoading(false)\n }\n }, [outcomesPage, runId])\n\n React.useEffect(() => {\n void loadRun()\n }, [loadRun])\n React.useEffect(() => {\n void loadOutcomes()\n }, [loadOutcomes])\n\n const failedCount = run?.summary?.accounts_failed ?? 0\n\n const handleRetryFailed = React.useCallback(async () => {\n if (!run || failedCount === 0) return\n setRetrying(true)\n try {\n const call = await apiCallOrThrow<{ billRunId: string; outcomesCount: number }>(\n '/api/billing/runs/retry-failed',\n {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ billRunId: run.id }),\n },\n )\n const outcomesCount = call.result?.outcomesCount ?? 0\n flash(\n t('billing.runs.retry.success', 'Retry run created') +\n ` (${outcomesCount} accounts)`,\n 'success',\n )\n // Refresh \u2014 the new run shows up in the list view; the current\n // run's outcomes are immutable so no reload of `loadOutcomes`\n // needed, but loadRun is cheap.\n void loadRun()\n } catch (err) {\n const { message } = normalizeCrudServerError(err)\n flash(message || t('billing.runs.retry.error', 'Retry failed'), 'error')\n } finally {\n setRetrying(false)\n }\n }, [failedCount, loadRun, run, t])\n\n const outcomeColumns = React.useMemo<ColumnDef<BillRunOutcome>[]>(\n () => [\n {\n accessorKey: 'bill_account_id',\n header: t('billing.runs.outcomes.columns.account', 'Account'),\n cell: ({ row }) => (\n <Link\n href={`/backend/billing/accounts/${row.original.bill_account_id}`}\n className=\"text-sm text-primary hover:underline\"\n >\n {row.original.bill_account_name ?? row.original.bill_account_id}\n </Link>\n ),\n },\n {\n accessorKey: 'status',\n header: t('billing.runs.outcomes.columns.status', 'Status'),\n cell: ({ row }) => (\n <Tag variant={outcomeStatusVariant(row.original.status)}>\n {row.original.status}\n </Tag>\n ),\n },\n {\n accessorKey: 'draft_invoice_id',\n header: t('billing.runs.outcomes.columns.invoice', 'Invoice'),\n cell: ({ row }) =>\n row.original.draft_invoice_id ? (\n <Link\n href={`/backend/billing/invoices/${row.original.draft_invoice_id}`}\n className=\"text-sm text-primary hover:underline\"\n >\n {row.original.invoice_number ?? row.original.draft_invoice_id}\n </Link>\n ) : (\n '\u2014'\n ),\n },\n {\n accessorKey: 'error_message',\n header: t('billing.runs.outcomes.columns.error', 'Error'),\n cell: ({ row }) => row.original.error_message ?? '\u2014',\n },\n {\n accessorKey: 'warnings',\n header: t('billing.runs.outcomes.columns.warnings', 'Warnings'),\n cell: ({ row }) => {\n if (!row.original.warnings) return '\u2014'\n return (\n <span className=\"font-mono text-xs\">{JSON.stringify(row.original.warnings)}</span>\n )\n },\n },\n ],\n [t],\n )\n\n if (runError) {\n return (\n <Page>\n <PageHeader title={t('billing.runs.detail.title', 'Bill Run')} />\n <PageBody>\n <ErrorMessage label={runError} />\n </PageBody>\n </Page>\n )\n }\n\n if (!run) {\n return (\n <Page>\n <PageHeader title={t('billing.runs.detail.title', 'Bill Run')} />\n <PageBody>\n <LoadingMessage label={t('billing.runs.detail.loading', 'Loading run\u2026')} />\n </PageBody>\n </Page>\n )\n }\n\n return (\n <Page>\n <FormHeader\n mode=\"detail\"\n backHref=\"/backend/billing/runs\"\n entityTypeLabel={t('billing.runs.detail.title', 'Bill Run')}\n title={billRunName(run.as_of_date)}\n statusBadge={\n <Tag variant={runStatusVariant(run.status)}>{run.status}</Tag>\n }\n actionsContent={\n failedCount > 0 ? (\n <Button disabled={retrying} onClick={handleRetryFailed}>\n {retrying\n ? t('billing.runs.retry.in_progress', 'Retrying\u2026')\n : t('billing.runs.retry.action', 'Retry failed accounts')}\n {` (${failedCount})`}\n </Button>\n ) : null\n }\n />\n <PageBody>\n <div className=\"space-y-6\">\n <DetailCard>\n <DetailField label={t('billing.runs.detail.field.run_id', 'Run ID')}>\n <span className=\"font-mono text-xs\">{run.id}</span>\n </DetailField>\n <DetailField label={t('billing.runs.detail.field.triggered_by', 'Trigger')}>\n {run.triggered_by}\n </DetailField>\n <DetailField label={t('billing.runs.detail.field.mode', 'Mode')}>\n <div className=\"flex flex-wrap gap-1\">\n {run.dry_run ? (\n <Tag variant=\"warning\">{t('billing.runs.mode.dry_run', 'Dry-run')}</Tag>\n ) : run.test_mode ? (\n <Tag variant=\"warning\">{t('billing.runs.mode.test', 'Test')}</Tag>\n ) : (\n <Tag variant=\"default\">{t('billing.runs.mode.real', 'Real')}</Tag>\n )}\n {run.catch_up ? (\n <Tag variant=\"default\">{t('billing.runs.mode.catch_up', 'Catch-up')}</Tag>\n ) : null}\n </div>\n </DetailField>\n <DetailField label={t('billing.runs.detail.field.as_of_date', 'As-of date')}>\n {run.as_of_date?.slice(0, 10) ?? '\u2014'}\n </DetailField>\n <DetailField label={t('billing.runs.detail.field.started_at', 'Started')}>\n {formatDate(run.started_at)}\n </DetailField>\n <DetailField label={t('billing.runs.detail.field.finished_at', 'Finished')}>\n {formatDate(run.finished_at)}\n </DetailField>\n {run.parent_run_id ? (\n <DetailField label={t('billing.runs.detail.field.parent_run', 'Parent run')}>\n <span className=\"font-mono text-xs\">{run.parent_run_id}</span>\n </DetailField>\n ) : null}\n </DetailCard>\n\n {run.summary ? (\n <StatCard title={t('billing.runs.summary.title', 'Summary')}>\n <Stat\n label={t('billing.runs.summary.accounts', 'Accounts')}\n value={run.summary.accounts_processed ?? 0}\n />\n <Stat\n label={t('billing.runs.summary.drafts', 'Drafts')}\n value={run.summary.drafts_created ?? 0}\n />\n <Stat\n label={t('billing.runs.summary.skipped', 'Skipped')}\n value={run.summary.drafts_skipped_existing ?? 0}\n />\n <Stat\n label={t('billing.runs.summary.warnings', 'Warnings')}\n value={run.summary.accounts_with_warnings ?? 0}\n />\n <Stat\n label={t('billing.runs.summary.failed', 'Failed')}\n value={run.summary.accounts_failed ?? 0}\n />\n <Stat\n label={t('billing.runs.summary.usage', 'Usage rated')}\n value={run.summary.usage_records_rated ?? 0}\n />\n </StatCard>\n ) : null}\n\n <div>\n <h2 className=\"text-base font-semibold mb-2\">\n {t('billing.runs.outcomes.title', 'Per-account outcomes')}\n </h2>\n <DataTable\n columns={outcomeColumns}\n data={outcomes}\n isLoading={outcomesLoading}\n pagination={{\n page: outcomesPage,\n pageSize: 50,\n total: outcomesTotal,\n totalPages: outcomesTotalPages,\n onPageChange: setOutcomesPage,\n }}\n />\n </div>\n </div>\n </PageBody>\n </Page>\n )\n}\n"],
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["\"use client\"\nimport * as React from 'react'\nimport Link from 'next/link'\nimport { useParams, useRouter } from 'next/navigation'\nimport type { LegacyColumnDef as ColumnDef } from '@tanstack/react-table/legacy'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport { Page, PageBody, PageHeader } from '@open-mercato/ui/backend/Page'\nimport { FormHeader } from '@open-mercato/ui/backend/forms'\nimport { BillingDataTable as DataTable } from '../../../../components/BillingDataTable'\nimport { Tag } from '@open-mercato/ui/primitives/tag'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { LoadingMessage, ErrorMessage } from '@open-mercato/ui/backend/detail'\nimport { flash } from '@open-mercato/ui/backend/FlashMessages'\nimport {\n apiCallOrThrow,\n readApiResultOrThrow,\n} from '@open-mercato/ui/backend/utils/apiCall'\nimport { normalizeCrudServerError } from '@open-mercato/ui/backend/utils/serverErrors'\nimport { billRunName } from '../../../../lib/billRunLabel'\nimport { RunCyclesSection, type RunCycle } from '../../../../components/RunCyclesSection'\nimport { TestRunActions, billRunMode } from '../../../../components/TestRunActions'\nimport { PostRunDraftsButton } from '../../../../components/PostRunDraftsButton'\nimport {\n DetailCard,\n DetailField,\n Stat,\n StatCard,\n} from '../../../../components/DetailFields'\n\n/**\n * Bill Run detail \u2014 header card + outcomes list.\n *\n * The \"Retry failed accounts\" button is enabled only when the run\n * has at least one failed outcome. It POSTs the\n * `billing.runs.retry_failed` endpoint, which creates a new run\n * scoped to those accounts (the new run shows up in the list at\n * `/backend/billing/runs`).\n */\n\n// API list rows are snake_case (see `api/runs/route.ts` +\n// `api/run-outcomes/route.ts` `fields`).\ntype BillRun = {\n id: string\n triggered_by: 'schedule' | 'manual'\n parent_run_id: string | null\n dry_run: boolean\n test_mode: boolean\n as_of_date: string\n started_at: string | null\n finished_at: string | null\n status: 'running' | 'completed' | 'partial_failure' | 'failed'\n summary: {\n accounts_processed?: number\n drafts_created?: number\n cycles_processed?: number\n drafts_skipped_existing?: number\n accounts_failed?: number\n accounts_with_warnings?: number\n usage_records_rated?: number\n } | null\n organization_id: string\n tenant_id: string\n created_at: string\n updated_at: string\n}\n\ntype BillRunOutcome = {\n id: string\n bill_run_id: string\n bill_account_id: string\n bill_account_name: string | null\n status: 'success' | 'success_with_warnings' | 'skipped_existing_draft' | 'failed'\n error_message: string | null\n warnings: Record<string, unknown> | null\n draft_invoice_id: string | null\n invoice_number: string | null\n cycles: RunCycle[] | null\n created_at: string\n}\n\ntype ListResponse<T> = {\n items: T[]\n total: number\n totalPages: number\n}\n\nfunction formatDate(value: string | null | undefined): string {\n if (!value) return '\u2014'\n const parsed = new Date(value)\n return Number.isNaN(parsed.getTime()) ? value : parsed.toLocaleString()\n}\n\nfunction runStatusVariant(\n status: BillRun['status'],\n): 'default' | 'success' | 'warning' | 'error' {\n switch (status) {\n case 'completed':\n return 'success'\n case 'partial_failure':\n return 'warning'\n case 'failed':\n return 'error'\n default:\n return 'default'\n }\n}\n\nfunction outcomeStatusVariant(\n status: BillRunOutcome['status'],\n): 'default' | 'success' | 'warning' | 'error' {\n switch (status) {\n case 'success':\n return 'success'\n case 'success_with_warnings':\n return 'warning'\n case 'failed':\n return 'error'\n case 'skipped_existing_draft':\n default:\n return 'default'\n }\n}\n\nexport default function BillRunDetailPage(props: { params?: { id?: string } }) {\n const t = useT()\n // OM serves backend pages through a catch-all route \u2014 the dynamic\n // `[id]` segment arrives as a page prop; `useParams()` is the fallback.\n const urlParams = useParams<{ id: string }>()\n const runId = (props.params?.id ?? urlParams?.id ?? '') as string\n\n const [run, setRun] = React.useState<BillRun | null>(null)\n const [runError, setRunError] = React.useState<string | null>(null)\n const [outcomes, setOutcomes] = React.useState<BillRunOutcome[]>([])\n const [outcomesPage, setOutcomesPage] = React.useState(1)\n const [outcomesTotal, setOutcomesTotal] = React.useState(0)\n const [outcomesTotalPages, setOutcomesTotalPages] = React.useState(1)\n const [outcomesLoading, setOutcomesLoading] = React.useState(true)\n const [retrying, setRetrying] = React.useState(false)\n\n const loadRun = React.useCallback(async () => {\n if (!runId) return\n setRunError(null)\n try {\n const result = await readApiResultOrThrow<ListResponse<BillRun>>(\n `/api/billing/runs?id=${runId}&pageSize=1`,\n )\n const found = result.items?.[0]\n if (!found) {\n setRunError(t('billing.runs.detail.error.not_found', 'Run not found'))\n setRun(null)\n return\n }\n setRun(found)\n } catch (err) {\n const { message } = normalizeCrudServerError(err)\n setRunError(message || t('billing.runs.detail.error.load', 'Failed to load run'))\n }\n }, [runId, t])\n\n const loadOutcomes = React.useCallback(async () => {\n if (!runId) return\n setOutcomesLoading(true)\n try {\n const params = new URLSearchParams({\n billRunId: runId,\n page: String(outcomesPage),\n pageSize: '50',\n })\n const result = await readApiResultOrThrow<ListResponse<BillRunOutcome>>(\n `/api/billing/run-outcomes?${params.toString()}`,\n )\n setOutcomes(result.items ?? [])\n setOutcomesTotal(result.total ?? 0)\n setOutcomesTotalPages(result.totalPages ?? 1)\n } finally {\n setOutcomesLoading(false)\n }\n }, [outcomesPage, runId])\n\n React.useEffect(() => {\n void loadRun()\n }, [loadRun])\n React.useEffect(() => {\n void loadOutcomes()\n }, [loadOutcomes])\n\n const router = useRouter()\n const failedCount = run?.summary?.accounts_failed ?? 0\n\n const handleRetryFailed = React.useCallback(async () => {\n if (!run || failedCount === 0) return\n setRetrying(true)\n try {\n const call = await apiCallOrThrow<{ billRunId: string; outcomesCount: number }>(\n '/api/billing/runs/retry-failed',\n {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ billRunId: run.id }),\n },\n )\n const outcomesCount = call.result?.outcomesCount ?? 0\n flash(\n t('billing.runs.retry.success', 'Retry run created') +\n ` (${outcomesCount} accounts)`,\n 'success',\n )\n // Refresh \u2014 the new run shows up in the list view; the current\n // run's outcomes are immutable so no reload of `loadOutcomes`\n // needed, but loadRun is cheap.\n void loadRun()\n } catch (err) {\n const { message } = normalizeCrudServerError(err)\n flash(message || t('billing.runs.retry.error', 'Retry failed'), 'error')\n } finally {\n setRetrying(false)\n }\n }, [failedCount, loadRun, run, t])\n\n const outcomeColumns = React.useMemo<ColumnDef<BillRunOutcome>[]>(\n () => [\n {\n accessorKey: 'bill_account_id',\n header: t('billing.runs.outcomes.columns.account', 'Account'),\n cell: ({ row }) => (\n <Link\n href={`/backend/billing/accounts/${row.original.bill_account_id}`}\n className=\"text-sm text-primary hover:underline\"\n >\n {row.original.bill_account_name ?? row.original.bill_account_id}\n </Link>\n ),\n },\n {\n accessorKey: 'status',\n header: t('billing.runs.outcomes.columns.status', 'Status'),\n cell: ({ row }) => (\n <Tag variant={outcomeStatusVariant(row.original.status)}>\n {row.original.status}\n </Tag>\n ),\n },\n {\n accessorKey: 'draft_invoice_id',\n header: t('billing.runs.outcomes.columns.invoice', 'Invoice'),\n cell: ({ row }) =>\n row.original.draft_invoice_id ? (\n <Link\n href={`/backend/billing/invoices/${row.original.draft_invoice_id}`}\n className=\"text-sm text-primary hover:underline\"\n >\n {row.original.invoice_number ?? row.original.draft_invoice_id}\n </Link>\n ) : (\n '\u2014'\n ),\n },\n {\n accessorKey: 'error_message',\n header: t('billing.runs.outcomes.columns.error', 'Error'),\n cell: ({ row }) => row.original.error_message ?? '\u2014',\n },\n {\n accessorKey: 'warnings',\n header: t('billing.runs.outcomes.columns.warnings', 'Warnings'),\n cell: ({ row }) => {\n // Skipped items get their own table below; show the rest inline.\n const { skipped_items: _skipped, ...rest } = row.original.warnings ?? {}\n if (Object.keys(rest).length === 0) return '\u2014'\n return <span className=\"font-mono text-xs\">{JSON.stringify(rest)}</span>\n },\n },\n ],\n [t],\n )\n\n if (runError) {\n return (\n <Page>\n <PageHeader title={t('billing.runs.detail.title', 'Bill Run')} />\n <PageBody>\n <ErrorMessage label={runError} />\n </PageBody>\n </Page>\n )\n }\n\n if (!run) {\n return (\n <Page>\n <PageHeader title={t('billing.runs.detail.title', 'Bill Run')} />\n <PageBody>\n <LoadingMessage label={t('billing.runs.detail.loading', 'Loading run\u2026')} />\n </PageBody>\n </Page>\n )\n }\n\n return (\n <Page>\n <FormHeader\n mode=\"detail\"\n backHref=\"/backend/billing/runs\"\n entityTypeLabel={t('billing.runs.detail.title', 'Bill Run')}\n title={billRunName(run.as_of_date)}\n statusBadge={\n <Tag variant={runStatusVariant(run.status)}>{run.status}</Tag>\n }\n actionsContent={\n <>\n {failedCount > 0 ? (\n <Button disabled={retrying} onClick={handleRetryFailed}>\n {retrying\n ? t('billing.runs.retry.in_progress', 'Retrying\u2026')\n : t('billing.runs.retry.action', 'Retry failed accounts')}\n {` (${failedCount})`}\n </Button>\n ) : null}\n {run.status !== 'running' && billRunMode(run) === 'real' ? (\n <PostRunDraftsButton\n runId={run.id}\n onPosted={() => {\n void loadRun()\n void loadOutcomes()\n }}\n />\n ) : null}\n {run.status !== 'running' ? (\n <TestRunActions\n runId={run.id}\n mode={billRunMode(run)}\n draftsCount={run.summary?.drafts_created}\n onWiped={() => {\n void loadRun()\n void loadOutcomes()\n }}\n onDeleted={() => router.push('/backend/billing/runs')}\n />\n ) : null}\n </>\n }\n />\n <PageBody>\n <div className=\"space-y-6\">\n <DetailCard>\n <DetailField label={t('billing.runs.detail.field.run_id', 'Run ID')}>\n <span className=\"font-mono text-xs\">{run.id}</span>\n </DetailField>\n <DetailField label={t('billing.runs.detail.field.triggered_by', 'Trigger')}>\n {run.triggered_by}\n </DetailField>\n <DetailField label={t('billing.runs.detail.field.mode', 'Mode')}>\n <div className=\"flex flex-wrap gap-1\">\n {run.dry_run ? (\n <Tag variant=\"warning\">{t('billing.runs.mode.dry_run', 'Dry-run')}</Tag>\n ) : run.test_mode ? (\n <Tag variant=\"warning\">{t('billing.runs.mode.test', 'Test')}</Tag>\n ) : (\n <Tag variant=\"default\">{t('billing.runs.mode.real', 'Real')}</Tag>\n )}\n </div>\n </DetailField>\n <DetailField label={t('billing.runs.detail.field.as_of_date', 'As-of date')}>\n {run.as_of_date?.slice(0, 10) ?? '\u2014'}\n </DetailField>\n <DetailField label={t('billing.runs.detail.field.started_at', 'Started')}>\n {formatDate(run.started_at)}\n </DetailField>\n <DetailField label={t('billing.runs.detail.field.finished_at', 'Finished')}>\n {formatDate(run.finished_at)}\n </DetailField>\n {run.parent_run_id ? (\n <DetailField label={t('billing.runs.detail.field.parent_run', 'Parent run')}>\n <span className=\"font-mono text-xs\">{run.parent_run_id}</span>\n </DetailField>\n ) : null}\n </DetailCard>\n\n {run.summary ? (\n <StatCard title={t('billing.runs.summary.title', 'Summary')}>\n <Stat\n label={t('billing.runs.summary.accounts', 'Accounts')}\n value={run.summary.accounts_processed ?? 0}\n />\n <Stat\n label={t('billing.runs.summary.drafts', 'Drafts')}\n value={run.summary.drafts_created ?? 0}\n />\n <Stat\n label={t('billing.runs.summary.cycles', 'Cycles')}\n value={run.summary.cycles_processed ?? 0}\n />\n <Stat\n label={t('billing.runs.summary.skipped', 'Skipped')}\n value={run.summary.drafts_skipped_existing ?? 0}\n />\n <Stat\n label={t('billing.runs.summary.warnings', 'Warnings')}\n value={run.summary.accounts_with_warnings ?? 0}\n />\n <Stat\n label={t('billing.runs.summary.failed', 'Failed')}\n value={run.summary.accounts_failed ?? 0}\n />\n <Stat\n label={t('billing.runs.summary.usage', 'Usage rated')}\n value={run.summary.usage_records_rated ?? 0}\n />\n </StatCard>\n ) : null}\n\n <div>\n <h2 className=\"text-base font-semibold mb-2\">\n {t('billing.runs.outcomes.title', 'Per-account outcomes')}\n </h2>\n <DataTable\n columns={outcomeColumns}\n data={outcomes}\n isLoading={outcomesLoading}\n pagination={{\n page: outcomesPage,\n pageSize: 50,\n total: outcomesTotal,\n totalPages: outcomesTotalPages,\n onPageChange: setOutcomesPage,\n }}\n />\n </div>\n\n <RunCyclesSection outcomes={outcomes} />\n </div>\n </PageBody>\n </Page>\n )\n}\n"],
|
|
5
|
+
"mappings": ";AAiOU,SAoFA,UApFA,KAqDJ,YArDI;AAhOV,YAAY,WAAW;AACvB,OAAO,UAAU;A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