action.skip

Enabling Deposit Invoices

Certain business use cases require merchants or suppliers to ask their customers for advance payments. To this end, JustOn allows for creating deposit invoices.

JustOn Billing & Invoice Management supports deposit invoices when billing arbitrary objects and billing opportunities.

Basically, the creation of a deposit invoice is controlled using the ON field ON_Type on the source object. If this field is set to Deposit, JustOn generates a deposit invoice.

In order to request an advance payment with your deposit invoice, use the ON fields ON_DepositRate or ON_DepositAmount. Depending on your use case, you can then specify either a percentage value of the invoice total or a fixed amount as the deposit.

For details on deposit invoices in JustOn, the usual workflow, their structure, etc., see Deposit Invoices.

Enabling deposit invoices in JustOn involves the following tasks:

If required, you can optionally

Adding Deposit Invoice Fields to Source Objects

In order to hold the required deposit invoice data, you must add new fields to the source object. Remember that JustOn Billing & Invoice Management supports deposit invoices when billing arbitrary objects and billing opportunities, so the source object can be any object if you use the generic invoice run or the Opportunity object.

Info

You add the deposit invoice fields to the source object in addition to the fields required for billing arbitrary objects or, respectively, opportunity billing.

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

    API Name Data Type Description
    ON_Type Text (255) Must be set to Deposit in order to create deposit invoices. Is cleared automatically when the deposit invoice is closed.
    ON_ProformaInvoice Lookup (Invoice) Shows the related pro forma or deposit invoice.

    To have JustOn create a deposit line item, create one of the optional fields:

    API Name Data Type Description
    ON_DepositRate Percent (3,2) If set, JustOn creates a deposit line item with an amount of Deposit Rate * Total on the deposit invoice.
    If both a deposit rate and a deposit amount is defined, the amount takes precedence.
    ON_DepositAmount Currency (16,2) If set, JustOn creates a deposit line item with the specified amount on the deposit invoice.
    If both a deposit rate and a deposit amount is defined, the amount takes precedence.

    For help about creating fields, see Managing Object Fields.

Info

If you need multiple billing configurations when billing arbitrary objects, JustOn must distinguish between different sets of field configurations using control field suffixes. To this end, append recipient-specific suffixes to the ON fields, as explained in Enabling Deposit Invoices for Multiple Parties.

Configuring Deposit Invoice Display

Adjusting Invoice Texts

Usually, a deposit invoice needs other texts on the printed document than the final invoice. You can therefore define a template detail – named Deposit – to provide appropriate texts.

For further information about template details and invoice PDF contents, see Configuring Template Details and PDF Contents.

The following fields are relevant on the template and the template detail:

Field Description Example Target
Display Type Specifies the type of the invoice to be printed to the PDF. It should reflect the nature of the pro forma or deposit invoice. Advance Invoice Template Detail
Text 2 Text to be rendered below the invoice line item table. Use it, for example, to describe how the deposit can be made (bank account etc.) and to specify the payment terms. Template Detail
Deposit Title Short description of the nature of the deposit
This field is mandatory if you have set a deposit rate or a deposit amount.
Advance Payment (50%) Template
Deposit Description Long description of the nature of the deposit Template
  1. Open the template or template detail to be edited.
  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.

Adjusting Spacing Between Deposit Invoice Line Item Table Parts

As explained in Deposit Invoice Structure, the deposit invoice first lists the invoice line items as Information type invoice line items, then shows an invoice line item of the type Deposit, which represents the advance payment. In order to visually separate the two table parts, add the following custom CSS rule to the invoice template:

  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.

    tr.Deposit.firstRowAfterSubtotal td {
        padding-top: 2.5em;
    }
    
  3. Click Save.

Enabling Deposit Gross Display

As explained in Deposit Invoice Structure, the deposit invoice lists the invoice line items as Information type invoice line items, followed by a subtotal section with tax breakdown. Optionally, you can display a line that shows the gross value for the Information type invoice line items.

