Invoice Total Derivation

Overview

For invoice records, the total is calculated as a sum of the line item, taxes, and discount amounts in the respective currency code. Depending on which integration the record is coming from, the subsequent records are linked to the invoice record and the sum is derived from the linked record amounts depending on what is configured.

Configuration

Required fields

FieldsDescription
linked_recordsRecords to be included within the calculation, ie. "Tax", "Discount"
sum_amountsInclude all the record types to compute the total amount and their respective fields for calculation

Walkthrough: Invoice Derivation

Let's say that John is invoiced for his purchase of a new car (base price: $40,000), which includes an upgrade to his speaker system ($2000) and executive model package ($6000). On the executive model package, there is a 50% discount applied as part of the promotion.

On the total amount of 45,000, there's a 4% overall discount ($1800) applied by the manager cutting the total value to 43,200. There's also a tax applied on the final total price of 10% ($4320) amounting to a final total of $47,520.

For accounting purposes, the car company would like to record invoice subtotals (ie. invoice.subtotal) as the accumulation of all line items while the invoice total (ie. invoice.total) will be recorded as the accumulation of line items, discounts, and tax.

For the invoice subtotal (ie. invoice.subtotal), the summation will be based on the following configuration:

  • linked_records = [ 'line_item']
  • sum_amounts =
    • line_items as an expression of the total value: line_item.amount - line_item.discount

For the invoice total (ie. invoice.total), the summation will be based on the following configuration,

  • linked_records = ['line_item', 'discount', 'tax']
  • sum_amounts =
    • line_item as an expression of the total value with discounts applied: line_item.amount - line_item.discountAmount
      • Note: For any discounts applied on the line items individually, they should be applied to the
    • discount.amount
    • tax.amount

Event: Invoice is Issued

An invoice is issued with multiple linked records:

  • line items:
    • base price: $40,000
    • speaker system upgrade: $2,000
    • executive model: $6,000
      • discount: 50% ($3,000)
  • discount: 4% ($1,800)
  • tax: 10% ($4,320)

Total and Subtotal Calculation

invoice.subtotal is calculated as:

  • base price ($40,000) + speaker system upgrade ($2,000) + executive model ($6,000 - ($6,000*0.5) = $3000) = $45,000

invoice.total is calculated as:

  • line items: $45,000 (calculated the same as above)
  • discount: $1800
  • tax: $4320
  • total = $45,000 - $1800 + $4320 = $47,520