mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-08 15:42:52 +00:00
Project wise analysis included in trend analyzer
This commit is contained in:
@@ -5,7 +5,7 @@ report.customize_filters = function() {
|
|||||||
|
|
||||||
this.add_filter({fieldname:'period', label:'Period', fieldtype:'Select', options:'Monthly'+NEWLINE+'Quarterly'+NEWLINE+'Half Yearly'+NEWLINE+'Annual',report_default:'Quarterly',ignore : 1, parent:'Profile',in_first_page:1,single_select:1});
|
this.add_filter({fieldname:'period', label:'Period', fieldtype:'Select', options:'Monthly'+NEWLINE+'Quarterly'+NEWLINE+'Half Yearly'+NEWLINE+'Annual',report_default:'Quarterly',ignore : 1, parent:'Profile',in_first_page:1,single_select:1});
|
||||||
|
|
||||||
this.add_filter({fieldname:'based_on', label:'Based On', fieldtype:'Select', options:'Item'+NEWLINE+'Item Group'+NEWLINE+'Customer'+NEWLINE+'Customer Group'+NEWLINE+'Territory'+NEWLINE+'Supplier'+NEWLINE+'Supplier Type', ignore : 1, parent:'Profile', report_default:'Item', in_first_page : 1,single_select:1});
|
this.add_filter({fieldname:'based_on', label:'Based On', fieldtype:'Select', options:'Item'+NEWLINE+'Item Group'+NEWLINE+'Customer'+NEWLINE+'Customer Group'+NEWLINE+'Territory'+NEWLINE+'Supplier'+NEWLINE+'Supplier Type'+NEWLINE+'Project', ignore : 1, parent:'Profile', report_default:'Item', in_first_page : 1,single_select:1});
|
||||||
|
|
||||||
this.add_filter({fieldname:'group_by', label:'Group By', fieldtype:'Select', options:NEWLINE+'Item'+NEWLINE+'Customer'+NEWLINE+'Supplier', ignore : 1, parent:'Profile',single_select:1});
|
this.add_filter({fieldname:'group_by', label:'Group By', fieldtype:'Select', options:NEWLINE+'Item'+NEWLINE+'Customer'+NEWLINE+'Supplier', ignore : 1, parent:'Profile',single_select:1});
|
||||||
|
|
||||||
@@ -24,6 +24,7 @@ report.customize_filters = function() {
|
|||||||
this.add_filter({fieldname:'territory', label:'Territory', fieldtype:'Link', options:'Territory', ignore : 1, parent:'Profile'});
|
this.add_filter({fieldname:'territory', label:'Territory', fieldtype:'Link', options:'Territory', ignore : 1, parent:'Profile'});
|
||||||
this.add_filter({fieldname:'supplier', label:'Supplier', fieldtype:'Link', options:'Supplier', ignore : 1, parent:'Profile'});
|
this.add_filter({fieldname:'supplier', label:'Supplier', fieldtype:'Link', options:'Supplier', ignore : 1, parent:'Profile'});
|
||||||
this.add_filter({fieldname:'supplier_type', label:'Supplier Type', fieldtype:'Link', options:'Supplier Type', ignore : 1, parent:'Profile'});
|
this.add_filter({fieldname:'supplier_type', label:'Supplier Type', fieldtype:'Link', options:'Supplier Type', ignore : 1, parent:'Profile'});
|
||||||
|
this.add_filter({fieldname:'project', label:'Project', fieldtype:'Link', options:'Project', ignore : 1, parent:'Profile'});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -99,6 +100,10 @@ report.get_query = function() {
|
|||||||
add_cond += ' AND t1.supplier = t3.name';
|
add_cond += ' AND t1.supplier = t3.name';
|
||||||
if(supp_type) add_cond += ' AND t1.supplier_type = "'+supp_type+'"';
|
if(supp_type) add_cond += ' AND t1.supplier_type = "'+supp_type+'"';
|
||||||
break;
|
break;
|
||||||
|
case 'Project' : pro = this.get_filter('Profile', 'Project').get_value();
|
||||||
|
col = 'DISTINCT t1.project_name';
|
||||||
|
if(pro) add_cond += ' AND t1.project_name = "'+pro+'"';
|
||||||
|
break;
|
||||||
case 'Item Group' : ig = this.get_filter('Profile', 'Item Group').get_value();
|
case 'Item Group' : ig = this.get_filter('Profile', 'Item Group').get_value();
|
||||||
if(ig) sp_cond += ' AND parent.name = "'+ig+'"';
|
if(ig) sp_cond += ' AND parent.name = "'+ig+'"';
|
||||||
break;
|
break;
|
||||||
@@ -108,10 +113,11 @@ report.get_query = function() {
|
|||||||
case 'Territory' : ter = this.get_filter('Profile', 'Territory').get_value();
|
case 'Territory' : ter = this.get_filter('Profile', 'Territory').get_value();
|
||||||
if(ter) sp_cond += ' AND parent.name = "'+ter+'"';
|
if(ter) sp_cond += ' AND parent.name = "'+ter+'"';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(based_on == 'Item' || based_on == 'Customer' || based_on == 'Supplier' || based_on == 'Supplier Type')
|
if(based_on == 'Item' || based_on == 'Customer' || based_on == 'Supplier' || based_on == 'Supplier Type' || based_on == 'Project')
|
||||||
var q ='SELECT '+col+' FROM `tab'+trans+'` t1, `tab'+trans_det+'` t2 '+add_tables+' WHERE t1.fiscal_year = "'+fiscal_year+'" and t1.company = "'+company+'" and t2.parent = t1.name '+add_cond;
|
var q ='SELECT '+col+' FROM `tab'+trans+'` t1, `tab'+trans_det+'` t2 '+add_tables+' WHERE t1.fiscal_year = "'+fiscal_year+'" and t1.company = "'+company+'" and t2.parent = t1.name '+add_cond;
|
||||||
else
|
else
|
||||||
var q = 'SELECT CONCAT(REPEAT(" ", COUNT(parent.name) - 1), node.name) AS "Name" FROM `tab'+based_on+'` node,`tab'+based_on+'` parent WHERE node.lft BETWEEN parent.lft and parent.rgt and node.docstatus !=2 '+sp_cond+' GROUP BY node.name ORDER BY node.lft';
|
var q = 'SELECT CONCAT(REPEAT(" ", COUNT(parent.name) - 1), node.name) AS "Name" FROM `tab'+based_on+'` node,`tab'+based_on+'` parent WHERE node.lft BETWEEN parent.lft and parent.rgt and node.docstatus !=2 '+sp_cond+' GROUP BY node.name ORDER BY node.lft';
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ customer_group = filter_values.get('customer_group')
|
|||||||
territory = filter_values.get('territory')
|
territory = filter_values.get('territory')
|
||||||
supplier = filter_values.get('supplier')
|
supplier = filter_values.get('supplier')
|
||||||
supplier_type = filter_values.get('supplier_type')
|
supplier_type = filter_values.get('supplier_type')
|
||||||
|
project = filter_values.get('project')
|
||||||
|
|
||||||
|
|
||||||
# ********************************************* SET DEFAULTS **************************************************
|
# ********************************************* SET DEFAULTS **************************************************
|
||||||
@@ -116,6 +116,9 @@ if supplier_type or based_on == 'Supplier Type':
|
|||||||
add_tab += ' ,`tabSupplier` t14, `tabSupplier Type` t15 '
|
add_tab += ' ,`tabSupplier` t14, `tabSupplier Type` t15 '
|
||||||
add_cond += ' AND t14.name = t1.supplier AND t14.supplier_type = t15.name and t15.name = "%s"' % (based_on != 'Supplier Type' and supplier_type or '%(value)s')
|
add_cond += ' AND t14.name = t1.supplier AND t14.supplier_type = t15.name and t15.name = "%s"' % (based_on != 'Supplier Type' and supplier_type or '%(value)s')
|
||||||
|
|
||||||
|
# Project
|
||||||
|
if project or based_on == 'Project':
|
||||||
|
add_cond += ' AND t1.project_name = "%s"' % (based_on != 'Project' and project or '%(value)s')
|
||||||
|
|
||||||
# Column to be seleted for group by condition
|
# Column to be seleted for group by condition
|
||||||
# ==============================================
|
# ==============================================
|
||||||
|
|||||||
Reference in New Issue
Block a user