Skip to content

Commit

Permalink
[ADD] fiscal_epos_print: aggiunta PR OCA#4569
Browse files Browse the repository at this point in the history
  • Loading branch information
Borruso committed Jan 30, 2025
1 parent bd5787a commit 4b1f5f8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 34 deletions.
29 changes: 5 additions & 24 deletions fiscal_epos_print/static/src/js/epson_epos_print.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ odoo.define("fiscal_epos_print.epson_epos_print", function (require) {
"use strict";

var core = require("web.core");
var utils = require("web.utils");
// Var PosDB = require('point_of_sale.DB');
// var rpc = require('web.rpc');
var _t = core._t;
var round_pr = utils.round_precision;

const {Gui} = require("point_of_sale.Gui");

Expand Down Expand Up @@ -687,10 +685,7 @@ odoo.define("fiscal_epos_print.epson_epos_print", function (require) {
xml += self.printRecItem({
description: l.product_name,
quantity: l.quantity,
unitPrice: round_pr(
l.full_price,
self.sender.env.pos.currency.rounding
),
unitPrice: l.full_price,
department: l.tax_department.code,
operator: fiscal_operator,
});
Expand All @@ -699,10 +694,7 @@ odoo.define("fiscal_epos_print.epson_epos_print", function (require) {
adjustmentType: 0,
description:
_t("Discount") + " " + l.discount + "%",
amount: round_pr(
l.quantity * l.full_price - l.price_display,
self.sender.env.pos.currency.rounding
),
amount: l.quantity * l.full_price - l.price_display,
operator: fiscal_operator,
});
}
Expand All @@ -711,10 +703,7 @@ odoo.define("fiscal_epos_print.epson_epos_print", function (require) {
xml += self.printRecRefund({
description: _t("Refund: ") + l.product_name,
quantity: l.quantity * -1.0,
unitPrice: round_pr(
l.price,
self.sender.env.pos.currency.rounding
),
unitPrice: l.price,
department: l.tax_department.code,
operator: fiscal_operator,
});
Expand All @@ -723,10 +712,7 @@ odoo.define("fiscal_epos_print.epson_epos_print", function (require) {
// xml += self.printRecItem({
// description: _t("Refund cash"),
// quantity: l.quantity,
// unitPrice: round_pr(
// l.price,
// self.sender.env.pos.currency.rounding
// ),
// unitPrice: l.price,
// department: l.tax_department.code,
// operator: fiscal_operator,
// });
Expand Down Expand Up @@ -755,12 +741,7 @@ odoo.define("fiscal_epos_print.epson_epos_print", function (require) {
}
if (receipt.rounding_applied !== 0 && !has_refund) {
xml += self.printRounding({
amount: Math.abs(
round_pr(
receipt.rounding_applied,
self.sender.env.pos.currency.rounding
)
),
amount: Math.abs(receipt.rounding_applied),
operator: fiscal_operator,
});
xml +=
Expand Down
12 changes: 2 additions & 10 deletions fiscal_epos_print/static/src/js/models.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,17 +200,9 @@ 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.decimal_places;
const full_price = Number(
(
this.price *
(1 + receipt.tax_department.tax_amount / 100)
).toFixed(dec_precision)
receipt.full_price = Number(
this.price * (1 + receipt.tax_department.tax_amount / 100)
);
const rounding_factor = Math.pow(10, dec_precision);
receipt.full_price =
Math.trunc(full_price * rounding_factor) / rounding_factor;
}
}

Expand Down

0 comments on commit 4b1f5f8

Please sign in to comment.