action.skip

Setting Up Invoice Management Options

Invoices in JustOn

Invoices are the statements that document your payment requests against your customers, relating to a sale transaction and indicating the involved products and prices.

For every generated invoice and its invoice line items, JustOn stores records in the database of the Salesforce Platform. These records are the single source of truth – they hold all legally relevant information. See the PDF files, which are produced by default, merely as readable images of this data.

JustOn allows for a number of options and advanced features with respect to managing invoices and invoice line items.

Invoice Creation and Management Invoice Data Invoice Distribution Accounting-Relevant Options Automation Options

Invoice Creation and Management Options

Disabling Manual Invoice Status Modification

Invoices are supposed to be finalized using the Finalize functionality. Finalizing invoices sets them to Open, sets a unique final invoice number, and generates the PDF documents to be sent out.

To prevent users from accidentally (or incorrectly) changing the invoice status manually, you set the Status field to Read-Only.

  1. Navigate to the object management settings of the Invoice object.
  2. Click Page Layouts.
  3. In the Invoice Layout row, click Edit.
  4. Click next to the Status field to open the field properties.
  5. Select the Read-Only checkbox.
  6. Click OK to save the field properties.
  7. Click Save to save the modified page layout.

    For help about modifying page layouts, see Managing Pages.

Enabling Gross Invoicing

Depending on your business or legal requirements, the nature of your products, etc., you must create net invoices, gross invoices or both of them. This behavior is controlled using the specific checkbox field GrossInvoice__c on the invoice line item.

You can set the checkbox individually on each invoice line item. This allows to specify whether to generate net invoices, gross invoices or mixed net/gross invoices.

If the checkbox is selected (the value set true), the unit prices of the invoice line items are considered gross prices. That is, JustOn Billing & Invoice Management deducts any applicable taxes from the unit prices.

  1. Navigate to the fields list of the Invoice Line Item object.
  2. Create the following new field.

    API Name Data Type Description
    GrossInvoice Checkbox If selected (the value set true) for an invoice line item, the unit price is considered a gross prices, and any applicable taxes are deducted.

    For help about creating fields, see Managing Object Fields.

Info

Use the ON field mechanism, Salesforce flows or other automation tools to have this checkbox set automatically when generating invoices and invoice line items. When doing so, make sure to use the correct API name GrossInvoice__c.

Enabling Invoice Rounding

Some countries, like Switzerland or Sweden, have removed low-denomination coins from circulation. In these countries, payable amounts are rounded to the nearest multiple of the minimum currency unit available – either for cash transactions only, or for both cash and electronic transfers.

Invoice Rounding Implementation

If your business requires invoice rounding, you can define rounding rules for a currency using the custom setting Currency Mapping.

Each record can hold the following information:

Field Data Type Description
Name Text (3) Specifies the ISO currency code.
Currency Sign Text (5) Specifies the currency symbol.
Activate Rounding Checkbox Controls whether the grand total of invoices in this currency is to be rounded.
Rounding Method Text (128) The method used for rounding the grand total of invoices. Available values include NONE, FLOOR, CEILING, DOWN, UP, HALF_DOWN, HALF_UP, HALF_DOWN_ZERO, HALF_UP_ZERO, HALF_EVEN.
The default rounding method is NONE.
For details, see, for example, RoundingMode.
Rounding Precision Number (13,5) Controls the precision for the rounding difference.
0.05 rounds to 5 cents, 1.00 rounds to whole euros.
Example configuration for Swiss currency rounding

In Switzerland, invoice amounts are rounded to 0,05 francs according to the following common rounding rules:

1,0001,0241,00
1,0251,0741,05
1,0751,0991,10

That is, to support the invoice rounding for Switzerland, you need the following currency mapping setting:

Field Value Description
Name CHF The ISO currency code for Swiss francs.
Currency Sign SFr. The currency symbol for Swiss francs.
Active Rounding Activates the invoice rounding.
Rounding Method HALF_UP Rounds towards the nearest neighbor according to the defined precision, unless both neighbors are equidistant, in which case rounds up.
Rounding Precision 0.05 Rounds to 5 rappen.

When applying invoice rounding, JustOn automatically creates a special invoice line item of the type Rounding Difference. This line item contains the value needed to round the grand total according to the rules defined in the currency mapping. On the invoice PDF, the rounding difference is printed between the tax rates and the grand total.

Info

Depending on your locale or your business, you may need to modify the display name for the rounding difference. To do so, edit the custom label Rounding Difference.

For help about modifying custom labels, see Managing Custom Labels.

Defining Invoice Rounding Settings

Create a currency mapping record for each currency for which you want invoice amounts to be rounded.

  1. Click to enter Setup, then open Custom Settings.

    In Salesforce Lightning, navigate to Custom Code > Custom Settings.

    In Salesforce Classic, navigate to Develop > Custom Settings.

  2. Click Manage in the row of Currency Mapping.

  3. Click New.
  4. Specify the information as necessary.
  5. Click Save.

    This creates the new currency mapping record.

Enabling Template Text Copies

Depending on your organization's requirements, you must modify the texts for individual invoices, that is, without applying the changes to the invoice template. To this end, JustOn can copy the text field contents of a template to a draft invoice. To enable this option, add the Copy Text button to the invoice detail view.

  1. Navigate to the object management settings of the Invoice object.
  2. Click Page Layouts.
  3. In the Invoice Layout row, click Edit.
  4. Add the Copy Text button to the page layout.

    In Salesforce Lightning, drag the button from the Mobile & Lightning Actions palette to the Salesforce Mobile and Lightning Experience Actions section.

    In Salesforce Classic, drag the button from the Buttons palette to the Custom Buttons area.

  5. Click Save.

    For help about modifying page layouts, see Managing Pages.

Enabling Number Range History

In case of issues or disputes with respect to the sequence of JustOn's numbering, you may may need some detailed tracking or debugging information about the number range usage. To this end, JustOn introduces dedicated history fields and history tracking for number ranges.

Info

The number range history is available as of JustOn 2.64.

Number range history data

For each generated number, the following information is recorded:

Field Description
Counter The current count for this number range.
Timestamp The date and time of the latest count increase.
Target ID The Salesforce ID of the record on which the counter has been used the last time.
Last Generated Name The last produced counter (invoice number, etc.)

In addition, each history record includes

  • The name of the user who triggered the counter generation
  • The last value and the current value for Counter, Timestamp, Target ID and Last Generated Name.

Activating Field History Tracking

In new installations, JustOn automatically writes the number range history data. If you are upgrading JustOn from a previous version (2.63 or lower), however, you must explicitly activate history tracking for all relevant Number Range fields.

  1. Navigate to the object management settings of the Number Range object.
  2. On the Details page, click Edit.
  3. In the Optional Features section, select the checkbox Track Field History.
  4. Click Save.
  5. Click Fields & Relationships.
  6. Click Set History Tracking.
  7. Select the checkboxes for the following fields:

    • Account
    • Counter
    • Counter Name
    • Day
    • Last Generated Name
    • Month
    • Target Id
    • Timestamp
    • Year
  8. Click Save.

Displaying Number Range History

To make the history data visible on the detail page of number range records, you add the corresponding fields and the related list to the Number Range object.

  1. Navigate to the object management settings of the Number Range object.
  2. Click Page Layouts.
  3. In the Number Range Layout row, click Edit.
  4. From the Fields palette, drag the Timestamp, Target ID and Last Generated Name fields to the Number Range Detail section.

    Optionally, you can create a dedicated section for the history fields.

  5. From the Related Lists palette, drag the Number Range History list to the Related Lists section.

  6. Click Save.
  7. In the object management settings of the Number Range object, click Lightning Record Pages.
  8. Open the Number Range page details, and click Edit.
  9. Drag the Related Lists component to the Number Range record page.

    This component displays all assigned related lists.

  10. Click Save.

  11. Click Activate.

    On the App Default sub-tab, assign the page as the app default for JustOn.

    For help about modifying page layouts, see Managing Pages.

Setting Up Credit Generation

JustOn allows for creating credits for existing invoices to be reversed. Setting up this feature involves these tasks:

Enabling Credit Creation for Single Invoices

