[FIX] point_of_sale: tip value not a discount

When we are adding a tip, the unit_price of the tip product is changed
on the line, but not the lst_price, that lead to show the difference
between the lst_price and unit_price as a discount on the receipt if the
pricelist is configured to show its price difference as a discount.

So we are now also changing the lst_price.

TASK-ID: 2058650
This commit is contained in:
Pierre Masereel
2019-08-29 11:38:35 +00:00
parent f84973578e
commit 82e3bd4326
+11 -1
View File
@@ -2011,6 +2011,11 @@ exports.Orderline = Backbone.Model.extend({
get_lst_price: function(){
return this.product.lst_price;
},
set_lst_price: function(price){
this.order.assert_editable();
this.product.lst_price = round_di(parseFloat(price) || 0, this.pos.dp['Product Price']);
this.trigger('change',this);
},
});
var OrderlineCollection = Backbone.Collection.extend({
@@ -2544,10 +2549,11 @@ exports.Order = Backbone.Model.extend({
for (var i = 0; i < lines.length; i++) {
if (lines[i].get_product() === tip_product) {
lines[i].set_unit_price(tip);
lines[i].set_lst_price(tip);
return;
}
}
this.add_product(tip_product, {quantity: 1, price: tip });
this.add_product(tip_product, {quantity: 1, price: tip, lst_price: tip });
}
},
set_pricelist: function (pricelist) {
@@ -2611,6 +2617,10 @@ exports.Order = Backbone.Model.extend({
line.set_unit_price(options.price);
}
if(options.lst_price !== undefined){
line.set_lst_price(options.lst_price);
}
//To substract from the unit price the included taxes mapped by the fiscal position
this.fix_tax_included_price(line);