action.skip

Invoice Line Items

← About Invoices

Invoice line items represent the individual billable positions of an invoice. Usually, they originate from items when billing subscriptions, or, with the generic invoice run, from arbitrary source records. In addition, users can create them manually.

Info

You can customize the invoice line item display on the invoice PDF using custom CSS rules.

Invoice Line Item Types

Invoice line items can be of different types.

Type Description
Product Default type, subject to the subtotal calculation. Is displayed in the invoice line item table, with the price broken down to net price, discounts, taxes.
Shipping Fees Specific type for applicable shipping fees. Is included after the subtotal calculation and, by default, displayed as a net value below the invoice line item table.
Handling Fees Specific type for applicable handling fees. Is included after the subtotal calculation and, by default, displayed as a net value below the invoice line item table.
Information Specific type for items that are put on the invoice for informational purposes only, exempt from the total calculation. Is displayed in the invoice line item table, including any defined price, but is ignored on calculation.
Deposit Specific type for deposit invoices, is produced when a deposit rate or a deposit value is defined. Is usually displayed in the invoice line item table, with the price broken down to net price and taxes.
None
or any other custom type
Specific type for "hidden" items. Is not displayed but included in the calculation.

Invoice Line Item Calculation

Except for net or gross, there are numerous other parameters that control an invoice line item's price. The calculation is fairly complex – so which data comes into play at what stage?

Think of a three-tier calculation process.

Unit price and quantity information

ILI_calc_1_qty

First, JustOn multiplies the unit price with the provided quantity information and, in case of recurring items, with the billing factor. This makes up the position price.

  • The unit price can be a fixed amount, an aggregated value, or an individual price determined by some custom condition – that depends on your invoice line item source data. For commission pricing, however, the given unit price is multiplied with the commission rate before proceeding.
  • The quantity is taken from the invoice line item source data as well. You either propagate a given value from the order, quote, subscription, etc., or have aggregated some usage data count. If your business usually handles very large quantities, you can use a custom factor to produce "manageable" quantity values.
  • The billing factor is a multiplier that is relevant with recurring items, where JustOn must consider the billing period (the time interval after which the item is subject to the invoice run), given in a billing unit. For example, the billing unit Month combined with the billing period 3 results in a billing factor of 3, that is, the recurring item is invoiced every three months with the price multiplied by three.

    The recurring item's billing period determines the resulting invoice line item's service period.

Discount information

ILI_calc_2_dct

Once the position price is determined, JustOn deducts the applicable discounts:

  • The item-based discount is individually applied to an invoice line item, based on a given percentage or fixed amount.
  • The order discount amount is the invoice line item's "share" of the order discount, which originally reduces the (net) subtotal of the complete invoice.

Deducting the discounts results in the position price discounted.

Tax information

ILI_calc_3_tax

Unless you use gross invoicing, JustOn finally adds the applicable taxes. You can either:

  • Feed a precalculated tax from an external system, or
  • Have JustOn internally determine the calculated tax based on the discounted position price and one or more tax rates – most probably determined by tax rules.

This calculation produces the position total gross price, which, in turn, becomes part of the invoice's grand total.

Invoice Line Item Rounding

Depending on the JustOn Billing & Invoice Management version, the invoice line item price calculation applies different rounding approaches:

  • With the invoicing engine v1, the rounding of invoice line item amounts has been done as late as possible: CalculatedTax, PosTotalNet, PosTotalTax, PosTotalGross.
  • With the invoicing engine v2 (as of JustOn 2.88), PosPriceDiscountedNoAE and hence, PosPriceDiscounted are rounded already, so that CalculatedTax, PosTotalNet, PosTotalTax and PosTotalGross are calculated from rounded values.

    This approach is in line with common third-party applications like XRechnung e-invoices, Basware or accounting systems, preventing possible integration or synchronization issues.

As of JustOn Billing & Invoice Management v2.88, the Invoice Line Item field Invoicing Engine controls the rounding approach.

Value Description
1 (or empty) Indicates that the old rounding mode is applied. The discounted position price is calculated using all passed decimal places, and the rounding is done only on CalculatedTax, PosTotalNet, PosTotalTax, PosTotalGross.
2 Indicates that the new rounding mode is applied. The discounted position price is rounded already, passing the rounded value to the tax calculation and order discount application.

For new invoices, Invoicing Engine is set to 2, indicating that PosPriceDiscountedNoAE and PosPriceDiscounted are rounded for all newly created invoices. For existing invoices after upgrading from a previous JustOn version, Invoicing Engine is empty, indicating that the previous rounding mode is applied.

Info

For details on the invoice line item calculation, see Invoice Line Item Fields and Formulas.

Rounding on Invoice Cancellation

When canceling an invoice, the cancellation invoice uses the same invoicing engine as the canceled (original) invoice. This ensures that there will be no amount differences between the canceled (original) invoice and the cancelation invoices.

If you create a new invoice from the same source data, however, you may get a different amount. Assume the following scenario:

(1) You have created an invoice with a JustOn version <2.88, that is, using the invoicing engine v1.

(2) You upgrade JustOn Billing & Invoice Management to v2.88 or newer.

(3) You notice that the previously produced invoice is not correct – you cancel it. The cancellation invoice uses the same invoicing engine v1.