To enable the option for individually creating a credit based on an invoice, add the Create Credit button to the invoice detail view. To do so:

  1. Navigate to the object management settings of the Invoice object.
  2. Click Page Layouts.
  3. In the Invoice Layout row, click Edit.
  4. Add the Create Credit button to the page layout.

    In Salesforce Lightning, drag the button from the Mobile & Lightning Actions palette to the Salesforce Mobile and Lightning Experience Actions section.

    In Salesforce Classic, drag the button from the Buttons palette to the Custom Buttons area.

  5. Click Save to save the modified page layout.

    For help about modifying page layouts, see Managing Pages.

Configuring Create Credit Fields

Info

The Create Credit field set is available as of JustOn 2.54.

To configure which invoice line item fields are displayed when creating a credit for a single invoice:

  1. Navigate to the field sets definition of the Invoice Line Item object.

    In Salesforce Lightning, navigate to Setup > Object Manager > Invoice Line Item > Field Sets.

    In Salesforce Classic, navigate to Setup > Create > Objects > Invoice Line Item > Field Sets.

  2. Click Edit in the Create Credit row.

  3. Move the fields to or from the In the Field Set container and reorder them as required.
  4. Click Save.

Modifying Credit Note Texts

Depending on your organization's requirements, you must modify the text building blocks for credit notes. Usually, the relevant texts are included in the following fields of the Credit template detail (which is associated to the invoice template):

Field Description Default Value
Display Type Specifies the type of the document to be printed to the PDF. Credit
Info Right Defines an area for printing general information like a page counter and the date above the actual document text, can include placeholders.
Text 1 Specifies the text to be rendered above the detail table, can include placeholders.
Email Subject Defines the default email subject, can include placeholders.
Email Body Defines the plain text body for the email, can include placeholders.
Line breaks are considered.
PDF Name Specifies the name pattern for the generated PDF file, can include placeholders.

To modify the texts:

  1. Open the Credit template detail.
  2. Double-click the intended field and specify the corresponding text as required.

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

  3. Click Save.

Setting Up Invoice Line Item Mass Editing

JustOn allows for editing multiple invoice line items at once ("mass edit"). Setting up this feature involves two tasks:

Adding the Mass Edit Button

To enable the option for editing multiple invoice line items, add the Edit All button to the invoice line item section of the invoice page layout. To do so:

  1. Navigate to the object management settings of the Invoice object.
  2. Click Page Layouts.
  3. In the Invoice Layout row, click Edit.
  4. Scroll to the Invoice Line Items list and click to open the list properties.
  5. Open the Buttons section.
  6. Under Custom Buttons, move Edit All to the Selected Buttons column.

    rel_list_prop
    Adding a custom button to a related list

  7. Click OK to save the list properties.

  8. Click Save to save the modified page layout.

    For help about modifying page layouts, see Managing Pages.

Configuring Mass Edit Fields

To configure which invoice line item fields are available for mass editing:

  1. Navigate to the field sets definition of the Invoice Line Item object.

    In Salesforce Lightning, navigate to Setup > Object Manager > Invoice Line Item > Field Sets.

    In Salesforce Classic, navigate to Setup > Create > Objects > Invoice Line Item > Field Sets.

  2. Click Edit in the Edit All row.

  3. Move the fields to or from the In the Field Set container and reorder them as required.

    Make sure to keep all mandatory fields in the field set (Title, Quantity, Unit Price, Tax Rate).

  4. Click Save.

Invoice Data Options

Defining Initial Invoice Count

Invoices, credits, cancellations and dunning reminders must have unique numbers to comply with legal regulations. In Draft status, these numbers are temporary and of no legal relevance. When finalizing invoices or dunning reminders, however, JustOn creates the unique and unalterable numbers based on defined counters.

Counter and number range concepts

JustOn implements counters using the custom setting Counters. The following fields are available:

Field Possible Values Description
Name Specifies the name of the counter, is to be referred to by the template.
Reset YEARLY
MONTHLY
DAILY
Defines the interval after which the counter is reset. If empty, the counter is not reset.
Some legal or fiscal systems do not allow invoice number ranges to restart on a monthly or daily base (for example, in France). Make sure you clarify this question before operating in a new market.
Template [Year]
[Month]
[Day]
[AccountNo]
{00000}
Specifies the pattern of the produced number. It may contain custom placeholders (defined for fields on the invoice, account, subscription, business entity, related invoice and email contact), and must define the minimum number of digits like {00000}. You can combine the placeholders and add any fix strings as necessary.
Use Account Counters (checkbox) true
false
If checked, creates a new number range for each account that uses this counter.
Start Count Optionally, specifies a start count. If set, the associated number range will start with the next number (<value> + 1). That is, if you want the number range to start with 5, the start count value must be 4.
JustOn evaluates the start count on number range creation and after reset.
If empty, defaults to 0.
If you need the start count for a specific period (→ reset period) only, make sure to delete it after the first unique numbers in the relevant period have been produced.

The Default counter as shipped with JustOn, for example, uses the following pattern template:

[Year]{00000}

This produces invoice numbers of the following pattern:

201700001, 201700002, 201700003

The count increases each time an invoice is set Open and a new invoice ID is created.

The following table lists some examples.

Example Counter Template
2018-Jan-00001 [Year]-[Month]-{00000}
180100001 [Year:yy][Month:MM]{00000}
2018ACME00001 [Year][AccountAccountName]{00000}

By default, JustOn provides the following counters:

  • Default: A single counter used by default for generating all invoice, credit, cancellation or dunning numbers. This counter is assigned to the default invoice template.

    If you have more than one template or template details to cover specific needs, you can use an individual counter with each template or template detail. To this end, configure additional counters. If you use the dunning functionality, for example, configure a dunning counter first and assign it to the corresponding template detail.

    If the template or template detail does not define a counter, JustOn falls back to the counter set on the business entity. If the system cannot find a valid counter, it shows an exception.

  • Dunning Run: Used to count the individual dunning runs. The dunning run counter does not offer the reset feature and does not work with placeholders.

  • Subscription: Used to count the subscriptions. The subscription counter does not offer the reset feature and supports only a limited set of placeholders (account-related and built-in).

Each counter is associated to one or more number ranges. Number ranges are implemented as a custom object. They represent the groups of numbers to which the unique numbers created for an invoice, dunning reminder etc. belong. If a number range as required by the counter does not exist, JustOn creates one automatically with the count set 0.

With the counter field Reset set to YEARLY, JustOn creates a new number range for each year. Likewise it creates a new number range for each month if Reset is set MONTHLY, and every day if Reset is set DAILY. The reset feature can be combined with the setting Use Account Counters.

JustOn selects number ranges based on the counter defined for the invoice, the account of the invoice and the invoice date for day/month/year.

Number ranges include the following fields:

Field Description
Counter Name Specifies the name of the associated counter.
Counter Shows the current count for this number range. Equals the last produced unique number for an invoice, dunning reminder, subscription or SEPA mandate reference using the associated counter.
Year Shows the year for this number range. Is empty if the counter is set to not reset.
Month Shows the month for this number range. Is empty if the counter is set to not reset or set to reset YEARLY.
Day Shows the day for this number range. Is empty if the counter is set to not reset or set to reset YEARLY or MONTHLY.
Account Shows the account for this number range. Is empty if the checkbox Use Account Counters on the counter is not selected.

Irrespective of the counter to be used, your business may require to start your invoices count with a given number. To this end, you create a number range for invoices that defines the intended start count before actually generating and finalizing invoices.

  1. Open the Number Ranges tab.
  2. Click New.
  3. Specify the details as necessary.

    • Counter Name: The name of the associated counter
    • Counter: The number preceding the intended start count, like <start_count> - 1

      Assume the invoices you produce are to start with the counter 1000. In this case, set 999 in the Counter field of your number range.

  4. Click Save.

You can provide invoice recipients the option to directly pay their invoices. To do so, you integrate with payment service providers via JustOn Cash Management.

Once set up, JustOn Billing & Invoice Management can set a link to the payment page for a given invoice. You usually add this link to the email body of your invoice template in order to redirect your users to the payment page.

Your business may, in addition, require to make this link available on the detail page of an invoice record. To this end, you add the corresponding field to the invoice layout.

  1. Navigate to the object management settings of the Invoice object.
  2. Click Page Layouts.
  3. In the row of the relevant invoice layout, click to open the action menu, then select Edit.
  4. From the Fields palette, drag the Payment Page URL field to the target layout section.
  5. Click Save.

