Applies to version 8.0.x; Author: Michal Rykiert
Some workflows and business processes such as purchase requests or cost invoice settlements require to calculate values that appear as metadata on a form. To make users’ life easier, WEBCON BPS enables real-time, dynamic calculations that significantly speed up processing of forms.
This article describes basic configuration of item list field where aforementioned calculations are usually held. It can be divided into following steps.
1. Creation of item list field and proper columns.
First step is pretty obvious. It is required to create a new field and set its type to “Items list”. To do so, just go to WEBCON BPS Designer Studio, go to your process, click on “Form fields” and create a new field. Name it as you like (e.g. “Products”).
Each Items list field should contain some columns. For the purpose of this exercise, create following fields:
- Product name (single line of text)
- Price (Floating-point number). Before proceeding to the next step, go to the field configuration and set number of decimal places to two, tick “Show as amount” checkbox and enter currency code (e.g. “$”).
- Quantity (Floating-point number) – in field configuration, change number of decimal places to 0
- Subtotal (Calculated floating-point value)
- Tax rate (Floating-point number) – in configuration uncheck “Show summary in column footer”
- Tax amount (Calculated floating-point number)
- Total (Calculated floating point number)
After doing so, proceed to Fields matrix and make sure the field and its columns will be visible on your form. Then save the process.
2. Configuration of calculation expressions.
Basic configuration of calculated columns is very simple and does not require any SQL queries. All that’s needed is an expression editor implemented in the system.
a) Calculation of Subtotal amount
Firstly, lets configure Subtotal field to show a outcome of following equation: Price*Quantity.
In order to do so, go to Subtotal field configuration and compose the equation by clicking proper values from the object tree.
Please note, there’s no need to put equal sign into the equation. The system already know that the result of the equation should be displayed in configured field.
So the proper expression in this case would look like this:
Also, check “Show as amount” and put currency code and leave “Show total” checked. This option will display a total amount for this column, below all rows included in the item list field.
Save the process and test your configuration. The result should look as below:
2b) Calculation of tax amount
In most cases tax applies to products we buy, therefore it’s always good to know how much tax we pay per each product.
This article will present the most basic method of calculating tax amount.
In the tax rate field, user has to put proper decimal number which will be equal to actual tax rate that applies to given product. E.g. 0,10 equals 10% tax.
With such assumption, configuration of Tax amount field would be analogical to previous example and the equation would be: Subtotal*Tax rate.
2c) Calculation of total value.
Now, it would probably nice to know how much in total each product cost and also how much all products cost.
To have that calculated, go to Total field configuration and apply following equation Subtotal+Tax amount.
By checking Show Total, below all rows within item list field, you’ll also see the total cost of all products.
Save the process. Try out the configuration on your form:
3. Transferring values from item list to other fields.
Sometimes, e.g. in case of generating documents, it is more convenient to have certain amounts put into “regular” fields on the form. Let’s transfer total amount into a new field named: “Order amount”.
First, create a new field and set its type to floating-point number, tick: “Show as amount” and “Currency code” checkboxes and put currency code. Save the process.
Now proceed to configuration of Products (item list field). Go to “Totals control” tab and add a new line in “Copy column total to field”. In Column choose Total and in Field choose Order total. Save the process.
Now the field of “Order total” will be updated dynamically based on data included in “Products” field.
4. Additional information
a) To ensure that all data will be correct 100%, set all automatically calculated fields to read-only mode. In order to do so, use Fields matrix.
In case presented above, it would be recommended to set fields of “Subtotal”, “Tax amount”, “Total” and “Order total” as read-only.
b) WEBCON BPS allows to make more complex calculations, also with static values, action brackets, etc.
The system will follow mathematical order of operations.
Please note, this article describes only basics regarding calculations in WEBCON BPS. Ultimately, much more can be achieved. Contact us at email@example.com to learn more.