Skip to content

Customizing Templates

The invoice template is the model based on which the PDF copy of an invoice is rendered. It defines its contents and layout. The produced PDF document is intended to be distributed via email or postal service to customers, and it can be exported and archived. JustOn provides a default template, based on which you can define your own templates.

For details about the template fields (its building blocks and the corresponding contents) see Default Template.

Customizing templates according to your needs usually comprises the following tasks:

Depending on your custom requirements, additional tasks can involve:

Template Concepts

Template Structure

The template is composed of a number of pre-defined containers that represent specific areas of the page - the header, footer, the invoice line item table, etc. Each container comprises text blocks that define the actual content displayed in the final document. For example, the header container contains text blocks for including addresses for sender and recipient, a company logo, and other invoice details.

Text blocks can include placeholders. These are symbols for fields of Salesforce or JustOn objects (like address fields or payment data), which are to be replaced with actual values upon PDF rendering.

For details about the template structure, building blocks, etc., see Default Template.

When creating a PDF copy of an invoice, JustOn executes the following internal steps:

  • JustOn produces an intermediate HTML document based on the invoice template and using the data provided by the actual invoice.
  • The HTML document is then converted into a PDF using standard Force.com functionality.

The template defines the structure and layout of the intermediary HTML document. That is, when customizing the template, you actually edit a HTML document.

Template Variation

Usually, you have multiple templates that each serve a specific target. There are, basically, two ways to diversify templates:

  • creating multiple templates for different targets, for example, different locales or specific customer groups
  • using template details to customize specific parts for different purposes, for example, invoice, credit, cancellation.

Info

You can combine the two approaches.

Template details are a means to override specific fields of a template in order to cover specific use cases. By default, JustOn ships template details for credits, cancellations and dunning reminders. These template details overwrite certain fields of the default template depending on the object (Invoice or Dunning) and the object type (Credit or Cancellation in case of invoices).

For information about using template details, see Configuring Template Details.

Note

If there is no specific template detail available for a certain use case, like dunning, for example, JustOn uses the information as defined in the corresponding invoice template, including the defined text blocks, the counter, etc.

Template Assignment

When setting up a Subscription, Opportunity or any other object for billing, you must specify a standard template for that object. This template is then assigned by default to all invoices created from that object. As long as an invoice has the status Draft, you can assign another template to the invoice.

Creating New Template

Info

JustOn recommends to create one or more custom templates and to leave the default template untouched.

To cover multiple targets, like different locales or specific customer groups, you need to create new templates. To do so:

  1. Open the Templates tab.
  2. Click New.
  3. Specify at least the template name and the template language.

    You can edit the other information later as required.

  4. Click Save.

    This generates the new template, copying the contents of the default template.

Info

Alternatively, you can also clone an existing template.

Populating Required Template Fields

Usually, your organization has defined a layout model for printed documents. When customizing a template, you must provide information to fields (text blocks) that are empty by default in order to comply with your organization's design specifications. Common header and footer fields to be populated with your custom information include

  • Header
  • Sender Address
  • Footer

For an overview of other fields that are to be filled, their placement etc., see Template Structure and Building Blocks.

To edit header and footer:

  1. Open the template to be edited.
  2. In the Header & Footer section, double-click the Header, Sender Address or Footer field and specify the information as required.

    Alternatively, you can click Edit in the detail view and edit all fields at once.

  3. Click Save.

Info

Template text blocks can contain

  • plain text
  • placeholders
  • HTML code for tables, lists, links, etc.

If you use HTML code in template text blocks, make sure to write all code in a single line to avoid line breaks being converted to <br/> tags.

Specifying Counter

Invoices, credits, cancellations and dunnings must have unique numbers to comply with legal regulations. In Draft status, these numbers are temporary and of no legal relevance. When setting them to Open, however, JustOn creates the unique and unalterable numbers for invoices, credits, cancellations and dunnings based on defined counters. For details, see Counters and Number Ranges.

Customizing templates therefore involves specifying the counter to be used. To do so:

  1. Open the template to be edited.
  2. In the Information section, double-click the Counter field and specify the counter as required.

    Alternatively, you can click Edit in the detail view to edit the field.

  3. Click Save.

Editing Standard Text Blocks

In the main content area, the template includes three generic text blocks that you can use for any running text to be rendered in the final document.

  • Text 1: Text to be rendered above the invoice line item table, can be used, for example, to edit a letter-like text introducing the invoice that follows.
  • Text 2: Text to be rendered below the invoice line item table, can be used, for example, to add payment terms.
  • Text 3: Additional text to be rendered below the Text 2 block.

To edit the generic text blocks:

  1. Open the template to be edited.
  2. In the Texts section, double-click the Text 1, Text 2 or Text 3 field and specify the information as required.

    Alternatively, you can click Edit in the detail view and edit all fields at once.

  3. Click Save.

Info

Template text blocks can contain

  • plain text
  • placeholders
  • HTML code for tables, lists, links, etc.

If you use HTML code in template text blocks, make sure to write all code in a single line to avoid line breaks being converted to <br/> tags.

Adjusting Invoice Line Item Table

The Table Columns field determines the contents of the line item table on the printed invoice. This field contains a list of invoice line item fields, separated by semicolon, which determines the visible table columns and their sequence. If the Table Columns field is left blank, JustOn defaults to the following setting:

