Skip to content

JustOn Invoice Statistics

JustOn Invoice Statistics is an add-on to JustOn that prepares invoice-related statistical data.

Info

JustOn Invoice Statistics requires at least the Salesforce Enterprise Edition.

JustOn Invoice Statistics Concepts

JustOn Invoice Statistics copies certain invoice and invoice line item information to dedicated objects (Invoice View and Invoice Line Item View) that allow for an easily accessible statistics evaluation.

Workflow

The Invoice Statistics Job, which is shipped with the add-on, generates the statistical data. If there are no statistics records available, the job creates them for each invoice and invoice line item. If there are existing statistics records, the job

  • deletes orphaned records, that is, statistics that do no longer relate to an invoice or invoice line item,
  • deletes records that point to canceled invoices, and
  • creates or updates statistics records for every invoice modified in the last five days.

Generally, the ways to access the generated statistics records may vary depending on your business or organization requirements. The possible options include, among others:

Invoice View Object

By default, the Invoice View object (API name ONBIS2__InvoiceStatistic__c) holds the following statistics-relevant information. The values are copied from the corresponding invoice fields:

  • Account
  • Balance
  • Date
  • Days Overdue
  • Dunning Level
  • GrandTotal
  • Payment Date
  • Status
  • Subscription
  • Total Net

In addition to the copied data, there are specific fields that hold calculated values:

Field Contents Description
Last Opportunity Lookup to an opportunity Links to the most recent opportunity that has been billed to this invoice. The value is taken from the invoice line item with the highest sequence number.
Opportunities Rich text field with opportunity names and links Specifies a list of names and links to all opportunities that may be combined with the current invoice.
No Update Checkbox (default false) Marks statistical data that does not link to an invoice, like imported legacy data. If selected, the corresponding statistics will not be deleted by the job.

Info

If required, you can add more fields to the Invoice View object to provide for more statistical information.

Invoice Line Item View Object

By default, the Invoice Line Item View object (API name ONBIS2__InvoiceLineItemStatistic__c) holds the following statistics-relevant information. The values are copied from the corresponding invoice line item fields:

  • Pos. Total (net)
  • Product Group
  • Quantity
  • Title
  • Unit
  • Unit Price (net)

Info

If required, you can add more fields to the Invoice Line Item View object to provide for more statistical information.

Setting Up JustOn Invoice Statistics

Info

JustOn Invoice Statistics requires at least the Salesforce Enterprise Edition.

Contact the JustOn support team to have the add-on installed in your org.

Setting up JustOn Invoice Statistics involves the following tasks:

Configuring User Permissions

Due to technical restrictions, JustOn Invoice Statistics does not provide permission sets. Hence, you must create them from scratch and assign them to the intended users.

JustOn recommends to create two different permission sets:

Permission Set Permissions Notes
Full Access Full access to the Invoice View object and all its fields To be assigned to the user who creates the statistics.
This user also needs a JustOn license and at least read access to JustOn.
Read Only Read access to the Invoice View object and all its fields Can be assigned to any user who needs to access the statistics, irrespective of a JustOn license.

Related information:

Create Permission Sets in the Salesforce Help
Assign Custom Record Types in Permission Sets in the Salesforce Help
Assign Permission Sets to a Single User in the Salesforce Help

Configuring Batch Settings

To provide for a smooth operation, JustOn recommends to define custom batch settings for the included statistics batch processes.

  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 Batch Settings.

  3. Create the following new records.

    Name Scope Notes
    BatchInvoiceStatisticsRemover 2000 Removes orphaned statistic records.
    BatchInvoiceStatisticsUpdater 500 Creates/updates statistic records.
    Reduce the scope if there are limit exceptions upon execution.

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 produce limit exceptions.
  • Limit exceptions are reported by email. If necessary, reduce the scope accordingly.

Scheduling Invoice Statistics Job

When scheduling the automatic invoice statistics generation, be aware of the following specifics:

  • Setting a frequent interval may cause problems if the execution duration of the job exceeds the defined interval.
  • A running invoice statistics job may prevent other jobs, like invoice run or PDF generation, from being executed.

To schedule the Invoice Statistics Job, you use 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/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 (App Launcher > JustOn Configuration > Jobs Setup).

  2. From the Apex Job drop-down list, select Invoice Statistics Job.

    In the Job Name field, JustOn automatically sets CreateInvoiceStatistics.

  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 statistics generation process to be executed at the specified time.

Info

For testing purposes, you can also run the batch chain immediately from the Scheduled Jobs page.

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

Disabling Invoice Line Item Statistics

Depending on your requirements, you may not need to export invoice line item data. To disable the invoice line item statistics generation:

  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 Global Settings.

  3. Click Edit in the Default row.
  4. Select the checkbox Disable Statistic Line Items.
  5. Click Save.

Creating Additional Statistics Fields

The Invoice Statistics Job copies the values of all fields from the invoice and the invoice line item to the fields that are available on the invoice view or, respectively, the invoice line item view. For this to work, the job expects the fields to have identical API names.

If required, you can add more fields to the Invoice View or Invoice Line Item View objects to provide for more statistical information. Once added, the field is filled upon the next update, that is, the next job execution.

Note

Be aware that the job expects the additional fields must have the same API names as the original invoice or invoice line item fields.

For help about creating fields, see Managing Object Fields.

Creating Roll-Up Summary Account Fields

The Invoice View object is in a master-detail relationship with the Account object. It is therefore possible to create roll-up summary fields on the Account object that can provide additional account-level statistics.

Example: Account Balance

You can display the account balance in the account detail view. To do so, create a roll-up summary field applying the following details:

Field Parameter Value
Summarized Object Invoices View
Roll-Up Type SUM
Field to Aggregate Balance
All records should be included in the calculation true
Example: Number of Invoices

You can show the overall number of successfully generated invoices. To do so, create a roll-up summary field applying the following details:

Field Parameter Value
Summarized Object Invoices View
Roll-Up Type COUNT
Only records meeting certain criteria should be included in the calculation true
Criteria Status not equal to Canceled

Enabling Invoice View List Display

You can enable the display of related invoice statistics records on the account detail page using Salesforce's related list functionality (see Work with Related Lists on Records in the Salesforce Help).

  1. Navigate to the object management settings of the Account object
  2. Click Page Layouts.
  3. In the Account Layout row, click Edit.
  4. Select the Related Lists palette.
  5. Drag the Invoices View list to the Related Lists section.
  6. Click Save to save the modified page layout.

For help about modifying page layouts, see Managing Pages.