Estimated reading time: 9 minutes



How to calculate commission on sales?


1. Introduction

The practical need of every business is to measure sales and to further motivate and/or reward successful ones. The most common way for a company is to calculate commission for its salesmen or lobbyists.

For simplicity, the most common form is flat rate commission (eg, on each sales order 5% of its value is charged). It is simple but it leaves many questions, and some of which are:

  • Is this applicable to all types of businesses?
  • How is the customer return calculated?
  • Should all commercialists have the same commission?
  • If the margin is different, should the same percentage always be calculated?
  • What if more people are participating in sales?
  • If the buyer is granted a discount, does the commission need to be reduced?
  • A higher sales order amount to account for a higher percentage?
  • The calculation should be done only when the goods are delivered?
  • Etc …

Since the simple way cannot meet the needs, there are different types of commission calculation (straight, tiered, gross, placement fees, gates, share of margin, etc.). The more time passes, the more complex the calculations become.

For us as software developers to implementing all these methods is a big challenge. Not only because of their complexity but that the methods are evolving. Depending on the market conditions, companies change their calculations. Each change takes time as well as new hours of development, which requires additional costs, especially for SMBs.

  • What is the solution?

The solution is to enable each company to independently set up the calculation.

  • Why?

No one can understand and set up a calculation other than the company itself.

  • How? When a visitor has no programming experience or access to the programmer’s code?

ERPAG has integrated Google Blocky ( ), a visual programming language ( VPL ) that allows users more unprecedented customization.

erpag blockly

In this text, we will do an example of commission calculation.

2. Custom fields

Custom fields are a very useful option in customization (for more details check out this link:

Due to data integrity, enrollment is limited to custom fields only. So we will open up new fields to store the results.

Opening a new custom filed is done by activating the “add new” option in the “custom fields” panel when entering a sales order (new or edit mode of an existing one).

sales order custom fields

In our example we will create a custom field, that is a type: List.

custom field type list

Where we will enter a list of our sales representatives:

custom field sales representatives

And we will create an additional “commission” field, that has an “Amount” type (numeric). “Read-only” status can be turned on in order to forbid the operators to change the values.

custom field amount type

Note: Opened Custom fields can be dragged-and-dropped to any position in the document. In our example, we will place it in the “document header” section.

custom fields repostitioning


3. Creating the Blockly Script

This option is located in Administration > Integrations > Blockly Scripts

erpag blockly scripts

Upon activating the “Create” button, we will choose “Sales Order”.

create blockly script

When entering a document, the Blockly toolbar also has ERPAG variables (highlighted in red) in addition to the standard options (highlighted in green).

blockly toolbar

Programming is done like stacking with the mouse (drag & drop technique). You can find more information on Google for Education ( ).

4. Creating the script

It is necessary that for the sales specialist “Nikola Tesla” we calculate the commission of 5% and added 2% on amounts over $1000 when the invoice is generated from the sales order.

Since the script will be executed at every recording of any sales order, we have to set the condition that the calculation is valid only for “Nikola Tesla”.

erpag blockly

What we recommend is that when comparing text data you should always include “UPPER CASE”, because operators do not care if data is case sensitive or not.

What we put inside the “IF” block will be executed if the data from the custom field called “sales specialist” equals “NIKOLA TESLA”.

erpag blockly script

In the example from the picture custom field named “Commission” will have 5% of the sales order value.

In order to only be accounted for when the invoice is generated, we need to add another condition.

erpag blockly script

And we still have to do an extra 2% if the invoices are over $1000.

erpag blockly script

And in such a simple way, we did a complex calculation without having to hire professional developers.

5. Activating the script

To prevent unfinished scripts from running, each script is paused when it is saved.

erpag blockly script

All blocks are colored in gray when the script is paused. Script activation is via the “Run” option.

The active script has the status “Running”, it can be stopped by activating the “Pause” option.

erpag blockly script start pause


6. Results in Sales Order

To see the results we will create a Sales Order, where we will mark the corresponding “sales specialist”.

sales order in erpag

Before the invoice, the commission value will be 0 and it will not be displayed (custom fields that are empty or value is 0 are not being displayed).

invoice sales order

When we “invoice” the sales order, the value of the “commission” custom field will be populated.

sales order commission


7. Manipulations with Scripts

This script is done for one sales specialist, for others, you can insert in the same script or form a new one. ERPAG has no specific limit on how many scripts you can have per document type.

When in edit mode you can use copy/paste options to copy.

copy paste blockly script

We will activate “copy” in “Nikola’s commission” and we will paste it into a new Script and refine it a bit.

erpag blockly script

On the script list, we can see which ones are currently active.

erpag blockly script list

If we have more than one script for the same document, the priority for executing will be its number.

8. Conclusion

Forming the scripts may seem unclear at first glance, especially to someone who has not had prior experience. The biggest benefit you get is the ability to customize the system on your own.

Visual programming languages ​​(such as Google Blockly) are already a part of the elementary school’s educational program today. Therefore mastering this tool will not pose as a big challenge.

2019. ER{“type”:”block”,”srcClientIds”:[“e46606b8-53b6-4258-8a15-46bd13979510″],”srcRootClientId”:”eaaea778-7a8c-4c28-9295-064cd3c565aa”}PAG Inc.

Start NOW

Read More

Related Posts

How Great Inventory Software Can Help Fight Inflation

In today's rapidly fluctuating economy, businesses face the daunting challenge of fighting inflation. Rising costs can erode profits and disrupt operations, making it essential to adopt strategies that mitigate these impacts. One powerful tool in this battle is...

read more
​ERPAG API – Xero OAuth 2.0 authorization

​ERPAG API – Xero OAuth 2.0 authorization

In this instruction blog, we will describe how to create OAuth 2.0 API keys on your Xero account. These API keys are necessary in order to make API calls from ERPAG via Blockly scripts. The instructions show how the process itself currently looks. If in the meantime...

read more