From a3b9b1a8686765b860ef9795a662edfb9604a0a7 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Fri, 22 Mar 2013 13:16:10 +0530 Subject: [PATCH] added filters from date and to date --- accounts/report/gross_profit/gross_profit.js | 12 ++++++++++++ accounts/report/gross_profit/gross_profit.py | 13 +++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/accounts/report/gross_profit/gross_profit.js b/accounts/report/gross_profit/gross_profit.js index 1f07df9e81..aa6be5528f 100644 --- a/accounts/report/gross_profit/gross_profit.js +++ b/accounts/report/gross_profit/gross_profit.js @@ -7,5 +7,17 @@ wn.query_reports["Gross Profit"] = { "options": "Company", "default": wn.defaults.get_user_default("company") }, + { + "fieldname":"from_date", + "label": "From Date", + "fieldtype": "Date", + "default": wn.defaults.get_user_default("year_start_date") + }, + { + "fieldname":"to_date", + "label": "To Date", + "fieldtype": "Date", + "default": wn.defaults.get_user_default("year_end_date") + }, ] } \ No newline at end of file diff --git a/accounts/report/gross_profit/gross_profit.py b/accounts/report/gross_profit/gross_profit.py index a4791616a1..5c06637fda 100644 --- a/accounts/report/gross_profit/gross_profit.py +++ b/accounts/report/gross_profit/gross_profit.py @@ -8,10 +8,10 @@ def execute(filters=None): stock_ledger_entries = get_stock_ledger_entries(filters) - item_sales_bom = get_item_sales_bom() - source = get_source_data(filters) + item_sales_bom = get_item_sales_bom() + columns = ["Delivery Note/Sales Invoice::120", "Posting Date:Date", "Posting Time", "Item Code:Link/Item", "Item Name", "Description", "Warehouse:Link/Warehouse", "Qty:Float", "Selling Rate:Currency", "Selling Amount:Currency", "Buying Amount:Currency", @@ -43,7 +43,8 @@ def get_stock_ledger_entries(filters): query = """select item_code, voucher_type, voucher_no, voucher_detail_no, posting_date, posting_time, stock_value, warehouse, actual_qty as qty - from `tabStock Ledger Entry` where ifnull(`is_cancelled`, "No") = "No" """ + from `tabStock Ledger Entry` + where ifnull(`is_cancelled`, "No") = "No" """ if filters.get("company"): query += """ and company=%(company)s""" @@ -57,7 +58,7 @@ def get_item_sales_bom(): for d in webnotes.conn.sql("""select parenttype, parent, parent_item, item_code, warehouse, -1*qty as total_qty - from `tabDelivery Note Packing Item` where docstatus=1""", as_dict=1): + from `tabDelivery Note Packing Item` where docstatus=1""", as_dict=True): item_sales_bom.setdefault(d.parenttype, webnotes._dict()).setdefault(d.parent, webnotes._dict()).setdefault(d.parent_item, []).append(d) @@ -67,6 +68,10 @@ def get_source_data(filters): conditions = "" if filters.get("company"): conditions += " and company=%(company)s" + if filters.get("from_date"): + conditions += " and posting_date>=%(from_date)s" + if filters.get("to_date"): + conditions += " and posting_date<=%(to_date)s" delivery_note_items = webnotes.conn.sql("""select item.parenttype, dn.name, dn.posting_date, dn.posting_time, dn.project_name,