LineItems
Overview
A purchase in CloudBilling goes through different Pricing Rules before it ends up as a line on an invoice. A LineItem is the result of a Pricing Rule applied on a purchase or a previous Pricing Rule Result (PRR). It captures the price change and quantity change associated with the Rule as AddedValue and AddedQuantity. The final invoice total for a product is the sum of AddedValue across all of its LineItems.
Consider a customer makes two separate purchases of product ‘A’ with quantity 10 and 15. The product has three Pricing Rules configured as shown below:
- Order 0 - A Price-Type Pricing Rule that applies a price of 10 Euros for each unit of the product. A unit is the standard measure of how a product is quantified (e.g., item, hour, meter).
- Order 10 - An Adjust Percentage Pricing Rule with value of -10. This Rule applies a 10% discount on the price.
- Order 30 - A Sum Pricing Rule that sums all purchases of product A.
Both purchases are processed by the Pricing Rules in the order specified below:
- Price - First, the Price-Type Pricing Rule is applied separately to each purchase, resulting in two PRRs. The two PRRs are synced to the dataset as two LineItems. The first LineItem has an
AddedValueof 100 (unit price * quantity) and anAddedQuantityof 10. The second LineItem has anAddedValueof 150 (unit price * quantity) and anAddedQuantityof 15. - Adjust Percentage - Then, the Adjust Percentage Rule applies a 10% discount on the two Price-Type PRRs, creating
two more PRRs and corresponding LineItems. The first LineItem has anAddedValueof -10 (-10% of 100) and anAddedQuantityof 0, and the second LineItem has anAddedValueof -15 (-10% of 150) and anAddedQuantityof 0. - Sum - Finally, the Sum Rule combines the two PRRs from the Adjust Percentage Rule into a single LineItem with
AddedValueof 0 andAddedQuantityof 0.
The aggregation of AddedValue across all LineItems is the price displayed on the invoice. Therefore, the price displayed in the invoice for Product ‘A’ is 225 Euros (100 + 150 - 10 - 15).
The LineItems table connects to several related tables through foreign keys. A foreign key is a field that stores the unique identifier of a row in another table, enabling you to link a LineItem to the matching entry in that table. For example, the field InvoiceKey can be used to find which invoice a LineItem belongs to, and the ProductKey can be used to find the product associated with the purchase that created the LineItem. When a foreign key does not link to a row in another table, its value is -1. Use these keys to navigate the dataset and retrieve context not stored directly in the LineItems table. For detailed schemas and field definitions, see the documentation sections for each related table.
Metadata
Valuable finance and business data can be included in CloudBilling purchases as purchase metadata. Some PRRs retain this information. If a Pricing Rule is applied on a purchase or on another PRR (e.g., Price and Adjust Percentage Rules), all metadata fields are retained. However, if a Pricing Rule is applied on multiple PRRs at once (e.g., SUM Rule), only the fields with matching name and value are retained. The metadata can be synced with the dataset, and below are the number of fields available for each metadata type:
- String - 10
- Numeric - 3
- Date - 2
For example, you can push usage in CloudBilling and assign it to a certain application, account or a aerver. You can then use this information to analyze how much usage is consumed by every account.
Users need to choose the fields to be synced in advance, and communicate their decision to our support team through the customer portal or by sending an email. Our consultants will ensure the selected fields are synced with the dataset. When synced, the dataset changes from a billing summary into a reliable source of business insights on revenue and costs. The metadata fields can be used to group, filter, analyse, and explain revenue and costs with relevant business context. Furthermore, you can do root causes analysis by navigating from high‑level KPIs (e.g., margin dip for a region), all the way to the specific invoices and LineItems driving the change.
The string type metadata fields are stored in a separate table and linked to the LineItems using the foreign key fields. There are a few deprecated metadata fields such as Meta1 and Bool1. They were replaced by the three different types of fields mentioned above. They remain only because they contain historical data from older LineItems (from prior years). Use the new metadata types and do not rely on these deprecated fields.
Ledger Account Entry
Each LineItem also contains information on whether it is a ledger entry. If it is, there is information on whether the entry is a credit or a debit, along with the entry values. The foreign key field LedgerAccountKey links the LineItems table to the LedgerAccounts table. This field is -1 if the LineItem is not a Ledger entry. Otherwise, use the key to look up the associated Ledger code and name. In CloudBilling, the ledger code and name are configured in the Pricing Rules as Billing Output Tags ( BOTs).
Public Cloud Usage
Purchases retrieved by CloudBilling connectors contain detailed information specific to the service provider as purchase metadata. The metadata specific to AWS and CSP are synced to the dataset in separate tables, and linked to LineItems by the foreign key fields starting with ‘Csp’ or ‘Aws’. Since most of these metadata fields contain string type values, they are stored in separate tables for efficient storage and performance.
Fields
| Name | Type | Description |
|---|---|---|
Key | Integer | Primary Key - LineItems Table. |
ProductKey | Integer | Foreign Key - Products Table. |
AddedValue | String | The value added by the Pricing Rule. |
AddedCost | String | The cost added by the Pricing Rule. |
AddedQuantity | String | Quantity change associated with a Pricing Rule. |
From | Integer | Foreign Key - Purchase start date. From date in yyyymmdd fromat. |
To | Integer | Foreign Key - Purchase end date. To date in yyyymmdd format. |
Type | String | Type of Pricing Rule that generated the LintItem; represented by predefined integers: 0 = Unknown, 1 = Tax, 2 = Discount, 3 = Margin, 4 = Fee, 5 = CurrencyExchange. |
LedgerAccountKey | Integer | Foreign Key - Ledger Accounts Table (-1 = Not a Ledger Entry). |
LedgerAccountCredit | String | The credit amount associated with the line item. |
LedgerAccountDebit | String | The debit amount associated with the line item. |
Meta1 | String | Deprecated field. |
Meta2 | String | Deprecated field. |
Meta3 | String | Deprecated field. |
NumericMeta1 | String | Numeric metadata 1 available in a line item. |
NumericMeta2 | String | Numeric metadata 2 available in a line item. |
NumericMeta3 | String | Numeric metadata 3 available in a line item. |
DateMeta1 | String | Date metadata 1 available in a line item. |
DateMeta2 | String | Date metadata 2 available in a line item. |
Bool1 | String | Deprecated field. |
Bool2 | String | Deprecated field. |
Bool3 | String | Deprecated field. |
Bool4 | String | Deprecated field. |
InvoiceKey | Integer | Foreign Key - Invoices Table. |
CspOrderKey | Integer | Foreign Key - CspOrders Table. |
CspInstanceKey | Integer | Foreign Key - CspInstances Table. |
CspProductKey | Integer | Foreign Key - CspProducts Table. |
CspSubscriptionKey | Integer | Foreign Key - CspSubscriptions Table. |
CspResourceGroupKey | Integer | Foreign Key - CspResource Groups Table. |
AwsProductKey | Integer | Foreign Key - AwsProducts Table. |
AwsReservationKey | Integer | Foreign Key - AwsReservations Table. |
AwsSavingsPlanKey | Integer | Foreign Key - AwsSavings Plan Table. |
AwsInvoiceKey | Integer | Foreign Key - AwsInvoices Table. |
AwsDescriptionKey | Integer | Foreign Key - AwsDescriptions Table. |
AwsUsageaccountKey | Integer | Foreign Key - AwsAccounts Table. |
AWSBlendedCost | Decimal | Average cost of an AWS service across all usage accounts. |
AWSPublicOndemandCost | Decimal | The total cost for an AWS line item based on public on-demand instance rates. |
AWSReservationEffectiveCost | Decimal | The effective cost for an AWS reservation line item. |
AWSSavingsPlanEffectiveCost | Decimal | The proportion of the Savings Plans monthly commitment amount (upfront and recurring) that is allocated to each usage line. |
AWSUnblendedCost | Decimal | Cost of an AWS service associated with one usage account. |
AddedMeasuredQuantity | Decimal | The measured quantity change associated with a Pricing Rule. It is usually different to AddedQuantity when there is pro-ration. |
FlagsKey | Integer | Foreign Key - Flag Table. |
StringMeta1Key. . . StringMeta10Key | Integer | Foreign Key - 10 separate keys for StringMetadatas Table |