# Contract automation and calculating a value automatically

## Contract automation and calculating a value automatically

Weagree’s contract automation wizard permits automatically calculating a value and inserting the result into the contract text. Such calculation operates with the calc-tag (calculation options and examples are below). The calc-tag must contain all variables as are necessary to calculate and produce the required result.

The variables may be Q&A-answers. Therefore, a calculation tag may contain global questions and local questions (which local questions may be used to reflect a value in the same contract clause).

By exception, inserting such calculation is not achieved by a dedicated button, but (given the indefinite number of possible calculations) requires that you add

Remarks:

• Like in mathematical formulae, any round brackets ( ) used within the calculation tag determine the order of the calculation.
• An edit question or choice question can be used without that answer being inserted in the contract. In such case, the answer will only be used in the calculation.
• Using brackets to open and close the calculation part of the tag permits using decimals with a full stop.
• It is possible to format the calculated value (see below)

Calculation tag structure:

[calc.<tag name>.(<calculation>)]

[calc.<tag name>.(<calculation>).<formatting parameter>]

### Examples of simple calculations:

Sum ( + ):

[calc.Example of a sum.(200+[edit.Amount 1]+[edit.Amount 2]+[gq.Value entered elsewhere])]

Example – Deduct ( – ):

[calc.Example of a deduction.(200-[edit.Amount 1]-[edit.Amount 2]-[gq.Value entered elsewhere])]

Example – Divide ( / ):

[calc.Example of a divide.(200/[edit.Amount X])]

Example – Multiply ( * ):

[calc.Example of a multiply.(200*[edit.sum1])]

Example – Combine: sum and divide ( + and / ):

[calc.Example of both sum and divide.((200+[edit.sum1]+[edit.sum2]+[gq.sumglobal])/2)]

Example – Combine a nested calculation and sum (calculation within a calculation and + ):

[calc.Calculate with existing value.(200+[calc.Example A divide])]

### Possible other parameters in a calc-tag are:

 Name Description Usage Result Pow Results in a specified number raised to the specified power. Pow(3, 2) 9d Sqrt Results in the square root of a specified number. Sqrt(4) 2d Ceiling Results in the smallest integer greater than or equal to the specified number. Ceiling(1.5) 2d Max Results in the larger of two specified numbers. Max(1, 2) 2 Floor Results in the largest integer less than or equal to the specified number. Floor(1.5) 1d Min Results in the smaller of two numbers. Min(1, 2) 1 Round Rounds a value to the nearest integer or specified number of decimal places. The mid number behaviour can be changed by using EvaluateOption.RoundAwayFromZero during construction of the Expression object. Round(3.222, 2) 3.22d Truncate Calculates the integral part of a number. Truncate(1.7) 1 Abs Results in the absolute value of a specified number. Abs(-1) 1M IEEERemainder Results in the remainder resulting from the division of a specified number by another specified number. IEEERemainder(3, 2) -1d Log Results in the logarithm of a specified number. Log(1, 10) 0d Log10 Results in the base 10 logarithm of a specified number. Log10(1) 0d Sign Results in a value indicating the sign of a number. Sign(-10) -1 Cos Results in the cosine of the specified angle. Cos(0) 1d Sin Results in the sine of the specified angle. Sin(0) 0d Tan Results in the tangent of the specified angle. Tan(0) 0d Acos Results in the angle whose cosine is the specified number. Acos(1) 0d Asin Results in the angle whose sine is the specified number. Asin(0) 0d Atan Results in the angle whose tangent is the specified number. Atan(0) 0d Exp Results in e raised to the specified power. Exp(0) 1d

Example:

[calc.Example A.(([edit.value1] +([edit.value2] * 3)/2))]

[calc.const.(5000)]

Reusing an existing calculation:

[calc.Example B.([calc.Example A]+2)]

[calc.Example C.([calc.const]+[calc.Example B])]

When inserting the tag (in the template creation tool), regardless of the applicable template language or culture, any decimals must be separated with a full stop ( . ):

[calc.Example D.([calc.Example A]+2.5)]

To force the user to enter a number whether as an integer or a numeral with decimals (and not a text string with thousand-separators or spaces), the edit-question dialogue screen permits enforcing certain data formatting.

The dropdown in the edit-question dialogues screen can be set to require an integer (natural number, containing no decimals) or a numeral with decimals. In such case, the value to be entered may not contain thousand separators (or decimal, if applicable), prompting an error message during the questionnaire.