From ae65172dca937a2380b4fdc251f79f50b520b492 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 8 Aug 2016 15:44:35 +0530 Subject: [PATCH] Added 'Ledger' button to show accounting entries against PCV --- .../period_closing_voucher.js | 50 ++++++++++++------- 1 file changed, 33 insertions(+), 17 deletions(-) diff --git a/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.js b/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.js index 364b78c876..a092e56928 100644 --- a/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.js +++ b/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.js @@ -1,21 +1,37 @@ // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt - -//========================== On Load ================================================= -cur_frm.cscript.onload = function(doc, cdt, cdn) { - if (!doc.transaction_date) doc.transaction_date = dateutil.obj_to_str(new Date()); -} - - -// ***************** Get Account Head ***************** -cur_frm.fields_dict['closing_account_head'].get_query = function(doc, cdt, cdn) { - return { - filters: [ - ['Account', 'company', '=', doc.company], - ['Account', 'is_group', '=', '0'], - ['Account', 'freeze_account', '=', 'No'], - ['Account', 'root_type', 'in', 'Liability, Equity'] - ] +frappe.ui.form.on('Period Closing Voucher', { + onload: function(frm) { + if (!frm.doc.transaction_date) frm.doc.transaction_date = dateutil.obj_to_str(new Date()); + }, + + setup: function(frm) { + frm.set_query("closing_account_head", function() { + return { + filters: [ + ['Account', 'company', '=', frm.doc.company], + ['Account', 'is_group', '=', '0'], + ['Account', 'freeze_account', '=', 'No'], + ['Account', 'root_type', 'in', 'Liability, Equity'] + ] + } + }); + }, + + refresh: function(frm) { + if(frm.doc.docstatus==1) { + frm.add_custom_button(__('Ledger'), function() { + frappe.route_options = { + "voucher_no": frm.doc.name, + "from_date": frm.doc.posting_date, + "to_date": frm.doc.posting_date, + "company": frm.doc.company, + group_by_voucher: 0 + }; + frappe.set_route("query-report", "General Ledger"); + }, "icon-table"); + } } -} + +})