Fixed patch and deprecated grid reports
This commit is contained in:
parent
ec5bbe351c
commit
4c79274054
@ -1 +0,0 @@
|
||||
Trends of purchases across Items, Item Groups, Suppliers.
|
@ -1 +0,0 @@
|
||||
from __future__ import unicode_literals
|
@ -1,231 +0,0 @@
|
||||
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
frappe.pages['purchase-analytics'].on_page_load = function(wrapper) {
|
||||
frappe.ui.make_app_page({
|
||||
parent: wrapper,
|
||||
title: __('Purchase Analytics'),
|
||||
single_column: true
|
||||
});
|
||||
|
||||
new erpnext.PurchaseAnalytics(wrapper);
|
||||
|
||||
frappe.breadcrumbs.add("Buying");
|
||||
}
|
||||
|
||||
erpnext.PurchaseAnalytics = frappe.views.TreeGridReport.extend({
|
||||
init: function(wrapper) {
|
||||
this._super({
|
||||
title: __("Purchase Analytics"),
|
||||
parent: $(wrapper).find('.layout-main'),
|
||||
page: wrapper.page,
|
||||
doctypes: ["Item", "Item Group", "Supplier", "Supplier Group", "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 }
|
||||
});
|
||||
|
||||
this.tree_grids = {
|
||||
"Supplier Group": {
|
||||
label: __("Supplier Group / Supplier"),
|
||||
show: true,
|
||||
item_key: "supplier",
|
||||
parent_field: "parent_supplier_group",
|
||||
formatter: function(item) {
|
||||
return item.supplier_name ? item.supplier_name + " (" + item.name + ")" : item.name;
|
||||
}
|
||||
},
|
||||
"Supplier": {
|
||||
label: __("Supplier"),
|
||||
show: false,
|
||||
item_key: "supplier",
|
||||
formatter: function(item) {
|
||||
return item.supplier_name ? item.supplier_name + " (" + item.name + ")" : item.name;
|
||||
}
|
||||
},
|
||||
"Item Group": {
|
||||
label: "Item",
|
||||
show: true,
|
||||
parent_field: "parent_item_group",
|
||||
item_key: "item_code",
|
||||
formatter: function(item) {
|
||||
return item.name;
|
||||
}
|
||||
},
|
||||
"Item": {
|
||||
label: "Item",
|
||||
show: false,
|
||||
item_key: "item_code",
|
||||
formatter: function(item) {
|
||||
return item.name;
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
setup_columns: function() {
|
||||
this.tree_grid = this.tree_grids[this.tree_type];
|
||||
|
||||
var std_columns = [
|
||||
{id: "name", name: this.tree_grid.label, field: "name", width: 300},
|
||||
{id: "total", name: "Total", field: "total", plot: false,
|
||||
formatter: this.currency_formatter}
|
||||
];
|
||||
|
||||
this.make_date_range_columns();
|
||||
this.columns = std_columns.concat(this.columns);
|
||||
},
|
||||
filters: [
|
||||
{fieldtype:"Select", label: __("Tree Type"), fieldname: "tree_type",
|
||||
options:["Supplier Group", "Supplier", "Item Group", "Item"],
|
||||
filter: function(val, item, opts, me) {
|
||||
return me.apply_zero_filter(val, item, opts, me);
|
||||
}},
|
||||
{fieldtype:"Select", label: __("Based On"), fieldname: "based_on",
|
||||
options:["Purchase Invoice", "Purchase Order", "Purchase Receipt"]},
|
||||
{fieldtype:"Select", label: __("Value or Qty"), fieldname: "value_or_qty",
|
||||
options:["Value", "Quantity"]},
|
||||
{fieldtype:"Select", label: __("Company"), link:"Company", fieldname: "company",
|
||||
default_value: __("Select Company...")},
|
||||
{fieldtype:"Date", label: __("From Date"), fieldname: "from_date"},
|
||||
{fieldtype:"Date", label: __("To Date"), fieldname: "to_date"},
|
||||
{fieldtype:"Select", label: __("Range"), fieldname: "range",
|
||||
options:[{label: __("Daily"), value: "Daily"}, {label: __("Weekly"), value: "Weekly"},
|
||||
{label: __("Monthly"), value: "Monthly"}, {label: __("Quarterly"), value: "Quarterly"},
|
||||
{label: __("Yearly"), value: "Yearly"}]}
|
||||
],
|
||||
setup_filters: function() {
|
||||
var me = this;
|
||||
this._super();
|
||||
|
||||
this.trigger_refresh_on_change(["value_or_qty", "tree_type", "based_on", "company"]);
|
||||
|
||||
this.show_zero_check();
|
||||
},
|
||||
init_filter_values: function() {
|
||||
this._super();
|
||||
this.filter_inputs.range.val('Monthly');
|
||||
},
|
||||
prepare_data: function() {
|
||||
var me = this;
|
||||
if (!this.tl) {
|
||||
// add 'Not Set' Supplier & Item
|
||||
// (Supplier / Item are not mandatory!!)
|
||||
frappe.report_dump.data["Supplier"].push({
|
||||
name: __("Not Set"),
|
||||
parent_supplier_group: __("All Supplier Groups"),
|
||||
id: "Not Set",
|
||||
});
|
||||
|
||||
frappe.report_dump.data["Item"].push({
|
||||
name: __("Not Set"),
|
||||
parent_item_group: "All Item Groups",
|
||||
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) {
|
||||
var items;
|
||||
if(me.tree_type=='Supplier') {
|
||||
items = frappe.report_dump.data["Supplier"];
|
||||
} else if(me.tree_type=='Supplier Group') {
|
||||
items = this.prepare_tree("Supplier", "Supplier Group");
|
||||
} else if(me.tree_type=="Item Group") {
|
||||
items = this.prepare_tree("Item", "Item Group");
|
||||
} else if(me.tree_type=="Item") {
|
||||
items = frappe.report_dump.data["Item"];
|
||||
}
|
||||
|
||||
me.item_type = me.tree_type
|
||||
me.parent_map = {};
|
||||
me.item_by_name = {};
|
||||
me.data = [];
|
||||
|
||||
$.each(items, function(i, v) {
|
||||
var d = copy_dict(v);
|
||||
|
||||
me.data.push(d);
|
||||
me.item_by_name[d.name] = d;
|
||||
if(d[me.tree_grid.parent_field]) {
|
||||
me.parent_map[d.name] = d[me.tree_grid.parent_field];
|
||||
}
|
||||
me.reset_item_values(d);
|
||||
});
|
||||
|
||||
this.set_indent();
|
||||
|
||||
} else {
|
||||
// otherwise, only reset values
|
||||
$.each(this.data, function(i, d) {
|
||||
me.reset_item_values(d);
|
||||
});
|
||||
}
|
||||
|
||||
this.prepare_balances();
|
||||
if(me.tree_grid.show) {
|
||||
this.set_totals(false);
|
||||
this.update_groups();
|
||||
} else {
|
||||
this.set_totals(true);
|
||||
}
|
||||
},
|
||||
prepare_balances: function() {
|
||||
var me = this;
|
||||
var from_date = frappe.datetime.str_to_obj(this.from_date);
|
||||
var to_date = frappe.datetime.str_to_obj(this.to_date);
|
||||
var is_val = this.value_or_qty == 'Value';
|
||||
|
||||
$.each(this.tl[this.based_on], function(i, tl) {
|
||||
if (me.is_default('company') ? true : tl.company === me.company) {
|
||||
var posting_date = frappe.datetime.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'];
|
||||
item[me.column_map[tl.posting_date].field] += (is_val ? tl.base_net_amount : tl.qty);
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
update_groups: function() {
|
||||
var me = this;
|
||||
|
||||
$.each(this.data, function(i, item) {
|
||||
var parent = me.parent_map[item.name];
|
||||
while(parent) {
|
||||
var parent_group = me.item_by_name[parent];
|
||||
|
||||
$.each(me.columns, function(c, col) {
|
||||
if (col.formatter == me.currency_formatter) {
|
||||
parent_group[col.field] =
|
||||
flt(parent_group[col.field])
|
||||
+ flt(item[col.field]);
|
||||
}
|
||||
});
|
||||
parent = me.parent_map[parent];
|
||||
}
|
||||
});
|
||||
},
|
||||
set_totals: function(sort) {
|
||||
var me = this;
|
||||
var checked = false;
|
||||
$.each(this.data, function(i, d) {
|
||||
d.total = 0.0;
|
||||
$.each(me.columns, function(i, col) {
|
||||
if(col.formatter==me.currency_formatter && !col.hidden && col.field!="total")
|
||||
d.total += d[col.field];
|
||||
if(d.checked) checked = true;
|
||||
})
|
||||
});
|
||||
|
||||
if(sort)this.data = this.data.sort(function(a, b) { return b.total - a.total; });
|
||||
|
||||
if(!this.checked) {
|
||||
this.data[0].checked = true;
|
||||
}
|
||||
}
|
||||
});
|
@ -1,23 +0,0 @@
|
||||
{
|
||||
"creation": "2012-09-21 20:15:16.000000",
|
||||
"docstatus": 0,
|
||||
"doctype": "Page",
|
||||
"icon": "fa fa-bar-chart",
|
||||
"idx": 1,
|
||||
"modified": "2013-07-11 14:43:52.000000",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Buying",
|
||||
"name": "purchase-analytics",
|
||||
"owner": "Administrator",
|
||||
"page_name": "purchase-analytics",
|
||||
"roles": [
|
||||
{
|
||||
"role": "Analytics"
|
||||
},
|
||||
{
|
||||
"role": "Purchase Manager"
|
||||
}
|
||||
],
|
||||
"standard": "Yes",
|
||||
"title": "Purchase Analytics"
|
||||
}
|
@ -1 +0,0 @@
|
||||
from __future__ import unicode_literals
|
@ -1,155 +0,0 @@
|
||||
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
frappe.pages['production-analytics'].on_page_load = function(wrapper) {
|
||||
frappe.ui.make_app_page({
|
||||
parent: wrapper,
|
||||
title: __('Production Analytics'),
|
||||
single_column: true
|
||||
});
|
||||
|
||||
new erpnext.ProductionAnalytics(wrapper);
|
||||
|
||||
frappe.breadcrumbs.add("Manufacturing");
|
||||
}
|
||||
|
||||
erpnext.ProductionAnalytics = frappe.views.GridReportWithPlot.extend({
|
||||
init: function(wrapper) {
|
||||
this._super({
|
||||
title: __("Production Analytics"),
|
||||
parent: $(wrapper).find('.layout-main'),
|
||||
page: wrapper.page,
|
||||
doctypes: ["Item", "Company", "Fiscal Year", "Work Order"]
|
||||
});
|
||||
|
||||
},
|
||||
setup_columns: function() {
|
||||
|
||||
var std_columns = [
|
||||
{id: "name", name: __("Status"), field: "name", width: 100}
|
||||
];
|
||||
|
||||
this.make_date_range_columns();
|
||||
this.columns = std_columns.concat(this.columns);
|
||||
},
|
||||
filters: [
|
||||
{fieldtype:"Select", label: __("Company"), link:"Company", fieldname: "company",
|
||||
default_value: __("Select Company...")},
|
||||
{fieldtype:"Date", label: __("From Date"), fieldname: "from_date"},
|
||||
{fieldtype:"Date", label: __("To Date"), fieldname: "to_date"},
|
||||
{fieldtype:"Select", label: __("Range"), fieldname: "range",
|
||||
options:[{label: __("Daily"), value: "Daily"}, {label: __("Weekly"), value: "Weekly"},
|
||||
{label: __("Monthly"), value: "Monthly"}, {label: __("Quarterly"), value: "Quarterly"},
|
||||
{label: __("Yearly"), value: "Yearly"}]}
|
||||
],
|
||||
setup_filters: function() {
|
||||
var me = this;
|
||||
this._super();
|
||||
|
||||
this.trigger_refresh_on_change(["company"]);
|
||||
this.trigger_refresh_on_change(["range"]);
|
||||
|
||||
this.show_zero_check();
|
||||
|
||||
},
|
||||
init_filter_values: function() {
|
||||
this._super();
|
||||
this.filter_inputs.range.val('Monthly');
|
||||
},
|
||||
setup_chart: function() {
|
||||
var me = this;
|
||||
|
||||
var chart_data = this.get_chart_data ? this.get_chart_data() : null;
|
||||
|
||||
const parent = this.wrapper.find('.chart')[0];
|
||||
this.chart = new Chart(parent, {
|
||||
height: 200,
|
||||
data: chart_data,
|
||||
type: 'line'
|
||||
});
|
||||
},
|
||||
set_default_values: function() {
|
||||
var values = {
|
||||
from_date: frappe.datetime.str_to_user(frappe.datetime.add_months(frappe.datetime.now_datetime(),-12) ),
|
||||
to_date: frappe.datetime.str_to_user(frappe.datetime.add_months(frappe.datetime.now_datetime(),1))
|
||||
}
|
||||
|
||||
var me = this;
|
||||
$.each(values, function(i, v) {
|
||||
if(me.filter_inputs[i] && !me.filter_inputs[i].val())
|
||||
me.filter_inputs[i].val(v);
|
||||
})
|
||||
},
|
||||
|
||||
prepare_data: function() {
|
||||
// add Opening, Closing, Totals rows
|
||||
// if filtered by account and / or voucher
|
||||
var me = this;
|
||||
var all_open_orders = {name:"All Work Orders", "id": "all-open-pos",
|
||||
checked:true};
|
||||
var not_started = {name:"Not Started", "id":"not-started-pos",
|
||||
checked:true};
|
||||
var overdue = {name:"Overdue (Not Started)", "id":"overdue-pos",
|
||||
checked:true};
|
||||
var pending = {name:"Pending", "id":"pending-pos",
|
||||
checked:true};
|
||||
var completed = {name:"Completed", "id":"completed-pos",
|
||||
checked:true};
|
||||
|
||||
$.each(frappe.report_dump.data["Work Order"], function(i, d) {
|
||||
var dateobj = frappe.datetime.str_to_obj(d.creation);
|
||||
var date = frappe.datetime.str_to_user(d.creation.split(" ")[0]);
|
||||
|
||||
$.each(me.columns, function(i,col) {
|
||||
if (i > 1){
|
||||
var start_period = frappe.datetime.user_to_obj(frappe.datetime.str_to_user(col.id));
|
||||
var end_period = frappe.datetime.user_to_obj(frappe.datetime.str_to_user(col.name));
|
||||
var astart_date = frappe.datetime.user_to_obj(frappe.datetime.str_to_user(d.actual_start_date));
|
||||
var planned_start_date = frappe.datetime.user_to_obj(frappe.datetime.str_to_user(d.planned_start_date));
|
||||
var aend_date = frappe.datetime.user_to_obj(frappe.datetime.str_to_user(d.actual_end_date));
|
||||
var modified = frappe.datetime.user_to_obj(frappe.datetime.str_to_user(d.modified));
|
||||
|
||||
if (dateobj <= start_period || dateobj <= end_period) {
|
||||
all_open_orders[col.field] = flt(all_open_orders[col.field]) + 1;
|
||||
|
||||
if(d.status=="Completed") {
|
||||
if(aend_date < start_period || modified < start_period) {
|
||||
completed[col.field] = flt(completed[col.field]) + 1;
|
||||
}
|
||||
else if (astart_date < start_period) {
|
||||
pending[col.field] = flt(pending[col.field]) + 1;
|
||||
}
|
||||
else if (planned_start_date < start_period) {
|
||||
overdue[col.field] = flt(overdue[col.field]) + 1;
|
||||
} else {
|
||||
not_started[col.field] = flt(not_started[col.field]) + 1;
|
||||
}
|
||||
}else if(d.status == "In Process")
|
||||
{
|
||||
if (astart_date < start_period || modified < start_period){
|
||||
pending[col.field] = flt(pending[col.field]) + 1;
|
||||
}else if (planned_start_date < start_period) {
|
||||
overdue[col.field] = flt(overdue[col.field]) + 1;
|
||||
}else{
|
||||
not_started[col.field] = flt(not_started[col.field]) + 1;
|
||||
}
|
||||
}else if(d.status == "Not Started") {
|
||||
if (planned_start_date < start_period){
|
||||
overdue[col.field] = flt(overdue[col.field]) + 1;
|
||||
}else{
|
||||
not_started[col.field] = flt(not_started[col.field]) + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
if(me.columns.length < 30){
|
||||
this.chart_area.toggle(true);
|
||||
}else {
|
||||
this.chart_area.toggle(false);
|
||||
}
|
||||
this.data = [all_open_orders, not_started, overdue, pending, completed];
|
||||
|
||||
}
|
||||
});
|
@ -1,26 +0,0 @@
|
||||
{
|
||||
"content": null,
|
||||
"creation": "2012-09-21 20:15:16",
|
||||
"docstatus": 0,
|
||||
"doctype": "Page",
|
||||
"icon": "fa fa-bar-chart",
|
||||
"idx": 1,
|
||||
"modified": "2017-02-20 17:33:05.913097",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Manufacturing",
|
||||
"name": "production-analytics",
|
||||
"owner": "Administrator",
|
||||
"page_name": "production-analytics",
|
||||
"roles": [
|
||||
{
|
||||
"role": "Analytics"
|
||||
},
|
||||
{
|
||||
"role": "Manufacturing Manager"
|
||||
}
|
||||
],
|
||||
"script": null,
|
||||
"standard": "Yes",
|
||||
"style": null,
|
||||
"title": "Production Analytics"
|
||||
}
|
@ -568,10 +568,10 @@ erpnext.patches.v11_0.remove_land_unit_icon
|
||||
erpnext.patches.v11_0.add_default_dispatch_notification_template
|
||||
erpnext.patches.v11_0.add_market_segments
|
||||
erpnext.patches.v11_0.add_sales_stages
|
||||
execute:frappe.delete_doc("Page", "sales-analytics")
|
||||
execute:frappe.delete_doc("Page", "purchase-analytics")
|
||||
execute:frappe.delete_doc("Page", "stock-analytics")
|
||||
execute:frappe.delete_doc("Page", "production-analytics")
|
||||
execute:frappe.delete_doc_if_exists("Page", "sales-analytics")
|
||||
execute:frappe.delete_doc_if_exists("Page", "purchase-analytics")
|
||||
execute:frappe.delete_doc_if_exists("Page", "stock-analytics")
|
||||
execute:frappe.delete_doc_if_exists("Page", "production-analytics")
|
||||
erpnext.patches.v11_0.ewaybill_fields_gst_india #2018-11-13
|
||||
erpnext.patches.v11_0.drop_column_max_days_allowed
|
||||
erpnext.patches.v11_0.change_healthcare_desktop_icons
|
||||
|
@ -1 +0,0 @@
|
||||
Trends of sales by Item, Item Group, Customer etc.
|
@ -1 +0,0 @@
|
||||
from __future__ import unicode_literals
|
@ -1,246 +0,0 @@
|
||||
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
frappe.pages['sales-analytics'].on_page_load = function(wrapper) {
|
||||
frappe.ui.make_app_page({
|
||||
parent: wrapper,
|
||||
title: __('Sales Analytics'),
|
||||
single_column: true
|
||||
});
|
||||
new erpnext.SalesAnalytics(wrapper);
|
||||
|
||||
|
||||
frappe.breadcrumbs.add("Selling")
|
||||
|
||||
};
|
||||
|
||||
erpnext.SalesAnalytics = frappe.views.TreeGridReport.extend({
|
||||
init: function(wrapper) {
|
||||
this._super({
|
||||
title: __("Sales Analytics"),
|
||||
parent: $(wrapper).find('.layout-main'),
|
||||
page: wrapper.page,
|
||||
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 }
|
||||
});
|
||||
|
||||
this.tree_grids = {
|
||||
"Customer Group": {
|
||||
label: __("Customer Group / Customer"),
|
||||
show: true,
|
||||
item_key: "customer",
|
||||
parent_field: "parent_customer_group",
|
||||
formatter: function(item) {
|
||||
return item.customer_name? item.customer_name + " (" + item.name + ")" : item.name;
|
||||
}
|
||||
},
|
||||
"Customer": {
|
||||
label: __("Customer"),
|
||||
show: false,
|
||||
item_key: "customer",
|
||||
formatter: function(item) {
|
||||
return item.customer_name? item.customer_name + " (" + item.name + ")" : item.name;
|
||||
}
|
||||
},
|
||||
"Item Group": {
|
||||
label: __("Item"),
|
||||
show: true,
|
||||
parent_field: "parent_item_group",
|
||||
item_key: "item_code",
|
||||
formatter: function(item) {
|
||||
return item.name;
|
||||
}
|
||||
},
|
||||
"Item": {
|
||||
label: __("Item"),
|
||||
show: false,
|
||||
item_key: "item_code",
|
||||
formatter: function(item) {
|
||||
return item.name;
|
||||
}
|
||||
},
|
||||
"Territory": {
|
||||
label: __("Territory / Customer"),
|
||||
show: true,
|
||||
item_key: "customer",
|
||||
parent_field: "parent_territory",
|
||||
formatter: function(item) {
|
||||
return item.customer_name? item.customer_name + " (" + item.name + ")" : item.name;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
setup_columns: function() {
|
||||
this.tree_grid = this.tree_grids[this.tree_type];
|
||||
|
||||
var std_columns = [
|
||||
{id: "name", name: this.tree_grid.label, field: "name", width: 300},
|
||||
{id: "total", name: "Total", field: "total", plot: false,
|
||||
formatter: this.currency_formatter}
|
||||
];
|
||||
|
||||
this.make_date_range_columns();
|
||||
this.columns = std_columns.concat(this.columns);
|
||||
},
|
||||
filters: [
|
||||
{fieldtype:"Select", fieldname: "tree_type", label: __("Tree Type"), options:["Customer Group", "Customer",
|
||||
"Item Group", "Item", "Territory"],
|
||||
filter: function(val, item, opts, me) {
|
||||
return me.apply_zero_filter(val, item, opts, me);
|
||||
}},
|
||||
{fieldtype:"Select", fieldname: "based_on", label: __("Based On"), options:["Sales Invoice",
|
||||
"Sales Order", "Delivery Note"]},
|
||||
{fieldtype:"Select", fieldname: "value_or_qty", label: __("Value or Qty"),
|
||||
options:[{label: __("Value"), value: "Value"}, {label: __("Quantity"), value: "Quantity"}]},
|
||||
{fieldtype:"Date", fieldname: "from_date", label: __("From Date")},
|
||||
{fieldtype:"Label", fieldname: "to", label: __("To")},
|
||||
{fieldtype:"Date", fieldname: "to_date", label: __("To Date")},
|
||||
{fieldtype:"Select", fieldname: "company", label: __("Company"), link:"Company",
|
||||
default_value: __("Select Company...")},
|
||||
{fieldtype:"Select", label: __("Range"), fieldname: "range",
|
||||
options:[{label: __("Daily"), value: "Daily"}, {label: __("Weekly"), value: "Weekly"},
|
||||
{label: __("Monthly"), value: "Monthly"}, {label: __("Quarterly"), value: "Quarterly"},
|
||||
{label: __("Yearly"), value: "Yearly"}]}
|
||||
],
|
||||
setup_filters: function() {
|
||||
var me = this;
|
||||
this._super();
|
||||
|
||||
this.trigger_refresh_on_change(["value_or_qty", "tree_type", "based_on", "company"]);
|
||||
|
||||
this.show_zero_check();
|
||||
},
|
||||
init_filter_values: function() {
|
||||
this._super();
|
||||
this.filter_inputs.range.val('Monthly');
|
||||
},
|
||||
prepare_data: function() {
|
||||
var me = this;
|
||||
if (!this.tl) {
|
||||
// add 'Not Set' Customer & Item
|
||||
// (Customer / Item are not mandatory!!)
|
||||
frappe.report_dump.data["Customer"].push({
|
||||
name: "Not Set",
|
||||
parent_customer_group: "All Customer Groups",
|
||||
parent_territory: "All Territories",
|
||||
id: "Not Set",
|
||||
});
|
||||
|
||||
frappe.report_dump.data["Item"].push({
|
||||
name: "Not Set",
|
||||
parent_item_group: "All Item Groups",
|
||||
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') {
|
||||
var items = frappe.report_dump.data["Customer"];
|
||||
} if(me.tree_type=='Customer Group') {
|
||||
var items = this.prepare_tree("Customer", "Customer Group");
|
||||
} else if(me.tree_type=="Item Group") {
|
||||
var items = this.prepare_tree("Item", "Item Group");
|
||||
} else if(me.tree_type=="Item") {
|
||||
var items = frappe.report_dump.data["Item"];
|
||||
} else if(me.tree_type=="Territory") {
|
||||
var items = this.prepare_tree("Customer", "Territory");
|
||||
}
|
||||
|
||||
me.item_type = me.tree_type
|
||||
me.parent_map = {};
|
||||
me.item_by_name = {};
|
||||
me.data = [];
|
||||
|
||||
$.each(items, function(i, v) {
|
||||
var d = copy_dict(v);
|
||||
|
||||
me.data.push(d);
|
||||
me.item_by_name[d.name] = d;
|
||||
if(d[me.tree_grid.parent_field]) {
|
||||
me.parent_map[d.name] = d[me.tree_grid.parent_field];
|
||||
}
|
||||
me.reset_item_values(d);
|
||||
});
|
||||
|
||||
this.set_indent();
|
||||
|
||||
} else {
|
||||
// otherwise, only reset values
|
||||
$.each(this.data, function(i, d) {
|
||||
me.reset_item_values(d);
|
||||
});
|
||||
}
|
||||
|
||||
this.prepare_balances();
|
||||
if(me.tree_grid.show) {
|
||||
this.set_totals(false);
|
||||
this.update_groups();
|
||||
} else {
|
||||
this.set_totals(true);
|
||||
}
|
||||
|
||||
},
|
||||
prepare_balances: function() {
|
||||
var me = this;
|
||||
var from_date = frappe.datetime.str_to_obj(this.from_date);
|
||||
var to_date = frappe.datetime.str_to_obj(this.to_date);
|
||||
var is_val = this.value_or_qty == 'Value';
|
||||
|
||||
$.each(this.tl[this.based_on], function(i, tl) {
|
||||
if (me.is_default('company') ? true : tl.company === me.company) {
|
||||
var posting_date = frappe.datetime.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'];
|
||||
if(item){
|
||||
item[me.column_map[tl.posting_date].field] += (is_val ? tl.base_net_amount : tl.qty);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
update_groups: function() {
|
||||
var me = this;
|
||||
|
||||
$.each(this.data, function(i, item) {
|
||||
var parent = me.parent_map[item.name];
|
||||
while(parent) {
|
||||
var parent_group = me.item_by_name[parent];
|
||||
|
||||
$.each(me.columns, function(c, col) {
|
||||
if (col.formatter == me.currency_formatter) {
|
||||
parent_group[col.field] =
|
||||
flt(parent_group[col.field])
|
||||
+ flt(item[col.field]);
|
||||
}
|
||||
});
|
||||
parent = me.parent_map[parent];
|
||||
}
|
||||
});
|
||||
},
|
||||
set_totals: function(sort) {
|
||||
var me = this;
|
||||
var checked = false;
|
||||
$.each(this.data, function(i, d) {
|
||||
d.total = 0.0;
|
||||
$.each(me.columns, function(i, col) {
|
||||
if(col.formatter==me.currency_formatter && !col.hidden && col.field!="total")
|
||||
d.total += d[col.field];
|
||||
if(d.checked) checked = true;
|
||||
})
|
||||
});
|
||||
|
||||
if(sort)this.data = this.data.sort(function(a, b) { return a.total < b.total; });
|
||||
|
||||
if(!this.checked) {
|
||||
this.data[0].checked = true;
|
||||
}
|
||||
}
|
||||
});
|
@ -1,26 +0,0 @@
|
||||
{
|
||||
"creation": "2012-09-21 20:15:12.000000",
|
||||
"docstatus": 0,
|
||||
"doctype": "Page",
|
||||
"icon": "fa fa-bar-chart",
|
||||
"idx": 1,
|
||||
"modified": "2013-07-11 14:43:59.000000",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Selling",
|
||||
"name": "sales-analytics",
|
||||
"owner": "Administrator",
|
||||
"page_name": "sales-analytics",
|
||||
"roles": [
|
||||
{
|
||||
"role": "Analytics"
|
||||
},
|
||||
{
|
||||
"role": "Sales Manager"
|
||||
},
|
||||
{
|
||||
"role": "Maintenance Manager"
|
||||
}
|
||||
],
|
||||
"standard": "Yes",
|
||||
"title": "Sales Analytics"
|
||||
}
|
@ -1 +0,0 @@
|
||||
Trends of Items quantities and values.
|
@ -1 +0,0 @@
|
||||
from __future__ import unicode_literals
|
@ -1,16 +0,0 @@
|
||||
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
frappe.pages['stock-analytics'].on_page_load = function(wrapper) {
|
||||
frappe.ui.make_app_page({
|
||||
parent: wrapper,
|
||||
title: __('Stock Analytics'),
|
||||
single_column: true
|
||||
});
|
||||
|
||||
frappe.require(["assets/erpnext/js/stock_grid_report.js",
|
||||
"assets/erpnext/js/stock_analytics.js"], function() {
|
||||
new erpnext.StockAnalytics(wrapper);
|
||||
frappe.breadcrumbs.add("Stock")
|
||||
});
|
||||
};
|
@ -1,23 +0,0 @@
|
||||
{
|
||||
"creation": "2012-09-21 20:15:14.000000",
|
||||
"docstatus": 0,
|
||||
"doctype": "Page",
|
||||
"icon": "fa fa-bar-chart",
|
||||
"idx": 1,
|
||||
"modified": "2013-07-11 14:44:10.000000",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Stock",
|
||||
"name": "stock-analytics",
|
||||
"owner": "Administrator",
|
||||
"page_name": "stock-analytics",
|
||||
"roles": [
|
||||
{
|
||||
"role": "Analytics"
|
||||
},
|
||||
{
|
||||
"role": "Material Manager"
|
||||
}
|
||||
],
|
||||
"standard": "Yes",
|
||||
"title": "Stock Analytics"
|
||||
}
|
Loading…
Reference in New Issue
Block a user