Skip to content

Commit

Permalink
feat: disable auto setting grand total to default mode of payment (ba…
Browse files Browse the repository at this point in the history
…ckport #45591) (#45917)

feat: disable auto setting grand total to default mode of payment (#45591)

(cherry picked from commit f0a6399)

Co-authored-by: Diptanil Saha <diptanil@frappe.io>
  • Loading branch information
mergify[bot] and diptanilsaha authored Feb 14, 2025
1 parent a486e29 commit e271a5c
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
9 changes: 8 additions & 1 deletion erpnext/accounts/doctype/pos_profile/pos_profile.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions erpnext/accounts/doctype/pos_profile/pos_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion erpnext/public/js/controllers/taxes_and_totals.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 10 additions & 2 deletions erpnext/selling/page/point_of_sale/pos_payment.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit e271a5c

Please sign in to comment.