To do so, add the following custom CSS rule to the invoice template:

  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.

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

Configuring Final Invoice Display

In the event of a final invoice with existing deposit payments, the invoice PDF shows additional information about the received payments and the final payments below the grand total. The corresponding sections include a detailed tax breakdown.

Example final invoice
Pos. Title Tax Rate Net Price
1 Some Goods 20% 1000
2 Some Service 20% 500
Subtotal Net 1500
Tax Amount 300
Deposit Gross 1800
Received Payments Net 750
Received Payments Tax 150
Received Payments Gross 900
Remaining Final Payment Net 750
Remaining Final Payment Tax 150
Remaining Final Payment Gross 900
Payment Amount 900

You can define the display of the grand total label using the template field Deposit Grand Total Label. The field can contain placeholders. It is used only for final invoices with deposit payments – in all other cases or if the field is empty, the invoice PDF shows the label of the invoice field Grand Total, which is the standard behavior. The other fields use custom labels.

Using custom CSS, you can adjust the positioning, layout, etc. according to your needs.

Label Custom Label Description
Grand total The total amount of the invoice.
Received Payments (net) ReceivedPaymentsNet The calculated total net amount of all payments received on the related deposit invoice. This is the sum of all balance amounts that are related to the deposit invoice without taxes. The tax rate is taken from the field TaxRate__c of the Deposit line item of the related deposit invoice.
Tax on Received Payments ([TaxRate]) ReceivedPaymentsTax Taxes on the total net amount of the payments received. The placeholder [TaxRate] is replaced by the actual value, like 7%.
Received Payments (gross) ReceivedPaymentsGross Total gross amount of the payments received. The display is disabled by the default CSS rules.
Remaining Final Payment (net) FinalPaymentNet The remaining net final payment amount.
Tax on Remaining Final Payment FinalPaymentTax Taxes on the remaining net final payment amount.
Remaining Final Payment (gross) FinalPaymentGross Remaining gross final payment amount. The display is disabled by the default CSS rules.

Info

Use overrides to overwrite the values of the custom labels.

Creating Flow for Closing Deposit Invoices

Closing deposit invoices requires a flow that calls the appropriate Apex class provided by JustOn. It closes the deposit invoice and prepares the source object for creating the final invoice (for details, see Deposit Invoice Closure).

Note

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

The source object for the flow depends on the object that is used for deposit invoicing:

Info

You can use multiple billing configurations when billing arbitrary objects with different sets of field configurations using recipient-specific suffixes. In this case, create an individual flow with an individual trigger for each configuration.

Set up the flow as follows:

  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 close the deposit invoice
    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 Close Proforma Invoice
    Input Values Invocable variables for the Apex class
    Object Id: the ID field of the original object, like {!$Record.Id}
    Suffix: string value that specifies a recipient-specific suffix, required when using multiple flows for multiple billing configurations

    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 closes the deposit invoice and prepares the source record for creating the final invoice.

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

Note

Make sure that closing a deposit invoice from its detail view using the Close button does not trigger the configured flow for closing deposit invoices from source records. This may produce errors.

Example use case: Set a checkbox to start the close flow

Assume you create invoices from orders. You can, for example, use a custom checkbox field ON_CloseProformaInvoice on the order to trigger the flow when the checkbox is selected.

(1) Create the custom checkbox:

API Name Data Type
ON_CloseProformaInvoice Checkbox

(2) Set up the flow as follows:

Flow Element Option Value
Start Object Order
Trigger A record is updated
Conditions All Conditions Are Met (AND)
1: Close Proforma Invoice Equals {!$GlobalConstant.True}
2: Close Proforma Invoice Is changed {!$GlobalConstant.True}
3: ON_ProformaInvoice__c Is null {!$GlobalConstant.False}
Action Action Close Proforma Invoice
Input Values Object Id: {!$Record.Id}

