Edit documentation Edit document
GH-Elements

Calculator

Calculator is a gh-element that allows you to make expressions that will automatically calculate a value according to given conditions.

Functional Characteristics

This element allows you to automate various calculations. For example, it can be configured for payroll calculations. It can calculate not only number data. It can also count the amount of items sold by their status, which is set with radio button in items.

Value Format

The value depends of the Persistent Value setting. When that is off, calculator does not save the any value. In other case, the calculation result with all additional elements entered in settings is saved as a field value.

{
    "field_value": "4.00"
}

Element Options

The calculator has two types of options, which allow you to compose an expression to calculate the value and which allow you to customize the value in the field.

Field Settings

The first setting group contains standard field settings and additional settings that configures the displaying of the calculated value.

Settings of calculator field

Name Description
Precision allows to select the precision of the calculation result; details...
Prefix allows to enter the special prefix for the calculation result; details...
Suffix allows to enter the special suffix for the calculation result; details...
Persistent value allow to configure whether the value will be saved or not; details...
One time generation allows to make the stored value unchanged; details...

Precision

This is a function that allows you to select the precision of the result of the calculation up to the third sign after the point.

Prefix

This is the sign that will be displayed before the calculation result. The prefix is entered in settings.

Suffix

The suffix is displayed after the calculation result. It could be any sign entered in settings.

Persistent Value

This function configures whether the calculation result will be saved as a field value or not.

One Time Generation

This option allows you to make the current value of the field constant. That means, the current value cannot be updated using simple methods. The only way is to use update button. The One Time Generation works only when Persistent Value is on.

Calculator Value Selection

This is the actual calculator by which the stored result is calculated. It can perform its functions both with entered values and with field values.

Value calculator

Name Description
Standard Calculator Buttons allows to enter the basic calculation element and numbers; details...
Field allows to select the value from which the value will be taken for calculation; details...
IF allows to use the value with the conditions; details...
Items count allows to use the number of items in calculation; details...
SUM allows to get the sum of all value of the selected field; details...
< allows to erase one element of the expression; details...
Clear allows you to erase expressions completely; details...

Standard Calculator Buttons

There are all standard calculator buttons in this element. They allow you to compose basic mathematical expressions.

Field

This button opens the popup up window where you can select the field from which the value will be taken for calculation.

IF

This is a function that allows you to use a value or field value in an expression if the conditions are met.

Items Count

This function allows to use the number of items of the selected application in calculation.

SUM

This function allows you to get the sum of the values of a certain field from all items. It also allows you to set conditions for fields and sum not all values.

Clear Element

This button removes the last one element of the expression after clicking it.

Clear

This the button that allows to erase all the expression.

Element Style

In set of style settings, besides standard options, the calculator has only one unique setting, which slightly changes its interpretation.

Style of calculator element

General Settings

The general style settings of calculator contains one additional option that allows to expand the functionality of the element.

General settings of calculator style

Name Description
Update button allows to add the update button

Update Button

This is the button that allows to update the field value. It is only useful when the One Time Generation function is enabled.

Data Model

{
    "data_model": {
        "arguments": [{
            "app_id": "27904",
            "sum_filters": []
        }],
        "expression": "5*6+ITEMSCOUNT()",
        "interpretation": [],
        "is_generate_once": 1,
        "is_persistent_value": 1,
        "precision": "2",
        "prefix": "",
        "suffix": ""
    }
}
Name Type Description
arguments array contains the settings of each of the arguments of the expression
app_id string contains ID of the source application
sum_filters array contains all the filters that determine which values will be used in the calculations
expression string contains full expression of the calculation
interpretation array contains all element interpretation types
is_generate_once boolean shows whether the value will be updated automatically
is_persistent_value boolean
precision string contains number of values after the point
prefix string contains value of the prefix
suffix string contains value of the suffix

Filtration

The current element can be filtered by value using these filters:

Interpretation

The calculator look is quite similar to the simple number. Namely, its interpretation types display this element as a number.

Types of calculator interpretation

Default

The default type of interpretation displays allows the result of calculations with all additional signs, such as prefix, suffix, and precision.

Value

The second interpretation type displays the raw field value. Namely, it is without additional signs.