Via the (legacy) JustOn Self-Service Extension, you can provide invoice recipients the option to supply their bank details, granting a SEPA direct debit mandate to your business. If they do, JustOn saves the mandate and the bank details with the user's account as well as the invoices. Consequently, this allows you to generate corresponding bank transfer orders to collect due payments.

Once set up, JustOn creates a link to the direct debit mandate page for a given invoice. You usually add this link to the email body of your invoice template in order to redirect your users to the direct debit mandate page.

Your business may, in addition, require to make this link available on the detail page of an invoice record. To this end, you add a custom formula field to the Invoice object that assembles the direct debit mandate link.

  1. Navigate to the fields list of the Invoice object.
  2. Create the following new field.

    Field Data Type Formula Notes
    Direct Debit Mandate Link Formula (Text) "https://<server>/ONBSE1__DirectDebitMandate?id=" + Id + "&uuid=" + ONB2__UUID__c Replace <server> with the secure site URL of your Salesforce instance, like <instance>.secure.force.com/ or <mydomain>.my.salesforce-sites.com.

    For help about creating fields, see Managing Object Fields.

Enabling Draft PDF Generation

For review or testing purposes, your business may require to generate PDF files from multiple invoices in the status Draft. Setting up this feature involves two tasks:

Creating Draft PDF File Distribution Target

To enable the option for creating PDF files for draft invoices, create a dedicated file distribution target for draft PDF documents:

  1. Click to enter Setup, then open Custom Settings.

    In Salesforce Lightning, navigate to Custom Code > Custom Settings.

    In Salesforce Classic, navigate to Develop > Custom Settings.

  2. Click Manage in the row of File Distribution.

  3. Click New.
  4. Specify the details as necessary.

    Make sure to select the checkbox Draft Folder. Other mandatory information include the name, backend and PDF name.

    For details, see File Distribution Information.

  5. Click Save.

Adding Create Draft PDFs Button

To enable the option for creating PDF files for multiple draft invoices from the invoices list view, add the Create Draft PDFs button to the invoices list view. To do so:

  1. Navigate to the object management settings of the Invoice object.
  2. Click Search Layouts.
  3. Click Edit in the row of the List View.
  4. In the Custom Buttons section, move Create Draft PDFs to the Selected Buttons column.
  5. Click Save to save the modified page layout.

To enable the option for creating PDF files for multiple draft invoices from the invoice run detail view, add the Create Draft PDFs button to the invoice run detail view. To do so:

  1. Navigate to the object management settings of the Invoice Run object.
  2. Click Page Layouts.
  3. Click Edit in the row of the Invoice Run Layout.
  4. Scroll to the Invoices list and click to open the list properties.
  5. Open the Buttons section.
  6. Under Custom Buttons, move Create Draft PDFs to the Selected Buttons column.

    rel_list_prop
    Adding a custom button to a related list

  7. Click OK to save the list properties.

  8. Click Save to save the modified page layout.

    For help about modifying page layouts, see Managing Pages.

Enabling Invoice PDF Regeneration

Usually, JustOn generates a PDF file when finalizing an invoice. In certain business use cases, you may need to recreate the PDF file for an already finalized invoice (status Open). Doing so does not modify any invoice data.

Info

Regenerating the invoice PDF does not constitute a suitable means to correct an invoice. In case of wrong billing data or formal invoice errors, you usually

  • cancel the invoice
  • correct the source data as necessary, and
  • create a new invoice.

For details, see How to correct an invoice.

Typical use cases

You usually must correct (cancel and recreate) an invoice if one of the legally required information is wrong or missing, including, among others

  • Recipient address
  • Seller information like VAT number
  • Invoice date
  • Invoice line item information
  • Invoice amount
  • Tax

When correcting any information that does not involve legally binding invoice data, recreating the invoice PDF may be sufficient. Use cases may include, for example

  • Correcting typos
  • Registering a partial payment, which reduces the payment amount

    This may be illegal in some jurisdictions.

To enable the option for individually recreating a PDF file for an open invoice, add the Recreate PDF button to the invoice detail view.

  1. Navigate to the object management settings of the Invoice object.
  2. Click Page Layouts.
  3. In the Invoice Layout row, click Edit.
  4. Drag the Recreate PDF button to the Custom Buttons area in the invoice detail section.
  5. Click Save to save the modified page layout.

    For help about modifying page layouts, see Managing Pages.

Enabling VAT Number Validation

The EU provides VIES, a VAT number validation service. It allows to validate the VATIN (value added tax identification number) of businesses in the EU.

Note

The EU VAT number validation service is designed for single, sporadic requests. In case your repeated requests are considered abusive use of the service, your IP address will be blocked for a certain period.

The VAT validation only tells whether a given EU VAT information exists. It does not necessarily prove, however, that the given VAT number actually belongs to the current account.

JustOn uses this service to check the VAT number of an account. The VAT check can be performed

  • Individually for a single account, using a button on the account page, or
  • For multiple accounts using a scheduled batch job.

Info

Switzerland adheres to certain regulations of the European Economic Area, including the reverse charge procedure. As a precondition, suppliers must specify the buyer's VAT ID. The EU VAT number validation service, however, does not cover Swiss VAT IDs. To check Swiss UIDs, you can use the official UID Register or third-party services like vatstack.

VAT validation concepts

By default, JustOn's VAT validation uses the VAT number as specified in the VATIN field of the account as the source field. You can, however, overwrite this behavior by creating a custom field ON_VATNumber on the Account object. Once this field exists, JustOn uses this field as the source. In order to validate the VAT number, the source field must not be empty.

The result of the VAT validation is written to fields on the Account object:

Field Label API Name Data Type Description
VAT Number Valid VATIsValid Checkbox Selected if the VAT number is valid
VAT Validated Name VATValidatedName Text (255) The name linked to the VAT number
VAT Validated Address VATValidatedAddress Long Text Area (32768) The address linked to the VAT number
Last VAT Validation VATLastValidation Date/Time The timestamp of the last validation
Last Successful VAT Validation VATLastValidationSuccess Date/Time The timestamp of the last successful validation
Last VAT Validation Error VATLastError Text (255) The error message if the last validation was not successful

Be aware of the following validation specifics:

  • If the validation was not successful, only the fields Last VAT Validation and Last VAT Validation Error are updated.
  • The fields VAT Number Valid, VAT Validated Name and VAT Validated Address reflect the result of the last successful validation.
  • Modifying the value in the VAT number source field (VATIN or ON_VATNumber) does not automatically update the VAT validation result fields. JustOn therefore recommends to delete the validation result fields after changing the VAT number.
  • Empty VAT number source fields (VATIN or ON_VATNumber) produce an error on manual VAT number check, prompting the user to specify a value, and make JustOn skip the corresponding accounts on automatic VAT number validation.
  • The name and address linked to a VAT may not be available.
  • If required, you can add the fields to the page layout of the Account object.

JustOn provides the remote site setting CheckVatService, which is required to access the VAT number validation service.

Enabling the VAT validation in JustOn involves the following tasks:

Activating CheckVatService Remote Site

JustOn provides the remote site setting CheckVatService, which is required to access the VAT number validation service. To activate the remote site:

  1. Click to enter Setup, then open Remote Site Settings.

    In Salesforce Lightning, navigate to Security > Remote Site Settings.

    In Salesforce Classic, navigate to Security Controls > Remote Site Settings.

  2. Click Edit in the row of CheckVatService.

  3. Select the Active checkbox.
  4. Make sure that the specified URL starts with https.

    As of version 2.75, JustOn uses HTTPS to access the EU VAT validation service. If upgrading from a previous version, you may have to modify the remote site setting CheckVatService, specifying the HTTPS URL.

  5. Click Save.

Adding VAT Validation Fields to Account

The VAT validation allows to use the custom field ON_VATNumber on the Account object to provide the VAT number, instead of the default VATIN field.

  1. Navigate to the fields list of the Account object.
  2. Create the following new field.

    API Name Data Type Description Example Value
    ON_VATNumber Text (255)
    or
    Formula
    Specifies the VAT number. If configured as a formula, it can determine the value based on other fields. DE1234567
    MyVATNumber__c