This triggers JustOn to execute the flow when the ON_CloseProformaInvoice checkbox is selected: It closes the deposit invoice and prepares the source record for creating the final invoice (for details, see Deposit Invoice Closure).

Enabling Deposit Invoices for Multiple Parties

Generally, JustOn is set up to issue invoices to one recipient, usually via the account associated to the corresponding source record. Certain business use cases require billing to multiple parties, however – like, for example, in a marketplace scenario.

  1. Create multiple (recipient-specific) sets of ON fields as listed in Adding Deposit Invoice Fields to Source Objects.

    For details, see Creating Recipient-Specific Controlling Fields.

  2. Create an individual closing flow with an individual trigger for each configuration set, specifying the corresponding recipient-specific suffix as an Apex variable.

    Flow Name Trigger Control Field Suffix
    Close Deposit Merch checkbox Close_Merch Merch
    Close Deposit Buy checkbox Close_Buy Buy

Creating Deposit Invoice and Final Invoice From Different Sources

Your business may require to create a deposit invoice from one source object and the related final invoice from another – using the generic invoice run in both cases. Think of the Salesforce CPQ process, for example: You can create the deposit invoice from a quote, and the final invoice from a CPQ subscription that is based on this quote.

In addition to the original deposit invoicing configuration, this approach involves the following steps:

  1. Set the deposit invoice fields on the two source objects.

    The first source object – the one from which you create the deposit invoice – requires these fields to hold the relevant deposit invoice data:

    API Name Description
    ON_Type Must be set to Deposit in order to create the deposit invoics.
    ON_ProformaInvoice Lookup the related deposit invoice.
    ON_DepositRate |
    ON_DepositAmount
    Used to set or calculate the price of the deposit line item to be created.

    The second source object – the one from which you create the final invoice – requires the following fields:

    API Name Description
    ON_Type Must be set to Final in order to create the final invoice.
    ON_ProformaInvoice Lookup the related deposit invoice.

    You add the deposit invoice fields to the source object in addition to the fields required for billing arbitrary objects.

    For details, see Adding Deposit Invoice Fields to Source Objects.

  2. Relate the deposit invoice with the second source object.

    The lookup field ON_ProformaInvoice on the second source record must point to the deposit invoice created from the first source record.

    According to your project requirements, this relation can be set

    • automatically using a dedicated custom flow (or an additional action in the deposit invoice closing flow)
    • automatically using other automation means on record creation, depending on the involved object
    • manually through user input

Other required tasks include:

Workflow outline

Once set up, the solution may work as follows:

deposit_2_sources
Creating deposit invoice and final invoice from different sources

(1) JustOn generates a deposit invoice if the field ON_Type on the first source record is set to Deposit. Using the fields ON_DepositRate or ON_DepositAmount, you set the price of the deposit line item to be created. The field ON_ProformaInvoice on the source record points to the deposit invoice.

On payment registration, JustOn assigns the corresponding payment balance to the deposit invoice.

(2) When appropriate, you close the deposit invoice. In particular, this

  • unassigns the payment balance from the deposit invoice, and
  • creates the lookup between the second source record and the deposit invoice, that is, sets ON_ProformaInvoice on the second source record.

(3) With both ON_Type set to Final and ON_ProformaInvoice pointing to the deposit invoice on the second source record, JustOn generates the final invoice. It registers the payment balance, which has been previously unassigned from the deposit invoice, with the final invoice. Doing so reduces the final payment amount.

Enabling Dunning Reminders for Deposit Invoices

By default, pro forma invoices and deposit invoices are exempt from dunning processes. When users try to create dunning reminders for pro forma invoices or deposit invoices, JustOn shows the following error message:

Error: Only invoices that are due for payment are subject to dunning processes.

If your business, however, requires issuing reminders for pro forma invoices or deposit invoices, you must explicitly enable this option using the corresponding global setting Allow Pro Forma / Deposit Dunnings.

  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 Allow Pro Forma / Deposit Dunnings.
  5. Click Save.