How to build a Commission model using DecisionRules Part II

Commissions play a pivotal role in various industries, especially in the financial sector. In this article, we dive into the practical implementation of commission management and calculation using In the first part, we'll explore the layers of the commission calculation model, rule variables, activation management, and input/output models. In the second one, we will look into examples of concrete rules, integration of DecisionRules with external systems, and Reporting of Commissions.


Commissions are typically recalculated once a month as a basis for employee payouts. But with DecisionRules, you can do these calculations at any time during the month at the team or individual broker level to increase their motivation.

Model structure

The solution must be able to calculate three different commission models. To define this complex behavior on one hand and simplify the integration on the other, we have implemented hierarchical rule structure.

  • The 1st layer represents the main rule (Calculate commissions) that is responsible for integration in both directions IN and OUT and executes rules in the following layers.
  • The 2nd layer defines different commission models and contains a list of all of the rules in each model.
  • The 3rd layer contains the final rules which calculate the final commission based on input data. A rule for every product type is created in this layer. It is possible to define various versions of a rule for each product type and turn them on and off as required.

1st layer

Rule Calculate Commissions is designed to evaluate all the applicable rules for a bulk input, meaning the input contains all of the accounts and/or deals of a broker. However, it is always possible to evaluate any rule in isolation if it is required or easier for implementation.

The rule has an input property commissionType which determines the type of commission that will be calculated, so for any subset of these commissions the input can remain the same.

This rule is not intended to be changed, unless the model is changed significantly, such as when another type of commission would be added. If the structure of commissions stays the same and rules are only removed or added, then only the input schema would change to reflect the structure of your input data.

1st layer

2nd layer

This layer organizes the rules into individual commission models. There are three tables, each for one commission model. Each table contains a list of all active commission rule ids. Only the current rules in these tables will be evaluated.

The table for Merit commissions also contains a column, where an exclusivity group can be set. This feature enables more of the rules to be defined for one case. All of the rules of this exclusivity group are evaluated at the same time and only the highest commissioned one will be awarded. This creates an option to design multiple tiers of Merit commissions.

3rd layer

The last layer contains the actual logic for evaluating the commissions. These rules are called from the orchestrating script Calculate Commissions. But there is also the possibility of evaluating all of them separately should the need arise.

All of the commissions have a separate rule where their logic is stored, therefore any rule can be modified independently.

Commission rules management

We expect that the number of rules will increase. IT might be beneficial for a business user that can see the opportunity to unleash his/her creativity. For an application administrator this could quickly become a headache. That is why we have introduced some techniques for keeping the number of rules at a manageable level.

Rule variables

For each rule, we can define a rule variable that proves useful when a single value is utilized in multiple sections of an algorithm, or when there's a need to easily modify significant attributes like the commission amount.

rule variables

A good example can be a commission percentage used as part of a condition in rule Sales commission - Loan Sale as described above. Using a variable, we can change it at the same time reducing the chance of a potential error.

usage of rule variables

The rule variables can also be used in the same way as if they were a part of the input.

Activating/Deactivating commission

As described above ( Model structure - 2nd layer ), only the rules present in the List tables are evaluated. That provides the possibility of easily managing active commissions; all the admin has to do to deactivate a commission rule is to switch its record off in this table.


It is also possible to set an activation time for a particular rule, which gives an option to create time limited promotions or vary the commission settings based on season.

set activation time for row

Input/Output models

Input data is structured around the broker. All information for the commission processing is sent in a single batch and also the commissions for individual brokers are evaluated in one go. The data structure is created as an array so it is possible to process different types of commissions for a single broker, one type of commission for multiple brokers or any other combination.

Input data model

The input structure is set in the I/O Model of the main rule - Calculate Commissions. The input is divided into three parts:

Input data model
  • Commission type, a critical parameter which determines the commission model used. Possible values are: “SALES”, “MERIT”, “REVENUE”
  • Deals - necessary information about deals made. This structure should contain all the data required by the particular rules which are to be evaluated.
  • Broker, providing some information about the broker who made the deal. That information is useful for both commission processing, where the amount of commission may depend on the rank of the seller (for example), but also for reporting purposes.

The CommissionType property is mandatory in the commission processing. The content of the Deals and Consultant properties is variable and depends on the rule and parameters significant for the business logic of the commission.

