Calculation Rules

Estimated reading: 3 minutes 8 views

Calculation Rules

The Calculation Rules are the core from the Calculation functionality as they defines what concepts must be added and summed up to the resulting invoice.

Fields

Field Description Example
Name The name for this rule. Consumption Rule
Billable Concept The Billable Concept record that defines how the concept would appear in the invoice Consumption 
Product Optional – If set, the rule will only apply when the agreement has this specific product.
Entry Rule Rule that must be met to calculate and add this concept to the invoice.
Quantity Rule Rule that specifies the quantity value for the invoice
Price Rule Rule that defines the Pricing for this concept
Tax Rule Rule that sets the Tax/es that apply to this concept

Rules Evaluation

All the different rules from a Calculation Rule record (quantity, pricing, entry and tax) are evaluated in the same way.

The rules can reference different data that is available in the context of the calculation process. This includes:

  • Variables: these are common properties that are usually required by the rules: From Date, To Date, Billable Concept, Product Code, etc.
  • Evaluation Context: this is the business data you may need to evaluate the rules. You can customize which is data is loaded in the Evaluation Context by defining the desired Object Tree and setting it in the Billing Setup.

Additionally, rules can evaluate functions in case you need to perform some custom logic. The functions can be either out of the box functions or custom functions that you define in the system. You can check all the Out of the box functions in the Rules Engine documentation.

Quantity

For the quantity you can set any rule that you need. It can be a static value like “1”, a value from some field, the result form a custom rule function or the result from out of the box function.

The most common case is to use the getUsage() function which would automatically calculate and retrieve the consumption for the specific billable concept and date range.

Pricing

For the pricing, it’s similar, you can set any rule that you need. It can be a static value like “1”, a value from some field, the result from a custom rule function or the result from out of the box function.

The most common case is to use the getPricing() function which would automatically retrieve the corresponding price for the current billable concept and date range.

Taxes

There are two ways to set the applicable taxes for a calculation rule / concept.

Note that it’s required to have different properties for a tax, so it’s not possible to enter a hardcoded/static value for the rule. This is why we offer two different rule functions to specify the taxes.

Tax SObject

You can define a Tax creating a Tax record and specifying the Name, Abbreviation, Rate (%) and Description.

You can use the getTax() rule function to achieve this. It support both a single tax or list of them sepparated by commas.

  • Tax Rule = getTax(“IVA”)
  • Tax Rule = getTax(“IVA,IE”)

The getTax function will search for the specified Tax record in the system. So it must exist in the system before using it in the rule.

Virtual Tax

You can speficy adhoc taxes on runtime by using the createTax method. This way, you can customize special taxes you could need for especific scenarios.

  • Tax Rule = createTax(“myTax”, 0.23)

Articles

Leave a Comment

       
Euphoria, forever till the end of times

Euphoria

Share this Doc

Calculation Rules

Or copy link

CONTENTS