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 f0a6399056)

Co-authored-by: Diptanil Saha <diptanil@frappe.io>
This commit is contained in:
mergify[bot]
2025-02-14 17:34:37 +05:30
committed by GitHub
parent a486e2962e
commit e271a5cba0
4 changed files with 26 additions and 4 deletions

View File

@@ -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",

View File

@@ -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

View File

@@ -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;

View File

@@ -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() {