Calculation Engine

Estimated reading: 5 minutes 6 views

Calculation Engine

The Calculation Engine is the core of the system, it is responsible for processing the data and applying the business rules to calculate the results of the billing processes.

The engine is designed to be flexible being able to be adapted to almost any business need and data model.

The Billable Element

We designed the Calculation Engine to be as much flexible as possible and because of this we didn’t want to use concepts as “Contracts”, “Agreements” or “Orders”. Instead, we use the concept of “Billable Element”. A Billable Element is a representation of a product, service, order, quote or whatever other thing that can be billed. The Billable Element is the main entity that the Calculation Engine will process.

Calculation Process Overview

The Calculation Engine bases its behaviour on two main blocks:

  • Calculation Context: it stores the data required to perform the calculations. It contains the Billable Elements, the rules to be applied, the usages in case of usage-based billing and technical information about the related entities, i.e. the Service Point. The context also stores all the calculation rules that applies to the element to be billed.
  • Rules Evaulation: it processes all the rules based on the Calculation Context and generate the Invoice according to the context and the configuration.

Calculation Context

The Calculation Context is the main entity that the Calculation Engine will process. It contains all the information required to perform the calculations. The context is composed by the following entities:

alt text
  • Billable Element: the main entity that the Calculation Engine will process. It represents a product, service, order, quote or whatever other thing that can be billed.
  • Rules: the rules that will be applied to the Billable Element. The rules are defined in the system and are associated with the Billable Element.
  • Usages: the usages in case of usage-based billing. The usages are associated with the Billable Element.
  • Technical Information: technical information about the related entities, i.e. the Service Point.
  • Calculation Rules: all the calculation rules that applies to the element to be billed.
  • Formula Context: the context that will be used to evaluate the formulas.

    All of this information is loaded using the different Providers

Providers

The providers are the entities responsible for loading the data required to perform the calculations. Wattyo comes with out of the box providers for each data category and these cover all the common scenarios and more complex ones. However, in case your business requires a specific behaviour not covered by the out of the box providers, you can create your own provider and plug it into the system.

Suppose you want to bill orders that are stored in an external system. You can define a custom provider that will load the orders from the external system and pass this data to the Calculation Engine.

There are seven types of providers:

  • Billable Element Provider: loads the Billable Elements.
  • Usages Provider: loads the usages.
  • Technical Information Provider: loads the technical information.
  • Pricing Provider: loads the pricing.
  • Usage Estimation Provider: loads the usage estimation when required.
  • Validaiton Provider: loads the validation rules.
  • Rules Provider: loads the rules.

Calculation Rules

The Calculation Rules are the rules that will be applied to the Billable Element. The rules are defined in the system and are associated with the Billable Element. The rules are defined using a simple language that allows the user to define complex rules in a simple way. The rules are evaluated by the Calculation Engine and the results are stored in the resulting invoice.

The rules contain the following information:

  • Name: the name of the rule.
  • Billable Concept: the concept that the rule will generate.
  • Filter Fields: the fields that will be used to filter the Calculation Rules. For instance Product, Company, etc. You can add custom filter fields as you need.
  • Entry Criteria Rule: the rule that will be used to filter the Billable Elements that will be processed by the rule. This is additional to the filter fields in case you need some more complex filtering.
  • Quantity Rule: the rule that will be used to calculate the quantity of the Billable Element.
  • Price Rule: the rule that will be used to calculate the price of the Billable Element.
  • Tax Rule: the rule that will be used to calculate the tax of the Billable Element.

Usage

The Usage is the amount of a product or service that has been consumed. The Usage is associated with the Billable Element and is used in case of usage-based billing. The Usage is used to calculate the price of a specific Billable Concept.

The usages can have any schema you need, they can be one-time, recurring, hourly metering, monthly metering, etc. The Calculation Engine is designed to be flexible and can adapt to any schema you need.

Of course, if you need to bill a product or service that doesn’t have usage, you can simply ignore the usage.

Pricing

The Pricing is the price of a product or service. The Pricing is used by the Calculation Rule to calculate the final price of the Billable Element. The pricing can be as simple as a single fixed price, or be more complex like a price that depends on usage range, hour of the day, etc.

Leave a Comment

       
Euphoria, forever till the end of times

Euphoria

Share this Doc

Calculation Engine

Or copy link

CONTENTS