[FIX] point_of_sale: total discount computation

When the total discount is computed on a receipt, it is computed based
on the the discount applied on lines, and the difference between the
pricelist price and the unit price. But there is an option on the
pricelist that say if you want to show or not the difference. Which is
not respected in this case because in total we always show all discount.

So we are now respecting the policy of the pricelist.

TASK-ID: 2058650
This commit is contained in:
Pierre Masereel
2019-08-29 09:16:45 +00:00
parent d4bfeec9ea
commit f84973578e
+3 -1
View File
@@ -2777,7 +2777,9 @@ exports.Order = Backbone.Model.extend({
get_total_discount: function() {
return round_pr(this.orderlines.reduce((function(sum, orderLine) {
sum += (orderLine.get_unit_price() * (orderLine.get_discount()/100) * orderLine.get_quantity());
sum += ((orderLine.get_lst_price() - orderLine.get_unit_price()) * orderLine.get_quantity());
if (orderLine.display_discount_policy() === 'without_discount'){
sum += ((orderLine.get_lst_price() - orderLine.get_unit_price()) * orderLine.get_quantity());
}
return sum;
}), 0), this.pos.currency.rounding);
},