(4) You create a new, correct invoice from the same source data. Now the new invoice uses the invoicing engine v2, applying the new rounding mechanism – which may produce slightly different amount values.

Rounding on Invoice Cloning

When cloning an invoice, the new invoice always uses the invoicing engine v2, regardless of the invoicing engine used for the original invoice. Since the invoicing engine may be different between the original and the new invoice, there may be some rounding-related differences in the invoice line item amounts.

Decimal Places

With multiple currencies enabled, you can specify the number of decimal places (number of digits to the right of decimal point) for each currency. Consequently, JustOn takes the number of decimal places used for a specific currency from the relevant currency configuration, copying it to the field Decimal Places of the invoice line item. This value is then used to round amounts in certain formulas when calculating the invoice line item price, taxes, etc.

When calculating invoices, JustOn uses best-practice, sensible defaults for decimal places.

(1) First, JustOn multiplies the unit price with the provided quantity information and, in case of recurring items, with the billing factor. This makes up the position price. The corresponding fields have five decimal places.

ILI+inv_calc_1_pos

(2) After the position price is determined, JustOn deducts the applicable discounts. This results in the position price discounted, which also has five decimal places.

ILI+inv_calc_2_pos

(3) JustOn then adds the applicable taxes. You can either feed a precalculated tax from an external system, or have JustOn internally determine the calculated tax based on the discounted position price and one or more tax rates (as defined by tax rules). The tax values are input with two decimal places.

ILI+inv_calc_3_pos_total

This calculation produces the position total gross price, which is rounded to two decimal places.

(4) Finally, JustOn sums the position total gross prices, producing the invoice's grand total, which also has two decimal places.

ILI+inv_calc_4_gr_total

Info

This calculation is independent of the configured decimal places display on PDF files.

There are several settings that control the number of displayed decimal places. JustOn applies the settings in the following order:

  1. Decimal Places on the template
  2. Decimal Places for Unit Price and Decimal Places for Quantity on the invoice line item
  3. Decimal Places for Unit Price and Decimal Places for Quantity in the global settings
  4. Global default: two decimal places for all numeric values

If one setting is not set or not found, JustOn falls back to the next one.

Implementation details

JustOn falls back to two decimal places if multiple currencies are not enabled, no currency set up for an invoice, or if the field Decimal Places is not (yet) set for an invoice line item.

To avoid inconsistencies, make sure to not change the value of the invoice line item field Decimal Places manually, because other parts of the business logic (not immediately related to the invoice line item price calculation) also use the decimal places configuration.

Be aware of the following limitations:

  • Currently, JustOn supports only 0, 1 or 2 decimal places.

    If you specify more than 2 decimal places, JustOn automatically limits their number to 2 to prevent errors.

  • The following features currently ignore the decimal places configuration:

    • Installments
    • Booking data creation and recognition rules
    • Discount calculation

Invoice Line Item Sort Order

Basically, the sort order of invoice line items is always controlled via the Sequence field.

In addition, there are other options that have an effect on the invoice line item listing:

Info

Note, however, that these options merely "overlap" the sequence but do not completely change it.

With respect to the sequence, there are various input factors that can determine this value, depending on the way you create invoices.

  • If you bill subscriptions, the sequence of the subscription items defines the sequence of the resulting invoice line items.

    When creating subscriptions and their items manually, JustOn sets a Sequence value as you add an item. If necessary, you can later edit the subscription items and modify the Sequence value as required.

    When automatically generating subscriptions, JustOn sorts the items alphabetically by their source object's Salesforce ID, assigning a corresponding Sequence value. If necessary, you can later edit the subscription items and modify the Sequence value as required.

  • If you generate invoices from arbitrary objects, JustOn sorts the invoice line items alphabetically by their source object's Salesforce ID, assigning a corresponding Sequence value.

Using the ON field mechanism, you can propagate customized sequence numbers to your subscription items or invoice line items.

Info

The actual way to implement this functionality in your org varies depending on your business requirements.

In broad outline, this involves the following major steps:

(1) Define the custom number field ON_Sequence on your source object.

(2) Depending on your requirements, you can have this field set manually by a user, or automatically via a formula. The formula may, for example, evaluate categorization data (product family, product code, order product number, etc.) to calculate a sequence number that reflects the intended sort order – if, for example, you want products of the category "A" to be placed on top of the list, your formula should produce a sequence number starting with 1.

(3) Create a batch setting record, setting an execution size > 1 for the relevant batch class, like, for example, 50 for BatchGenericInvoiceRun. This makes sure that JustOn considers the ON_Sequence field when evaluating the source records.

(4) When generating the subscriptions or invoices, JustOn copies the value calculated in the ON_Sequence field of the source object to the subscription item or invoice line item, respectively.

Example sequence formula

The following formula illustrates the sequence number generation. It evaluates a condition (order no. starts with SL). If that is true, it returns a sequence number made of a custom auto-number value prepended with 1, if not, prepended with 9.

IF (
BEGINS( ON_OrderNo__c , "SL"),
VALUE (LPAD ( ON_OpportunityProductNo__c , 6 , '1' )),
VALUE (LPAD ( ON_OpportunityProductNo__c , 6 , '9' ))
)

Note

Avalara AvaTax requires unique invoice line item numbers (sequence), which JustOn usually guarantees. If some custom configuration produces duplicate sequence values, make sure to correct the invoice line item numbering accordingly.