# Calculations and number-formatting

Weagree’s contract automation wizard permits automatic calculations of values and inserting the results into the contract text. Also, it is possible to force a number formatting (it reinforces consistency and permits exporting of entered or calculated data to external IT systems and into the CLM).

1. CALCULATING A VALUE (AND INSERTING THE RESULT IN THE CONTRACT TEXT)
Such calculations operate 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).

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>)]

If formatting requirements apply to the calculation result:

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

Examples of a simple calculation:

Sum ( + ):

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

Example – Deduct ( – ):

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

Example – Divide ( / ):

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

Example – Multiply ( * ):

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

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

[calc.Example A 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: 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)]

2. FORCING A DATA FORMAT
To force the user to enter a number whether as an integer or a numeral with decimals (and not a text string with hand-typed thousand-separators or spaces), the dialogue screen for editable questions 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 by an end-user may not contain thousand separators (or decimal, if applicable), prompting an error message during the questionnaire.

3. FORMATTING A NUMBER
Contract automation with external integration option likely requires that the exported values (amounts and percentages) in the contract text have been entered in a plain number format. Also in Weagree’s contract lifecycle management solution, the CLM data are only searchable as a (numeral) value if they had been formatted correctly.

So, while the user must enter a numeral without thousand-separators, the contract text should present the numeral correctly: with thousand separators and with such number of decimals (two cents) as the amount or number may require. This is achieved with the calc-tag, which will contain the edit-tag followed by the formatting parameter.

The typical formatting tag applied to a user entered value will be:

[calc.Amount of the loan.([edit.Principal loan amount]).#,###.##]

The following number-formatting examples deliver the indicated results in the contract: 