Skip to main content

Method of calculating and rounding values for Invoices

There are two options in the Invoices Templates section that help to avoid rounding issues with float numbers and missing cents:

  1. Totals Calculation
  2. Taxes Calculation

Let's review how they work with the following example, where the tax is 21%:

ItemAmountTax
Calls with the cost$0.0050$0.001050
Package #1 fee$7.1144$1.494024
Package #2 fee$5.1144$1.074024
Package #3 fee$3.1144$0.654024

Now, let's see how the calculations are made depending on the selected option:

1. Round then sum and Percent from the total amount

In this case, each line item is rounded first and then subtotal amount is calculated:

ItemAmount
Calls with the cost$0.01
Package #1 fee$7.11
Package #2 fee$5.11
Package #3 fee$3.11
Subtotal$15.34

After that tax total and total due are calculated:

ItemAmountNotes
Subtotal$15.34
Tax total$3.2215.34 x 21%
Total due$18.5615.34 + 3.22

2. Sum then round and Sum of individual taxes

In this case, each line item and its taxes are added up first:

ItemAmountTax
Calls with the cost$0.0050$0.001050
Package #1 fee$7.1144$1.494024
Package #2 fee$5.1144$1.074024
Package #3 fee$3.1144$0.654024
Totals$15.3482$3.223122
Totals (rounded)$15.35$3.22

And then rounded results are used to calculate total due:

ItemAmountNotes
Subtotal$15.35
Tax total$3.22
Total due$18.5715.35 + 3.22