PosNo;Title__c+Description__c;UnitPriceCalc__c;Quantity__c+Unit__c;TaxRate__c;PosTotalNet__c

This produces the following invoice line item information:

  • Position number
  • Item title and description
  • Calculated item price (the unit price multiplied with the commission, if defined)
  • Item quantity
  • Tax rate
  • Item net total

Depending on your organization's requirements, you must remove columns you do not need or add new columns. To do so:

  1. Open the template to be edited.
  2. In the Information section, double-click the Table Columns field and specify the information as required.
  3. Click Save.

Info

You can use any invoice line item field. Note that the specified order defines the column sequence.

To remove, for example, the item description, quantity unit and tax rate and to show the billing factor and an applicable item discount, type the following line in the Table Columns field:

PosNo;Title__c;UnitPriceNet__c;Quantity__c;BillingFactor__c;Discount__c;PosTotalNet__c

Adjusting Invoice Formatting

The invoice template defines display formats for date and time display as well as currency and number display.

Field Description
Use Unicode Font (checkbox) Specifies whether to use the font Arial Unicode for the text rendering. This allows for printing virtually any character of any language, but impedes bold and italic text formatting.
Date Format Specifies the format for all date fields of the invoice.
Month Format Specifies the format for the [LastMonth], [CurrentMonth] and [NextMonth] placeholders.
Time Format Specifies the format for displaying time values.
Leading Currency (checkbox) Controls whether the currency sign (like $ or €) is displayed before (checked) or after (unchecked) the value.
Decimal Separator Specifies the decimal separator for all number fields like currency values or percentage values.
Grouping Separator Specifies the grouping separator for all number fields like currency values.

Note

Selecting or changing the template language does not modify the (region-specific) formatting settings.

Depending on your organization's localization requirements, you must adjust the display of date, time, currency or number values. To do so:

  1. Open the template to be edited.
  2. Click Edit.
  3. In the Formatting section, modify the fields as required.
  4. Click Save.

Info

For details about supported date and time formats, refer to the Simple Date Format syntax in the Java Documentation.

Info

If you send email with non-Latin data, like the Euro symbol, Hebrew, Chinese, Japanese, Russian, etc., set your email encoding to Unicode (UTF-8). For details, see Why do emails contain garbage characters?.

Usually, your organization has defined a layout model for printed documents. As this model most certainly includes a company logo, you have to add an image file and configure its display when customizing your template.

Info

When attaching an image file as your organization's logo, consider that the recommended file format is PNG and that the file size should not exceed 30 kB in order to keep the resulting PDF file size manageable.

Attaching Image

You can add image files as attachments to your template.

  1. Open the template to be edited.
  2. In the Notes & Attachments section, click Attach File.
  3. Select the intended file using using your browser's file selection dialog.
  4. Click Attach File.
  5. Click Done.

    This completes the image upload operation and returns you to the previous page.

Note

Make sure that files are not set to be uploaded as Salesforce Files.

To verify this, open the General Settings page for Salesforce Files. The checkbox Files uploaded to the Attachments related list on records are uploaded as Salesforce Files, not as attachments must not be selected. See also How to display the Attach File button in Notes & Attachments?.

Handling Multiple Images

You can add multiple image files as attachments to your template. There are two ways to specify the image attachment to be used as the company logo:

  • Add the description text logo to the image attachment that you want to use as your company logo. If there is none of the attached images marked as logo this way, JustOn does not print a logo to the invoice PDF.
  • Use the placeholder [img|byid:<ATTACHMENTID>] in the header text (see Populating Required Template Fields). Replace <ATTACHMENTID> with the Salesforce record ID of the attached image file.

    Using this placeholder allows for including other image file attachments in other text fields, if necessary.

Configuring Image Display

Generally, the layout, styling, positioning of the template building blocks is controlled using CSS, see CSS Rules.

By default, the company logo is rendered unscaled on top of the page and aligned with the left margin. Depending on your organization's requirements, you must adjust the image display, like changing the display size or aligning the image with the right margin.

To adjust the image display, you have to provide custom CSS rules. To do so:

  1. Open the template to be edited.
  2. In the Layout & Design section, double-click the Custom CSS field and specify the CSS code as required.

    Following the mentioned examples, you can use this CSS to resize the image:

    • Using a percentage value:
      .logo {width: 60%}
      
    • Using an absolute value:
      .logo {width: 3cm}
      

    To align the image, you can use this CSS:

    • Aligning the logo with the right margin:
      .c1 .block_0 {
          width: 100%;
          text-align: right;
      }
      
    • Centering the logo:
      .c1 .block_0 {
          width: 100%;
          text-align: center;
      }
      
  3. Click Save.

Configuring Overrides

Depending on your organization's requirements, you must modify some labels or the number of decimal places that are to be printed on the invoice PDF. To do so, you configure override labels and decimal places in the corresponding template fields.

Configuring Override Labels

The template field Override Labels allows to define a new label for individual fields. The setting accepts all objects (standard, custom and JustOn objects) and fields. It therefore applies to all placeholder fields as well as fields in the line item table and the transaction table.

The field value is in JSON notation and has the following syntax:

{
  "ObjectApiName" : { "FieldApiName" : "Label" }
}

To define, for example, new labels for some invoice line item and invoice fields, use:

{
    "InvoiceLineItem__c": {
        "Title__c": "Product Name",
        "UnitPriceNet__c": "Price"
    },
    "Invoice__c": {
        "GrandTotal__c": "Invoice Total"
    }
}

