[FIX] point_of_sale: correctly show discount on receipt

Current behavior:
When a fiscal position is applied on an order in the PoS, the change of
price was interpreted as a discount. This shouldn't be the case.

Steps to reproduce:
- Create a tax that is included in the price (e.g. 10%)
- Create a fiscal position that match this tax and change it to no tax
- Change the pricelist option to show discount
- Create a product with a price of 100€
- Open the PoS and add the product to the order
- Apply the fiscal position
- Pay the order, and go to the receipt screen
- There is a discount showed on the receipt

opw-3154499

closes odoo/odoo#119902

X-original-commit: c7e1e634f76ef01920f7bcc7ccb43b3f28736499
Signed-off-by: Heinz Robin (rhe) <rhe@odoo.com>
Signed-off-by: Engels Robin (roen) <roen@odoo.com>
This commit is contained in:
roen-odoo
2023-04-27 11:21:17 +02:00
parent 04bfbb4e7e
commit 5db35ac7c5
3 changed files with 27 additions and 2 deletions
+10 -2
View File
@@ -2199,7 +2199,7 @@ export class Orderline extends PosModel {
discount: this.get_discount(),
product_name: this.get_product().display_name,
product_name_wrapped: this.generate_wrapped_product_name(),
price_lst: this.get_lst_price(),
price_lst: this.get_taxed_lst_unit_price(),
fixed_lst_price: this.get_fixed_lst_price(),
price_manually_set: this.price_manually_set,
price_automatically_set: this.price_automatically_set,
@@ -2311,7 +2311,8 @@ export class Orderline extends PosModel {
return this.compute_all(product_taxes, lst_price, 1, this.pos.currency.rounding)
.total_included;
}
return lst_price;
var digits = this.pos.dp['Product Price'];
return lst_price.toFixed(digits)
}
get_price_without_tax() {
return this.get_all_prices().priceWithoutTax;
@@ -3387,6 +3388,13 @@ export class Order extends PosModel {
_get_ignored_product_ids_total_discount() {
return [];
}
_reduce_total_discount_callback(sum, orderLine) {
sum += (orderLine.get_unit_price() * (orderLine.get_discount()/100) * orderLine.get_quantity());
if (orderLine.display_discount_policy() === 'without_discount'){
sum += ((orderLine.get_taxed_lst_unit_price() - orderLine.get_unit_price()) * orderLine.get_quantity());
}
return sum;
}
get_total_discount() {
const ignored_product_ids = this._get_ignored_product_ids_total_discount();
return round_pr(
@@ -1,6 +1,8 @@
/** @odoo-module */
import { PaymentScreen } from "@point_of_sale/../tests/tours/helpers/PaymentScreenTourMethods";
import { ProductScreen } from "@point_of_sale/../tests/tours/helpers/ProductScreenTourMethods";
import { ReceiptScreen } from "@point_of_sale/../tests/tours/helpers/ReceiptScreenTourMethods";
import { TextAreaPopup } from "@point_of_sale/../tests/tours/helpers/TextAreaPopupTourMethods";
import { getSteps, startSteps } from "@point_of_sale/../tests/tours/helpers/utils";
import { registry } from "@web/core/registry";
@@ -142,6 +144,12 @@ ProductScreen.check.totalAmountIs('100.00');
ProductScreen.do.changeFiscalPosition('No Tax');
ProductScreen.check.noDiscountApplied("100.00");
ProductScreen.check.totalAmountIs('86.96');
ProductScreen.do.clickPayButton();
PaymentScreen.do.clickPaymentMethod('Bank');
PaymentScreen.check.remainingIs('0.00');
PaymentScreen.do.clickValidate();
ReceiptScreen.check.isShown();
ReceiptScreen.check.noOrderlineContainsDiscount();
registry.category("web_tour.tours").add("FiscalPositionNoTax", { test: true, url: "/pos/ui", steps: getSteps() });
@@ -90,6 +90,15 @@ class Check {
},
];
}
noOrderlineContainsDiscount() {
return [
{
trigger: `.orderlines:not(:contains('->'))`,
run: () => { },
},
];
}
}
class Execute {