Working with Variables

General

LoanPro makes loan and customer data available so that you can create  formsemailspayment receipts,  rulescomputation fields, etc. that are customized for each loan or customer. This article will help you understand how to use these variables so you can maximize your use of the software.

To access a list of available variables in most places where rules or templates are created in the system, click  Help Variables at the top right of the edit area.

You can use the search field to find variables you want to use.  For most variables, you can click the Help Variable ID to insert the variable into the edit area at the position where the cursor is located.

Single-Value Variables

Most variables are single-value variables. This means that the variable has one value per loan, customer, etc. For example, the variable ‘setup-loan-amount’ is the variable for loan amount, which is a single number. Using a single-value variable is easy. Just click on the variable ID or type the variable into a template or rule.

If you are using a variable with a template, you will typically enter it like this [[v(‘setup-loan-amount’)]]. This is because templates are forms or messages that will require a direct replacement of the variable with a display value. The double brackets tell our template generator to look at the text as something more than just plain text. The v() is the variable function, which tells the template generator that you want to find a variable and replace it with an appropriate value. The ‘setup-loan-amount’ piece is the ID of the variable you want to use.

Because templates are for display, there are functions to help you format the data the variable is standing in for. For more information on using formatting functions, see the article  here.

If you are entering the variable into a rule, you are actually writing a Clojure (the language our rules service uses) script. This means you can enter the variable name straight in, in most cases (e.g. setup-loan-amount).

Date-Range Variables

Date Range is a category of variables. You can have this type of variable calculate and display a total over a specified date range. Several ranges are built in to the system, but you can also choose a custom range. The query() function is used in order to specify both the date and the date range.

Function Name: query()

Parameter 1: Variable Property Name (required)

Parameter 2: Date Range String (required). Options include:

  • date.range.all – This returns the sum for all dates.
  • date.range.customDays – This lets you specify a custom date range in the past. You will be required to enter the number of days ago when the date range starts and the number of days ago when the date range stops as additional parameters. The larger number should be entered first.
  • date.range.customFuture – This lets you specify a future date range starting with tomorrow up to a specified number of days over which the total will be calculated.
  • date.range.customPast – This lets you specify a past date range starting with yesterday up to a specified number of days ago over which the total will be calculated.
  • date.range.lastMonth – This will calculate a total for the last month.
  • date.range.lastWeek – This will calculate a total for the last week.
  • date.range.lastYear – This will calculate a total for last year.
  • date.range.monthToDate – This will calculate a total for the current month to date.
  • date.range.thisMonth – This will calculate a total for the current month.
  • date.range.thisWeek – This will calculate a total for the current week.
  • date.range.today – This will show the total for today only.
  • date.range.yearToDate – This will calculate a total for the year to date.
  • date.range.yesterday – This will show a total for yesterday only.

Parameter 3: A number of days. This option is only used for the date.range.customPast, date.range.customFuture, and date.range.customDays options.

Parameter 4: A number of days. This option is only used for the date.range.customDays option.

Example #1

If you would like to see the total paid last month, you should use the following date range variable with the query function: [[query(‘payments-total’, ‘date.range.lastMonth’)]].

Example #2

If you would like to see the total amount paid for the last 10 days, you should use the following date range variable with the query function: [[query(‘payments-total’, ‘date.range.customPast’, 10)]].

Example #3

If you would like to see the total amount paid over a date range that started five days ago and extends to 15 days ago, you should use the following date range variable with the query function: [[query(‘payments-total’, ‘date.range.customDays’, 5, 15)]].

Array-Style Variables

Some variables let you merge data for which there are multiple values.  For example, if you wanted to merge the scheduled interest amount for a single payment into a form, you’d need to specify which payment you had in mind.  Since there are multiple scheduled payments on a loan, this variable is an array-style variable (a variable that holds multiple values).

Array variables also contain

all the data for a particular item or transaction.  For example, if you want to include the payment amount from a scheduled payment in a form, you can search for Scheduled Payments and click the  icon to the left of the variable name to view the data for this variable.

To insert the variable value for principal amount, click scheduled-payments.amount.  This will insert the variable in this form: [[v(‘scheduled-payments.INDEX.scheduled-payments.amount-principal’)]].  Now, you simply need to replace INDEX with a numeric value for a specific payment like this: [[v(‘scheduled-payments.0.amount’)]].  This will actually show the values for the first scheduled payment because the indexes for array variables start at 0 instead of 1.

