From 665175e0c15a73523ce48512b740937b1654077a Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 24 Jan 2013 16:08:26 +0530 Subject: [PATCH 1/3] fixes in territory link to sales browser --- selling/doctype/lead/lead.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/selling/doctype/lead/lead.txt b/selling/doctype/lead/lead.txt index 0d4983a87f..688c65385b 100644 --- a/selling/doctype/lead/lead.txt +++ b/selling/doctype/lead/lead.txt @@ -1,8 +1,8 @@ [ { - "creation": "2013-01-10 16:34:18", + "creation": "2013-01-22 16:50:33", "docstatus": 0, - "modified": "2013-01-22 14:56:03", + "modified": "2013-01-24 16:06:05", "modified_by": "Administrator", "owner": "Administrator" }, @@ -227,7 +227,7 @@ "oldfieldtype": "Data" }, { - "description": "To manage Territory, click here", + "description": "To manage Territory, click here", "doctype": "DocField", "fieldname": "territory", "fieldtype": "Link", @@ -470,6 +470,6 @@ { "cancel": 0, "doctype": "DocPerm", - "role": "System Manager" + "role": "Guest" } ] \ No newline at end of file From 96601597e32aa7b5ab7a1ef9ec21fb6a0830689f Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 24 Jan 2013 18:24:33 +0530 Subject: [PATCH 2/3] sales analytics based on sales order/delivery note/sales invoice --- .../page/sales_analytics/sales_analytics.js | 31 +++++++++------- startup/report_data_map.py | 37 +++++++++++++++++++ 2 files changed, 55 insertions(+), 13 deletions(-) diff --git a/selling/page/sales_analytics/sales_analytics.js b/selling/page/sales_analytics/sales_analytics.js index 3d54203c54..499c6c0156 100644 --- a/selling/page/sales_analytics/sales_analytics.js +++ b/selling/page/sales_analytics/sales_analytics.js @@ -34,8 +34,10 @@ erpnext.SalesAnalytics = wn.views.TreeGridReport.extend({ page: wrapper, parent: $(wrapper).find('.layout-main'), appframe: wrapper.appframe, - doctypes: ["Item", "Item Group", "Customer", "Customer Group", "Company", - "Sales Invoice", "Sales Invoice Item", "Territory"], + doctypes: ["Item", "Item Group", "Customer", "Customer Group", "Company", "Territory", + "Fiscal Year", "Sales Invoice", "Sales Invoice Item", + "Sales Order", "Sales Order Item[Sales Analytics]", + "Delivery Note", "Delivery Note Item[Sales Analytics]"], tree_grid: { show: true } }); @@ -45,13 +47,7 @@ erpnext.SalesAnalytics = wn.views.TreeGridReport.extend({ show: true, item_key: "customer", parent_field: "parent_customer_group", - formatter: function(item) { - // return repl('%(value)s', { - // value: item.name, - // enc_value: encodeURIComponent(item.name) - // }); - return item.name; - } + formatter: function(item) { return item.name; } }, "Customer": { label: "Customer", @@ -110,6 +106,8 @@ erpnext.SalesAnalytics = wn.views.TreeGridReport.extend({ filter: function(val, item, opts, me) { return me.apply_zero_filter(val, item, opts, me); }}, + {fieldtype:"Select", label: "Based On", options:["Sales Invoice", + "Sales Order", "Delivery Note"]}, {fieldtype:"Select", label: "Value or Qty", options:["Value", "Quantity"]}, {fieldtype:"Select", label: "Company", link:"Company", default_value: "Select Company..."}, @@ -132,6 +130,10 @@ erpnext.SalesAnalytics = wn.views.TreeGridReport.extend({ this.filter_inputs.tree_type.change(function() { me.filter_inputs.refresh.click(); }); + + this.filter_inputs.based_on.change(function() { + me.filter_inputs.refresh.click(); + }); this.show_zero_check() this.setup_plot_check(); @@ -143,8 +145,6 @@ erpnext.SalesAnalytics = wn.views.TreeGridReport.extend({ prepare_data: function() { var me = this; if (!this.tl) { - this.make_transaction_list("Sales Invoice", "Sales Invoice Item"); - // add 'Not Set' Customer & Item // (Customer / Item are not mandatory!!) wn.report_dump.data["Customer"].push({ @@ -160,6 +160,10 @@ erpnext.SalesAnalytics = wn.views.TreeGridReport.extend({ id: "Not Set", }); } + + if (!this.tl || !this.tl[this.based_on]) { + this.make_transaction_list(this.based_on, this.based_on + " Item"); + } if(!this.data || me.item_type != me.tree_type) { if(me.tree_type=='Customer') { @@ -214,11 +218,12 @@ erpnext.SalesAnalytics = wn.views.TreeGridReport.extend({ var to_date = dateutil.str_to_obj(this.to_date); var is_val = this.value_or_qty == 'Value'; - $.each(this.tl, function(i, tl) { + $.each(this.tl[this.based_on], function(i, tl) { if (me.is_default('company') ? true : me.apply_filter(tl, "company")) { var posting_date = dateutil.str_to_obj(tl.posting_date); if (posting_date >= from_date && posting_date <= to_date) { - var item = me.item_by_name[tl[me.tree_grid.item_key]] || me.item_by_name['Not Set']; + var item = me.item_by_name[tl[me.tree_grid.item_key]] || + me.item_by_name['Not Set']; item[me.column_map[tl.posting_date].field] += (is_val ? tl.amount : tl.qty); } } diff --git a/startup/report_data_map.py b/startup/report_data_map.py index 06bbf44e12..feffae78a9 100644 --- a/startup/report_data_map.py +++ b/startup/report_data_map.py @@ -134,6 +134,7 @@ data_map = { "warehouse": ["Warehouse", "name"] }, }, + "Sales Order Item": { "columns": ["item_code", "(ifnull(qty, 0) - ifnull(delivered_qty, 0)) as qty", "reserved_warehouse as warehouse"], @@ -185,6 +186,42 @@ data_map = { "item_code": ["Item", "name"] } }, + "Sales Order": { + "columns": ["name", "customer", "transaction_date as posting_date", "company"], + "conditions": ["docstatus=1"], + "order_by": "transaction_date", + "links": { + "customer": ["Customer", "name"], + "company":["Company", "name"] + } + }, + "Sales Order Item[Sales Analytics]": { + "columns": ["parent", "item_code", "qty", "amount"], + "conditions": ["docstatus=1", "ifnull(parent, '')!=''"], + "order_by": "parent", + "links": { + "parent": ["Sales Order", "name"], + "item_code": ["Item", "name"] + } + }, + "Delivery Note": { + "columns": ["name", "customer", "posting_date", "company"], + "conditions": ["docstatus=1"], + "order_by": "posting_date", + "links": { + "customer": ["Customer", "name"], + "company":["Company", "name"] + } + }, + "Delivery Note Item[Sales Analytics]": { + "columns": ["parent", "item_code", "qty", "amount"], + "conditions": ["docstatus=1", "ifnull(parent, '')!=''"], + "order_by": "parent", + "links": { + "parent": ["Delivery Note", "name"], + "item_code": ["Item", "name"] + } + }, "Supplier": { "columns": ["name", "if(supplier_name=name, '', supplier_name) as supplier_name", "supplier_type as parent_supplier_type"], From d1301c7823af4f6c0315dc51b37e8e515a6b8e7c Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 24 Jan 2013 18:38:30 +0530 Subject: [PATCH 3/3] purchase analytics based on pur order/pur receipt/pur invoice --- .../purchase_analytics/purchase_analytics.js | 26 +++++++++---- startup/report_data_map.py | 37 ++++++++++++++++++- 2 files changed, 55 insertions(+), 8 deletions(-) diff --git a/buying/page/purchase_analytics/purchase_analytics.js b/buying/page/purchase_analytics/purchase_analytics.js index 6919ad3a87..7d8171ebbd 100644 --- a/buying/page/purchase_analytics/purchase_analytics.js +++ b/buying/page/purchase_analytics/purchase_analytics.js @@ -35,8 +35,10 @@ erpnext.PurchaseAnalytics = wn.views.TreeGridReport.extend({ page: wrapper, parent: $(wrapper).find('.layout-main'), appframe: wrapper.appframe, - doctypes: ["Item", "Item Group", "Supplier", "Supplier Type", "Company", - "Purchase Invoice", "Purchase Invoice Item", "Fiscal Year"], + doctypes: ["Item", "Item Group", "Supplier", "Supplier Type", "Company", "Fiscal Year", + "Purchase Invoice", "Purchase Invoice Item", + "Purchase Order", "Purchase Order Item[Purchase Analytics]", + "Purchase Receipt", "Purchase Receipt Item[Purchase Analytics]"], tree_grid: { show: true } }); @@ -102,6 +104,8 @@ erpnext.PurchaseAnalytics = wn.views.TreeGridReport.extend({ filter: function(val, item, opts, me) { return me.apply_zero_filter(val, item, opts, me); }}, + {fieldtype:"Select", label: "Based On", options:["Purchase Invoice", + "Purchase Order", "Purchase Receipt"]}, {fieldtype:"Select", label: "Value or Qty", options:["Value", "Quantity"]}, {fieldtype:"Select", label: "Company", link:"Company", default_value: "Select Company..."}, @@ -124,7 +128,11 @@ erpnext.PurchaseAnalytics = wn.views.TreeGridReport.extend({ this.filter_inputs.tree_type.change(function() { me.filter_inputs.refresh.click(); }); - + + this.filter_inputs.based_on.change(function() { + me.filter_inputs.refresh.click(); + }); + this.show_zero_check() this.setup_plot_check(); }, @@ -135,8 +143,6 @@ erpnext.PurchaseAnalytics = wn.views.TreeGridReport.extend({ prepare_data: function() { var me = this; if (!this.tl) { - this.make_transaction_list("Purchase Invoice", "Purchase Invoice Item"); - // add 'Not Set' Supplier & Item // Add 'All Supplier Types' Supplier Type // (Supplier / Item are not mandatory!!) @@ -164,6 +170,11 @@ erpnext.PurchaseAnalytics = wn.views.TreeGridReport.extend({ }); } + if (!this.tl || !this.tl[this.based_on]) { + this.make_transaction_list(this.based_on, this.based_on + " Item"); + } + + if(!this.data || me.item_type != me.tree_type) { if(me.tree_type=='Supplier') { var items = wn.report_dump.data["Supplier"]; @@ -214,11 +225,12 @@ erpnext.PurchaseAnalytics = wn.views.TreeGridReport.extend({ var to_date = dateutil.str_to_obj(this.to_date); var is_val = this.value_or_qty == 'Value'; - $.each(this.tl, function(i, tl) { + $.each(this.tl[this.based_on], function(i, tl) { if (me.is_default('company') ? true : me.apply_filter(tl, "company")) { var posting_date = dateutil.str_to_obj(tl.posting_date); if (posting_date >= from_date && posting_date <= to_date) { - var item = me.item_by_name[tl[me.tree_grid.item_key]] || me.item_by_name['Not Set']; + var item = me.item_by_name[tl[me.tree_grid.item_key]] || + me.item_by_name['Not Set']; item[me.column_map[tl.posting_date].field] += (is_val ? tl.amount : tl.qty); } } diff --git a/startup/report_data_map.py b/startup/report_data_map.py index feffae78a9..dc1833d1e2 100644 --- a/startup/report_data_map.py +++ b/startup/report_data_map.py @@ -254,7 +254,42 @@ data_map = { "item_code": ["Item", "name"] } }, - + "Purchase Order": { + "columns": ["name", "supplier", "transaction_date as posting_date", "company"], + "conditions": ["docstatus=1"], + "order_by": "posting_date", + "links": { + "supplier": ["Supplier", "name"], + "company":["Company", "name"] + } + }, + "Purchase Order Item[Purchase Analytics]": { + "columns": ["parent", "item_code", "qty", "amount"], + "conditions": ["docstatus=1", "ifnull(parent, '')!=''"], + "order_by": "parent", + "links": { + "parent": ["Purchase Order", "name"], + "item_code": ["Item", "name"] + } + }, + "Purchase Receipt": { + "columns": ["name", "supplier", "posting_date", "company"], + "conditions": ["docstatus=1"], + "order_by": "posting_date", + "links": { + "supplier": ["Supplier", "name"], + "company":["Company", "name"] + } + }, + "Purchase Receipt Item[Purchase Analytics]": { + "columns": ["parent", "item_code", "qty", "amount"], + "conditions": ["docstatus=1", "ifnull(parent, '')!=''"], + "order_by": "parent", + "links": { + "parent": ["Purchase Receipt", "name"], + "item_code": ["Item", "name"] + } + }, # Support "Support Ticket": { "columns": ["name","status","creation","resolution_date","first_responded_on"],