Using the timestamp fields Last VAT Validation and Last Successful VAT Validation, you can, optionally, create a formula field (VATValidCheck) on the Account object that shows if the validation result is up to date. This field can be used, for example, for an Account list view filter.

  1. Navigate to the fields list of the Account object.
  2. Create the following new field.

    API Name Data Type Description
    VATValidCheck Formula (Checkbox) Shows if the validation result is up to date

    Use the following formula:

    IF(
      AND(
        NOT(ISBLANK(ONB2__VATLastValidation__c)),
        NOT(ISBLANK(ONB2__VATLastValidationSuccess__c)),
        ONB2__VATLastValidation__c == ONB2__VATLastValidationSuccess__c
      ),
      true,
      false
    )
    

For help about creating fields, see Managing Object Fields.

Enabling Individual VAT Number Validation

If you are upgrading from a version prior to JustOn 2.57, you may have to add the VAT Validation button to the Account page layout in order to enable the individual VAT number check for a single account.

Adding the button involves two steps:

Creating VAT Validation Button

To create the VAT Validation button:

  1. Navigate to the object management settings of the Account object.
  2. Click Buttons, Links, and Actions.
  3. Click New Buttons or Link.
  4. Create the following button, then click Save.

    Detail Value
    Label VAT Validation
    Display Type Detail Page Button
    Behavior Display in existing window without sidebar
    Content Source Visualforce Page
    Content VATValidation [ONB2_VATValidation]

    For help about creating buttons, see Managing Buttons or Links.

Adding VAT Validation Button to Account Layout

To add the VAT Validation button to the page layout:

  1. Navigate to the object management settings of the Account object.
  2. Click Page Layouts.
  3. In the Account Layout row, click Edit.
  4. Add the VAT Validation button to the page layout.

    In Salesforce Lightning, drag the button from the Mobile & Lightning Actions palette to the Salesforce Mobile and Lightning Experience Actions section.

    In Salesforce Classic, drag the button from the Buttons palette to the Custom Buttons area.

  5. Click Save.

    For help about modifying page layouts, see Managing Pages.

This enables users to validate the VAT number for an individual account (see Account - VAT Number Validation).

Enabling Automatic VAT Number Validation

JustOn allows to schedule a job for validating the VAT number of multiple accounts automatically. For accounts to be considered by the job, the VAT number source field (VATIN or ON_VATNumber) must not be empty. That is, accounts for which the VAT number source field is not set are skipped, but no error is produced.

VAT Validation Custom Setting

The VAT validation job is controlled by the custom setting VAT Validation.

Field Name API Name Data Type Description
Validity Period ValidityPeriod__c Number(18,0) The validity period of the VAT validation result in days. Defaults to 0 if empty. If 0, the VAT validation batch job validates only VAT numbers that are not yet validated.
  • If there is no VAT Validation setting record with the name Default, or if the validity period is 0, JustOn executes the VAT number validation only for accounts that are not yet validated, that is, for which the field Last Successful VAT Validation is not set.
  • If there is a validity period specified, the job refreshes the VAT number validation of accounts for which the last check was performed more than the specified number of days ago.

To configure the VAT Validation job, you define a VAT Validation setting named Default:

  1. Click to enter Setup, then open Custom Settings.

    In Salesforce Lightning, navigate to Custom Code > Custom Settings.

    In Salesforce Classic, navigate to Develop > Custom Settings.

  2. Click Manage in the row of VAT Validation.

  3. Click New.
  4. Specify the details as necessary.

    • Name: Default
    • Validity Period: The validity period of the VAT validation result in days
  5. Click Save.

Scheduling VAT Validation Job

You can set up a job in order to have VAT numbers validated automatically on a regular basis. To schedule the VAT validation, you can use either JustOn's Scheduled Jobs page, Salesforce's Schedule Apex functionality or the Salesforce Developer Console. For details, see Scheduling a Job.

Via JustOn's Scheduled Jobs page:

  1. Open the Scheduled Jobs page.

    Use the following URL https://login.salesforce.com/apex/ONB2__JobsSetup, or, if you are already logged in, append apex/ONB2__JobsSetup to your org's domain name.

    As of JustOn 2.52, you can access the Scheduled Jobs page via the JustOn configuration app ( > JustOn Configuration > Jobs Setup).

  2. From the Apex Job drop-down list, select VAT Validation Job.

    The Job Name field is automatically set to BatchVATValidationJob.

  3. From the Start Time drop-down list, select the preferred execution time.

  4. Optionally, edit the displayed cron expression to adjust the execution time.
  5. Click Schedule.

    This sets up the VAT validation to be executed at the specified time. For accounts to be considered by the job, the VAT number source field (VATIN or ON_VATNumber) must not be empty.

Info

From the Scheduled Jobs page, you can also run the job immediately.

Via Salesforce's Schedule Apex functionality:

  1. Click to enter Setup, then open Apex Classes.

    In Salesforce Lightning, navigate to Custom Code > Apex Classes.

    In Salesforce Classic, navigate to Develop > Apex Classes.

  2. Click Schedule Apex on top of the list.

  3. Specify the details as required.

    • Job Name: VATValidationChain
    • Apex Class: VATValidationChain
    • Frequency: Weekly or Monthly (with an according weekday or day of month setting)
    • Start
    • End
    • Preferred Start Time
  4. Click Save.

    This sets up the VAT validation to be executed at the specified time. For accounts to be considered by the job, the VAT number source field (VATIN or ON_VATNumber) must not be empty.

For more details about job scheduling, see Scheduling a Job in the JustOn documentation and Schedule Apex in the Salesforce Help.

You can also invoke the VAT validation using the following code in the Salesforce Developer Console:

new ONB2.ChainRunner()
.execute(
    new ONB2.ChainFactory().getByName('VATValidationChain')
);

Distribution Options

Enabling Contact Roles for Invoice Distribution

You can use contact roles to pre-populate contact and address fields when executing an invoice run. JustOn supports contact roles as defined using the custom picklist field JustOn Contact Role on the Contact object or on the Account Contact Relationship object.

Depending on your business requirements or use cases, proceed as follows:

  • For users with a JustOn license, you add the managed field JustOn Contact Role (API name ONB2__ContactRole__c) to the page layout of the Contact object.
  • For users without a JustOn license, the managed Contact field ONB2__ContactRole__c is not visible. If you still must support contact roles on contacts, you create the custom field JustOnContactRole on the Contact object, which replicates the behavior of ONB2__ContactRole__c but is available for other Salesforce users.

    Once the custom field is defined, it takes precedence over the managed field.

  • If you need the contact role functionality on account–contact relationships, you create the custom field JustOnContactRole on the Account Contact Relationship object.

JustOn Contact Role priority
  • If both JustOn Contact Role on the account–contact relationship and JustOn Contact Role on the contact are set, the role defined on the account–contact relationship (irrespective of whether it is a primary or secondary relation) has priority over the role defined on the contact.
  • If JustOn Contact Role is set both on a direct and an indirect account–contact relationship, the role defined on the direct account–contact relationship (primary relation) has priority over the role defined on the indirect account–contact relationship.
  • JustOn Billing & Invoice Management considers JustOn contact roles defined on primary contacts (related via a direct account–contact relationship) only.

    If you need a JustOn contact role on a secondary contact (related via an indirect account–contact relationship), you must define it on the corresponding ACR record.

  • Salesforce allows time limitations and an explicit Active status for account–contact relationships. These settings, however, do not have influence on the priority of the assigned JustOn contact roles. If an account–contact relationship is valid on a given date, JustOn Billing & Invoice Management will consider the assigned contact role.

    You must make sure to not assign two or more contacts with the same role to an account. If this is the case, the system randomly picks one of them, which may produce unwanted results.

  • Contact role settings on the account–contact relationship (ACR) and on the contact can complement each other, as long as they are not in conflict.

  • For compatibility reasons, JustOn Billing & Invoice Management still supports existing Salesforce Classic Account Contact Roles. If available, they take general precedence over the values set in the JustOn Contact Role fields on the contact or the account–contact relationship.

To keep control simple, use JustOn contact roles either on contacts or on account-contact relationships only. If you decide to use account-contact relationships, JustOn recommends to use JustOn contact roles on account-contact relationships for more flexibility.

