Skip to content

Commit

Permalink
fix(ux): Action buttons in Bank Reconciliation
Browse files Browse the repository at this point in the history
(cherry picked from commit 6ebe8ad)
  • Loading branch information
deepeshgarg007 authored and mergify[bot] committed Nov 29, 2022
1 parent 0d8112a commit 93b8cc3
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 31 deletions.
28 changes: 22 additions & 6 deletions erpnext/accounts/doctype/bank_clearance/bank_clearance.js
Expand Up @@ -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) {
Expand All @@ -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');
}
}
});
}
Expand Down
29 changes: 6 additions & 23 deletions 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",
Expand All @@ -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": [
{
Expand Down Expand Up @@ -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"
Expand All @@ -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",
Expand All @@ -126,5 +108,6 @@
"quick_entry": 1,
"read_only": 1,
"sort_field": "modified",
"sort_order": "ASC"
"sort_order": "ASC",
"states": []
}
2 changes: 0 additions & 2 deletions erpnext/accounts/doctype/bank_clearance/bank_clearance.py
Expand Up @@ -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:
Expand All @@ -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):
Expand Down

0 comments on commit 93b8cc3

Please sign in to comment.