From 6ebe8ad60d62645b1604481ff6d9b2b97a0fc104 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Mon, 28 Nov 2022 17:37:41 +0530 Subject: [PATCH] fix(ux): Action buttons in Bank Reconciliation --- .../doctype/bank_clearance/bank_clearance.js | 28 ++++++++++++++---- .../bank_clearance/bank_clearance.json | 29 ++++--------------- .../doctype/bank_clearance/bank_clearance.py | 2 -- 3 files changed, 28 insertions(+), 31 deletions(-) diff --git a/erpnext/accounts/doctype/bank_clearance/bank_clearance.js b/erpnext/accounts/doctype/bank_clearance/bank_clearance.js index 7e57c2fc471d..ceba99a56a8a 100644 --- a/erpnext/accounts/doctype/bank_clearance/bank_clearance.js +++ b/erpnext/accounts/doctype/bank_clearance/bank_clearance.js @@ -37,6 +37,14 @@ frappe.ui.form.on("Bank Clearance", { refresh: function(frm) { frm.disable_save(); + + if (frm.doc.account && frm.doc.from_date && frm.doc.to_date) { + frm.add_custom_button(__('Get Payment Entries'), () => + frm.trigger("get_payment_entries") + ); + + frm.change_custom_button_type('Get Payment Entries', null, 'primary'); + } }, update_clearance_date: function(frm) { @@ -46,22 +54,30 @@ frappe.ui.form.on("Bank Clearance", { callback: function(r, rt) { frm.refresh_field("payment_entries"); frm.refresh_fields(); + + if (!frm.doc.payment_entries.length) { + frm.change_custom_button_type('Get Payment Entries', null, 'primary'); + frm.change_custom_button_type('Update Clearance Date', null, 'default'); + } } }); }, + get_payment_entries: function(frm) { return frappe.call({ method: "get_payment_entries", doc: frm.doc, callback: function(r, rt) { frm.refresh_field("payment_entries"); - frm.refresh_fields(); - $(frm.fields_dict.payment_entries.wrapper).find("[data-fieldname=amount]").each(function(i,v){ - if (i !=0){ - $(v).addClass("text-right") - } - }) + if (frm.doc.payment_entries.length) { + frm.add_custom_button(__('Update Clearance Date'), () => + frm.trigger("update_clearance_date") + ); + + frm.change_custom_button_type('Get Payment Entries', null, 'default'); + frm.change_custom_button_type('Update Clearance Date', null, 'primary'); + } } }); } diff --git a/erpnext/accounts/doctype/bank_clearance/bank_clearance.json b/erpnext/accounts/doctype/bank_clearance/bank_clearance.json index a436d1effb8a..591d01949b83 100644 --- a/erpnext/accounts/doctype/bank_clearance/bank_clearance.json +++ b/erpnext/accounts/doctype/bank_clearance/bank_clearance.json @@ -1,4 +1,5 @@ { + "actions": [], "allow_copy": 1, "creation": "2013-01-10 16:34:05", "doctype": "DocType", @@ -13,11 +14,8 @@ "bank_account", "include_reconciled_entries", "include_pos_transactions", - "get_payment_entries", "section_break_10", - "payment_entries", - "update_clearance_date", - "total_amount" + "payment_entries" ], "fields": [ { @@ -76,11 +74,6 @@ "fieldtype": "Check", "label": "Include POS Transactions" }, - { - "fieldname": "get_payment_entries", - "fieldtype": "Button", - "label": "Get Payment Entries" - }, { "fieldname": "section_break_10", "fieldtype": "Section Break" @@ -91,25 +84,14 @@ "fieldtype": "Table", "label": "Payment Entries", "options": "Bank Clearance Detail" - }, - { - "fieldname": "update_clearance_date", - "fieldtype": "Button", - "label": "Update Clearance Date" - }, - { - "fieldname": "total_amount", - "fieldtype": "Currency", - "label": "Total Amount", - "options": "account_currency", - "read_only": 1 } ], "hide_toolbar": 1, "icon": "fa fa-check", "idx": 1, "issingle": 1, - "modified": "2020-04-06 16:12:06.628008", + "links": [], + "modified": "2022-11-28 17:24:13.008692", "modified_by": "Administrator", "module": "Accounts", "name": "Bank Clearance", @@ -126,5 +108,6 @@ "quick_entry": 1, "read_only": 1, "sort_field": "modified", - "sort_order": "ASC" + "sort_order": "ASC", + "states": [] } \ No newline at end of file diff --git a/erpnext/accounts/doctype/bank_clearance/bank_clearance.py b/erpnext/accounts/doctype/bank_clearance/bank_clearance.py index 78c35266542d..80878ac50682 100644 --- a/erpnext/accounts/doctype/bank_clearance/bank_clearance.py +++ b/erpnext/accounts/doctype/bank_clearance/bank_clearance.py @@ -179,7 +179,6 @@ def get_payment_entries(self): ) self.set("payment_entries", []) - self.total_amount = 0.0 default_currency = erpnext.get_default_currency() for d in entries: @@ -198,7 +197,6 @@ def get_payment_entries(self): d.pop("debit") d.pop("account_currency") row.update(d) - self.total_amount += flt(amount) @frappe.whitelist() def update_clearance_date(self):