From 2a3d7e660fbb4d7490e017cd34f12ca707f4f106 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 30 Dec 2013 20:28:14 +0530 Subject: [PATCH 1/2] Fixes in general ledger report --- accounts/report/general_ledger/general_ledger.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/accounts/report/general_ledger/general_ledger.js b/accounts/report/general_ledger/general_ledger.js index f2e60b6447..96682f9647 100644 --- a/accounts/report/general_ledger/general_ledger.js +++ b/accounts/report/general_ledger/general_ledger.js @@ -38,7 +38,7 @@ wn.query_reports["General Ledger"] = { "get_query": function() { var company = wn.query_report.filters_by_name.company.get_value(); return { - "query": "accounts.utils.get_account_list", + "doctype": "Account", "filters": { "company": company, } From 424b4a4b36d7b650365bc752fc7729ff725ff968 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 31 Dec 2013 10:24:28 +0530 Subject: [PATCH 2/2] Supplier bill info in accounts payable report --- .../accounts_payable/accounts_payable.py | 39 +++++++++---------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/accounts/report/accounts_payable/accounts_payable.py b/accounts/report/accounts_payable/accounts_payable.py index e5489d100f..f9266dc9ea 100644 --- a/accounts/report/accounts_payable/accounts_payable.py +++ b/accounts/report/accounts_payable/accounts_payable.py @@ -19,8 +19,8 @@ def execute(filters=None): for gle in get_gl_entries(filters, before_report_date=False)] account_supplier_type_map = get_account_supplier_type_map() - pi_map = get_pi_map() - + voucher_detail_map = get_voucher_details() + # Age of the invoice on this date age_on = getdate(filters.get("report_date")) > getdate(nowdate()) \ and nowdate() or filters.get("report_date") @@ -29,14 +29,8 @@ def execute(filters=None): for gle in entries: if cstr(gle.against_voucher) == gle.voucher_no or not gle.against_voucher \ or [gle.against_voucher_type, gle.against_voucher] in entries_after_report_date: - if gle.voucher_type == "Purchase Invoice": - pi_info = pi_map.get(gle.voucher_no) - due_date = pi_info.get("due_date") - bill_no = pi_info.get("bill_no") - bill_date = pi_info.get("bill_date") - else: - due_date = bill_no = bill_date = "" - + voucher_details = voucher_detail_map.get(gle.voucher_type, {}).get(gle.voucher_no, {}) + invoiced_amount = gle.credit > 0 and gle.credit or 0 outstanding_amount = get_outstanding_amount(gle, filters.get("report_date") or nowdate()) @@ -44,13 +38,15 @@ def execute(filters=None): if abs(flt(outstanding_amount)) > 0.01: paid_amount = invoiced_amount - outstanding_amount row = [gle.posting_date, gle.account, account_supplier.get(gle.account, ""), - gle.voucher_type, gle.voucher_no, - gle.remarks, account_supplier_type_map.get(gle.account), due_date, bill_no, - bill_date, invoiced_amount, paid_amount, outstanding_amount] + gle.voucher_type, gle.voucher_no, gle.remarks, + account_supplier_type_map.get(gle.account), + voucher_details.get("due_date", ""), voucher_details.get("bill_no", ""), + voucher_details.get("bill_date", ""), invoiced_amount, + paid_amount, outstanding_amount] # Ageing if filters.get("ageing_based_on") == "Due Date": - ageing_based_on_date = due_date + ageing_based_on_date = voucher_details.get("due_date", "") else: ageing_based_on_date = gle.posting_date @@ -112,14 +108,15 @@ def get_account_supplier_type_map(): return account_supplier_type_map -def get_pi_map(): - """ get due_date from sales invoice """ - pi_map = {} - for t in webnotes.conn.sql("""select name, due_date, bill_no, bill_date - from `tabPurchase Invoice`""", as_dict=1): - pi_map[t.name] = t +def get_voucher_details(): + voucher_details = {} + for dt in ["Purchase Invoice", "Journal Voucher"]: + voucher_details.setdefault(dt, webnotes._dict()) + for t in webnotes.conn.sql("""select name, due_date, bill_no, bill_date + from `tab%s`""" % dt, as_dict=1): + voucher_details[dt].setdefault(t.name, t) - return pi_map + return voucher_details def get_outstanding_amount(gle, report_date): payment_amount = webnotes.conn.sql("""