@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
|
@@ -2,14 +2,14 @@
|
|
|
2
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 { Pencil, Plus } from "lucide-react";
|
|
6
|
-
import { useParams, useRouter } from "next/navigation";
|
|
5
|
+
import { Pencil, Play, Plus } from "lucide-react";
|
|
6
|
+
import { useParams, useRouter, useSearchParams } from "next/navigation";
|
|
7
7
|
import { useT } from "@open-mercato/shared/lib/i18n/context";
|
|
8
8
|
import { Page, PageBody, PageHeader } from "@open-mercato/ui/backend/Page";
|
|
9
9
|
import { FormHeader } from "@open-mercato/ui/backend/forms";
|
|
10
|
-
import { DataTable } from "@open-mercato/ui/backend/DataTable";
|
|
11
10
|
import { Tag } from "@open-mercato/ui/primitives/tag";
|
|
12
11
|
import { Button } from "@open-mercato/ui/primitives/button";
|
|
12
|
+
import { Tabs, TabsList, TabsTrigger } from "@open-mercato/ui/primitives/tabs";
|
|
13
13
|
import { LoadingMessage, ErrorMessage } from "@open-mercato/ui/backend/detail";
|
|
14
14
|
import { flash } from "@open-mercato/ui/backend/FlashMessages";
|
|
15
15
|
import { useConfirmDialog } from "@open-mercato/ui/backend/confirm-dialog";
|
|
@@ -19,217 +19,18 @@ import {
|
|
|
19
19
|
} from "@open-mercato/ui/backend/utils/apiCall";
|
|
20
20
|
import { normalizeCrudServerError } from "@open-mercato/ui/backend/utils/serverErrors";
|
|
21
21
|
import { AccountForm } from "../../../../components/AccountForm.js";
|
|
22
|
-
import { DetailCard, DetailField } from "../../../../components/DetailFields.js";
|
|
23
22
|
import { PrepaidPanel } from "../../../../components/PrepaidPanel.js";
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
billCycleAnchor: row.bill_cycle_anchor,
|
|
36
|
-
invoiceEmail: row.invoice_email,
|
|
37
|
-
invoiceLanguage: row.invoice_language,
|
|
38
|
-
taxId: row.tax_id ?? "",
|
|
39
|
-
invoiceAddress: {
|
|
40
|
-
line1: row.invoice_address?.line1 ?? "",
|
|
41
|
-
line2: row.invoice_address?.line2 ?? "",
|
|
42
|
-
city: row.invoice_address?.city ?? "",
|
|
43
|
-
postal_code: row.invoice_address?.postal_code ?? "",
|
|
44
|
-
country: row.invoice_address?.country ?? ""
|
|
45
|
-
},
|
|
46
|
-
nextBillDate: row.next_bill_date?.slice(0, 10) ?? "",
|
|
47
|
-
isActive: row.is_active,
|
|
48
|
-
billingMode: row.billing_mode,
|
|
49
|
-
creditLimit: row.credit_limit ?? "0",
|
|
50
|
-
// The threshold lives on the balance row, not the account row — blank
|
|
51
|
-
// means "leave unchanged" on save.
|
|
52
|
-
lowBalanceThreshold: ""
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
function AccountView({ row }) {
|
|
56
|
-
const t = useT();
|
|
57
|
-
const addr = row.invoice_address;
|
|
58
|
-
const addressText = addr ? [
|
|
59
|
-
addr.line1,
|
|
60
|
-
addr.line2,
|
|
61
|
-
[addr.postal_code, addr.city].filter(Boolean).join(" "),
|
|
62
|
-
addr.country
|
|
63
|
-
].map((part) => (part ?? "").trim()).filter(Boolean).join(", ") : "";
|
|
64
|
-
return /* @__PURE__ */ jsxs(DetailCard, { children: [
|
|
65
|
-
/* @__PURE__ */ jsx(DetailField, { label: t("billing.accounts.form.customer_id", "Customer ID"), children: /* @__PURE__ */ jsx("span", { className: "font-mono text-xs", children: row.customer_id }) }),
|
|
66
|
-
/* @__PURE__ */ jsx(DetailField, { label: t("billing.accounts.columns.currency", "Currency"), children: row.currency_code }),
|
|
67
|
-
/* @__PURE__ */ jsx(DetailField, { label: t("billing.accounts.columns.mode", "Mode"), children: row.billing_mode === "prepaid" ? /* @__PURE__ */ jsx(Tag, { variant: "brand", children: t("billing.mode.prepaid", "Prepaid") }) : /* @__PURE__ */ jsx(Tag, { variant: "neutral", children: t("billing.mode.postpaid", "Postpaid") }) }),
|
|
68
|
-
/* @__PURE__ */ jsx(DetailField, { label: t("billing.accounts.columns.credit_limit", "Credit limit"), children: /* @__PURE__ */ jsx("span", { className: "font-mono tabular-nums", children: row.credit_limit }) }),
|
|
69
|
-
/* @__PURE__ */ jsx(DetailField, { label: t("billing.common.id", "ID"), children: /* @__PURE__ */ jsx("span", { className: "font-mono text-xs", children: row.id }) }),
|
|
70
|
-
/* @__PURE__ */ jsxs(DetailField, { label: t("billing.accounts.columns.cycle", "Cycle"), children: [
|
|
71
|
-
row.bill_cycle,
|
|
72
|
-
/* @__PURE__ */ jsxs("span", { className: "text-muted-foreground", children: [
|
|
73
|
-
" \xB7 ",
|
|
74
|
-
row.bill_cycle_anchor
|
|
75
|
-
] })
|
|
76
|
-
] }),
|
|
77
|
-
/* @__PURE__ */ jsx(DetailField, { label: t("billing.accounts.columns.next_bill", "Next bill"), children: formatDate(row.next_bill_date) }),
|
|
78
|
-
/* @__PURE__ */ jsx(DetailField, { label: t("billing.accounts.columns.last_bill", "Last bill"), children: formatDate(row.last_bill_date) }),
|
|
79
|
-
/* @__PURE__ */ jsx(DetailField, { label: t("billing.accounts.form.invoice_email", "Invoice email"), children: row.invoice_email }),
|
|
80
|
-
/* @__PURE__ */ jsx(DetailField, { label: t("billing.accounts.form.invoice_language", "Invoice language"), children: row.invoice_language }),
|
|
81
|
-
/* @__PURE__ */ jsx(DetailField, { label: t("billing.accounts.form.tax_id", "Tax ID"), children: row.tax_id || "\u2014" }),
|
|
82
|
-
/* @__PURE__ */ jsx(
|
|
83
|
-
DetailField,
|
|
84
|
-
{
|
|
85
|
-
label: t("billing.accounts.form.address.title", "Invoice address"),
|
|
86
|
-
fullWidth: true,
|
|
87
|
-
children: addressText || "\u2014"
|
|
88
|
-
}
|
|
89
|
-
)
|
|
90
|
-
] });
|
|
91
|
-
}
|
|
92
|
-
function AccountItemsSection({ accountId }) {
|
|
93
|
-
const t = useT();
|
|
94
|
-
const router = useRouter();
|
|
95
|
-
const [rows, setRows] = React.useState([]);
|
|
96
|
-
const [page, setPage] = React.useState(1);
|
|
97
|
-
const [total, setTotal] = React.useState(0);
|
|
98
|
-
const [totalPages, setTotalPages] = React.useState(1);
|
|
99
|
-
const [loading, setLoading] = React.useState(true);
|
|
100
|
-
const pageSize = 25;
|
|
101
|
-
const load = React.useCallback(async () => {
|
|
102
|
-
setLoading(true);
|
|
103
|
-
try {
|
|
104
|
-
const result = await readApiResultOrThrow(
|
|
105
|
-
`/api/billing/items?billAccountId=${accountId}&page=${page}&pageSize=${pageSize}&sortField=createdAt&sortDir=desc`
|
|
106
|
-
);
|
|
107
|
-
setRows(result.items ?? []);
|
|
108
|
-
setTotal(result.total ?? 0);
|
|
109
|
-
setTotalPages(result.totalPages ?? 1);
|
|
110
|
-
} finally {
|
|
111
|
-
setLoading(false);
|
|
112
|
-
}
|
|
113
|
-
}, [accountId, page]);
|
|
114
|
-
React.useEffect(() => {
|
|
115
|
-
void load();
|
|
116
|
-
}, [load]);
|
|
117
|
-
const columns = React.useMemo(
|
|
118
|
-
() => [
|
|
119
|
-
{
|
|
120
|
-
accessorKey: "description",
|
|
121
|
-
header: t("billing.items.columns.description", "Description"),
|
|
122
|
-
cell: ({ row }) => /* @__PURE__ */ jsx("span", { className: "text-sm font-medium text-primary", children: row.original.description })
|
|
123
|
-
},
|
|
124
|
-
{
|
|
125
|
-
accessorKey: "type",
|
|
126
|
-
header: t("billing.items.columns.type", "Type"),
|
|
127
|
-
cell: ({ row }) => /* @__PURE__ */ jsx(Tag, { variant: "info", children: row.original.type })
|
|
128
|
-
},
|
|
129
|
-
{
|
|
130
|
-
accessorKey: "bill_start_date",
|
|
131
|
-
header: t("billing.items.columns.start", "Start"),
|
|
132
|
-
cell: ({ row }) => formatDate(row.original.bill_start_date)
|
|
133
|
-
},
|
|
134
|
-
{
|
|
135
|
-
accessorKey: "is_active",
|
|
136
|
-
header: t("billing.items.columns.status", "Status"),
|
|
137
|
-
cell: ({ row }) => row.original.is_active ? /* @__PURE__ */ jsx(Tag, { variant: "success", children: t("billing.common.active", "Active") }) : /* @__PURE__ */ jsx(Tag, { variant: "default", children: t("billing.common.inactive", "Inactive") })
|
|
138
|
-
}
|
|
139
|
-
],
|
|
140
|
-
[t]
|
|
141
|
-
);
|
|
142
|
-
return /* @__PURE__ */ jsx("div", { className: "mt-6", children: /* @__PURE__ */ jsx(
|
|
143
|
-
DataTable,
|
|
144
|
-
{
|
|
145
|
-
title: t("billing.accounts.detail.items.title", "Items"),
|
|
146
|
-
columns,
|
|
147
|
-
data: rows,
|
|
148
|
-
isLoading: loading,
|
|
149
|
-
onRowClick: (row) => router.push(`/backend/billing/items/${row.id}`),
|
|
150
|
-
pagination: { page, pageSize, total, totalPages, onPageChange: setPage },
|
|
151
|
-
emptyState: /* @__PURE__ */ jsx("div", { className: "rounded-lg border bg-card p-6 text-center text-sm text-muted-foreground", children: t("billing.accounts.detail.items.empty", "No items for this account yet.") })
|
|
152
|
-
}
|
|
153
|
-
) });
|
|
154
|
-
}
|
|
155
|
-
function AccountUsageSection({ accountId }) {
|
|
156
|
-
const t = useT();
|
|
157
|
-
const [rows, setRows] = React.useState([]);
|
|
158
|
-
const [page, setPage] = React.useState(1);
|
|
159
|
-
const [total, setTotal] = React.useState(0);
|
|
160
|
-
const [totalPages, setTotalPages] = React.useState(1);
|
|
161
|
-
const [loading, setLoading] = React.useState(true);
|
|
162
|
-
const pageSize = 25;
|
|
163
|
-
const load = React.useCallback(async () => {
|
|
164
|
-
setLoading(true);
|
|
165
|
-
try {
|
|
166
|
-
const result = await readApiResultOrThrow(
|
|
167
|
-
`/api/billing/usage?billAccountId=${accountId}&page=${page}&pageSize=${pageSize}&sortField=periodStart&sortDir=desc`
|
|
168
|
-
);
|
|
169
|
-
setRows(result.items ?? []);
|
|
170
|
-
setTotal(result.total ?? 0);
|
|
171
|
-
setTotalPages(result.totalPages ?? 1);
|
|
172
|
-
} finally {
|
|
173
|
-
setLoading(false);
|
|
174
|
-
}
|
|
175
|
-
}, [accountId, page]);
|
|
176
|
-
React.useEffect(() => {
|
|
177
|
-
void load();
|
|
178
|
-
}, [load]);
|
|
179
|
-
const columns = React.useMemo(
|
|
180
|
-
() => [
|
|
181
|
-
{
|
|
182
|
-
accessorKey: "uom_code",
|
|
183
|
-
header: t("billing.usage.columns.uom", "Unit"),
|
|
184
|
-
cell: ({ row }) => /* @__PURE__ */ jsx("span", { className: "font-mono text-xs", children: row.original.uom_code })
|
|
185
|
-
},
|
|
186
|
-
{
|
|
187
|
-
accessorKey: "quantity",
|
|
188
|
-
header: t("billing.usage.columns.quantity", "Quantity"),
|
|
189
|
-
cell: ({ row }) => /* @__PURE__ */ jsx("span", { className: "font-mono tabular-nums", children: row.original.quantity })
|
|
190
|
-
},
|
|
191
|
-
{
|
|
192
|
-
accessorKey: "period_start",
|
|
193
|
-
header: t("billing.usage.columns.period", "Period"),
|
|
194
|
-
cell: ({ row }) => `${formatDate(row.original.period_start)} \u2013 ${formatDate(row.original.period_end)}`
|
|
195
|
-
},
|
|
196
|
-
{
|
|
197
|
-
accessorKey: "line_description",
|
|
198
|
-
header: t("billing.usage.columns.description", "Description"),
|
|
199
|
-
cell: ({ row }) => row.original.line_description || "\u2014"
|
|
200
|
-
},
|
|
201
|
-
{
|
|
202
|
-
accessorKey: "rated_in_bill_run_id",
|
|
203
|
-
header: t("billing.usage.columns.rated", "Rated"),
|
|
204
|
-
cell: ({ row }) => row.original.rated_in_bill_run_id ? (
|
|
205
|
-
// Rated records carry the Bill Run that priced them — link to it.
|
|
206
|
-
// Unrated records have no destination, so they stay non-interactive
|
|
207
|
-
// (no misleading row-level click affordance).
|
|
208
|
-
/* @__PURE__ */ jsx(
|
|
209
|
-
Link,
|
|
210
|
-
{
|
|
211
|
-
href: `/backend/billing/runs/${row.original.rated_in_bill_run_id}`,
|
|
212
|
-
className: "rounded-sm hover:underline",
|
|
213
|
-
children: /* @__PURE__ */ jsx(Tag, { variant: "success", children: t("billing.usage.rated.yes", "Rated") })
|
|
214
|
-
}
|
|
215
|
-
)
|
|
216
|
-
) : /* @__PURE__ */ jsx(Tag, { variant: "default", children: t("billing.usage.rated.no", "Unrated") })
|
|
217
|
-
}
|
|
218
|
-
],
|
|
219
|
-
[t]
|
|
220
|
-
);
|
|
221
|
-
return /* @__PURE__ */ jsx("div", { className: "mt-6", children: /* @__PURE__ */ jsx(
|
|
222
|
-
DataTable,
|
|
223
|
-
{
|
|
224
|
-
title: t("billing.accounts.detail.usage.title", "Usage"),
|
|
225
|
-
columns,
|
|
226
|
-
data: rows,
|
|
227
|
-
isLoading: loading,
|
|
228
|
-
pagination: { page, pageSize, total, totalPages, onPageChange: setPage },
|
|
229
|
-
emptyState: /* @__PURE__ */ jsx("div", { className: "rounded-lg border bg-card p-6 text-center text-sm text-muted-foreground", children: t("billing.accounts.detail.usage.empty", "No usage records for this account yet.") })
|
|
230
|
-
}
|
|
231
|
-
) });
|
|
232
|
-
}
|
|
23
|
+
import { AccountInvoicesSection } from "../../../../components/AccountInvoicesSection.js";
|
|
24
|
+
import { AccountPaymentsSection } from "../../../../components/AccountPaymentsSection.js";
|
|
25
|
+
import { AccountView } from "../../../../components/account/AccountView.js";
|
|
26
|
+
import { AccountItemsTab } from "../../../../components/account/AccountItemsTab.js";
|
|
27
|
+
import { AccountUsageTab } from "../../../../components/account/AccountUsageTab.js";
|
|
28
|
+
import { AccountRunsTab } from "../../../../components/account/AccountRunsTab.js";
|
|
29
|
+
import { AccountStatementsTab } from "../../../../components/account/AccountStatementsTab.js";
|
|
30
|
+
import { AccountSummaryCards } from "../../../../components/account/AccountSummaryCards.js";
|
|
31
|
+
import { AccountRunBillingDialog } from "../../../../components/account/AccountRunBillingDialog.js";
|
|
32
|
+
import { toFormValues } from "../../../../components/account/accountRow.js";
|
|
33
|
+
import { accountHref, isAccountTab } from "../../../../lib/navigation.js";
|
|
233
34
|
function BillingAccountDetailPage(props) {
|
|
234
35
|
const t = useT();
|
|
235
36
|
const router = useRouter();
|
|
@@ -241,10 +42,27 @@ function BillingAccountDetailPage(props) {
|
|
|
241
42
|
const [editing, setEditing] = React.useState(false);
|
|
242
43
|
const [saving, setSaving] = React.useState(false);
|
|
243
44
|
const [deleting, setDeleting] = React.useState(false);
|
|
45
|
+
const [runDialogOpen, setRunDialogOpen] = React.useState(false);
|
|
46
|
+
const [refreshKey, setRefreshKey] = React.useState(0);
|
|
47
|
+
const refresh = React.useCallback(() => setRefreshKey((key) => key + 1), []);
|
|
48
|
+
const searchParams = useSearchParams();
|
|
49
|
+
const requestedTab = searchParams?.get("tab");
|
|
50
|
+
const activeTab = isAccountTab(requestedTab) ? requestedTab : "overview";
|
|
51
|
+
const [visitedTabs, setVisitedTabs] = React.useState(() => /* @__PURE__ */ new Set([activeTab]));
|
|
52
|
+
React.useEffect(() => {
|
|
53
|
+
setVisitedTabs((prev) => prev.has(activeTab) ? prev : new Set(prev).add(activeTab));
|
|
54
|
+
}, [activeTab]);
|
|
55
|
+
const selectTab = React.useCallback(
|
|
56
|
+
(next) => {
|
|
57
|
+
if (!isAccountTab(next) || !accountId) return;
|
|
58
|
+
router.replace(accountHref(accountId, next), { scroll: false });
|
|
59
|
+
},
|
|
60
|
+
[accountId, router]
|
|
61
|
+
);
|
|
244
62
|
const { confirm, ConfirmDialogElement } = useConfirmDialog();
|
|
245
|
-
const load = React.useCallback(async () => {
|
|
63
|
+
const load = React.useCallback(async (options = {}) => {
|
|
246
64
|
if (!accountId) return;
|
|
247
|
-
setLoading(true);
|
|
65
|
+
if (!options.silent) setLoading(true);
|
|
248
66
|
setError(null);
|
|
249
67
|
try {
|
|
250
68
|
const result = await readApiResultOrThrow(
|
|
@@ -291,6 +109,9 @@ function BillingAccountDetailPage(props) {
|
|
|
291
109
|
payload.taxId = values.taxId.trim() === "" ? null : values.taxId.trim();
|
|
292
110
|
const creditLimit = Number.parseFloat(values.creditLimit);
|
|
293
111
|
if (Number.isFinite(creditLimit) && creditLimit >= 0) payload.creditLimit = creditLimit;
|
|
112
|
+
const termsDays = Number.parseInt(values.paymentTermsDays, 10);
|
|
113
|
+
payload.paymentTermsDays = values.paymentTermsDays.trim() && Number.isInteger(termsDays) && termsDays >= 0 ? termsDays : null;
|
|
114
|
+
payload.autoSendInvoice = values.autoSendInvoice;
|
|
294
115
|
if (row.billing_mode === "prepaid" && values.lowBalanceThreshold.trim()) {
|
|
295
116
|
const threshold = Number.parseFloat(values.lowBalanceThreshold);
|
|
296
117
|
if (Number.isFinite(threshold) && threshold >= 0) payload.lowBalanceThreshold = threshold;
|
|
@@ -302,7 +123,7 @@ function BillingAccountDetailPage(props) {
|
|
|
302
123
|
});
|
|
303
124
|
flash(t("billing.accounts.detail.save.success", "Account updated"), "success");
|
|
304
125
|
setEditing(false);
|
|
305
|
-
void load();
|
|
126
|
+
void load({ silent: true });
|
|
306
127
|
} catch (err) {
|
|
307
128
|
const { message, fieldErrors } = normalizeCrudServerError(err);
|
|
308
129
|
const fieldDetail = fieldErrors && Object.keys(fieldErrors).length ? Object.entries(fieldErrors).map(([field, msg]) => `${field}: ${msg}`).join("; ") : null;
|
|
@@ -341,6 +162,49 @@ function BillingAccountDetailPage(props) {
|
|
|
341
162
|
setDeleting(false);
|
|
342
163
|
}
|
|
343
164
|
}, [confirm, router, row, t]);
|
|
165
|
+
const isPrepaid = row?.billing_mode === "prepaid";
|
|
166
|
+
const visibleTabs = isPrepaid ? ["overview", "items", "usage", "invoices", "balance", "statements", "runs"] : ["overview", "items", "usage", "invoices", "payments", "runs"];
|
|
167
|
+
const tabLabels = {
|
|
168
|
+
overview: t("billing.accounts.tabs.overview", "Overview"),
|
|
169
|
+
items: t("billing.accounts.tabs.items", "Items"),
|
|
170
|
+
usage: t("billing.accounts.tabs.usage", "Usage"),
|
|
171
|
+
invoices: t("billing.accounts.tabs.invoices", "Invoices"),
|
|
172
|
+
payments: t("billing.accounts.tabs.payments", "Payments"),
|
|
173
|
+
balance: t("billing.accounts.tabs.balance", "Balance & top-ups"),
|
|
174
|
+
statements: t("billing.accounts.tabs.statements", "Statements"),
|
|
175
|
+
runs: t("billing.accounts.tabs.runs", "Bill runs")
|
|
176
|
+
};
|
|
177
|
+
const currentTab = visibleTabs.includes(activeTab) ? activeTab : "overview";
|
|
178
|
+
const renderTab = (tab) => {
|
|
179
|
+
if (!row) return null;
|
|
180
|
+
switch (tab) {
|
|
181
|
+
case "overview":
|
|
182
|
+
return editing ? /* @__PURE__ */ jsx(
|
|
183
|
+
AccountForm,
|
|
184
|
+
{
|
|
185
|
+
mode: "edit",
|
|
186
|
+
initial: toFormValues(row),
|
|
187
|
+
submitting: saving,
|
|
188
|
+
onSubmit: handleSubmit,
|
|
189
|
+
onCancel: () => setEditing(false)
|
|
190
|
+
}
|
|
191
|
+
) : /* @__PURE__ */ jsx(AccountView, { row });
|
|
192
|
+
case "items":
|
|
193
|
+
return /* @__PURE__ */ jsx(AccountItemsTab, { accountId: row.id, currencyCode: row.currency_code }, refreshKey);
|
|
194
|
+
case "usage":
|
|
195
|
+
return /* @__PURE__ */ jsx(AccountUsageTab, { accountId: row.id });
|
|
196
|
+
case "invoices":
|
|
197
|
+
return /* @__PURE__ */ jsx(AccountInvoicesSection, { accountId: row.id, showSummary: false }, refreshKey);
|
|
198
|
+
case "payments":
|
|
199
|
+
return /* @__PURE__ */ jsx(AccountPaymentsSection, { accountId: row.id, currencyCode: row.currency_code });
|
|
200
|
+
case "balance":
|
|
201
|
+
return /* @__PURE__ */ jsx(PrepaidPanel, { accountId: row.id, currencyCode: row.currency_code }, refreshKey);
|
|
202
|
+
case "statements":
|
|
203
|
+
return /* @__PURE__ */ jsx(AccountStatementsTab, { accountId: row.id, refreshKey });
|
|
204
|
+
case "runs":
|
|
205
|
+
return /* @__PURE__ */ jsx(AccountRunsTab, { accountId: row.id, refreshKey });
|
|
206
|
+
}
|
|
207
|
+
};
|
|
344
208
|
if (error) {
|
|
345
209
|
return /* @__PURE__ */ jsxs(Page, { children: [
|
|
346
210
|
/* @__PURE__ */ jsx(PageHeader, { title: t("billing.accounts.detail.title", "Billing Account") }),
|
|
@@ -366,8 +230,15 @@ function BillingAccountDetailPage(props) {
|
|
|
366
230
|
backHref: "/backend/billing/accounts",
|
|
367
231
|
entityTypeLabel: t("billing.accounts.detail.title", "Billing Account"),
|
|
368
232
|
title: row.name,
|
|
369
|
-
statusBadge:
|
|
233
|
+
statusBadge: /* @__PURE__ */ jsxs("span", { className: "inline-flex items-center gap-2", children: [
|
|
234
|
+
row.is_active ? /* @__PURE__ */ jsx(Tag, { variant: "success", children: t("billing.common.active", "Active") }) : /* @__PURE__ */ jsx(Tag, { variant: "default", children: t("billing.common.inactive", "Inactive") }),
|
|
235
|
+
row.billing_mode === "prepaid" ? /* @__PURE__ */ jsx(Tag, { variant: "brand", children: t("billing.mode.prepaid", "Prepaid") }) : /* @__PURE__ */ jsx(Tag, { variant: "neutral", children: t("billing.mode.postpaid", "Postpaid") })
|
|
236
|
+
] }),
|
|
370
237
|
actionsContent: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
238
|
+
/* @__PURE__ */ jsxs(Button, { type: "button", variant: "outline", onClick: () => setRunDialogOpen(true), children: [
|
|
239
|
+
/* @__PURE__ */ jsx(Play, { size: 16 }),
|
|
240
|
+
t("billing.accounts.run.action", "Run billing")
|
|
241
|
+
] }),
|
|
371
242
|
/* @__PURE__ */ jsx(Button, { asChild: true, variant: "outline", children: /* @__PURE__ */ jsxs(Link, { href: `/backend/billing/items/create?billAccountId=${row.id}`, children: [
|
|
372
243
|
/* @__PURE__ */ jsx(Plus, { size: 16 }),
|
|
373
244
|
t("billing.accounts.detail.add_item", "Add item")
|
|
@@ -376,10 +247,20 @@ function BillingAccountDetailPage(props) {
|
|
|
376
247
|
/* @__PURE__ */ jsx(Plus, { size: 16 }),
|
|
377
248
|
t("billing.accounts.detail.add_usage", "Add usage")
|
|
378
249
|
] }) }),
|
|
379
|
-
!editing ? /* @__PURE__ */ jsxs(
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
250
|
+
!editing ? /* @__PURE__ */ jsxs(
|
|
251
|
+
Button,
|
|
252
|
+
{
|
|
253
|
+
type: "button",
|
|
254
|
+
onClick: () => {
|
|
255
|
+
setEditing(true);
|
|
256
|
+
selectTab("overview");
|
|
257
|
+
},
|
|
258
|
+
children: [
|
|
259
|
+
/* @__PURE__ */ jsx(Pencil, { size: 16 }),
|
|
260
|
+
t("billing.common.edit", "Edit")
|
|
261
|
+
]
|
|
262
|
+
}
|
|
263
|
+
) : null,
|
|
383
264
|
/* @__PURE__ */ jsx(
|
|
384
265
|
Button,
|
|
385
266
|
{
|
|
@@ -394,19 +275,27 @@ function BillingAccountDetailPage(props) {
|
|
|
394
275
|
}
|
|
395
276
|
),
|
|
396
277
|
/* @__PURE__ */ jsxs(PageBody, { children: [
|
|
397
|
-
|
|
398
|
-
|
|
278
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-6", children: [
|
|
279
|
+
/* @__PURE__ */ jsx(AccountSummaryCards, { accountId: row.id, refreshKey }),
|
|
280
|
+
/* @__PURE__ */ jsx(Tabs, { value: currentTab, onValueChange: selectTab, variant: "underline", children: /* @__PURE__ */ jsx(TabsList, { "aria-label": t("billing.accounts.tabs.label", "Account sections"), children: visibleTabs.map((tab) => /* @__PURE__ */ jsx(TabsTrigger, { value: tab, children: tabLabels[tab] }, tab)) }) }),
|
|
281
|
+
visibleTabs.map(
|
|
282
|
+
(tab) => visitedTabs.has(tab) || tab === currentTab ? /* @__PURE__ */ jsx("div", { role: "tabpanel", hidden: tab !== currentTab, children: renderTab(tab) }, tab) : null
|
|
283
|
+
)
|
|
284
|
+
] }),
|
|
285
|
+
/* @__PURE__ */ jsx(
|
|
286
|
+
AccountRunBillingDialog,
|
|
399
287
|
{
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
288
|
+
accountId: row.id,
|
|
289
|
+
open: runDialogOpen,
|
|
290
|
+
onOpenChange: setRunDialogOpen,
|
|
291
|
+
onCompleted: () => {
|
|
292
|
+
setRunDialogOpen(false);
|
|
293
|
+
refresh();
|
|
294
|
+
void load({ silent: true });
|
|
295
|
+
selectTab("runs");
|
|
296
|
+
}
|
|
405
297
|
}
|
|
406
|
-
)
|
|
407
|
-
row.billing_mode === "prepaid" ? /* @__PURE__ */ jsx(PrepaidPanel, { accountId: row.id, currencyCode: row.currency_code }) : null,
|
|
408
|
-
/* @__PURE__ */ jsx(AccountItemsSection, { accountId: row.id }),
|
|
409
|
-
/* @__PURE__ */ jsx(AccountUsageSection, { accountId: row.id }),
|
|
298
|
+
),
|
|
410
299
|
ConfirmDialogElement
|
|
411
300
|
] })
|
|
412
301
|
] });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../src/modules/billing/backend/billing/accounts/%5Bid%5D/page.tsx"],
|
|
4
|
-
"sourcesContent": ["\"use client\"\nimport * as React from 'react'\nimport Link from 'next/link'\nimport { Pencil, Plus } from 'lucide-react'\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 { 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 { useConfirmDialog } from '@open-mercato/ui/backend/confirm-dialog'\nimport {\n apiCallOrThrow,\n readApiResultOrThrow,\n} from '@open-mercato/ui/backend/utils/apiCall'\nimport { normalizeCrudServerError } from '@open-mercato/ui/backend/utils/serverErrors'\nimport { AccountForm, type AccountFormValues } from '../../../../components/AccountForm'\nimport { DetailCard, DetailField } from '../../../../components/DetailFields'\nimport { PrepaidPanel } from '../../../../components/PrepaidPanel'\n\n/**\n * `/backend/billing/accounts/[id]` \u2014 Billing Account detail.\n *\n * Opens read-only (field grid + the account's items). The `Edit`\n * button swaps the grid for the `AccountForm`; Save / Cancel return\n * to the read-only view. Loads via `GET /api/billing/accounts?id=<id>`,\n * edits through `PUT`, soft-delete through `DELETE`.\n *\n * `customerId` + `currencyCode` are immutable on update \u2014 the form\n * disables both in `mode='edit'` and the schema rejects them per\n * `billingAccountUpdateSchema`.\n */\n\n// API list rows are snake_case (see `api/accounts/route.ts` `fields`).\ntype AccountRow = {\n id: string\n customer_id: string\n name: string\n currency_code: string\n bill_cycle: 'weekly' | 'monthly' | 'quarterly' | 'annually'\n bill_cycle_anchor: string\n invoice_email: string\n invoice_language: string\n tax_id: string | null\n invoice_address: {\n line1?: string\n line2?: string\n city?: string\n postal_code?: string\n country?: string\n } | null\n next_bill_date: string\n last_bill_date: string | null\n billing_mode: 'postpaid' | 'prepaid'\n credit_limit: string\n is_active: boolean\n created_at: string\n updated_at: string\n}\n\ntype ListResponse = { items: AccountRow[] }\n\n// Minimal item shape for the embedded \"Items\" table.\ntype AccountItemRow = {\n id: string\n description: string\n type: 'one_time' | 'recurring' | 'usage'\n bill_start_date: string\n is_active: boolean\n}\n\n// Minimal usage shape for the embedded \"Usage\" table. Mirrors the\n// snake_case `fields` projection in `api/usage/route.ts`. Usage is\n// append-only \u2014 `rated_in_bill_run_id` is null until a Bill Run rates it.\ntype AccountUsageRow = {\n id: string\n uom_code: string\n quantity: string\n period_start: string\n period_end: string\n line_description: string | null\n rated_in_bill_run_id: string | null\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.toLocaleDateString()\n}\n\nfunction toFormValues(row: AccountRow): AccountFormValues {\n return {\n customerId: row.customer_id,\n name: row.name,\n currencyCode: row.currency_code,\n billCycle: row.bill_cycle,\n billCycleAnchor: row.bill_cycle_anchor,\n invoiceEmail: row.invoice_email,\n invoiceLanguage: row.invoice_language,\n taxId: row.tax_id ?? '',\n invoiceAddress: {\n line1: row.invoice_address?.line1 ?? '',\n line2: row.invoice_address?.line2 ?? '',\n city: row.invoice_address?.city ?? '',\n postal_code: row.invoice_address?.postal_code ?? '',\n country: row.invoice_address?.country ?? '',\n },\n nextBillDate: row.next_bill_date?.slice(0, 10) ?? '',\n isActive: row.is_active,\n billingMode: row.billing_mode,\n creditLimit: row.credit_limit ?? '0',\n // The threshold lives on the balance row, not the account row \u2014 blank\n // means \"leave unchanged\" on save.\n lowBalanceThreshold: '',\n }\n}\n\n// \u2500\u2500\u2500 Read-only view \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nfunction AccountView({ row }: { row: AccountRow }) {\n const t = useT()\n const addr = row.invoice_address\n const addressText = addr\n ? [\n addr.line1,\n addr.line2,\n [addr.postal_code, addr.city].filter(Boolean).join(' '),\n addr.country,\n ]\n .map((part) => (part ?? '').trim())\n .filter(Boolean)\n .join(', ')\n : ''\n return (\n <DetailCard>\n <DetailField label={t('billing.accounts.form.customer_id', 'Customer ID')}>\n <span className=\"font-mono text-xs\">{row.customer_id}</span>\n </DetailField>\n <DetailField label={t('billing.accounts.columns.currency', 'Currency')}>\n {row.currency_code}\n </DetailField>\n <DetailField label={t('billing.accounts.columns.mode', 'Mode')}>\n {row.billing_mode === 'prepaid' ? (\n <Tag variant=\"brand\">{t('billing.mode.prepaid', 'Prepaid')}</Tag>\n ) : (\n <Tag variant=\"neutral\">{t('billing.mode.postpaid', 'Postpaid')}</Tag>\n )}\n </DetailField>\n <DetailField label={t('billing.accounts.columns.credit_limit', 'Credit limit')}>\n <span className=\"font-mono tabular-nums\">{row.credit_limit}</span>\n </DetailField>\n <DetailField label={t('billing.common.id', 'ID')}>\n <span className=\"font-mono text-xs\">{row.id}</span>\n </DetailField>\n <DetailField label={t('billing.accounts.columns.cycle', 'Cycle')}>\n {row.bill_cycle}\n <span className=\"text-muted-foreground\"> \u00B7 {row.bill_cycle_anchor}</span>\n </DetailField>\n <DetailField label={t('billing.accounts.columns.next_bill', 'Next bill')}>\n {formatDate(row.next_bill_date)}\n </DetailField>\n <DetailField label={t('billing.accounts.columns.last_bill', 'Last bill')}>\n {formatDate(row.last_bill_date)}\n </DetailField>\n <DetailField label={t('billing.accounts.form.invoice_email', 'Invoice email')}>\n {row.invoice_email}\n </DetailField>\n <DetailField label={t('billing.accounts.form.invoice_language', 'Invoice language')}>\n {row.invoice_language}\n </DetailField>\n <DetailField label={t('billing.accounts.form.tax_id', 'Tax ID')}>\n {row.tax_id || '\u2014'}\n </DetailField>\n <DetailField\n label={t('billing.accounts.form.address.title', 'Invoice address')}\n fullWidth\n >\n {addressText || '\u2014'}\n </DetailField>\n </DetailCard>\n )\n}\n\n// \u2500\u2500\u2500 Embedded items table \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nfunction AccountItemsSection({ accountId }: { accountId: string }) {\n const t = useT()\n const router = useRouter()\n const [rows, setRows] = React.useState<AccountItemRow[]>([])\n const [page, setPage] = React.useState(1)\n const [total, setTotal] = React.useState(0)\n const [totalPages, setTotalPages] = React.useState(1)\n const [loading, setLoading] = React.useState(true)\n const pageSize = 25\n\n const load = React.useCallback(async () => {\n setLoading(true)\n try {\n const result = await readApiResultOrThrow<{\n items: AccountItemRow[]\n total: number\n totalPages: number\n }>(\n `/api/billing/items?billAccountId=${accountId}&page=${page}` +\n `&pageSize=${pageSize}&sortField=createdAt&sortDir=desc`,\n )\n setRows(result.items ?? [])\n setTotal(result.total ?? 0)\n setTotalPages(result.totalPages ?? 1)\n } finally {\n setLoading(false)\n }\n }, [accountId, page])\n\n React.useEffect(() => {\n void load()\n }, [load])\n\n const columns = React.useMemo<ColumnDef<AccountItemRow>[]>(\n () => [\n {\n accessorKey: 'description',\n header: t('billing.items.columns.description', 'Description'),\n cell: ({ row }) => (\n <span className=\"text-sm font-medium text-primary\">\n {row.original.description}\n </span>\n ),\n },\n {\n accessorKey: 'type',\n header: t('billing.items.columns.type', 'Type'),\n cell: ({ row }) => <Tag variant=\"info\">{row.original.type}</Tag>,\n },\n {\n accessorKey: 'bill_start_date',\n header: t('billing.items.columns.start', 'Start'),\n cell: ({ row }) => formatDate(row.original.bill_start_date),\n },\n {\n accessorKey: 'is_active',\n header: t('billing.items.columns.status', 'Status'),\n cell: ({ row }) =>\n row.original.is_active ? (\n <Tag variant=\"success\">{t('billing.common.active', 'Active')}</Tag>\n ) : (\n <Tag variant=\"default\">{t('billing.common.inactive', 'Inactive')}</Tag>\n ),\n },\n ],\n [t],\n )\n\n return (\n <div className=\"mt-6\">\n <DataTable\n title={t('billing.accounts.detail.items.title', 'Items')}\n columns={columns}\n data={rows}\n isLoading={loading}\n onRowClick={(row) => router.push(`/backend/billing/items/${row.id}`)}\n pagination={{ page, pageSize, total, totalPages, onPageChange: setPage }}\n emptyState={\n <div className=\"rounded-lg border bg-card p-6 text-center text-sm text-muted-foreground\">\n {t('billing.accounts.detail.items.empty', 'No items for this account yet.')}\n </div>\n }\n />\n </div>\n )\n}\n\n// \u2500\u2500\u2500 Embedded usage table \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nfunction AccountUsageSection({ accountId }: { accountId: string }) {\n const t = useT()\n const [rows, setRows] = React.useState<AccountUsageRow[]>([])\n const [page, setPage] = React.useState(1)\n const [total, setTotal] = React.useState(0)\n const [totalPages, setTotalPages] = React.useState(1)\n const [loading, setLoading] = React.useState(true)\n const pageSize = 25\n\n const load = React.useCallback(async () => {\n setLoading(true)\n try {\n const result = await readApiResultOrThrow<{\n items: AccountUsageRow[]\n total: number\n totalPages: number\n }>(\n `/api/billing/usage?billAccountId=${accountId}&page=${page}` +\n `&pageSize=${pageSize}&sortField=periodStart&sortDir=desc`,\n )\n setRows(result.items ?? [])\n setTotal(result.total ?? 0)\n setTotalPages(result.totalPages ?? 1)\n } finally {\n setLoading(false)\n }\n }, [accountId, page])\n\n React.useEffect(() => {\n void load()\n }, [load])\n\n const columns = React.useMemo<ColumnDef<AccountUsageRow>[]>(\n () => [\n {\n accessorKey: 'uom_code',\n header: t('billing.usage.columns.uom', 'Unit'),\n cell: ({ row }) => (\n <span className=\"font-mono text-xs\">{row.original.uom_code}</span>\n ),\n },\n {\n accessorKey: 'quantity',\n header: t('billing.usage.columns.quantity', 'Quantity'),\n cell: ({ row }) => (\n <span className=\"font-mono tabular-nums\">{row.original.quantity}</span>\n ),\n },\n {\n accessorKey: 'period_start',\n header: t('billing.usage.columns.period', 'Period'),\n cell: ({ row }) =>\n `${formatDate(row.original.period_start)} \u2013 ${formatDate(row.original.period_end)}`,\n },\n {\n accessorKey: 'line_description',\n header: t('billing.usage.columns.description', 'Description'),\n cell: ({ row }) => row.original.line_description || '\u2014',\n },\n {\n accessorKey: 'rated_in_bill_run_id',\n header: t('billing.usage.columns.rated', 'Rated'),\n cell: ({ row }) =>\n row.original.rated_in_bill_run_id ? (\n // Rated records carry the Bill Run that priced them \u2014 link to it.\n // Unrated records have no destination, so they stay non-interactive\n // (no misleading row-level click affordance).\n <Link\n href={`/backend/billing/runs/${row.original.rated_in_bill_run_id}`}\n className=\"rounded-sm hover:underline\"\n >\n <Tag variant=\"success\">{t('billing.usage.rated.yes', 'Rated')}</Tag>\n </Link>\n ) : (\n <Tag variant=\"default\">{t('billing.usage.rated.no', 'Unrated')}</Tag>\n ),\n },\n ],\n [t],\n )\n\n return (\n <div className=\"mt-6\">\n <DataTable\n title={t('billing.accounts.detail.usage.title', 'Usage')}\n columns={columns}\n data={rows}\n isLoading={loading}\n pagination={{ page, pageSize, total, totalPages, onPageChange: setPage }}\n emptyState={\n <div className=\"rounded-lg border bg-card p-6 text-center text-sm text-muted-foreground\">\n {t('billing.accounts.detail.usage.empty', 'No usage records for this account yet.')}\n </div>\n }\n />\n </div>\n )\n}\n\nexport default function BillingAccountDetailPage(props: { params?: { id?: string } }) {\n const t = useT()\n const router = useRouter()\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 accountId = (props.params?.id ?? urlParams?.id ?? '') as string\n\n const [row, setRow] = React.useState<AccountRow | null>(null)\n const [loading, setLoading] = React.useState(true)\n const [error, setError] = React.useState<string | null>(null)\n const [editing, setEditing] = React.useState(false)\n const [saving, setSaving] = React.useState(false)\n const [deleting, setDeleting] = React.useState(false)\n\n const { confirm, ConfirmDialogElement } = useConfirmDialog()\n\n const load = React.useCallback(async () => {\n if (!accountId) return\n setLoading(true)\n setError(null)\n try {\n const result = await readApiResultOrThrow<ListResponse>(\n `/api/billing/accounts?id=${accountId}&pageSize=1`,\n )\n const found = result.items?.[0]\n if (!found) {\n setError(t('billing.accounts.detail.error.not_found', 'Account not found'))\n return\n }\n setRow(found)\n } catch (err) {\n const { message } = normalizeCrudServerError(err)\n setError(message || t('billing.accounts.detail.error.load', 'Failed to load account'))\n } finally {\n setLoading(false)\n }\n }, [accountId, t])\n\n React.useEffect(() => {\n void load()\n }, [load])\n\n const handleSubmit = React.useCallback(\n async (values: AccountFormValues) => {\n if (!row) return\n setSaving(true)\n try {\n const payload: Record<string, unknown> = {\n id: row.id,\n name: values.name.trim(),\n billCycle: values.billCycle,\n billCycleAnchor: values.billCycleAnchor.trim(),\n invoiceEmail: values.invoiceEmail.trim(),\n invoiceLanguage: values.invoiceLanguage.trim().toLowerCase(),\n invoiceAddress: {\n line1: values.invoiceAddress.line1.trim(),\n ...(values.invoiceAddress.line2.trim()\n ? { line2: values.invoiceAddress.line2.trim() }\n : {}),\n city: values.invoiceAddress.city.trim(),\n postal_code: values.invoiceAddress.postal_code.trim(),\n country: values.invoiceAddress.country.trim().toUpperCase(),\n },\n nextBillDate: values.nextBillDate,\n isActive: values.isActive,\n }\n payload.taxId = values.taxId.trim() === '' ? null : values.taxId.trim()\n // billingMode is immutable on update; creditLimit + threshold are editable.\n const creditLimit = Number.parseFloat(values.creditLimit)\n if (Number.isFinite(creditLimit) && creditLimit >= 0) payload.creditLimit = creditLimit\n if (row.billing_mode === 'prepaid' && values.lowBalanceThreshold.trim()) {\n const threshold = Number.parseFloat(values.lowBalanceThreshold)\n if (Number.isFinite(threshold) && threshold >= 0) payload.lowBalanceThreshold = threshold\n }\n\n await apiCallOrThrow('/api/billing/accounts', {\n method: 'PUT',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(payload),\n })\n flash(t('billing.accounts.detail.save.success', 'Account updated'), 'success')\n setEditing(false)\n void load()\n } catch (err) {\n const { message, fieldErrors } = normalizeCrudServerError(err)\n const fieldDetail =\n fieldErrors && Object.keys(fieldErrors).length\n ? Object.entries(fieldErrors)\n .map(([field, msg]) => `${field}: ${msg}`)\n .join('; ')\n : null\n const detailed =\n fieldDetail && message\n ? `${message} \u2014 ${fieldDetail}`\n : fieldDetail || message\n flash(detailed || t('billing.accounts.detail.save.error', 'Save failed'), 'error')\n } finally {\n setSaving(false)\n }\n },\n [load, row, t],\n )\n\n const handleDelete = React.useCallback(async () => {\n if (!row) return\n const ok = await confirm({\n title: t('billing.accounts.detail.delete.confirm.title', 'Delete account?'),\n text: t(\n 'billing.accounts.detail.delete.confirm.text',\n \"Soft-deletes the account. Its items + usage records stay in the database for audit; the Bill Run engine will stop picking it up immediately.\",\n ),\n confirmText: t('billing.accounts.detail.delete.confirm.button', 'Soft delete'),\n variant: 'destructive',\n })\n if (!ok) return\n setDeleting(true)\n try {\n await apiCallOrThrow('/api/billing/accounts', {\n method: 'DELETE',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ id: row.id }),\n })\n flash(t('billing.accounts.detail.delete.success', 'Account deleted'), 'success')\n router.push('/backend/billing/accounts')\n } catch (err) {\n const { message } = normalizeCrudServerError(err)\n flash(message || t('billing.accounts.detail.delete.error', 'Delete failed'), 'error')\n setDeleting(false)\n }\n }, [confirm, router, row, t])\n\n if (error) {\n return (\n <Page>\n <PageHeader title={t('billing.accounts.detail.title', 'Billing Account')} />\n <PageBody>\n <ErrorMessage label={error} />\n </PageBody>\n </Page>\n )\n }\n\n if (loading || !row) {\n return (\n <Page>\n <PageHeader title={t('billing.accounts.detail.title', 'Billing Account')} />\n <PageBody>\n <LoadingMessage\n label={t('billing.accounts.detail.loading', 'Loading account\u2026')}\n />\n </PageBody>\n </Page>\n )\n }\n\n return (\n <Page>\n <FormHeader\n mode=\"detail\"\n backHref=\"/backend/billing/accounts\"\n entityTypeLabel={t('billing.accounts.detail.title', 'Billing Account')}\n title={row.name}\n statusBadge={\n row.is_active ? (\n <Tag variant=\"success\">{t('billing.common.active', 'Active')}</Tag>\n ) : (\n <Tag variant=\"default\">{t('billing.common.inactive', 'Inactive')}</Tag>\n )\n }\n actionsContent={\n <>\n <Button asChild variant=\"outline\">\n <Link href={`/backend/billing/items/create?billAccountId=${row.id}`}>\n <Plus size={16} />\n {t('billing.accounts.detail.add_item', 'Add item')}\n </Link>\n </Button>\n <Button asChild variant=\"outline\">\n <Link href={`/backend/billing/usage/create?billAccountId=${row.id}`}>\n <Plus size={16} />\n {t('billing.accounts.detail.add_usage', 'Add usage')}\n </Link>\n </Button>\n {!editing ? (\n <Button type=\"button\" onClick={() => setEditing(true)}>\n <Pencil size={16} />\n {t('billing.common.edit', 'Edit')}\n </Button>\n ) : null}\n <Button\n type=\"button\"\n variant=\"outline\"\n onClick={handleDelete}\n disabled={deleting}\n >\n {deleting\n ? t('billing.accounts.detail.delete.in_progress', 'Deleting\u2026')\n : t('billing.accounts.detail.delete.action', 'Soft delete')}\n </Button>\n </>\n }\n />\n <PageBody>\n {editing ? (\n <AccountForm\n mode=\"edit\"\n initial={toFormValues(row)}\n submitting={saving}\n onSubmit={handleSubmit}\n onCancel={() => setEditing(false)}\n />\n ) : (\n <AccountView row={row} />\n )}\n {row.billing_mode === 'prepaid' ? (\n <PrepaidPanel accountId={row.id} currencyCode={row.currency_code} />\n ) : null}\n <AccountItemsSection accountId={row.id} />\n <AccountUsageSection accountId={row.id} />\n {ConfirmDialogElement}\n </PageBody>\n </Page>\n )\n}\n"],
|
|
5
|
-
"m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,YAAY;AAAA,UACZ,UAAU;AAAA,UACV,UAAU,MAAM,WAAW,KAAK;AAAA;AAAA,MAClC,IAEA,oBAAC,eAAY,KAAU;AAAA,MAExB,IAAI,iBAAiB,YACpB,oBAAC,gBAAa,WAAW,IAAI,IAAI,cAAc,IAAI,eAAe,IAChE;AAAA,MACJ,oBAAC,uBAAoB,WAAW,IAAI,IAAI;AAAA,MACxC,oBAAC,uBAAoB,WAAW,IAAI,IAAI;AAAA,MACvC;AAAA,OACH;AAAA,KACF;AAEJ;",
|
|
4
|
+
"sourcesContent": ["\"use client\"\nimport * as React from 'react'\nimport Link from 'next/link'\nimport { Pencil, Play, Plus } from 'lucide-react'\nimport { useParams, useRouter, useSearchParams } from 'next/navigation'\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 { Tag } from '@open-mercato/ui/primitives/tag'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { Tabs, TabsList, TabsTrigger } from '@open-mercato/ui/primitives/tabs'\nimport { LoadingMessage, ErrorMessage } from '@open-mercato/ui/backend/detail'\nimport { flash } from '@open-mercato/ui/backend/FlashMessages'\nimport { useConfirmDialog } from '@open-mercato/ui/backend/confirm-dialog'\nimport {\n apiCallOrThrow,\n readApiResultOrThrow,\n} from '@open-mercato/ui/backend/utils/apiCall'\nimport { normalizeCrudServerError } from '@open-mercato/ui/backend/utils/serverErrors'\nimport { AccountForm, type AccountFormValues } from '../../../../components/AccountForm'\nimport { PrepaidPanel } from '../../../../components/PrepaidPanel'\nimport { AccountInvoicesSection } from '../../../../components/AccountInvoicesSection'\nimport { AccountPaymentsSection } from '../../../../components/AccountPaymentsSection'\nimport { AccountView } from '../../../../components/account/AccountView'\nimport { AccountItemsTab } from '../../../../components/account/AccountItemsTab'\nimport { AccountUsageTab } from '../../../../components/account/AccountUsageTab'\nimport { AccountRunsTab } from '../../../../components/account/AccountRunsTab'\nimport { AccountStatementsTab } from '../../../../components/account/AccountStatementsTab'\nimport { AccountSummaryCards } from '../../../../components/account/AccountSummaryCards'\nimport { AccountRunBillingDialog } from '../../../../components/account/AccountRunBillingDialog'\nimport { toFormValues, type AccountRow } from '../../../../components/account/accountRow'\nimport { accountHref, isAccountTab, type AccountTab } from '../../../../lib/navigation'\n\n/**\n * `/backend/billing/accounts/[id]` \u2014 the Billing Account workspace\n * (Spec E \u00A74, delivered by Spec F, F8).\n *\n * Header actions (Run billing, Add item / usage, Edit, Soft delete), summary\n * cards from `GET /api/billing/accounts/{id}/summary`, and deep-linkable\n * tabs (`?tab=`). A tab mounts on first open and stays mounted, so switching\n * back keeps its page and filters; prepaid-only tabs are hidden for postpaid\n * accounts and vice versa. Loads via `GET /api/billing/accounts?id=<id>`,\n * edits through `PUT`, soft-delete through `DELETE`.\n *\n * `customerId` + `currencyCode` are immutable on update \u2014 the form\n * disables both in `mode='edit'` and the schema rejects them per\n * `billingAccountUpdateSchema`.\n */\n\ntype ListResponse = { items: AccountRow[] }\n\nexport default function BillingAccountDetailPage(props: { params?: { id?: string } }) {\n const t = useT()\n const router = useRouter()\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 accountId = (props.params?.id ?? urlParams?.id ?? '') as string\n\n const [row, setRow] = React.useState<AccountRow | null>(null)\n const [loading, setLoading] = React.useState(true)\n const [error, setError] = React.useState<string | null>(null)\n const [editing, setEditing] = React.useState(false)\n const [saving, setSaving] = React.useState(false)\n const [deleting, setDeleting] = React.useState(false)\n const [runDialogOpen, setRunDialogOpen] = React.useState(false)\n // Bumped after a run / cleanup so the summary and run-driven tabs reload.\n const [refreshKey, setRefreshKey] = React.useState(0)\n const refresh = React.useCallback(() => setRefreshKey((key) => key + 1), [])\n\n // Deep-linkable tab (`?tab=`); router.replace keeps history clean.\n const searchParams = useSearchParams()\n const requestedTab = searchParams?.get('tab')\n const activeTab: AccountTab = isAccountTab(requestedTab) ? requestedTab : 'overview'\n const [visitedTabs, setVisitedTabs] = React.useState<Set<AccountTab>>(() => new Set([activeTab]))\n React.useEffect(() => {\n setVisitedTabs((prev) => (prev.has(activeTab) ? prev : new Set(prev).add(activeTab)))\n }, [activeTab])\n const selectTab = React.useCallback(\n (next: string) => {\n if (!isAccountTab(next) || !accountId) return\n router.replace(accountHref(accountId, next), { scroll: false })\n },\n [accountId, router],\n )\n\n const { confirm, ConfirmDialogElement } = useConfirmDialog()\n\n // `silent` refreshes the row in place (after a run / save) without the\n // full-page loading state, which would unmount the workspace and its dialogs.\n const load = React.useCallback(async (options: { silent?: boolean } = {}) => {\n if (!accountId) return\n if (!options.silent) setLoading(true)\n setError(null)\n try {\n const result = await readApiResultOrThrow<ListResponse>(\n `/api/billing/accounts?id=${accountId}&pageSize=1`,\n )\n const found = result.items?.[0]\n if (!found) {\n setError(t('billing.accounts.detail.error.not_found', 'Account not found'))\n return\n }\n setRow(found)\n } catch (err) {\n const { message } = normalizeCrudServerError(err)\n setError(message || t('billing.accounts.detail.error.load', 'Failed to load account'))\n } finally {\n setLoading(false)\n }\n }, [accountId, t])\n\n React.useEffect(() => {\n void load()\n }, [load])\n\n const handleSubmit = React.useCallback(\n async (values: AccountFormValues) => {\n if (!row) return\n setSaving(true)\n try {\n const payload: Record<string, unknown> = {\n id: row.id,\n name: values.name.trim(),\n billCycle: values.billCycle,\n billCycleAnchor: values.billCycleAnchor.trim(),\n invoiceEmail: values.invoiceEmail.trim(),\n invoiceLanguage: values.invoiceLanguage.trim().toLowerCase(),\n invoiceAddress: {\n line1: values.invoiceAddress.line1.trim(),\n ...(values.invoiceAddress.line2.trim()\n ? { line2: values.invoiceAddress.line2.trim() }\n : {}),\n city: values.invoiceAddress.city.trim(),\n postal_code: values.invoiceAddress.postal_code.trim(),\n country: values.invoiceAddress.country.trim().toUpperCase(),\n },\n nextBillDate: values.nextBillDate,\n isActive: values.isActive,\n }\n payload.taxId = values.taxId.trim() === '' ? null : values.taxId.trim()\n // billingMode is immutable on update; creditLimit + threshold are editable.\n const creditLimit = Number.parseFloat(values.creditLimit)\n if (Number.isFinite(creditLimit) && creditLimit >= 0) payload.creditLimit = creditLimit\n const termsDays = Number.parseInt(values.paymentTermsDays, 10)\n payload.paymentTermsDays =\n values.paymentTermsDays.trim() && Number.isInteger(termsDays) && termsDays >= 0 ? termsDays : null\n payload.autoSendInvoice = values.autoSendInvoice\n if (row.billing_mode === 'prepaid' && values.lowBalanceThreshold.trim()) {\n const threshold = Number.parseFloat(values.lowBalanceThreshold)\n if (Number.isFinite(threshold) && threshold >= 0) payload.lowBalanceThreshold = threshold\n }\n\n await apiCallOrThrow('/api/billing/accounts', {\n method: 'PUT',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(payload),\n })\n flash(t('billing.accounts.detail.save.success', 'Account updated'), 'success')\n setEditing(false)\n void load({ silent: true })\n } catch (err) {\n const { message, fieldErrors } = normalizeCrudServerError(err)\n const fieldDetail =\n fieldErrors && Object.keys(fieldErrors).length\n ? Object.entries(fieldErrors)\n .map(([field, msg]) => `${field}: ${msg}`)\n .join('; ')\n : null\n const detailed =\n fieldDetail && message\n ? `${message} \u2014 ${fieldDetail}`\n : fieldDetail || message\n flash(detailed || t('billing.accounts.detail.save.error', 'Save failed'), 'error')\n } finally {\n setSaving(false)\n }\n },\n [load, row, t],\n )\n\n const handleDelete = React.useCallback(async () => {\n if (!row) return\n const ok = await confirm({\n title: t('billing.accounts.detail.delete.confirm.title', 'Delete account?'),\n text: t(\n 'billing.accounts.detail.delete.confirm.text',\n \"Soft-deletes the account. Its items + usage records stay in the database for audit; the Bill Run engine will stop picking it up immediately.\",\n ),\n confirmText: t('billing.accounts.detail.delete.confirm.button', 'Soft delete'),\n variant: 'destructive',\n })\n if (!ok) return\n setDeleting(true)\n try {\n await apiCallOrThrow('/api/billing/accounts', {\n method: 'DELETE',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ id: row.id }),\n })\n flash(t('billing.accounts.detail.delete.success', 'Account deleted'), 'success')\n router.push('/backend/billing/accounts')\n } catch (err) {\n const { message } = normalizeCrudServerError(err)\n flash(message || t('billing.accounts.detail.delete.error', 'Delete failed'), 'error')\n setDeleting(false)\n }\n }, [confirm, router, row, t])\n\n const isPrepaid = row?.billing_mode === 'prepaid'\n const visibleTabs: AccountTab[] = isPrepaid\n ? ['overview', 'items', 'usage', 'invoices', 'balance', 'statements', 'runs']\n : ['overview', 'items', 'usage', 'invoices', 'payments', 'runs']\n const tabLabels: Record<AccountTab, string> = {\n overview: t('billing.accounts.tabs.overview', 'Overview'),\n items: t('billing.accounts.tabs.items', 'Items'),\n usage: t('billing.accounts.tabs.usage', 'Usage'),\n invoices: t('billing.accounts.tabs.invoices', 'Invoices'),\n payments: t('billing.accounts.tabs.payments', 'Payments'),\n balance: t('billing.accounts.tabs.balance', 'Balance & top-ups'),\n statements: t('billing.accounts.tabs.statements', 'Statements'),\n runs: t('billing.accounts.tabs.runs', 'Bill runs'),\n }\n // A tab that does not apply to this account's mode falls back to Overview.\n const currentTab: AccountTab = visibleTabs.includes(activeTab) ? activeTab : 'overview'\n const renderTab = (tab: AccountTab): React.ReactNode => {\n if (!row) return null\n switch (tab) {\n case 'overview':\n return editing ? (\n <AccountForm\n mode=\"edit\"\n initial={toFormValues(row)}\n submitting={saving}\n onSubmit={handleSubmit}\n onCancel={() => setEditing(false)}\n />\n ) : (\n <AccountView row={row} />\n )\n case 'items':\n return <AccountItemsTab key={refreshKey} accountId={row.id} currencyCode={row.currency_code} />\n case 'usage':\n return <AccountUsageTab accountId={row.id} />\n case 'invoices':\n return <AccountInvoicesSection key={refreshKey} accountId={row.id} showSummary={false} />\n case 'payments':\n return <AccountPaymentsSection accountId={row.id} currencyCode={row.currency_code} />\n case 'balance':\n return <PrepaidPanel key={refreshKey} accountId={row.id} currencyCode={row.currency_code} />\n case 'statements':\n return <AccountStatementsTab accountId={row.id} refreshKey={refreshKey} />\n case 'runs':\n return <AccountRunsTab accountId={row.id} refreshKey={refreshKey} />\n }\n }\n\n if (error) {\n return (\n <Page>\n <PageHeader title={t('billing.accounts.detail.title', 'Billing Account')} />\n <PageBody>\n <ErrorMessage label={error} />\n </PageBody>\n </Page>\n )\n }\n\n if (loading || !row) {\n return (\n <Page>\n <PageHeader title={t('billing.accounts.detail.title', 'Billing Account')} />\n <PageBody>\n <LoadingMessage\n label={t('billing.accounts.detail.loading', 'Loading account\u2026')}\n />\n </PageBody>\n </Page>\n )\n }\n\n return (\n <Page>\n <FormHeader\n mode=\"detail\"\n backHref=\"/backend/billing/accounts\"\n entityTypeLabel={t('billing.accounts.detail.title', 'Billing Account')}\n title={row.name}\n statusBadge={\n <span className=\"inline-flex items-center gap-2\">\n {row.is_active ? (\n <Tag variant=\"success\">{t('billing.common.active', 'Active')}</Tag>\n ) : (\n <Tag variant=\"default\">{t('billing.common.inactive', 'Inactive')}</Tag>\n )}\n {row.billing_mode === 'prepaid' ? (\n <Tag variant=\"brand\">{t('billing.mode.prepaid', 'Prepaid')}</Tag>\n ) : (\n <Tag variant=\"neutral\">{t('billing.mode.postpaid', 'Postpaid')}</Tag>\n )}\n </span>\n }\n actionsContent={\n <>\n <Button type=\"button\" variant=\"outline\" onClick={() => setRunDialogOpen(true)}>\n <Play size={16} />\n {t('billing.accounts.run.action', 'Run billing')}\n </Button>\n <Button asChild variant=\"outline\">\n <Link href={`/backend/billing/items/create?billAccountId=${row.id}`}>\n <Plus size={16} />\n {t('billing.accounts.detail.add_item', 'Add item')}\n </Link>\n </Button>\n <Button asChild variant=\"outline\">\n <Link href={`/backend/billing/usage/create?billAccountId=${row.id}`}>\n <Plus size={16} />\n {t('billing.accounts.detail.add_usage', 'Add usage')}\n </Link>\n </Button>\n {!editing ? (\n <Button\n type=\"button\"\n onClick={() => {\n setEditing(true)\n selectTab('overview')\n }}\n >\n <Pencil size={16} />\n {t('billing.common.edit', 'Edit')}\n </Button>\n ) : null}\n <Button\n type=\"button\"\n variant=\"outline\"\n onClick={handleDelete}\n disabled={deleting}\n >\n {deleting\n ? t('billing.accounts.detail.delete.in_progress', 'Deleting\u2026')\n : t('billing.accounts.detail.delete.action', 'Soft delete')}\n </Button>\n </>\n }\n />\n <PageBody>\n <div className=\"space-y-6\">\n <AccountSummaryCards accountId={row.id} refreshKey={refreshKey} />\n <Tabs value={currentTab} onValueChange={selectTab} variant=\"underline\">\n <TabsList aria-label={t('billing.accounts.tabs.label', 'Account sections')}>\n {visibleTabs.map((tab) => (\n <TabsTrigger key={tab} value={tab}>\n {tabLabels[tab]}\n </TabsTrigger>\n ))}\n </TabsList>\n </Tabs>\n {visibleTabs.map((tab) =>\n visitedTabs.has(tab) || tab === currentTab ? (\n <div key={tab} role=\"tabpanel\" hidden={tab !== currentTab}>\n {renderTab(tab)}\n </div>\n ) : null,\n )}\n </div>\n <AccountRunBillingDialog\n accountId={row.id}\n open={runDialogOpen}\n onOpenChange={setRunDialogOpen}\n onCompleted={() => {\n setRunDialogOpen(false)\n refresh()\n void load({ silent: true })\n selectTab('runs')\n }}\n />\n {ConfirmDialogElement}\n </PageBody>\n </Page>\n )\n}\n"],
|
|
5
|
+
"mappings": ";AAsOU,SAyEA,UAzEA,KA6BJ,YA7BI;AArOV,YAAY,WAAW;AACvB,OAAO,UAAU;AACjB,SAAS,QAAQ,MAAM,YAAY;AACnC,SAAS,WAAW,WAAW,uBAAuB;AACtD,SAAS,YAAY;AACrB,SAAS,MAAM,UAAU,kBAAkB;AAC3C,SAAS,kBAAkB;AAC3B,SAAS,WAAW;AACpB,SAAS,cAAc;AACvB,SAAS,MAAM,UAAU,mBAAmB;AAC5C,SAAS,gBAAgB,oBAAoB;AAC7C,SAAS,aAAa;AACtB,SAAS,wBAAwB;AACjC;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,gCAAgC;AACzC,SAAS,mBAA2C;AACpD,SAAS,oBAAoB;AAC7B,SAAS,8BAA8B;AACvC,SAAS,8BAA8B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AAAA,MACA;AAAA,QAAC;AAAA;AAAA,UACC,WAAW,IAAI;AAAA,UACf,MAAM;AAAA,UACN,cAAc;AAAA,UACd,aAAa,MAAM;AACjB,6BAAiB,KAAK;AACtB,oBAAQ;AACR,iBAAK,KAAK,EAAE,QAAQ,KAAK,CAAC;AAC1B,sBAAU,MAAM;AAAA,UAClB;AAAA;AAAA,MACF;AAAA,MACC;AAAA,OACH;AAAA,KACF;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -18,6 +18,7 @@ function CreateBillingAccountPage() {
|
|
|
18
18
|
try {
|
|
19
19
|
const payload = {
|
|
20
20
|
customerId: values.customerId.trim(),
|
|
21
|
+
customerKind: values.customerKind,
|
|
21
22
|
name: values.name.trim(),
|
|
22
23
|
currencyCode: values.currencyCode.trim().toUpperCase(),
|
|
23
24
|
billCycle: values.billCycle,
|
|
@@ -37,6 +38,11 @@ function CreateBillingAccountPage() {
|
|
|
37
38
|
if (values.taxId.trim()) payload.taxId = values.taxId.trim();
|
|
38
39
|
const creditLimit = Number.parseFloat(values.creditLimit);
|
|
39
40
|
if (Number.isFinite(creditLimit) && creditLimit >= 0) payload.creditLimit = creditLimit;
|
|
41
|
+
const termsDays = Number.parseInt(values.paymentTermsDays, 10);
|
|
42
|
+
if (values.paymentTermsDays.trim() && Number.isInteger(termsDays) && termsDays >= 0) {
|
|
43
|
+
payload.paymentTermsDays = termsDays;
|
|
44
|
+
}
|
|
45
|
+
payload.autoSendInvoice = values.autoSendInvoice;
|
|
40
46
|
if (values.billingMode === "prepaid" && values.lowBalanceThreshold.trim()) {
|
|
41
47
|
const threshold = Number.parseFloat(values.lowBalanceThreshold);
|
|
42
48
|
if (Number.isFinite(threshold) && threshold >= 0) payload.lowBalanceThreshold = threshold;
|