SendRegning

Rounding


To calculate the price by line

  • multiply quantity, unitPrice and discount then round it to 2 decimals.
  • multiply the result with the taxRate and round it again to 2 decimals
  • discount and taxRate are in percentage

JavaScript example

1
2
3
4
5
6
//           Quantity
//           |   Unit price
//           |   |             Discount
//           |   |             |             Tax rate
//           |   |             |             |
Math.round(((1 * 100 * ((100 - 13) / 100)) * 1.25) * 100) / 100;

Example

Quantity Unit price Discount Tax rate Sum
2.00 234.00 0% 25% 585.00
45.50 1.25 0% 15% 65.41
1.00 121.42 0% 10% 133.56
1.25 1204.12 13% 0% 1309.48

To calculate the total price

  • multiply quantity, price and discount then round it to 2 decimals
  • group the same results by tax amount
  • add all in the same group
  • multiply the group result with tax
  • add them together

Based on the table above total is 2093.45, total excluding tax is 1955.78 and tax is 137.67