The examples in JustOn Contact Role Priority illustrate the behavior.

Using Managed Contact Role Field on Contact

To add the managed field JustOn Contact Role (API name ONB2__ContactRole__c) to the page layout of the Contact object:

  1. Click to enter Setup, then navigate to the object management settings of the Contact object.
  2. Click Page Layouts.
  3. In the Contact Layout row, click Edit.
  4. Drag the JustOn Contact Role field to the page layout.
  5. Click Save.

    For help about modifying page layouts, see Managing Pages.

Creating Custom Contact Role Field on Contact

To create the custom field JustOnContactRole on the Contact object to replicate the behavior of ONB2__ContactRole__c:

  1. Click to enter Setup, then navigate to the fields list of the Contact object.

    Open the field configuration for JustOn Contact Role in a new browser window or tab for later reference.

  2. Create the following new field.

    Label API Name Data Type Values
    JustOn Contact Role JustOnContactRole Picklist (Multi-Select) Copy all picklist entries from JustOn Contact Role that are needed for your org's uses cases.
    Make sure to use the same API names for the picklist entries.

    For help about creating fields, see Managing Object Fields in the JustOn Documentation or Create Custom Fields in the Salesforce Help.

  3. Allow the relevant users access to the new field either by adding it to their assigned profiles or permission sets.

    For details, see Set Field Permissions in Permission Sets and Profiles in the Salesforce Help.

  4. Allowlist the new field to make it accessible for database queries.

    To this end, create the new Field Whitelist record JustOnContactRole__c.

  5. Add the new picklist field (API name JustOnContactRole) to the Contact layout.

    Remove, if necessary, the managed field (API name ONB2__ContactRole__c) from the layout.

    For help about modifying page layouts, see Managing Pages or Page Layouts in the Salesforce Help.

Creating Contact Role Field on Account Contact Relationship

Salesforce allows associating one contact to multiple accounts through the Account Contact Relationship object. For details and configuration instructions, see

Once set up accordingly, you can enable JustOn contact roles on account–contact relationships. To this end, you create the custom field JustOnContactRole on the Account Contact Relationship object:

  1. Click to enter Setup, then navigate to the fields list of the Account Contact Relationship object.

    Open the field configuration for JustOn Contact Role on the Contact object in a new browser window or tab for later reference.

  2. Create the following new field.

    Label API Name Data Type Values
    JustOn Contact Role JustOnContactRole Picklist (Multi-Select) Copy all picklist entries from JustOn Contact Role on the Contact object that are needed for your org's uses cases.
    Make sure to use the same API names for the picklist entries.

    For help about creating fields, see Managing Object Fields in the JustOn Documentation or Create Custom Fields in the Salesforce Help.

  3. Allow the relevant users access to the new field either by adding it to their assigned profiles or permission sets.

    For details, see Set Field Permissions in Permission Sets and Profiles in the Salesforce Help.

  4. Allowlist the new field to make it accessible for database queries.

    To this end, create the new Field Whitelist record JustOnContactRole__c.

    If you have already allowlisted the custom field JustOnContactRole as created on the Contact object, do not create a second record. A Field Whitelist record allowlists a field, irrespective of its object.

  5. Add the new picklist field (API name JustOnContactRole) to the Account Contact Relationship layout.

    For help about modifying page layouts, see Managing Pages or Page Layouts in the Salesforce Help.

Once enabled, you can define contact roles for the invoice distribution use cases.

JustOn can generate public links to the produced PDF files. This allows you to share the documents with any users, including outside your organization, without password protection or any other restrictions. If set up accordingly, JustOn creates the preview or download links when finalizing the invoices.

Note

For generating public links, the Salesforce features Content Deliveries and Public Links must be enabled. For details, see Set Up Content Deliveries in the Salesforce Help.

For details on how to create public links subsequently for existing invoices, see How to create public links for existing invoices.

Enabling the public file link generation for invoice PDF files involves the following tasks:

Enabling Content Distribution

In order to enable public file link generation, you activate the corresponding global setting.

  1. Click to enter Setup, then open Custom Settings.

    In Salesforce Lightning, navigate to Custom Code > Custom Settings.

    In Salesforce Classic, navigate to Develop > Custom Settings.

  2. Click Manage in the row of Global Settings.

  3. Click Edit in the Default row.
  4. Select the checkbox Always Create Content Distribution.
  5. Click Save.

    This enables the public file link generation without installing additional software.

Creating PDF Preview URL Field

For integrations with external systems like customer portals, etc., you can make JustOn write the public PDF preview link to the invoice record upon finalization. To this end, create the custom field ContentDistributionUrl on the Invoice object.

Info

As opposed to the ContentDownloadUrl field, the ContentDistributionUrl field provides a link to a preview page instead of a link for downloading the PDF file.

JustOn supports the ContentDistributionUrl field as of version 2.50.

  1. Navigate to the fields list of the Invoice object.
  2. Create the following new field.

    API Name Data Type Description
    ContentDistributionUrl URL Specifies the public link to the PDF preview.
    Make sure to grant edit access for users who finalize invoices and read access for payment guest users.

    For help about creating fields, see Managing Object Fields.

Creating PDF Download URL Field

For integrations with external systems like customer portals, etc., you can make JustOn write the public PDF file link to the invoice record upon finalization. To this end, create the custom field ContentDownloadUrl on the Invoice object.

Info

As opposed to the ContentDistributionUrl field, the ContentDownloadUrl field provides a link for downloading the PDF file instead of a link to a preview page.

JustOn supports the ContentDownloadUrl field as of version 2.57.

  1. Navigate to the fields list of the Invoice object.
  2. Create the following new field.

    API Name Data Type Description
    ContentDownloadUrl URL Specifies the public link to the PDF file.
    Make sure to grant edit access for all users who finalize invoices.

    For help about creating fields, see Managing Object Fields.

Controlling Email Tracking Options

To help tracking the invoice distribution, JustOn creates a history task for sent invoice emails. The task is assigned to the contact set in Email Contact on the invoice (see Address Data Flow). The generated task records are displayed in the Activities list on the related invoice.

Note

Due to security-related modifications introduced with JustOn 2.74, you must explicitly allow Read and Edit access to the Type field of the Task object, as described in Enabling Access for New Users.

invoice_history_task
Displaying tasks on invoices

Info

Note that record types for Task records are always project specific. Therefore, JustOn cannot programmatically support your record types. For details about working with record types, see Tailor Business Processes to Different Users in the Salesforce Help.

JustOn saves the past activity by default when emailing invoices. The Activities list, however, is not visible on the invoice page by default. To enable the Activities display:

  1. Open an invoice.
  2. Click to open the Setup menu, then select Edit Page.
  3. Drag the Activities component to the intended region of the page.
  4. Click Save.

    For help about modifying pages, see Managing Pages.

Note

Make sure that the default activities view is set to Activity Timeline (see Set the Default Activities View in the Salesforce Help). Otherwise, the Activities list will not be accessible via the Lightning record page.

Disabling Email Tracking

If you do not want these email tracking activities to be created, you can disable this functionality. To do so:

  1. Click to enter Setup, then open Custom Settings.

    In Salesforce Lightning, navigate to Custom Code > Custom Settings.

    In Salesforce Classic, navigate to Develop > Custom Settings.

  2. Click Manage in the row of Global Settings.

  3. Click Edit in the Default row.
  4. Deselect the checkbox Track E-Mail.
  5. Click Save.

Accounting-Relevant Options

Enabling Custom Booking Dates

JustOn allows for writing bookkeeping data for revenues and taxes from finalized invoices. When doing so, JustOn sets a booking date, which allocates the booking detail to a booking period.

Your business may require to use custom booking dates. To enable the support for custom booking dates, you add the custom field ON_BookingDate to the Invoice object to determine the relevant date.

  1. Navigate to the fields list of the Invoice object.
  2. Create the following new field.

    API Name Data Type Description
    ON_BookingDate Date
    Formula (Date)
    Produces the booking date according to custom requirements.

    If you need, for example, the booking date to be the invoice's service period end, create a formula field with the formula ONB2__ServicePeriodEnd__c.

    For help about creating fields, see Managing Object Fields.

This writes a booking date according to your business' requirements to the invoice. When creating booking details, this date is passed as the booking date.

