Calculate attributes down

Event action – Abstract

Purpose: Multiplies the 'Value' in a common business object in all aggregated numeric attributes of line items of the relevant line item types by the 'General number of packages' to calculate the 'Aggregate value' per attribute.

See also: Calculate attributes down (Order), Calculate attributes down (Shipment)

images/download/attachments/78253215/image2021-8-2_11-17-2-version-1-modificationdate-1627895824342-api-v2.png

The Calculate attributes down event action executes the following steps for selected Line item types (see Line item type) in a reference object of the Allgemeines Geschäftsobjekt:

  1. For 'Aggregate numeric attributes' within a relevant line item, the 'value" (value) is multiplied by the 'Aggregate number of packages' (aggregateNumberOfPackages), which can be determined in advance via the event action Berechne aggregierte Anzahl Packstücke, if required.

  2. The result of the multiplication is stored as an 'Aggregate value' (aggregateValue) within the attribute. If the 'value' (value) or the 'Aggregate number of packages' (aggregateNumberOfPackages) does not contain a value, the 'Aggregate value' (aggregateValue) field is deleted.

IMPORTANT◄ In contrast to the event action Berechne aggregierte Anzahl Packstücke, if the Line item types parameter does not specify a selection, the calculation does not include all line item types, but only the 'default' line item type (DEFAULT). Therefore, there is no possibility to parameterize the event action in such a way that it includes 'all' Line item types (i.e. also those that may be created in the future).

NOTE◄ On the line item level, basically every Numeric types appears as an 'Aggregate numeric attribute'. There is no possibility to distinguish between extensive and intensive quantities. The Calculate attributes down event action also treats each Numeric types the same: each 'value' is multiplied by the 'Aggregate number of packages' of the line item. However, scaling the 'value' does not make sense for every Numeric types, for example, if the value describes a 'maximum storage temperature', the 'standard lot size' for an item, or a 'minimum shelf life'. In such cases, simply ignore the calculation result in the 'Aggregate value' field and most importantly, do not display it in the form.

Runtime example:

The following example demonstrates a typical use for the Calculate attributes down event action:

images/download/attachments/78253215/image2021-8-2_11-22-14-version-1-modificationdate-1627896136531-api-v2.png

  • The line item hierarchy for a particular Line item type (here: 'Default') includes child line items. In the example, the child level refers to 'beer crates', which the parent item level summarizes as pallets.

  • The Number of packages defines the number of packages per pallet for the child line items, so that the actual number of 'beer crates' must first be determined as the Aggregate number of packages. This is made possible, for example, by the event action Berechne aggregierte Anzahl Packstücke.
    NOTE◄ How values are determined for the Aggregate number of packages is irrelevant for the execution of the Calculate attributes down event action. In addition to a calculation, interactive assignments or a provision via the interface can also be considered. It is essential that corresponding values must be available for all line items, for which the event action Calculate attributes down returns 'Aggregate values' in the following step.

images/download/attachments/78253215/image2021-8-2_11-23-30-version-1-modificationdate-1627896212655-api-v2.png

  • For the Aggregate number of packages, the value here is 60 (beer crates), which indicates the line item is 2 pallets, each containing 30 pieces (beer crates).

  • At the child item level, the 'Numeric aggregate attribute' Unit price has a Value (value) of 12.99 with a Unit price (unit) in 'EUR'.

  • The total value of all beer crates of the 'Lager' variety can be determined via the event action Calculate attributes down and written as the Aggregate value (aggregateValue).

images/download/attachments/78253215/image2021-8-2_11-25-21-version-1-modificationdate-1627896323710-api-v2.png

  • In the Aggregate value field, the product 2 x 30 x 12.99 = 779.40 (EUR) appears for line item 1.1 as the total value of the beer crates of the 'Lager' variety on the two pallets belonging to line item 1.

NOTE◄ The 'Aggregate value' field is included in the default component for each 'Aggregate numeric attribute'. However, by default, the component is added to the form without the element in question. It must be explicitly added to the container, which otherwise only displays the fields 'Value' and 'Unit'. The screenshot shows this container for the child item level shaded in gray for demonstration purposes. The calculation symbols ('X' and '=') have been added as Label elements for the sake of transparency.

NOTE◄ Of course, it is also possible to implement corresponding calculations in other ways (e.g. via Calculation field in Input forms or via loops with explicit calculations and value assignments in event handlings). Then the calculation result can also be assigned to another field or attribute instead of the 'Aggregate value'. Whether the schematic calculation via Calculate attributes down is applicable or advantageous in the respective use case remains to be weighed up against the background of the specific requirements.

IMPORTANT◄ For the Calculate attributes down event action execution, the display of the attributes in the form is irrelevant. The calculation results are always executed and written to the volatile data of the reference object.

Configuration

images/download/attachments/78253215/image2021-8-2_11-31-42-version-1-modificationdate-1627896704524-api-v2.png

The event action Calculate attributes down expects a Allgemeines Geschäftsobjekt as the reference object. In the context of another object type, the event action has no effect without an error occurring at runtime.

Multiple selection for Line item types can be used to define a positive list for relevant Line item types (see Line item type).

  • If no Line item types are selected, only the Positionstyp 'Default' (DEFAULT) will be taken into account.

Example

As an extension to the event action Berechne aggregierte Anzahl Packstücke, for example, the event action Calculate attributes down is executed for the displayed reference object by clicking on an additional Button (Calculate) within a data input form for a fictitious Allgemeines Geschäftsobjekt of the type 'Package deal' (PACKAGE_DEAL). Using the values for 'Aggregate number of packages' previously calculated via Berechne aggregierte Anzahl Packstücke, the total value per line item is to be determined in this way for all line items (with Line item type 'Default') for which a Unit price is specified.

Configuration:

For the Calculate Button, a behaviour is set up with a Client workflow behaviour configured as shown on the right:

  • The Validating rule uses a Check type to ensure that the reference object is a Allgemeines Geschäftsobjekt.

  • As the only Action on passed rule, the event action Calculate attributes down (from the Allgemeines Geschäftsobjekt category) is added. Under Line item types, 'Default' (DEFAULT) has been explicitly selected. Although this is equivalent to 'no selection', it is much more transparent as it avoids the impression that the calculation includes all line item categories.

NOTE◄ If the calculations are triggered not only manually but also automatically when saving, for example, an event handling can also be configured instead of the Client workflow, which must then be addressed by the Button via a Eigenes Aktionsevent. It may also be useful to execute the event action Berechne aggregierte Anzahl Packstücke in the same workflow immediately beforehand, so that both calculations are always executed in combination.


images/download/attachments/78253215/image2021-8-2_11-29-48-version-1-modificationdate-1627896590480-api-v2.png

Runtime example:

The following screenshot shows a Allgemeines Geschäftsobjekt of the 'Package deal' type for which the event action Berechne aggregierte Anzahl Packstücke per the Aggregate Button has already been executed.

Then, for selected items or child items, values were entered in the Unit price attribute, which then appear highlighted in gray shading (see CSS class behaviour type).

images/download/attachments/78253215/image2021-8-2_11-27-5-version-1-modificationdate-1627896427956-api-v2.png

After the aggregation has been executed and the 'correct' (child) items have been provided with prices, the Calculate Button triggers the calculation of the goods values:

images/download/attachments/78253215/image2021-8-2_11-27-51-version-1-modificationdate-1627896473736-api-v2.png

  • The configured Client workflow provides the Aggregate value in the 'Unit price' attribute of each default item and also assigns corresponding values to other 'Aggregate numeric attributes' not displayed in the form.

  • In the header data of the 'Package deal', the 'Numeric attribute" with the Numeric types 'Goods value' is also included here. It is located above the elements for the 'Aggregate value' and is designed as a calculation field (see Calculation field) with the following expression:

    images/download/attachments/78253215/image2021-8-2_11-28-47-version-1-modificationdate-1627896529833-api-v2.png


    The elements #66, #75 and #81 are the elements for the Aggregate value in the 'Unit price' attribute in the three mapped line item levels.