Merge pull request #33138 from deepeshgarg007/bank_reco_button_fix

fix(ux): Action buttons in Bank Reconciliation
This commit is contained in:
Deepesh Garg 2022-11-29 09:23:21 +05:30 committed by GitHub
commit 8112493c3c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 31 deletions

View File

@ -37,6 +37,14 @@ frappe.ui.form.on("Bank Clearance", {
refresh: function(frm) { refresh: function(frm) {
frm.disable_save(); 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) { update_clearance_date: function(frm) {
@ -46,22 +54,30 @@ frappe.ui.form.on("Bank Clearance", {
callback: function(r, rt) { callback: function(r, rt) {
frm.refresh_field("payment_entries"); frm.refresh_field("payment_entries");
frm.refresh_fields(); 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) { get_payment_entries: function(frm) {
return frappe.call({ return frappe.call({
method: "get_payment_entries", method: "get_payment_entries",
doc: frm.doc, doc: frm.doc,
callback: function(r, rt) { callback: function(r, rt) {
frm.refresh_field("payment_entries"); frm.refresh_field("payment_entries");
frm.refresh_fields();
$(frm.fields_dict.payment_entries.wrapper).find("[data-fieldname=amount]").each(function(i,v){ if (frm.doc.payment_entries.length) {
if (i !=0){ frm.add_custom_button(__('Update Clearance Date'), () =>
$(v).addClass("text-right") 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');
}
} }
}); });
} }

View File

@ -1,4 +1,5 @@
{ {
"actions": [],
"allow_copy": 1, "allow_copy": 1,
"creation": "2013-01-10 16:34:05", "creation": "2013-01-10 16:34:05",
"doctype": "DocType", "doctype": "DocType",
@ -13,11 +14,8 @@
"bank_account", "bank_account",
"include_reconciled_entries", "include_reconciled_entries",
"include_pos_transactions", "include_pos_transactions",
"get_payment_entries",
"section_break_10", "section_break_10",
"payment_entries", "payment_entries"
"update_clearance_date",
"total_amount"
], ],
"fields": [ "fields": [
{ {
@ -76,11 +74,6 @@
"fieldtype": "Check", "fieldtype": "Check",
"label": "Include POS Transactions" "label": "Include POS Transactions"
}, },
{
"fieldname": "get_payment_entries",
"fieldtype": "Button",
"label": "Get Payment Entries"
},
{ {
"fieldname": "section_break_10", "fieldname": "section_break_10",
"fieldtype": "Section Break" "fieldtype": "Section Break"
@ -91,25 +84,14 @@
"fieldtype": "Table", "fieldtype": "Table",
"label": "Payment Entries", "label": "Payment Entries",
"options": "Bank Clearance Detail" "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, "hide_toolbar": 1,
"icon": "fa fa-check", "icon": "fa fa-check",
"idx": 1, "idx": 1,
"issingle": 1, "issingle": 1,
"modified": "2020-04-06 16:12:06.628008", "links": [],
"modified": "2022-11-28 17:24:13.008692",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Accounts", "module": "Accounts",
"name": "Bank Clearance", "name": "Bank Clearance",
@ -126,5 +108,6 @@
"quick_entry": 1, "quick_entry": 1,
"read_only": 1, "read_only": 1,
"sort_field": "modified", "sort_field": "modified",
"sort_order": "ASC" "sort_order": "ASC",
"states": []
} }

View File

@ -179,7 +179,6 @@ class BankClearance(Document):
) )
self.set("payment_entries", []) self.set("payment_entries", [])
self.total_amount = 0.0
default_currency = erpnext.get_default_currency() default_currency = erpnext.get_default_currency()
for d in entries: for d in entries:
@ -198,7 +197,6 @@ class BankClearance(Document):
d.pop("debit") d.pop("debit")
d.pop("account_currency") d.pop("account_currency")
row.update(d) row.update(d)
self.total_amount += flt(amount)
@frappe.whitelist() @frappe.whitelist()
def update_clearance_date(self): def update_clearance_date(self):