From 6a8a4b4db75a65487a61838bb21ab9cf3d6d91a3 Mon Sep 17 00:00:00 2001 From: Borruso Date: Thu, 23 May 2024 09:08:46 +0200 Subject: [PATCH] [UPD] fiscal_epos_print: aggiornata PR https://github.com/OCA/l10n-italy/pull/3060 --- .../src/js/Screens/PaymentScreen/PaymentScreen.js | 2 +- fiscal_epos_print/static/src/js/models.js | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/fiscal_epos_print/static/src/js/Screens/PaymentScreen/PaymentScreen.js b/fiscal_epos_print/static/src/js/Screens/PaymentScreen/PaymentScreen.js index bc3eb1619ec9..ea3124867728 100644 --- a/fiscal_epos_print/static/src/js/Screens/PaymentScreen/PaymentScreen.js +++ b/fiscal_epos_print/static/src/js/Screens/PaymentScreen/PaymentScreen.js @@ -46,7 +46,7 @@ odoo.define("fiscal_epos_print.PaymentScreen", function (require) { var receipt = order.export_for_printing(); var fp90 = new eposDriver(printer_options, this); await fp90.printFiscalReceipt(receipt); - await new Promise(resolve => setTimeout(resolve, 2500)); + await new Promise((resolve) => setTimeout(resolve, 2000)); // This line causes problems on bill split. What's the sense of deleting the actual pos context?! // It regenerates orders which are already partly paid using split function... // this.env.pos.context = {}; diff --git a/fiscal_epos_print/static/src/js/models.js b/fiscal_epos_print/static/src/js/models.js index fe88f074698a..5f8b77066a7a 100644 --- a/fiscal_epos_print/static/src/js/models.js +++ b/fiscal_epos_print/static/src/js/models.js @@ -200,8 +200,17 @@ odoo.define("fiscal_epos_print.models", function (require) { if (receipt.tax_department.included_in_price === true) { receipt.full_price = this.price; } else { + // This strategy was used because JavaScript's Math.round rounds to the nearest integer + const dec_precision = this.pos.currency.decimals; + const full_price = Number( + ( + this.price * + (1 + receipt.tax_department.tax_amount / 100) + ).toFixed(dec_precision) + ); + const rounding_factor = Math.pow(10, dec_precision); receipt.full_price = - this.price * (1 + receipt.tax_department.tax_amount / 100); + Math.trunc(full_price * rounding_factor) / rounding_factor; } }