You can also use array variables inside of a loop. This means that you tell the template to go through every iteration of the array variable. You can see more information on using logic in templates  here.

Loops

When you create loops, you can either surround the loop elements in double curly braces {{}} or double square brackets [[]]. You have the option to either loop commands either directly on the face of the template, or as HTML comments. On the face of the template, logic would look something like this:

[[BEGIN]] [[END]]

After the BEGIN command, we need to enter the name of the array variable we want to loop through:

[[BEGIN scheduled-payments]] [[END]]

Finally, we will enter what we want the form to display for each iteration of the variable. If we enter variable properties, they should be inside double square brackets:

[[BEGIN scheduled-payments]] [[amount]] [[END]]

The logic above will output the amount of each payment. If the payment amount is $500.00 and there are 5 payments, the output will be something like this:

1000

1000

1000

1000

1000

We can then add other things to help format the loop output.  Formatting functions don’t work exactly like usual in loops. When enter the logic on the face of the form, it can be hard to do things like build HTML tables. To do something like that, you can enter the BEGIN and END commands as HTML comments.

To do this, first click the HTML editor button  . This will bring up a window where you can directly edit the HTML. Your commands as HTML comments should look like this:

<!– [[BEGIN scheduled-payments]] –>

<!– [[END]] –>

If you are trying to build a table on the form, the end result will look something like this:

You can see the comments in red. Click . Your form will look something like this:

  

This should output the following schedule:

Formatting Functions With Array-Style Variables

You can use formatting functions within array-style variables, but you have to include extra parameters for them to work. Currently only these formatting functions are supported:

  • formatDateTime()
  • companyFormatDateTime()
  • formatNumber

The difference when using these functions inside a loop is that the first parameter is a variable property name instead of a variable name, there is a variable used to let the template service know which iteration of a variable it’s on, and there is an extra parameter of variable name.

  • Function Name: formatDateTime()
  • Parameter 1: Variable Property Name (required)
  • Parameter 2: Format String (required)
  • Parameter 3: Offset (required) – This is a string that lets you add or subtract time from dates. For more information go here.
  • Parameter 4: $_num (required) – This is a variable the template engine uses to recognize the number of the variable iteration.
  • Parameter 5: Variable Name (required) – The name of the variable the property of which is being used as Parameter 1.

The final function should look something like this: [[formatDateTime(‘date’, ‘m/d/Y’, ”, $_num, ‘scheduled-payments’)]].

Example Loan Payment Schedule:

