March 04

BRF+ Function (Event Mode Scenario)

In this blog, Let’s try to create a BRF+ Function with Event mode.

Function:

A function is the rule interface in BRFplus and acts as a link between the application code and the BRFplus code.

A function carries a modecontext and a result. It imports the context from the calling application and passes the context data to the assigned top expression or ruleset for further processing. After processing, the function returns the calculated result to the calling application. To create function from scratch, follow the Creating a Function.

  1. Mode (Event mode)
  2. Context
  3. Result

2019-03-04_20-33-27

Ruleset:

A ruleset is a collection of rules to be processed in a particular business case. It serves as an entry point for rule processing and can be used as an alternative to a top expression assigned to a function.

The mode of operation setting of the assigned function must be either Event Mode or Functional and Event Mode.

2019-03-04_20-38-02

Here, I have designed a scenario to calculate actual price of item using event mode (ruleset), following are the steps:

  1. Find the base price
  2. Apply State Tax
  3. Apply Central Tax
  4. Find the Festive season
  5. If transaction date falls in festive season, apply festival discount

2019-03-04_20-39-30

Decision Table:

A decision table expression is used to compare a given input against a list of predefined combinations of conditions. Each combination has an individual result assigned which is returned as the expression result when the input data matches the particular combination.

Here the combinations are,

  • Gold
  • Silver

2019-03-04_20-41-54
Calculating the basic price using the expression,

Table settings are shown below:

2019-03-04_20-42-31

Including 18% of state tax with the basic price using the below Formula expression,

2019-03-04_20-43-04
Including 18% of Central tax with the base price (after inclusion of state tax),

2019-03-04_20-43-32

Finding the month from current date using the below Formula expression (Using standard date function DT_PART_MONTHS)

2019-03-04_20-44-04
Based on the month, check whether it is festival season based using Boolean expression:

As an example, I have taken December and January as festival months. i.e., Festival discount will be applicable for transactions performed in them:

2019-03-04_20-44-42
Finally calculating the final price,

  • If the current purchase date falls in festive months then 50% discount will be applied to the final price (after central tax).
  • If the current purchase date is not falling in festive months then the result will give the final price (after central tax).

2019-03-04_20-45-20