API to get details about the invoice line items, features and pricing models.
JSON Response has the following structure:
{
"lines": [],
"features": [],
"total": "",
}
Lines contains array of lines, each line comprises of a pricing model and some features
attached to it. The pricing model can be one of the following:
- Subscription Pricing
- Per Unit Pricing
- Tiered Pricing
- Volume Pricing
- Package Pricing
- Matrix Pricing etc
And Features can be one of the following: - Free Units
- Discount
- Sales Tax
- Avalara Tax
- Minimum amount overages etc
Each Line has the following structure:
{
"name": "",
"quantity": {},
"subtotal": {},
"pricing_model": "",
"features": [],
}
Features is an ordered list of all the features of the line item, including the pricing model.
the ordering is important while displaying it on the invoice because for example
free units as a feature should come before the pricing model. And discount after pricing model etc etc.
The ordering of the features are implicit when you create a contract based on the Simple Editor. You can
specify the order of the features in the advanced editor.
Each Feature has the following structure:
{
"name": "",
"type": "",
"display: {},
"price": {},
"quantity": {},
"total": {},
"currency": "",
"quantity_unit": "",
}
And also pricing model/feature specific information.
For some of the pricing models/features, some of the fields are not applicable. For example,
Subscription Pricing doesn't really have a quantity field. So it will be null.
In some cases these values can have implicit values, for example, if the price is 0, for free-units feature.
There's also a root level field called features, which are invoice level features. Things like
discount, sales tax can be at the invoice level.
This key has invoice level features, and their structure is similar to what we see for invoice line item level features.
For each feature in the display
field, its an array of objects that has templatized strings for
name
, price
, quantity
, and total
with the right units and currencies.
You can use it to display the line items directly.
The total
field is the total amount for the line item.
Here is an example of how to access the display fields to show the line items
lines = GET /invoices/{invoice_id}/line_items
import pydash as _
list_of_features = _.flat_map(lines, 'features')
display_lines = _.flat_map(list_of_features, 'display')
for line in display_lines:
print(f"line['name'] line['price'] line['quantity'] line['total']")