Configure RatingDetails in HTML template
RatingDetail schema
The RatingDetail schema captures detailed charge calculations and billing information, particularly for complex pricing models such as tiered pricing, volume-based pricing, overage charges, and usage-based charges. This schema accurately presents pricing details to end customers in invoices and statements.
Here’s how you can structure the presentation with the major fields:
- Formula: The Formula field defines the tiered pricing structure in the following format:
1:PriceFormat:StartUnit:EndUnit:Price;2:PriceFormat:StartUnit:EndUnit:Price;...,
- Where:
- PriceFormat indicates the type of pricing: flat fee or per unit. The available values are 0 for Flat Fee and 1 for Per Unit.
- StartUnit and EndUnit define the quantity range for each tier.
- Price specifies the unit price for the tier.
- 1, 2 represents the tier number in the Tiered Pricing charge model. Most charge models, such as Flat Fee and Per Unit, have a single tier. However, when using Tiered Pricing, multiple tiers may apply if the quantity spans more than one tier.
- CalculatedAmount: This field provides the result of the pricing calculation based on the formula defined.
- Quantity: If applicable, this field indicates the quantity of usage for the current charge.
- Calculation: This field shows the details of how the charge amount is calculated. It applies different prices to the quantity breakdown when using a tiered pricing model.
- BilledQuantity and BilledAmount: These fields represent the previously billed quantity and amount for usage charges in the current billing period. Both fields are available only for on-demand usage rating.
Assume you have an InvoiceItem object with associated RatingDetails. Here’s how you can render tiered pricing using these fields:
<table> <thead> <tr> <th>Charge Type</th> <th>Charge Model</th> <th>Quantity</th> <th>Calculated Amount</th> <th>Formula</th> <th>Calculation</th> </tr> </thead> <tbody> {{#Invoice.InvoiceItems}} {{^RatingDetails|IsEmpty}} {{#RatingDetails|First(1)}} <tr> <td>{{ChargeType}}</td> <td>{{ChargeModel}}</td> <td>{{Quantity}}</td> <td>{{CalculatedAmount}}</td> <td>{{Formula}}</td> <td>{{Calculation}}</td> </tr> {{/RatingDetails|First(1)}} {{/RatingDetails|IsEmpty}} {{/Invoice.InvoiceItems}} </tbody> </table>
Charge Type | Charge Model | Quantity | Calculated Amount | Formula | Calculation |
---|---|---|---|---|---|
Usage | Tiered with Overage Pricing | 130.0 | 60.0 | 1:1:0:100:0.00;2:1:101:200:2.00 | 100 * USD0.00 + 30 * USD2.00 = USD60.00 |
- Invoice.InvoiceItems: Iterates over each InvoiceItem.
- RatingDetails|IsEmpty: Checks if there are RatingDetails associated.
- #RatingDetails|First(1): Retrives the first item from the RatingDetails list. Each invoice item has one rating detail object.
- ChargeType, ChargeModel, Quantity, CalculatedAmount, Formula, Calculation: These fields are the standard fields from the RatingDetail object. You can refer to the details of each field in the table.
The formula format is not designed for direct customer readability, as it is structured to support various pricing models, including tiered pricing. To enhance clarity, you’ll need to parse and present it in a more user-friendly format.
This template snippet iterates through each InvoiceItem to retrieve its associated RatingDetails. It identifies the ChargeModel (e.g., Tiered Pricing) and extracts key fields to generate a structured pricing table, including quantity ranges, unit prices, and calculated amounts.
RatingDetail schema fields and descriptions
Field | Description | Use |
---|---|---|
Id | Unique identifier for the Rating Detail record. | Ensures each rating detail entry is distinct for tracking and referencing. |
InvoiceItemId | Links the Rating Detail to its associated invoice item. | Correlates charges to their respective invoices. |
CreditMemoItemId | Links the Rating Detail to its associated credit memo item. | Supports detailed credit adjustments for customers. |
ChargeType | Specifies the type of charge (for example, recurring, usage). | Differentiates charge models for customer clarity. |
ChargeModel | Defines the charge structure (for example, tiered, flat rate, volume-based). | Helps render pricing details accurately. |
Formula | A mathematical representation of the charge calculation. | Displays calculations, such as tier start/end units and rates, in the UI. |
Calculation | Breaks down the calculation process by applying values to the formula. | Demonstrates how charges are derived for transparency. |
CalculatedAmount | The final result of the charge calculation. | Displayed as the charge amount billed. |
Currency | The currency code for the calculated amount, such as USD or EUR. | Indicates the currency for international customers. |
UnitOfMeasure | Defines the unit for usage charges, such as GB and hours. | Helps customers understand what was measured. |
BilledQuantity | Quantity billed during the same period for on-demand usage rating. | Displays prior usage quantities on invoices. |
BilledAmount | Amount billed during the same period for on-demand usage rating. | Shows previously charged amounts. |
Quantity | The total usage or units for the charge. | Clarifies the quantity driving the charge. |
IsProration | Indicates if the charge is prorated (true/false). | Informs customers about partial-period adjustments. |
IsCredit | Indicates if the charge is a credit (true/false). | Identifies credit adjustments. |
ListPriceBase | Base price set in the rate plan charge. | Establishes a baseline for discounts or calculations. |
BillingCycleDay/Type | Indicates the cycle day or type for recurring charges. | Aligns billing with customer expectations. |
BillingPeriod | The billing frequency (for example, monthly, yearly). | Specifies the timeframe for charges. |
SpecificBillingPeriod | Indicates any unique billing periods. | Supports custom billing scenarios. |
AmountWithoutTax | The pre-tax amount of the charge. | Separates tax-inclusive amounts for transparency. |
Proration Rules | Flags and rules for prorating charges based on period, days in a month, or discount application. | Provides detailed prorated adjustments. |
Dates | Start and end dates for billing periods, terms, charges, and subscriptions. | Tracks service timelines for accurate billing. |
Discount Information |
|
Details how discounts affect the overall charge. |
Prepaid/Commitment Balances |
|
Tracks fund usage for prepaid plans. |
Usage in HTML templates
The RatingDetail schema enables dynamic rendering of pricing details in HTML templates. While RatingDetails is a list of objects within an InvoiceItem, each InvoiceItem is associated with a single RatingDetail object.
Below is an example showcasing key fields, followed by variations demonstrating different usage charge models.
<table> <thead> <tr> <th>Charge Type</th> <th>Charge Model</th> <th>Quantity</th> <th>Calculated Amount</th> <th>Formula</th> <th>Calculation</th> </tr> </thead> <tbody> {{#Invoice.InvoiceItems}} {{^RatingDetails|IsEmpty}} {{#RatingDetails|First(1)}} <tr> <td>{{ChargeType}}</td> <td>{{ChargeModel}}</td> <td>{{Quantity}}</td> <td>{{CalculatedAmount}}</td> <td>{{Formula}}</td> <td>{{Calculation}}</td> </tr> {{/RatingDetails|First(1)}} {{/RatingDetails|IsEmpty}} {{/Invoice.InvoiceItems}} </tbody> </table>
This enables clear invoices with detailed charge breakdowns.
Example: Tiered pricing mode
Using the HTML template snippet above, the output appears as follows:
Charge Type | Charge Model | Quantity | Calculated Amount | Formula | Calculation |
---|---|---|---|---|---|
Usage | Tiered with Overage Pricing | 130.0 | 60.0 | 1:1:0:100:0.00;2:1:101:200:2.00; | 100 * USD0.00 + 30 * USD2.00 = USD60.00 |
Understanding the Formula:
- For Tiered with Overage Pricing, the formula format can include multiple tiers, depending on usage crossing different thresholds.
- Example:
1:1:0:100:0.00;2:1:101:200:2.00;
- This represents the usage of 130 units across 2 tiers. The first tier is priced at $0, and the second is priced at $2.00 per unit.
Example: Flat fee pricing model
Using the HTML template snippet above, the output appears as follows:
Charge Type | Charge Model | Quantity | Calculated Amount | Formula | Calculation |
---|---|---|---|---|---|
Usage | Flat Fee Pricing | 160.0 | 99.0 | 1:0:0::99.00; | USD99.00 |
Understanding the Formula:
-
For Flat Fee Pricing, the formula format is the same as Tiered Pricing, but it's always just 1 tier.
-
Example: 1:0:0::99.00;
-
This represents a flat fee of the price $99.00, where the charge amount is always $99.00, irrespective of the usage.
Example: Per unit pricing model
Using the HTML template snippet above, the output appears as follows:
Charge Type | Charge Model | Quantity | Calculated Amount | Formula | Calculation |
---|---|---|---|---|---|
Usage | Per Unit Pricing | 120.00 | 12000.0.0 | 1:0:0::100.00; | 120 * USD100.00 = USD12,000.0 |
Understanding the Formula:
- For Per Unit Pricing, the formula follows the same format as Tiered Pricing but always contains a single tier.
- Example:
1:0:0::100.00;
- This indicates a per-unit price of $100.00.
- For 120 units, the total charge is calculated as 120 × $100.00 = $12,000.00.