Info

If ON_BookingDate is not set, JustOn uses the invoice date as fallback.

Disabling Automatic Balance Assignment

By default, JustOn Billing & Invoice Management assigns new or free payment balances on the account to invoices on finalization (see Automatic Balance Assignment). You can disable the automatic assignment on invoice level through adding and selecting the custom checkbox field ON_NoAutoBalanceAssignment on the invoice.

  1. Navigate to the fields list of the Invoice object.
  2. Create the following new field.

    API Name Data Type Description
    ON_NoAutoBalanceAssignment Checkbox
    Formula (Checkbox)
    If selected, prevents available balances from being assigned to the current invoice.
    Using a formula, you can apply certain logic to have this field set automatically.

    For help about creating fields, see Managing Object Fields.

Configuring Settlement Options

JustOn can offset non-related invoices and credits of an account via settlements.

Enabling Settlement Assignment Key

Using an optional settlement assignment key on both invoices and credits narrows down the set of invoices and credits available for automatic settlements. Only invoices and credits with the same key can be settled with each other automatically.

Info

Users can still select any invoices and credits for manual settlements, irrespective of defined settlement assignment keys.

To allow users or automatic means (like, for example, a formula or the ON field mechanism) to define the settlement assignment key, you create the custom field Settlement Assignment Key on the Invoice object.

  1. Navigate to the fields list of the Invoice object.
  2. Create the following new field.

    API Name Data Type Description
    SettlementAssignmentKey Formula (Text)
    Text
    Specifies the key to define allowed settlement matches.

    For help about creating fields, see Managing Object Fields.

Enabling Automatic Settlement

Automatic settlement concepts

Generally, JustOn settles an open invoice against a new credit, and an open credit against a new invoice (also referred to as the settlement target).

Be aware of the following specifics:

  • JustOn settles the complete open amount of the invoice or credit, following this rule:

    settled amount = min(abs(credit amount), abs(open invoice amount))
    
  • The payment due dates of the invoice or credit are irrelevant for the settlement.

  • If you work with business entities, the business entity specified for both the invoice and the credit must match for the settlement to take place.
  • Using an optional settlement assignment key on both invoices and credits narrows down the set of invoices and credits available for automatic settlements. Only invoices and credits with the same key can be settled with each other automatically.

    Users can still select any invoices and credits for manual settlements, irrespective of defined settlement assignment keys.

    Enabling Settlement Assignment Key

The settlement itself is implemented by balances on the open invoice and on the new (target) invoice.

New invoice balance

Field Value
Type Settlement
Amount <settlement amount>
Related Invoice <settled invoice ID>

Settled invoice balance

Field Value
Type Clearing
Amount -1 * <settlement amount>
Related Invoice <new invoice ID>

The invoice finalization involves the Settle invoices step. So if configured accordingly, JustOn can settle open invoices or credits automatically with new draft invoices or credits when finalizing them.

Doing so creates the balance of the type Settlement on the new (target) invoice. The open invoice to be settled gets the corresponding balance of the type Clearing, and at the same time, it is set Paid (in case of invoices) or Settled (in case of credits).

settlement_auto
Automatically settling an invoice against a credit

For more details, see Settlements.

In order to have open invoices or credits settled automatically, the feature has to be activated in the global settings.

  1. Click to enter Setup, then open Custom Settings.

    In Salesforce Lightning, navigate to Custom Code > Custom Settings.

    In Salesforce Classic, navigate to Develop > Custom Settings.

  2. Click Manage in the row of Global Settings.

  3. Click Edit in the Default row.
  4. Select the checkboxes Settle Credits or Settle Invoices as required.
  5. Click Save.

    This activates the batch job for the automatic settlement.

Info

JustOn executes the settlement job with the finalization batch chain. The job automatically settles credits against invoices with a positive balance, and invoices against credits with a negative balance.

Adjusting Cancellation Details

Modifying Cancellation Texts

Depending on your organization's requirements, you must modify the text building blocks for invoice cancellations. Usually, the relevant texts are included in the following fields of the Cancelation template detail (which is associated to the invoice template):

Field Description Default Value
Display Type Specifies the type of the document to be printed to the PDF. Cancelation
Info Right Defines an area for printing general information like a page counter and the date above the actual document text, can include placeholders.
Text 1 Specifies the text to be rendered above the detail table, can include placeholders.
Email Subject Defines the default email subject, can include placeholders.
Email Body Defines the plain text body for the email, can include placeholders.
Line breaks are considered.
PDF Name Specifies the name pattern for the generated PDF file, can include placeholders.

To modify the texts:

  1. Open the Cancelation template detail.
  2. Double-click the intended field and specify the corresponding text as required.

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

  3. Click Save.

Modifying Invoice Cancellation Reasons

Depending on your business requirements, you may have to add new or remove unnecessary cancellation reasons. To this end, you edit the value picklist for the Cancelation Reason field of the Invoice object.

  1. Navigate to the Cancelation Reason field of the Invoice object.
  2. In the Values section, modify the picklist values as necessary.

    • To create a new value, click New.
    • To edit an existing value, click Edit in the row of the value to be edited.
  3. Specify the details as required, then click Save.

  4. To delete a value, click Del in the row of the value to be removed, and confirm the operation.

    For help about editing picklists, see Modifying Picklist Values.

Enabling Payment Method SEPA

Your business may require a dedicated payment method that explicitly supports SEPA Direct Debit and SEPA Credit transfers. To this end, you add the picklist value SEPA to the invoice field Payment Method.

Info

Doing so will consequently limit the SEPA export to invoices with the payment method set to SEPA. At the same time, JustOn will ignore invoices with the payment method set to Direct Debit or Bank Transfer when exporting SEPA orders.

For compatibility reasons, JustOn still supports SEPA exports for invoices with the payment methods Direct Debit or Bank Transfer. Be aware, however, that for this purpose, the invoice field Payment Method must not include the picklist value SEPA.

  1. Click to enter Setup, then navigate to the PaymentMethod field of the Invoice object.
  2. In the Values section, click New.
  3. Specify the value SEPA.
  4. Click Save.

    For help about editing picklists, see Modifying Picklist Values.

Note

Transferring the payment method value SEPA using the ON field mechanism from the account or invoice source records is not sufficient. Doing so creates an inactive picklist value only, which will not allow the SEPA export.

So make sure to activate the inactive picklist value SEPA or create it in the first place, as described above.

Automation Options

Scheduling Invoice Run

You can schedule the invoice run to have invoices created automatically on a regular basis.

Parameterized Invoice Run

The scheduled invoice run may require additional options. To this end, you can set up the invoice run to be executed with additional parameters.

The following parameters are available:

Parameter Possible Values Description Example Values
Interval x(d|w|m) Specifies the invoice run period, where x is a positive or negative integer, d=day, w=week, m=month.
Defaults to 1m.
2w
x-y x and y are positive integers (1 .. 31), where x-y specifies a day range for a month. If x>y, then x is considered a day of the previous month. 1-15
Alignment previous, current or next Used to describe the Interval position relative to the execution time.
Interval = 1m and Alignment = next means that the invoice run period is the next month.
Interval = -3m (negative value) and Alignment = current means that the invoice run period is the current and the last two months.
Interval = 1w and Alignment = previous means that the invoice run period is the previous week.
If not set, defaults to previous.
next
ShiftDays x Usually, the time period calculation is based on the current date. This integer specifies a number of days by which the "anchor date" is to be moved backward or forward. -5
StartOfWeek 1 .. 7 Specifies the start day of the week, with 1 = Monday ... 7 = Sunday. Defaults to 1 if left empty. 1
InvoiceDate (start|end)(+|-)x Specifies the invoice date based on the start date or end date of the invoice run, where x is a number of days. end-5
InvoiceRunFilter <string> Specifies the name of a filter to be applied as taken from the custom setting Filters <filter name>
GenericFilters <string> Specifies the names of the generic invoice run filters to be applied as taken from the custom setting Filters (comma-separated list) <filter name list>
TransactionFilters <string> Specifies the names of the transaction filters to be applied as taken from the custom setting Filters (comma-separated list) <filter name list>
OpportunityInvoiceRunFilter <string> Specifies the name of a opportunity filter to be applied as taken from the custom setting Filters <filter name>

