# Introduction

This article describes Provet Cloud price and tax calculation methods in detail.

The logic which Provet Cloud uses to calculate prices and invoices has been revamped in update 1.75 (May 2020). This has been done to improve reliability and predictability of price calculation as well as improve underlying the codebase.

Cost estimates in Provet Cloud are currently excluded from these changes and might behave differently than invoices. There’s no current estimate when estimate price calculation is revamped.

# Main rules

## Four decimal places

Provet Cloud stores and uses four decimal places. The reason for storing four decimal places is that currency values need *two* decimal places, a *third* decimal place is required in order to round to two decimal places, and *fourth* decimal ensures that the third decimal place is unaffected by rounding.

## Round half to even

Provet Cloud now uses the round half to even rule that differs from the conventional rounding logic taught in school.

Examples:

- If the value 2.235 is rounded using this strategy to two decimal places, it results in 2.24.
- If the value 2.245 is rounded using this strategy to two decimal places, it results in 2.24.

The reason for this logic is to minimize rounding errors in the long run. If ties in rounding would always be resolved by rounding up instead, the sum of rounded numbers would trend up.

## Recalculation

Prices for invoices and invoice rows are recalculated every time they are changed. Invoices are also recalculated whenever their invoice rows are changed in a manner that changes their sum values.

## Invoice row prices

The invoice row total prices shown on invoice pages follow some general rules:

- The invoice row display price includes all possible extra fees like dispense fees or injection fees.
- If you modify the invoice row total price on the invoice page, the total price is calculated so that the total is
*shown quantity*×*invoice row total price*, even if there are dispense or injection fees in the price (“what you see is what you get” editing). - If you don't change the invoice row total price but otherwise modify an invoice row, the invoice row total price is recalculated based on the existing price, fees and possible rounding, meaning that it can still change despite the price values not changing in the background.

## Finalised invoices stay as is

Invoices are saved in databases so that the invoice total sums can be recalculated even if relevant settings are modified after the invoice has been finalised.

# What are the main options to modify the calculation process?

## Determining price for tax calculation selection

Settings > General > Organisation > Determining price for tax calculation

This setting is used to select whether the price including VAT or the price excluding VAT is used for the tax calculation. This is only significant if there are rounding differences between the two values.

### Price including VAT

Let's consider an example where an item with a price excluding VAT of 0.99 is sold.

Price excl. VAT | VAT % | Price incl. VAT | Quantity | Subtotal | VAT | Total |

0.99 | 24 % | 1.23 | 10 | 9.92 | 2.38 | 12.30 |

In that case, the calculation is 1.23 x 10 units = **12.30**, and the subtotal without VAT is **9.92**, and the VAT total is **2.38**.

### Price excluding VAT

Same sale example item as above.

Price excl. VAT | VAT % | Price incl. VAT | Quantity | Subtotal | VAT | Total |

0.99 | 24 % | 1.23 | 10 | 9.90 | 2.38 | 12.28 |

In this case, however, the calculation is 0.99 x 1.24 x 10 = 12.276 ≈ **12.28**, and the subtotal without VAT is **9.90**, and the total VAT is **2.38**.

## Tax price option

Settings > General > Department > Department settings > Tax prices

There is however a notable exception to the determining price setting described above. The department setting "Tax prices" controls whether or not prices in the user interface include or exclude VAT. When adding items to a consultation, the price shown in the consultation item modal is either the price incl. VAT with two decimal precision or the price excl. VAT with two decimal precision depending on the setting. Therefore it is possible that even if the determining price is set to price excl. VAT that the price calculation actually starts from the price incl. VAT, as the price shown in the modal is used as the starting point.

## Tax calculation method

Settings > General > Organisation > Tax calculation method

The tax calculation method setting is used to determine the invoice total VAT calculation method. There are two options: "Invoice total sum" or "Single invoice row".

Let's consider these invoice rows as an example:

Price incl. VAT | VAT % | Price excl. VAT (raw) |
Price excl. VAT (rounded) |
VAT (incl. - excl.) |

3.45 | 24 % | 2.7823 | 2.78 | 0.67 |

10.50 | 24 % | 8.4677 | 8.47 | 2.03 |

0.25 | 24 % | 0.2016 | 0.20 | 0.05 |

2.89 | 14 % | 2.5351 | 2.54 | 0.35 |

2.89 | 14 % | 2.5351 | 2.54 | 0.35 |

2.39 | 14 % | 2.0965 | 2.10 | 0.29 |

2.39 | 14 % | 2.0965 | 2.10 | 0.29 |

4.25 | 14 % | 3.7281 | 3.73 | 0.52 |

1.99 | 14 % | 1.7456 | 1.75 | 0.24 |

1.99 | 14 % | 1.7456 | 1.75 | 0.24 |

### Invoice total sum

The "Invoice total sum" method calculates the tax for each VAT group from their totals. The only price we need for calculating the VAT is the price including VAT. Every other value is derived from that and the VAT percentage. The invoice total sum is **32.99** in this case, subtotal without VAT is **27.93** and the total VAT is **5.06**.

Sum incl. VAT | Sum excl. VAT | VAT total | |

24 % | 14.20 | 14.20 / 1.24 = 11.4516 ≈ 11.45 | 14.20 - 11.45 = 2.75 |

14 % | 18.79 | 18.79 / 1.14 = 16.4825 ≈ 16.48 | 18.79 - 16.48 = 2.31 |

Total | 14.20 + 18.79 = 32.99 |
11.45 + 16.48 = 27.93 |
2.75 + 2.31 = 5.06 |

### Single invoice row

The "Single invoice row" method calculates the VAT for each individual invoice row with two decimal place precision and then sums those values together. The invoice total sum is **32.99** in this case, subtotal without VAT is **27.96** and the total VAT is **5.03**.

If the invoice row VAT values round primarily away from zero or primarily towards zero, this calculation method will show different values than the "Invoice total sum" method. It is therefore not always possible to derive *sum excl. VAT* and *VAT total* from the *sum incl. VAT *within the breakdown. This example has a negligible bias for 24% VAT, but significant enough of a bias away from zero for 14% (amount rounded up is more than amount rounded down).

Sum incl. VAT | Sum excl. VAT | VAT total | |

24 % | 14.20 | 11.45 | 2.75 |

14 % | 18.79 | 16.51 | 2.28 |

Total | 14.20 + 18.79 = 32.99 |
11.45 + 16.51 = 27.96 |
2.75 + 2.28 = 5.03 |

With both methods, the sum of the total sum excl. VAT and VAT total lead back to the total sum incl. VAT even though the values are different (14.20 + 18.79 = 32.99 vs. 27.93 + 5.06 = 32.99). VAT total is always calculated as the difference between the sum incl. VAT and sum excl. VAT for the values to be consistent.

### Single item

Provet Cloud also includes a third option for tax calculation method called "Single item". This is an old, deprecated tax calculation method that will be removed from Provet Cloud in the future. Systems that have "Single item" selected calculate taxes the same exact way as "Single invoice row".

## Comments

0 comments

Please sign in to leave a comment.