Some labels do not originate from fields, but can still be changed specifying them as Calculated:

{
    "Calculated": {
        "PosNo": "Position",
        "Subtotal": "Subtotal"
    }
}

Info

Labels are rendered in the language of the current user locale. If the language of the template differs from the user language, you need to override the labels for the fields PageLabel and OfLabel to produce a correctly localized invoice PDF.

The following code illustrates an example for German labels that may be used and must be overridden:

{
    "Calculated": {
        "PosNo" : "Pos.",
        "Subtotal" : "Zwischensumme",
        "PaymentAmount" : "Zahlbetrag",
        "RefundAmount" : "Erstattungsbetrag",
        "Credit" : "Gutschrift",
        "RoundingDifference" : "Rundungsdifferenz",
        "AccountBalance" : "Account-Saldo",
        "BalanceTitle" : "Posten",
        "OpenAmount" : "Offener Betrag",
        "SubTotalNet" : "Zwischensumme (netto)",
        "SubTotalGross" : "Zwischensumme (brutto)",
        "PageLabel" : "Seite",
        "OfLabel" : "von"
   }
}

To configure override labels:

  1. Open the template to be edited.
  2. In the Overrides section, double-click the Override Labels field and specify the override definition in JSON as required.

    Alternatively, you can click Edit in the detail view to edit the field.

  3. Click Save.

Configuring Decimal Places

The template field Decimal Places is the most relevant setting to control the number of decimal places to be displayed for individual fields. The setting accepts all objects (standard, custom and JustOn objects) and fields. It therefore applies to all placeholder fields as well as fields in the line item table and the transaction table.

The field value is in JSON notation and has the following syntax:

{
  "ObjectApiName" : { "FieldApiName" : number }
}

To set, for example, the number of displayed decimal places for the price and tax fields of the invoice line item to 2 and for the invoice total to 4, use:

{
    "InvoiceLineItem__c": {
        "TaxRate__c": 2,
        "UnitPriceNet__c": 2,
        "Quantity__c": 2,
        "PosTotalNet__c": 2
    },
    "Invoice__c": {
        "GrandTotal__c": 4
    }
}

The setting also accepts special fields for calculated values:

{
    "Calculated": {
        "TaxAmount": 2,
        "SubTotalNet": 2,
        "SubTotalGross": 2
    }
}

To configure the number of decimal places:

  1. Open the template to be edited.
  2. In the Overrides section, double-click the Decimal Places field and specify the definition in JSON as required.

    Alternatively, you can click Edit in the detail view to edit the field.

  3. Click Save.

Info

If there is no definition of decimal places in the template, JustOn falls back to the following settings in this order:

(1) Decimal Places for Unit Price and Decimal Places for Quantity on the invoice line item

(2) Decimal Places for Unit Price and Decimal Places for Quantity in the global settings

(3) Global default: two decimal places for all numeric values

Configuring Subtotal Display

Depending on your business requirements, you must display a subtotal after an invoice line item.

Generally, a subtotal section includes a row for the calculated net subtotal, followed by one or more rows for each distinct tax rate. After the last invoice line item, there will be always a subtotal section.

There are two options:

  • Using the checkbox Display Subtotal After on the subscription item or the invoice line item, you can force JustOn to produce a subtotal section after each invoice line item when generating the invoice.
  • You can, however, define a criterion that triggers the subtotal section display, grouping the invoice line items by this criterion at the same time. To do so, use the field Subtotal Criterion on the invoice template: Specify a field of the invoice line item, and each time the contents of the field changes, JustOn produces a subtotal section.

Displaying Grouped Subtotal Section

Subtotal Criterion set to TaxRate__c
Pos Title Unit Price Tax Rate Tax Amount Pos Total Net
1 A 10,00 10% 1,00 10,00
2 B 25,00 10% 2,50 25,00
Subtotal (net) 35,00
Tax (10%) 3,50
3 C 25,00 5% 1,25 25,00
Subtotal (net) 25,00
Tax (5%) 1,25
4 D ... ... ... ...

To set a subtotal criterion:

  1. Open the template to be edited.
  2. In the Line Items section, double-click the Subtotal Criterion field and specify the API name of the invoice line item field you want to use as subtotal criterion.

    Alternatively, you can click Edit in the detail view to edit the field.

  3. Click Save.

Info

You can define a custom formula field on the invoice line item to be used as criterion if you must model complex subtotal criteria.

Displaying Gross Subtotal

You may want to display the gross subtotal, that is, the sum of the net subtotal and the taxes, for each subtotal section.

Subtotal Criteria set to TaxRate__c, including gross subtotal
Pos Title Unit Price Tax Rate Tax Amount Pos Total Net
1 A 10,00 10% 1,00 10,00
2 B 25,00 10% 2,50 25,00
Subtotal (net) 35,00
Tax (10%) 3,50
Subtotal (gross) 38,50
3 C 25,00 5% 1,25 25,00
Subtotal (net) 25,00
Tax (5%) 1,25
Subtotal (gross) 26,25
4 D ... ... ... ...

To enable the gross subtotal display, you add a corresponding CSS rule:

  1. Open the template to be edited.
  2. In the Layout & Design section, double-click the Custom CSS field and specify the following CSS code:

    .invoice-table .subtotal-calculated.gross {
        display: table-row;
    }
    
  3. Click Save.