Input JSON model

Output model

While the input structure has some mandatory components and many optional parameters that vary by the commission model, the output structure will be always the same:

Output data model
  • date of evaluation
  • the branch in which the broker is working
  • identification of the broker
  • Array of commissions awarded to the broker
Output JSON model

Input/Output model of Commission Rules

Each rule may have a different set of inputs to evaluate, and so the input structure is variable. If we take a look at an example of the sales commission SC_LOAN, it’s input model looks like the one in image no.1

The output of every commission rule has the same structure to make the final output uniform and simple to integrate. You can see the output model in image no.2

Input/Output model of Commission Rules
Input JSON model
Image no.1
Output JSON model
Image no.2

Example Commission Rules

Let’s have a look at rules in the 3rd layer which defines the business logic of individual commissions. Every commission model has its specifics just as every product class has the same.

For each example we will describe the input data needed, the logic and parameters set and also output of the rule.

While input structures will often vary depending on the type of commission model, the output will be essentially the same. All of the rules we have intended to present can be easily set in a simple form of tree structure so there is no need for programming skills. This might be useful for organizations where the IT resources are very sparse. Please bear in mind that as for any other IT tool it is strongly recommended to involve an application administrator in the process of new rule development.

Sales commission - Loan Sale

Sale commission of a loan in our case is calculated from three basic inputs:

  • loan amount, or the credit limit
  • withdrawn amount
  • and the type of a product

There might be several other parameters to calculate the commission, but we have decided to use a simple rule.

I/O JSON model

For the ease of maintainability there are also two rule variables defined. One defines the percentage values for the commission rate, which is used to calculate the payout of the commission, and the other, specifies the minimum ratio of the disbursed amount.

rule variables

This rule is constructed in the form of a decision tree and its implementation takes the following form:

decision tree

There is only one condition which checks whether or not the number of clients exceeds the predefined threshold.

We use the ARRAY_FILTER function to filter out any account where the newClient property is not true, then we COUNT these entries and we check if the count is greater than or equal to the threshold value defined in the rule variables as ACC_COUNT_THRESHOLD.

Positive Outcome

If the condition has been met, then the commission value is set to a predefined value (in our case 30.000) and the awarded property is set to true.

Negative Outcome

If the condition is not met, then the value of the commission is set to 0, the awarded property is set to false and there is a message generated under the reasoning that says “Not enough new clients” with the number of new clients that the broker has achieved.


DecisionRules integrates through Restful API (documentation). For the purposes of our case study, we would leverage the bulk processing of larger data sets. On top of that, there is also the possibility to call a single rule for one deal only. That could come in handy in situations where a broker needs to validate the amount of commission for a deal he/she intends to make.

API Calls

Communication with the DecisionRules dealing with larger data volumes invokes leveraging a middleware solution to facilitate seamless communication between the DecisionRules and the data source. This intermediary tool will manage data transmission, ensuring a secure and efficient exchange of information and maintaining data integrity.

The response from the API call contains a predefined output structure described above in detail. After processing in the middleware component, it can be used as a source for further business processes to approve the commissions and payment.

In order to test the solution, we can use the tool to mimic the middleware, visualize the response received and prove working logic inside the

A call from a postman application can look like this.

postman request

… and the response from Sales commission rule:

postman response


Business owners will need a set of reports that will provide information about the sum of the commission to be paid and also detailed information about a single case to be able to decide possible complaints.

Power BI will be our weapon of choice.

power Bi report is able to store detailed information about every single rule processing including the input data and the calculated output. This kind of data will be stored in the form of Audit logs. These logs can be then retrieved through the API and processed for reporting in Power BI. Find out more about the Audit logs from our documentation: link

In our example, the rule logs some basic information about the broker along with all the data used in rule evaluation, commission amount, name and type of the commission, the date when the commission was awarded and basic anonymous information about the account or client.


In this article, we have described how the commission models are implemented in the DecisionRules and we have described broadly how the model functions and the way to evaluate it. We have also tackled the reporting of commission results.

We mentioned that is not a single tool that will solve every aspect of the commission process, but could be the critical one that will contain and manage the precious knowhow.

In the next and last part of this series we will go into deeper detail for the implementation in so you can try if for yourself and experiment with various commission models.

Más Artículos