From 36af6a02adbc0dccfdd2915e660ff3df39ae985c Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Mon, 1 Jul 2013 14:35:57 +0530 Subject: [PATCH] [grid reports] now show by wn.route_options --- accounts/doctype/account/account.js | 7 ++++++- .../doctype/journal_voucher/journal_voucher.js | 14 ++++++++------ .../journal_voucher_detail.txt | 5 +++-- .../doctype/purchase_invoice/purchase_invoice.js | 15 +++++++++------ accounts/doctype/sales_invoice/sales_invoice.js | 15 +++++++++------ accounts/page/general_ledger/general_ledger.js | 8 +++++--- .../stock_reconciliation/stock_reconciliation.js | 2 -- 7 files changed, 40 insertions(+), 26 deletions(-) diff --git a/accounts/doctype/account/account.js b/accounts/doctype/account/account.js index 252b708fc0..c12c2d6964 100644 --- a/accounts/doctype/account/account.js +++ b/accounts/doctype/account/account.js @@ -92,7 +92,12 @@ cur_frm.cscript.add_toolbar_buttons = function(doc) { function() { cur_frm.cscript.convert_to_group(); }, 'icon-retweet') cur_frm.add_custom_button('View Ledger', function() { - wn.set_route("general-ledger", "account=" + doc.name); + wn.route_options = { + "account": doc.name, + "from_date": sys_defaults.year_start_date, + "to_date": sys_defaults.year_end_date + }; + wn.set_route("general-ledger"); }); } } diff --git a/accounts/doctype/journal_voucher/journal_voucher.js b/accounts/doctype/journal_voucher/journal_voucher.js index c2fa21ab37..f00ab1f450 100644 --- a/accounts/doctype/journal_voucher/journal_voucher.js +++ b/accounts/doctype/journal_voucher/journal_voucher.js @@ -23,7 +23,14 @@ cur_frm.cscript.refresh = function(doc) { erpnext.hide_naming_series(); cur_frm.cscript.voucher_type(doc); if(doc.docstatus==1) { - cur_frm.add_custom_button('View Ledger', cur_frm.cscript.view_ledger_entry); + cur_frm.add_custom_button('View Ledger', function() { + wn.route_options = { + "voucher_no": doc.name, + "from_date": doc.posting_date, + "to_date": doc.posting_date, + }; + wn.set_route("general-ledger"); + }); } } @@ -131,11 +138,6 @@ cur_frm.cscript.select_print_heading = function(doc,cdt,cdn){ cur_frm.pformat.print_heading = "Journal Voucher"; } -cur_frm.cscript.view_ledger_entry = function(doc,cdt,cdn){ - wn.set_route('Report', 'GL Entry', 'General Ledger', 'Voucher No='+cur_frm.doc.name); -} - - cur_frm.cscript.voucher_type = function(doc, cdt, cdn) { cur_frm.set_df_property("cheque_no", "reqd", doc.voucher_type=="Bank Voucher"); cur_frm.set_df_property("cheque_date", "reqd", doc.voucher_type=="Bank Voucher"); diff --git a/accounts/doctype/journal_voucher_detail/journal_voucher_detail.txt b/accounts/doctype/journal_voucher_detail/journal_voucher_detail.txt index 68019cb840..9946bfb37f 100644 --- a/accounts/doctype/journal_voucher_detail/journal_voucher_detail.txt +++ b/accounts/doctype/journal_voucher_detail/journal_voucher_detail.txt @@ -2,7 +2,7 @@ { "creation": "2013-02-22 01:27:39", "docstatus": 0, - "modified": "2013-04-17 14:05:18", + "modified": "2013-07-01 13:53:33", "modified_by": "Administrator", "owner": "Administrator" }, @@ -74,11 +74,12 @@ { "doctype": "DocField", "fieldname": "balance", - "fieldtype": "Data", + "fieldtype": "Currency", "label": "Account Balance", "no_copy": 1, "oldfieldname": "balance", "oldfieldtype": "Data", + "options": "Company:company:default_currency", "read_only": 1 }, { diff --git a/accounts/doctype/purchase_invoice/purchase_invoice.js b/accounts/doctype/purchase_invoice/purchase_invoice.js index 665fbb7441..cf308e3bbd 100644 --- a/accounts/doctype/purchase_invoice/purchase_invoice.js +++ b/accounts/doctype/purchase_invoice/purchase_invoice.js @@ -42,7 +42,14 @@ erpnext.accounts.PurchaseInvoiceController = erpnext.buying.BuyingController.ext this.frm.add_custom_button('Make Payment Entry', this.make_bank_voucher); if(doc.docstatus==1) { - this.frm.add_custom_button('View Ledger', this.view_ledger_entry); + cur_frm.add_custom_button('View Ledger', function() { + wn.route_options = { + "voucher_no": doc.name, + "from_date": doc.posting_date, + "to_date": doc.posting_date, + }; + wn.set_route("general-ledger"); + }); } this.is_opening(doc); @@ -226,8 +233,4 @@ cur_frm.cscript.select_print_heading = function(doc,cdt,cdn){ } else cur_frm.pformat.print_heading = "Purchase Invoice"; -} - -cur_frm.cscript.view_ledger_entry = function(){ - wn.set_route('Report', 'GL Entry', 'General Ledger', 'Voucher No='+cur_frm.doc.name); -} +} \ No newline at end of file diff --git a/accounts/doctype/sales_invoice/sales_invoice.js b/accounts/doctype/sales_invoice/sales_invoice.js index ab1053494e..ca4ca9241c 100644 --- a/accounts/doctype/sales_invoice/sales_invoice.js +++ b/accounts/doctype/sales_invoice/sales_invoice.js @@ -45,7 +45,15 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte cur_frm.cscript.is_opening(doc, dt, dn); if(doc.docstatus==1) { - cur_frm.add_custom_button('View Ledger', cur_frm.cscript.view_ledger_entry); + cur_frm.add_custom_button('View Ledger', function() { + wn.route_options = { + "voucher_no": doc.name, + "from_date": doc.posting_date, + "to_date": doc.posting_date, + }; + wn.set_route("general-ledger"); + }); + cur_frm.add_custom_button('Send SMS', cur_frm.cscript.send_sms); if(doc.is_pos==1 && doc.update_stock!=1) @@ -381,11 +389,6 @@ cur_frm.cscript.make_jv = function(doc, dt, dn, bank_account) { } -/****************** Get Accounting Entry *****************/ -cur_frm.cscript.view_ledger_entry = function(){ - wn.set_route('Report', 'GL Entry', 'General Ledger', 'Voucher No='+cur_frm.doc.name); -} - cur_frm.cscript.on_submit = function(doc, cdt, cdn) { if(cint(wn.boot.notification_settings.sales_invoice)) { cur_frm.email_doc(wn.boot.notification_settings.sales_invoice_message); diff --git a/accounts/page/general_ledger/general_ledger.js b/accounts/page/general_ledger/general_ledger.js index 1f8618f20a..3985507e22 100644 --- a/accounts/page/general_ledger/general_ledger.js +++ b/accounts/page/general_ledger/general_ledger.js @@ -110,7 +110,7 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({ // filter accounts options by company this.filter_inputs.company.change(function() { me.setup_account_filter(this); - me.set_route() + me.refresh() }); this.filter_inputs.account.change(function() { @@ -220,13 +220,15 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({ } } - if(date < from_date || item.is_opening=="Yes") { + if(!me.voucher_no && (date < from_date || item.is_opening=="Yes")) { opening.debit += item.debit; opening.credit += item.credit; grouped_ledgers[item.account].opening.debit += item.debit; grouped_ledgers[item.account].opening.credit += item.credit; + } else if(date <= to_date) { + totals.debit += item.debit; totals.credit += item.credit; @@ -242,7 +244,7 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({ + item.voucher_no][(item.debit > 0 ? "credits" : "debits")].join(", "); } - if(me.apply_filters(item) && item.is_opening=="No") { + if(me.apply_filters(item) && (me.voucher_no || item.is_opening=="No")) { out.push(item); grouped_ledgers[item.account].entries.push(item); diff --git a/stock/doctype/stock_reconciliation/stock_reconciliation.js b/stock/doctype/stock_reconciliation/stock_reconciliation.js index cf6821ebd5..dd496833b5 100644 --- a/stock/doctype/stock_reconciliation/stock_reconciliation.js +++ b/stock/doctype/stock_reconciliation/stock_reconciliation.js @@ -48,8 +48,6 @@ erpnext.stock.StockReconciliation = erpnext.stock.StockController.extend({ return { "query": "accounts.utils.get_account_list", "filters": { - "is_pl_account": "Yes", - "debit_or_credit": "Debit", "company": me.frm.doc.company } }