Skip to main content
TRXN automatically generates invoices from active subscriptions through the GenerateInvoicesJob. This ensures that recurring charges are billed on time without manual intervention.

How it works

1

Scheduled execution

The GenerateInvoicesJob runs on a regular schedule, typically daily. It evaluates all subscriptions to determine which ones are due for billing.
2

Subscription processing

The job iterates through all subscriptions and checks billing eligibility based on the subscription’s next billing date and the current time.
3

Active phase check

Only subscriptions with an active phase containing recurring items are processed. If a subscription has no active phase or the active phase contains only one-time items, it is skipped.
4

Due date calculation

The job compares each subscription’s next_billing_date with the current time. If the billing date has arrived or passed, the subscription is eligible for invoice generation.
5

Invoice creation

For each eligible subscription, the job generates an invoice with line items corresponding to the recurring phase items in the active phase.

Invoice structure

When an invoice is generated, it contains:
  • Invoice level — customer, account, and subscription references
  • Line items — one line item per subscription phase item
  • Pricing — uses overridden prices when set, otherwise falls back to the base product price
  • Quantities — reflects the quantity specified in each phase item

Example

Duplicate prevention

The invoice generation system includes safeguards to prevent duplicate invoices. If an invoice has already been generated for a billing period, the job will not create another one for the same period.

Billing cycle anchors

Invoice generation respects billing cycle anchors. When a subscription has an anchor set, the next_billing_date calculation aligns with the anchor date rather than the subscription creation date.

Initial invoices

When a subscription is first created, the system may generate an initial invoice depending on the proration behavior:

Subscriptions

Multi-phase subscriptions with flexible pricing and automatic transitions.

Billing cycles

Control when recurring charges occur with billing cycle anchors.