Skip to content

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 pro forma billing.

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 pro forma invoice (including advance payment) from opportunity, triggered by opportunity update to won
Customer executes advance payment Register payment entry
Create (advance) payment balance
Company delivers negotiated goods Update opportunity to stage delivered (or similar) Close pro forma invoice, triggered by opportunity update to delivered
Unregister (advance) payment balance from pro forma 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 (advance) 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 pro forma billing

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 pro forma invoice when you set your opportunity to won
  • closes the pro forma 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.
    For help about creating fields, see Managing Object Fields.

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

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. In Setup, 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 pro forma invoice
Complete Opportunity StageName = 'complete' Used when creating the final invoice

Adding Pro Forma Billing Fields to Opportunity

In order to hold the required pro forma billing 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 as required.
    For help about creating fields, see Managing Object Fields.

Mandatory fields

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

Optional fields

Field Label API Name Data Type Description
Deposit Rate ON_DepositRate Percent (3,2) If set, JustOn creates a deposit line item with an amount of Deposit Rate * Total on the pro forma invoice.
If both a deposit rate and a deposit amount is defined, the amount takes precedence.
Deposit Value ON_DepositValue Currency (16,2) If set, JustOn creates a deposit line item with the specified amount on the pro forma invoice.
If both a deposit rate and a deposit amount is defined, the amount takes precedence.
Close Pro Forma Invoice ON_CloseProformaInvoice Checkbox Can be used to trigger the process to close the pro forma invoice.

Configuring Pro Forma Invoice Display

Adjusting Pro Forma Invoice Texts

Usually, pro forma invoices need other texts on the printed invoice than the final invoice. You can therefore define a template detail named Proforma 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 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.
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 Invoice Line Item Table Parts

As explained in Pro Forma Invoice Structure, the pro forma 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:

tr.Deposit.firstRowAfterSubtotal td {
    padding-top: 2.5em;
}
  1. Open the template to be edited.
  2. In the Layout & Design section, double-click the Custom CSS field and specify the CSS code as required.
    Alternatively, you can click Edit in the detail view to edit the field.
  3. Click Save.

Enabling Pro Forma Gross Display

As explained in Pro Forma Invoice Structure, the pro forma 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:

.invoice-table .subtotal-calculated.criteria-forced.gross {
    display: table-row;
}
  1. Open the template to be edited.
  2. In the Layout & Design section, double-click the Custom CSS field and specify the CSS code as required.
    Alternatively, you can click Edit in the detail view to edit the field.
  3. Click Save.

Creating Process for Closing Pro Forma Invoices

Closing pro forma invoices requires a process that calls the appropriate Apex class provided by JustOn. The process criteria that start the execution depend on your use cases. Following the example, you want the process to be triggered when the opportunity is moved to the stage delivered.

  1. In Setup, open Process Builder.
    In Salesforce Lightning, navigate to Process Automation > Process Builder.
    In Salesforce Classic, navigate to Create > Workflow & Approvals > Process Builder.
  2. Click New.
  3. Specify a name and an API name as required.
  4. Set the process to start when A record changes.
  5. Click Save.
  6. Select Opportunity as the object whose modifications are to close the pro forma invoice.
  7. Set the process to start when a record is created or edited.
  8. Define the process criteria as required.
    • [Opportunity].StageName Is changed True
    • [Opportunity].StageName Equals Picklist delivered
    • [Opportunity].ON_ProformaInvoice__c Is null False
      Combine the conditions with logical AND, that is, select All of the conditions are met.
  9. Select Apex as immediate action, and specify the class Close Proforma Invoice.
  10. Set the following Apex variables:
    • For Object Id, set the Field Reference value [Opportunity].Id.
  11. Click Save.
  12. Click Activate.

Related information:

Enabling Opportunity Billing
Enabling Pro Forma Billing
Executing an Opportunity Invoice Run