@dainamite/billing 0.20.0 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +90 -0
- package/dist/modules/billing/acl.js +13 -1
- package/dist/modules/billing/acl.js.map +2 -2
- package/dist/modules/billing/api/accounts/[id]/summary/route.js +52 -0
- package/dist/modules/billing/api/accounts/[id]/summary/route.js.map +7 -0
- package/dist/modules/billing/api/accounts/route.js +46 -4
- package/dist/modules/billing/api/accounts/route.js.map +2 -2
- package/dist/modules/billing/api/export/account/[id]/route.js +11 -7
- package/dist/modules/billing/api/export/account/[id]/route.js.map +2 -2
- package/dist/modules/billing/api/invoices/[id]/memos/route.js +54 -0
- package/dist/modules/billing/api/invoices/[id]/memos/route.js.map +7 -0
- package/dist/modules/billing/api/invoices/[id]/pdf/route.js +69 -0
- package/dist/modules/billing/api/invoices/[id]/pdf/route.js.map +7 -0
- package/dist/modules/billing/api/invoices/[id]/route.js +44 -24
- package/dist/modules/billing/api/invoices/[id]/route.js.map +2 -2
- package/dist/modules/billing/api/invoices/[id]/send/route.js +107 -0
- package/dist/modules/billing/api/invoices/[id]/send/route.js.map +7 -0
- package/dist/modules/billing/api/invoices/add-line/route.js +2 -2
- package/dist/modules/billing/api/invoices/add-line/route.js.map +2 -2
- package/dist/modules/billing/api/invoices/delete-draft/route.js +33 -0
- package/dist/modules/billing/api/invoices/delete-draft/route.js.map +7 -0
- package/dist/modules/billing/api/invoices/edit-line/route.js +2 -2
- package/dist/modules/billing/api/invoices/edit-line/route.js.map +2 -2
- package/dist/modules/billing/api/invoices/post/route.js +2 -2
- package/dist/modules/billing/api/invoices/post/route.js.map +2 -2
- package/dist/modules/billing/api/invoices/remove-line/route.js +2 -2
- package/dist/modules/billing/api/invoices/remove-line/route.js.map +2 -2
- package/dist/modules/billing/api/invoices/route.js +45 -46
- package/dist/modules/billing/api/invoices/route.js.map +2 -2
- package/dist/modules/billing/api/items/bulk/route.js +1 -1
- package/dist/modules/billing/api/items/bulk/route.js.map +2 -2
- package/dist/modules/billing/api/items/change-price/route.js +44 -0
- package/dist/modules/billing/api/items/change-price/route.js.map +7 -0
- package/dist/modules/billing/api/items/route.js +19 -7
- package/dist/modules/billing/api/items/route.js.map +2 -2
- package/dist/modules/billing/api/payment-imports/[id]/route.js +49 -0
- package/dist/modules/billing/api/payment-imports/[id]/route.js.map +7 -0
- package/dist/modules/billing/api/payment-imports/route.js +57 -0
- package/dist/modules/billing/api/payment-imports/route.js.map +7 -0
- package/dist/modules/billing/api/payments/[id]/route.js +60 -0
- package/dist/modules/billing/api/payments/[id]/route.js.map +7 -0
- package/dist/modules/billing/api/payments/allocate/route.js +35 -0
- package/dist/modules/billing/api/payments/allocate/route.js.map +7 -0
- package/dist/modules/billing/api/payments/assign/route.js +36 -0
- package/dist/modules/billing/api/payments/assign/route.js.map +7 -0
- package/dist/modules/billing/api/payments/convert-to-topup/route.js +35 -0
- package/dist/modules/billing/api/payments/convert-to-topup/route.js.map +7 -0
- package/dist/modules/billing/api/payments/ignore/route.js +35 -0
- package/dist/modules/billing/api/payments/ignore/route.js.map +7 -0
- package/dist/modules/billing/api/payments/import/route.js +63 -0
- package/dist/modules/billing/api/payments/import/route.js.map +7 -0
- package/dist/modules/billing/api/payments/restore/route.js +35 -0
- package/dist/modules/billing/api/payments/restore/route.js.map +7 -0
- package/dist/modules/billing/api/payments/route.js +114 -0
- package/dist/modules/billing/api/payments/route.js.map +7 -0
- package/dist/modules/billing/api/payments/unallocate/route.js +35 -0
- package/dist/modules/billing/api/payments/unallocate/route.js.map +7 -0
- package/dist/modules/billing/api/payments/unassign/route.js +35 -0
- package/dist/modules/billing/api/payments/unassign/route.js.map +7 -0
- package/dist/modules/billing/api/run-outcomes/route.js +43 -6
- package/dist/modules/billing/api/run-outcomes/route.js.map +2 -2
- package/dist/modules/billing/api/runs/[id]/post-drafts/route.js +61 -0
- package/dist/modules/billing/api/runs/[id]/post-drafts/route.js.map +7 -0
- package/dist/modules/billing/api/runs/[id]/route.js +53 -0
- package/dist/modules/billing/api/runs/[id]/route.js.map +7 -0
- package/dist/modules/billing/api/runs/retry-failed/route.js +1 -1
- package/dist/modules/billing/api/runs/retry-failed/route.js.map +2 -2
- package/dist/modules/billing/api/runs/route.js +9 -3
- package/dist/modules/billing/api/runs/route.js.map +2 -2
- package/dist/modules/billing/api/settings/number-preview/route.js +42 -0
- package/dist/modules/billing/api/settings/number-preview/route.js.map +7 -0
- package/dist/modules/billing/api/settings/route.js +92 -0
- package/dist/modules/billing/api/settings/route.js.map +7 -0
- package/dist/modules/billing/api/statements/route.js +3 -0
- package/dist/modules/billing/api/statements/route.js.map +2 -2
- package/dist/modules/billing/api/test-invoices/wipe/route.js +2 -2
- package/dist/modules/billing/api/test-invoices/wipe/route.js.map +2 -2
- package/dist/modules/billing/backend/billing/accounts/[id]/page.js +121 -232
- package/dist/modules/billing/backend/billing/accounts/[id]/page.js.map +2 -2
- package/dist/modules/billing/backend/billing/accounts/create/page.js +6 -0
- package/dist/modules/billing/backend/billing/accounts/create/page.js.map +2 -2
- package/dist/modules/billing/backend/billing/accounts/page.js +63 -4
- package/dist/modules/billing/backend/billing/accounts/page.js.map +2 -2
- package/dist/modules/billing/backend/billing/invoices/[id]/page.js +297 -65
- package/dist/modules/billing/backend/billing/invoices/[id]/page.js.map +3 -3
- package/dist/modules/billing/backend/billing/invoices/page.js +6 -172
- package/dist/modules/billing/backend/billing/invoices/page.js.map +2 -2
- package/dist/modules/billing/backend/billing/items/[id]/page.js +51 -7
- package/dist/modules/billing/backend/billing/items/[id]/page.js.map +2 -2
- package/dist/modules/billing/backend/billing/items/create/page.js +9 -6
- package/dist/modules/billing/backend/billing/items/create/page.js.map +2 -2
- package/dist/modules/billing/backend/billing/items/page.js +8 -2
- package/dist/modules/billing/backend/billing/items/page.js.map +2 -2
- package/dist/modules/billing/backend/billing/payments/[id]/page.js +297 -0
- package/dist/modules/billing/backend/billing/payments/[id]/page.js.map +7 -0
- package/dist/modules/billing/backend/billing/payments/[id]/page.meta.js +21 -0
- package/dist/modules/billing/backend/billing/payments/[id]/page.meta.js.map +7 -0
- package/dist/modules/billing/backend/billing/payments/imports/[id]/page.js +74 -0
- package/dist/modules/billing/backend/billing/payments/imports/[id]/page.js.map +7 -0
- package/dist/modules/billing/backend/billing/payments/imports/[id]/page.meta.js +21 -0
- package/dist/modules/billing/backend/billing/payments/imports/[id]/page.meta.js.map +7 -0
- package/dist/modules/billing/backend/billing/payments/page.js +58 -0
- package/dist/modules/billing/backend/billing/payments/page.js.map +7 -0
- package/dist/modules/billing/backend/billing/payments/page.meta.js +18 -0
- package/dist/modules/billing/backend/billing/payments/page.meta.js.map +7 -0
- package/dist/modules/billing/backend/billing/runs/[id]/page.js +49 -14
- package/dist/modules/billing/backend/billing/runs/[id]/page.js.map +2 -2
- package/dist/modules/billing/backend/billing/runs/page.js +58 -7
- package/dist/modules/billing/backend/billing/runs/page.js.map +2 -2
- package/dist/modules/billing/backend/billing/statements/[id]/page.js +61 -6
- package/dist/modules/billing/backend/billing/statements/[id]/page.js.map +2 -2
- package/dist/modules/billing/backend/billing/statements/page.js +1 -1
- package/dist/modules/billing/backend/billing/statements/page.js.map +2 -2
- package/dist/modules/billing/backend/billing/topups/page.js +1 -1
- package/dist/modules/billing/backend/billing/topups/page.js.map +2 -2
- package/dist/modules/billing/backend/billing/transactions/page.js +1 -1
- package/dist/modules/billing/backend/billing/transactions/page.js.map +2 -2
- package/dist/modules/billing/backend/billing/usage/create/page.js +3 -2
- package/dist/modules/billing/backend/billing/usage/create/page.js.map +2 -2
- package/dist/modules/billing/backend/config/billing/page.js +472 -0
- package/dist/modules/billing/backend/config/billing/page.js.map +7 -0
- package/dist/modules/billing/backend/config/billing/page.meta.js +19 -0
- package/dist/modules/billing/backend/config/billing/page.meta.js.map +7 -0
- package/dist/modules/billing/cli.js +22 -1
- package/dist/modules/billing/cli.js.map +2 -2
- package/dist/modules/billing/commands/accounts.js +6 -0
- package/dist/modules/billing/commands/accounts.js.map +2 -2
- package/dist/modules/billing/commands/index.js +3 -0
- package/dist/modules/billing/commands/index.js.map +2 -2
- package/dist/modules/billing/commands/invoices.js +269 -167
- package/dist/modules/billing/commands/invoices.js.map +2 -2
- package/dist/modules/billing/commands/items.js +108 -0
- package/dist/modules/billing/commands/items.js.map +2 -2
- package/dist/modules/billing/commands/memos.js +179 -0
- package/dist/modules/billing/commands/memos.js.map +7 -0
- package/dist/modules/billing/commands/payments.js +379 -0
- package/dist/modules/billing/commands/payments.js.map +7 -0
- package/dist/modules/billing/commands/runs.js +151 -4
- package/dist/modules/billing/commands/runs.js.map +2 -2
- package/dist/modules/billing/commands/settings.js +59 -0
- package/dist/modules/billing/commands/settings.js.map +7 -0
- package/dist/modules/billing/commands/topups.js +9 -2
- package/dist/modules/billing/commands/topups.js.map +2 -2
- package/dist/modules/billing/commands/transactions.js +2 -2
- package/dist/modules/billing/commands/transactions.js.map +2 -2
- package/dist/modules/billing/components/AccountForm.js +149 -42
- package/dist/modules/billing/components/AccountForm.js.map +2 -2
- package/dist/modules/billing/components/AccountInvoicesSection.js +64 -0
- package/dist/modules/billing/components/AccountInvoicesSection.js.map +7 -0
- package/dist/modules/billing/components/AccountPaymentsSection.js +43 -0
- package/dist/modules/billing/components/AccountPaymentsSection.js.map +7 -0
- package/dist/modules/billing/components/AccountPicker.js +56 -0
- package/dist/modules/billing/components/AccountPicker.js.map +7 -0
- package/dist/modules/billing/components/AllocatePaymentDialog.js +134 -0
- package/dist/modules/billing/components/AllocatePaymentDialog.js.map +7 -0
- package/dist/modules/billing/components/BillingDataTable.js +21 -0
- package/dist/modules/billing/components/BillingDataTable.js.map +7 -0
- package/dist/modules/billing/components/BillingSettingsLink.js +19 -0
- package/dist/modules/billing/components/BillingSettingsLink.js.map +7 -0
- package/dist/modules/billing/components/ChangeItemPriceDialog.js +158 -0
- package/dist/modules/billing/components/ChangeItemPriceDialog.js.map +7 -0
- package/dist/modules/billing/components/CreateMemoDialog.js +200 -0
- package/dist/modules/billing/components/CreateMemoDialog.js.map +7 -0
- package/dist/modules/billing/components/CustomerLabel.js +33 -0
- package/dist/modules/billing/components/CustomerLabel.js.map +7 -0
- package/dist/modules/billing/components/InvoicesTable.js +270 -0
- package/dist/modules/billing/components/InvoicesTable.js.map +7 -0
- package/dist/modules/billing/components/ItemForm.js +176 -44
- package/dist/modules/billing/components/ItemForm.js.map +2 -2
- package/dist/modules/billing/components/ItemPriceField.js +46 -0
- package/dist/modules/billing/components/ItemPriceField.js.map +7 -0
- package/dist/modules/billing/components/LineFormDialog.js +25 -2
- package/dist/modules/billing/components/LineFormDialog.js.map +2 -2
- package/dist/modules/billing/components/ManualPaymentDialog.js +122 -0
- package/dist/modules/billing/components/ManualPaymentDialog.js.map +7 -0
- package/dist/modules/billing/components/MoneyInput.js +14 -0
- package/dist/modules/billing/components/MoneyInput.js.map +7 -0
- package/dist/modules/billing/components/PaymentUploadDialog.js +115 -0
- package/dist/modules/billing/components/PaymentUploadDialog.js.map +7 -0
- package/dist/modules/billing/components/PaymentsTable.js +171 -0
- package/dist/modules/billing/components/PaymentsTable.js.map +7 -0
- package/dist/modules/billing/components/PostRunDraftsButton.js +105 -0
- package/dist/modules/billing/components/PostRunDraftsButton.js.map +7 -0
- package/dist/modules/billing/components/PrepaidPanel.js +14 -4
- package/dist/modules/billing/components/PrepaidPanel.js.map +2 -2
- package/dist/modules/billing/components/RunCyclesSection.js +209 -0
- package/dist/modules/billing/components/RunCyclesSection.js.map +7 -0
- package/dist/modules/billing/components/TestRunActions.js +127 -0
- package/dist/modules/billing/components/TestRunActions.js.map +7 -0
- package/dist/modules/billing/components/account/AccountItemsTab.js +157 -0
- package/dist/modules/billing/components/account/AccountItemsTab.js.map +7 -0
- package/dist/modules/billing/components/account/AccountRunBillingDialog.js +122 -0
- package/dist/modules/billing/components/account/AccountRunBillingDialog.js.map +7 -0
- package/dist/modules/billing/components/account/AccountRunsTab.js +152 -0
- package/dist/modules/billing/components/account/AccountRunsTab.js.map +7 -0
- package/dist/modules/billing/components/account/AccountStatementsTab.js +98 -0
- package/dist/modules/billing/components/account/AccountStatementsTab.js.map +7 -0
- package/dist/modules/billing/components/account/AccountSummaryCards.js +125 -0
- package/dist/modules/billing/components/account/AccountSummaryCards.js.map +7 -0
- package/dist/modules/billing/components/account/AccountUsageTab.js +91 -0
- package/dist/modules/billing/components/account/AccountUsageTab.js.map +7 -0
- package/dist/modules/billing/components/account/AccountView.js +73 -0
- package/dist/modules/billing/components/account/AccountView.js.map +7 -0
- package/dist/modules/billing/components/account/accountRow.js +39 -0
- package/dist/modules/billing/components/account/accountRow.js.map +7 -0
- package/dist/modules/billing/components/customerNames.js +42 -0
- package/dist/modules/billing/components/customerNames.js.map +7 -0
- package/dist/modules/billing/data/entities.js +560 -4
- package/dist/modules/billing/data/entities.js.map +2 -2
- package/dist/modules/billing/data/entityIds.js +10 -1
- package/dist/modules/billing/data/entityIds.js.map +2 -2
- package/dist/modules/billing/data/validators.js +269 -15
- package/dist/modules/billing/data/validators.js.map +2 -2
- package/dist/modules/billing/events.js +50 -0
- package/dist/modules/billing/events.js.map +2 -2
- package/dist/modules/billing/i18n/en.json +457 -21
- package/dist/modules/billing/i18n/pl.json +457 -21
- package/dist/modules/billing/index.js +6 -2
- package/dist/modules/billing/index.js.map +2 -2
- package/dist/modules/billing/lib/accountFinancials.js +58 -0
- package/dist/modules/billing/lib/accountFinancials.js.map +7 -0
- package/dist/modules/billing/lib/accountLock.js +14 -0
- package/dist/modules/billing/lib/accountLock.js.map +7 -0
- package/dist/modules/billing/lib/accountStatus.js +9 -7
- package/dist/modules/billing/lib/accountStatus.js.map +2 -2
- package/dist/modules/billing/lib/accountSummary.js +106 -0
- package/dist/modules/billing/lib/accountSummary.js.map +7 -0
- package/dist/modules/billing/lib/allocation.js +356 -0
- package/dist/modules/billing/lib/allocation.js.map +7 -0
- package/dist/modules/billing/lib/allocationEvents.js +22 -0
- package/dist/modules/billing/lib/allocationEvents.js.map +7 -0
- package/dist/modules/billing/lib/billPeriod.js +15 -1
- package/dist/modules/billing/lib/billPeriod.js.map +2 -2
- package/dist/modules/billing/lib/billRunEngine.js +237 -102
- package/dist/modules/billing/lib/billRunEngine.js.map +2 -2
- package/dist/modules/billing/lib/billingSettings.js +116 -0
- package/dist/modules/billing/lib/billingSettings.js.map +7 -0
- package/dist/modules/billing/lib/commandRoute.js +81 -0
- package/dist/modules/billing/lib/commandRoute.js.map +7 -0
- package/dist/modules/billing/lib/customerLookup.js +97 -0
- package/dist/modules/billing/lib/customerLookup.js.map +7 -0
- package/dist/modules/billing/lib/dateOnly.js +13 -0
- package/dist/modules/billing/lib/dateOnly.js.map +7 -0
- package/dist/modules/billing/lib/documentParties.js +16 -0
- package/dist/modules/billing/lib/documentParties.js.map +7 -0
- package/dist/modules/billing/lib/documentTypes.js +27 -0
- package/dist/modules/billing/lib/documentTypes.js.map +7 -0
- package/dist/modules/billing/lib/dueDate.js +18 -0
- package/dist/modules/billing/lib/dueDate.js.map +7 -0
- package/dist/modules/billing/lib/iban.js +29 -0
- package/dist/modules/billing/lib/iban.js.map +7 -0
- package/dist/modules/billing/lib/invoiceDelivery.js +131 -0
- package/dist/modules/billing/lib/invoiceDelivery.js.map +7 -0
- package/dist/modules/billing/lib/invoiceLanguages.js +16 -0
- package/dist/modules/billing/lib/invoiceLanguages.js.map +7 -0
- package/dist/modules/billing/lib/invoiceWriter.js +107 -99
- package/dist/modules/billing/lib/invoiceWriter.js.map +2 -2
- package/dist/modules/billing/lib/itemBillingState.js +27 -0
- package/dist/modules/billing/lib/itemBillingState.js.map +7 -0
- package/dist/modules/billing/lib/itemPriceChange.js +18 -0
- package/dist/modules/billing/lib/itemPriceChange.js.map +7 -0
- package/dist/modules/billing/lib/itemSelector.js.map +2 -2
- package/dist/modules/billing/lib/lineAmounts.js +32 -0
- package/dist/modules/billing/lib/lineAmounts.js.map +7 -0
- package/dist/modules/billing/lib/memoGuards.js +25 -0
- package/dist/modules/billing/lib/memoGuards.js.map +7 -0
- package/dist/modules/billing/lib/navigation.js +48 -0
- package/dist/modules/billing/lib/navigation.js.map +7 -0
- package/dist/modules/billing/lib/numbering.js +120 -0
- package/dist/modules/billing/lib/numbering.js.map +7 -0
- package/dist/modules/billing/lib/overdue.js +36 -0
- package/dist/modules/billing/lib/overdue.js.map +7 -0
- package/dist/modules/billing/lib/paymentCsv.js +125 -0
- package/dist/modules/billing/lib/paymentCsv.js.map +7 -0
- package/dist/modules/billing/lib/paymentGateway.js +15 -0
- package/dist/modules/billing/lib/paymentGateway.js.map +7 -0
- package/dist/modules/billing/lib/paymentImport.js +164 -0
- package/dist/modules/billing/lib/paymentImport.js.map +7 -0
- package/dist/modules/billing/lib/paymentMatcher.js +36 -0
- package/dist/modules/billing/lib/paymentMatcher.js.map +7 -0
- package/dist/modules/billing/lib/pdf/attachmentStore.js +46 -0
- package/dist/modules/billing/lib/pdf/attachmentStore.js.map +7 -0
- package/dist/modules/billing/lib/pdf/fonts/embeddedFonts.js +7 -0
- package/dist/modules/billing/lib/pdf/fonts/embeddedFonts.js.map +7 -0
- package/dist/modules/billing/lib/pdf/invoiceModel.js +194 -0
- package/dist/modules/billing/lib/pdf/invoiceModel.js.map +7 -0
- package/dist/modules/billing/lib/pdf/invoicePdf.js +165 -0
- package/dist/modules/billing/lib/pdf/invoicePdf.js.map +7 -0
- package/dist/modules/billing/lib/pdf/invoiceTemplate.js +274 -0
- package/dist/modules/billing/lib/pdf/invoiceTemplate.js.map +7 -0
- package/dist/modules/billing/lib/prepaidConfig.js +17 -25
- package/dist/modules/billing/lib/prepaidConfig.js.map +2 -2
- package/dist/modules/billing/lib/prepaidConsume.js +26 -7
- package/dist/modules/billing/lib/prepaidConsume.js.map +2 -2
- package/dist/modules/billing/lib/prepaidPeriodClose.js +277 -158
- package/dist/modules/billing/lib/prepaidPeriodClose.js.map +2 -2
- package/dist/modules/billing/lib/prepaidTaxPoint.js +37 -0
- package/dist/modules/billing/lib/prepaidTaxPoint.js.map +7 -0
- package/dist/modules/billing/lib/seeds/demo.js +51 -3
- package/dist/modules/billing/lib/seeds/demo.js.map +2 -2
- package/dist/modules/billing/lib/seeds/paymentsSample.js +93 -0
- package/dist/modules/billing/lib/seeds/paymentsSample.js.map +7 -0
- package/dist/modules/billing/lib/seeds/sellerSettings.js +41 -0
- package/dist/modules/billing/lib/seeds/sellerSettings.js.map +7 -0
- package/dist/modules/billing/lib/servicePeriods.js +121 -0
- package/dist/modules/billing/lib/servicePeriods.js.map +7 -0
- package/dist/modules/billing/lib/testRunCleanup.js +24 -0
- package/dist/modules/billing/lib/testRunCleanup.js.map +7 -0
- package/dist/modules/billing/lib/topupCapture.js +2 -2
- package/dist/modules/billing/lib/topupCapture.js.map +2 -2
- package/dist/modules/billing/lib/topupReceipt.js +58 -79
- package/dist/modules/billing/lib/topupReceipt.js.map +2 -2
- package/dist/modules/billing/lib/usageRater.js.map +1 -1
- package/dist/modules/billing/lib/usageRunner.js +14 -6
- package/dist/modules/billing/lib/usageRunner.js.map +2 -2
- package/dist/modules/billing/lib/vat.js +39 -0
- package/dist/modules/billing/lib/vat.js.map +7 -0
- package/dist/modules/billing/migrations/Migration20261114000000_billing_customer_kind.js +15 -0
- package/dist/modules/billing/migrations/Migration20261114000000_billing_customer_kind.js.map +7 -0
- package/dist/modules/billing/migrations/Migration20261114100000_billing_cycle_semantics.js +25 -0
- package/dist/modules/billing/migrations/Migration20261114100000_billing_cycle_semantics.js.map +7 -0
- package/dist/modules/billing/migrations/Migration20261115000000_billing_invoice_ledger.js +115 -0
- package/dist/modules/billing/migrations/Migration20261115000000_billing_invoice_ledger.js.map +7 -0
- package/dist/modules/billing/migrations/Migration20261116000000_billing_invoice_documents.js +47 -0
- package/dist/modules/billing/migrations/Migration20261116000000_billing_invoice_documents.js.map +7 -0
- package/dist/modules/billing/migrations/Migration20261117000000_billing_payments.js +89 -0
- package/dist/modules/billing/migrations/Migration20261117000000_billing_payments.js.map +7 -0
- package/dist/modules/billing/migrations/Migration20261118000000_billing_memos.js +17 -0
- package/dist/modules/billing/migrations/Migration20261118000000_billing_memos.js.map +7 -0
- package/dist/modules/billing/migrations/Migration20261119000000_billing_operator_feedback.js +27 -0
- package/dist/modules/billing/migrations/Migration20261119000000_billing_operator_feedback.js.map +7 -0
- package/dist/modules/billing/migrations/Migration20261120000000_billing_allocation_scope_indexes.js +29 -0
- package/dist/modules/billing/migrations/Migration20261120000000_billing_allocation_scope_indexes.js.map +7 -0
- package/dist/modules/billing/setup.js +7 -184
- package/dist/modules/billing/setup.js.map +2 -2
- package/dist/modules/billing/subscribers/credit-memo-auto-send.js +16 -0
- package/dist/modules/billing/subscribers/credit-memo-auto-send.js.map +7 -0
- package/dist/modules/billing/subscribers/debit-memo-apply-credit.js +16 -0
- package/dist/modules/billing/subscribers/debit-memo-apply-credit.js.map +7 -0
- package/dist/modules/billing/subscribers/debit-memo-auto-send.js +16 -0
- package/dist/modules/billing/subscribers/debit-memo-auto-send.js.map +7 -0
- package/dist/modules/billing/subscribers/invoice-apply-credit.js +34 -0
- package/dist/modules/billing/subscribers/invoice-apply-credit.js.map +7 -0
- package/dist/modules/billing/subscribers/invoice-auto-send.js +30 -0
- package/dist/modules/billing/subscribers/invoice-auto-send.js.map +7 -0
- package/dist/modules/billing/subscribers/payment-captured-to-paid.js +69 -33
- package/dist/modules/billing/subscribers/payment-captured-to-paid.js.map +2 -2
- package/dist/modules/billing/subscribers/prepaid-topup-captured.js +4 -6
- package/dist/modules/billing/subscribers/prepaid-topup-captured.js.map +2 -2
- package/generated/entities/billing_account/index.ts +3 -0
- package/generated/entities/billing_allocation/index.ts +18 -0
- package/generated/entities/billing_document_sequence/index.ts +11 -0
- package/generated/entities/billing_invoice/index.ts +38 -0
- package/generated/entities/billing_invoice_line/index.ts +24 -0
- package/generated/entities/billing_item/index.ts +4 -0
- package/generated/entities/billing_payment/index.ts +25 -0
- package/generated/entities/billing_payment_import/index.ts +14 -0
- package/generated/entities/billing_run/index.ts +0 -1
- package/generated/entities/billing_run_outcome/index.ts +1 -0
- package/generated/entities/billing_settings/index.ts +26 -0
- package/generated/entities/billing_statement/index.ts +1 -0
- package/generated/entities.ids.generated.ts +7 -0
- package/package.json +5 -1
- package/src/modules/billing/__integration__/TC-BILL-004.spec.ts +170 -0
- package/src/modules/billing/__integration__/TC-BILL-005.spec.ts +134 -0
- package/src/modules/billing/__integration__/TC-BILL-006.spec.ts +101 -0
- package/src/modules/billing/__integration__/TC-BILL-007.spec.ts +140 -0
- package/src/modules/billing/__integration__/TC-BILL-008.spec.ts +108 -0
- package/src/modules/billing/__integration__/TC-BILL-009.spec.ts +113 -0
- package/src/modules/billing/__integration__/TC-BILL-010.spec.ts +118 -0
- package/src/modules/billing/__integration__/TC-BILL-011.spec.ts +142 -0
- package/src/modules/billing/__integration__/TC-BILL-012.spec.ts +115 -0
- package/src/modules/billing/__integration__/TC-BILL-013.spec.ts +118 -0
- package/src/modules/billing/__integration__/sellerSettings.ts +24 -0
- package/src/modules/billing/__tests__/commands/invoices.test.ts +436 -354
- package/src/modules/billing/__tests__/commands/itemsBulk.test.ts +33 -0
- package/src/modules/billing/__tests__/commands/memos.test.ts +205 -0
- package/src/modules/billing/__tests__/commands/payments.test.ts +241 -0
- package/src/modules/billing/__tests__/commands/runsDelete.test.ts +146 -0
- package/src/modules/billing/__tests__/commands/runsPostDrafts.test.ts +106 -0
- package/src/modules/billing/__tests__/commands/topups.test.ts +11 -0
- package/src/modules/billing/__tests__/entityRegistry.test.ts +8 -1
- package/src/modules/billing/__tests__/helpers/prepaidMockEm.ts +28 -11
- package/src/modules/billing/__tests__/lib/accountFinancials.test.ts +53 -0
- package/src/modules/billing/__tests__/lib/accountSummary.test.ts +97 -0
- package/src/modules/billing/__tests__/lib/allocation.test.ts +319 -0
- package/src/modules/billing/__tests__/lib/billRunEngine.test.ts +228 -17
- package/src/modules/billing/__tests__/lib/billingSettings.test.ts +109 -0
- package/src/modules/billing/__tests__/lib/customerLookup.test.ts +156 -0
- package/src/modules/billing/__tests__/lib/dueDate.test.ts +35 -0
- package/src/modules/billing/__tests__/lib/iban.test.ts +38 -0
- package/src/modules/billing/__tests__/lib/invoiceDelivery.test.ts +189 -0
- package/src/modules/billing/__tests__/lib/invoiceWriter.test.ts +212 -10
- package/src/modules/billing/__tests__/lib/itemBillingState.test.ts +42 -0
- package/src/modules/billing/__tests__/lib/itemPriceChange.test.ts +165 -0
- package/src/modules/billing/__tests__/lib/lineAmounts.test.ts +86 -0
- package/src/modules/billing/__tests__/lib/navigation.test.ts +71 -0
- package/src/modules/billing/__tests__/lib/numbering.test.ts +91 -0
- package/src/modules/billing/__tests__/lib/overdue.test.ts +36 -0
- package/src/modules/billing/__tests__/lib/paymentCsv.test.ts +148 -0
- package/src/modules/billing/__tests__/lib/paymentImport.test.ts +113 -0
- package/src/modules/billing/__tests__/lib/paymentsSample.test.ts +73 -0
- package/src/modules/billing/__tests__/lib/pdf/invoicePdf.test.ts +199 -0
- package/src/modules/billing/__tests__/lib/pdf/invoicePdfService.test.ts +147 -0
- package/src/modules/billing/__tests__/lib/prepaidPeriodClose.test.ts +374 -98
- package/src/modules/billing/__tests__/lib/prepaidTaxPoint.test.ts +118 -0
- package/src/modules/billing/__tests__/lib/seedsDemo.test.ts +53 -2
- package/src/modules/billing/__tests__/lib/sellerSettings.test.ts +28 -0
- package/src/modules/billing/__tests__/lib/servicePeriods.test.ts +190 -0
- package/src/modules/billing/__tests__/lib/topupCapture.test.ts +6 -28
- package/src/modules/billing/__tests__/lib/topupReceipt.test.ts +21 -52
- package/src/modules/billing/__tests__/lib/vat.test.ts +51 -0
- package/src/modules/billing/__tests__/package-isolation.test.ts +22 -8
- package/src/modules/billing/__tests__/setup.test.ts +13 -4
- package/src/modules/billing/__tests__/validators.test.ts +193 -3
- package/src/modules/billing/acl.ts +12 -0
- package/src/modules/billing/api/accounts/[id]/summary/route.ts +62 -0
- package/src/modules/billing/api/accounts/route.ts +58 -4
- package/src/modules/billing/api/export/account/[id]/route.ts +13 -11
- package/src/modules/billing/api/invoices/[id]/memos/route.ts +63 -0
- package/src/modules/billing/api/invoices/[id]/pdf/route.ts +79 -0
- package/src/modules/billing/api/invoices/[id]/route.ts +57 -70
- package/src/modules/billing/api/invoices/[id]/send/route.ts +127 -0
- package/src/modules/billing/api/invoices/add-line/route.ts +2 -2
- package/src/modules/billing/api/invoices/delete-draft/route.ts +33 -0
- package/src/modules/billing/api/invoices/edit-line/route.ts +2 -2
- package/src/modules/billing/api/invoices/post/route.ts +7 -6
- package/src/modules/billing/api/invoices/remove-line/route.ts +2 -2
- package/src/modules/billing/api/invoices/route.ts +81 -86
- package/src/modules/billing/api/items/bulk/route.ts +2 -1
- package/src/modules/billing/api/items/change-price/route.ts +54 -0
- package/src/modules/billing/api/items/route.ts +23 -7
- package/src/modules/billing/api/payment-imports/[id]/route.ts +49 -0
- package/src/modules/billing/api/payment-imports/route.ts +57 -0
- package/src/modules/billing/api/payments/[id]/route.ts +63 -0
- package/src/modules/billing/api/payments/allocate/route.ts +35 -0
- package/src/modules/billing/api/payments/assign/route.ts +36 -0
- package/src/modules/billing/api/payments/convert-to-topup/route.ts +35 -0
- package/src/modules/billing/api/payments/ignore/route.ts +35 -0
- package/src/modules/billing/api/payments/import/route.ts +72 -0
- package/src/modules/billing/api/payments/restore/route.ts +35 -0
- package/src/modules/billing/api/payments/route.ts +147 -0
- package/src/modules/billing/api/payments/unallocate/route.ts +35 -0
- package/src/modules/billing/api/payments/unassign/route.ts +35 -0
- package/src/modules/billing/api/run-outcomes/route.ts +49 -6
- package/src/modules/billing/api/runs/[id]/post-drafts/route.ts +71 -0
- package/src/modules/billing/api/runs/[id]/route.ts +59 -0
- package/src/modules/billing/api/runs/retry-failed/route.ts +2 -1
- package/src/modules/billing/api/runs/route.ts +15 -7
- package/src/modules/billing/api/settings/number-preview/route.ts +46 -0
- package/src/modules/billing/api/settings/route.ts +116 -0
- package/src/modules/billing/api/statements/route.ts +5 -0
- package/src/modules/billing/api/test-invoices/wipe/route.ts +2 -2
- package/src/modules/billing/backend/billing/accounts/[id]/page.tsx +151 -372
- package/src/modules/billing/backend/billing/accounts/create/page.tsx +6 -0
- package/src/modules/billing/backend/billing/accounts/page.tsx +70 -4
- package/src/modules/billing/backend/billing/invoices/[id]/page.tsx +444 -95
- package/src/modules/billing/backend/billing/invoices/page.tsx +8 -227
- package/src/modules/billing/backend/billing/items/[id]/page.tsx +75 -6
- package/src/modules/billing/backend/billing/items/create/page.tsx +13 -8
- package/src/modules/billing/backend/billing/items/page.tsx +18 -2
- package/src/modules/billing/backend/billing/payments/[id]/page.meta.ts +19 -0
- package/src/modules/billing/backend/billing/payments/[id]/page.tsx +415 -0
- package/src/modules/billing/backend/billing/payments/imports/[id]/page.meta.ts +19 -0
- package/src/modules/billing/backend/billing/payments/imports/[id]/page.tsx +106 -0
- package/src/modules/billing/backend/billing/payments/page.meta.ts +16 -0
- package/src/modules/billing/backend/billing/payments/page.tsx +56 -0
- package/src/modules/billing/backend/billing/runs/[id]/page.tsx +49 -18
- package/src/modules/billing/backend/billing/runs/page.tsx +59 -8
- package/src/modules/billing/backend/billing/statements/[id]/page.tsx +86 -5
- package/src/modules/billing/backend/billing/statements/page.tsx +1 -1
- package/src/modules/billing/backend/billing/topups/page.tsx +1 -1
- package/src/modules/billing/backend/billing/transactions/page.tsx +1 -1
- package/src/modules/billing/backend/billing/usage/create/page.tsx +3 -2
- package/src/modules/billing/backend/config/billing/page.meta.ts +21 -0
- package/src/modules/billing/backend/config/billing/page.tsx +549 -0
- package/src/modules/billing/cli.ts +31 -1
- package/src/modules/billing/commands/accounts.ts +6 -0
- package/src/modules/billing/commands/index.ts +3 -0
- package/src/modules/billing/commands/invoices.ts +364 -231
- package/src/modules/billing/commands/items.ts +143 -0
- package/src/modules/billing/commands/memos.ts +218 -0
- package/src/modules/billing/commands/payments.ts +428 -0
- package/src/modules/billing/commands/runs.ts +205 -3
- package/src/modules/billing/commands/settings.ts +77 -0
- package/src/modules/billing/commands/topups.ts +12 -3
- package/src/modules/billing/commands/transactions.ts +2 -2
- package/src/modules/billing/components/AccountForm.tsx +199 -53
- package/src/modules/billing/components/AccountInvoicesSection.tsx +75 -0
- package/src/modules/billing/components/AccountPaymentsSection.tsx +42 -0
- package/src/modules/billing/components/AccountPicker.tsx +70 -0
- package/src/modules/billing/components/AllocatePaymentDialog.tsx +167 -0
- package/src/modules/billing/components/BillingDataTable.tsx +34 -0
- package/src/modules/billing/components/BillingSettingsLink.tsx +25 -0
- package/src/modules/billing/components/ChangeItemPriceDialog.tsx +180 -0
- package/src/modules/billing/components/CreateMemoDialog.tsx +232 -0
- package/src/modules/billing/components/CustomerLabel.tsx +53 -0
- package/src/modules/billing/components/InvoicesTable.tsx +344 -0
- package/src/modules/billing/components/ItemForm.tsx +233 -44
- package/src/modules/billing/components/ItemPriceField.tsx +81 -0
- package/src/modules/billing/components/LineFormDialog.tsx +25 -1
- package/src/modules/billing/components/ManualPaymentDialog.tsx +140 -0
- package/src/modules/billing/components/MoneyInput.tsx +26 -0
- package/src/modules/billing/components/PaymentUploadDialog.tsx +148 -0
- package/src/modules/billing/components/PaymentsTable.tsx +213 -0
- package/src/modules/billing/components/PostRunDraftsButton.tsx +129 -0
- package/src/modules/billing/components/PrepaidPanel.tsx +19 -6
- package/src/modules/billing/components/RunCyclesSection.tsx +298 -0
- package/src/modules/billing/components/TestRunActions.tsx +152 -0
- package/src/modules/billing/components/account/AccountItemsTab.tsx +192 -0
- package/src/modules/billing/components/account/AccountRunBillingDialog.tsx +147 -0
- package/src/modules/billing/components/account/AccountRunsTab.tsx +201 -0
- package/src/modules/billing/components/account/AccountStatementsTab.tsx +120 -0
- package/src/modules/billing/components/account/AccountSummaryCards.tsx +153 -0
- package/src/modules/billing/components/account/AccountUsageTab.tsx +122 -0
- package/src/modules/billing/components/account/AccountView.tsx +101 -0
- package/src/modules/billing/components/account/accountRow.ts +70 -0
- package/src/modules/billing/components/customerNames.ts +62 -0
- package/src/modules/billing/data/entities.ts +654 -5
- package/src/modules/billing/data/entityIds.ts +9 -0
- package/src/modules/billing/data/validators.ts +388 -8
- package/src/modules/billing/events.ts +56 -3
- package/src/modules/billing/i18n/en.json +457 -21
- package/src/modules/billing/i18n/pl.json +457 -21
- package/src/modules/billing/index.ts +6 -2
- package/src/modules/billing/lib/accountFinancials.ts +84 -0
- package/src/modules/billing/lib/accountLock.ts +32 -0
- package/src/modules/billing/lib/accountStatus.ts +11 -9
- package/src/modules/billing/lib/accountSummary.ts +172 -0
- package/src/modules/billing/lib/allocation.ts +515 -0
- package/src/modules/billing/lib/allocationEvents.ts +26 -0
- package/src/modules/billing/lib/billPeriod.ts +19 -0
- package/src/modules/billing/lib/billRunEngine.ts +350 -150
- package/src/modules/billing/lib/billingSettings.ts +145 -0
- package/src/modules/billing/lib/commandRoute.ts +112 -0
- package/src/modules/billing/lib/customerLookup.ts +157 -0
- package/src/modules/billing/lib/dateOnly.ts +22 -0
- package/src/modules/billing/lib/documentParties.ts +23 -0
- package/src/modules/billing/lib/documentTypes.ts +37 -0
- package/src/modules/billing/lib/dueDate.ts +26 -0
- package/src/modules/billing/lib/iban.ts +36 -0
- package/src/modules/billing/lib/invoiceDelivery.ts +197 -0
- package/src/modules/billing/lib/invoiceLanguages.ts +34 -0
- package/src/modules/billing/lib/invoiceWriter.ts +162 -148
- package/src/modules/billing/lib/itemBillingState.ts +67 -0
- package/src/modules/billing/lib/itemPriceChange.ts +56 -0
- package/src/modules/billing/lib/itemSelector.ts +4 -1
- package/src/modules/billing/lib/lineAmounts.ts +61 -0
- package/src/modules/billing/lib/memoGuards.ts +41 -0
- package/src/modules/billing/lib/navigation.ts +64 -0
- package/src/modules/billing/lib/numbering.ts +174 -0
- package/src/modules/billing/lib/overdue.ts +60 -0
- package/src/modules/billing/lib/paymentCsv.ts +171 -0
- package/src/modules/billing/lib/paymentGateway.ts +52 -0
- package/src/modules/billing/lib/paymentImport.ts +228 -0
- package/src/modules/billing/lib/paymentMatcher.ts +88 -0
- package/src/modules/billing/lib/pdf/attachmentStore.ts +60 -0
- package/src/modules/billing/lib/pdf/fonts/NotoSans-Bold.ttf +0 -0
- package/src/modules/billing/lib/pdf/fonts/NotoSans-Regular.ttf +0 -0
- package/src/modules/billing/lib/pdf/fonts/OFL.txt +93 -0
- package/src/modules/billing/lib/pdf/fonts/embeddedFonts.ts +9 -0
- package/src/modules/billing/lib/pdf/invoiceModel.ts +328 -0
- package/src/modules/billing/lib/pdf/invoicePdf.ts +216 -0
- package/src/modules/billing/lib/pdf/invoiceTemplate.ts +338 -0
- package/src/modules/billing/lib/prepaidConfig.ts +27 -36
- package/src/modules/billing/lib/prepaidConsume.ts +29 -6
- package/src/modules/billing/lib/prepaidPeriodClose.ts +407 -239
- package/src/modules/billing/lib/prepaidTaxPoint.ts +76 -0
- package/src/modules/billing/lib/seeds/demo.ts +79 -6
- package/src/modules/billing/lib/seeds/paymentsSample.ts +136 -0
- package/src/modules/billing/lib/seeds/sellerSettings.ts +78 -0
- package/src/modules/billing/lib/servicePeriods.ts +226 -0
- package/src/modules/billing/lib/testRunCleanup.ts +42 -0
- package/src/modules/billing/lib/topupCapture.ts +3 -4
- package/src/modules/billing/lib/topupReceipt.ts +70 -103
- package/src/modules/billing/lib/usageRater.ts +1 -1
- package/src/modules/billing/lib/usageRunner.ts +17 -5
- package/src/modules/billing/lib/vat.ts +56 -0
- package/src/modules/billing/migrations/Migration20261114000000_billing_customer_kind.ts +25 -0
- package/src/modules/billing/migrations/Migration20261114100000_billing_cycle_semantics.ts +37 -0
- package/src/modules/billing/migrations/Migration20261115000000_billing_invoice_ledger.ts +132 -0
- package/src/modules/billing/migrations/Migration20261116000000_billing_invoice_documents.ts +58 -0
- package/src/modules/billing/migrations/Migration20261117000000_billing_payments.ts +97 -0
- package/src/modules/billing/migrations/Migration20261118000000_billing_memos.ts +21 -0
- package/src/modules/billing/migrations/Migration20261119000000_billing_operator_feedback.ts +39 -0
- package/src/modules/billing/migrations/Migration20261120000000_billing_allocation_scope_indexes.ts +35 -0
- package/src/modules/billing/setup.ts +11 -237
- package/src/modules/billing/subscribers/credit-memo-auto-send.ts +15 -0
- package/src/modules/billing/subscribers/debit-memo-apply-credit.ts +15 -0
- package/src/modules/billing/subscribers/debit-memo-auto-send.ts +15 -0
- package/src/modules/billing/subscribers/invoice-apply-credit.ts +39 -0
- package/src/modules/billing/subscribers/invoice-auto-send.ts +46 -0
- package/src/modules/billing/subscribers/payment-captured-to-paid.ts +84 -62
- package/src/modules/billing/subscribers/prepaid-topup-captured.ts +4 -8
- package/dist/modules/billing/lib/invoiceStatus.js +0 -38
- package/dist/modules/billing/lib/invoiceStatus.js.map +0 -7
- package/src/modules/billing/__tests__/lib/invoiceStatus.test.ts +0 -97
- package/src/modules/billing/lib/invoiceStatus.ts +0 -61
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/modules/billing/data/validators.ts"],
|
|
4
|
-
"sourcesContent": ["import { z } from 'zod'\n\n// \u2500\u2500\u2500 Enums \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nexport const BILLING_ITEM_TYPES = ['one_time', 'recurring', 'usage'] as const\nexport type BillingItemType = (typeof BILLING_ITEM_TYPES)[number]\n\nexport const BILL_CYCLES = ['weekly', 'monthly', 'quarterly', 'annually'] as const\nexport type BillCycle = (typeof BILL_CYCLES)[number]\n\nexport const BILL_RUN_TRIGGERS = ['schedule', 'manual'] as const\nexport type BillRunTrigger = (typeof BILL_RUN_TRIGGERS)[number]\n\nexport const BILL_RUN_STATUSES = ['running', 'completed', 'partial_failure', 'failed'] as const\nexport type BillRunStatus = (typeof BILL_RUN_STATUSES)[number]\n\nexport const BILL_RUN_OUTCOME_STATUSES = [\n 'success',\n 'success_with_warnings',\n 'skipped_existing_draft',\n // SPEC-002: prepaid period close was skipped because a statement already\n // exists for the window.\n 'skipped_existing_statement',\n 'failed',\n] as const\nexport type BillRunOutcomeStatus = (typeof BILL_RUN_OUTCOME_STATUSES)[number]\n\nexport const DRAFT_INVOICE_EDIT_ACTIONS = ['line_added', 'line_removed', 'line_edited'] as const\nexport type DraftInvoiceEditAction = (typeof DRAFT_INVOICE_EDIT_ACTIONS)[number]\n\nexport const INVOICE_STATUSES = ['draft', 'posted', 'paid', 'void'] as const\nexport type InvoiceStatus = (typeof INVOICE_STATUSES)[number]\n\n// \u2500\u2500\u2500 Prepaid (SPEC-002) enums \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nexport const BILLING_MODES = ['postpaid', 'prepaid'] as const\nexport type BillingMode = (typeof BILLING_MODES)[number]\n\nexport const TRANSACTION_TYPES = [\n 'topup',\n 'usage',\n 'recurring',\n 'one_time',\n 'adjustment',\n 'reversal',\n] as const\nexport type TransactionType = (typeof TRANSACTION_TYPES)[number]\n\nexport const TOPUP_STATUSES = [\n 'pending',\n 'captured',\n 'failed',\n 'expired',\n 'cancelled',\n] as const\nexport type TopupStatus = (typeof TOPUP_STATUSES)[number]\n\nexport const STATEMENT_STATUSES = ['generated', 'sent'] as const\nexport type StatementStatus = (typeof STATEMENT_STATUSES)[number]\n\n// Prepaid funds status (the account's own money).\nexport const BALANCE_STATUSES = ['ok', 'low', 'exhausted'] as const\nexport type BalanceStatus = (typeof BALANCE_STATUSES)[number]\n\n// Credit-line status (extended overdraft / AR exposure \u2014 both modes).\nexport const CREDIT_STATUSES = ['within_limit', 'near_limit', 'over_limit'] as const\nexport type CreditStatus = (typeof CREDIT_STATUSES)[number]\n\n// `mon`\u2013`sun` for weekly cycles; 1\u201328 (as text) for the others.\n// Why text for numeric anchors: the column type stays uniform across cycles\n// and we never do arithmetic on the raw value (the engine parses it on use).\nconst WEEKLY_ANCHORS = ['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun'] as const\n\nexport const billCycleAnchorSchema = z\n .string()\n .min(1)\n .refine(\n (val) => {\n if ((WEEKLY_ANCHORS as readonly string[]).includes(val.toLowerCase())) return true\n const n = Number.parseInt(val, 10)\n return Number.isInteger(n) && n >= 1 && n <= 28\n },\n {\n message:\n 'bill_cycle_anchor must be 1\u201328 (monthly/quarterly/annually) or mon\u2013sun (weekly)',\n },\n )\n\n// \u2500\u2500\u2500 rate_json \u2014 pricing definitions \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n//\n// Validated at API ingress so the engine can trust the shape downstream.\n// Negative amounts are intentionally allowed only on `one_time` (refunds /\n// credits / proration credits). Recurring and usage unit prices MUST be\n// non-negative \u2014 discounts on those are modeled as separate `one_time`\n// credit items.\n\nconst numericNonNegative = z.number().finite().nonnegative()\nconst numericAny = z.number().finite()\n\nexport const rateJsonOneTime = z\n .object({ amount: numericAny })\n .strict()\n\nexport const rateJsonRecurring = z\n .object({ unit_price: numericNonNegative })\n .strict()\n\nexport const rateJsonUsageSimple = z\n .object({ unit_price: numericNonNegative })\n .strict()\n\nconst tierWithUnitPrice = z\n .object({\n up_to: z.union([z.number().int().positive(), z.null()]),\n unit_price: numericNonNegative,\n })\n .strict()\n\nconst tierWithFlatAmount = z\n .object({\n up_to: z.union([z.number().int().positive(), z.null()]),\n flat_amount: numericNonNegative,\n })\n .strict()\n\n// All tiers must use the same key shape (consistent with the model). Mixing\n// `unit_price` and `flat_amount` across tiers is rejected \u2014 see spec\n// validation rules.\nconst tiersUnitPrice = z\n .array(tierWithUnitPrice)\n .min(1, 'tiers must be a non-empty array')\nconst tiersFlatAmount = z\n .array(tierWithFlatAmount)\n .min(1, 'tiers must be a non-empty array')\n\nfunction refineTierProgression<T extends { up_to: number | null }>(\n tiers: T[],\n ctx: z.RefinementCtx,\n): void {\n const openTopCount = tiers.filter((t) => t.up_to === null).length\n if (openTopCount !== 1) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: 'tiers must contain exactly one open-ended top tier (up_to: null)',\n })\n return\n }\n if (tiers[tiers.length - 1].up_to !== null) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: 'the open-ended top tier (up_to: null) must be the last entry',\n })\n return\n }\n for (let i = 1; i < tiers.length - 1; i++) {\n const prev = tiers[i - 1].up_to\n const curr = tiers[i].up_to\n if (prev !== null && curr !== null && curr <= prev) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: `up_to values must be strictly increasing across tiers (failed at index ${i})`,\n })\n return\n }\n }\n}\n\nexport const rateJsonUsageVolume = z\n .object({\n model: z.literal('volume'),\n tiers: tiersUnitPrice,\n })\n .strict()\n .superRefine((val, ctx) => refineTierProgression(val.tiers, ctx))\n\nexport const rateJsonUsageGraduated = z\n .object({\n model: z.literal('graduated'),\n tiers: tiersUnitPrice,\n })\n .strict()\n .superRefine((val, ctx) => refineTierProgression(val.tiers, ctx))\n\nexport const rateJsonUsageFlat = z\n .object({\n model: z.literal('flat'),\n tiers: tiersFlatAmount,\n })\n .strict()\n .superRefine((val, ctx) => refineTierProgression(val.tiers, ctx))\n\nexport const rateJsonUsageTiered = z.discriminatedUnion('model', [\n rateJsonUsageVolume,\n rateJsonUsageGraduated,\n rateJsonUsageFlat,\n])\n\nexport const rateJsonUsage = z.union([rateJsonUsageSimple, rateJsonUsageTiered])\n\n/**\n * Validate a `rate_json` payload against the rules for a given Billing Item\n * `type`. Returns the parsed value or throws a `ZodError` whose message\n * surfaces the specific shape violation.\n */\nexport function validateRateJson(\n type: BillingItemType,\n rateJson: unknown,\n):\n | z.infer<typeof rateJsonOneTime>\n | z.infer<typeof rateJsonRecurring>\n | z.infer<typeof rateJsonUsage> {\n switch (type) {\n case 'one_time':\n return rateJsonOneTime.parse(rateJson)\n case 'recurring':\n return rateJsonRecurring.parse(rateJson)\n case 'usage':\n return rateJsonUsage.parse(rateJson)\n }\n}\n\n// \u2500\u2500\u2500 Invoice address (BillingAccount.invoice_address) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nexport const invoiceAddressSchema = z\n .object({\n line1: z.string().min(1),\n line2: z.string().optional(),\n city: z.string().min(1),\n postal_code: z.string().min(1),\n country: z.string().min(2).max(3), // ISO 3166-1 alpha-2 or alpha-3\n })\n .strict()\n\nexport type InvoiceAddress = z.infer<typeof invoiceAddressSchema>\n\n// \u2500\u2500\u2500 Scope (injected by withScopedPayload at API ingress) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nconst scopedSchema = z.object({\n tenantId: z.string().uuid(),\n organizationId: z.string().uuid(),\n})\n\n// \u2500\u2500\u2500 List pagination (shared shape) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nconst listPaginationBase = {\n page: z.coerce.number().int().min(1).default(1),\n pageSize: z.coerce.number().int().min(1).max(100).default(50),\n sortField: z.string().optional(),\n sortDir: z.enum(['asc', 'desc']).optional(),\n}\n\n// \u2500\u2500\u2500 BillingAccount payloads \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n// numeric(18,4) money inputs arrive as numbers; the command coerces to a\n// 4dp string at persist time.\nconst moneyNonNegative = z.number().finite().nonnegative()\n\nexport const billingAccountCreateSchema = scopedSchema.extend({\n customerId: z.string().min(1).max(255),\n name: z.string().trim().min(1).max(255),\n currencyCode: z.string().trim().toUpperCase().length(3),\n billCycle: z.enum(BILL_CYCLES),\n billCycleAnchor: billCycleAnchorSchema,\n invoiceEmail: z.string().trim().email().max(320),\n invoiceLanguage: z.string().trim().toLowerCase().min(2).max(5),\n // Nullable + optional \u2014 consistent with the update schema, and the\n // cpq-billing-connector's shell-account seed sends `taxId: null`\n // for customers with no tax id.\n taxId: z.string().trim().max(64).nullable().optional(),\n invoiceAddress: invoiceAddressSchema,\n nextBillDate: z.coerce.date(),\n lastBillDate: z.coerce.date().optional(),\n isActive: z.boolean().optional(),\n // SPEC-002: mode is immutable after create (like currencyCode). Default\n // 'postpaid' so existing callers are unaffected.\n billingMode: z.enum(BILLING_MODES).optional(),\n // Credit line (both modes). 0 = no credit.\n creditLimit: moneyNonNegative.optional(),\n // Initial low-balance threshold for a prepaid account's balance row.\n // Null = resolve the tenant config default at read time.\n lowBalanceThreshold: moneyNonNegative.nullable().optional(),\n})\n\nexport type BillingAccountCreateInput = z.infer<typeof billingAccountCreateSchema>\n\nexport const billingAccountUpdateSchema = scopedSchema.extend({\n id: z.string().uuid(),\n name: z.string().trim().min(1).max(255).optional(),\n billCycle: z.enum(BILL_CYCLES).optional(),\n billCycleAnchor: billCycleAnchorSchema.optional(),\n invoiceEmail: z.string().trim().email().max(320).optional(),\n invoiceLanguage: z.string().trim().toLowerCase().min(2).max(5).optional(),\n taxId: z.string().trim().max(64).nullable().optional(),\n invoiceAddress: invoiceAddressSchema.optional(),\n nextBillDate: z.coerce.date().optional(),\n lastBillDate: z.coerce.date().nullable().optional(),\n isActive: z.boolean().optional(),\n // SPEC-002: credit_limit is editable (it's an AR/overdraft policy knob);\n // `billingMode` is intentionally NOT updatable \u2014 mode is frozen at create\n // (like currencyCode), no live postpaid\u2194prepaid switch in v1.\n creditLimit: moneyNonNegative.optional(),\n // Editing the prepaid balance row's low-balance threshold. Null clears it\n // back to the tenant config default.\n lowBalanceThreshold: moneyNonNegative.nullable().optional(),\n // `currencyCode` is intentionally NOT updatable \u2014 currency is frozen at\n // account create time so historical invoices keep their currency context.\n // `customerId` is also immutable; create a new account if the customer\n // FK changes.\n})\n\nexport type BillingAccountUpdateInput = z.infer<typeof billingAccountUpdateSchema>\n\nexport const billingAccountDeleteSchema = scopedSchema.extend({\n id: z.string().uuid(),\n})\n\nexport type BillingAccountDeleteInput = z.infer<typeof billingAccountDeleteSchema>\n\nexport const billingAccountListQuerySchema = z\n .object({\n ...listPaginationBase,\n id: z.string().uuid().optional(),\n customerId: z.string().optional(),\n currencyCode: z.string().optional(),\n billCycle: z.enum(BILL_CYCLES).optional(),\n billingMode: z.enum(BILLING_MODES).optional(),\n isActive: z.coerce.boolean().optional(),\n search: z.string().optional(),\n })\n .passthrough()\n\nexport type BillingAccountListQuery = z.infer<typeof billingAccountListQuerySchema>\n\n// \u2500\u2500\u2500 BillingItem payloads \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nconst ratePayloadByType = z\n .object({\n type: z.enum(BILLING_ITEM_TYPES),\n rateJson: z.unknown(),\n })\n .superRefine((val, ctx) => {\n try {\n validateRateJson(val.type, val.rateJson)\n } catch (err) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['rateJson'],\n message: err instanceof Error ? err.message : 'rate_json is invalid for this type',\n })\n }\n })\n\nexport const billingItemCreateSchema = scopedSchema\n .extend({\n billAccountId: z.string().uuid(),\n type: z.enum(BILLING_ITEM_TYPES),\n billStartDate: z.coerce.date(),\n billEndDate: z.coerce.date().nullable().optional(),\n description: z.string().trim().min(1).max(500),\n rateJson: z.unknown(), // shape validated via the refine below\n uomCode: z.string().trim().max(64).optional(),\n subscriptionId: z.string().trim().max(255).optional(),\n subscriptionItemId: z.string().trim().max(255).optional(),\n // `source_ref` is the idempotency key. NULL \u2192 no dedup, always create.\n sourceRef: z.string().trim().min(1).max(255).optional(),\n // currency_mismatch and billed_to_date are system-managed, never set by\n // clients on create.\n })\n .superRefine((val, ctx) => {\n try {\n validateRateJson(val.type, val.rateJson)\n } catch (err) {\n const message = err instanceof Error ? err.message : 'rate_json is invalid for this type'\n ctx.addIssue({ code: z.ZodIssueCode.custom, path: ['rateJson'], message })\n }\n if (val.type === 'usage' && !val.uomCode) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['uomCode'],\n message: 'uomCode is required for type=usage',\n })\n }\n })\n\nexport type BillingItemCreateInput = z.infer<typeof billingItemCreateSchema>\n\n// \u2500\u2500\u2500 Bulk item create (Phase 4g) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n//\n// One scope envelope, N item payloads. The CPQ connector activating\n// a large subscription used to fire one `billing.items.create` per\n// charge \u2014 bulk-create collapses that into a single command with a\n// batched `source_ref` idempotency check + single flush.\n\nconst billingItemBulkEntrySchema = z\n .object({\n billAccountId: z.string().uuid(),\n type: z.enum(BILLING_ITEM_TYPES),\n billStartDate: z.coerce.date(),\n billEndDate: z.coerce.date().nullable().optional(),\n description: z.string().trim().min(1).max(500),\n rateJson: z.unknown(),\n uomCode: z.string().trim().max(64).optional(),\n subscriptionId: z.string().trim().max(255).optional(),\n subscriptionItemId: z.string().trim().max(255).optional(),\n sourceRef: z.string().trim().min(1).max(255).optional(),\n })\n .superRefine((val, ctx) => {\n try {\n validateRateJson(val.type, val.rateJson)\n } catch (err) {\n const message = err instanceof Error ? err.message : 'rate_json is invalid for this type'\n ctx.addIssue({ code: z.ZodIssueCode.custom, path: ['rateJson'], message })\n }\n if (val.type === 'usage' && !val.uomCode) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['uomCode'],\n message: 'uomCode is required for type=usage',\n })\n }\n })\n\nexport type BillingItemBulkEntry = z.infer<typeof billingItemBulkEntrySchema>\n\nexport const billingItemBulkCreateSchema = scopedSchema.extend({\n // Cap at 500 per call \u2014 keeps a single bulk transaction bounded.\n // A CPQ subscription with >500 charges should be split by the\n // caller (the connector); 500 is already far past any realistic\n // single-subscription charge count.\n items: z.array(billingItemBulkEntrySchema).min(1).max(500),\n})\n\nexport type BillingItemBulkCreateInput = z.infer<typeof billingItemBulkCreateSchema>\n\nexport const billingItemUpdateSchema = scopedSchema.extend({\n id: z.string().uuid(),\n // `type` is immutable \u2014 changing one_time \u2192 recurring would silently\n // change billing semantics. Cancel the old item, create a new one.\n billStartDate: z.coerce.date().optional(),\n billEndDate: z.coerce.date().nullable().optional(),\n description: z.string().trim().min(1).max(500).optional(),\n rateJson: z.unknown().optional(),\n uomCode: z.string().trim().max(64).nullable().optional(),\n subscriptionId: z.string().trim().max(255).nullable().optional(),\n subscriptionItemId: z.string().trim().max(255).nullable().optional(),\n // `source_ref` immutable \u2014 it's the idempotency identity of the item.\n isActive: z.boolean().optional(),\n})\n\nexport type BillingItemUpdateInput = z.infer<typeof billingItemUpdateSchema>\n\nexport const billingItemDeleteSchema = scopedSchema.extend({\n id: z.string().uuid(),\n})\n\nexport type BillingItemDeleteInput = z.infer<typeof billingItemDeleteSchema>\n\nexport const billingItemListQuerySchema = z\n .object({\n ...listPaginationBase,\n id: z.string().uuid().optional(),\n search: z.string().optional(),\n billAccountId: z.string().uuid().optional(),\n type: z.enum(BILLING_ITEM_TYPES).optional(),\n subscriptionId: z.string().optional(),\n isActive: z.coerce.boolean().optional(),\n activeAt: z.coerce.date().optional(), // bill_start_date <= X AND (bill_end_date IS NULL OR bill_end_date >= X)\n })\n .passthrough()\n\nexport type BillingItemListQuery = z.infer<typeof billingItemListQuerySchema>\n\n// \u2500\u2500\u2500 BillingAccountUsage payloads \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nexport const billingUsageCreateSchema = scopedSchema.extend({\n billAccountId: z.string().uuid(),\n uomCode: z.string().trim().min(1).max(64),\n // `quantity` arrives as a number from JSON; MikroORM stores it as\n // numeric(18,4). The service coerces to a string at persist time.\n quantity: z.number().finite().nonnegative(),\n periodStart: z.coerce.date(),\n periodEnd: z.coerce.date(),\n lineDescription: z.string().trim().min(1).max(500).optional(),\n sourceRef: z.string().trim().min(1).max(255).optional(),\n}).superRefine((val, ctx) => {\n if (val.periodEnd < val.periodStart) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['periodEnd'],\n message: 'periodEnd must be on or after periodStart',\n })\n }\n})\n\nexport type BillingUsageCreateInput = z.infer<typeof billingUsageCreateSchema>\n\nexport const billingUsageListQuerySchema = z\n .object({\n ...listPaginationBase,\n billAccountId: z.string().uuid().optional(),\n uomCode: z.string().optional(),\n rated: z.coerce.boolean().optional(), // true \u2192 already rated; false \u2192 unrated\n periodEndFrom: z.coerce.date().optional(),\n periodEndTo: z.coerce.date().optional(),\n })\n .passthrough()\n\nexport type BillingUsageListQuery = z.infer<typeof billingUsageListQuerySchema>\n\n// Suppress unused-export TS warning \u2014 `ratePayloadByType` is reserved for\n// reuse by a future per-tenant rate-validation CLI tool.\nvoid ratePayloadByType\n\n// \u2500\u2500\u2500 Bill Run trigger payloads (Phase 2) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nexport const BILL_RUN_MODES = ['real', 'test', 'dry'] as const\nexport type BillRunMode = (typeof BILL_RUN_MODES)[number]\n\nexport const billingRunTriggerSchema = scopedSchema.extend({\n // `triggeredBy` is filled in by the route layer (always 'manual' for\n // API triggers; the cron worker sets 'schedule'). The client cannot\n // forge a 'schedule' trigger \u2014 the field is intentionally omitted\n // from the input shape.\n mode: z.enum(BILL_RUN_MODES).default('real'),\n asOfDate: z.coerce.date().optional(),\n scopedAccountIds: z.array(z.string().uuid()).optional(),\n catchUp: z.boolean().optional(),\n})\n\nexport type BillingRunTriggerInput = z.infer<typeof billingRunTriggerSchema>\n\nexport const billingRunRetryFailedSchema = scopedSchema.extend({\n billRunId: z.string().uuid(),\n mode: z.enum(BILL_RUN_MODES).default('real'),\n})\n\nexport type BillingRunRetryFailedInput = z.infer<typeof billingRunRetryFailedSchema>\n\nexport const billingRunListQuerySchema = z\n .object({\n ...listPaginationBase,\n id: z.string().uuid().optional(),\n search: z.string().optional(),\n status: z.enum(BILL_RUN_STATUSES).optional(),\n triggeredBy: z.enum(BILL_RUN_TRIGGERS).optional(),\n parentRunId: z.string().uuid().optional(),\n asOfDateFrom: z.coerce.date().optional(),\n asOfDateTo: z.coerce.date().optional(),\n })\n .passthrough()\n\nexport type BillingRunListQuery = z.infer<typeof billingRunListQuerySchema>\n\n// \u2500\u2500\u2500 Invoice post (Phase 4) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nexport const billingInvoicePostSchema = scopedSchema.extend({\n invoiceId: z.string().uuid(),\n})\n\nexport type BillingInvoicePostInput = z.infer<typeof billingInvoicePostSchema>\n\n// \u2500\u2500\u2500 Draft invoice edits (Phase 4b) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n/**\n * Fields the operator may change on a draft invoice line. Per spec:\n * \"operator CAN: add lines, remove lines, edit line description /\n * quantity / unit_price / amount\". `taxRate` is owned by core/sales\n * tax service and `currencyCode` is frozen at account create \u2014 both\n * intentionally absent from this schema.\n */\nconst lineEditableFields = z.object({\n description: z.string().trim().min(1).max(500).optional(),\n quantity: z.coerce.number().finite().nonnegative().optional(),\n unitPriceNet: z.coerce.number().finite().optional(),\n // `totalNetAmount` is operator-overridable for the \"I know better\n // than `unit_price \u00D7 quantity`\" cases (rare; mostly for negative\n // credits or rounding fix-ups). When provided, it short-circuits\n // the auto-compute path.\n totalNetAmount: z.coerce.number().finite().optional(),\n})\n\nexport const billingInvoiceEditLineSchema = scopedSchema.extend({\n invoiceId: z.string().uuid(),\n invoiceLineId: z.string().uuid(),\n changes: lineEditableFields,\n})\n\nexport type BillingInvoiceEditLineInput = z.infer<typeof billingInvoiceEditLineSchema>\n\nexport const billingInvoiceAddLineSchema = scopedSchema.extend({\n invoiceId: z.string().uuid(),\n description: z.string().trim().min(1).max(500),\n quantity: z.coerce.number().finite().nonnegative(),\n unitPriceNet: z.coerce.number().finite(),\n // Optional metadata for traceability \u2014 typically operators leave\n // `billing_item_id` blank because ad-hoc lines aren't tied to a\n // Billing Item.\n billingItemId: z.string().uuid().optional(),\n billingType: z.enum(BILLING_ITEM_TYPES).optional(),\n})\n\nexport type BillingInvoiceAddLineInput = z.infer<typeof billingInvoiceAddLineSchema>\n\nexport const billingInvoiceRemoveLineSchema = scopedSchema.extend({\n invoiceId: z.string().uuid(),\n invoiceLineId: z.string().uuid(),\n})\n\nexport type BillingInvoiceRemoveLineInput = z.infer<typeof billingInvoiceRemoveLineSchema>\n\n// \u2500\u2500\u2500 Test-invoices wipe (Phase 4b) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nexport const billingWipeTestInvoicesSchema = scopedSchema.extend({\n /** Optional \u2014 when set, wipes only test invoices from this run. */\n billRunId: z.string().uuid().optional(),\n})\n\nexport type BillingWipeTestInvoicesInput = z.infer<typeof billingWipeTestInvoicesSchema>\n\n// \u2500\u2500\u2500 Prepaid: top-ups (SPEC-002 P2) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nexport const billingTopupCreateSchema = scopedSchema.extend({\n // The route maps the `/accounts/{id}/topups` path param into billAccountId.\n billAccountId: z.string().uuid(),\n amount: z.number().finite().positive(),\n // Optional \u2014 defaults to the tenant config `prepaid.topup_provider`.\n providerKey: z.string().trim().min(1).max(64).optional(),\n successUrl: z.string().trim().url().max(2048).optional(),\n cancelUrl: z.string().trim().url().max(2048).optional(),\n // Optional idempotency for the initiating request.\n sourceRef: z.string().trim().min(1).max(255).optional(),\n})\n\nexport type BillingTopupCreateInput = z.infer<typeof billingTopupCreateSchema>\n\nexport const billingTopupListQuerySchema = z\n .object({\n ...listPaginationBase,\n id: z.string().uuid().optional(),\n billAccountId: z.string().uuid().optional(),\n status: z.enum(TOPUP_STATUSES).optional(),\n search: z.string().optional(),\n })\n .passthrough()\n\nexport type BillingTopupListQuery = z.infer<typeof billingTopupListQuerySchema>\n\n// \u2500\u2500\u2500 Prepaid: transactions / manual adjustments (SPEC-002 P1/P5) \u2500\u2500\n\nexport const billingTransactionAdjustSchema = scopedSchema\n .extend({\n billAccountId: z.string().uuid(),\n // SIGNED: > 0 credit, < 0 debit. Zero is rejected.\n amount: z.number().finite(),\n description: z.string().trim().min(1).max(500),\n sourceRef: z.string().trim().min(1).max(255).optional(),\n })\n .superRefine((val, ctx) => {\n if (val.amount === 0) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['amount'],\n message: 'amount must be non-zero (positive credit or negative debit)',\n })\n }\n })\n\nexport type BillingTransactionAdjustInput = z.infer<typeof billingTransactionAdjustSchema>\n\nexport const billingTransactionListQuerySchema = z\n .object({\n ...listPaginationBase,\n id: z.string().uuid().optional(),\n billAccountId: z.string().uuid().optional(),\n type: z.enum(TRANSACTION_TYPES).optional(),\n createdFrom: z.coerce.date().optional(),\n createdTo: z.coerce.date().optional(),\n })\n .passthrough()\n\nexport type BillingTransactionListQuery = z.infer<typeof billingTransactionListQuerySchema>\n\n// \u2500\u2500\u2500 Prepaid: statements (SPEC-002 P3) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nexport const billingStatementGenerateSchema = scopedSchema.extend({\n billAccountId: z.string().uuid(),\n // \"today\" the close evaluates the due period against. Defaults to now.\n asOfDate: z.coerce.date().optional(),\n})\n\nexport type BillingStatementGenerateInput = z.infer<typeof billingStatementGenerateSchema>\n\nexport const billingStatementListQuerySchema = z\n .object({\n ...listPaginationBase,\n id: z.string().uuid().optional(),\n billAccountId: z.string().uuid().optional(),\n status: z.enum(STATEMENT_STATUSES).optional(),\n periodEndFrom: z.coerce.date().optional(),\n periodEndTo: z.coerce.date().optional(),\n })\n .passthrough()\n\nexport type BillingStatementListQuery = z.infer<typeof billingStatementListQuerySchema>\n\n\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,SAAS;AAIX,MAAM,qBAAqB,CAAC,YAAY,aAAa,OAAO;AAG5D,MAAM,cAAc,CAAC,UAAU,WAAW,aAAa,UAAU;AAGjE,MAAM,oBAAoB,CAAC,YAAY,QAAQ;AAG/C,MAAM,oBAAoB,CAAC,WAAW,aAAa,mBAAmB,QAAQ;AAG9E,MAAM,4BAA4B;AAAA,EACvC;AAAA,EACA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AAS;AAAA,EAC1C,MAAM,EAAE,KAAK,iBAAiB,EAAE,SAAS;AAAA,EACzC,aAAa,EAAE,OAAO,KAAK,EAAE,SAAS;AAAA,EACtC,WAAW,EAAE,OAAO,KAAK,EAAE,SAAS;AACtC,CAAC,EACA,YAAY;AAMR,MAAM,iCAAiC,aAAa,OAAO;AAAA,EAChE,eAAe,EAAE,OAAO,EAAE,KAAK;AAAA;AAAA,EAE/B,UAAU,EAAE,OAAO,KAAK,EAAE,SAAS;AACrC,CAAC;AAIM,MAAM,kCAAkC,EAC5C,OAAO;AAAA,EACN,GAAG;AAAA,EACH,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS;AAAA,EAC/B,eAAe,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS;AAAA,EAC1C,QAAQ,EAAE,KAAK,kBAAkB,EAAE,SAAS;AAAA,EAC5C,eAAe,EAAE,OAAO,KAAK,EAAE,SAAS;AAAA,EACxC,aAAa,EAAE,OAAO,KAAK,EAAE,SAAS;AACxC,CAAC,EACA,YAAY;",
|
|
4
|
+
"sourcesContent": ["import { z } from 'zod'\nimport { DEFAULT_INVOICE_LANGUAGE, INVOICE_LANGUAGE_CODES } from '../lib/invoiceLanguages'\nimport { DOCUMENT_SERIES, validateMask } from '../lib/numbering'\nimport { isValidBic, isValidIban, normalizeIban } from '../lib/iban'\n\n// \u2500\u2500\u2500 Enums \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nexport const BILLING_ITEM_TYPES = ['one_time', 'recurring', 'usage'] as const\nexport type BillingItemType = (typeof BILLING_ITEM_TYPES)[number]\n\nexport const BILL_CYCLES = ['weekly', 'monthly', 'quarterly', 'annually'] as const\nexport type BillCycle = (typeof BILL_CYCLES)[number]\n\n// Spec A: when a recurring item is charged relative to the bill date \u2014\n// for the coming period (in advance, default) or the period just ended.\nexport const CHARGE_TIMINGS = ['in_advance', 'in_arrears'] as const\nexport type ChargeTiming = (typeof CHARGE_TIMINGS)[number]\n\n// Spec F (F-D2): the basis the item price was entered on.\nexport const PRICE_BASES = ['net', 'gross'] as const\nexport type PriceBasis = (typeof PRICE_BASES)[number]\n\n// Spec F (F-D3): where prepaid VAT is charged.\nexport const PREPAID_TAX_POINTS = ['topup', 'consumption'] as const\nexport type PrepaidTaxPoint = (typeof PREPAID_TAX_POINTS)[number]\n\nexport const BILL_RUN_TRIGGERS = ['schedule', 'manual'] as const\nexport type BillRunTrigger = (typeof BILL_RUN_TRIGGERS)[number]\n\nexport const BILL_RUN_STATUSES = ['running', 'completed', 'partial_failure', 'failed'] as const\nexport type BillRunStatus = (typeof BILL_RUN_STATUSES)[number]\n\nexport const BILL_RUN_OUTCOME_STATUSES = [\n 'success',\n 'success_with_warnings',\n 'skipped_existing_draft',\n // SPEC-002: prepaid period close was skipped because a statement already\n // exists for the window.\n 'skipped_existing_statement',\n 'failed',\n] as const\nexport type BillRunOutcomeStatus = (typeof BILL_RUN_OUTCOME_STATUSES)[number]\n\nexport const DRAFT_INVOICE_EDIT_ACTIONS = ['line_added', 'line_removed', 'line_edited'] as const\nexport type DraftInvoiceEditAction = (typeof DRAFT_INVOICE_EDIT_ACTIONS)[number]\n\n// Spec 0: billing-owned document statuses. No 'void' \u2014 a posted document is\n// only neutralised by a credit memo ('credited'); drafts are deleted.\nexport const INVOICE_STATUSES = ['draft', 'posted', 'partially_paid', 'paid', 'credited'] as const\nexport type InvoiceStatus = (typeof INVOICE_STATUSES)[number]\n\nexport const DOCUMENT_TYPES = ['invoice', 'credit_memo', 'debit_memo', 'receipt'] as const\nexport type DocumentType = (typeof DOCUMENT_TYPES)[number]\n\n// \u2500\u2500\u2500 Prepaid (SPEC-002) enums \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nexport const BILLING_MODES = ['postpaid', 'prepaid'] as const\nexport type BillingMode = (typeof BILLING_MODES)[number]\n\nexport const TRANSACTION_TYPES = [\n 'topup',\n 'usage',\n 'recurring',\n 'one_time',\n 'adjustment',\n 'reversal',\n] as const\nexport type TransactionType = (typeof TRANSACTION_TYPES)[number]\n\nexport const TOPUP_STATUSES = [\n 'pending',\n 'captured',\n 'failed',\n 'expired',\n 'cancelled',\n] as const\nexport type TopupStatus = (typeof TOPUP_STATUSES)[number]\n\n// Spec E (B2C): a billing account belongs to a company or a person. Both\n// live in the customers module under one `customer_entities` id space, so\n// `customer_id` is kind-agnostic \u2014 `customer_kind` only drives the lookup\n// and the label.\nexport const CUSTOMER_KINDS = ['company', 'person'] as const\nexport type CustomerKind = (typeof CUSTOMER_KINDS)[number]\n\nexport const STATEMENT_STATUSES = ['generated', 'sent'] as const\nexport type StatementStatus = (typeof STATEMENT_STATUSES)[number]\n\n// Prepaid funds status (the account's own money).\nexport const BALANCE_STATUSES = ['ok', 'low', 'exhausted'] as const\nexport type BalanceStatus = (typeof BALANCE_STATUSES)[number]\n\n// Credit-line status (extended overdraft / AR exposure \u2014 both modes).\nexport const CREDIT_STATUSES = ['within_limit', 'near_limit', 'over_limit'] as const\nexport type CreditStatus = (typeof CREDIT_STATUSES)[number]\n\n// `mon`\u2013`sun` for weekly cycles; 1\u201328 (as text) for the others.\n// Why text for numeric anchors: the column type stays uniform across cycles\n// and we never do arithmetic on the raw value (the engine parses it on use).\nconst WEEKLY_ANCHORS = ['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun'] as const\n\nexport const billCycleAnchorSchema = z\n .string()\n .min(1)\n .refine(\n (val) => {\n if ((WEEKLY_ANCHORS as readonly string[]).includes(val.toLowerCase())) return true\n const n = Number.parseInt(val, 10)\n return Number.isInteger(n) && n >= 1 && n <= 28\n },\n {\n message:\n 'bill_cycle_anchor must be 1\u201328 (monthly/quarterly/annually) or mon\u2013sun (weekly)',\n },\n )\n\n// \u2500\u2500\u2500 rate_json \u2014 pricing definitions \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n//\n// Validated at API ingress so the engine can trust the shape downstream.\n// Negative amounts are intentionally allowed only on `one_time` (refunds /\n// credits / proration credits). Recurring and usage unit prices MUST be\n// non-negative \u2014 discounts on those are modeled as separate `one_time`\n// credit items.\n\nconst numericNonNegative = z.number().finite().nonnegative()\nconst numericAny = z.number().finite()\n\nexport const rateJsonOneTime = z\n .object({ amount: numericAny })\n .strict()\n\nexport const rateJsonRecurring = z\n .object({ unit_price: numericNonNegative })\n .strict()\n\nexport const rateJsonUsageSimple = z\n .object({ unit_price: numericNonNegative })\n .strict()\n\nconst tierWithUnitPrice = z\n .object({\n up_to: z.union([z.number().int().positive(), z.null()]),\n unit_price: numericNonNegative,\n })\n .strict()\n\nconst tierWithFlatAmount = z\n .object({\n up_to: z.union([z.number().int().positive(), z.null()]),\n flat_amount: numericNonNegative,\n })\n .strict()\n\n// All tiers must use the same key shape (consistent with the model). Mixing\n// `unit_price` and `flat_amount` across tiers is rejected \u2014 see spec\n// validation rules.\nconst tiersUnitPrice = z\n .array(tierWithUnitPrice)\n .min(1, 'tiers must be a non-empty array')\nconst tiersFlatAmount = z\n .array(tierWithFlatAmount)\n .min(1, 'tiers must be a non-empty array')\n\nfunction refineTierProgression<T extends { up_to: number | null }>(\n tiers: T[],\n ctx: z.RefinementCtx,\n): void {\n const openTopCount = tiers.filter((t) => t.up_to === null).length\n if (openTopCount !== 1) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: 'tiers must contain exactly one open-ended top tier (up_to: null)',\n })\n return\n }\n if (tiers[tiers.length - 1].up_to !== null) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: 'the open-ended top tier (up_to: null) must be the last entry',\n })\n return\n }\n for (let i = 1; i < tiers.length - 1; i++) {\n const prev = tiers[i - 1].up_to\n const curr = tiers[i].up_to\n if (prev !== null && curr !== null && curr <= prev) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: `up_to values must be strictly increasing across tiers (failed at index ${i})`,\n })\n return\n }\n }\n}\n\nexport const rateJsonUsageVolume = z\n .object({\n model: z.literal('volume'),\n tiers: tiersUnitPrice,\n })\n .strict()\n .superRefine((val, ctx) => refineTierProgression(val.tiers, ctx))\n\nexport const rateJsonUsageGraduated = z\n .object({\n model: z.literal('graduated'),\n tiers: tiersUnitPrice,\n })\n .strict()\n .superRefine((val, ctx) => refineTierProgression(val.tiers, ctx))\n\nexport const rateJsonUsageFlat = z\n .object({\n model: z.literal('flat'),\n tiers: tiersFlatAmount,\n })\n .strict()\n .superRefine((val, ctx) => refineTierProgression(val.tiers, ctx))\n\nexport const rateJsonUsageTiered = z.discriminatedUnion('model', [\n rateJsonUsageVolume,\n rateJsonUsageGraduated,\n rateJsonUsageFlat,\n])\n\nexport const rateJsonUsage = z.union([rateJsonUsageSimple, rateJsonUsageTiered])\n\n/**\n * Validate a `rate_json` payload against the rules for a given Billing Item\n * `type`. Returns the parsed value or throws a `ZodError` whose message\n * surfaces the specific shape violation.\n */\nexport function validateRateJson(\n type: BillingItemType,\n rateJson: unknown,\n):\n | z.infer<typeof rateJsonOneTime>\n | z.infer<typeof rateJsonRecurring>\n | z.infer<typeof rateJsonUsage> {\n switch (type) {\n case 'one_time':\n return rateJsonOneTime.parse(rateJson)\n case 'recurring':\n return rateJsonRecurring.parse(rateJson)\n case 'usage':\n return rateJsonUsage.parse(rateJson)\n }\n}\n\n// \u2500\u2500\u2500 Invoice address (BillingAccount.invoice_address) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nexport const invoiceAddressSchema = z\n .object({\n line1: z.string().min(1),\n line2: z.string().optional(),\n city: z.string().min(1),\n postal_code: z.string().min(1),\n country: z.string().min(2).max(3), // ISO 3166-1 alpha-2 or alpha-3\n })\n .strict()\n\nexport type InvoiceAddress = z.infer<typeof invoiceAddressSchema>\n\n// \u2500\u2500\u2500 Scope (injected by withScopedPayload at API ingress) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nconst scopedSchema = z.object({\n tenantId: z.string().uuid(),\n organizationId: z.string().uuid(),\n})\n\n// \u2500\u2500\u2500 List pagination (shared shape) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nconst listPaginationBase = {\n page: z.coerce.number().int().min(1).default(1),\n pageSize: z.coerce.number().int().min(1).max(100).default(50),\n sortField: z.string().optional(),\n sortDir: z.enum(['asc', 'desc']).optional(),\n}\n\n// \u2500\u2500\u2500 BillingAccount payloads \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n// numeric(18,4) money inputs arrive as numbers; the command coerces to a\n// 4dp string at persist time.\nconst moneyNonNegative = z.number().finite().nonnegative()\n\n// Invoice language must be one the document template supports (Spec E, D22).\n// Case/whitespace-tolerant on input, canonical lowercase code on output.\n// Spec B: payment terms in days (0 = due on issue).\nconst paymentTermsDaysSchema = z.coerce.number().int().min(0).max(365)\n\nconst invoiceLanguageSchema = z.string().trim().toLowerCase().pipe(z.enum(INVOICE_LANGUAGE_CODES))\n\nexport const billingAccountCreateSchema = scopedSchema.extend({\n customerId: z.string().min(1).max(255),\n // Immutable after create (like customerId). Default 'company' keeps\n // existing callers (CPQ connector, seeds) unaffected.\n customerKind: z.enum(CUSTOMER_KINDS).default('company'),\n name: z.string().trim().min(1).max(255),\n currencyCode: z.string().trim().toUpperCase().length(3),\n billCycle: z.enum(BILL_CYCLES),\n billCycleAnchor: billCycleAnchorSchema,\n invoiceEmail: z.string().trim().email().max(320),\n invoiceLanguage: invoiceLanguageSchema.default(DEFAULT_INVOICE_LANGUAGE),\n // Nullable + optional \u2014 consistent with the update schema, and the\n // cpq-billing-connector's shell-account seed sends `taxId: null`\n // for customers with no tax id.\n taxId: z.string().trim().max(64).nullable().optional(),\n invoiceAddress: invoiceAddressSchema,\n nextBillDate: z.coerce.date(),\n lastBillDate: z.coerce.date().optional(),\n isActive: z.boolean().optional(),\n // SPEC-002: mode is immutable after create (like currencyCode). Default\n // 'postpaid' so existing callers are unaffected.\n billingMode: z.enum(BILLING_MODES).optional(),\n // Credit line (both modes). 0 = no credit.\n creditLimit: moneyNonNegative.optional(),\n // Initial low-balance threshold for a prepaid account's balance row.\n // Null = resolve the tenant config default at read time.\n lowBalanceThreshold: moneyNonNegative.nullable().optional(),\n // Spec B: null/omitted = the organization default payment terms.\n paymentTermsDays: paymentTermsDaysSchema.nullable().optional(),\n autoSendInvoice: z.boolean().optional(),\n})\n\nexport type BillingAccountCreateInput = z.infer<typeof billingAccountCreateSchema>\n\nexport const billingAccountUpdateSchema = scopedSchema.extend({\n id: z.string().uuid(),\n name: z.string().trim().min(1).max(255).optional(),\n billCycle: z.enum(BILL_CYCLES).optional(),\n billCycleAnchor: billCycleAnchorSchema.optional(),\n invoiceEmail: z.string().trim().email().max(320).optional(),\n invoiceLanguage: invoiceLanguageSchema.optional(),\n taxId: z.string().trim().max(64).nullable().optional(),\n invoiceAddress: invoiceAddressSchema.optional(),\n nextBillDate: z.coerce.date().optional(),\n lastBillDate: z.coerce.date().nullable().optional(),\n isActive: z.boolean().optional(),\n // SPEC-002: credit_limit is editable (it's an AR/overdraft policy knob);\n // `billingMode` is intentionally NOT updatable \u2014 mode is frozen at create\n // (like currencyCode), no live postpaid\u2194prepaid switch in v1.\n creditLimit: moneyNonNegative.optional(),\n // Editing the prepaid balance row's low-balance threshold. Null clears it\n // back to the tenant config default.\n lowBalanceThreshold: moneyNonNegative.nullable().optional(),\n paymentTermsDays: paymentTermsDaysSchema.nullable().optional(),\n autoSendInvoice: z.boolean().optional(),\n // `currencyCode` is intentionally NOT updatable \u2014 currency is frozen at\n // account create time so historical invoices keep their currency context.\n // `customerId` is also immutable; create a new account if the customer\n // FK changes. `customerKind` follows `customerId` and is likewise not\n // updatable.\n})\n\nexport type BillingAccountUpdateInput = z.infer<typeof billingAccountUpdateSchema>\n\nexport const billingAccountDeleteSchema = scopedSchema.extend({\n id: z.string().uuid(),\n})\n\nexport type BillingAccountDeleteInput = z.infer<typeof billingAccountDeleteSchema>\n\nexport const billingAccountListQuerySchema = z\n .object({\n ...listPaginationBase,\n id: z.string().uuid().optional(),\n customerId: z.string().optional(),\n customerKind: z.enum(CUSTOMER_KINDS).optional(),\n currencyCode: z.string().optional(),\n billCycle: z.enum(BILL_CYCLES).optional(),\n billingMode: z.enum(BILLING_MODES).optional(),\n isActive: z.coerce.boolean().optional(),\n search: z.string().optional(),\n // Spec F (F8): only accounts with at least one overdue receivable.\n hasOverdue: z\n .union([z.boolean(), z.enum(['true', 'false'])])\n .transform((value) => value === true || value === 'true')\n .optional(),\n })\n .passthrough()\n\nexport type BillingAccountListQuery = z.infer<typeof billingAccountListQuerySchema>\n\n// \u2500\u2500\u2500 BillingItem payloads \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n// Spec A: `chargeTiming` / `prorate` only mean something for recurring\n// items. Omitted \u2192 the command applies the defaults (in_advance, true).\n// Setting a non-default value on another type is a client mistake.\n// Spec B (B-D1): VAT rate in percent. Omitted on create \u2192 the command fills\n// the organization default; never re-filled on update.\nconst taxRateSchema = z.coerce.number().finite().min(0).max(100)\n\nconst chargeTimingFields = {\n chargeTiming: z.enum(CHARGE_TIMINGS).optional(),\n prorate: z.boolean().optional(),\n // Spec F (F-D2). Omitted \u2192 'net' on create; unchanged on update.\n priceBasis: z.enum(PRICE_BASES).optional(),\n}\n\nexport const GROSS_TIERED_UNSUPPORTED_MESSAGE = 'billing.item.gross_tiered_unsupported'\n\n/** Tiered usage rates (`{ model, tiers }`) are always net (Spec F, P-D4). */\nexport function isTieredRate(rateJson: unknown): boolean {\n return typeof rateJson === 'object' && rateJson !== null && 'model' in rateJson && 'tiers' in rateJson\n}\n\nfunction refinePriceBasis(val: { priceBasis?: PriceBasis; rateJson: unknown }, ctx: z.RefinementCtx): void {\n if (val.priceBasis === 'gross' && isTieredRate(val.rateJson)) {\n ctx.addIssue({ code: z.ZodIssueCode.custom, path: ['priceBasis'], message: GROSS_TIERED_UNSUPPORTED_MESSAGE })\n }\n}\n\nexport const CHARGE_TIMING_RECURRING_ONLY_MESSAGE =\n 'chargeTiming / prorate can only be set on recurring items'\n\nfunction refineChargeTiming(\n val: { type: BillingItemType; chargeTiming?: ChargeTiming; prorate?: boolean },\n ctx: z.RefinementCtx,\n): void {\n if (val.type === 'recurring') return\n if (val.chargeTiming !== undefined && val.chargeTiming !== 'in_advance') {\n ctx.addIssue({ code: z.ZodIssueCode.custom, path: ['chargeTiming'], message: CHARGE_TIMING_RECURRING_ONLY_MESSAGE })\n }\n if (val.prorate === false) {\n ctx.addIssue({ code: z.ZodIssueCode.custom, path: ['prorate'], message: CHARGE_TIMING_RECURRING_ONLY_MESSAGE })\n }\n}\n\nconst ratePayloadByType = z\n .object({\n type: z.enum(BILLING_ITEM_TYPES),\n rateJson: z.unknown(),\n })\n .superRefine((val, ctx) => {\n try {\n validateRateJson(val.type, val.rateJson)\n } catch (err) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['rateJson'],\n message: err instanceof Error ? err.message : 'rate_json is invalid for this type',\n })\n }\n })\n\nexport const billingItemCreateSchema = scopedSchema\n .extend({\n billAccountId: z.string().uuid(),\n type: z.enum(BILLING_ITEM_TYPES),\n billStartDate: z.coerce.date(),\n billEndDate: z.coerce.date().nullable().optional(),\n description: z.string().trim().min(1).max(500),\n rateJson: z.unknown(), // shape validated via the refine below\n uomCode: z.string().trim().max(64).optional(),\n subscriptionId: z.string().trim().max(255).optional(),\n subscriptionItemId: z.string().trim().max(255).optional(),\n // `source_ref` is the idempotency key. NULL \u2192 no dedup, always create.\n sourceRef: z.string().trim().min(1).max(255).optional(),\n taxRate: taxRateSchema.optional(),\n ...chargeTimingFields,\n // currency_mismatch and billed_to_date are system-managed, never set by\n // clients on create.\n })\n .superRefine((val, ctx) => {\n refineChargeTiming(val, ctx)\n refinePriceBasis(val, ctx)\n try {\n validateRateJson(val.type, val.rateJson)\n } catch (err) {\n const message = err instanceof Error ? err.message : 'rate_json is invalid for this type'\n ctx.addIssue({ code: z.ZodIssueCode.custom, path: ['rateJson'], message })\n }\n if (val.type === 'usage' && !val.uomCode) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['uomCode'],\n message: 'uomCode is required for type=usage',\n })\n }\n })\n\nexport type BillingItemCreateInput = z.infer<typeof billingItemCreateSchema>\n\n// \u2500\u2500\u2500 Bulk item create (Phase 4g) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n//\n// One scope envelope, N item payloads. The CPQ connector activating\n// a large subscription used to fire one `billing.items.create` per\n// charge \u2014 bulk-create collapses that into a single command with a\n// batched `source_ref` idempotency check + single flush.\n\nconst billingItemBulkEntrySchema = z\n .object({\n billAccountId: z.string().uuid(),\n type: z.enum(BILLING_ITEM_TYPES),\n billStartDate: z.coerce.date(),\n billEndDate: z.coerce.date().nullable().optional(),\n description: z.string().trim().min(1).max(500),\n rateJson: z.unknown(),\n uomCode: z.string().trim().max(64).optional(),\n subscriptionId: z.string().trim().max(255).optional(),\n subscriptionItemId: z.string().trim().max(255).optional(),\n sourceRef: z.string().trim().min(1).max(255).optional(),\n taxRate: taxRateSchema.optional(),\n ...chargeTimingFields,\n })\n .superRefine((val, ctx) => {\n refineChargeTiming(val, ctx)\n refinePriceBasis(val, ctx)\n try {\n validateRateJson(val.type, val.rateJson)\n } catch (err) {\n const message = err instanceof Error ? err.message : 'rate_json is invalid for this type'\n ctx.addIssue({ code: z.ZodIssueCode.custom, path: ['rateJson'], message })\n }\n if (val.type === 'usage' && !val.uomCode) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['uomCode'],\n message: 'uomCode is required for type=usage',\n })\n }\n })\n\nexport type BillingItemBulkEntry = z.infer<typeof billingItemBulkEntrySchema>\n\nexport const billingItemBulkCreateSchema = scopedSchema.extend({\n // Cap at 500 per call \u2014 keeps a single bulk transaction bounded.\n // A CPQ subscription with >500 charges should be split by the\n // caller (the connector); 500 is already far past any realistic\n // single-subscription charge count.\n items: z.array(billingItemBulkEntrySchema).min(1).max(500),\n})\n\nexport type BillingItemBulkCreateInput = z.infer<typeof billingItemBulkCreateSchema>\n\nexport const billingItemUpdateSchema = scopedSchema.extend({\n id: z.string().uuid(),\n // `type` is immutable \u2014 changing one_time \u2192 recurring would silently\n // change billing semantics. Cancel the old item, create a new one.\n billStartDate: z.coerce.date().optional(),\n billEndDate: z.coerce.date().nullable().optional(),\n description: z.string().trim().min(1).max(500).optional(),\n rateJson: z.unknown().optional(),\n uomCode: z.string().trim().max(64).nullable().optional(),\n subscriptionId: z.string().trim().max(255).nullable().optional(),\n subscriptionItemId: z.string().trim().max(255).nullable().optional(),\n // `source_ref` immutable \u2014 it's the idempotency identity of the item.\n isActive: z.boolean().optional(),\n // Affects future invoices only \u2014 posted lines keep their snapshot.\n taxRate: taxRateSchema.optional(),\n // Recurring only (enforced by the command, which knows the item type).\n // Safe to change after billing: the `billed_to_date` watermark prevents\n // any day from being billed twice.\n ...chargeTimingFields,\n})\n\nexport type BillingItemUpdateInput = z.infer<typeof billingItemUpdateSchema>\n\n// Change a recurring item's price from a date on: end the item the day\n// before, start a copy with the new price (see lib/itemPriceChange.ts).\nexport const billingItemChangePriceSchema = scopedSchema.extend({\n id: z.string().uuid(),\n effectiveDate: z.coerce.date(),\n unitPrice: z.coerce.number().finite().nonnegative(),\n})\n\nexport type BillingItemChangePriceInput = z.infer<typeof billingItemChangePriceSchema>\n\nexport const billingItemDeleteSchema = scopedSchema.extend({\n id: z.string().uuid(),\n})\n\nexport type BillingItemDeleteInput = z.infer<typeof billingItemDeleteSchema>\n\nexport const billingItemListQuerySchema = z\n .object({\n ...listPaginationBase,\n id: z.string().uuid().optional(),\n search: z.string().optional(),\n billAccountId: z.string().uuid().optional(),\n type: z.enum(BILLING_ITEM_TYPES).optional(),\n subscriptionId: z.string().optional(),\n isActive: z.coerce.boolean().optional(),\n activeAt: z.coerce.date().optional(), // bill_start_date <= X AND (bill_end_date IS NULL OR bill_end_date >= X)\n })\n .passthrough()\n\nexport type BillingItemListQuery = z.infer<typeof billingItemListQuerySchema>\n\n// \u2500\u2500\u2500 BillingAccountUsage payloads \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nexport const billingUsageCreateSchema = scopedSchema.extend({\n billAccountId: z.string().uuid(),\n uomCode: z.string().trim().min(1).max(64),\n // `quantity` arrives as a number from JSON; MikroORM stores it as\n // numeric(18,4). The service coerces to a string at persist time.\n quantity: z.number().finite().nonnegative(),\n periodStart: z.coerce.date(),\n periodEnd: z.coerce.date(),\n lineDescription: z.string().trim().min(1).max(500).optional(),\n sourceRef: z.string().trim().min(1).max(255).optional(),\n}).superRefine((val, ctx) => {\n if (val.periodEnd < val.periodStart) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['periodEnd'],\n message: 'periodEnd must be on or after periodStart',\n })\n }\n})\n\nexport type BillingUsageCreateInput = z.infer<typeof billingUsageCreateSchema>\n\nexport const billingUsageListQuerySchema = z\n .object({\n ...listPaginationBase,\n billAccountId: z.string().uuid().optional(),\n uomCode: z.string().optional(),\n rated: z.coerce.boolean().optional(), // true \u2192 already rated; false \u2192 unrated\n periodEndFrom: z.coerce.date().optional(),\n periodEndTo: z.coerce.date().optional(),\n })\n .passthrough()\n\nexport type BillingUsageListQuery = z.infer<typeof billingUsageListQuerySchema>\n\n// Suppress unused-export TS warning \u2014 `ratePayloadByType` is reserved for\n// reuse by a future per-tenant rate-validation CLI tool.\nvoid ratePayloadByType\n\n// \u2500\u2500\u2500 Bill Run trigger payloads (Phase 2) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nexport const BILL_RUN_MODES = ['real', 'test', 'dry'] as const\nexport type BillRunMode = (typeof BILL_RUN_MODES)[number]\n\nexport const billingRunTriggerSchema = scopedSchema.extend({\n // `triggeredBy` is filled in by the route layer (always 'manual' for\n // API triggers; the cron worker sets 'schedule'). The client cannot\n // forge a 'schedule' trigger \u2014 the field is intentionally omitted\n // from the input shape.\n mode: z.enum(BILL_RUN_MODES).default('real'),\n asOfDate: z.coerce.date().optional(),\n scopedAccountIds: z.array(z.string().uuid()).optional(),\n // Spec A: there is no `catchUp` flag \u2014 every run bills all due cycles up\n // to `asOfDate`. Old clients still sending it are not rejected: the\n // object schema strips unknown keys.\n})\n\nexport type BillingRunTriggerInput = z.infer<typeof billingRunTriggerSchema>\n\nexport const billingRunRetryFailedSchema = scopedSchema.extend({\n billRunId: z.string().uuid(),\n mode: z.enum(BILL_RUN_MODES).default('real'),\n})\n\nexport type BillingRunRetryFailedInput = z.infer<typeof billingRunRetryFailedSchema>\n\nexport const billingRunListQuerySchema = z\n .object({\n ...listPaginationBase,\n id: z.string().uuid().optional(),\n search: z.string().optional(),\n status: z.enum(BILL_RUN_STATUSES).optional(),\n triggeredBy: z.enum(BILL_RUN_TRIGGERS).optional(),\n parentRunId: z.string().uuid().optional(),\n asOfDateFrom: z.coerce.date().optional(),\n asOfDateTo: z.coerce.date().optional(),\n // Spec F (F1): narrow the list to one run mode.\n mode: z.enum(['real', 'test', 'dry']).optional(),\n })\n .passthrough()\n\nexport type BillingRunListQuery = z.infer<typeof billingRunListQuerySchema>\n\n// \u2500\u2500\u2500 Invoice post (Phase 4) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nexport const billingInvoicePostSchema = scopedSchema.extend({\n invoiceId: z.string().uuid(),\n})\n\nexport type BillingInvoicePostInput = z.infer<typeof billingInvoicePostSchema>\n\n// Spec B \u2014 email a posted document (manual send / resend).\nexport const billingInvoiceSendSchema = scopedSchema.extend({\n invoiceId: z.string().uuid(),\n})\n\nexport type BillingInvoiceSendInput = z.infer<typeof billingInvoiceSendSchema>\n\n// \u2500\u2500\u2500 Draft invoice edits (Phase 4b) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n/**\n * Fields the operator may change on a draft invoice line. Per spec:\n * \"operator CAN: add lines, remove lines, edit line description /\n * quantity / unit_price / amount\". Spec B adds `taxRate` (VAT % of the\n * line). `currencyCode` is frozen at account create and intentionally absent.\n */\nconst lineEditableFields = z.object({\n description: z.string().trim().min(1).max(500).optional(),\n quantity: z.coerce.number().finite().nonnegative().optional(),\n unitPriceNet: z.coerce.number().finite().optional(),\n // `totalNetAmount` is operator-overridable for the \"I know better\n // than `unit_price \u00D7 quantity`\" cases (rare; mostly for negative\n // credits or rounding fix-ups). When provided, it short-circuits\n // the auto-compute path.\n totalNetAmount: z.coerce.number().finite().optional(),\n taxRate: taxRateSchema.optional(),\n})\n\nexport const billingInvoiceEditLineSchema = scopedSchema.extend({\n invoiceId: z.string().uuid(),\n invoiceLineId: z.string().uuid(),\n changes: lineEditableFields,\n})\n\nexport type BillingInvoiceEditLineInput = z.infer<typeof billingInvoiceEditLineSchema>\n\nexport const billingInvoiceAddLineSchema = scopedSchema.extend({\n invoiceId: z.string().uuid(),\n description: z.string().trim().min(1).max(500),\n quantity: z.coerce.number().finite().nonnegative(),\n unitPriceNet: z.coerce.number().finite(),\n // Optional metadata for traceability \u2014 typically operators leave\n // `billing_item_id` blank because ad-hoc lines aren't tied to a\n // Billing Item.\n billingItemId: z.string().uuid().optional(),\n billingType: z.enum(BILLING_ITEM_TYPES).optional(),\n // Omitted \u2192 the organization default VAT rate.\n taxRate: taxRateSchema.optional(),\n})\n\nexport type BillingInvoiceAddLineInput = z.infer<typeof billingInvoiceAddLineSchema>\n\nexport const billingInvoiceRemoveLineSchema = scopedSchema.extend({\n invoiceId: z.string().uuid(),\n invoiceLineId: z.string().uuid(),\n})\n\nexport type BillingInvoiceRemoveLineInput = z.infer<typeof billingInvoiceRemoveLineSchema>\n\n// \u2500\u2500\u2500 Test-invoices wipe (Phase 4b) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nexport const billingWipeTestInvoicesSchema = scopedSchema.extend({\n /** Optional \u2014 when set, wipes only test invoices from this run. */\n billRunId: z.string().uuid().optional(),\n})\n\nexport type BillingWipeTestInvoicesInput = z.infer<typeof billingWipeTestInvoicesSchema>\n\n// Spec F (F-D1): test and dry runs can be deleted (real runs never).\nexport const billingRunDeleteSchema = scopedSchema.extend({\n billRunId: z.string().uuid(),\n})\n\nexport type BillingRunDeleteInput = z.infer<typeof billingRunDeleteSchema>\n\n// Post the draft invoices of a REAL run, one bounded batch per call; the\n// caller passes back `nextCursor` until `remaining` is 0.\nexport const billingRunPostDraftsSchema = scopedSchema.extend({\n billRunId: z.string().uuid(),\n /** Continue after this invoice id (ids are processed in ascending order). */\n afterInvoiceId: z.string().uuid().optional(),\n limit: z.coerce.number().int().min(1).max(100).optional(),\n})\n\nexport type BillingRunPostDraftsInput = z.infer<typeof billingRunPostDraftsSchema>\n\n// \u2500\u2500\u2500 Prepaid: top-ups (SPEC-002 P2) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nexport const billingTopupCreateSchema = scopedSchema.extend({\n // The route maps the `/accounts/{id}/topups` path param into billAccountId.\n billAccountId: z.string().uuid(),\n amount: z.number().finite().positive(),\n // Optional \u2014 defaults to the tenant config `prepaid.topup_provider`.\n providerKey: z.string().trim().min(1).max(64).optional(),\n successUrl: z.string().trim().url().max(2048).optional(),\n cancelUrl: z.string().trim().url().max(2048).optional(),\n // Optional idempotency for the initiating request.\n sourceRef: z.string().trim().min(1).max(255).optional(),\n})\n\nexport type BillingTopupCreateInput = z.infer<typeof billingTopupCreateSchema>\n\nexport const billingTopupListQuerySchema = z\n .object({\n ...listPaginationBase,\n id: z.string().uuid().optional(),\n billAccountId: z.string().uuid().optional(),\n status: z.enum(TOPUP_STATUSES).optional(),\n search: z.string().optional(),\n })\n .passthrough()\n\nexport type BillingTopupListQuery = z.infer<typeof billingTopupListQuerySchema>\n\n// \u2500\u2500\u2500 Prepaid: transactions / manual adjustments (SPEC-002 P1/P5) \u2500\u2500\n\nexport const billingTransactionAdjustSchema = scopedSchema\n .extend({\n billAccountId: z.string().uuid(),\n // SIGNED: > 0 credit, < 0 debit. Zero is rejected.\n amount: z.number().finite(),\n description: z.string().trim().min(1).max(500),\n sourceRef: z.string().trim().min(1).max(255).optional(),\n })\n .superRefine((val, ctx) => {\n if (val.amount === 0) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['amount'],\n message: 'amount must be non-zero (positive credit or negative debit)',\n })\n }\n })\n\nexport type BillingTransactionAdjustInput = z.infer<typeof billingTransactionAdjustSchema>\n\nexport const billingTransactionListQuerySchema = z\n .object({\n ...listPaginationBase,\n id: z.string().uuid().optional(),\n billAccountId: z.string().uuid().optional(),\n type: z.enum(TRANSACTION_TYPES).optional(),\n createdFrom: z.coerce.date().optional(),\n createdTo: z.coerce.date().optional(),\n })\n .passthrough()\n\nexport type BillingTransactionListQuery = z.infer<typeof billingTransactionListQuerySchema>\n\n// \u2500\u2500\u2500 Prepaid: statements (SPEC-002 P3) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nexport const billingStatementGenerateSchema = scopedSchema.extend({\n billAccountId: z.string().uuid(),\n // \"today\" the close evaluates the due period against. Defaults to now.\n asOfDate: z.coerce.date().optional(),\n})\n\nexport type BillingStatementGenerateInput = z.infer<typeof billingStatementGenerateSchema>\n\nexport const billingStatementListQuerySchema = z\n .object({\n ...listPaginationBase,\n id: z.string().uuid().optional(),\n billAccountId: z.string().uuid().optional(),\n status: z.enum(STATEMENT_STATUSES).optional(),\n periodEndFrom: z.coerce.date().optional(),\n periodEndTo: z.coerce.date().optional(),\n })\n .passthrough()\n\nexport type BillingStatementListQuery = z.infer<typeof billingStatementListQuerySchema>\n\n\n\n// \u2500\u2500\u2500 Spec 0 \u2014 invoice ledger + billing settings \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n// Query-string boolean: only the literal strings count (\"false\" must NOT\n// coerce to true the way z.coerce.boolean() would).\nconst queryBoolean = z.preprocess(\n (value) => (value === 'true' || value === true ? true : value === 'false' || value === false ? false : undefined),\n z.boolean().optional(),\n)\n\nexport const billingInvoiceListQuerySchema = z\n .object({\n ...listPaginationBase,\n id: z.string().uuid().optional(),\n status: z.enum(INVOICE_STATUSES).optional(),\n documentType: z.enum(DOCUMENT_TYPES).optional(),\n billRunId: z.string().uuid().optional(),\n billAccountId: z.string().uuid().optional(),\n testRun: queryBoolean,\n search: z.string().trim().max(100).optional(),\n // Spec B: computed overdue (B-D6) and due-date window.\n overdue: queryBoolean,\n dueFrom: z.string().regex(/^\\d{4}-\\d{2}-\\d{2}$/).optional(),\n dueTo: z.string().regex(/^\\d{4}-\\d{2}-\\d{2}$/).optional(),\n })\n .passthrough()\n\nexport type BillingInvoiceListQuery = z.infer<typeof billingInvoiceListQuerySchema>\n\nconst numberMaskSchema = z\n .string()\n .trim()\n .superRefine((mask, ctx) => {\n for (const code of validateMask(mask)) {\n ctx.addIssue({ code: z.ZodIssueCode.custom, message: code })\n }\n })\n\nconst moneyString = z.coerce.number().finite().nonnegative()\n\n/** Trimmed optional text; '' \u2192 null (clears the field). */\nfunction optionalText(max: number) {\n return z\n .string()\n .trim()\n .max(max)\n .transform((value) => (value === '' ? null : value))\n .nullable()\n .optional()\n}\n\n// Seller address: same shape (and country rule) as the buyer's invoice address.\nconst sellerAddressSchema = invoiceAddressSchema\n\nexport const billingSettingsUpdateSchema = scopedSchema.extend({\n lowBalanceThresholdDefault: moneyString.optional(),\n nearLimitBufferDefault: moneyString.optional(),\n statementEnabled: z.boolean().optional(),\n topupTaxRate: z.coerce.number().finite().min(0).max(100).optional(),\n topupProvider: z.string().trim().min(1).max(64).optional(),\n numberMasks: z\n .object(Object.fromEntries(DOCUMENT_SERIES.map((series) => [series, numberMaskSchema.optional()])) as Record<\n (typeof DOCUMENT_SERIES)[number],\n z.ZodOptional<typeof numberMaskSchema>\n >)\n .strict()\n .optional(),\n // Seller / payment / document fields (Spec B). Empty string clears.\n legalName: optionalText(255),\n sellerAddress: sellerAddressSchema.nullable().optional(),\n taxId: optionalText(64),\n bankName: optionalText(255),\n iban: z\n .string()\n .transform(normalizeIban)\n .refine((value) => value === '' || isValidIban(value), { message: 'billing.settings.error.iban_invalid' })\n .transform((value) => (value === '' ? null : value))\n .nullable()\n .optional(),\n bic: z\n .string()\n .trim()\n .toUpperCase()\n .refine((value) => value === '' || isValidBic(value), { message: 'billing.settings.error.bic_invalid' })\n .transform((value) => (value === '' ? null : value))\n .nullable()\n .optional(),\n invoiceFooter: optionalText(2000),\n logoAttachmentId: z.string().uuid().nullable().optional(),\n defaultPaymentTermsDays: paymentTermsDaysSchema.optional(),\n defaultTaxRate: taxRateSchema.optional(),\n // Spec F (F-D3).\n prepaidTaxPoint: z.enum(PREPAID_TAX_POINTS).optional(),\n})\n\nexport type BillingSettingsUpdateInput = z.infer<typeof billingSettingsUpdateSchema>\n\n// \u2500\u2500\u2500 Spec C \u2014 payments \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nexport const PAYMENT_STATUSES = [\n 'unmatched',\n 'matched',\n 'partially_allocated',\n 'allocated',\n 'ignored',\n 'converted_to_topup',\n] as const\nexport type PaymentStatus = (typeof PAYMENT_STATUSES)[number]\n\nexport const PAYMENT_SOURCES = ['csv', 'manual', 'gateway'] as const\nexport type PaymentSource = (typeof PAYMENT_SOURCES)[number]\n\nexport const PAYMENT_MATCH_REASONS = [\n 'no_reference',\n 'currency_mismatch',\n 'invoice_already_paid',\n 'prepaid_account',\n 'manual',\n] as const\nexport type PaymentMatchReason = (typeof PAYMENT_MATCH_REASONS)[number]\n\nexport const ALLOCATION_SOURCE_TYPES = ['payment', 'credit_memo'] as const\nexport type AllocationSourceType = (typeof ALLOCATION_SOURCE_TYPES)[number]\n\nexport const ALLOCATED_BY = ['auto', 'credit', 'user', 'gateway'] as const\nexport type AllocatedBy = (typeof ALLOCATED_BY)[number]\n\nconst isoDateString = z.string().regex(/^\\d{4}-\\d{2}-\\d{2}$/)\nconst positiveMoney = z.coerce.number().finite().positive()\n\nexport const billingPaymentCreateSchema = scopedSchema.extend({\n receivedAt: isoDateString,\n amount: positiveMoney,\n currencyCode: z.string().trim().toUpperCase().length(3),\n reference: z.string().trim().max(500).optional(),\n payerName: z.string().trim().max(255).optional(),\n payerAccount: z.string().trim().max(64).optional(),\n // Known account \u2192 status `matched` and credit auto-apply; else `unmatched`.\n billAccountId: z.string().uuid().optional(),\n})\nexport type BillingPaymentCreateInput = z.infer<typeof billingPaymentCreateSchema>\n\nexport const billingPaymentAssignSchema = scopedSchema.extend({\n paymentId: z.string().uuid(),\n billAccountId: z.string().uuid(),\n})\nexport type BillingPaymentAssignInput = z.infer<typeof billingPaymentAssignSchema>\n\nexport const billingPaymentAllocateSchema = scopedSchema.extend({\n paymentId: z.string().uuid(),\n allocations: z\n .array(z.object({ invoiceId: z.string().uuid(), amount: positiveMoney }))\n .min(1)\n .max(100),\n})\nexport type BillingPaymentAllocateInput = z.infer<typeof billingPaymentAllocateSchema>\n\nexport const billingAllocationRemoveSchema = scopedSchema.extend({\n allocationId: z.string().uuid(),\n})\nexport type BillingAllocationRemoveInput = z.infer<typeof billingAllocationRemoveSchema>\n\nexport const billingPaymentIdSchema = scopedSchema.extend({\n paymentId: z.string().uuid(),\n})\nexport type BillingPaymentIdInput = z.infer<typeof billingPaymentIdSchema>\n\nexport const billingPaymentConvertSchema = scopedSchema.extend({\n paymentId: z.string().uuid(),\n billAccountId: z.string().uuid(),\n})\nexport type BillingPaymentConvertInput = z.infer<typeof billingPaymentConvertSchema>\n\n// CSV upload: 2 MB of text, \u2264 5,000 data rows (checked by the parser).\nexport const PAYMENT_IMPORT_MAX_BYTES = 2 * 1024 * 1024\nexport const PAYMENT_IMPORT_MAX_ROWS = 5000\n\nexport const billingPaymentImportSchema = scopedSchema.extend({\n fileName: z.string().trim().min(1).max(255),\n content: z.string().max(PAYMENT_IMPORT_MAX_BYTES),\n})\nexport type BillingPaymentImportInput = z.infer<typeof billingPaymentImportSchema>\n\nexport const billingPaymentListQuerySchema = z\n .object({\n ...listPaginationBase,\n id: z.string().uuid().optional(),\n status: z.enum(PAYMENT_STATUSES).optional(),\n billAccountId: z.string().uuid().optional(),\n importId: z.string().uuid().optional(),\n receivedFrom: isoDateString.optional(),\n receivedTo: isoDateString.optional(),\n search: z.string().trim().max(100).optional(),\n })\n .passthrough()\nexport type BillingPaymentListQuery = z.infer<typeof billingPaymentListQuerySchema>\n\nexport const billingPaymentImportListQuerySchema = z\n .object({ ...listPaginationBase, id: z.string().uuid().optional() })\n .passthrough()\nexport type BillingPaymentImportListQuery = z.infer<typeof billingPaymentImportListQuerySchema>\n\n// \u2500\u2500\u2500 Spec D \u2014 credit / debit memos \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nexport const MEMO_TYPES = ['credit_memo', 'debit_memo'] as const\nexport type MemoType = (typeof MEMO_TYPES)[number]\n\nconst memoLineSchema = z.object({\n // Copied from the original (credit prefill). The original line's VAT rate wins.\n correctsLineId: z.string().uuid().optional(),\n description: z.string().trim().min(1).max(500),\n quantity: z.coerce.number().finite().positive(),\n unitPriceNet: z.coerce.number().finite().nonnegative(),\n // New lines: omitted \u2192 organization default rate.\n taxRate: z.coerce.number().finite().min(0).max(100).optional(),\n})\nexport type MemoLineInput = z.infer<typeof memoLineSchema>\n\nexport const billingMemoCreateSchema = scopedSchema.extend({\n invoiceId: z.string().uuid(),\n type: z.enum(MEMO_TYPES),\n reason: z.string().trim().min(1, 'billing.memo.error.reason_required').max(1000),\n // Credit memo without lines = full credit (all original lines). Debit memo\n // without lines = empty draft (lines are added on the draft).\n lines: z.array(memoLineSchema).max(200).optional(),\n})\nexport type BillingMemoCreateInput = z.infer<typeof billingMemoCreateSchema>\n\nexport const billingDraftDeleteSchema = scopedSchema.extend({\n invoiceId: z.string().uuid(),\n})\nexport type BillingDraftDeleteInput = z.infer<typeof billingDraftDeleteSchema>\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,SAAS;AAClB,SAAS,0BAA0B,8BAA8B;AACjE,SAAS,iBAAiB,oBAAoB;AAC9C,SAAS,YAAY,aAAa,qBAAqB;AAIhD,MAAM,qBAAqB,CAAC,YAAY,aAAa,OAAO;AAG5D,MAAM,cAAc,CAAC,UAAU,WAAW,aAAa,UAAU;AAKjE,MAAM,iBAAiB,CAAC,cAAc,YAAY;AAIlD,MAAM,cAAc,CAAC,OAAO,OAAO;AAInC,MAAM,qBAAqB,CAAC,SAAS,aAAa;AAGlD,MAAM,oBAAoB,CAAC,YAAY,QAAQ;AAG/C,MAAM,oBAAoB,CAAC,WAAW,aAAa,mBAAmB,QAAQ;AAG9E,MAAM,4BAA4B;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AAAA;AAAA;AAAA,EAGA;AAAA,EACA;AACF;AAGO,MAAM,6BAA6B,CAAC,cAAc,gBAAgB,aAAa;AAK/E,MAAM,mBAAmB,CAAC,SAAS,UAAU,kBAAkB,QAAQ,UAAU;AAGjF,MAAM,iBAAiB,CAAC,WAAW,eAAe,cAAc,SAAS;AAKzE,MAAM,gBAAgB,CAAC,YAAY,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
|
}
|
|
@@ -27,6 +27,48 @@ const events = [
|
|
|
27
27
|
category: "lifecycle",
|
|
28
28
|
clientBroadcast: true
|
|
29
29
|
},
|
|
30
|
+
{
|
|
31
|
+
id: "billing.invoice.sent",
|
|
32
|
+
label: "Billing Invoice Sent",
|
|
33
|
+
entity: "invoice",
|
|
34
|
+
category: "lifecycle",
|
|
35
|
+
clientBroadcast: true
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
id: "billing.invoice.send_failed",
|
|
39
|
+
label: "Billing Invoice Send Failed",
|
|
40
|
+
entity: "invoice",
|
|
41
|
+
category: "lifecycle",
|
|
42
|
+
clientBroadcast: true
|
|
43
|
+
},
|
|
44
|
+
// ─── Payments (Spec C) ───────────────────────────────────────
|
|
45
|
+
{ id: "billing.payment.created", label: "Billing Payment Created", entity: "payment", category: "lifecycle" },
|
|
46
|
+
{ id: "billing.payment.allocated", label: "Billing Payment Allocated", entity: "payment", category: "lifecycle" },
|
|
47
|
+
{ id: "billing.payment.unallocated", label: "Billing Payment Unallocated", entity: "payment", category: "lifecycle" },
|
|
48
|
+
{
|
|
49
|
+
id: "billing.payment.converted_to_topup",
|
|
50
|
+
label: "Billing Payment Converted to Top-up",
|
|
51
|
+
entity: "payment",
|
|
52
|
+
category: "lifecycle"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
id: "billing.payment_import.completed",
|
|
56
|
+
label: "Billing Payment Import Completed",
|
|
57
|
+
entity: "payment_import",
|
|
58
|
+
category: "lifecycle",
|
|
59
|
+
clientBroadcast: true
|
|
60
|
+
},
|
|
61
|
+
{ id: "billing.invoice.paid", label: "Billing Invoice Paid", entity: "invoice", category: "lifecycle", clientBroadcast: true },
|
|
62
|
+
// ─── Corrective documents (Spec D) ───────────────────────────
|
|
63
|
+
{ id: "billing.credit_memo.posted", label: "Billing Credit Memo Posted", entity: "credit_memo", category: "lifecycle", clientBroadcast: true },
|
|
64
|
+
{ id: "billing.debit_memo.posted", label: "Billing Debit Memo Posted", entity: "debit_memo", category: "lifecycle", clientBroadcast: true },
|
|
65
|
+
{ id: "billing.invoice.credited", label: "Billing Invoice Credited", entity: "invoice", category: "lifecycle", clientBroadcast: true },
|
|
66
|
+
{
|
|
67
|
+
id: "billing.invoice.partially_paid",
|
|
68
|
+
label: "Billing Invoice Partially Paid",
|
|
69
|
+
entity: "invoice",
|
|
70
|
+
category: "lifecycle"
|
|
71
|
+
},
|
|
30
72
|
{
|
|
31
73
|
id: "billing.invoice.line_posted",
|
|
32
74
|
label: "Billing Invoice Line Posted",
|
|
@@ -40,6 +82,14 @@ const events = [
|
|
|
40
82
|
category: "lifecycle",
|
|
41
83
|
clientBroadcast: true
|
|
42
84
|
},
|
|
85
|
+
// Spec F — a test / dry run and its test invoices were deleted.
|
|
86
|
+
{
|
|
87
|
+
id: "billing.run.deleted",
|
|
88
|
+
label: "Bill Run Deleted",
|
|
89
|
+
entity: "bill_run",
|
|
90
|
+
category: "lifecycle",
|
|
91
|
+
clientBroadcast: true
|
|
92
|
+
},
|
|
43
93
|
// ─── Prepaid balance billing (SPEC-002) ──────────────────────
|
|
44
94
|
{
|
|
45
95
|
id: "billing.balance.topped_up",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/modules/billing/events.ts"],
|
|
4
|
-
"sourcesContent": ["import { createModuleEvents } from '@open-mercato/shared/modules/events'\n\n/**\n * Billing module events.\n *\n * Emission contract:\n * - `billing.invoice.posted` fires once per posted draft AFTER the post\n * transaction commits (
|
|
5
|
-
"mappings": "AAAA,SAAS,0BAA0B;
|
|
4
|
+
"sourcesContent": ["import { createModuleEvents } from '@open-mercato/shared/modules/events'\n\n/**\n * Billing module events.\n *\n * Emission contract:\n * - `billing.invoice.posted` fires once per posted draft AFTER the post\n * transaction commits (series number, issue/due dates assigned, status\n * `posted` in `billing_invoices`) and after the PDF is frozen. Consumed by\n * the auto-send subscriber, accounting bridges, analytics.\n * - `billing.invoice.sent` / `billing.invoice.send_failed` fire once per\n * email delivery attempt (Spec B), manual or automatic.\n * - `billing.invoice.line_posted` fires once per line on a posted invoice\n * so analytics can aggregate without scanning invoice lines directly.\n * - `billing.run.completed` fires once per Bill Run after all per-account\n * transactions finished (status is one of `completed` / `partial_failure`\n * / `failed`). Useful for \"did the nightly run go OK?\" alerts.\n *\n * CRUD events (`billing.<entity>.<action>`) are emitted by the data engine\n * from the commands' `emitCrudSideEffects({ events: { module: 'billing',\n * entity } })`. Only the (entity, action) pairs a command actually emits are\n * declared \u2014 `__tests__/events.test.ts` fails when a command emits one that\n * is missing here (the data engine would log \"Emitting undeclared event\").\n */\nconst events = [\n // \u2500\u2500\u2500 CRUD (commands/*.ts) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n { id: 'billing.account.created', label: 'Billing Account Created', entity: 'account', category: 'crud' },\n { id: 'billing.account.updated', label: 'Billing Account Updated', entity: 'account', category: 'crud' },\n { id: 'billing.account.deleted', label: 'Billing Account Deleted', entity: 'account', category: 'crud' },\n { id: 'billing.item.created', label: 'Billing Item Created', entity: 'item', category: 'crud' },\n { id: 'billing.item.updated', label: 'Billing Item Updated', entity: 'item', category: 'crud' },\n { id: 'billing.item.deleted', label: 'Billing Item Deleted', entity: 'item', category: 'crud' },\n {\n // One per usage upload, on the same high-throughput path as\n // `billing.usage.rated` \u2014 excluded from workflow triggers for the same\n // reason (see Open Question #2).\n id: 'billing.usage.created',\n label: 'Billing Usage Record Created',\n entity: 'usage',\n category: 'crud',\n excludeFromTriggers: true,\n },\n { id: 'billing.transaction.created', label: 'Billing Balance Transaction Created', entity: 'transaction', category: 'crud' },\n { id: 'billing.topup.created', label: 'Billing Top-up Created', entity: 'topup', category: 'crud' },\n // \u2500\u2500\u2500 Lifecycle \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n {\n id: 'billing.invoice.posted',\n label: 'Billing Invoice Posted',\n entity: 'invoice',\n category: 'lifecycle',\n clientBroadcast: true,\n },\n {\n id: 'billing.invoice.sent',\n label: 'Billing Invoice Sent',\n entity: 'invoice',\n category: 'lifecycle',\n clientBroadcast: true,\n },\n {\n id: 'billing.invoice.send_failed',\n label: 'Billing Invoice Send Failed',\n entity: 'invoice',\n category: 'lifecycle',\n clientBroadcast: true,\n },\n // \u2500\u2500\u2500 Payments (Spec C) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n { id: 'billing.payment.created', label: 'Billing Payment Created', entity: 'payment', category: 'lifecycle' },\n { id: 'billing.payment.allocated', label: 'Billing Payment Allocated', entity: 'payment', category: 'lifecycle' },\n { id: 'billing.payment.unallocated', label: 'Billing Payment Unallocated', entity: 'payment', category: 'lifecycle' },\n {\n id: 'billing.payment.converted_to_topup',\n label: 'Billing Payment Converted to Top-up',\n entity: 'payment',\n category: 'lifecycle',\n },\n {\n id: 'billing.payment_import.completed',\n label: 'Billing Payment Import Completed',\n entity: 'payment_import',\n category: 'lifecycle',\n clientBroadcast: true,\n },\n { id: 'billing.invoice.paid', label: 'Billing Invoice Paid', entity: 'invoice', category: 'lifecycle', clientBroadcast: true },\n // \u2500\u2500\u2500 Corrective documents (Spec D) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n { id: 'billing.credit_memo.posted', label: 'Billing Credit Memo Posted', entity: 'credit_memo', category: 'lifecycle', clientBroadcast: true },\n { id: 'billing.debit_memo.posted', label: 'Billing Debit Memo Posted', entity: 'debit_memo', category: 'lifecycle', clientBroadcast: true },\n { id: 'billing.invoice.credited', label: 'Billing Invoice Credited', entity: 'invoice', category: 'lifecycle', clientBroadcast: true },\n {\n id: 'billing.invoice.partially_paid',\n label: 'Billing Invoice Partially Paid',\n entity: 'invoice',\n category: 'lifecycle',\n },\n {\n id: 'billing.invoice.line_posted',\n label: 'Billing Invoice Line Posted',\n entity: 'invoice_line',\n category: 'lifecycle',\n },\n {\n id: 'billing.run.completed',\n label: 'Bill Run Completed',\n entity: 'bill_run',\n category: 'lifecycle',\n clientBroadcast: true,\n },\n // Spec F \u2014 a test / dry run and its test invoices were deleted.\n {\n id: 'billing.run.deleted',\n label: 'Bill Run Deleted',\n entity: 'bill_run',\n category: 'lifecycle',\n clientBroadcast: true,\n },\n // \u2500\u2500\u2500 Prepaid balance billing (SPEC-002) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n {\n id: 'billing.balance.topped_up',\n label: 'Balance Topped Up',\n entity: 'balance',\n category: 'lifecycle',\n clientBroadcast: true,\n },\n {\n id: 'billing.balance.low',\n label: 'Balance Low',\n entity: 'balance',\n category: 'lifecycle',\n clientBroadcast: true,\n },\n {\n id: 'billing.balance.exhausted',\n label: 'Balance Exhausted',\n entity: 'balance',\n category: 'lifecycle',\n clientBroadcast: true,\n },\n {\n // Per-debit signal \u2014 useful for a live balance UI but potentially\n // high-volume, so excluded from workflow triggers (see Open Question #2).\n id: 'billing.usage.rated',\n label: 'Usage Rated',\n entity: 'transaction',\n category: 'lifecycle',\n excludeFromTriggers: true,\n },\n {\n id: 'billing.statement.generated',\n label: 'Consumption Statement Generated',\n entity: 'statement',\n category: 'lifecycle',\n clientBroadcast: true,\n },\n {\n id: 'billing.credit.over_limit',\n label: 'Credit Over Limit',\n entity: 'credit',\n category: 'lifecycle',\n clientBroadcast: true,\n },\n {\n id: 'billing.credit.near_limit',\n label: 'Credit Near Limit',\n entity: 'credit',\n category: 'lifecycle',\n clientBroadcast: true,\n },\n] as const\n\nexport const eventsConfig = createModuleEvents({\n moduleId: 'billing',\n events,\n})\n\nexport const emitBillingEvent = eventsConfig.emit\nexport type BillingEventId = (typeof events)[number]['id']\n\nexport default eventsConfig\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,0BAA0B;AAwBnC,MAAM,SAAS;AAAA;AAAA,EAEb,EAAE,IAAI,2BAA2B,OAAO,2BAA2B,QAAQ,WAAW,UAAU,OAAO;AAAA,EACvG,EAAE,IAAI,2BAA2B,OAAO,2BAA2B,QAAQ,WAAW,UAAU,OAAO;AAAA,EACvG,EAAE,IAAI,2BAA2B,OAAO,2BAA2B,QAAQ,WAAW,UAAU,OAAO;AAAA,EACvG,EAAE,IAAI,wBAAwB,OAAO,wBAAwB,QAAQ,QAAQ,UAAU,OAAO;AAAA,EAC9F,EAAE,IAAI,wBAAwB,OAAO,wBAAwB,QAAQ,QAAQ,UAAU,OAAO;AAAA,EAC9F,EAAE,IAAI,wBAAwB,OAAO,wBAAwB,QAAQ,QAAQ,UAAU,OAAO;AAAA,EAC9F;AAAA;AAAA;AAAA;AAAA,IAIE,IAAI;AAAA,IACJ,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,UAAU;AAAA,IACV,qBAAqB;AAAA,EACvB;AAAA,EACA,EAAE,IAAI,+BAA+B,OAAO,uCAAuC,QAAQ,eAAe,UAAU,OAAO;AAAA,EAC3H,EAAE,IAAI,yBAAyB,OAAO,0BAA0B,QAAQ,SAAS,UAAU,OAAO;AAAA;AAAA,EAElG;AAAA,IACE,IAAI;AAA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