SmartPay > Receipt Templates

Receipt Templates can be customised, using a "Mail Merge" syntax, where merge fields are denoted by curly-brackets - e.g. {Ref1}.

NB - There will NEVER be spaces in the merge field name - so it is "{Ref1}" not "{Ref 1}".

The drop-down list in the Template Edit screen shows available fields for common system objects - e.g. Payment and Payment Line.

The main "in-scope" object for a receipt is a Payment.

Template Targeting

Templates are selected by Code, and can be targeted by Payment Type and Fund.

The "Default" template will be used - as the name implies - by default, so you should edit that first to be your standard "base" template.

You can then override the default for particular Funds or Payment Types.

So if you want to override the "Default" template for a general receipt, you need create a new Template with the same Code ("RECEIPT") and then select the Payment Types and/ or Funds you want to target.

When adding a new template, the "Defaults..." drop-down at the bottom left of the screen allows you to easily base your new template on an existing one, and sets the correct code. You then need to check the Payment Types and/ or Funds you are targeting, and make the text changes you require.

When selecting a receipt, the system will check for a match in the following order:

  1. Payment Type + Fund(s)*
  2. No Payment Type + Fund(s)*
  3. Payment Type + No Funds
  4. Default

*All funds must match

NB - If you leave all Payment Types and Funds unchecked, the system will fall back to the "Default" Template not your edit.

Payment Lines

You can iterate through Payment Lines with a {@Payment.Lines} block. In this block, the main in-scope object is a Payment Line

˂table˃
	˂tr˃
		˂th˃Payment Type˂/th˃
		˂th˃Your Reference˂/th˃
		˂th˃VAT˂/th˃
		˂th˃Amount˂/th˃
	˂/tr˃
	{@Payment.Lines}
		˂tr˃
			˂td˃{FundName}˂/td˃
			˂td˃{Ref1}˂/td˃
			˂td˃{VAT}˂/td˃
			˂td˃{Amount}˂/td˃
		˂/tr˃
	{/@}
	˂tr˃
		˂td colspan="3"˃TOTAL˂/td˃
		˂td˃{Total}˂/td˃
	˂/tr˃
˂/table˃

VAT Lines

You can iterate through "rolled-up" VAT Lines, using a VATLines block.

˂table˃
	˂tr˃
		˂th˃VAT Code˂/td˃
		˂th˃VAT Rate˂/td˃
		˂th˃Net˂/td˃
		˂th˃VAT˂/td˃
		˂th˃Amount˂/td˃
	˂/tr˃
	{@Payment.VATLines}
		˂tr˃
			˂td˃{VATCode}˂/td˃
			˂td˃{VATRate}˂/td˃
			˂td˃{Net}˂/td˃
			˂td˃{VAT}˂/td˃
			˂td˃{Amount}˂/td˃
		˂/tr˃
	{/@}
	˂tr˃
		˂td colspan=""2""˃Totals˂/td˃
		˂td˃{Net}˂/td˃
		˂td˃{VAT}˂/td˃
		˂td˃{Total}˂/td˃
	˂/tr˃
˂/table˃

Images

To use an image as part of a template, go to Templates -˃ Images and add a new image.

Your image will then appear in the Images list when editing a template - simply select the image to copy the required HTML code to the clipboard, which you can then paste into your template.

Paper Sizes

You can target non-standard paper sizes, by adding the following html attributes somewhere in your template: -pdf-margin, -pdf-width, -pdf-height. These attributes can be added to any html tag, anywhere in your document.

˂div -pdf-width='210mm' -pdf-height='297mm' -pdf-margin='20mm'˃

Format Strings

Standard .NET format strings can be applied in the merge field, using the syntax {FIELD:FORMAT}.

For example:

{PaymentDate:dd MMMM yyyy}

Google .net format strings for more info!

NB - Amounts are stored in SmartPay in pennies, with a data type of 'long', but are special-cased in the merge process.

Evaluated Expressions

It is possible to use evaluated expressions on text, dates and numeric fields - these are C# expressions, with access to a limited "safe" subset of built-in libraries.

The syntax for an Evaluated Expression is {=...=}.

For example, to add 10.00 to the {Total} value:

{= {Total} + 10.00 =}

(No... we've no idea why you'd want to do that either, but...)

To print today's date:

{= DateTime.Now =}

To print just the 3 left-most characters of the Payment Reference:

{= Text.Left('{PaymentReference}', 3) =}

NB - The merge is processed BEFORE the evaluation, so you need quotes around the text string value {PaymentReference}.

Text Expressions

  • Text.AddressLine (address, line)
  • Text.Ellipses (text, length)
  • Text.FirstName (name)
  • Text.LastName (name)
  • Text.Left (text, length)
  • Text.Left (text, split)
  • Text.Mid (text, split)
  • Text.Mid (text, start)
  • Text.Mid (text, start, length)
  • Text.Postcode (address, format)
  • Text.Replace (text, oldValue, newValue, caseSensitive)
  • Text.Replace (text, parameters)
  • Text.Reverse (text)
  • Text.Right (text, length)
  • Text.Right (text, split)
  • Text.StripPunctuation (text)
  • Text.StripWhiteSpace (text)
  • Text.ToDigits (text)
  • Text.ToDisplayText (text)
  • Text.ToSingleLine (text)
  • Text.ToTitleCase (text)
  • Text.TrimChars (text, chars)
  • Text.TrimEnd (text, trim)
  • Text.TrimEnd (text, length)
  • Text.TrimStart (text, trim)
  • Text.TrimTo (text, value)
  • Text.TryMatch (text, pattern, index)
Last Updated on 29 Mar 2021 by Syd Egan
© Adelante Software Ltd 2024