[FIX] pos_coupon: apply discounts on lines' discounted amount

Order discount do not take into account the discount on order lines so
the discount amount will be wrong

Steps to reproduce:
1. Install Point of Sale
2. Go to Settings > Point of Sale > Pricing and enable Coupons &
   Promotions
3. Go to Point of Sale > Products > Promotion Programs and edit program
   'Code for 10% on orders'
4. Change the Promo Code Usage to 'Automatically Applied'
5. Open a new session in Point of Sale 'Shop'
6. Add a product (e.g. Acoustic Bloc Screens, the discount is applied
   with value 29.50$)
7. Apply a discount of 20% on the product, the discount value doesn't
   change (it should be 23.60$)

Solution:
When computing the amount to discount, take into consideration the
discount already applied on the order line

opw-2883724

closes odoo/odoo#94791

X-original-commit: afb3e5516e43e831bec1fd6b6bc3aaa18fe3fde2
Signed-off-by: Guillaume Merlin (megu) <megu@odoo.com>
This commit is contained in:
MerlinGuillaume
2022-06-29 10:00:50 +02:00
parent 7aae635831
commit bccf88ae2d
+2 -2
View File
@@ -1028,7 +1028,7 @@ const PosLoyaltyOrder = (Order) => class PosLoyaltyOrder extends Order {
if (!discountablePerTax[taxKey]) {
discountablePerTax[taxKey] = 0;
}
discountablePerTax[taxKey] += line.price * line.get_quantity();
discountablePerTax[taxKey] += line.get_base_price();
}
return {discountable, discountablePerTax};
}
@@ -1164,7 +1164,7 @@ const PosLoyaltyOrder = (Order) => class PosLoyaltyOrder extends Order {
if (!discountablePerTax[taxKey]) {
discountablePerTax[taxKey] = 0;
}
discountablePerTax[taxKey] += (line.price * line.get_quantity()) * (remainingAmountPerLine[line.cid] / line.get_price_with_tax());
discountablePerTax[taxKey] += (line.get_base_price()) * (remainingAmountPerLine[line.cid] / line.get_price_with_tax());
}
return {discountable, discountablePerTax};
}