Skip to content

Commit 3018574

Browse files
WvveneLBati
authored andcommitted
added rounding feature (#15)
1 parent 6e1e1ac commit 3018574

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

fiscal_epos_print/static/src/js/epson_epos_print.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import { _t } from "@web/core/l10n/translation";
44
import { ErrorPopup } from "@point_of_sale/app/errors/popups/error_popup";
55
import { ErrorTracebackPopup } from "@point_of_sale/app/errors/popups/error_traceback_popup";
6+
import { roundPrecision as round_pr } from "@web/core/utils/numbers";
67

78
export class EpsonEposPrint {
89
constructor(...args) {
@@ -247,13 +248,31 @@ export class EpsonEposPrint {
247248

248249
// Process payment lines
249250
//receipt.ticket = "";
251+
252+
//Gestione arrotondamento pagamenti
253+
//Viene aggiunta una riga di pagamento con payment method type a 6
254+
if (receipt.amount_total != receipt.amount_paid) {
255+
let payment_round = 0;
256+
if (receipt.amount_paid < receipt.amount_total) {
257+
const rounding = this.pos.currency.rounding;
258+
payment_round = round_pr(
259+
(receipt.amount_total - receipt.amount_paid), rounding
260+
);
261+
xml += this.printRecTotal({
262+
payment: Math.abs(payment_round),
263+
paymentType: "6",
264+
operator: fiscalOperator,
265+
});
266+
}
267+
}
268+
250269
receipt.statement_ids.forEach((st) => {
251270
let l = st[2];
252271
// vedi modulo fiscal_epos_print_meal_voucher
253272
//receipt.ticket += l.ticket; // Append ticket to receipt
254273

255274
// TODO
256-
//const method = hasRefund ? "printRecTotalRefund" : "printRecTotal";
275+
//const method = hasRefund ? "printRecTotalRefund" : "printRecTotal";
257276
xml += this.printRecTotal({
258277
payment: Math.abs(l.amount),
259278
paymentType: l.fiscalprinter_payment_type,

0 commit comments

Comments
 (0)