Finalizing Draft Invoices
Invoices are initially created with a draft status, and this is the only state in which an invoice can be edited or deleted. Once an invoice is ready to be paid, it should be finalized. This sets its status to open. Subscriptions automatically create draft invoices during each billing cycle. The subscription's simultaneous_invoice
field determines when the invoice is automatically finalized.
The Finalize Method
You can finalize an order or a subscription invoice via the Finalize method
Restrictions on Finalized Invoices
After an invoice is finalized, it can no longer be deleted and its final status can be one of the following:
Paid
Uncollectible
Void
Calculation of Invoice Total
The total amount due under an invoice is calculated as follows:
The subtotal is the sum of all invoice lines. An invoice line describes the amount to pay for an
invoice_item
or asubscription_item
.The subtotal is reduced by the amount of the discounts available to the subscription.
The adjusted subtotal is multiplied by the tax rate, which produces the amount of tax due.
The total amount due is the sum of the tax and the adjusted subtotal.
The discount is calculated as a percentage or a fixed monetary amount, depending on the settings of the amount_off
or percent_off
fields of the coupon
object.
Percentage Discount
When the discount is a percentage, the formula is as follows:
TInvoice = ( (sum(ItemsSubscription) + sum(ItemsInvoice) ) x ( (100 - DPercent) /100) ) x (1 + (RTax / 100) )
where:
TInvoice is the total due under the invoice.
ItemsSubscription is the charges for all the subscription items.
ItemsInvoice is the charges for all the invoice items.
DPercent is the percentage discount.
RTax is the tax rate as a percentage.
Fixed Discount
When the discount is a fixed monetary amount, the formula is as follows:
TInvoice = ( sum(ItemsSubscription) + sum(ItemsInvoice) - DFixed ) x (1 + (RTax / 100) )
where:
TInvoice is the total due under the invoice.
ItemsSubscription is the charges for all the subscription items.
ItemsInvoice is the charges for all the invoice items.
DFixed is the fixed discount.
RTax is the tax rate as a percentage.