Calculations (Grouping)
    • 04 Mar 2025
    • 2 Minutes to read
    • Contributors
    • PDF

    Calculations (Grouping)

    • PDF

    Article summary

    You can use the Calculation tool to calculate groups of item lines in the Conditional Area.

    Selecting the Sum Group option of the Calculation tool allows creating a new script rearrange that sums over all values of rearranges selected within a group. By default, the script rearrange is inserted relative to the last instance of the group.

    Exercise

    Download and import the attached configuration called 19. Calculations (Grouping) in Lasernet Developer 9. Afterward, navigate to the Forms section and open the Sample form.

    1. Select rearranges in the Amount column and open the Edit Rearrange dialog. Switch to the Objects tab.

    2. Type Amount as Object name.

    1. Switch to the Formats tab and select Number as Format category.

    2. Click Ok to confirm changes.

    1. On the Developer toolbar, select the Pattern tool.

    2. In the input, click the /Root/Body/ItemGroup node.

    3. Switch to the Output tab in the Pattern Properties dialog.

    4. Select the Group until checkbox.

    5. Set Additional progress to 10 mm.

    6. Click Ok to confirm changes.

    The item lines are now divided into three groups with a progress of 10 mm between each group [1]-[3].

    1. On the Developer toolbar, select the Rearrange tool.

    2. In the input, click the /Root/Body/ItemGroup/Description node.

    1. On the Property bar, set Font size to 13 pt, the X position to 42 mm and the Font style to Bold.

    1. Select the first rearrange in the Amount column.

    2. On the Developer toolbar, select the Calculation tool, and then click Sum Group.

    A script rearrange used for calculating totals for a group of patterns is added to the bottom of each group.

    The SumGroup(Amount) system script is used to calculate the rearrange group total.

    The Relative to: Bottom of group and the Group: ItemGroupGroup (a user can define a name for a group) parameters are used to bind rearranges at the bottom of the required group.

    1. On the Menu bar, click View, and then click Run JavaScript, or click Shift + F5 to view the result of group calculations.

    1. On the Developer toolbar, select the Text tool to add a fixed text to the output.

    2. Open the Edit Rearrange dialog and switch to the Position tab.

    3. Set Relative to to Bottom of group and Group to ItemGroupGroup.

    4. Click Ok to confirm changes.

    1. Select text objects you have added and right-click the selection. On the context menu, click In-place edit to edit the text. Type “Subtotal”, and then click F2 or Ctrl + Enter to exit the edit mode.

    1. Afterward, set the X position of the selection to 42 mm.

    1. Select the Subtotal text and [script]. Set the Y position of the selection to 4.5 mm, as well as the Font style to Bold.

    1. On the Developer toolbar, click Shape, and then click Line.

    1. Add a line to the output as illustrated:

    1. For the added line, set the following properties: the X position - 162.5 mm and Y - 1 mm, Relative to - Bottom of group and Group - ItemGroupGroup.

    A line is added at the bottom of the group just above the subtotal.

    1. To complete the design you can insert the total sum for the Amount column. To this end, use the Text tool to create a new text object. Edit the object properties by setting Object type to Script, Format category to Number, Script to Sum(Amount), Font size to 18 pt, the X position to 196 mm, the Y position to 281 mm, and the Font type to Bold.