Overriding Subtotal Labels

Your business may require to customize the labels for the calculated values Subtotal (net) and Subtotal (gross). Depending on your requirements, there are three options to do so:

Modifying Subtotal Custom Labels

You can override the subtotal labels SubTotalGross and SubTotalNet on org level.

Note

To modify custom labels, you must enable the Translation Workbench. For details, see Enable and Disable the Translation Workbench in the Salesforce Help.

  1. In Setup, open the Custom Labels list.

    In Salesforce Lightning, navigate to User Interface > Custom Labels.

    In Salesforce Classic, navigate to Create > Custom Labels.

  2. Click the name of the label you want to modify.

  3. Click New Local Translations/Overrides.
  4. Select the target language and specify the text as required.
  5. Click Save.

    This applies the new labels to all invoices generated in your org.

For additional information, see Custom Labels in the Salesforce Help.

Overriding Subtotal Labels per Template

Assume you want to specify new subtotal labels on a template-specific basis, like, for example, Net Subtotal instead of the default Subtotal (net). To do so:

  1. Open the template to be edited.
  2. In the Overrides section, double-click the Override Labels field and specify the override definition in JSON as required.

    {
        "calculated":{
            "SubTotalNet":"Net Subtotal",
            "SubTotalGross":"Gross Subtotal"
        }
    }
    
  3. Click Save.

    This applies the new labels to all invoices based on the current template.

For additional information, see Configuring Override Labels.

Overriding Individual Subtotal Labels

If you display grouped subtotal sections, you can configure individual overrides for the subtotal labels. To this end, you combine a specific JSON value in the Override Labels field with a specific CSS rule.

Criterion Cause CSS Class Notes
Criterion-based subtotal Criterion is set in the field Subtotal Criterion on the invoice template - each time the contents of the field changes, JustOn produces a subtotal section. .criteria-OLD-NEW OLD and NEW represent the values of the set criterion field, like the tax rate if Subtotal Criteria set to TaxRate__c
To identify the actual CSS classes, use the template debug mode.
Forced subtotal Checkbox Display Subtotal After on the invoice line item is set. .criteria-forced
End of table To be printed after the last invoice line item .criteria-last
  1. Open the template to be edited.
  2. In the Overrides section, double-click the Override Labels field and specify the following JSON code:

    {
        "calculated":{
            "SubTotalNet":"",
            "SubTotalGross":""
        }
    }
    
  3. Click Save.

  4. In the Layout & Design section, double-click the Custom CSS field and specify the CSS code as required.

    Depending on your use case, set .criteria-OLD-NEW, .criteria-forced or .criteria-last. For content, specify the intended label.

    .subtotal-calculated.net.criteria-19_000-0_000 .label:after {
        content: "replaced net label for criteria change from 19% tax to 0% tax";
    }
    .subtotal-calculated.gross.criteria-19_000-0_000 .label:after {
        content: "replaced gross label for criteria change from 19% tax to 0% tax";
    }
    
  5. Click Save.

    This applies the new labels to the corresponding subtotal sections.

Controlling Subtotal Tax and Subtotal Order Discount Display

By default, JustOn includes the tax information and order discount information in each subtotal section. Depending on your business requirements, however, you can configure JustOn to print a summary of this information for the entire invoice instead of displaying it separately in each subtotal section.

To this end, use the following template fields:

Field Description Default Value
No Subtotal Tax (checkbox) If selected, disables the display of the subtotal tax for each individual subtotal section and prints a tax summary for the entire invoice. false
No Subtotal Discount (checkbox) If selected, disables the display of the subtotal order discount for each individual subtotal section and prints an order discount summary for the entire invoice. false

To configure the subtotal tax display:

  1. Open the template to be edited.
  2. Click Edit in the detail view.
  3. In the Line Items section, select or deselect the checkbox No Subtotal Tax.
  4. Click Save.

To configure the subtotal order discount display:

  1. Open the template to be edited.
  2. Click Edit in the detail view.
  3. In the Line Items section, select or deselect the checkbox No Subtotal Discount.
  4. Click Save.

Displaying Total Net or Total Tax

Your business may require to display the invoice total net or invoice total tax above the grand total. To enable the total net and total tax display, you add a corresponding CSS rule:

  1. Open the template to be edited.
  2. In the Layout & Design section, double-click the Custom CSS field and specify the following CSS code:

    .invoice-table tr.totalNet,
    .invoice-table tr.totalTax {
        display: table-row;
    }
    
  3. Click Save.

Grouping Invoice Line Items by Category

Depending on your business requirements, you may need to group related invoice line items and display a corresponding category header. To this end, use the following template fields:

Field Description
Category Criterion Specifies the invoice line item field that is used as the categorization criterion.
Category Label Specifies the text to be printed as the category header. Can contain placeholders like [ProductGroup] to allow for a category-specific distinction.

When using the category criterion and category label, be aware of the following characteristics:

  • The category header is displayed for each group of invoice line items.
  • If a group of invoice line items is distributed over several subtotal sections, the header is also shown above the first invoice line item after a subtotal section.
  • JustOn does not sort the invoice line items according to the groups. To actually merge invoice line items of one group into one category section on the invoice, you can use the Sequence field.
  • If the Category Label contains a placeholder that refers to a line item field, it refers to the first line item below the header.
  • If the invoice line item field as specified by Category Criterion is empty for the first invoice line item of a group or after a subtotal section, then the category header is not displayed.
