[FIX] point_of_sale: compute the tax based on the rounded price
Before this, we would compute taxes based on quantity * price. In account.tax (used by the POS backend) however taxes are computed on a rounded (based on currency precision) quantity * price. This would cause issues as orders in the backend would have a different total price as calculated in the frontend. An example that used to trigger the problem: Order with orderline with product with price of 5, excluded tax of 21% and a quantity of 0.985. This would cost 5.96 in the frontend and 5.97 in the backend.
This commit is contained in:
@@ -1325,13 +1325,13 @@ exports.Orderline = Backbone.Model.extend({
|
||||
return base_amount >= 0 ? ret : ret * -1;
|
||||
}
|
||||
if ((tax.amount_type === 'percent' && !tax.price_include) || (tax.amount_type === 'division' && tax.price_include)){
|
||||
return (base_amount * tax.amount / 100) * quantity;
|
||||
return base_amount * tax.amount / 100;
|
||||
}
|
||||
if (tax.amount_type === 'percent' && tax.price_include){
|
||||
return (base_amount - (base_amount / (1 + tax.amount / 100))) * quantity;
|
||||
return base_amount - (base_amount / (1 + tax.amount / 100));
|
||||
}
|
||||
if (tax.amount_type === 'division' && !tax.price_include) {
|
||||
return (base_amount / (1 - tax.amount / 100) - base_amount) * quantity;
|
||||
return base_amount / (1 - tax.amount / 100) - base_amount;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
@@ -1354,7 +1354,7 @@ exports.Orderline = Backbone.Model.extend({
|
||||
list_taxes.concat(ret.taxes);
|
||||
}
|
||||
else {
|
||||
var tax_amount = self._compute_all(tax, price_unit, quantity);
|
||||
var tax_amount = self._compute_all(tax, base, quantity);
|
||||
tax_amount = round_pr(tax_amount, currency_rounding);
|
||||
|
||||
if (tax_amount){
|
||||
|
||||
Reference in New Issue
Block a user