From 24208f5c4a985d1a762251d166808c4f7e85ee89 Mon Sep 17 00:00:00 2001 From: Saurabh Date: Tue, 18 Jun 2013 15:45:08 +0530 Subject: [PATCH] [Report][Item-Wise Purchase Receipt] --- buying/page/buying_home/buying_home.js | 4 ++++ .../item_wise_last_purchase_rate/__init__.py | 0 .../item_wise_last_purchase_rate.txt | 22 +++++++++++++++++++ controllers/trends.py | 6 ++--- 4 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 buying/report/item_wise_last_purchase_rate/__init__.py create mode 100644 buying/report/item_wise_last_purchase_rate/item_wise_last_purchase_rate.txt diff --git a/buying/page/buying_home/buying_home.js b/buying/page/buying_home/buying_home.js index dfcd71e17d..0e078fefc9 100644 --- a/buying/page/buying_home/buying_home.js +++ b/buying/page/buying_home/buying_home.js @@ -120,6 +120,10 @@ wn.module_page["Buying"] = [ route: "query-report/Purchase Order Trends", doctype: "Purchase Order" }, + { + "label":wn._("Item-wise Last Purchase Rate"), + route: "query-report/Item-wise Last Purchase Rate", + } ] } ] diff --git a/buying/report/item_wise_last_purchase_rate/__init__.py b/buying/report/item_wise_last_purchase_rate/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/buying/report/item_wise_last_purchase_rate/item_wise_last_purchase_rate.txt b/buying/report/item_wise_last_purchase_rate/item_wise_last_purchase_rate.txt new file mode 100644 index 0000000000..db99e724ce --- /dev/null +++ b/buying/report/item_wise_last_purchase_rate/item_wise_last_purchase_rate.txt @@ -0,0 +1,22 @@ +[ + { + "creation": "2013-06-18 11:24:36", + "docstatus": 0, + "modified": "2013-06-18 15:28:57", + "modified_by": "Administrator", + "owner": "Administrator" + }, + { + "doctype": "Report", + "is_standard": "Yes", + "name": "__common__", + "query": "select * from (select \n result.item_code as \"Item Code:Link/Item:120\",\n result.item_name as \"Item Name::120\",\n result.description as \"Description::150\",\n result.posting_date as \"Date::150\",\n result.purchase_ref_rate as \"Price List Rate::180\", \n result.discount_rate as \"Discount::120\", \n result.purchase_rate as \"Rate::120\"\nfrom (\n (select \n po_item.item_code,\n po_item.item_name,\n po_item.description,\n po.transaction_date as posting_date,\n po_item.purchase_ref_rate, \n po_item.discount_rate, \n po_item.purchase_rate\n from `tabPurchase Order` po, `tabPurchase Order Item` po_item\n where po.name = po_item.parent and po.docstatus = 1)\n union\n (select \n pr_item.item_code,\n pr_item.item_name,\n pr_item.description,\n pr.posting_date,\n pr_item.purchase_ref_rate,\n pr_item.discount_rate,\n pr_item.purchase_rate\n from `tabPurchase Receipt` pr, `tabPurchase Receipt Item` pr_item\n where pr.name = pr_item.parent and pr.docstatus = 1)\n) result\norder by result.item_code asc, result.posting_date desc) result_wrapper\ngroup by `Item Code:Link/Item:120`\n", + "ref_doctype": "Purchase Order", + "report_name": "Item-wise Last Purchase Rate", + "report_type": "Query Report" + }, + { + "doctype": "Report", + "name": "Item-wise Last Purchase Rate" + } +] \ No newline at end of file diff --git a/controllers/trends.py b/controllers/trends.py index dee9ec8b4f..8905591193 100644 --- a/controllers/trends.py +++ b/controllers/trends.py @@ -83,7 +83,7 @@ def get_data(filters, tab, details): #to get distinct value of col specified by group_by in filter row = webnotes.conn.sql("""select DISTINCT(%s) from `%s` t1, `%s` t2 %s where t2.parent = t1.name and t1.company = %s - and t1.fiscal_year = %s and t1.docstatus = 1 + and t1.fiscal_year = %s and t1.docstatus = 1 and %s = %s """%(sel_col, tab[0], tab[1], details["sup_tab"], "%s", "%s", details["basedon"], "%s"), @@ -224,13 +224,13 @@ def basedon_wise_colums_query(based_on, trans): bon = ["Supplier:Link/Supplier:120", "Supplier Type:Link/Supplier Type:120"] query_details = "t1.supplier, t3.supplier_type," basedon = 't1.supplier' - sup_tab = ',`tabSupplier` t3' + sup_tab = '`tabSupplier` t3', elif based_on == 'Supplier Type': bon = ["Supplier Type:Link/Supplier Type:120"] query_details = "t3.supplier_type," basedon = 't3.supplier_type' - sup_tab = ',`tabSupplier` t3' + sup_tab ='`tabSupplier` t3', elif based_on == "Territory": bon = ["Territory:Link/Territory:120"]