Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: columns and filters for sales analytics report #1410

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion erpnext/config/selling.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def get_data():
{
"type": "report",
"is_query_report": True,
"name": "Sales Analytics",
"name": "Sales Report By Customer",
"doctype": "Sales Order",
"onboard": 1,
},
Expand Down
1 change: 1 addition & 0 deletions erpnext/patches.txt
Original file line number Diff line number Diff line change
Expand Up @@ -726,3 +726,4 @@ erpnext.patches.v13_0.recalculate_outstanding_amount
erpnext.patches.v13_0.add_insight_engine_module
execute:frappe.delete_doc_if_exists("Page", "welcome-to-erpnext")
execute:frappe.delete_doc_if_exists("Report", "Item-Wise Sales Register")
execute:frappe.delete_doc_if_exists("Report", "Sales Analytics")
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// For license information, please see license.txt
/* eslint-disable */

frappe.query_reports["Sales Analytics"] = {
frappe.query_reports["Sales Report By Customer"] = {
"filters": [
{
fieldname: "tree_type",
Expand All @@ -22,11 +22,11 @@ frappe.query_reports["Sales Analytics"] = {
},
{
fieldname: "value_quantity",
label: __("Value Or Qty"),
label: __("Value of Goods Or Qty of Goods"),
fieldtype: "Select",
options: [
{ "value": "Value", "label": __("Value") },
{ "value": "Quantity", "label": __("Quantity") },
{ "value": "Value", "label": __("Value of Goods") },
{ "value": "Quantity", "label": __("Quantity of Goods") },
],
default: "Value",
reqd: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
"modified": "2020-04-30 19:49:02.303320",
"modified_by": "Administrator",
"module": "Selling",
"name": "Sales Analytics",
"name": "Sales Report By Customer",
"owner": "Administrator",
"prepared_report": 0,
"ref_doctype": "Sales Order",
"report_name": "Sales Analytics",
"report_name": "Sales Report By Customer",
"report_type": "Script Report",
"roles": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,7 @@ def run(self):
return self.columns, self.data, None, self.chart

def get_columns(self):
self.columns = [{
"label": _(self.filters.tree_type + " ID"),
"options": self.filters.tree_type if self.filters.tree_type != "Order Type" else "",
"fieldname": "entity",
"fieldtype": "Link" if self.filters.tree_type != "Order Type" else "Data",
"width": 140 if self.filters.tree_type != "Order Type" else 200
}]
self.columns = []

if self.filters.tree_type in ["Customer", "Supplier", "Item"]:
self.columns.append({
sahil28297 marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -58,8 +52,8 @@ def get_columns(self):
if self.filters.tree_type == "Customer":
self.columns.extend([
{
"label": _("City"),
"fieldname": "city",
"label": _("Territory"),
"fieldname": "territory",
"fieldtype": "Data",
"width": 140
},
Expand Down Expand Up @@ -230,10 +224,9 @@ def get_rows(self):
address = get_default_address("Customer", entity)

row.update({
"city": frappe.db.get_value("Address", address, "city"),
"territory": frappe.db.get_value("Customer", entity, "territory"),
"sales_partner": frappe.db.get_value("Customer", entity, "default_sales_partner")
})

total = 0
for end_date in self.periodic_daterange:
period = self.get_period(end_date)
Expand Down Expand Up @@ -292,11 +285,11 @@ def get_periodic_data(self):

def get_period(self, posting_date):
if self.filters.range == 'Weekly':
period = "Week " + str(posting_date.isocalendar()[1]) + " " + str(posting_date.year)
period = "Week " + str(posting_date.isocalendar()[1]) + ", " + str(posting_date.year)
elif self.filters.range == 'Monthly':
period = str(self.months[posting_date.month - 1]) + " " + str(posting_date.year)
period = str(self.months[posting_date.month - 1]) + ", " + str(posting_date.year)
elif self.filters.range == 'Quarterly':
period = "Quarter " + str(((posting_date.month - 1) // 3) + 1) + " " + str(posting_date.year)
period = "Q" + str(((posting_date.month - 1) // 3) + 1) + ", " + str(posting_date.year)
else:
year = get_fiscal_year(posting_date, company=self.filters.company)
period = str(year[0])
Expand Down
4 changes: 2 additions & 2 deletions erpnext/startup/report_data_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@
"company":["Company", "name"]
}
},
"Sales Order Item[Sales Analytics]": {
"Sales Order Item[Sales Report By Customer]": {
"columns": ["name", "parent", "item_code", "stock_qty as qty", "base_net_amount"],
"conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
"order_by": "parent",
Expand All @@ -197,7 +197,7 @@
"company":["Company", "name"]
}
},
"Delivery Note Item[Sales Analytics]": {
"Delivery Note Item[Sales Report By Customer]": {
"columns": ["name", "parent", "item_code", "stock_qty as qty", "base_net_amount"],
"conditions": ["docstatus=1", "ifnull(parent, '')!=''"],
"order_by": "parent",
Expand Down