Info

If the calculated period and the specified filters of a scheduled invoice run belong to an existing invoice run (irrespective of whether created manually or via the scheduled job), JustOn Billing & Invoice Management adds any new invoices to the existing invoice run instead of creating a new one.

Setting up a parameterized invoice run involves two steps:

  • Defining parameters for the batch chain
  • Scheduling the batch chain
Configuring Batch Chain Parameters
  1. Click to enter Setup, then open Custom Settings.

    In Salesforce Lightning, navigate to Custom Code > Custom Settings.

    In Salesforce Classic, navigate to Develop > Custom Settings.

  2. Click Manage in the row of Batch Parameters.

  3. Click New.
  4. Specify the details as required.

    • Name: Must match the Job Name to be set when scheduling the job
    • Batch Chain: InvoiceRunChain
    • Parameter 1..8: Define batch chain-specific execution options using the syntax parameter = value, for example, Interval = 2w or Alignment = next
  5. Click Save.

InvoiceRunChain parameters examples

Create invoices for the past two weeks:

Field Value Description
Name ir_schedule_1 Must match the Job Name to be set when scheduling the job
Batch Chain InvoiceRunChain
Parameter 1 Interval = 2w Sets the invoice run period to two weeks
With the default alignment setting (Alignment = previous), the invoice run period is the past two weeks.
Parameter 2 InvoiceDate = end-1 Sets the invoice date to the penultimate day of the invoice run period
Parameter 3 InvoiceRunFilter = MySubscriptions Sets the invoice run filter to MySubscriptions, which must be defined in Filters
Parameter 4 TransactionFilters = Cases,Orders Sets the transaction filters to Cases and Orders, which must be defined in Filters

Create invoices for the next month one week before it starts:

Field Value Description
Name ir_schedule_2 Must match the Job Name to be set when scheduling the job
Batch Chain InvoiceRunChain
Parameter 1 Alignment = current Sets the invoice run period to the current interval period
With the default interval setting (Interval = 1m), the invoice run period is the current month.
Parameter 2 ShiftDays = 7 Moves the time period calculation seven days forward (so that current actually starts one week earlier)
Parameter 3 InvoiceRunFilter = MySubscriptions Sets the invoice run filter to MySubscriptions, which must be defined in Filters
Scheduling Batch Chain

To schedule the batch chain, you can use either JustOn's Scheduled Jobs page or Salesforce's Schedule Apex functionality. For details, see Scheduling a Job.

Via JustOn's Scheduled Jobs page:

  1. Open the Scheduled Jobs page.

    Use the following URL https://login.salesforce.com/apex/ONB2__JobsSetup, or, if you are already logged in, append apex/ONB2__JobsSetup to your org's domain name.

    As of JustOn 2.52, you can access the Scheduled Jobs page via the JustOn configuration app ( > JustOn Configuration > Jobs Setup).

  2. From the Apex Job drop-down list, select Batch Chain Job.

  3. In the Job Name field, specify the name of the batch parameters setting created before.
  4. From the Start Time drop-down list, select the preferred execution time.

    Your business may require to schedule multiple invoice runs. In order to prevent concurrent access to records or batch job limitations, they should, however, not run in parallel. Therefore, JustOn recommends to involve a certain time delay between the scheduled invoice runs – for example, one at 00:00, the next at 01:00, and so on. The interval may vary depending on the amount of records to be processed.

  5. Click Schedule.

    This sets up the invoice run to be executed on a regular basis at the specified time with the additional parameters set.

Info

From the Scheduled Jobs page, you can also run the batch chain immediately.

Via Salesforce's Schedule Apex functionality:

  1. Click to enter Setup, then open Apex Classes.

    In Salesforce Lightning, navigate to Custom Code > Apex Classes.

    In Salesforce Classic, navigate to Develop > Apex Classes.

  2. Click Schedule Apex on top of the list.

  3. Specify the details as required.

    • Job Name: The name of the batch parameters setting created before
    • Apex Class: ScheduledBatchChain
    • Frequency
    • Start
    • End
    • Preferred Start Time

    Your business may require to schedule multiple invoice runs. In order to prevent concurrent access to records or batch job limitations, they should, however, not run in parallel. Therefore, JustOn recommends to involve a certain time delay between the scheduled invoice runs – for example, one at 00:00, the next at 01:00, and so on. The interval may vary depending on the amount of records to be processed.

  4. Click Save.

    This sets up the invoice run to be executed on a regular basis at the specified time with the additional parameters set.

For more details about job scheduling, see Scheduling a Job in the JustOn documentation and Schedule Apex in the Salesforce Help.

Monthly Invoice Run

You can schedule the invoice run to have invoices created automatically once a month. To do so:

  1. Click to enter Setup, then open Apex Classes.

    In Salesforce Lightning, navigate to Custom Code > Apex Classes.

    In Salesforce Classic, navigate to Develop > Apex Classes.

  2. Click Schedule Apex on top of the list.

    schedule_ir_job
    Scheduling the invoice run

  3. Specify the details as required.

    • Job Name
    • Apex Class: ScheduledMonthlyInvoiceRun
    • Frequency: Monthly with an according day of month setting
    • Start
    • End
    • Preferred Start Time
  4. Click Save.

    This sets up the invoice run to be executed on a regular basis at the specified time.

For the invoice run parameters, the following values are applied by default:

Invoice Run Parameter Value
Start Date Sets the first day of the month before the invoice run has been executed
End Date Sets the last day of the month before the invoice run has been executed
Invoice Date If empty, sets the date of the invoice run execution

For more details about job scheduling, see Scheduling a Job in the JustOn documentation and Schedule Apex in the Salesforce Help.

Enabling Automatic Finalization on Invoice Run

Your organization's business may require to finalize draft invoices automatically during an invoice run when certain conditions become true.

To be able to control the automatic finalization of invoices, you add the checkbox AutoFinalize to the Invoice object. You can then apply custom logic to have this checkbox set selectively on specific records or globally on all produced records using a formula, the ON field mechanism or a Salesforce Flow.

Info

This approach differs from the finalization via flow: JustOn will only execute this operation during an invoice run, without respect to any other conditions.

  1. Navigate to the fields list of the Invoice object.
  2. Create the following new field.

    API Name Data Type Description
    AutoFinalize Formula (Checkbox)
    Checkbox
    When selected, the FinalizeInvoiceChain will run for this invoice.

    For help about creating fields, see Managing Object Fields.

    If you use a custom INVOICERUN batch chain, make sure to include the AutoFinalizeBatchHelper batch for this function to work.

Setting Up Finalization or Cancellation Using Flows

Your organization's business may require to finalize or cancel invoices automatically when certain conditions become true. To this end, JustOn provides the specific Apex class InvoiceStatusChange, which you can use to set up according flows. Depending on your use cases, you can pass the following arguments to the Apex class:

Apex Variable Value Description
Cancel Creates a draft cancellation invoice and sets the status of the original invoices to Canceled.
Finalize Finalizes the involved invoices, setting the status to Open.
Cancel + Finalize Creates a cancellation invoice that refers to the original invoice, finalizes the cancellation invoice and sets the original invoice to Canceled.

Info

JustOn 2.80 has modified the behavior of the involved Apex class InvoiceStatusChange.

Up to version 2.79, the class – and thus, the flow – synchronously executed the cancelation and finalization. This meant that after the flow execution was finished, the finalization and cancelation were also completed. However, the finalization did not include all batch classes of the FinalizeInvoiceChain but only the BatchFinalizeInvoice class. Therefore, the flow did not execute operations like settlement, balance assignment, installment creation, PDF generation, etc.

Starting with version 2.80, the flow calls the FINALIZEINVOICE batch chain to finalize the invoices. Consequently, it executes all operations of the included Apex classes (see FinalizeInvoiceChain). The batch chain runs asynchronously – this means that after the flow execution has finished, the invoice finalization is not yet completed.

The flow still executes the cancelation synchronously, though, before starting the finalization.

Note

