action.skip

Best Practice: Down-Payment Invoicing

Certain business models require companies to make advance contributions for a deal – like project-specific purchases of supplies, upfront deliveries, etc. In such cases, companies may demand down payments from their customers to ensure that the customers will follow through with the orders they place. The advance payment is then to be offset with a final invoice.

A typical process may be:

(1) customer places order

(2) company issues advance invoice

(3) customer executes advance payment, company registers payment entry

(4) company delivers order and tracks actual consumption

(5) company issues final invoice, offsetting the advance payment

(6) customer executes final payment, company registers payment entry

Now assume that a company controls their deals, involved products etc. using opportunities and opportunity products in Salesforce, and wants to create the down-payment invoices and the final invoices out of them. Enter JustOn: To cover this use case, you combine JustOn's opportunity billing and deposit invoicing.

Doing so, the typical process as outlined above breaks down to the following main steps:

Stage Operation in Salesforce Operation in JustOn
Customer requests delivery Create opportunity
Company makes proposal Update opportunity, create opportunity products
Customer and company negotiate scope and conditions Create/update opportunity products
Customer accepts proposal/places order Update opportunity to stage won (or similar) Create deposit invoice from opportunity, triggered by opportunity update to won
Customer executes advance payment Register payment entry
Create (deposit) payment balance
Company delivers negotiated goods Update opportunity to stage delivered (or similar) Close deposit invoice, triggered by opportunity update to delivered
Unregister (deposit) payment balance from deposit invoice
Company registers actual consumption Update opportunity products
Company signals completion Update opportunity to stage complete (or similar) Create final invoice from (updated) opportunity, triggered by opportunity update to complete
Register (deposit) payment balance with final invoice, reducing the grand total
Customer executes final payment Register payment entry
Create (final) payment balance
Move final invoice to status Paid

uc_oppy_pfi
Combining opportunity billing with deposit invoices

Modeling this business use case with JustOn comprises at least these configuration tasks:

Info

Once set up as outlined in the example, JustOn automatically

  • creates the deposit invoice when you set your opportunity to won
  • closes the deposit invoice when you set your opportunity to delivered
  • creates the final invoice when you set your opportunity to complete

Adding Invoicing Fields to Opportunity

In order to hold the required invoicing data, you must add new fields to the Opportunity object.

  1. Navigate to the fields list of the Opportunity object.
  2. Create the following new fields as required.

    Mandatory fields

    Field Label API Name Data Type Description
    Invoice Run ON_LastInvoiceRun Lookup (Invoice Run) Shows the last invoice run that has processed this opportunity
    Last Error ON_LastError Text (255) Shows possible errors occurred during the last invoice run

    Optional fields

    Field Label API Name Data Type Description
    Email Contact ON_EmailContact Lookup (Contact)
    or
    Formula (Text)
    Shows a related contact
    Gross Invoice ON_GrossInvoice Boolean True if a gross invoice is to be generated
    Email Invoice ON_EmailInvoice Boolean True if the invoice is to be be sent via email
    Print Invoice ON_PrintInvoice Boolean True if the invoice is to be be printed

    For help about creating fields, see Managing Object Fields.

Info

You can add more fields using the ON field mechanism.

Creating Opportunity Filters

To define which opportunities to include in the invoice run, you create custom filters.

Info

At least one filter is required.

  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 Filters.

  3. Create opportunity filter(s) as required, following the examples below.

    For opportunity filters, a condition is mandatory.

    For help about creating filters, see Filters.

Following the example, create these filters:

Name Target Condition Notes
Won Opportunity StageName = 'won' Used when creating the deposit invoice
Complete Opportunity StageName = 'complete' Used when creating the final invoice

Adding Deposit Invoice Fields to Opportunity

In order to hold the required deposit invoice data, you must add new fields to the source object, that is, the Opportunity object.

  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.

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.

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.

Following the example, you want the flow to be triggered when the opportunity is moved to the stage delivered.

  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 Value
    Object Opportunity
    Trigger A record is updated
    Conditions All Conditions Are Met (AND)
    1: StageName Equals delivered
    2: StageName Is changed {!$GlobalConstant.True}
    3: ON_ProformaInvoice__c Is null {!$GlobalConstant.False}
    Optimize for Actions and Related Records
  5. Click and add the following Action element.

    Option Value
    Action Close Proforma Invoice
    Input Values Object Id: {!$Record.Id}

    Specify a label and an API name as required.

  6. Click Save.

    Specify a label and an API name as required.

  7. Click Activate.

    This triggers JustOn to execute the flow when the opportunity is moved to the stage delivered: It closes the deposit invoice and prepares the opportunity for creating the final invoice.

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

Related information:

Enabling Opportunity Billing
Enabling Deposit Invoices
Executing an Opportunity Invoice Run