purchase analytics based on pur order/pur receipt/pur invoice
This commit is contained in:
parent
c53177a412
commit
d1301c7823
@ -35,8 +35,10 @@ erpnext.PurchaseAnalytics = wn.views.TreeGridReport.extend({
|
|||||||
page: wrapper,
|
page: wrapper,
|
||||||
parent: $(wrapper).find('.layout-main'),
|
parent: $(wrapper).find('.layout-main'),
|
||||||
appframe: wrapper.appframe,
|
appframe: wrapper.appframe,
|
||||||
doctypes: ["Item", "Item Group", "Supplier", "Supplier Type", "Company",
|
doctypes: ["Item", "Item Group", "Supplier", "Supplier Type", "Company", "Fiscal Year",
|
||||||
"Purchase Invoice", "Purchase Invoice Item", "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 }
|
tree_grid: { show: true }
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -102,6 +104,8 @@ erpnext.PurchaseAnalytics = wn.views.TreeGridReport.extend({
|
|||||||
filter: function(val, item, opts, me) {
|
filter: function(val, item, opts, me) {
|
||||||
return me.apply_zero_filter(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: "Value or Qty", options:["Value", "Quantity"]},
|
||||||
{fieldtype:"Select", label: "Company", link:"Company",
|
{fieldtype:"Select", label: "Company", link:"Company",
|
||||||
default_value: "Select Company..."},
|
default_value: "Select Company..."},
|
||||||
@ -125,6 +129,10 @@ erpnext.PurchaseAnalytics = wn.views.TreeGridReport.extend({
|
|||||||
me.filter_inputs.refresh.click();
|
me.filter_inputs.refresh.click();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.filter_inputs.based_on.change(function() {
|
||||||
|
me.filter_inputs.refresh.click();
|
||||||
|
});
|
||||||
|
|
||||||
this.show_zero_check()
|
this.show_zero_check()
|
||||||
this.setup_plot_check();
|
this.setup_plot_check();
|
||||||
},
|
},
|
||||||
@ -135,8 +143,6 @@ erpnext.PurchaseAnalytics = wn.views.TreeGridReport.extend({
|
|||||||
prepare_data: function() {
|
prepare_data: function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
if (!this.tl) {
|
if (!this.tl) {
|
||||||
this.make_transaction_list("Purchase Invoice", "Purchase Invoice Item");
|
|
||||||
|
|
||||||
// add 'Not Set' Supplier & Item
|
// add 'Not Set' Supplier & Item
|
||||||
// Add 'All Supplier Types' Supplier Type
|
// Add 'All Supplier Types' Supplier Type
|
||||||
// (Supplier / Item are not mandatory!!)
|
// (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(!this.data || me.item_type != me.tree_type) {
|
||||||
if(me.tree_type=='Supplier') {
|
if(me.tree_type=='Supplier') {
|
||||||
var items = wn.report_dump.data["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 to_date = dateutil.str_to_obj(this.to_date);
|
||||||
var is_val = this.value_or_qty == 'Value';
|
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")) {
|
if (me.is_default('company') ? true : me.apply_filter(tl, "company")) {
|
||||||
var posting_date = dateutil.str_to_obj(tl.posting_date);
|
var posting_date = dateutil.str_to_obj(tl.posting_date);
|
||||||
if (posting_date >= from_date && posting_date <= to_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);
|
item[me.column_map[tl.posting_date].field] += (is_val ? tl.amount : tl.qty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -254,7 +254,42 @@ data_map = {
|
|||||||
"item_code": ["Item", "name"]
|
"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
|
||||||
"Support Ticket": {
|
"Support Ticket": {
|
||||||
"columns": ["name","status","creation","resolution_date","first_responded_on"],
|
"columns": ["name","status","creation","resolution_date","first_responded_on"],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user