<table><tbody>
<tr>
<th>Period</th>
<th>Payment Amount</th>
<th>Payment Date</th>
<th>Principal Remaining</th>
</tr>
<!–[[BEGIN scheduled-payments]]–>
<tr>
<td>[[period]]</td>
<td>$[[formatNumber('amount', '2', '.', ',', $_num, 'scheduled-payments')]]</td>
<td>[[formatDateTime('date', 'm/d/Y', ", $_num, 'scheduled-payments')]]</td>
<td>$[[formatNumber('principal-balance', '2', '.', ',', $_num, 'scheduled-payments')]]</td>
</tr>
<!–[[END]]–>
</tbody></table>

This example will iterate the scheduled payments on the loan from the loan transactions report, and will display a list of payment due dates and amounts. The example above would output something similar to the following formatted inside of a table using HTML:

Scheduled Payments:

Period Payment Amount Payment Date Principal Remaining

1 $439.58 10/01/2015 $4,602.09
2 $439.58 11/01/2015 $4,200.86
3 $439.58 12/01/2015 $3,796.29
4 $439.58 01/01/2016 $3,388.35
5 $439.58 02/01/2016 $2,977.01
6 $439.58 03/01/2016 $2,562.24
7 $439.58 04/01/2016 $2,144.01
8 $439.58 05/01/2016 $1,722.30
9 $439.58 06/01/2016 $1,297.07
10 $439.58 07/01/2016 $868.30
11 $439.58 08/01/2016 $435.96
12 $439.58 09/01/2016 $0.00

Note: When using recursive loops inside of HTML tables, the [[BEGIN]] and [[END]] statements must be encapsulated in HTML comment tags. See above.

Function Name: companyFormatDateTime()

Parameter 1: Variable Property Name (required)

Parameter 2: Offset (required) – This is a string that lets you add or subtract time from dates. For more information go here.

Parameter 3: $_num (required) – This is a variable the template engine uses to recognize the number of the variable iteration.

Parameter 4: Variable Name (required) – The name of the variable the property of which is being used as Parameter 1.

The final function should look something like this: [[companyFormatDateTime(‘date’, ”, $_num, ‘scheduled-payments’)]].

Example Loan Payment Schedule:

<table><tbody>
<tr>
<th>Period</th>
<th>Payment Amount</th>
<th>Payment Date</th>
<th>Principal Remaining</th>
</tr>
<!–[[BEGIN scheduled-payments]]–>
<tr>
<td>[[period]]</td>
<td>$[[formatNumber('amount', '2', '.', ',', $_num, 'scheduled-payments')]]</td>
<td>[[companyFormatDateTime('date', ", $_num, 'scheduled-payments')]]</td>
<td>$[[formatNumber('principal-balance', '2', '.', ',', $_num, 'scheduled-payments')]]</td>
</tr>
<!–[[END]]–>
</tbody></table>

This example will iterate the scheduled payments on the loan from the loan transactions report, and will display a list of payment due dates and amounts. The example above would output something similar to the following formatted inside of a table using HTML:

Scheduled Payments:

Period Payment Amount Payment Date Principal Remaining

1 $439.58 10/01/2015 $4,602.09
2 $439.58 11/01/2015 $4,200.86
3 $439.58 12/01/2015 $3,796.29
4 $439.58 01/01/2016 $3,388.35
5 $439.58 02/01/2016 $2,977.01
6$439.58 03/01/2016 $2,562.24
7 $439.58 04/01/2016 $2,144.01
8 $439.58 05/01/2016 $1,722.30
9 $439.58 06/01/2016 $1,297.07
10 $439.58 07/01/2016 $868.30
11 $439.58 08/01/2016 $435.96
12 $439.58 09/01/2016 $0.00

Note: When using recursive loops inside of HTML tables, the [[BEGIN]] and [[END]] statements must be encapsulated in HTML comment tags. See above.

Function Name: formatNumber()

Parameter 1: Variable Property Name (required)

Parameter 2: Number places after the ones place (required) – Typically number of places after the decimal.

Parameter 3: Delimiter character between the ones and the tenths place (required).

Parameter 4: Delimiter character between each 1000x magnitude (required).

Parameter 5: $_num – This lets the template service keep track of the iteration number.

Parameter 6: Variable Name (required).

Example Loan Payment Schedule:

<table><tbody>
<tr>
<th>Period</th>
<th>Payment Amount</th>
<th>Payment Date</th>
<th>Principal Remaining</th>
</tr>
<!–[[BEGIN scheduled-payments]]–>
<tr>
<td>[[period]]</td>
<td>$[[formatNumber('amount', '2', '.', ',', $_num, 'scheduled-payments')]]</td>
<td>[[companyFormatDateTime('date', ", $_num, 'scheduled-payments')]]</td>
<td>$[[formatNumber('principal-balance', '2', '.', ',', $_num, 'scheduled-payments')]]</td>
</tr>
<!–[[END]]–>
</tbody></table>

This example will iterate the scheduled payments on the loan from the loan transactions report, and will display a list of payment due dates and amounts. The example above would output something similar to the following formatted inside of a table using HTML:

Scheduled Payments:

Period Payment Amount Payment Date Principal Remaining

1 $439.58 10/01/2015 $4,602.09
2 $439.58 11/01/2015 $4,200.86
3 $439.58 12/01/2015 $3,796.29
4 $439.58 01/01/2016 $3,388.35
5 $439.58 02/01/2016 $2,977.01
6 $439.58 03/01/2016 $2,562.24
7 $439.58 04/01/2016 $2,144.01
8 $439.58 05/01/2016 $1,722.30
9 $439.58 06/01/2016 $1,297.07
10 $439.58 07/01/2016 $868.30
11 $439.58 08/01/2016 $435.96
12 $439.58 09/01/2016 $0.00

Note: When using recursive loops inside of HTML tables, the [[BEGIN]] and [[END]] statements must be encapsulated in HTML comment tags. See above.


How did we do?


Powered by HelpDocs (opens in a new tab)