diff --git a/fiscal_epos_print/__manifest__.py b/fiscal_epos_print/__manifest__.py index c20a8337563..9a7e573a74f 100644 --- a/fiscal_epos_print/__manifest__.py +++ b/fiscal_epos_print/__manifest__.py @@ -21,6 +21,7 @@ "point_of_sale", "hr", "pos_hr", + "pos_full_refund", # TODO is this necessary? # 'pos_order_mgmt' ], @@ -55,6 +56,7 @@ "fiscal_epos_print/static/src/xml/ChromeWidgets/EpsonFP81IIComponent.xml", # "fiscal_epos_print/static/src/xml/ChromeWidgets/SetLotteryCodeButton.xml", "fiscal_epos_print/static/src/xml/ChromeWidgets/SetRefundInfoButton.xml", + "fiscal_epos_print/static/src/js/Screens/TicketScreen/TicketScreen.js", ], }, "installable": True, diff --git a/fiscal_epos_print/static/src/js/ChromeWidgets/SetRefundInfoButton.js b/fiscal_epos_print/static/src/js/ChromeWidgets/SetRefundInfoButton.js index 0eba44a3c5a..63dd374813d 100644 --- a/fiscal_epos_print/static/src/js/ChromeWidgets/SetRefundInfoButton.js +++ b/fiscal_epos_print/static/src/js/ChromeWidgets/SetRefundInfoButton.js @@ -45,11 +45,11 @@ export class SetRefundInfoButton extends Component { // } await this.popup.add(RefundInfoPopup, { title: _t("Refund Information Details"), - // refund_date: yyyy + "-" + mm + "-" + dd, - // refund_report: current_order.refund_report, - // refund_doc_num: current_order.refund_doc_num, - // refund_cash_fiscal_serial: current_order.refund_cash_fiscal_serial, - // refund_full_refund: current_order.refund_full_refund, + refund_date: current_order.refund_date, + refund_report: current_order.refund_report, + refund_doc_num: current_order.refund_doc_num, + refund_cash_fiscal_serial: current_order.refund_cash_fiscal_serial, + refund_full_refund: current_order.refund_full_refund, }).then(async () => { this.update_refund_info_button(); }); diff --git a/fiscal_epos_print/static/src/js/Popups/RefundInfoPopup.js b/fiscal_epos_print/static/src/js/Popups/RefundInfoPopup.js index d5c5272a81d..3087daaf787 100644 --- a/fiscal_epos_print/static/src/js/Popups/RefundInfoPopup.js +++ b/fiscal_epos_print/static/src/js/Popups/RefundInfoPopup.js @@ -22,7 +22,6 @@ export class RefundInfoPopup extends AbstractAwaitablePopup { this.inputRefundDocNum = useRef("inputRefundDocNum"); this.inputRefundCashFiscalSerial = useRef("inputRefundCashFiscalSerial"); this.inputRefundFullRefund = useRef("inputRefundFullRefund"); - this.inputDatePicker = this.initializeDatePicker(); } clickConfirmRefund() { this.$el = $(this.el); @@ -70,14 +69,4 @@ export class RefundInfoPopup extends AbstractAwaitablePopup { this.$el.find("#error-message-dialog").show(); } } - initializeDatePicker() { - this.$el = $(this.el); - var element = this.$el.find("#refund_date").get(0); - if (element && !this.datepicker) { - // eslint-disable-next-line - this.datepicker = new Pikaday({ - field: element, - }); - } - } } \ No newline at end of file diff --git a/fiscal_epos_print/static/src/js/Screens/TicketScreen/TicketScreen.js b/fiscal_epos_print/static/src/js/Screens/TicketScreen/TicketScreen.js new file mode 100644 index 00000000000..c13022370a1 --- /dev/null +++ b/fiscal_epos_print/static/src/js/Screens/TicketScreen/TicketScreen.js @@ -0,0 +1,25 @@ +/** @odoo-module **/ + +import { TicketScreen } from "@point_of_sale/app/screens/ticket_screen/ticket_screen"; +import { _t } from "@web/core/l10n/translation"; +import { patch } from "@web/core/utils/patch"; + +patch(TicketScreen.prototype, { + async onDoRefund() { + const selected_order = this.getSelectedOrder(); + const res = super.onDoRefund(); + const new_order = this.pos.get_order(); + new_order.refund_report = selected_order.fiscal_z_rep_number; + new_order.refund_doc_num = selected_order.fiscal_receipt_number; + new_order.refund_date = selected_order.fiscal_receipt_date; + new_order.refund_cash_fiscal_serial = selected_order.fiscal_printer_serial; + return res; + }, + + onDoFullRefund() { + const res = super.onDoFullRefund(); + const new_order = this.pos.get_order(); + new_order.refund_full_refund = true; + return res; + } +}); \ No newline at end of file diff --git a/fiscal_epos_print/static/src/js/models.js b/fiscal_epos_print/static/src/js/models.js index fb72fd73c7f..7f5cf911754 100644 --- a/fiscal_epos_print/static/src/js/models.js +++ b/fiscal_epos_print/static/src/js/models.js @@ -20,7 +20,6 @@ patch(PosStore.prototype, { patch(Order.prototype, { setup() { - super.setup(...arguments); this.lottery_code = null; this.refund_report = null; this.refund_date = null; @@ -32,9 +31,14 @@ patch(Order.prototype, { this.fiscal_receipt_amount = null; this.fiscal_receipt_date = null; this.fiscal_z_rep_number = null; - this.fiscal_printer_serial = this.pos.config.fiscal_printer_serial || null; this.fiscal_printer_debug_info = null; + super.setup(...arguments); + + if (!this.fiscal_printer_serial) { + this.fiscal_printer_serial = this.pos.config.fiscal_printer_serial || null; + } + try { if (this.pos.config.module_pos_hr) { this.fiscal_operator_number = this.pos.cashier.fiscal_operator_number || "1"; @@ -91,6 +95,33 @@ patch(Order.prototype, { return json; }, + init_from_JSON(json) { + var res = super.init_from_JSON(...arguments); + this.lottery_code = json.lottery_code; + this.refund_report = json.refund_report; + this.refund_date = json.refund_date; + this.refund_doc_num = json.refund_doc_num; + this.refund_cash_fiscal_serial = json.refund_cash_fiscal_serial; + this.refund_full_refund = json.refund_full_refund; + this.check_order_has_refund(); + this.fiscal_receipt_number = json.fiscal_receipt_number; + this.fiscal_receipt_amount = json.fiscal_receipt_amount; + this.fiscal_receipt_date = json.fiscal_receipt_date; + this.fiscal_z_rep_number = json.fiscal_z_rep_number; + this.fiscal_printer_serial = json.fiscal_printer_serial; + this.fiscal_printer_debug_info = json.fiscal_printer_debug_info; + return res; + }, + + + check_order_has_refund() { + const order = this.pos.get_order(); + if (order) { + const lines = order.orderlines; + order.has_refund = lines.some(line => line.quantity < 0); + } + }, + getPrinterOptions() { var protocol = this.pos.config.use_https ? "https://" : "http://"; var printer_url = diff --git a/fiscal_epos_print/static/src/xml/Popups/RefundInfoPopup.xml b/fiscal_epos_print/static/src/xml/Popups/RefundInfoPopup.xml index 1b76f5b1b72..01602c8ea11 100644 --- a/fiscal_epos_print/static/src/xml/Popups/RefundInfoPopup.xml +++ b/fiscal_epos_print/static/src/xml/Popups/RefundInfoPopup.xml @@ -60,7 +60,7 @@ id="refund_full_refund" class="detail refund_full_refund" type='checkbox' - t-att-value="props.refund_full_refund || ''" + t-att-checked="props.refund_full_refund || ''" t-ref="inputRefundFullRefund" />