At a glance
Runs bill cycles and produces accurate invoices from recurring, one-time and usage charges.
Key data
Receives from
- Rating
- Order management
- Product catalog
Sends to
- Collection & dunning
- Payments
- Document management
- Finance
Bill Cycle — Key Milestones
Monthly billing cycle dates and their purpose
Billing Pipeline — End-to-End
From rated usage data through invoice generation and document delivery
Component Responsibilities
Detailed function of each service in the Billing module
Bill Scheduler
- Daily batch job checks bill cycle configuration for run dates
- Triggers Test Bill Run and Final Bill Run on configured dates
- Reads account list from billing scheduler document
- Distributes accounts to event bus partitions using weighted load-balancing
- Weight based on active line count per account — prevents partition overload
- Updates last-processed date to prevent duplicate runs on same day
- Handles failure with exponential retry and resume logic
Bill Generation
- Consumes account details from event bus
- Aggregates all charges for the bill period: recurring, rated usage, one-time, installments
- Applies tax rules to taxable charge components
- Generates invoice document per billing account
- Sends invoice data to Accounting via internal API
- Triggers document generation for PDF creation
- Handles large accounts with child invoice documents
Bill Accounting
- Receives invoice data from Bill Generation via internal API
- Stores account, line and charge breakdown in search store
- Prevents duplicate entries using account + usage month + subscriber key
- Provides data source for billing and sales reports
- Supports on-demand re-run with overwrite of existing records
Bill Invoice
- Manages invoice state: generated → delivered → paid / overdue
- Links subscriber payment method to invoice for collection
- Tracks reissue count for payment slip re-generation
- Exposes invoice query APIs to care and self-care portals
- Passes overdue invoices to Collection module at due date
Bill Document Generation
- Generates printable invoice PDF from invoice charge data
- Applies localised templates for language and formatting
- Stores generated document in document management store
- Triggers notification service to deliver invoice to subscriber
- Supports on-demand reprint and reissue requests
Handoff to Collection
- At payment due date, unpaid invoices are passed to the Collection & Dunning module
- Invoice status updated: pending → overdue
- Payment method and invoice details passed to Collection service
- Billing module has no further responsibility once handed off
- Collection & Dunning module manages all subsequent recovery steps
Storage & Persistence
How and where the Billing module stores its data
Document Data Store
- Bill cycle configuration and run dates
- Billing account scheduler list
- Invoice documents per billing account
- Scheduler job status and last-run tracking
Search & Analytics Store
- Invoice charge breakdowns per account
- Tax amounts per service and charge type
- Source data for billing and sales reports
- Supports account + month + subscriber dedup
Async Event Bus
- Bill generation trigger channel (per account)
- Document generation notification channel
- Accounting notification channel
- Invoice handoff channel to Collection
Document Store
- PDF invoice documents per subscriber
- Versioned for reprint and reissue
- Accessible via document management service
Design Principles
Key architectural decisions behind the Billing module
Weighted Account Distribution
Bill Scheduler uses a weighted min-heap algorithm to distribute accounts to event bus partitions based on active line count. This prevents large multi-line accounts from overloading single partitions and ensures consistent invoice generation throughput across all Bill Generation instances.
Configurable Bill Cycle
Bill run dates, test run dates, payment due dates and usage periods are all driven by a centralised cycle configuration document. Relative date expressions (e.g. last day of month, Nth day of next month) make the cycle flexible and configurable without code changes.
Clean Module Boundary
The Billing module's responsibility ends at invoice delivery. Overdue management, dunning and payment processing are handled by the separate Collection & Dunning module. This separation keeps billing logic focused and allows collection policy to evolve independently.
Machine learning flags unusual bills before they are sent. See the AI for Pre-Billing Validation page.
Generative AI explains bill changes to customers and care agents in plain language.
More in 30 AI & ML use cases and AIOps for BSS.