@dainamite/billing 0.19.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 +172 -0
- package/README.md +14 -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 +16 -12
- 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 +3 -3
- 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 +3 -3
- 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 +3 -3
- 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 +44 -7
- 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 +3 -3
- package/dist/modules/billing/api/runs/retry-failed/route.js.map +2 -2
- package/dist/modules/billing/api/runs/route.js +11 -5
- 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/ce.js.map +2 -2
- 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 +272 -170
- 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 +154 -7
- 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 +615 -59
- 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 +70 -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 +241 -106
- package/dist/modules/billing/lib/billRunEngine.js.map +2 -2
- package/dist/modules/billing/lib/billRunLabel.js.map +1 -1
- 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/tenantLock.js.map +1 -1
- 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/dist/modules/billing/workers/reap-stale-bill-runs.js +2 -2
- package/dist/modules/billing/workers/reap-stale-bill-runs.js.map +2 -2
- package/generated/entities/billing_account/index.ts +26 -0
- package/generated/entities/billing_account_balance/index.ts +13 -0
- package/generated/entities/billing_account_transaction/index.ts +21 -0
- package/generated/entities/billing_account_usage/index.ts +18 -0
- package/generated/entities/billing_allocation/index.ts +18 -0
- package/generated/entities/billing_document_sequence/index.ts +11 -0
- package/generated/entities/billing_draft_invoice_edit/index.ts +14 -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 +26 -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 +20 -0
- package/generated/entities/billing_run_outcome/index.ts +18 -0
- package/generated/entities/billing_settings/index.ts +26 -0
- package/generated/entities/billing_statement/index.ts +22 -0
- package/generated/entities/billing_topup/index.ts +20 -0
- package/generated/entities.ids.generated.ts +35 -0
- package/package.json +15 -10
- 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 +437 -355
- 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 +326 -0
- package/src/modules/billing/__tests__/events.test.ts +142 -0
- 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 +231 -20
- 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 +20 -18
- 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 +3 -3
- package/src/modules/billing/api/invoices/delete-draft/route.ts +33 -0
- package/src/modules/billing/api/invoices/edit-line/route.ts +4 -4
- package/src/modules/billing/api/invoices/post/route.ts +7 -6
- package/src/modules/billing/api/invoices/remove-line/route.ts +3 -3
- 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 +50 -7
- 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 +4 -3
- package/src/modules/billing/api/runs/route.ts +17 -9
- 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 +71 -5
- package/src/modules/billing/backend/billing/invoices/[id]/page.tsx +445 -96
- 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 +19 -3
- 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 +50 -19
- package/src/modules/billing/backend/billing/runs/page.tsx +60 -9
- package/src/modules/billing/backend/billing/statements/[id]/page.tsx +87 -6
- package/src/modules/billing/backend/billing/statements/page.tsx +2 -2
- package/src/modules/billing/backend/billing/topups/page.tsx +2 -2
- package/src/modules/billing/backend/billing/transactions/page.tsx +2 -2
- 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/ce.ts +8 -7
- 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 +371 -238
- 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 +208 -6
- 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 +20 -7
- 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 +685 -15
- package/src/modules/billing/data/entityIds.ts +25 -11
- package/src/modules/billing/data/validators.ts +388 -8
- package/src/modules/billing/events.ts +82 -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 +362 -162
- package/src/modules/billing/lib/billRunLabel.ts +1 -1
- 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 +410 -242
- 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/tenantLock.ts +1 -1
- 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/src/modules/billing/workers/reap-stale-bill-runs.ts +4 -4
- package/dist/modules/billing/lib/invoiceStatus.js +0 -38
- package/dist/modules/billing/lib/invoiceStatus.js.map +0 -7
- package/src/modules/billing/__tests__/lib/invoiceStatus.test.ts +0 -97
- package/src/modules/billing/lib/invoiceStatus.ts +0 -61
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { Send } from "lucide-react";
|
|
5
|
+
import { useT } from "@open-mercato/shared/lib/i18n/context";
|
|
6
|
+
import { Button } from "@open-mercato/ui/primitives/button";
|
|
7
|
+
import { flash } from "@open-mercato/ui/backend/FlashMessages";
|
|
8
|
+
import { useConfirmDialog } from "@open-mercato/ui/backend/confirm-dialog";
|
|
9
|
+
import { apiCallOrThrow, readApiResultOrThrow } from "@open-mercato/ui/backend/utils/apiCall";
|
|
10
|
+
import { normalizeCrudServerError } from "@open-mercato/ui/backend/utils/serverErrors";
|
|
11
|
+
const BATCH_SIZE = 25;
|
|
12
|
+
function PostRunDraftsButton({ runId, onPosted }) {
|
|
13
|
+
const t = useT();
|
|
14
|
+
const { confirm, ConfirmDialogElement } = useConfirmDialog();
|
|
15
|
+
const [draftCount, setDraftCount] = React.useState(null);
|
|
16
|
+
const [progress, setProgress] = React.useState(null);
|
|
17
|
+
const loadCount = React.useCallback(async () => {
|
|
18
|
+
try {
|
|
19
|
+
const params = new URLSearchParams({ billRunId: runId, status: "draft", testRun: "false", pageSize: "1" });
|
|
20
|
+
const result = await readApiResultOrThrow(`/api/billing/invoices?${params.toString()}`);
|
|
21
|
+
setDraftCount(result.total ?? 0);
|
|
22
|
+
} catch {
|
|
23
|
+
setDraftCount(0);
|
|
24
|
+
}
|
|
25
|
+
}, [runId]);
|
|
26
|
+
React.useEffect(() => {
|
|
27
|
+
void loadCount();
|
|
28
|
+
}, [loadCount]);
|
|
29
|
+
const handlePost = React.useCallback(async () => {
|
|
30
|
+
if (!draftCount) return;
|
|
31
|
+
const ok = await confirm({
|
|
32
|
+
title: t("billing.runs.post.confirm.title", "Post the draft invoices of this run?"),
|
|
33
|
+
text: `${t(
|
|
34
|
+
"billing.runs.post.confirm.text",
|
|
35
|
+
"Each draft gets its final number, due date and frozen PDF; invoices set to auto-send are emailed. Posted invoices cannot be edited. Drafts:"
|
|
36
|
+
)} ${draftCount}`,
|
|
37
|
+
confirmText: t("billing.runs.post.confirm.button", "Post invoices")
|
|
38
|
+
});
|
|
39
|
+
if (!ok) return;
|
|
40
|
+
const total = draftCount;
|
|
41
|
+
let done = 0;
|
|
42
|
+
let posted = 0;
|
|
43
|
+
const failed = [];
|
|
44
|
+
let cursor = null;
|
|
45
|
+
let stoppedReason = null;
|
|
46
|
+
setProgress({ done, total });
|
|
47
|
+
try {
|
|
48
|
+
for (let guard = 0; guard <= Math.ceil(total / BATCH_SIZE) + 1; guard += 1) {
|
|
49
|
+
const call = await apiCallOrThrow(
|
|
50
|
+
`/api/billing/runs/${encodeURIComponent(runId)}/post-drafts`,
|
|
51
|
+
{
|
|
52
|
+
method: "POST",
|
|
53
|
+
headers: { "Content-Type": "application/json" },
|
|
54
|
+
body: JSON.stringify({ limit: BATCH_SIZE, ...cursor ? { afterInvoiceId: cursor } : {} })
|
|
55
|
+
}
|
|
56
|
+
);
|
|
57
|
+
const batch = call.result;
|
|
58
|
+
if (!batch) break;
|
|
59
|
+
posted += batch.posted;
|
|
60
|
+
failed.push(...batch.failed);
|
|
61
|
+
done += batch.posted + batch.failed.length;
|
|
62
|
+
setProgress({ done: Math.min(done, total), total });
|
|
63
|
+
if (batch.stoppedReason) {
|
|
64
|
+
stoppedReason = batch.stoppedReason;
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
if (batch.remaining === 0 || !batch.nextCursor || batch.nextCursor === cursor) break;
|
|
68
|
+
cursor = batch.nextCursor;
|
|
69
|
+
}
|
|
70
|
+
if (stoppedReason === "billing.settings.incomplete") {
|
|
71
|
+
flash(
|
|
72
|
+
t("billing.invoices.post.settings_incomplete", "Fill in the seller details in Settings \u2192 Billing before posting invoices."),
|
|
73
|
+
"error"
|
|
74
|
+
);
|
|
75
|
+
} else if (failed.length > 0) {
|
|
76
|
+
const sample = failed.slice(0, 3).map((f) => `${f.number}: ${f.error}`).join("; ");
|
|
77
|
+
flash(
|
|
78
|
+
`${t("billing.runs.post.partial", "Posted")} ${posted} \xB7 ${t("billing.runs.post.failed", "failed")} ${failed.length} \u2014 ${sample}`,
|
|
79
|
+
"warning"
|
|
80
|
+
);
|
|
81
|
+
} else {
|
|
82
|
+
flash(`${t("billing.runs.post.success", "Invoices posted")}: ${posted}`, "success");
|
|
83
|
+
}
|
|
84
|
+
} catch (err) {
|
|
85
|
+
const { message } = normalizeCrudServerError(err);
|
|
86
|
+
flash(message || t("billing.runs.post.error", "Posting failed"), "error");
|
|
87
|
+
} finally {
|
|
88
|
+
setProgress(null);
|
|
89
|
+
void loadCount();
|
|
90
|
+
onPosted();
|
|
91
|
+
}
|
|
92
|
+
}, [confirm, draftCount, onPosted, runId, t]);
|
|
93
|
+
if (!draftCount && !progress) return ConfirmDialogElement;
|
|
94
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
95
|
+
/* @__PURE__ */ jsxs(Button, { type: "button", onClick: () => void handlePost(), disabled: progress !== null, children: [
|
|
96
|
+
/* @__PURE__ */ jsx(Send, { size: 16 }),
|
|
97
|
+
progress ? `${t("billing.runs.post.in_progress", "Posting\u2026")} ${progress.done}/${progress.total}` : `${t("billing.runs.post.action", "Post invoices")} (${draftCount})`
|
|
98
|
+
] }),
|
|
99
|
+
ConfirmDialogElement
|
|
100
|
+
] });
|
|
101
|
+
}
|
|
102
|
+
export {
|
|
103
|
+
PostRunDraftsButton
|
|
104
|
+
};
|
|
105
|
+
//# sourceMappingURL=PostRunDraftsButton.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/modules/billing/components/PostRunDraftsButton.tsx"],
|
|
4
|
+
"sourcesContent": ["\"use client\"\nimport * as React from 'react'\nimport { Send } from 'lucide-react'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { flash } from '@open-mercato/ui/backend/FlashMessages'\nimport { useConfirmDialog } from '@open-mercato/ui/backend/confirm-dialog'\nimport { apiCallOrThrow, readApiResultOrThrow } from '@open-mercato/ui/backend/utils/apiCall'\nimport { normalizeCrudServerError } from '@open-mercato/ui/backend/utils/serverErrors'\n\n/**\n * \"Post invoices\" for a REAL Bill Run: posts every draft invoice the run\n * wrote. Batches through `POST /api/billing/runs/{id}/post-drafts` (cursor\n * paging) so large runs never become one long request, showing progress on\n * the button. Renders nothing when the run has no drafts left.\n */\n\ntype BatchResult = {\n posted: number\n failed: Array<{ invoiceId: string; number: string; error: string; code: string | null }>\n nextCursor: string | null\n remaining: number\n stoppedReason: string | null\n}\n\nconst BATCH_SIZE = 25\n\nexport function PostRunDraftsButton({ runId, onPosted }: { runId: string; onPosted: () => void }) {\n const t = useT()\n const { confirm, ConfirmDialogElement } = useConfirmDialog()\n const [draftCount, setDraftCount] = React.useState<number | null>(null)\n const [progress, setProgress] = React.useState<{ done: number; total: number } | null>(null)\n\n const loadCount = React.useCallback(async () => {\n try {\n const params = new URLSearchParams({ billRunId: runId, status: 'draft', testRun: 'false', pageSize: '1' })\n const result = await readApiResultOrThrow<{ total?: number }>(`/api/billing/invoices?${params.toString()}`)\n setDraftCount(result.total ?? 0)\n } catch {\n setDraftCount(0)\n }\n }, [runId])\n\n React.useEffect(() => {\n void loadCount()\n }, [loadCount])\n\n const handlePost = React.useCallback(async () => {\n if (!draftCount) return\n const ok = await confirm({\n title: t('billing.runs.post.confirm.title', 'Post the draft invoices of this run?'),\n text: `${t(\n 'billing.runs.post.confirm.text',\n 'Each draft gets its final number, due date and frozen PDF; invoices set to auto-send are emailed. Posted invoices cannot be edited. Drafts:',\n )} ${draftCount}`,\n confirmText: t('billing.runs.post.confirm.button', 'Post invoices'),\n })\n if (!ok) return\n const total = draftCount\n let done = 0\n let posted = 0\n const failed: BatchResult['failed'] = []\n let cursor: string | null = null\n let stoppedReason: string | null = null\n setProgress({ done, total })\n try {\n // Bounded by the draft count: every batch advances the cursor or stops.\n for (let guard = 0; guard <= Math.ceil(total / BATCH_SIZE) + 1; guard += 1) {\n const call: { result?: BatchResult | null } = await apiCallOrThrow<BatchResult>(\n `/api/billing/runs/${encodeURIComponent(runId)}/post-drafts`,\n {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ limit: BATCH_SIZE, ...(cursor ? { afterInvoiceId: cursor } : {}) }),\n },\n )\n const batch = call.result\n if (!batch) break\n posted += batch.posted\n failed.push(...batch.failed)\n done += batch.posted + batch.failed.length\n setProgress({ done: Math.min(done, total), total })\n if (batch.stoppedReason) {\n stoppedReason = batch.stoppedReason\n break\n }\n if (batch.remaining === 0 || !batch.nextCursor || batch.nextCursor === cursor) break\n cursor = batch.nextCursor\n }\n if (stoppedReason === 'billing.settings.incomplete') {\n flash(\n t('billing.invoices.post.settings_incomplete', 'Fill in the seller details in Settings \u2192 Billing before posting invoices.'),\n 'error',\n )\n } else if (failed.length > 0) {\n const sample = failed\n .slice(0, 3)\n .map((f) => `${f.number}: ${f.error}`)\n .join('; ')\n flash(\n `${t('billing.runs.post.partial', 'Posted')} ${posted} \u00B7 ${t('billing.runs.post.failed', 'failed')} ${failed.length} \u2014 ${sample}`,\n 'warning',\n )\n } else {\n flash(`${t('billing.runs.post.success', 'Invoices posted')}: ${posted}`, 'success')\n }\n } catch (err) {\n const { message } = normalizeCrudServerError(err)\n flash(message || t('billing.runs.post.error', 'Posting failed'), 'error')\n } finally {\n setProgress(null)\n void loadCount()\n onPosted()\n }\n }, [confirm, draftCount, onPosted, runId, t])\n\n if (!draftCount && !progress) return ConfirmDialogElement\n return (\n <>\n <Button type=\"button\" onClick={() => void handlePost()} disabled={progress !== null}>\n <Send size={16} />\n {progress\n ? `${t('billing.runs.post.in_progress', 'Posting\u2026')} ${progress.done}/${progress.total}`\n : `${t('billing.runs.post.action', 'Post invoices')} (${draftCount})`}\n </Button>\n {ConfirmDialogElement}\n </>\n )\n}\n"],
|
|
5
|
+
"mappings": ";AAsHI,mBAEI,KADF,YADF;AArHJ,YAAY,WAAW;AACvB,SAAS,YAAY;AACrB,SAAS,YAAY;AACrB,SAAS,cAAc;AACvB,SAAS,aAAa;AACtB,SAAS,wBAAwB;AACjC,SAAS,gBAAgB,4BAA4B;AACrD,SAAS,gCAAgC;AAiBzC,MAAM,aAAa;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;AAChB,WAAK,UAAU;AACf,eAAS;AAAA,IACX;AAAA,EACF,GAAG,CAAC,SAAS,YAAY,UAAU,OAAO,CAAC,CAAC;AAE5C,MAAI,CAAC,cAAc,CAAC,SAAU,QAAO;AACrC,SACE,iCACE;AAAA,yBAAC,UAAO,MAAK,UAAS,SAAS,MAAM,KAAK,WAAW,GAAG,UAAU,aAAa,MAC7E;AAAA,0BAAC,QAAK,MAAM,IAAI;AAAA,MACf,WACG,GAAG,EAAE,iCAAiC,eAAU,CAAC,IAAI,SAAS,IAAI,IAAI,SAAS,KAAK,KACpF,GAAG,EAAE,4BAA4B,eAAe,CAAC,KAAK,UAAU;AAAA,OACtE;AAAA,IACC;AAAA,KACH;AAEJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -4,11 +4,11 @@ import * as React from "react";
|
|
|
4
4
|
import { useRouter } from "next/navigation";
|
|
5
5
|
import { Plus, SlidersHorizontal } from "lucide-react";
|
|
6
6
|
import { useT } from "@open-mercato/shared/lib/i18n/context";
|
|
7
|
-
import { DataTable } from "
|
|
7
|
+
import { BillingDataTable as DataTable } from "./BillingDataTable.js";
|
|
8
8
|
import { Tag } from "@open-mercato/ui/primitives/tag";
|
|
9
9
|
import { Button } from "@open-mercato/ui/primitives/button";
|
|
10
10
|
import { flash } from "@open-mercato/ui/backend/FlashMessages";
|
|
11
|
-
import { apiCallOrThrow, readApiResultOrThrow } from "@open-mercato/ui/backend/utils/apiCall";
|
|
11
|
+
import { apiCall, apiCallOrThrow, readApiResultOrThrow } from "@open-mercato/ui/backend/utils/apiCall";
|
|
12
12
|
import { normalizeCrudServerError } from "@open-mercato/ui/backend/utils/serverErrors";
|
|
13
13
|
import { StatCard, Stat } from "./DetailFields.js";
|
|
14
14
|
function balanceVariant(status) {
|
|
@@ -51,6 +51,16 @@ function PrepaidPanel({
|
|
|
51
51
|
const [adjAmount, setAdjAmount] = React.useState("");
|
|
52
52
|
const [adjReason, setAdjReason] = React.useState("");
|
|
53
53
|
const [adjSubmitting, setAdjSubmitting] = React.useState(false);
|
|
54
|
+
const [gatewayTopups, setGatewayTopups] = React.useState(false);
|
|
55
|
+
React.useEffect(() => {
|
|
56
|
+
let cancelled = false;
|
|
57
|
+
void apiCall("/api/billing/settings").then((call) => {
|
|
58
|
+
if (!cancelled) setGatewayTopups(call.ok && call.result?.capabilities?.gatewayTopups === true);
|
|
59
|
+
});
|
|
60
|
+
return () => {
|
|
61
|
+
cancelled = true;
|
|
62
|
+
};
|
|
63
|
+
}, []);
|
|
54
64
|
const pageSize = 10;
|
|
55
65
|
const loadStatus = React.useCallback(async () => {
|
|
56
66
|
const [bal, cred] = await Promise.all([
|
|
@@ -227,10 +237,10 @@ function PrepaidPanel({
|
|
|
227
237
|
] }),
|
|
228
238
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
229
239
|
!topupOpen && !adjustOpen ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
230
|
-
/* @__PURE__ */ jsxs(Button, { type: "button", onClick: () => setTopupOpen(true), children: [
|
|
240
|
+
gatewayTopups ? /* @__PURE__ */ jsxs(Button, { type: "button", onClick: () => setTopupOpen(true), children: [
|
|
231
241
|
/* @__PURE__ */ jsx(Plus, { size: 16 }),
|
|
232
242
|
t("billing.prepaid.topup.action", "Top up")
|
|
233
|
-
] }),
|
|
243
|
+
] }) : null,
|
|
234
244
|
/* @__PURE__ */ jsxs(Button, { type: "button", variant: "outline", onClick: () => setAdjustOpen(true), children: [
|
|
235
245
|
/* @__PURE__ */ jsx(SlidersHorizontal, { size: 16 }),
|
|
236
246
|
t("billing.prepaid.adjust.action", "Adjust")
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/modules/billing/components/PrepaidPanel.tsx"],
|
|
4
|
-
"sourcesContent": ["\"use client\"\nimport * as React from 'react'\nimport { useRouter } from 'next/navigation'\nimport { Plus, SlidersHorizontal } from 'lucide-react'\nimport type { ColumnDef } from '@tanstack/react-table'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\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 { flash } from '@open-mercato/ui/backend/FlashMessages'\nimport { apiCallOrThrow, readApiResultOrThrow } from '@open-mercato/ui/backend/utils/apiCall'\nimport { normalizeCrudServerError } from '@open-mercato/ui/backend/utils/serverErrors'\nimport { StatCard, Stat } from './DetailFields'\n\n/**\n * Prepaid panel (SPEC-002 P4) injected into the Billing Account detail page\n * for `billing_mode='prepaid'` accounts: balance + status, credit status,\n * a top-up launcher, and the recent balance transactions.\n */\n\ntype BalanceSnapshot = {\n balance: string\n balanceStatus: 'ok' | 'low' | 'exhausted'\n lowBalanceThreshold: string\n lastMovementAt: string | null\n}\n\ntype CreditSnapshot = {\n mode: string\n creditLimit: string\n creditUsed: string\n availableCredit: string\n creditStatus: 'within_limit' | 'near_limit' | 'over_limit'\n}\n\ntype TransactionRow = {\n id: string\n type: string\n amount: string\n balance_after: string\n description: string\n created_at: string\n}\n\nfunction balanceVariant(status: string): 'success' | 'warning' | 'error' {\n if (status === 'low') return 'warning'\n if (status === 'exhausted') return 'error'\n return 'success'\n}\n\nfunction creditVariant(status: string): 'success' | 'warning' | 'error' {\n if (status === 'near_limit') return 'warning'\n if (status === 'over_limit') return 'error'\n return 'success'\n}\n\nfunction txnVariant(type: string): 'success' | 'info' | 'neutral' {\n if (type === 'topup' || type === 'adjustment') return 'success'\n if (type === 'usage') return 'info'\n return 'neutral'\n}\n\nfunction formatDateTime(value: string | null | undefined): string {\n if (!value) return '\u2014'\n const d = new Date(value)\n return Number.isNaN(d.getTime()) ? value : d.toLocaleString()\n}\n\nexport function PrepaidPanel({\n accountId,\n currencyCode,\n}: {\n accountId: string\n currencyCode: string\n}) {\n const t = useT()\n const router = useRouter()\n const [balance, setBalance] = React.useState<BalanceSnapshot | null>(null)\n const [credit, setCredit] = React.useState<CreditSnapshot | null>(null)\n const [rows, setRows] = React.useState<TransactionRow[]>([])\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 [topupOpen, setTopupOpen] = React.useState(false)\n const [amount, setAmount] = React.useState('')\n const [submitting, setSubmitting] = React.useState(false)\n const [adjustOpen, setAdjustOpen] = React.useState(false)\n const [adjAmount, setAdjAmount] = React.useState('')\n const [adjReason, setAdjReason] = React.useState('')\n const [adjSubmitting, setAdjSubmitting] = React.useState(false)\n const pageSize = 10\n\n const loadStatus = React.useCallback(async () => {\n const [bal, cred] = await Promise.all([\n readApiResultOrThrow<BalanceSnapshot>(`/api/billing/accounts/${accountId}/balance`),\n readApiResultOrThrow<CreditSnapshot>(`/api/billing/accounts/${accountId}/credit-status`),\n ])\n setBalance(bal)\n setCredit(cred)\n }, [accountId])\n\n const loadTransactions = React.useCallback(async () => {\n setLoading(true)\n try {\n const result = await readApiResultOrThrow<{\n items: TransactionRow[]\n total: number\n totalPages: number\n }>(\n `/api/billing/transactions?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 loadStatus().catch(() => undefined)\n }, [loadStatus])\n React.useEffect(() => {\n void loadTransactions()\n }, [loadTransactions])\n\n const handleTopup = React.useCallback(async () => {\n const value = Number.parseFloat(amount)\n if (!Number.isFinite(value) || value <= 0) {\n flash(t('billing.prepaid.topup.invalid', 'Enter a positive amount'), 'error')\n return\n }\n setSubmitting(true)\n try {\n const res = await apiCallOrThrow<{ redirectUrl?: string | null }>(\n `/api/billing/accounts/${accountId}/topups`,\n {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n amount: value,\n successUrl: typeof window !== 'undefined' ? window.location.href : undefined,\n cancelUrl: typeof window !== 'undefined' ? window.location.href : undefined,\n }),\n },\n )\n const redirectUrl = res.result?.redirectUrl\n if (redirectUrl && typeof window !== 'undefined') {\n window.location.href = redirectUrl\n return\n }\n flash(t('billing.prepaid.topup.created', 'Top-up session created'), 'success')\n setTopupOpen(false)\n setAmount('')\n void loadStatus().catch(() => undefined)\n void loadTransactions()\n } catch (err) {\n const { message } = normalizeCrudServerError(err)\n flash(message || t('billing.prepaid.topup.error', 'Top-up failed'), 'error')\n } finally {\n setSubmitting(false)\n }\n }, [accountId, amount, loadStatus, loadTransactions, t])\n\n const handleAdjust = React.useCallback(async () => {\n const value = Number.parseFloat(adjAmount)\n if (!Number.isFinite(value) || value === 0) {\n flash(t('billing.prepaid.adjust.invalid_amount', 'Enter a non-zero amount'), 'error')\n return\n }\n if (!adjReason.trim()) {\n flash(t('billing.prepaid.adjust.invalid_description', 'Enter a reason'), 'error')\n return\n }\n setAdjSubmitting(true)\n try {\n await apiCallOrThrow('/api/billing/transactions/adjust', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n billAccountId: accountId,\n amount: value,\n description: adjReason.trim(),\n }),\n })\n flash(t('billing.prepaid.adjust.success', 'Balance adjusted'), 'success')\n setAdjustOpen(false)\n setAdjAmount('')\n setAdjReason('')\n void loadStatus().catch(() => undefined)\n void loadTransactions()\n } catch (err) {\n const { message } = normalizeCrudServerError(err)\n flash(message || t('billing.prepaid.adjust.error', 'Adjustment failed'), 'error')\n } finally {\n setAdjSubmitting(false)\n }\n }, [accountId, adjAmount, adjReason, loadStatus, loadTransactions, t])\n\n const columns = React.useMemo<ColumnDef<TransactionRow>[]>(\n () => [\n {\n accessorKey: 'created_at',\n header: t('billing.transactions.columns.when', 'When'),\n cell: ({ row }) => formatDateTime(row.original.created_at),\n },\n {\n accessorKey: 'type',\n header: t('billing.transactions.columns.type', 'Type'),\n cell: ({ row }) => (\n <Tag variant={txnVariant(row.original.type)}>\n {t(`billing.transactions.type.${row.original.type}`, row.original.type)}\n </Tag>\n ),\n },\n {\n accessorKey: 'description',\n header: t('billing.transactions.columns.description', 'Description'),\n cell: ({ row }) => <span className=\"text-sm\">{row.original.description}</span>,\n },\n {\n accessorKey: 'amount',\n header: t('billing.transactions.columns.amount', 'Amount'),\n cell: ({ row }) => (\n <span className=\"font-mono tabular-nums\">{row.original.amount}</span>\n ),\n },\n {\n accessorKey: 'balance_after',\n header: t('billing.transactions.columns.balance_after', 'Balance'),\n cell: ({ row }) => (\n <span className=\"font-mono tabular-nums\">{row.original.balance_after}</span>\n ),\n },\n ],\n [t],\n )\n\n return (\n <div className=\"mt-6 space-y-4\">\n <StatCard title={t('billing.prepaid.panel.title', 'Prepaid balance')}>\n <Stat\n label={t('billing.prepaid.panel.balance', 'Balance')}\n value={\n <span className=\"flex items-center gap-2\">\n <span className=\"font-mono tabular-nums\">\n {balance?.balance ?? '\u2014'} {currencyCode}\n </span>\n {balance ? (\n <Tag variant={balanceVariant(balance.balanceStatus)}>\n {t(`billing.prepaid.status.${balance.balanceStatus}`, balance.balanceStatus)}\n </Tag>\n ) : null}\n </span>\n }\n />\n <Stat\n label={t('billing.prepaid.panel.threshold', 'Low threshold')}\n value={\n <span className=\"font-mono tabular-nums\">{balance?.lowBalanceThreshold ?? '\u2014'}</span>\n }\n />\n {credit ? (\n <Stat\n label={t('billing.prepaid.panel.credit', 'Credit')}\n value={\n <span className=\"flex items-center gap-2\">\n <span className=\"font-mono tabular-nums\">\n {credit.creditUsed} / {credit.creditLimit}\n </span>\n <Tag variant={creditVariant(credit.creditStatus)}>\n {t(`billing.prepaid.credit.${credit.creditStatus}`, credit.creditStatus)}\n </Tag>\n </span>\n }\n />\n ) : null}\n <Stat\n label={t('billing.prepaid.panel.last_movement', 'Last movement')}\n value={formatDateTime(balance?.lastMovementAt)}\n />\n </StatCard>\n\n <div className=\"flex flex-wrap items-center gap-2\">\n {!topupOpen && !adjustOpen ? (\n <>\n <Button type=\"button\" onClick={() => setTopupOpen(true)}>\n <Plus size={16} />\n {t('billing.prepaid.topup.action', 'Top up')}\n </Button>\n <Button type=\"button\" variant=\"outline\" onClick={() => setAdjustOpen(true)}>\n <SlidersHorizontal size={16} />\n {t('billing.prepaid.adjust.action', 'Adjust')}\n </Button>\n </>\n ) : null}\n\n {topupOpen ? (\n <div className=\"flex items-center gap-2\">\n <input\n type=\"number\"\n min=\"0\"\n step=\"0.01\"\n autoFocus\n value={amount}\n onChange={(e) => setAmount(e.target.value)}\n onKeyDown={(e) => {\n if (e.key === 'Enter') void handleTopup()\n if (e.key === 'Escape') setTopupOpen(false)\n }}\n placeholder={t('billing.prepaid.topup.amount', 'Amount')}\n className=\"h-9 w-32 rounded-md border border-border bg-background px-3 text-sm\"\n />\n <Button type=\"button\" onClick={handleTopup} disabled={submitting}>\n {submitting\n ? t('billing.prepaid.topup.submitting', 'Starting\u2026')\n : t('billing.prepaid.topup.confirm', 'Start checkout')}\n </Button>\n <Button type=\"button\" variant=\"outline\" onClick={() => setTopupOpen(false)}>\n {t('billing.common.cancel', 'Cancel')}\n </Button>\n </div>\n ) : null}\n\n {adjustOpen ? (\n <div className=\"flex flex-wrap items-center gap-2\">\n <input\n type=\"number\"\n step=\"0.01\"\n autoFocus\n value={adjAmount}\n onChange={(e) => setAdjAmount(e.target.value)}\n onKeyDown={(e) => {\n if (e.key === 'Enter') void handleAdjust()\n if (e.key === 'Escape') setAdjustOpen(false)\n }}\n placeholder={t('billing.prepaid.adjust.amount', 'Amount (+credit / \u2212debit)')}\n className=\"h-9 w-48 rounded-md border border-border bg-background px-3 text-sm\"\n />\n <input\n type=\"text\"\n value={adjReason}\n onChange={(e) => setAdjReason(e.target.value)}\n onKeyDown={(e) => {\n if (e.key === 'Enter') void handleAdjust()\n if (e.key === 'Escape') setAdjustOpen(false)\n }}\n placeholder={t('billing.prepaid.adjust.description', 'Reason')}\n className=\"h-9 w-64 rounded-md border border-border bg-background px-3 text-sm\"\n />\n <Button type=\"button\" onClick={handleAdjust} disabled={adjSubmitting}>\n {adjSubmitting\n ? t('billing.prepaid.adjust.submitting', 'Applying\u2026')\n : t('billing.prepaid.adjust.confirm', 'Apply adjustment')}\n </Button>\n <Button type=\"button\" variant=\"outline\" onClick={() => setAdjustOpen(false)}>\n {t('billing.common.cancel', 'Cancel')}\n </Button>\n </div>\n ) : null}\n </div>\n\n <DataTable\n title={t('billing.prepaid.panel.transactions', 'Balance transactions')}\n columns={columns}\n data={rows}\n isLoading={loading}\n onRowClick={(row) => router.push(`/backend/billing/transactions/${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.prepaid.panel.no_transactions', 'No balance movements yet.')}\n </div>\n }\n />\n </div>\n )\n}\n\nexport default PrepaidPanel\n"],
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["\"use client\"\nimport * as React from 'react'\nimport { useRouter } from 'next/navigation'\nimport { Plus, SlidersHorizontal } from 'lucide-react'\nimport type { LegacyColumnDef as ColumnDef } from '@tanstack/react-table/legacy'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport { BillingDataTable as DataTable } from './BillingDataTable'\nimport { Tag } from '@open-mercato/ui/primitives/tag'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { flash } from '@open-mercato/ui/backend/FlashMessages'\nimport { apiCall, apiCallOrThrow, readApiResultOrThrow } from '@open-mercato/ui/backend/utils/apiCall'\nimport { normalizeCrudServerError } from '@open-mercato/ui/backend/utils/serverErrors'\nimport { StatCard, Stat } from './DetailFields'\n\n/**\n * Prepaid panel (SPEC-002 P4) injected into the Billing Account detail page\n * for `billing_mode='prepaid'` accounts: balance + status, credit status,\n * a top-up launcher, and the recent balance transactions.\n */\n\ntype BalanceSnapshot = {\n balance: string\n balanceStatus: 'ok' | 'low' | 'exhausted'\n lowBalanceThreshold: string\n lastMovementAt: string | null\n}\n\ntype CreditSnapshot = {\n mode: string\n creditLimit: string\n creditUsed: string\n availableCredit: string\n creditStatus: 'within_limit' | 'near_limit' | 'over_limit'\n}\n\ntype TransactionRow = {\n id: string\n type: string\n amount: string\n balance_after: string\n description: string\n created_at: string\n}\n\nfunction balanceVariant(status: string): 'success' | 'warning' | 'error' {\n if (status === 'low') return 'warning'\n if (status === 'exhausted') return 'error'\n return 'success'\n}\n\nfunction creditVariant(status: string): 'success' | 'warning' | 'error' {\n if (status === 'near_limit') return 'warning'\n if (status === 'over_limit') return 'error'\n return 'success'\n}\n\nfunction txnVariant(type: string): 'success' | 'info' | 'neutral' {\n if (type === 'topup' || type === 'adjustment') return 'success'\n if (type === 'usage') return 'info'\n return 'neutral'\n}\n\nfunction formatDateTime(value: string | null | undefined): string {\n if (!value) return '\u2014'\n const d = new Date(value)\n return Number.isNaN(d.getTime()) ? value : d.toLocaleString()\n}\n\nexport function PrepaidPanel({\n accountId,\n currencyCode,\n}: {\n accountId: string\n currencyCode: string\n}) {\n const t = useT()\n const router = useRouter()\n const [balance, setBalance] = React.useState<BalanceSnapshot | null>(null)\n const [credit, setCredit] = React.useState<CreditSnapshot | null>(null)\n const [rows, setRows] = React.useState<TransactionRow[]>([])\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 [topupOpen, setTopupOpen] = React.useState(false)\n const [amount, setAmount] = React.useState('')\n const [submitting, setSubmitting] = React.useState(false)\n const [adjustOpen, setAdjustOpen] = React.useState(false)\n const [adjAmount, setAdjAmount] = React.useState('')\n const [adjReason, setAdjReason] = React.useState('')\n const [adjSubmitting, setAdjSubmitting] = React.useState(false)\n // Spec 0 (E-D1): online top-ups need the optional payment gateways module.\n const [gatewayTopups, setGatewayTopups] = React.useState(false)\n React.useEffect(() => {\n let cancelled = false\n void apiCall<{ capabilities?: { gatewayTopups?: boolean } }>('/api/billing/settings').then((call) => {\n if (!cancelled) setGatewayTopups(call.ok && call.result?.capabilities?.gatewayTopups === true)\n })\n return () => {\n cancelled = true\n }\n }, [])\n const pageSize = 10\n\n const loadStatus = React.useCallback(async () => {\n const [bal, cred] = await Promise.all([\n readApiResultOrThrow<BalanceSnapshot>(`/api/billing/accounts/${accountId}/balance`),\n readApiResultOrThrow<CreditSnapshot>(`/api/billing/accounts/${accountId}/credit-status`),\n ])\n setBalance(bal)\n setCredit(cred)\n }, [accountId])\n\n const loadTransactions = React.useCallback(async () => {\n setLoading(true)\n try {\n const result = await readApiResultOrThrow<{\n items: TransactionRow[]\n total: number\n totalPages: number\n }>(\n `/api/billing/transactions?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 loadStatus().catch(() => undefined)\n }, [loadStatus])\n React.useEffect(() => {\n void loadTransactions()\n }, [loadTransactions])\n\n const handleTopup = React.useCallback(async () => {\n const value = Number.parseFloat(amount)\n if (!Number.isFinite(value) || value <= 0) {\n flash(t('billing.prepaid.topup.invalid', 'Enter a positive amount'), 'error')\n return\n }\n setSubmitting(true)\n try {\n const res = await apiCallOrThrow<{ redirectUrl?: string | null }>(\n `/api/billing/accounts/${accountId}/topups`,\n {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n amount: value,\n successUrl: typeof window !== 'undefined' ? window.location.href : undefined,\n cancelUrl: typeof window !== 'undefined' ? window.location.href : undefined,\n }),\n },\n )\n const redirectUrl = res.result?.redirectUrl\n if (redirectUrl && typeof window !== 'undefined') {\n window.location.href = redirectUrl\n return\n }\n flash(t('billing.prepaid.topup.created', 'Top-up session created'), 'success')\n setTopupOpen(false)\n setAmount('')\n void loadStatus().catch(() => undefined)\n void loadTransactions()\n } catch (err) {\n const { message } = normalizeCrudServerError(err)\n flash(message || t('billing.prepaid.topup.error', 'Top-up failed'), 'error')\n } finally {\n setSubmitting(false)\n }\n }, [accountId, amount, loadStatus, loadTransactions, t])\n\n const handleAdjust = React.useCallback(async () => {\n const value = Number.parseFloat(adjAmount)\n if (!Number.isFinite(value) || value === 0) {\n flash(t('billing.prepaid.adjust.invalid_amount', 'Enter a non-zero amount'), 'error')\n return\n }\n if (!adjReason.trim()) {\n flash(t('billing.prepaid.adjust.invalid_description', 'Enter a reason'), 'error')\n return\n }\n setAdjSubmitting(true)\n try {\n await apiCallOrThrow('/api/billing/transactions/adjust', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n billAccountId: accountId,\n amount: value,\n description: adjReason.trim(),\n }),\n })\n flash(t('billing.prepaid.adjust.success', 'Balance adjusted'), 'success')\n setAdjustOpen(false)\n setAdjAmount('')\n setAdjReason('')\n void loadStatus().catch(() => undefined)\n void loadTransactions()\n } catch (err) {\n const { message } = normalizeCrudServerError(err)\n flash(message || t('billing.prepaid.adjust.error', 'Adjustment failed'), 'error')\n } finally {\n setAdjSubmitting(false)\n }\n }, [accountId, adjAmount, adjReason, loadStatus, loadTransactions, t])\n\n const columns = React.useMemo<ColumnDef<TransactionRow>[]>(\n () => [\n {\n accessorKey: 'created_at',\n header: t('billing.transactions.columns.when', 'When'),\n cell: ({ row }) => formatDateTime(row.original.created_at),\n },\n {\n accessorKey: 'type',\n header: t('billing.transactions.columns.type', 'Type'),\n cell: ({ row }) => (\n <Tag variant={txnVariant(row.original.type)}>\n {t(`billing.transactions.type.${row.original.type}`, row.original.type)}\n </Tag>\n ),\n },\n {\n accessorKey: 'description',\n header: t('billing.transactions.columns.description', 'Description'),\n cell: ({ row }) => <span className=\"text-sm\">{row.original.description}</span>,\n },\n {\n accessorKey: 'amount',\n header: t('billing.transactions.columns.amount', 'Amount'),\n cell: ({ row }) => (\n <span className=\"font-mono tabular-nums\">{row.original.amount}</span>\n ),\n },\n {\n accessorKey: 'balance_after',\n header: t('billing.transactions.columns.balance_after', 'Balance'),\n cell: ({ row }) => (\n <span className=\"font-mono tabular-nums\">{row.original.balance_after}</span>\n ),\n },\n ],\n [t],\n )\n\n return (\n <div className=\"mt-6 space-y-4\">\n <StatCard title={t('billing.prepaid.panel.title', 'Prepaid balance')}>\n <Stat\n label={t('billing.prepaid.panel.balance', 'Balance')}\n value={\n <span className=\"flex items-center gap-2\">\n <span className=\"font-mono tabular-nums\">\n {balance?.balance ?? '\u2014'} {currencyCode}\n </span>\n {balance ? (\n <Tag variant={balanceVariant(balance.balanceStatus)}>\n {t(`billing.prepaid.status.${balance.balanceStatus}`, balance.balanceStatus)}\n </Tag>\n ) : null}\n </span>\n }\n />\n <Stat\n label={t('billing.prepaid.panel.threshold', 'Low threshold')}\n value={\n <span className=\"font-mono tabular-nums\">{balance?.lowBalanceThreshold ?? '\u2014'}</span>\n }\n />\n {credit ? (\n <Stat\n label={t('billing.prepaid.panel.credit', 'Credit')}\n value={\n <span className=\"flex items-center gap-2\">\n <span className=\"font-mono tabular-nums\">\n {credit.creditUsed} / {credit.creditLimit}\n </span>\n <Tag variant={creditVariant(credit.creditStatus)}>\n {t(`billing.prepaid.credit.${credit.creditStatus}`, credit.creditStatus)}\n </Tag>\n </span>\n }\n />\n ) : null}\n <Stat\n label={t('billing.prepaid.panel.last_movement', 'Last movement')}\n value={formatDateTime(balance?.lastMovementAt)}\n />\n </StatCard>\n\n <div className=\"flex flex-wrap items-center gap-2\">\n {!topupOpen && !adjustOpen ? (\n <>\n {gatewayTopups ? (\n <Button type=\"button\" onClick={() => setTopupOpen(true)}>\n <Plus size={16} />\n {t('billing.prepaid.topup.action', 'Top up')}\n </Button>\n ) : null}\n <Button type=\"button\" variant=\"outline\" onClick={() => setAdjustOpen(true)}>\n <SlidersHorizontal size={16} />\n {t('billing.prepaid.adjust.action', 'Adjust')}\n </Button>\n </>\n ) : null}\n\n {topupOpen ? (\n <div className=\"flex items-center gap-2\">\n <input\n type=\"number\"\n min=\"0\"\n step=\"0.01\"\n autoFocus\n value={amount}\n onChange={(e) => setAmount(e.target.value)}\n onKeyDown={(e) => {\n if (e.key === 'Enter') void handleTopup()\n if (e.key === 'Escape') setTopupOpen(false)\n }}\n placeholder={t('billing.prepaid.topup.amount', 'Amount')}\n className=\"h-9 w-32 rounded-md border border-border bg-background px-3 text-sm\"\n />\n <Button type=\"button\" onClick={handleTopup} disabled={submitting}>\n {submitting\n ? t('billing.prepaid.topup.submitting', 'Starting\u2026')\n : t('billing.prepaid.topup.confirm', 'Start checkout')}\n </Button>\n <Button type=\"button\" variant=\"outline\" onClick={() => setTopupOpen(false)}>\n {t('billing.common.cancel', 'Cancel')}\n </Button>\n </div>\n ) : null}\n\n {adjustOpen ? (\n <div className=\"flex flex-wrap items-center gap-2\">\n <input\n type=\"number\"\n step=\"0.01\"\n autoFocus\n value={adjAmount}\n onChange={(e) => setAdjAmount(e.target.value)}\n onKeyDown={(e) => {\n if (e.key === 'Enter') void handleAdjust()\n if (e.key === 'Escape') setAdjustOpen(false)\n }}\n placeholder={t('billing.prepaid.adjust.amount', 'Amount (+credit / \u2212debit)')}\n className=\"h-9 w-48 rounded-md border border-border bg-background px-3 text-sm\"\n />\n <input\n type=\"text\"\n value={adjReason}\n onChange={(e) => setAdjReason(e.target.value)}\n onKeyDown={(e) => {\n if (e.key === 'Enter') void handleAdjust()\n if (e.key === 'Escape') setAdjustOpen(false)\n }}\n placeholder={t('billing.prepaid.adjust.description', 'Reason')}\n className=\"h-9 w-64 rounded-md border border-border bg-background px-3 text-sm\"\n />\n <Button type=\"button\" onClick={handleAdjust} disabled={adjSubmitting}>\n {adjSubmitting\n ? t('billing.prepaid.adjust.submitting', 'Applying\u2026')\n : t('billing.prepaid.adjust.confirm', 'Apply adjustment')}\n </Button>\n <Button type=\"button\" variant=\"outline\" onClick={() => setAdjustOpen(false)}>\n {t('billing.common.cancel', 'Cancel')}\n </Button>\n </div>\n ) : null}\n </div>\n\n <DataTable\n title={t('billing.prepaid.panel.transactions', 'Balance transactions')}\n columns={columns}\n data={rows}\n isLoading={loading}\n onRowClick={(row) => router.push(`/backend/billing/transactions/${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.prepaid.panel.no_transactions', 'No balance movements yet.')}\n </div>\n }\n />\n </div>\n )\n}\n\nexport default PrepaidPanel\n"],
|
|
5
|
+
"mappings": ";AA+NU,SA2EA,UA3EA,KAmCI,YAnCJ;AA9NV,YAAY,WAAW;AACvB,SAAS,iBAAiB;AAC1B,SAAS,MAAM,yBAAyB;AAExC,SAAS,YAAY;AACrB,SAAS,oBAAoB,iBAAiB;AAC9C,SAAS,WAAW;AACpB,SAAS,cAAc;AACvB,SAAS,aAAa;AACtB,SAAS,SAAS,gBAAgB,4BAA4B;AAC9D,SAAS,gCAAgC;AACzC,SAAS,UAAU,YAAY;AAgC/B,SAAS,eAAe,QAAiD;AACvE,MAAI,WAAW,MAAO,QAAO;AAC7B,MAAI,WAAW,YAAa,QAAO;AACnC,SAAO;AACT;AAEA,SAAS,cAAc,QAAiD;AACtE,MAAI,WAAW,aAAc,QAAO;AACpC,MAAI,WAAW,aAAc,QAAO;AACpC,SAAO;AACT;AAEA,SAAS,WAAW,MAA8C;AAChE,MAAI,SAAS,WAAW,SAAS,aAAc,QAAO;AACtD,MAAI,SAAS,QAAS,QAAO;AAC7B,SAAO;AACT;AAEA,SAAS,eAAe,OAA0C;AAChE,MAAI,CAAC,MAAO,QAAO;AACnB,QAAM,IAAI,IAAI,KAAK,KAAK;AACxB,SAAO,OAAO,MAAM,EAAE,QAAQ,CAAC,IAAI,QAAQ,EAAE,eAAe;AAC9D;AAEO,SAAS,aAAa;AAAA,EAC3B;AAAA,EACA;AACF,GAGG;AACD,QAAM,IAAI,KAAK;AACf,QAAM,SAAS,UAAU;AACzB,QAAM,CA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YACL,OAAO;AAAA,YACP,UAAU,CAAC,MAAM,aAAa,EAAE,OAAO,KAAK;AAAA,YAC5C,WAAW,CAAC,MAAM;AAChB,kBAAI,EAAE,QAAQ,QAAS,MAAK,aAAa;AACzC,kBAAI,EAAE,QAAQ,SAAU,eAAc,KAAK;AAAA,YAC7C;AAAA,YACA,aAAa,EAAE,sCAAsC,QAAQ;AAAA,YAC7D,WAAU;AAAA;AAAA,QACZ;AAAA,QACA,oBAAC,UAAO,MAAK,UAAS,SAAS,cAAc,UAAU,eACpD,0BACG,EAAE,qCAAqC,gBAAW,IAClD,EAAE,kCAAkC,kBAAkB,GAC5D;AAAA,QACA,oBAAC,UAAO,MAAK,UAAS,SAAQ,WAAU,SAAS,MAAM,cAAc,KAAK,GACvE,YAAE,yBAAyB,QAAQ,GACtC;AAAA,SACF,IACE;AAAA,OACN;AAAA,IAEA;AAAA,MAAC;AAAA;AAAA,QACC,OAAO,EAAE,sCAAsC,sBAAsB;AAAA,QACrE;AAAA,QACA,MAAM;AAAA,QACN,WAAW;AAAA,QACX,YAAY,CAAC,QAAQ,OAAO,KAAK,iCAAiC,IAAI,EAAE,EAAE;AAAA,QAC1E,YAAY,EAAE,MAAM,UAAU,OAAO,YAAY,cAAc,QAAQ;AAAA,QACvE,YACE,oBAAC,SAAI,WAAU,2EACZ,YAAE,yCAAyC,2BAA2B,GACzE;AAAA;AAAA,IAEJ;AAAA,KACF;AAEJ;AAEA,IAAO,uBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import Link from "next/link";
|
|
5
|
+
import { useT } from "@open-mercato/shared/lib/i18n/context";
|
|
6
|
+
import { BillingDataTable as DataTable } from "./BillingDataTable.js";
|
|
7
|
+
import { Tag } from "@open-mercato/ui/primitives/tag";
|
|
8
|
+
const PAGE_SIZE = 50;
|
|
9
|
+
function cycleVariant(status) {
|
|
10
|
+
switch (status) {
|
|
11
|
+
case "invoiced":
|
|
12
|
+
case "charged":
|
|
13
|
+
return "success";
|
|
14
|
+
case "previewed":
|
|
15
|
+
return "info";
|
|
16
|
+
case "skipped_existing":
|
|
17
|
+
return "warning";
|
|
18
|
+
default:
|
|
19
|
+
return "neutral";
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function usePagedRows(rows) {
|
|
23
|
+
const [page, setPage] = React.useState(1);
|
|
24
|
+
const totalPages = Math.max(1, Math.ceil(rows.length / PAGE_SIZE));
|
|
25
|
+
const safePage = Math.min(page, totalPages);
|
|
26
|
+
const pageRows = React.useMemo(
|
|
27
|
+
() => rows.slice((safePage - 1) * PAGE_SIZE, safePage * PAGE_SIZE),
|
|
28
|
+
[rows, safePage]
|
|
29
|
+
);
|
|
30
|
+
return { page: safePage, setPage, pageRows, totalPages };
|
|
31
|
+
}
|
|
32
|
+
function RunCyclesSection({ outcomes }) {
|
|
33
|
+
const t = useT();
|
|
34
|
+
const cycleRows = React.useMemo(
|
|
35
|
+
() => outcomes.flatMap(
|
|
36
|
+
(outcome) => (outcome.cycles ?? []).map((cycle) => ({
|
|
37
|
+
...cycle,
|
|
38
|
+
key: `${outcome.bill_account_id}:${cycle.bill_date}`,
|
|
39
|
+
accountId: outcome.bill_account_id,
|
|
40
|
+
accountName: outcome.bill_account_name ?? outcome.bill_account_id
|
|
41
|
+
}))
|
|
42
|
+
),
|
|
43
|
+
[outcomes]
|
|
44
|
+
);
|
|
45
|
+
const skippedRows = React.useMemo(
|
|
46
|
+
() => outcomes.flatMap((outcome) => {
|
|
47
|
+
const skipped = outcome.warnings?.skipped_items ?? [];
|
|
48
|
+
return skipped.map((entry, index) => ({
|
|
49
|
+
key: `${outcome.bill_account_id}:${index}`,
|
|
50
|
+
accountId: outcome.bill_account_id,
|
|
51
|
+
accountName: outcome.bill_account_name ?? outcome.bill_account_id,
|
|
52
|
+
itemId: String(entry.item_id ?? ""),
|
|
53
|
+
reason: String(entry.reason ?? ""),
|
|
54
|
+
periodStart: typeof entry.service_period_start === "string" ? entry.service_period_start : null,
|
|
55
|
+
periodEnd: typeof entry.service_period_end === "string" ? entry.service_period_end : null
|
|
56
|
+
}));
|
|
57
|
+
}),
|
|
58
|
+
[outcomes]
|
|
59
|
+
);
|
|
60
|
+
const hasPrepaid = React.useMemo(() => cycleRows.some((row) => row.total_debit !== void 0), [cycleRows]);
|
|
61
|
+
const statusLabel = React.useCallback(
|
|
62
|
+
(status) => {
|
|
63
|
+
switch (status) {
|
|
64
|
+
case "invoiced":
|
|
65
|
+
return t("billing.runs.cycles.status.invoiced", "Invoiced");
|
|
66
|
+
case "charged":
|
|
67
|
+
return t("billing.runs.cycles.status.charged", "Charged to balance");
|
|
68
|
+
case "previewed":
|
|
69
|
+
return t("billing.runs.cycles.status.previewed", "Preview");
|
|
70
|
+
case "skipped_existing":
|
|
71
|
+
return t("billing.runs.cycles.status.skipped_existing", "Skipped \u2014 already billed");
|
|
72
|
+
default:
|
|
73
|
+
return t("billing.runs.cycles.status.empty", "Nothing to bill");
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
[t]
|
|
77
|
+
);
|
|
78
|
+
const reasonLabel = React.useCallback(
|
|
79
|
+
(reason) => {
|
|
80
|
+
switch (reason) {
|
|
81
|
+
case "partial-period-not-prorated":
|
|
82
|
+
return t("billing.runs.skipped.reason.partial_not_prorated", "Partial period, proration off");
|
|
83
|
+
case "ended-after-billing-no-credit":
|
|
84
|
+
return t("billing.runs.skipped.reason.ended_no_credit", "Ended after billing, proration off \u2014 no credit");
|
|
85
|
+
case "period-cap-reached":
|
|
86
|
+
return t("billing.runs.skipped.reason.period_cap", "Too many periods for one bill date");
|
|
87
|
+
default:
|
|
88
|
+
return reason;
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
[t]
|
|
92
|
+
);
|
|
93
|
+
const cycleColumns = React.useMemo(
|
|
94
|
+
() => [
|
|
95
|
+
{
|
|
96
|
+
accessorKey: "accountName",
|
|
97
|
+
header: t("billing.runs.outcomes.columns.account", "Account"),
|
|
98
|
+
cell: ({ row }) => /* @__PURE__ */ jsx(Link, { href: `/backend/billing/accounts/${row.original.accountId}`, className: "text-sm text-primary hover:underline", children: row.original.accountName })
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
accessorKey: "bill_date",
|
|
102
|
+
header: t("billing.runs.cycles.columns.bill_date", "Bill date")
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
accessorKey: "period_start",
|
|
106
|
+
header: t("billing.runs.cycles.columns.service_period", "Service period"),
|
|
107
|
+
cell: ({ row }) => row.original.period_start && row.original.period_end ? `${row.original.period_start} \u2013 ${row.original.period_end}` : "\u2014"
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
accessorKey: "status",
|
|
111
|
+
header: t("billing.runs.outcomes.columns.status", "Status"),
|
|
112
|
+
cell: ({ row }) => /* @__PURE__ */ jsx(Tag, { variant: cycleVariant(row.original.status), children: statusLabel(row.original.status) })
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
accessorKey: "line_count",
|
|
116
|
+
header: t("billing.runs.cycles.columns.lines", "Lines")
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
accessorKey: "total_net",
|
|
120
|
+
header: t("billing.runs.cycles.columns.total_net", "Net total"),
|
|
121
|
+
cell: ({ row }) => /* @__PURE__ */ jsx("span", { className: "font-mono tabular-nums", children: row.original.total_net })
|
|
122
|
+
},
|
|
123
|
+
...hasPrepaid ? [
|
|
124
|
+
{
|
|
125
|
+
accessorKey: "total_debit",
|
|
126
|
+
header: t("billing.runs.cycles.columns.total_debit", "Charged to balance"),
|
|
127
|
+
cell: ({ row }) => row.original.total_debit !== void 0 ? /* @__PURE__ */ jsx("span", { className: "font-mono tabular-nums", children: row.original.total_debit }) : "\u2014"
|
|
128
|
+
}
|
|
129
|
+
] : [],
|
|
130
|
+
{
|
|
131
|
+
accessorKey: "invoice_id",
|
|
132
|
+
header: t("billing.runs.cycles.columns.document", "Document"),
|
|
133
|
+
cell: ({ row }) => row.original.invoice_id ? /* @__PURE__ */ jsx(Link, { href: `/backend/billing/invoices/${row.original.invoice_id}`, className: "text-sm text-primary hover:underline", children: row.original.invoice_number ?? row.original.invoice_id }) : row.original.statement_id ? /* @__PURE__ */ jsx(Link, { href: `/backend/billing/statements/${row.original.statement_id}`, className: "text-sm text-primary hover:underline", children: t("billing.runs.cycles.statement", "Statement") }) : "\u2014"
|
|
134
|
+
}
|
|
135
|
+
],
|
|
136
|
+
[hasPrepaid, statusLabel, t]
|
|
137
|
+
);
|
|
138
|
+
const skippedColumns = React.useMemo(
|
|
139
|
+
() => [
|
|
140
|
+
{
|
|
141
|
+
accessorKey: "accountName",
|
|
142
|
+
header: t("billing.runs.outcomes.columns.account", "Account")
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
accessorKey: "itemId",
|
|
146
|
+
header: t("billing.runs.skipped.columns.item", "Item"),
|
|
147
|
+
cell: ({ row }) => /* @__PURE__ */ jsx(Link, { href: `/backend/billing/items/${row.original.itemId}`, className: "text-sm text-primary hover:underline", children: row.original.itemId })
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
accessorKey: "reason",
|
|
151
|
+
header: t("billing.runs.skipped.columns.reason", "Reason"),
|
|
152
|
+
cell: ({ row }) => reasonLabel(row.original.reason)
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
accessorKey: "periodStart",
|
|
156
|
+
header: t("billing.runs.cycles.columns.service_period", "Service period"),
|
|
157
|
+
cell: ({ row }) => row.original.periodStart ? `${row.original.periodStart} \u2013 ${row.original.periodEnd ?? "\u2026"}` : "\u2014"
|
|
158
|
+
}
|
|
159
|
+
],
|
|
160
|
+
[reasonLabel, t]
|
|
161
|
+
);
|
|
162
|
+
const cyclesPaging = usePagedRows(cycleRows);
|
|
163
|
+
const skippedPaging = usePagedRows(skippedRows);
|
|
164
|
+
if (cycleRows.length === 0 && skippedRows.length === 0) return null;
|
|
165
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
166
|
+
cycleRows.length > 0 ? /* @__PURE__ */ jsxs("div", { children: [
|
|
167
|
+
/* @__PURE__ */ jsx("h2", { className: "text-base font-semibold mb-1", children: t("billing.runs.cycles.title", "Cycles") }),
|
|
168
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground mb-2", children: t(
|
|
169
|
+
"billing.runs.cycles.help",
|
|
170
|
+
"One row per account and bill date \u2014 a run bills every due cycle up to its as-of date."
|
|
171
|
+
) }),
|
|
172
|
+
/* @__PURE__ */ jsx(
|
|
173
|
+
DataTable,
|
|
174
|
+
{
|
|
175
|
+
columns: cycleColumns,
|
|
176
|
+
data: cyclesPaging.pageRows,
|
|
177
|
+
pagination: {
|
|
178
|
+
page: cyclesPaging.page,
|
|
179
|
+
pageSize: PAGE_SIZE,
|
|
180
|
+
total: cycleRows.length,
|
|
181
|
+
totalPages: cyclesPaging.totalPages,
|
|
182
|
+
onPageChange: cyclesPaging.setPage
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
)
|
|
186
|
+
] }) : null,
|
|
187
|
+
skippedRows.length > 0 ? /* @__PURE__ */ jsxs("div", { children: [
|
|
188
|
+
/* @__PURE__ */ jsx("h2", { className: "text-base font-semibold mb-2", children: t("billing.runs.skipped.title", "Skipped items") }),
|
|
189
|
+
/* @__PURE__ */ jsx(
|
|
190
|
+
DataTable,
|
|
191
|
+
{
|
|
192
|
+
columns: skippedColumns,
|
|
193
|
+
data: skippedPaging.pageRows,
|
|
194
|
+
pagination: {
|
|
195
|
+
page: skippedPaging.page,
|
|
196
|
+
pageSize: PAGE_SIZE,
|
|
197
|
+
total: skippedRows.length,
|
|
198
|
+
totalPages: skippedPaging.totalPages,
|
|
199
|
+
onPageChange: skippedPaging.setPage
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
)
|
|
203
|
+
] }) : null
|
|
204
|
+
] });
|
|
205
|
+
}
|
|
206
|
+
export {
|
|
207
|
+
RunCyclesSection
|
|
208
|
+
};
|
|
209
|
+
//# sourceMappingURL=RunCyclesSection.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/modules/billing/components/RunCyclesSection.tsx"],
|
|
4
|
+
"sourcesContent": ["\"use client\"\nimport * as React from 'react'\nimport Link from 'next/link'\nimport type { LegacyColumnDef as ColumnDef } from '@tanstack/react-table/legacy'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport { BillingDataTable as DataTable } from './BillingDataTable'\nimport { Tag } from '@open-mercato/ui/primitives/tag'\n\n/**\n * Spec A \u2014 per-bill-date breakdown of a Bill Run.\n *\n * Every run bills all due cycles, so one account outcome can stand for\n * several invoices. These two tables flatten the outcomes currently shown\n * on the run page into:\n * - Cycles: one row per (account, bill date) with its status and invoice;\n * - Skipped items: diagnostics such as partial periods not prorated.\n * Both are paginated client-side over the already-loaded outcome page.\n */\n\nexport type RunCycle = {\n bill_date: string\n period_start: string | null\n period_end: string | null\n /** `charged` = prepaid charges debited from the balance (Spec F). */\n status: 'invoiced' | 'charged' | 'previewed' | 'empty' | 'skipped_existing'\n line_count: number\n total_net: string\n invoice_id: string | null\n invoice_number?: string | null\n /** Prepaid only: what left the balance, and the period's statement. */\n total_debit?: string\n statement_id?: string | null\n}\n\nexport type RunCycleOutcome = {\n bill_account_id: string\n bill_account_name: string | null\n cycles?: RunCycle[] | null\n warnings: Record<string, unknown> | null\n}\n\ntype CycleRow = RunCycle & { key: string; accountId: string; accountName: string }\n\ntype SkippedRow = {\n key: string\n accountId: string\n accountName: string\n itemId: string\n reason: string\n periodStart: string | null\n periodEnd: string | null\n}\n\nconst PAGE_SIZE = 50\n\nfunction cycleVariant(status: RunCycle['status']): 'success' | 'info' | 'neutral' | 'warning' {\n switch (status) {\n case 'invoiced':\n case 'charged':\n return 'success'\n case 'previewed':\n return 'info'\n case 'skipped_existing':\n return 'warning'\n default:\n return 'neutral'\n }\n}\n\nfunction usePagedRows<T>(rows: T[]): { page: number; setPage: (page: number) => void; pageRows: T[]; totalPages: number } {\n const [page, setPage] = React.useState(1)\n const totalPages = Math.max(1, Math.ceil(rows.length / PAGE_SIZE))\n const safePage = Math.min(page, totalPages)\n const pageRows = React.useMemo(\n () => rows.slice((safePage - 1) * PAGE_SIZE, safePage * PAGE_SIZE),\n [rows, safePage],\n )\n return { page: safePage, setPage, pageRows, totalPages }\n}\n\nexport function RunCyclesSection({ outcomes }: { outcomes: RunCycleOutcome[] }) {\n const t = useT()\n\n const cycleRows = React.useMemo<CycleRow[]>(\n () =>\n outcomes.flatMap((outcome) =>\n (outcome.cycles ?? []).map((cycle) => ({\n ...cycle,\n key: `${outcome.bill_account_id}:${cycle.bill_date}`,\n accountId: outcome.bill_account_id,\n accountName: outcome.bill_account_name ?? outcome.bill_account_id,\n })),\n ),\n [outcomes],\n )\n\n const skippedRows = React.useMemo<SkippedRow[]>(\n () =>\n outcomes.flatMap((outcome) => {\n const skipped = (outcome.warnings?.skipped_items ?? []) as Array<Record<string, unknown>>\n return skipped.map((entry, index) => ({\n key: `${outcome.bill_account_id}:${index}`,\n accountId: outcome.bill_account_id,\n accountName: outcome.bill_account_name ?? outcome.bill_account_id,\n itemId: String(entry.item_id ?? ''),\n reason: String(entry.reason ?? ''),\n periodStart: typeof entry.service_period_start === 'string' ? entry.service_period_start : null,\n periodEnd: typeof entry.service_period_end === 'string' ? entry.service_period_end : null,\n }))\n }),\n [outcomes],\n )\n\n const hasPrepaid = React.useMemo(() => cycleRows.some((row) => row.total_debit !== undefined), [cycleRows])\n\n const statusLabel = React.useCallback(\n (status: RunCycle['status']) => {\n switch (status) {\n case 'invoiced':\n return t('billing.runs.cycles.status.invoiced', 'Invoiced')\n case 'charged':\n return t('billing.runs.cycles.status.charged', 'Charged to balance')\n case 'previewed':\n return t('billing.runs.cycles.status.previewed', 'Preview')\n case 'skipped_existing':\n return t('billing.runs.cycles.status.skipped_existing', 'Skipped \u2014 already billed')\n default:\n return t('billing.runs.cycles.status.empty', 'Nothing to bill')\n }\n },\n [t],\n )\n\n const reasonLabel = React.useCallback(\n (reason: string) => {\n switch (reason) {\n case 'partial-period-not-prorated':\n return t('billing.runs.skipped.reason.partial_not_prorated', 'Partial period, proration off')\n case 'ended-after-billing-no-credit':\n return t('billing.runs.skipped.reason.ended_no_credit', 'Ended after billing, proration off \u2014 no credit')\n case 'period-cap-reached':\n return t('billing.runs.skipped.reason.period_cap', 'Too many periods for one bill date')\n default:\n return reason\n }\n },\n [t],\n )\n\n const cycleColumns = React.useMemo<ColumnDef<CycleRow>[]>(\n () => [\n {\n accessorKey: 'accountName',\n header: t('billing.runs.outcomes.columns.account', 'Account'),\n cell: ({ row }) => (\n <Link href={`/backend/billing/accounts/${row.original.accountId}`} className=\"text-sm text-primary hover:underline\">\n {row.original.accountName}\n </Link>\n ),\n },\n {\n accessorKey: 'bill_date',\n header: t('billing.runs.cycles.columns.bill_date', 'Bill date'),\n },\n {\n accessorKey: 'period_start',\n header: t('billing.runs.cycles.columns.service_period', 'Service period'),\n cell: ({ row }) =>\n row.original.period_start && row.original.period_end\n ? `${row.original.period_start} \u2013 ${row.original.period_end}`\n : '\u2014',\n },\n {\n accessorKey: 'status',\n header: t('billing.runs.outcomes.columns.status', 'Status'),\n cell: ({ row }) => <Tag variant={cycleVariant(row.original.status)}>{statusLabel(row.original.status)}</Tag>,\n },\n {\n accessorKey: 'line_count',\n header: t('billing.runs.cycles.columns.lines', 'Lines'),\n },\n {\n accessorKey: 'total_net',\n header: t('billing.runs.cycles.columns.total_net', 'Net total'),\n cell: ({ row }) => <span className=\"font-mono tabular-nums\">{row.original.total_net}</span>,\n },\n ...(hasPrepaid\n ? [\n {\n accessorKey: 'total_debit',\n header: t('billing.runs.cycles.columns.total_debit', 'Charged to balance'),\n cell: ({ row }: { row: { original: CycleRow } }) =>\n row.original.total_debit !== undefined ? (\n <span className=\"font-mono tabular-nums\">{row.original.total_debit}</span>\n ) : (\n '\u2014'\n ),\n } satisfies ColumnDef<CycleRow>,\n ]\n : []),\n {\n accessorKey: 'invoice_id',\n header: t('billing.runs.cycles.columns.document', 'Document'),\n cell: ({ row }) =>\n row.original.invoice_id ? (\n <Link href={`/backend/billing/invoices/${row.original.invoice_id}`} className=\"text-sm text-primary hover:underline\">\n {row.original.invoice_number ?? row.original.invoice_id}\n </Link>\n ) : row.original.statement_id ? (\n <Link href={`/backend/billing/statements/${row.original.statement_id}`} className=\"text-sm text-primary hover:underline\">\n {t('billing.runs.cycles.statement', 'Statement')}\n </Link>\n ) : (\n '\u2014'\n ),\n },\n ],\n [hasPrepaid, statusLabel, t],\n )\n\n const skippedColumns = React.useMemo<ColumnDef<SkippedRow>[]>(\n () => [\n {\n accessorKey: 'accountName',\n header: t('billing.runs.outcomes.columns.account', 'Account'),\n },\n {\n accessorKey: 'itemId',\n header: t('billing.runs.skipped.columns.item', 'Item'),\n cell: ({ row }) => (\n <Link href={`/backend/billing/items/${row.original.itemId}`} className=\"text-sm text-primary hover:underline\">\n {row.original.itemId}\n </Link>\n ),\n },\n {\n accessorKey: 'reason',\n header: t('billing.runs.skipped.columns.reason', 'Reason'),\n cell: ({ row }) => reasonLabel(row.original.reason),\n },\n {\n accessorKey: 'periodStart',\n header: t('billing.runs.cycles.columns.service_period', 'Service period'),\n cell: ({ row }) =>\n row.original.periodStart ? `${row.original.periodStart} \u2013 ${row.original.periodEnd ?? '\u2026'}` : '\u2014',\n },\n ],\n [reasonLabel, t],\n )\n\n const cyclesPaging = usePagedRows(cycleRows)\n const skippedPaging = usePagedRows(skippedRows)\n\n if (cycleRows.length === 0 && skippedRows.length === 0) return null\n\n return (\n <>\n {cycleRows.length > 0 ? (\n <div>\n <h2 className=\"text-base font-semibold mb-1\">{t('billing.runs.cycles.title', 'Cycles')}</h2>\n <p className=\"text-sm text-muted-foreground mb-2\">\n {t(\n 'billing.runs.cycles.help',\n 'One row per account and bill date \u2014 a run bills every due cycle up to its as-of date.',\n )}\n </p>\n <DataTable\n columns={cycleColumns}\n data={cyclesPaging.pageRows}\n pagination={{\n page: cyclesPaging.page,\n pageSize: PAGE_SIZE,\n total: cycleRows.length,\n totalPages: cyclesPaging.totalPages,\n onPageChange: cyclesPaging.setPage,\n }}\n />\n </div>\n ) : null}\n {skippedRows.length > 0 ? (\n <div>\n <h2 className=\"text-base font-semibold mb-2\">{t('billing.runs.skipped.title', 'Skipped items')}</h2>\n <DataTable\n columns={skippedColumns}\n data={skippedPaging.pageRows}\n pagination={{\n page: skippedPaging.page,\n pageSize: PAGE_SIZE,\n total: skippedRows.length,\n totalPages: skippedPaging.totalPages,\n onPageChange: skippedPaging.setPage,\n }}\n />\n </div>\n ) : null}\n </>\n )\n}\n"],
|
|
5
|
+
"mappings": ";AA2JU,SAqGN,UArGM,KAuGF,YAvGE;AA1JV,YAAY,WAAW;AACvB,OAAO,UAAU;AAEjB,SAAS,YAAY;AACrB,SAAS,oBAAoB,iBAAiB;AAC9C,SAAS,WAAW;AA+CpB,MAAM,YAAY;AAElB,SAAS,aAAa,QAAwE;AAC5F,UAAQ,QAAQ;AAAA,IACd,KAAK;AAAA,IACL,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT;AACE,aAAO;AAAA,EACX;AACF;AAEA,SAAS,aAAgB,MAAiG;AACxH,QAAM,CAAC,MAAM,OAAO,IAAI,MAAM,SAAS,CAAC;AACxC,QAAM,aAAa,KAAK,IAAI,GAAG,KAAK,KAAK,KAAK,SAAS,SAAS,CAAC;AACjE,QAAM,WAAW,KAAK,IAAI,MAAM,UAAU;AAC1C,QAAM,WAAW,MAAM;AAAA,IACrB,MAAM,KAAK,OAAO,WAAW,KAAK,WAAW,WAAW,SAAS;AAAA,IACjE,CAAC,MAAM,QAAQ;AAAA,EACjB;AACA,SAAO,EAAE,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