From 6dfa84164e68c67058826d994bb2e05be21a62ad Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 25 Feb 2013 18:57:41 +0530 Subject: [PATCH] fixes in new gross profit report --- accounts/page/accounts_home/accounts_home.js | 5 +++++ accounts/report/gross_profit/gross_profit.py | 12 +++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/accounts/page/accounts_home/accounts_home.js b/accounts/page/accounts_home/accounts_home.js index 237b51fd8d..f2faf93785 100644 --- a/accounts/page/accounts_home/accounts_home.js +++ b/accounts/page/accounts_home/accounts_home.js @@ -151,6 +151,11 @@ wn.module_page["Accounts"] = [ route: "Report/Profile/Trend Analyzer", doctype: "Sales Invoice" }, + { + "label":wn._("Gross Profit"), + route: "query-report/Gross Profit", + doctype: "Sales Invoice" + }, ] }, { diff --git a/accounts/report/gross_profit/gross_profit.py b/accounts/report/gross_profit/gross_profit.py index a9a4532c5e..de8651bb66 100644 --- a/accounts/report/gross_profit/gross_profit.py +++ b/accounts/report/gross_profit/gross_profit.py @@ -56,12 +56,9 @@ def _get_buying_amount(voucher_no, item_row, item_code, warehouse, qty): if sle.voucher_type == "Delivery Note" and sle.voucher_no == voucher_no: if (sle.voucher_detail_no == item_row) or \ (sle.item_code == item_code and sle.warehouse == warehouse and \ - abs(sle.qty) == qty): + abs(flt(sle.qty)) == qty): buying_amount = flt(stock_ledger_entries[i+1].stock_value) - flt(sle.stock_value) - if buying_amount < 0: - webnotes.errprint([voucher_no, item_row, item_code, warehouse, qty]) - webnotes.errprint(["previous", stock_ledger_entries[i+1]]) - webnotes.errprint(["current", sle]) + return buying_amount return 0.0 @@ -78,7 +75,8 @@ def get_stock_ledger_entries(filters): global stock_ledger_entries query = """select item_code, voucher_type, voucher_no, - voucher_detail_no, posting_date, posting_time, stock_value + voucher_detail_no, posting_date, posting_time, stock_value, + warehouse, actual_qty as qty from `tabStock Ledger Entry` where ifnull(`is_cancelled`, "No") = "No" """ if filters.get("company"): @@ -86,4 +84,4 @@ def get_stock_ledger_entries(filters): query += " order by item_code desc, warehouse desc, posting_date desc, posting_time desc, name desc" - stock_ledger_entries = webnotes.conn.sql(query, filters, as_dict=True, debug=1) + stock_ledger_entries = webnotes.conn.sql(query, filters, as_dict=True)