Category Criterion set to ProductGroup__c and Category Label set to Group [ProductGroup]
Pos Title Unit Price Tax Rate Tax Amount Pos Total Net
Group G1
1 A 10,00 10% 1,00 10,00
2 B 25,00 10% 2,50 25,00
Group G2
3 C 25,00 10% 2,50 25,00
4 D ... ... ... ...

To configure the invoice line item group display:

  1. Open the template to be edited.
  2. In the Line Items section, double-click the Category Criterion field and specify the API name of the invoice line item field you want to use as category criterion.

    Alternatively, you can click Edit in the detail view to edit the field.

  3. Double-click the Category Label field and specify the text to be printed as the category header.

    The label can contain placeholders like [ProductGroup].

    Alternatively, you can click Edit in the detail view to edit the field.

  4. Click Save.

Info

You can define custom formula fields on the invoice line item to be used as criterion and label if you must model complex category criteria.

Using CSS to Control Output

Certain use cases require multiple templates with only small differences. Multiple templates, however, may become difficult to maintain. This section illustrates some example requirements and shows how to cover them with a single template.

Available Style Classes

JustOn supports specific CSS classes that allow for applying some custom styling to the contents of certain invoice or dunning fields.

CSS classes in the body element of the invoice PDF
Considered Invoice Field Available CSS Classes Notes
Class class-Invoice
class-Credit
Type type-Installment
no-type
Email Invoice is-email-invoice
no-email-invoice
Print Invoice is-print-invoice
no-print-invoice
Tenant tenant-<Company_Name>
no-tenant
The tenant class name is composed of tenant- and the name of the tenant, where the allowed characters include a–z, A–Z, 0–9, and underscore (_). That is, you must replace dots, commas or spaces with underscores, and special characters with their nearest ASCII neighbor.
CSS classes in the body element of the dunning PDF
Considered Dunning Field Available CSS Classes Notes
Level level-1
Email Dunning is-email-dunning
no-email-dunning
Print Dunning is-print-dunning
no-print-dunning
Tenant tenant-<Company_Name>
no-tenant
The tenant class name is composed of tenant- and the name of the tenant, where the allowed characters include a–z, A–Z, 0–9, and underscore (_). That is, you must replace dots, commas or spaces with underscores, and special characters with their nearest ASCII neighbor.

You can define the field AdditionalStyleClass on the invoice or dunning. Its content will be normalized and added as an additional style class to the body element. Use this field to consider the values of further invoice or dunning fields to be styled using CSS.

Depending on your business, you may decide on a per customer basis whether to email PDF documents or to post hard copies. To this end, you can mark invoices using the Email Invoice or Print Invoice checkboxes.

Now assume that you print invoices or statements on your company stationery, which already includes all relevant company information and design elements. In this case, you hide the header, footer and logo.

  1. Open the template to be edited.
  2. In the Layout & Design section, double-click the Custom CSS field and specify the following CSS code:

    .is-print-invoice .page-footer, .is-print-invoice .page-header, .is-print-invoice .header, .is-print-invoice .logo {
        display: none;
    }
    
  3. Click Save.

    This suppresses the header, footer and logo if the invoice is marked as Print Invoice.

If you work with tenants, you can apply individual company information for them. The following example assumes that you want to use tenant-specific logos and footers, whereas the other information (like invoice texts and table configurations) remain the same. Implementing this example involves three steps:

Adding Tenant-Specific Logos

You can add the two logos using the image-by-ID mechanism (as mentioned in Handling Multiple Images) to a text building block like Header or Info Left.

Info

Following the example, the images are moved using the position CSS declaration, so you can use any generic text container to hold the image references.

Assuming the image IDs are ONE and TWO, use the following placeholders to declare the logos:

[img|byid:ONE][img|byid:TWO]
  1. Open the template to be edited.
  2. In the Header & Footer section, double-click, for example, the Header field and add the placeholders as required.

    Alternatively, you can click Edit in the detail view to edit the field.

  3. Click Save.

Adding Tenant-Specific Footers

Now you add two footers to the Footer field. To allow them for being addressed individually, you wrap them in addressable DIV elements, like

<div class="footer-ONE">Tenant ONE</div>
<div class="footer-TWO">Tenant TWO</div>
  1. Open the template to be edited.
  2. In the Header & Footer section, double-click the Footer field and add the footer texts as required.

    Alternatively, you can click Edit in the detail view to edit the field.

  3. Click Save.

Finally, you hide the logos and footers by default and enable them based on the tenant (named FIRST and SECOND following the example). These custom CSS rules do the job:

#ONE, #TWO {
    position: absolute;
    left:0;
    top:0;
    display: none;
}

.footer-ONE, .footer-TWO {
    display: none;
}

.tenant-FIRST #ONE, .tenant-FIRST .footer-ONE {
    display: block;
}

.tenant-SECOND #TWO, .tenant-SECOND .footer-TWO {
    display: block;
}
  1. Open the template to be edited.
  2. In the Layout & Design section, double-click the Custom CSS field and specify the CSS code as required.

    Alternatively, you can click Edit in the detail view to edit the field.

  3. Click Save.

Displaying Transaction Records on Invoices