Depending on your use cases, the flow setup and the objects to involve will vary.

  1. Click to enter Setup, then navigate to Process Automation > Flows.
  2. Click New Flow.
  3. Select Record-Triggered Flow and click Create.
  4. Configure the Start element.

    Option Description
    Object The object whose record modifications are to change the invoice status
    Trigger The type of record change that triggers the flow
    Conditions The use case-specific trigger conditions, one or more filter criteria for evaluating certain field values
    Optimize for Actions and Related Records
  5. Click and add the following Action element.

    Option Description
    Action The Apex class to call, must be Change invoice status
    Input Values Invocable variables for the Apex class
    "Cancel", "Finalize" or "Cancel + Finalize": string value that specifies the operation to be executed
    Invoice Id: specifies the invoices to be modified, usually produced via lookup relation from the original object to the related invoice, like {!$Record.ON_Invoice__r.Id}
    Cancellation Reason: optional string value that specifies a cancellation reason

    Specify a label and an API name as required.

  6. Click Save.

    Specify a label and an API name as required.

  7. Click Activate.

    When the defined conditions are met, JustOn triggers the intended operation(s).

    For help about creating flows, see Flows in the Salesforce Help.

Example use case: Cancel invoice when losing opportunity

Assume the following example: You create (draft) invoices from opportunities when they are Closed Won. Now you lose an opportunity, and you must cancel the corresponding invoice. You want this to happen automatically when you set the opportunity stage to Closed Lost.

Following this example, you need a lookup field on the Opportunity object that refers to the generated invoice.

Field Data Type Description
Invoice Lookup (Invoice) Shows the invoice that has been created for this opportunity

Then you set up the flow as follows:

Flow Element Option Value
Start Object Opportunity
Trigger A record is updated
Conditions All Conditions Are Met (AND)
1: StageName Equals Closed Lost
2: StageName Is changed {!$GlobalConstant.True}
Action Action Change invoice status
Input Values "Cancel", "Finalize" or "Cancel + Finalize": Cancel + Finalize
Invoice Id: {!$Record.ON_Invoice__r.Id}
Cancellation Reason: Invoice incorrect

This triggers JustOn to execute the flow when the opportunity is set Closed Lost: It creates a Cancelation invoice that refers to the original invoice, finalizes the cancellation invoice and sets the original invoice to Canceled.

Enabling Automatic Email Dispatch on Finalization

Your organization's business may require to send invoice or statement emails automatically upon finalization when certain conditions become true.

To support this scenario, you add the checkbox AutoSend to the Invoice or Statement object. You can then apply custom logic to have this checkbox set selectively on specific records or globally on all produced records using a formula, the ON field mechanism or a Salesforce Flow. Remember that for an invoice or statement to be considered in the email distribution, the checkbox Email Invoice or, respectively, Email Statement must be selected.

Note

For the auto send feature to work, the custom setting Auto Queue Emails After Finalization must not be selected.

  1. Navigate to the fields list of the Invoice or Statement object.
  2. Create the following new field.

    API Name Data Type Description
    AutoSend Formula (Checkbox)
    Checkbox
    When selected, JustOn Billing & Invoice Management will automatically send the emails on invoice or statement finalization.

    For help about creating fields, see Managing Object Fields.

    If you use a custom FINALIZEINVOICE batch chain, make sure to append the AutoSendInvoiceBatchHelper batch as the last batch of the chain for this function to work.

Setting Up Automatic Draft Invoice Deletion

Certain use cases may require to delete draft invoices – produced by an invoice run – based on given criteria.

As an example, assume you use the continuous invoice run to produce invoices as early as possible and to update them when required – there may be changes to the account (like a new address or bank account), to the subscription (a new item) or to the source object. These modifications may invalidate the information on already created draft invoices, which therefore must be deleted. The next continuous invoice run then regenerates the previously removed draft invoice with the correct information.

To this end, JustOn provides the specific Apex class DraftInvoiceRemover, which you can use to set up a flow to delete invalidated draft invoices.

Note

Be aware that the draft invoice remover only deletes invoices that are associated with an invoice run.

draft_invoice_remover_use_cases
Modifications on a parent or a source record trigger the draft invoice removal

Flow details
  • JustOn executes the draft invoice remover when the criteria of the flow are met.
  • The remover determines all draft invoices that are related to the records in the scope of the flow.
  • The remover queues the delete job for the draft invoices.
  • The delete job is executed until all relevant invoices are deleted.
  • The number of jobs equals the number of invoices divided by the batch scope.
  • You can monitor the jobs on the Apex Jobs page in Setup.
  • The job sends an email that lists all invoices that could not be deleted. You must delete these invoices manually.

Setting Up Draft Invoice Remover Flow

Note

Depending on your use cases, the flow setup and the objects to involve will vary.

  1. Click to enter Setup, then navigate to Process Automation > Flows.
  2. Click New Flow.
  3. Select Record-Triggered Flow and click Create.
  4. Configure the Start element.

    Option Description
    Object The object whose record modifications are to trigger the draft invoice deletion
    For use case A, the invoice parent (account/subscription), related like Invoice → invoice parent via lookup or formula with CASESAFEID()
    For use case B, the invoice source object, related like invoice source → Invoice via lookup or formula with CASESAFEID()
    For objects marked as single source object, that is, where ON_IsItem = true, the use case B applies.
    Trigger The type of record change that triggers the flow, must be A record is created or updated
    Conditions The use case-specific trigger conditions, one or more filter criteria for evaluating certain field values
    Optimize for Actions and Related Records
  5. Click and add the following Action element.

    Option Description
    Action The Apex class to call, must be Remove draft invoices
    Input Values Invocable variables for the Apex class
    Is Parent: is to be set True for invoice parents (use case A), False for invoice sources (use case B)
    Lookup Field Name: string value that specifies the API name of the relevant ID field, for the invoice parent (use case A) located on the invoice (for example, Account__c), for the invoice source (use case B) located on the source object (usually ON_Invoice__c)
    Object Id: the ID field of the related object, for the invoice parent (use case A) the ID of the parent object, for the invoice source (use case B) the ID of the source object

    Specify a label and an API name as required.

  6. Click Save.

    Specify a label and an API name as required.

  7. Click Activate.

    When the defined conditions are met, JustOn triggers the intended operation(s).

    For help about creating flows, see Flows in the Salesforce Help.

Flow configuration examples

draft_invoice_remover_use_cases

Following the two use cases, the corresponding flow configurations may result like this:

Flow Element Option Example Values Use Case A
Identify and delete draft invoices for an account whose bank account information has been modified
Example Values Use Case B
Identify and delete draft invoices from an order whose effective date has been modified
Start Object Account Order
Trigger A record is created or updated A record is created or updated
Conditions ON_BankAccount__c Is changed {!$GlobalConstant.True} EffectiveDate Is changed {!$GlobalConstant.True}
Action Action Remove draft invoices Remove draft invoices
Input Values Is Parent: {!$GlobalConstant.True}
Lookup Field Name: Account__c
Object Id: {!$Record.Id}
Is Parent: {!$GlobalConstant.False}
Lookup Field Name: ON_Invoice__c
Object Id: {!$Record.Id}

Configuring Batch Scope

The invoices are deleted by a queueable asynchronous batch process in order to keep the governor limits under control. This also enables bulk operations on parent and child objects with larger batch sizes than a usual invoice deletion would allow.

  1. Click to enter Setup, then open Custom Settings.

    In Salesforce Lightning, navigate to Custom Code > Custom Settings.

    In Salesforce Classic, navigate to Develop > Custom Settings.

  2. Click Manage in the row of Batch Settings.

  3. Click New.
  4. Specify the details as necessary.

    • Name: DraftInvoiceRemover
    • Scope: 50
  5. Click Save.

Info

Be aware of the following specifics:

  • The scope depends on the number of objects and relationships. Test the setting to determine the appropriate value. A larger scope may work, but can can produce limit exceptions.
  • Limit exceptions are reported by email. If necessary, reduce the scope accordingly.

Excluding Draft Invoices From Deletion

You can exclude the draft invoices produced in an invoice run from the deletion by the draft invoice remover flow. To do so, mark the corresponding invoice run as final.

  1. Open the Invoice Runs tab.
  2. Click the number of the invoice run whose draft invoices you want to exclude from deletion.
  3. Double-click the Is Final checkbox and select it.

    Alternatively, you can click Edit in the invoice run view and then select the Is Final checkbox.

  4. Click Save.

    This excludes the draft invoices produced by the current invoice run from deletion by the draft invoice remover flow.