@dainamite/billing 0.20.0 → 0.21.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 +90 -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 +46 -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 +69 -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/en.json +457 -21
- package/dist/modules/billing/i18n/pl.json +457 -21
- 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 +131 -0
- package/dist/modules/billing/lib/invoiceDelivery.js.map +7 -0
- package/dist/modules/billing/lib/invoiceLanguages.js +16 -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 +274 -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 +170 -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__/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 +189 -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 +199 -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 +193 -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 +58 -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 +79 -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 +654 -5
- 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/en.json +457 -21
- package/src/modules/billing/i18n/pl.json +457 -21
- 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 +197 -0
- package/src/modules/billing/lib/invoiceLanguages.ts +34 -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 +328 -0
- package/src/modules/billing/lib/pdf/invoicePdf.ts +216 -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
|
@@ -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
|
-
"mappings": ";AA4IQ,SAwZE,UAxZF,KAoBA,YApBA;AA3IR,YAAY,WAAW;AACvB,OAAO,UAAU;AACjB,SAAS,QAAQ,YAAY;AAC7B,SAAS,WAAW,iBAAiB;AAErC,SAAS,YAAY;AACrB,SAAS,MAAM,UAAU,kBAAkB;AAC3C,SAAS,kBAAkB;AAC3B,SAAS,iBAAiB;AAC1B,SAAS,WAAW;AACpB,SAAS,cAAc;AACvB,SAAS,gBAAgB,oBAAoB;AAC7C,SAAS,aAAa;AACtB,SAAS,wBAAwB;AACjC;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,gCAAgC;AACzC,SAAS,mBAA2C;AACpD,SAAS,YAAY,mBAAmB;AACxC,SAAS,oBAAoB;AAkE7B,SAAS,WAAW,OAA0C;AAC5D,MAAI,CAAC,MAAO,QAAO;AACnB,QAAM,SAAS,IAAI,KAAK,KAAK;AAC7B,SAAO,OAAO,MAAM,OAAO,QAAQ,CAAC,IAAI,QAAQ,OAAO,mBAAmB;AAC5E;AAEA,SAAS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,+CAA+C,IAAI,EAAE,IAC/D;AAAA,gCAAC,QAAK,MAAM,IAAI;AAAA,YACf,EAAE,qCAAqC,WAAW;AAAA,aACrD,GACF;AAAA,UACC,CAAC,UACA,qBAAC,UAAO,MAAK,UAAS,SAAS,MAAM,WAAW,IAAI,GAClD;AAAA,gCAAC,UAAO,MAAM,IAAI;AAAA,YACjB,EAAE,uBAAuB,MAAM;AAAA,aAClC,IACE;AAAA,UACJ;AAAA,YAAC;AAAA;AAAA,cACC,MAAK;AAAA,cACL,SAAQ;AAAA,cACR,SAAS;AAAA,cACT,UAAU;AAAA,cAET,qBACG,EAAE,8CAA8C,gBAAW,IAC3D,EAAE,yCAAyC,aAAa;AAAA;AAAA,UAC9D;AAAA,WACF;AAAA;AAAA,IAEJ;AAAA,IACA,qBAAC,YACE;AAAA,gBACC;AAAA,QAAC;AAAA;AAAA,UACC,MAAK;AAAA,UACL,SAAS,aAAa,GAAG;AAAA,UACzB,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()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,cAET,qBACG,EAAE,8CAA8C,gBAAW,IAC3D,EAAE,yCAAyC,aAAa;AAAA;AAAA,UAC9D;AAAA,WACF;AAAA;AAAA,IAEJ;AAAA,IACA,qBAAC,YACC;AAAA,2BAAC,SAAI,WAAU,aACb;AAAA,4BAAC,uBAAoB,WAAW,IAAI,IAAI,YAAwB;AAAA,QAChE,oBAAC,QAAK,OAAO,YAAY,eAAe,WAAW,SAAQ,aACzD,8BAAC,YAAS,cAAY,EAAE,+BAA+B,kBAAkB,GACtE,sBAAY,IAAI,CAAC,QAChB,oBAAC,eAAsB,OAAO,KAC3B,oBAAU,GAAG,KADE,GAElB,CACD,GACH,GACF;AAAA,QACC,YAAY;AAAA,UAAI,CAAC,QAChB,YAAY,IAAI,GAAG,KAAK,QAAQ,aAC9B,oBAAC,SAAc,MAAK,YAAW,QAAQ,QAAQ,YAC5C,oBAAU,GAAG,KADN,GAEV,IACE;AAAA,QACN;AAAA,SACF;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;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../src/modules/billing/backend/billing/accounts/create/page.tsx"],
|
|
4
|
-
"sourcesContent": ["\"use client\"\nimport * as React from 'react'\nimport { useRouter } from 'next/navigation'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport { Page, PageBody, PageHeader } from '@open-mercato/ui/backend/Page'\nimport { flash } from '@open-mercato/ui/backend/FlashMessages'\nimport { apiCallOrThrow } from '@open-mercato/ui/backend/utils/apiCall'\nimport { normalizeCrudServerError } from '@open-mercato/ui/backend/utils/serverErrors'\nimport { AccountForm, type AccountFormValues } from '../../../../components/AccountForm'\n\n/**\n * `/backend/billing/accounts/create` \u2014 create a Billing Account.\n *\n * POSTs `/api/billing/accounts`. On success, flash + navigate to the\n * new account's detail page (`/backend/billing/accounts/<id>`) so the\n * operator can continue editing if they need to tweak after-creation\n * details.\n */\nexport default function CreateBillingAccountPage() {\n const t = useT()\n const router = useRouter()\n const [submitting, setSubmitting] = React.useState(false)\n\n const handleSubmit = React.useCallback(\n async (values: AccountFormValues) => {\n setSubmitting(true)\n try {\n const payload: Record<string, unknown> = {\n customerId: values.customerId.trim(),\n name: values.name.trim(),\n currencyCode: values.currencyCode.trim().toUpperCase(),\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 billingMode: values.billingMode,\n }\n if (values.taxId.trim()) payload.taxId = values.taxId.trim()\n const creditLimit = Number.parseFloat(values.creditLimit)\n if (Number.isFinite(creditLimit) && creditLimit >= 0) payload.creditLimit = creditLimit\n if (values.billingMode === 'prepaid' && values.lowBalanceThreshold.trim()) {\n const threshold = Number.parseFloat(values.lowBalanceThreshold)\n if (Number.isFinite(threshold) && threshold >= 0) payload.lowBalanceThreshold = threshold\n }\n\n const call = await apiCallOrThrow<{ id: string }>('/api/billing/accounts', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(payload),\n })\n const id = call.result?.id\n flash(t('billing.accounts.create.success', 'Billing account created'), 'success')\n if (id) {\n router.push(`/backend/billing/accounts/${id}`)\n } else {\n router.push('/backend/billing/accounts')\n }\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(\n detailed || t('billing.accounts.create.error', 'Failed to create account'),\n 'error',\n )\n } finally {\n setSubmitting(false)\n }\n },\n [router, t],\n )\n\n const handleCancel = React.useCallback(() => {\n router.push('/backend/billing/accounts')\n }, [router])\n\n return (\n <Page>\n <PageHeader title={t('billing.accounts.create.title', 'Create Billing Account')} />\n <PageBody>\n <AccountForm\n mode=\"create\"\n submitting={submitting}\n onSubmit={handleSubmit}\n onCancel={handleCancel}\n />\n </PageBody>\n </Page>\n )\n}\n"],
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["\"use client\"\nimport * as React from 'react'\nimport { useRouter } from 'next/navigation'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport { Page, PageBody, PageHeader } from '@open-mercato/ui/backend/Page'\nimport { flash } from '@open-mercato/ui/backend/FlashMessages'\nimport { apiCallOrThrow } from '@open-mercato/ui/backend/utils/apiCall'\nimport { normalizeCrudServerError } from '@open-mercato/ui/backend/utils/serverErrors'\nimport { AccountForm, type AccountFormValues } from '../../../../components/AccountForm'\n\n/**\n * `/backend/billing/accounts/create` \u2014 create a Billing Account.\n *\n * POSTs `/api/billing/accounts`. On success, flash + navigate to the\n * new account's detail page (`/backend/billing/accounts/<id>`) so the\n * operator can continue editing if they need to tweak after-creation\n * details.\n */\nexport default function CreateBillingAccountPage() {\n const t = useT()\n const router = useRouter()\n const [submitting, setSubmitting] = React.useState(false)\n\n const handleSubmit = React.useCallback(\n async (values: AccountFormValues) => {\n setSubmitting(true)\n try {\n const payload: Record<string, unknown> = {\n customerId: values.customerId.trim(),\n customerKind: values.customerKind,\n name: values.name.trim(),\n currencyCode: values.currencyCode.trim().toUpperCase(),\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 billingMode: values.billingMode,\n }\n if (values.taxId.trim()) payload.taxId = values.taxId.trim()\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 if (values.paymentTermsDays.trim() && Number.isInteger(termsDays) && termsDays >= 0) {\n payload.paymentTermsDays = termsDays\n }\n payload.autoSendInvoice = values.autoSendInvoice\n if (values.billingMode === 'prepaid' && values.lowBalanceThreshold.trim()) {\n const threshold = Number.parseFloat(values.lowBalanceThreshold)\n if (Number.isFinite(threshold) && threshold >= 0) payload.lowBalanceThreshold = threshold\n }\n\n const call = await apiCallOrThrow<{ id: string }>('/api/billing/accounts', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(payload),\n })\n const id = call.result?.id\n flash(t('billing.accounts.create.success', 'Billing account created'), 'success')\n if (id) {\n router.push(`/backend/billing/accounts/${id}`)\n } else {\n router.push('/backend/billing/accounts')\n }\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(\n detailed || t('billing.accounts.create.error', 'Failed to create account'),\n 'error',\n )\n } finally {\n setSubmitting(false)\n }\n },\n [router, t],\n )\n\n const handleCancel = React.useCallback(() => {\n router.push('/backend/billing/accounts')\n }, [router])\n\n return (\n <Page>\n <PageHeader title={t('billing.accounts.create.title', 'Create Billing Account')} />\n <PageBody>\n <AccountForm\n mode=\"create\"\n submitting={submitting}\n onSubmit={handleSubmit}\n onCancel={handleCancel}\n />\n </PageBody>\n </Page>\n )\n}\n"],
|
|
5
|
+
"mappings": ";AAqGI,SACE,KADF;AApGJ,YAAY,WAAW;AACvB,SAAS,iBAAiB;AAC1B,SAAS,Y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AG,CAAC,MAAM,CAAC;AAEX,SACE,qBAAC,QACC;AAAA,wBAAC,cAAW,OAAO,EAAE,iCAAiC,wBAAwB,GAAG;AAAA,IACjF,oBAAC,YACC;AAAA,MAAC;AAAA;AAAA,QACC,MAAK;AAAA,QACL;AAAA,QACA,UAAU;AAAA,QACV,UAAU;AAAA;AAAA,IACZ,GACF;AAAA,KACF;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -6,10 +6,12 @@ import { useRouter } from "next/navigation";
|
|
|
6
6
|
import { Plus } from "lucide-react";
|
|
7
7
|
import { useT } from "@open-mercato/shared/lib/i18n/context";
|
|
8
8
|
import { Page, PageBody } from "@open-mercato/ui/backend/Page";
|
|
9
|
-
import { DataTable } from "
|
|
9
|
+
import { BillingDataTable as DataTable } from "../../../components/BillingDataTable.js";
|
|
10
10
|
import { Tag } from "@open-mercato/ui/primitives/tag";
|
|
11
11
|
import { Button } from "@open-mercato/ui/primitives/button";
|
|
12
12
|
import { readApiResultOrThrow } from "@open-mercato/ui/backend/utils/apiCall";
|
|
13
|
+
import { CustomerLabel } from "../../../components/CustomerLabel.js";
|
|
14
|
+
import { fetchCustomerNames } from "../../../components/customerNames.js";
|
|
13
15
|
function formatDate(value) {
|
|
14
16
|
if (!value) return "\u2014";
|
|
15
17
|
const parsed = new Date(value);
|
|
@@ -26,6 +28,7 @@ function BillingAccountsListPage() {
|
|
|
26
28
|
const [total, setTotal] = React.useState(0);
|
|
27
29
|
const [totalPages, setTotalPages] = React.useState(1);
|
|
28
30
|
const [loading, setLoading] = React.useState(true);
|
|
31
|
+
const [customerNames, setCustomerNames] = React.useState({});
|
|
29
32
|
const filterDefs = React.useMemo(
|
|
30
33
|
() => [
|
|
31
34
|
{
|
|
@@ -44,6 +47,15 @@ function BillingAccountsListPage() {
|
|
|
44
47
|
label: t("billing.accounts.filters.currency", "Currency"),
|
|
45
48
|
type: "text"
|
|
46
49
|
},
|
|
50
|
+
{
|
|
51
|
+
id: "customerKind",
|
|
52
|
+
label: t("billing.accounts.filters.customer_kind", "Customer type"),
|
|
53
|
+
type: "select",
|
|
54
|
+
options: [
|
|
55
|
+
{ value: "company", label: t("billing.accounts.kind.company", "Company") },
|
|
56
|
+
{ value: "person", label: t("billing.accounts.kind.person", "Person") }
|
|
57
|
+
]
|
|
58
|
+
},
|
|
47
59
|
{
|
|
48
60
|
id: "billingMode",
|
|
49
61
|
label: t("billing.accounts.columns.mode", "Mode"),
|
|
@@ -53,6 +65,12 @@ function BillingAccountsListPage() {
|
|
|
53
65
|
{ value: "prepaid", label: t("billing.mode.prepaid", "Prepaid") }
|
|
54
66
|
]
|
|
55
67
|
},
|
|
68
|
+
{
|
|
69
|
+
id: "hasOverdue",
|
|
70
|
+
label: t("billing.accounts.filters.has_overdue", "Has overdue"),
|
|
71
|
+
type: "select",
|
|
72
|
+
options: [{ value: "true", label: t("billing.common.yes", "Yes") }]
|
|
73
|
+
},
|
|
56
74
|
{
|
|
57
75
|
id: "isActive",
|
|
58
76
|
label: t("billing.accounts.filters.active", "Active"),
|
|
@@ -84,14 +102,22 @@ function BillingAccountsListPage() {
|
|
|
84
102
|
if (typeof filters.billingMode === "string" && filters.billingMode) {
|
|
85
103
|
params.set("billingMode", filters.billingMode);
|
|
86
104
|
}
|
|
105
|
+
if (typeof filters.customerKind === "string" && filters.customerKind) {
|
|
106
|
+
params.set("customerKind", filters.customerKind);
|
|
107
|
+
}
|
|
108
|
+
if (filters.hasOverdue === "true") params.set("hasOverdue", "true");
|
|
87
109
|
if (filters.isActive === "true") params.set("isActive", "true");
|
|
88
110
|
if (filters.isActive === "false") params.set("isActive", "false");
|
|
89
111
|
const result = await readApiResultOrThrow(
|
|
90
112
|
`/api/billing/accounts?${params.toString()}`
|
|
91
113
|
);
|
|
92
|
-
|
|
114
|
+
const items = result.items ?? [];
|
|
115
|
+
setRows(items);
|
|
93
116
|
setTotal(result.total ?? 0);
|
|
94
117
|
setTotalPages(result.totalPages ?? 1);
|
|
118
|
+
void fetchCustomerNames(
|
|
119
|
+
items.map((row) => ({ customerId: row.customer_id, customerKind: row.customer_kind }))
|
|
120
|
+
).then(setCustomerNames);
|
|
95
121
|
} finally {
|
|
96
122
|
setLoading(false);
|
|
97
123
|
}
|
|
@@ -99,7 +125,9 @@ function BillingAccountsListPage() {
|
|
|
99
125
|
filters.billCycle,
|
|
100
126
|
filters.currencyCode,
|
|
101
127
|
filters.billingMode,
|
|
128
|
+
filters.customerKind,
|
|
102
129
|
filters.isActive,
|
|
130
|
+
filters.hasOverdue,
|
|
103
131
|
page,
|
|
104
132
|
pageSize,
|
|
105
133
|
search
|
|
@@ -117,7 +145,14 @@ function BillingAccountsListPage() {
|
|
|
117
145
|
{
|
|
118
146
|
accessorKey: "customer_id",
|
|
119
147
|
header: t("billing.accounts.columns.customer", "Customer"),
|
|
120
|
-
cell: ({ row }) => /* @__PURE__ */ jsx(
|
|
148
|
+
cell: ({ row }) => /* @__PURE__ */ jsx(
|
|
149
|
+
CustomerLabel,
|
|
150
|
+
{
|
|
151
|
+
customerId: row.original.customer_id,
|
|
152
|
+
customerKind: row.original.customer_kind ?? "company",
|
|
153
|
+
name: customerNames[row.original.customer_id]?.name
|
|
154
|
+
}
|
|
155
|
+
)
|
|
121
156
|
},
|
|
122
157
|
{
|
|
123
158
|
accessorKey: "currency_code",
|
|
@@ -149,13 +184,37 @@ function BillingAccountsListPage() {
|
|
|
149
184
|
header: t("billing.accounts.columns.last_bill", "Last bill"),
|
|
150
185
|
cell: ({ row }) => formatDate(row.original.last_bill_date)
|
|
151
186
|
},
|
|
187
|
+
{
|
|
188
|
+
accessorKey: "balance_due",
|
|
189
|
+
header: t("billing.accounts.columns.balance_due", "Balance due"),
|
|
190
|
+
cell: ({ row }) => row.original.billing_mode === "prepaid" ? /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: "\u2014" }) : /* @__PURE__ */ jsxs("span", { className: "tabular-nums", children: [
|
|
191
|
+
Number(row.original.balance_due ?? 0).toFixed(2),
|
|
192
|
+
" ",
|
|
193
|
+
row.original.currency_code
|
|
194
|
+
] })
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
accessorKey: "overdue_amount",
|
|
198
|
+
header: t("billing.accounts.columns.overdue", "Overdue"),
|
|
199
|
+
cell: ({ row }) => {
|
|
200
|
+
const overdue = Number(row.original.overdue_amount ?? 0);
|
|
201
|
+
if (row.original.billing_mode === "prepaid" || !(overdue > 0)) {
|
|
202
|
+
return /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: "\u2014" });
|
|
203
|
+
}
|
|
204
|
+
return /* @__PURE__ */ jsxs("span", { className: "font-medium tabular-nums text-status-error-text", children: [
|
|
205
|
+
overdue.toFixed(2),
|
|
206
|
+
" ",
|
|
207
|
+
row.original.currency_code
|
|
208
|
+
] });
|
|
209
|
+
}
|
|
210
|
+
},
|
|
152
211
|
{
|
|
153
212
|
accessorKey: "is_active",
|
|
154
213
|
header: t("billing.accounts.columns.status", "Status"),
|
|
155
214
|
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") })
|
|
156
215
|
}
|
|
157
216
|
],
|
|
158
|
-
[t]
|
|
217
|
+
[customerNames, t]
|
|
159
218
|
);
|
|
160
219
|
return /* @__PURE__ */ jsx(Page, { children: /* @__PURE__ */ jsx(PageBody, { children: /* @__PURE__ */ jsx(
|
|
161
220
|
DataTable,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/modules/billing/backend/billing/accounts/page.tsx"],
|
|
4
|
-
"sourcesContent": ["\"use client\"\nimport * as React from 'react'\nimport Link from 'next/link'\nimport { useRouter } from 'next/navigation'\nimport { Plus } from 'lucide-react'\nimport type { LegacyColumnDef as ColumnDef } from '@tanstack/react-table/legacy'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport type { FilterDef, FilterValues } from '@open-mercato/ui/backend/FilterBar'\nimport { Page, PageBody } from '@open-mercato/ui/backend/Page'\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 { readApiResultOrThrow } from '@open-mercato/ui/backend/utils/apiCall'\n\n/**\n * Billing Accounts admin list.\n *\n * Search + filter by bill cycle / currency / active state. The\n * \"New account\" CTA opens the create page; rows link into the detail\n * page for inspect + edit + soft-delete.\n */\n\n// API list rows are snake_case \u2014 the billing list endpoints project\n// raw column names (see `api/accounts/route.ts` `fields`).\ntype BillingAccountRow = {\n id: string\n customer_id: string\n name: string\n currency_code: string\n bill_cycle: 'monthly' | 'quarterly' | 'annually' | 'weekly'\n bill_cycle_anchor: string\n invoice_email: string\n next_bill_date: string\n last_bill_date: string | null\n billing_mode: 'postpaid' | 'prepaid'\n is_active: boolean\n created_at: string\n}\n\ntype ListResponse = {\n items: BillingAccountRow[]\n total: number\n totalPages: number\n}\n\nfunction formatDate(value: string | null | undefined): string {\n if (!value) return '\u2014'\n const parsed = new Date(value)\n return Number.isNaN(parsed.getTime()) ? value : parsed.toLocaleDateString()\n}\n\nexport default function BillingAccountsListPage() {\n const t = useT()\n const router = useRouter()\n const [rows, setRows] = React.useState<BillingAccountRow[]>([])\n const [page, setPage] = React.useState(1)\n const [pageSize] = React.useState(25)\n const [filters, setFilters] = React.useState<FilterValues>({})\n const [search, setSearch] = React.useState('')\n const [total, setTotal] = React.useState(0)\n const [totalPages, setTotalPages] = React.useState(1)\n const [loading, setLoading] = React.useState(true)\n\n const filterDefs = React.useMemo<FilterDef[]>(\n () => [\n {\n id: 'billCycle',\n label: t('billing.accounts.filters.cycle', 'Bill cycle'),\n type: 'select',\n options: [\n { value: 'weekly', label: t('billing.cycle.weekly', 'Weekly') },\n { value: 'monthly', label: t('billing.cycle.monthly', 'Monthly') },\n { value: 'quarterly', label: t('billing.cycle.quarterly', 'Quarterly') },\n { value: 'annually', label: t('billing.cycle.annually', 'Annually') },\n ],\n },\n {\n id: 'currencyCode',\n label: t('billing.accounts.filters.currency', 'Currency'),\n type: 'text',\n },\n {\n id: 'billingMode',\n label: t('billing.accounts.columns.mode', 'Mode'),\n type: 'select',\n options: [\n { value: 'postpaid', label: t('billing.mode.postpaid', 'Postpaid') },\n { value: 'prepaid', label: t('billing.mode.prepaid', 'Prepaid') },\n ],\n },\n {\n id: 'isActive',\n label: t('billing.accounts.filters.active', 'Active'),\n type: 'select',\n options: [\n { value: 'true', label: t('billing.common.active', 'Active') },\n { value: 'false', label: t('billing.common.inactive', 'Inactive') },\n ],\n },\n ],\n [t],\n )\n\n const loadRows = React.useCallback(async () => {\n setLoading(true)\n try {\n const params = new URLSearchParams({\n page: String(page),\n pageSize: String(pageSize),\n sortField: 'createdAt',\n sortDir: 'desc',\n })\n if (search.trim()) params.set('search', search.trim())\n if (typeof filters.billCycle === 'string' && filters.billCycle) {\n params.set('billCycle', filters.billCycle)\n }\n if (typeof filters.currencyCode === 'string' && filters.currencyCode.trim()) {\n params.set('currencyCode', filters.currencyCode.trim().toUpperCase())\n }\n if (typeof filters.billingMode === 'string' && filters.billingMode) {\n params.set('billingMode', filters.billingMode)\n }\n if (filters.isActive === 'true') params.set('isActive', 'true')\n if (filters.isActive === 'false') params.set('isActive', 'false')\n const result = await readApiResultOrThrow<ListResponse>(\n `/api/billing/accounts?${params.toString()}`,\n )\n setRows(result.items ?? [])\n setTotal(result.total ?? 0)\n setTotalPages(result.totalPages ?? 1)\n } finally {\n setLoading(false)\n }\n }, [\n filters.billCycle,\n filters.currencyCode,\n filters.billingMode,\n filters.isActive,\n page,\n pageSize,\n search,\n ])\n\n React.useEffect(() => {\n void loadRows()\n }, [loadRows])\n\n const columns = React.useMemo<ColumnDef<BillingAccountRow>[]>(\n () => [\n {\n accessorKey: 'name',\n header: t('billing.accounts.columns.name', 'Name'),\n cell: ({ row }) => (\n <span className=\"text-sm font-medium text-primary\">{row.original.name}</span>\n ),\n },\n {\n accessorKey: 'customer_id',\n header: t('billing.accounts.columns.customer', 'Customer'),\n cell: ({ row }) => (\n <span className=\"font-mono text-xs\">{row.original.customer_id}</span>\n ),\n },\n {\n accessorKey: 'currency_code',\n header: t('billing.accounts.columns.currency', 'Currency'),\n },\n {\n accessorKey: 'bill_cycle',\n header: t('billing.accounts.columns.cycle', 'Cycle'),\n cell: ({ row }) => (\n <span>\n {row.original.bill_cycle}\n <span className=\"text-muted-foreground\"> \u00B7 {row.original.bill_cycle_anchor}</span>\n </span>\n ),\n },\n {\n accessorKey: 'billing_mode',\n header: t('billing.accounts.columns.mode', 'Mode'),\n cell: ({ row }) =>\n row.original.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 },\n {\n accessorKey: 'next_bill_date',\n header: t('billing.accounts.columns.next_bill', 'Next bill'),\n cell: ({ row }) => formatDate(row.original.next_bill_date),\n },\n {\n accessorKey: 'last_bill_date',\n header: t('billing.accounts.columns.last_bill', 'Last bill'),\n cell: ({ row }) => formatDate(row.original.last_bill_date),\n },\n {\n accessorKey: 'is_active',\n header: t('billing.accounts.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 <Page>\n <PageBody>\n <DataTable\n title={t('billing.accounts.title', 'Billing Accounts')}\n actions={\n <Button asChild>\n <Link href=\"/backend/billing/accounts/create\">\n <Plus size={16} />\n {t('billing.accounts.create.action', 'New account')}\n </Link>\n </Button>\n }\n refreshButton={{\n label: t('billing.common.refresh', 'Refresh'),\n onRefresh: loadRows,\n isRefreshing: loading,\n }}\n columnChooser={{ auto: true }}\n perspective={{ tableId: 'billing-accounts' }}\n columns={columns}\n data={rows}\n onRowClick={(row) => router.push(`/backend/billing/accounts/${row.id}`)}\n isLoading={loading}\n pagination={{\n page,\n pageSize,\n total,\n totalPages,\n onPageChange: setPage,\n }}\n filters={filterDefs}\n filterValues={filters}\n onFiltersApply={setFilters}\n onFiltersClear={() => setFilters({})}\n searchValue={search}\n onSearchChange={setSearch}\n />\n </PageBody>\n </Page>\n )\n}\n"],
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["\"use client\"\nimport * as React from 'react'\nimport Link from 'next/link'\nimport { useRouter } from 'next/navigation'\nimport { Plus } from 'lucide-react'\nimport type { LegacyColumnDef as ColumnDef } from '@tanstack/react-table/legacy'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport type { FilterDef, FilterValues } from '@open-mercato/ui/backend/FilterBar'\nimport { Page, PageBody } from '@open-mercato/ui/backend/Page'\nimport { BillingDataTable as DataTable } from '../../../components/BillingDataTable'\nimport { Tag } from '@open-mercato/ui/primitives/tag'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { readApiResultOrThrow } from '@open-mercato/ui/backend/utils/apiCall'\nimport { CustomerLabel } from '../../../components/CustomerLabel'\nimport { fetchCustomerNames } from '../../../components/customerNames'\nimport type { CustomerSummary } from '../../../lib/customerLookup'\n\n/**\n * Billing Accounts admin list.\n *\n * Search + filter by bill cycle / currency / active state. The\n * \"New account\" CTA opens the create page; rows link into the detail\n * page for inspect + edit + soft-delete.\n */\n\n// API list rows are snake_case \u2014 the billing list endpoints project\n// raw column names (see `api/accounts/route.ts` `fields`).\ntype BillingAccountRow = {\n id: string\n customer_id: string\n customer_kind: 'company' | 'person'\n name: string\n currency_code: string\n bill_cycle: 'monthly' | 'quarterly' | 'annually' | 'weekly'\n bill_cycle_anchor: string\n invoice_email: string\n next_bill_date: string\n last_bill_date: string | null\n billing_mode: 'postpaid' | 'prepaid'\n // Spec F (F8): open receivables and the overdue subset.\n balance_due?: string\n overdue_amount?: string\n is_active: boolean\n created_at: string\n}\n\ntype ListResponse = {\n items: BillingAccountRow[]\n total: number\n totalPages: number\n}\n\nfunction formatDate(value: string | null | undefined): string {\n if (!value) return '\u2014'\n const parsed = new Date(value)\n return Number.isNaN(parsed.getTime()) ? value : parsed.toLocaleDateString()\n}\n\nexport default function BillingAccountsListPage() {\n const t = useT()\n const router = useRouter()\n const [rows, setRows] = React.useState<BillingAccountRow[]>([])\n const [page, setPage] = React.useState(1)\n const [pageSize] = React.useState(25)\n const [filters, setFilters] = React.useState<FilterValues>({})\n const [search, setSearch] = React.useState('')\n const [total, setTotal] = React.useState(0)\n const [totalPages, setTotalPages] = React.useState(1)\n const [loading, setLoading] = React.useState(true)\n const [customerNames, setCustomerNames] = React.useState<Record<string, CustomerSummary>>({})\n\n const filterDefs = React.useMemo<FilterDef[]>(\n () => [\n {\n id: 'billCycle',\n label: t('billing.accounts.filters.cycle', 'Bill cycle'),\n type: 'select',\n options: [\n { value: 'weekly', label: t('billing.cycle.weekly', 'Weekly') },\n { value: 'monthly', label: t('billing.cycle.monthly', 'Monthly') },\n { value: 'quarterly', label: t('billing.cycle.quarterly', 'Quarterly') },\n { value: 'annually', label: t('billing.cycle.annually', 'Annually') },\n ],\n },\n {\n id: 'currencyCode',\n label: t('billing.accounts.filters.currency', 'Currency'),\n type: 'text',\n },\n {\n id: 'customerKind',\n label: t('billing.accounts.filters.customer_kind', 'Customer type'),\n type: 'select',\n options: [\n { value: 'company', label: t('billing.accounts.kind.company', 'Company') },\n { value: 'person', label: t('billing.accounts.kind.person', 'Person') },\n ],\n },\n {\n id: 'billingMode',\n label: t('billing.accounts.columns.mode', 'Mode'),\n type: 'select',\n options: [\n { value: 'postpaid', label: t('billing.mode.postpaid', 'Postpaid') },\n { value: 'prepaid', label: t('billing.mode.prepaid', 'Prepaid') },\n ],\n },\n {\n id: 'hasOverdue',\n label: t('billing.accounts.filters.has_overdue', 'Has overdue'),\n type: 'select',\n options: [{ value: 'true', label: t('billing.common.yes', 'Yes') }],\n },\n {\n id: 'isActive',\n label: t('billing.accounts.filters.active', 'Active'),\n type: 'select',\n options: [\n { value: 'true', label: t('billing.common.active', 'Active') },\n { value: 'false', label: t('billing.common.inactive', 'Inactive') },\n ],\n },\n ],\n [t],\n )\n\n const loadRows = React.useCallback(async () => {\n setLoading(true)\n try {\n const params = new URLSearchParams({\n page: String(page),\n pageSize: String(pageSize),\n sortField: 'createdAt',\n sortDir: 'desc',\n })\n if (search.trim()) params.set('search', search.trim())\n if (typeof filters.billCycle === 'string' && filters.billCycle) {\n params.set('billCycle', filters.billCycle)\n }\n if (typeof filters.currencyCode === 'string' && filters.currencyCode.trim()) {\n params.set('currencyCode', filters.currencyCode.trim().toUpperCase())\n }\n if (typeof filters.billingMode === 'string' && filters.billingMode) {\n params.set('billingMode', filters.billingMode)\n }\n if (typeof filters.customerKind === 'string' && filters.customerKind) {\n params.set('customerKind', filters.customerKind)\n }\n if (filters.hasOverdue === 'true') params.set('hasOverdue', 'true')\n if (filters.isActive === 'true') params.set('isActive', 'true')\n if (filters.isActive === 'false') params.set('isActive', 'false')\n const result = await readApiResultOrThrow<ListResponse>(\n `/api/billing/accounts?${params.toString()}`,\n )\n const items = result.items ?? []\n setRows(items)\n setTotal(result.total ?? 0)\n setTotalPages(result.totalPages ?? 1)\n // One batched lookup per customer kind for the whole page (no N+1).\n // Names arrive after the rows; until then the raw id is shown.\n void fetchCustomerNames(\n items.map((row) => ({ customerId: row.customer_id, customerKind: row.customer_kind })),\n ).then(setCustomerNames)\n } finally {\n setLoading(false)\n }\n }, [\n filters.billCycle,\n filters.currencyCode,\n filters.billingMode,\n filters.customerKind,\n filters.isActive,\n filters.hasOverdue,\n page,\n pageSize,\n search,\n ])\n\n React.useEffect(() => {\n void loadRows()\n }, [loadRows])\n\n const columns = React.useMemo<ColumnDef<BillingAccountRow>[]>(\n () => [\n {\n accessorKey: 'name',\n header: t('billing.accounts.columns.name', 'Name'),\n cell: ({ row }) => (\n <span className=\"text-sm font-medium text-primary\">{row.original.name}</span>\n ),\n },\n {\n accessorKey: 'customer_id',\n header: t('billing.accounts.columns.customer', 'Customer'),\n cell: ({ row }) => (\n <CustomerLabel\n customerId={row.original.customer_id}\n customerKind={row.original.customer_kind ?? 'company'}\n name={customerNames[row.original.customer_id]?.name}\n />\n ),\n },\n {\n accessorKey: 'currency_code',\n header: t('billing.accounts.columns.currency', 'Currency'),\n },\n {\n accessorKey: 'bill_cycle',\n header: t('billing.accounts.columns.cycle', 'Cycle'),\n cell: ({ row }) => (\n <span>\n {row.original.bill_cycle}\n <span className=\"text-muted-foreground\"> \u00B7 {row.original.bill_cycle_anchor}</span>\n </span>\n ),\n },\n {\n accessorKey: 'billing_mode',\n header: t('billing.accounts.columns.mode', 'Mode'),\n cell: ({ row }) =>\n row.original.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 },\n {\n accessorKey: 'next_bill_date',\n header: t('billing.accounts.columns.next_bill', 'Next bill'),\n cell: ({ row }) => formatDate(row.original.next_bill_date),\n },\n {\n accessorKey: 'last_bill_date',\n header: t('billing.accounts.columns.last_bill', 'Last bill'),\n cell: ({ row }) => formatDate(row.original.last_bill_date),\n },\n {\n accessorKey: 'balance_due',\n header: t('billing.accounts.columns.balance_due', 'Balance due'),\n cell: ({ row }) =>\n row.original.billing_mode === 'prepaid' ? (\n <span className=\"text-muted-foreground\">\u2014</span>\n ) : (\n <span className=\"tabular-nums\">\n {Number(row.original.balance_due ?? 0).toFixed(2)} {row.original.currency_code}\n </span>\n ),\n },\n {\n accessorKey: 'overdue_amount',\n header: t('billing.accounts.columns.overdue', 'Overdue'),\n cell: ({ row }) => {\n const overdue = Number(row.original.overdue_amount ?? 0)\n if (row.original.billing_mode === 'prepaid' || !(overdue > 0)) {\n return <span className=\"text-muted-foreground\">\u2014</span>\n }\n return (\n <span className=\"font-medium tabular-nums text-status-error-text\">\n {overdue.toFixed(2)} {row.original.currency_code}\n </span>\n )\n },\n },\n {\n accessorKey: 'is_active',\n header: t('billing.accounts.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 [customerNames, t],\n )\n\n return (\n <Page>\n <PageBody>\n <DataTable\n title={t('billing.accounts.title', 'Billing Accounts')}\n actions={\n <Button asChild>\n <Link href=\"/backend/billing/accounts/create\">\n <Plus size={16} />\n {t('billing.accounts.create.action', 'New account')}\n </Link>\n </Button>\n }\n refreshButton={{\n label: t('billing.common.refresh', 'Refresh'),\n onRefresh: loadRows,\n isRefreshing: loading,\n }}\n columnChooser={{ auto: true }}\n perspective={{ tableId: 'billing-accounts' }}\n columns={columns}\n data={rows}\n onRowClick={(row) => router.push(`/backend/billing/accounts/${row.id}`)}\n isLoading={loading}\n pagination={{\n page,\n pageSize,\n total,\n totalPages,\n onPageChange: setPage,\n }}\n filters={filterDefs}\n filterValues={filters}\n onFiltersApply={setFilters}\n onFiltersClear={() => setFilters({})}\n searchValue={search}\n onSearchChange={setSearch}\n />\n </PageBody>\n </Page>\n )\n}\n"],
|
|
5
|
+
"mappings": ";AA4LU,cAwBE,YAxBF;AA3LV,YAAY,WAAW;AACvB,OAAO,UAAU;AACjB,SAAS,iBAAiB;AAC1B,SAAS,YAAY;AAErB,SAAS,YAAY;AAErB,SAAS,MAAM,gBAAgB;AAC/B,SAAS,oBAAoB,iBAAiB;AAC9C,SAAS,WAAW;AACpB,SAAS,cAAc;AACvB,SAAS,4BAA4B;AACrC,SAAS,qBAAqB;AAC9B,SAAS,0BAA0B;AAsCnC,SAAS,WAAW,OAA0C;AAC5D,MAAI,CAAC,MAAO,QAAO;AACnB,QAAM,SAAS,IAAI,KAAK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