Format of the IF-ELSIF-ELSE-ENDIF construction is:
\If(Condition1)\
Reaction1
\elsif(Condition2)\
Reaction2
\else\
Reaction3
\endif\
Note: \If\ and \endif\ are the mandatory commands in this construction, \elsif\ and \else\ are an optional commands. The condition must be a variable with a boolean value. Such variables can have only two values: True or False.
Example:
Invoice template |
Explanation |
\If(INV_IS_PAID)\ Invoice is paid \else\ Invoice is not paid \endif\ |
If the invoice is paid (INV_IS_PAID=True), then "Invoice is paid" is displayed in the produced invoice, if invoice is not paid (INV_IS_PAID=False), then "Invoice is not paid" is displayed in the produced invoice. |
or
Invoice template |
Explanation |
\scan(dtLinkJobs)\ …….. \scanentry\ …….. \If(INV_IS_PAID)\ Invoice is paid \elsif(DTLINKJOBS:CJOB_ISCOMPLETED=true)\ Invoice is not paid \else\ Job is not completed \endif\
\scanfooter\ …….. \endscan\ |
If the invoice is paid (INV_IS_PAID=True), then "Invoice is paid" is displayed in the produced invoice, if invoice is not paid (INV_IS_PAID=False), then, if (DTLINKJOBS:CJOB_ISCOMPLETED=true), then "Invoice is not paid" is displayed in the produced invoice, if invoice is not paid (INV_IS_PAID=False) and if (DTLINKJOBS:CJOB_ISCOMPLETED=false), then "Job is not completed" is displayed in the produced invoice. |
IIF function
Function IIF returns one of the two values depending on the value of a logical expression. The syntax is: IIF(Logical_expr, Value1, Value2)
Invoice template |
Explanation |
\scan(dtLinkJobs)\ ... \scanentry\ ... \IIF(DTLINKJOBS:CJOB_ISCOMPLETED=true,100,0)\ ... \scanfooter\ ... \endscan\ |
If the Client Job is completed (DTLINKJOBS:CJOB_ISCOMPLETED=true) then 100.00 is displayed in the produced invoice. If the Client Job is not completed (DTLINKJOBS:CJOB_ISCOMPLETED=false), then 0.00 is displayed in the produced invoice.
|
Numeric report functions.
ROUND - The Round function rounds a real-type value to an integer-type value. 0.5 is always processed to largest integer number. This is not a banker's rounding.
Invoice template |
Explanation |
\Round(JOBS_TOTAL)\ |
If Jobs Total is 504.49, then 504 is displayed in the produced invoice, If Jobs Total is 504.50, then 505 is displayed in the produced invoice.
|
INT - The INT function returns the integer part of a real number.
Invoice template |
Explanation |
\Int(JOBS_TOTAL)\ |
If Jobs Total is 504.49, then 504 is displayed in the produced invoice, If Jobs Total is 504.51, then 504 is displayed in the produced invoice. |
SUM function
Function SUM can be used after \scan(dtLinkJobs)\, \scan(dtLinkInvoices)\ or \scan(dtLinkPayments)\ to give to some new custom variable the value of the sum of the values in the defined field. The syntax is:
\scan(table1)\
\endscan, sum(field of the table1, variable1)\
Total: \variable1\
Invoice template |
Explanation |
\scan(dtLinkJobs)\ \endscan, sum(DTLINKJOBS:CJOB_TOTAL, V1)\ Total: \V1\ |
Variable V1 is set to return the sum of client job totals anywhere in this invoice, just by entering \V1\ anywhere below in this invoice. If there are two client jobs in this invoice with totals of 345.00 and 678.00, then Total: 1023.00 will be displayed in the produced invoice. |
CTN function
Function CTN can be used after \scan(dtLinkJobs)\, \scan(dtLinkInvoices)\ or \scan(dtLinkPayments)\ to give to some new custom variable the value of number of data field entries with values <> 0. The syntax is:
\scan(table1)\
\endscan, ctn(field of the table1, variable1)\
Total: \variable1\
Invoice template |
Explanation |
\scan(dtLinkJobs)\ \endscan, ctn(DTLINKJOBS:CJOB_TOTAL, V1)\ Number of Client Jobs: \V1\ |
Variable V1 is set to return the number of client jobs with totals that are <> 0 anywhere in this invoice, just by entering \V1\ anywhere below in this invoice. If there are three client jobs in this invoice with totals of 345.00, 678.00 and 901.00, then Number of Client Jobs: 3.00 will be displayed in the produced invoice. |
NORESET option with SUM and CTN functions
NORESET option can be used with SUM and CTN functions to add the new values of the source field to the previous result of the function. The syntax is:
\scan(table1)\
........
\endscan, sum(field of the table1, variable1)\
\scan(table2)\
........
\endscan, sum(field of the table2, variable1,noreset)\
All totals: \variable1\
Invoice template |
Explanation |
\scan(dtLinkJobs)\ \endscan, sum(DTLINKJOBS:CJOB_TOTAL, V1)\ \scan(DTLINKPAYMENTS)\ \endscan, sum(DTLINKPAYMENTS: CPAYM_TOTAL, V1,noreset)\ Total: \V1\ |
Variable V1 is set to return the sum of client job totals plus payment totals anywhere in this invoice, just by entering \V1\ anywhere below in this invoice. If there are two client jobs in this invoice with totals of 345.00 and 678.00 and one payment with total of 77.00 , then Total: 1100.00 will be displayed in the produced invoice. |
For more details on Variables for each document type, see the chapters of "Available Template Variables".
It is recommended to begin with the Common Template Variables topic.
See also: