From e271a5cba0a969bd54fc57c3e384b7f3c226cecb Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Fri, 14 Feb 2025 17:34:37 +0530 Subject: [PATCH] feat: disable auto setting grand total to default mode of payment (backport #45591) (#45917) feat: disable auto setting grand total to default mode of payment (#45591) (cherry picked from commit f0a639905688125c10d5568e854174b69d36b59f) Co-authored-by: Diptanil Saha --- .../accounts/doctype/pos_profile/pos_profile.json | 9 ++++++++- erpnext/accounts/doctype/pos_profile/pos_profile.py | 1 + erpnext/public/js/controllers/taxes_and_totals.js | 8 +++++++- erpnext/selling/page/point_of_sale/pos_payment.js | 12 ++++++++++-- 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/erpnext/accounts/doctype/pos_profile/pos_profile.json b/erpnext/accounts/doctype/pos_profile/pos_profile.json index 22f2965b86e..c38f9563eb2 100644 --- a/erpnext/accounts/doctype/pos_profile/pos_profile.json +++ b/erpnext/accounts/doctype/pos_profile/pos_profile.json @@ -29,6 +29,7 @@ "ignore_pricing_rule", "allow_rate_change", "allow_discount_change", + "disable_grand_total_to_default_mop", "section_break_23", "item_groups", "column_break_25", @@ -382,6 +383,12 @@ "fieldname": "print_receipt_on_order_complete", "fieldtype": "Check", "label": "Print Receipt on Order Complete" + }, + { + "default": "0", + "fieldname": "disable_grand_total_to_default_mop", + "fieldtype": "Check", + "label": "Disable auto setting Grand Total to default Payment Mode" } ], "icon": "icon-cog", @@ -409,7 +416,7 @@ "link_fieldname": "pos_profile" } ], - "modified": "2025-01-01 11:07:03.161950", + "modified": "2025-01-29 13:12:30.796630", "modified_by": "Administrator", "module": "Accounts", "name": "POS Profile", diff --git a/erpnext/accounts/doctype/pos_profile/pos_profile.py b/erpnext/accounts/doctype/pos_profile/pos_profile.py index ea27116e91c..cb9ae67fffd 100644 --- a/erpnext/accounts/doctype/pos_profile/pos_profile.py +++ b/erpnext/accounts/doctype/pos_profile/pos_profile.py @@ -36,6 +36,7 @@ class POSProfile(Document): currency: DF.Link customer: DF.Link | None customer_groups: DF.Table[POSCustomerGroup] + disable_grand_total_to_default_mop: DF.Check disable_rounded_total: DF.Check disabled: DF.Check expense_account: DF.Link | None diff --git a/erpnext/public/js/controllers/taxes_and_totals.js b/erpnext/public/js/controllers/taxes_and_totals.js index 875e6980e1e..30ebb3d97ce 100644 --- a/erpnext/public/js/controllers/taxes_and_totals.js +++ b/erpnext/public/js/controllers/taxes_and_totals.js @@ -894,10 +894,16 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments { this.frm.refresh_fields(); } - set_default_payment(total_amount_to_pay, update_paid_amount) { + async set_default_payment(total_amount_to_pay, update_paid_amount) { var me = this; var payment_status = true; if(this.frm.doc.is_pos && (update_paid_amount===undefined || update_paid_amount)) { + let r = await frappe.db.get_value("POS Profile", this.frm.doc.pos_profile, "disable_grand_total_to_default_mop"); + + if (r.message.disable_grand_total_to_default_mop) { + return; + } + $.each(this.frm.doc['payments'] || [], function(index, data) { if(data.default && payment_status && total_amount_to_pay > 0) { let base_amount, amount; diff --git a/erpnext/selling/page/point_of_sale/pos_payment.js b/erpnext/selling/page/point_of_sale/pos_payment.js index 33dd0489ba2..fc8b75031c8 100644 --- a/erpnext/selling/page/point_of_sale/pos_payment.js +++ b/erpnext/selling/page/point_of_sale/pos_payment.js @@ -340,11 +340,19 @@ erpnext.PointOfSale.Payment = class { // pass } - render_payment_section() { + async render_payment_section() { this.render_payment_mode_dom(); this.make_invoice_fields_control(); this.update_totals_section(); - this.focus_on_default_mop(); + let r = await frappe.db.get_value( + "POS Profile", + this.frm.doc.pos_profile, + "disable_grand_total_to_default_mop" + ); + + if (!r.message.disable_grand_total_to_default_mop) { + this.focus_on_default_mop(); + } } after_render() {