[FIX] point_of_sale: correct sign of fixed tax

Oversight of e8b965f93c. Although the
previous commit gave the correct behaviour for a negative fixed tax with
a base_amount of 0, it was still incorrect for positive fixed taxes with
a base_amount of 0.

This rewrites the code to more closely resemble the relevant code of
account.tax._compute_amount() solving the above mentioned issue.
This commit is contained in:
Joren Van Onder
2016-03-21 15:31:38 +01:00
parent 51cbf110c3
commit 95f8693a3d
+2 -2
View File
@@ -1321,8 +1321,8 @@ exports.Orderline = Backbone.Model.extend({
},
_compute_all: function(tax, base_amount, quantity) {
if (tax.amount_type === 'fixed') {
var ret = tax.amount * quantity;
return base_amount > 0 ? ret : ret * -1;
var sign_base_amount = base_amount >= 0 ? 1 : -1;
return (Math.abs(tax.amount) * sign_base_amount) * quantity;
}
if ((tax.amount_type === 'percent' && !tax.price_include) || (tax.amount_type === 'division' && tax.price_include)){
return base_amount * tax.amount / 100;