Skip to content

Commit

Permalink
set refund data
Browse files Browse the repository at this point in the history
  • Loading branch information
eLBati committed Oct 11, 2024
1 parent 50ec815 commit 015fa77
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 17 deletions.
1 change: 1 addition & 0 deletions fiscal_epos_print/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ 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_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();
Expand Down
11 changes: 0 additions & 11 deletions fiscal_epos_print/static/src/js/Popups/RefundInfoPopup.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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,
});
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/** @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;
},
});
34 changes: 32 additions & 2 deletions fiscal_epos_print/static/src/js/models.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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";
Expand Down Expand Up @@ -91,6 +95,32 @@ 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.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 =
Expand Down

0 comments on commit 015fa77

Please sign in to comment.