You can configure JustOn to print a table of transaction records on an invoice. To this end, provide a corresponding configuration (in JSON notation) in the template field Transaction Records.

  1. Open the template to be edited.
  2. In the Additional Content section, double-click the Transaction Records field and specify the transaction table configuration as required.

    Alternatively, you can click Edit in the detail view to edit the field.

  3. Click Save.

Note

Make sure that the checkbox fields

  • ON_AddToTransactionTable on the source object (see Controlling Fields) and
  • DisplayTransactionTables on the invoice

are selected.

Configuration Options

The following configuration records are possible:

Keyword Data Type Possible Values Description
active Boolean true or false Activates the current configuration record.
title string The text to be printed above the transaction table.
name string object API name Specifies the source object for the transaction records to be displayed.
note that the object needs a lookup relationship to the invoice.
invoiceFieldName string Specifies the field that holds the invoice ID. Optional, required if there are more than one lookup fields.
fields list of strings field names Specifies the columns and their order to be rendered.
JustOn takes the column header from the field labels, and it considers the field types and applies the corresponding number and date formats of the template.
You can use the special field PosNo to display a running number of the records in a separate column.
calculationFields list of strings field names Specifies the fields (columns) whose values are to be added up.
order string Specifies a comma-separated list of fields whose values are to define the sort order of the records (optional).
conditions list of strings Specifies complex conditions (optional). Can be used to restrict the number of printed records, like Quantity > 1000.
Multiple conditions are separated by AND. String values must be enclosed in single quotes.
For more details, see the Force.com SOQL and SOSL Reference in the Salesforce Developer Documentation.
subtotal map: string => list<string> Specifies a map of fields to field lists. Determines that a subtotal is printed when a column (the "field") changes its value. The "field list" specifies the subtotal fields.
Configuration Examples

Show all records of the type Transaction__c that are related to the current invoice:

[{
    "active" : true,
    "title" : "Billed Transactions",
    "name" : "Transaction__c",
    "fields" : [ "Date__c", "ExternalId__c", "Description__c", "Quantity__c" ],
    "calculationFields" : [ "Quantity__c" ],
    "order" : "Type__c, Date__c"
}]

Show all records of the type Transaction__c that have set the type Foo, and hide records of the type Bar:

[{
    "active" : true,
    "title" : "Billed Transactions of type Foo",
    "name" : "Transaction__c",
    "fields" : [ "Date__c", "ExternalId__c", "Description__c", "Quantity__c" ],
    "order" : "Date__c",
    "conditions" : [ "Type__c = 'Foo'" ]
},
{
    "active" : false,
    "title" : "Billed Transactions of type Bar",
    "name" : "Transaction__c",
    "fields" : [ "Date__c", "ExternalId__c", "Description__c", "Quantity__c" ],
    "order" : "Date__c",
    "conditions" : [ "Type__c = 'Bar'" ]
}]

Show all transaction detail records that refer to the invoice via the field ONB2__Transaction__r.ONB2__Invoice__c:

[{
    "active" : true,
    "title" : "Billed Transaction Details",
    "order" : "Date__c",
    "name" : "TransactionDetail__c",
    "fields" : [ "Date__c", "Quantity__c", "Price__c" ],
    "invoiceFieldName" : "Invoice__c"
}]

Display a subtotal after each change of Description__c and Title__c:

[{
    "active" : true,
    "title" : "Billed Transactions",
    "name" : "Transaction__c",
    "fields" : [ "Date__c", "ExternalId__c", "Description__c", "Quantity__c" ],
    "calculationFields" : [ "Quantity__c" ],
    "order" : "Type__c, Date__c",
    "subtotal" : { "Description__c" : ["Quantity__c", "Price__c"],
                   "Title__c" : ["SingleIndividualCount__c"]}
}]

If your business requires to show many columns in the transaction tables, you may need to rotate the corresponding pages of the invoice PDF in order to print landscape. To do so, you add a corresponding CSS rule to the template.

  1. Open the template to be edited.
  2. In the Layout & Design section, double-click the Custom CSS field and specify the following CSS code:

    @page land {
        size: landscape;
    }
    .c9 {
        page: land;
    }
    
  3. Click Save.

Attaching Transaction CSV to Invoices

You can configure JustOn to generate CSV files for transaction records to be attached to invoices. Use this functionality if the transaction tables as printed directly on invoices become too large or if you need the CSV files for a specific purpose.

To generate transaction CSV files, provide a corresponding configuration (in JSON notation) in the template field Transaction CSV.

  1. Open the template to be edited.
  2. In the Additional Content section, double-click the Transaction CSV field and specify the transaction CSV file configuration as required.

    Alternatively, you can click Edit in the detail view to edit the field.

  3. Click Save.

Note

Make sure that the checkbox field ON_AddToCsv on the source object (see Controlling Fields) is selected.

Configuration Options

The following configuration records are possible:

Keyword Data Type Possible Values Description
active Boolean true or false Activates the current configuration record.
name string object API name Specifies the source object for the transaction records to be displayed.
note that the object needs a lookup relationship to the invoice.
title string Part of the CV file name, which is generated as follows InvoiceNo_ObjectName_Title_No.csv.
invoiceFieldName string Specifies the field that holds the invoice ID. Optional, required if there are more than one lookup fields.
order string Specifies a comma-separated list of fields whose values are to define the sort order of the records (optional).
conditions list of strings Specifies complex conditions (optional). Can be used to restrict the number of printed records, like Quantity > 1000.
Multiple conditions are separated by AND. String values must be enclosed in single quotes.
For more details, see the Force.com SOQL and SOSL Reference in the Salesforce Developer Documentation.
config map Specifies a configuration that defines the columns and format of the CSV file. For details, see Defining CSV File JSON Configuration.
The config key must have a rows setting with the following row definitions:
headerRow - A list of column labels to be printed at the start of each CSV file.
recordRow - A list of fields where each row corresponds to a transaction record.
Configuration Example
[{
"active" : true,
"name" : "Transaction__c",
"order" : "Type__c, Date__c",
"invoiceFieldName" : "Invoice__c",
"conditions" : [ ],
"config" : {
             "useASCII" : false,
             "rows" : {
                        "headerRow" : [ "Date", "ExternalId", "Description", "Quantity" ],
                        "recordRow" : [ "Date__c", "ExternalId__c", "Description__c", "Quantity__c" ]
                      },
             "rowOrder" : [ "recordRow" ],
             "options" : {
                           "timeFormat" : "hh:mm a",
                           "language" : "en",
                           "groupingSeparator" : "",
                           "decimalSeparator" : ".",
                           "dateFormat" : "yyyy/MM/dd"
                         },
             "decimalPlaces" : { },
             "columnSeparator" : ","
           }
}]

Configuring Installment Table on Invoices

With an applied installment setting, JustOn automatically prints the payment plan to the invoice PDF. There are two template fields that control the display of the corresponding installment information:

Template Field Description
Installment Columns Defines the columns for the installment table, must be a list of payment field names separated by semicolons. Defaults to Title__c;Date__c;Amount__c.
Installments Text Specifies text to be rendered above the installment table.

To configure the contents of the installment table:

  1. Open the template to be edited.
  2. In the Information section, double-click the Installment Columns field and specify the installment table configuration as required.

    Alternatively, you can click Edit in the detail view to edit the field.

  3. Click Save.

To specify a text that introduces the payment plan:

  1. Open the template to be edited.
  2. In the Additional Content section, double-click the Installment Text field and type the text as required.

    Alternatively, you can click Edit in the detail view to edit the field.

  3. Click Save.

Hiding Deposit Installment on Invoice PDF

When creating installments, JustOn may create a deposit installment that represents the sum of payment balances assigned to the invoice. By default, the deposit payment is the first entry of the payment plan as printed to the invoice PDF. Depending on your requirements, however, you may decide not to show the received payment in the list of payments still to be made.

You can use a custom CSS rule to suppress the deposit payment row in the printed invoice:

  1. Open the template to be edited.
  2. In the Layout & Design section, double-click the Custom CSS field and specify the following CSS code:

    .is-print-invoice .depositInstallmentRow {
        display: none;
    }
    
  3. Click Save.

Configuring Balance Table on Invoices

With an existing invoice balance, JustOn automatically prints the balance to the invoice PDF.

Balance Table Concepts

An invoice balance usually alters the payment amount - this is why the balance records are not printed as a separate table but as part of the invoice table between the invoice grand total and the final payment amount, like illustrated below:

Pos Title Quantity Tax Rate Unit Price Pos Total
1 Product 1 0,00% 25,00 25,00
Subtotal (net) 25,00
Tax (0,00%) 0,00
Grand Total 25,00
Prepayment 2017-03-02 -10,00
Payment Amount 15,00

There are two template fields that control the display of the corresponding balance information:

Template Field Description
Balance Columns Defines the columns for the balance table. The definition must be a list of balance field API names separated by semicolons. If BalanceTitle is used, the column will display the text defined in the field Balance Types.
The default definition is BalanceTitle;Date__c;Amount__c
Balance Types Specifies a mapping (in JSON notation) of the values defined in the Type field of the Balance object to some display text (which can include placeholders).
Types that are not specified in the mapping are not displayed on the invoice.

The default balance type mapping is

[ {
"type" : "Payment",
"title" : "Payment"
}, {
"type" : "Refund",
"title" : "Refund"
}, {
"type" : "Prepayment",
"title" : "Prepayment"
}, {
"type" : "Payout",
"title" : "Payout"
}, {
"type" : "Clearing",
"title" : "Clearing"
}, {
"type" : "Settlement",
"title" : "Settlement for Invoice [RelatedInvoiceNo]"
}, {
"type" : "Dunning Fee",
"title" : "Dunning Fee"
} ]

Modifying Balance Table Columns

Depending on your organization's requirements, you must add or remove columns or change their sequence.

  1. Open the template to be edited.
  2. In the Information section, double-click the Balance Columns field and specify the balance column configuration as required.

    Alternatively, you can click Edit in the detail view to edit the field.

  3. Click Save.

Info

You can use any balance field. Note that the specified order defines the column sequence.

Modifying Balance Type Display

You can configure which balance types are to be displayed in the balance table and modify their display names.

  1. Open the template to be edited.
  2. In the Information section, double-click the Balance Types field and specify the balance type configuration as required.

    Alternatively, you can click Edit in the detail view to edit the field.

  3. Click Save.

Hiding Balance Table

Depending on your business requirements, you may need to prevent the balance table from being printed. There are two ways to hide the balance table:

  • emptying the Balance Types field,
  • using a custom CSS rule.

Hiding Balance Table Clearing Balance Types

