refactor(pos): set/reset grand total to default mode of payment

This commit is contained in:
diptanilsaha
2025-08-05 15:58:53 +05:30
parent 14e17f584a
commit 265f7ce092

View File

@@ -450,10 +450,11 @@ erpnext.PointOfSale.Payment = class {
}
render_payment_section() {
this.grand_total_to_default_mop();
this.render_payment_mode_dom();
this.make_invoice_field_dialog();
this.update_totals_section();
this.set_grand_total_to_default_mop();
this.focus_on_default_mop();
}
after_render() {
@@ -497,6 +498,17 @@ erpnext.PointOfSale.Payment = class {
}
}
grand_total_to_default_mop() {
if (this.set_gt_to_default_mop) return;
const doc = this.events.get_frm().doc;
const payments = doc.payments;
payments.forEach((p) => {
if (p.default) {
frappe.model.set_value(p.doctype, p.name, "amount", 0);
}
});
}
render_payment_mode_dom() {
const doc = this.events.get_frm().doc;
const payments = doc.payments;
@@ -557,6 +569,7 @@ erpnext.PointOfSale.Payment = class {
}
focus_on_default_mop() {
if (!this.set_gt_to_default_mop) return;
const doc = this.events.get_frm().doc;
const payments = doc.payments;
payments.forEach((p) => {
@@ -711,12 +724,6 @@ erpnext.PointOfSale.Payment = class {
.toLowerCase();
}
set_grand_total_to_default_mop() {
if (this.set_gt_to_default_mop) {
this.focus_on_default_mop();
}
}
validate_reqd_invoice_fields() {
if (this.invoice_fields.length === 0) return true;
const doc = this.events.get_frm().doc;