You can prevent the balance table from being printed, clearing the field contents. This takes advantage of the fact that balance types that are not specified in the Balance Types field are not displayed on the invoice.

  1. Open the template to be edited.
  2. In the Information section, double-click the Balance Types field and clear its contents.

    Alternatively, you can click Edit in the detail view to edit the field.

  3. Click Save.

Hiding Balance Table Using CSS

Alternatively, you can apply a custom CSS rule that hides the balance table:

  1. Open the template to be edited.
  2. In the Layout & Design section, double-click the Custom CSS field and specify the following CSS code:

    tr.balances {
        display: none;
    }
    
  3. Click Save.

Displaying Tax Breakdown Table

If multiple taxes are applied, JustOn can print the tax breakdown table on the invoice PDF. This table contains one line for each applied tax rule. The amount is the sum of all taxes of the same rule. The table is sorted first by the tax type and then by the applied tax rule.

To configure the tax breakdown table display in the invoice template, use the following fields:

Field Description Default Value
Tax Table Checkbox to enable or disable the tax table display on the invoice
Tax Table Text An introductory text for the tax table The composition of the taxes is presented on the following table.
Tax Table Columns Defines the tax detail fields (API names) to be displayed as columns in the tax table, separated by semicolon.
To display the local currency, add LocalAmount.
Name;AppliedTaxRule__c;Rate__c;Amount__c

Before using the tax breakdown table, you may have to add the corresponding fields to the template layout:

  1. Navigate to the object management settings of the Template object.
  2. Click Page Layouts.
  3. In the row of Template Layout, click Edit.
  4. Drag the fields Tax Table, Tax Table Columns and Tax Table Text to the Line Items section.
  5. Click Save to save the modified page layout.

For help about modifying page layouts, see Managing Pages.

To configure the tax table display:

  1. Open the template to be edited.
  2. Click Edit in the detail view.
  3. Modify the values for Tax Table, Tax Table Text and Tax Table Columns as required.
  4. Click Save.

Configuring Payment Reference Text

Depending on your organization's requirements, you specify a string that is to be written as the payment reference for SEPA payments. To do so, you configure the template field Payment Reference.

  1. Open the template to be edited.
  2. In the Payment Information section, double-click the Payment Reference field and modify the information as required.

    Modify the default value [InvoiceNo] - [InvoiceDate] as necessary.

  3. Click Save.

Info

You can use the placeholders that are available for the invoice context.

Configuring Reverse Charge Notice Text

You can configure JustOn to display a reverse charge notice for invoices to be sent to buyers in specific countries.

The invoice template includes a specific text block for the reverse charge information.

Info

Whether the text is displayed or not depends on the setting of the corresponding controlling field on the invoice.

To configure this text:

  1. Open the template to be edited.
  2. In the Texts section, double-click the Reverse Charge Text field and specify the information as required.

    Alternatively, you can click Edit in the detail view to edit the field.

  3. Click Save.

Info

Template text blocks can contain

  • plain text
  • placeholders
  • HTML code for tables, lists, links, etc.

If you use HTML code in template text blocks, make sure to write all code in a single line to avoid line breaks being converted to <br/> tags.

Displaying Outstanding Invoices

Depending on your business requirements, you can have JustOn print a table of outstanding invoices on an invoice PDF. This table lists other open invoices of the corresponding account.

To configure the outstanding invoices table display in the invoice template, use the following fields:

Field Description Default Value
Outstanding Invoices Checkbox to enable or disable the outstanding invoices table display on the invoice.
Outstanding Invoices Text Specifies the text to be printed above the table of outstanding invoices. For your information, below is a list of outstanding invoices that are either unpaid, partially paid or overpaid.

To configure the outstanding invoices table display:

  1. Open the template to be edited.
  2. Click Edit in the detail view.
  3. In the Additional Content section, select or deselect the checkbox Outstanding Invoices modify the value for Outstanding Invoices Text as required.
  4. Click Save.

Accessing Template Debug Mode

The layout, styling, positioning of the template building blocks is controlled using CSS rules. JustOn defines a default set of CSS rules (see CSS Rules).

To identify the class for an element that you want to override using custom CSS, you can proceed as follows:

  1. Open the detail view of the corresponding record (invoice, dunning reminder or account statement).

    A standard URL of an invoice, for example, may look like

    https://<server>/apex/InvoiceView?id=<id>&sfdc.override=1 (Classic UI) or

    https://<server>/lightning/r/ONB2__Invoice__c/<id>/view (Lightning UI)

  2. Modify the URL as follows, then press Enter.

    1. For Classic, replace the InvoiceView or DunningView directive with InvoicePDF or DunningPDF, respectively, and append the query string &debug=true like:

      https://<server>/apex/InvoicePDF?id=<id>&sfdc.override=1&debug=true
      
    2. For Lightning, replace the complete path with apex/ONB2__InvoicePDF?id=<id> or, respectively, apex/ONB2__DunningPDF?id=<id> for dunning reminders or account statements, and append the query string &debug=true like:

      https://<server>/apex/ONB2__InvoicePDF?id=<id>&debug=true
      

    If required, you can also add a language query string, like &lang=en, for example

    https://<server>/apex/ONB2__InvoicePDF?id=<id>&debug=true&lang=en
    

    This opens the intermediate HTML file, which you can now inspect using your tool of choice.

Info

For further help with template customization, contact the JustOn support team.