1. Sales Person wise transaction report
2. Sales Person wise target variance report
3. Sales order trend report generation for selection in group by feild
This commit is contained in:
shreyas 2016-01-28 16:38:59 +05:30 committed by Anand Doshi
parent 51db2ba22a
commit e970ddcee9
5 changed files with 32 additions and 21 deletions

View File

@ -98,7 +98,8 @@ def get_data(filters, conditions):
(filters.get("company"), filters.get("fiscal_year"), row[i][0],
data1[d][0]), as_list=1)
des[ind] = row[i]
des[ind] = row[i][0]
for j in range(1,len(conditions["columns"])-inc):
des[j+inc] = row1[0][j]
@ -213,7 +214,7 @@ def based_wise_columns_query(based_on, trans):
elif based_on == "Customer":
based_on_details["based_on_cols"] = ["Customer:Link/Customer:120", "Territory:Link/Territory:120"]
based_on_details["based_on_select"] = "t1.customer_name, t1.territory, "
based_on_details["based_on_group_by"] = 't1.customer_name'
based_on_details["based_on_group_by"] = 't1.customer'
based_on_details["addl_tables"] = ''
elif based_on == "Customer Group":

View File

@ -10,5 +10,4 @@ def execute(filters=None):
data = []
conditions = get_columns(filters, "Sales Order")
data = get_data(filters, conditions)
return conditions["columns"], data

View File

@ -130,30 +130,30 @@ def get_salesperson_item_month_map(filters):
tdd = get_target_distribution_details(filters)
item_groups = get_item_groups()
sim_map = {}
sales_person_achievement_dict = {}
for sd in salesperson_details:
achieved_details = get_achieved_details(filters, sd.name, item_groups)
for month_id in range(1, 13):
month = datetime.date(2013, month_id, 1).strftime('%B')
sim_map.setdefault(sd.name, {}).setdefault(sd.item_group, {})\
sales_person_achievement_dict.setdefault(sd.name, {}).setdefault(sd.item_group, {})\
.setdefault(month, frappe._dict({
"target": 0.0, "achieved": 0.0
}))
tav_dict = sim_map[sd.name][sd.item_group][month]
sales_target_achieved = sales_person_achievement_dict[sd.name][sd.item_group][month]
month_percentage = tdd.get(sd.distribution_id, {}).get(month, 0) \
if sd.distribution_id else 100.0/12
if (filters["target_on"] == "Quantity"):
tav_dict.target = flt(sd.target_qty) * month_percentage / 100
sales_target_achieved.target = flt(sd.target_qty) * month_percentage / 100
else:
tav_dict.target = flt(sd.target_amount) * month_percentage / 100
sales_target_achieved.target = flt(sd.target_amount) * month_percentage / 100
tav_dict.achieved = achieved_details.get(sd.item_group, frappe._dict()).get(month,\
frappe._dict()).get(filters["target_on"].lower())
sales_target_achieved.achieved = achieved_details.get(sd.item_group, frappe._dict()).\
get(month, frappe._dict()).get(filters["target_on"].lower())
return sim_map
return sales_person_achievement_dict
def get_item_groups():
return dict(frappe.get_all("Item", fields=["name", "item_group"], as_list=True))

View File

@ -1,12 +1,13 @@
{
"add_total_row": 1,
"add_total_row": 0,
"apply_user_permissions": 1,
"creation": "2013-05-03 11:31:05",
"disabled": 0,
"docstatus": 0,
"doctype": "Report",
"idx": 1,
"is_standard": "Yes",
"modified": "2014-06-03 07:18:17.312328",
"modified": "2016-01-28 04:22:49.476068",
"modified_by": "Administrator",
"module": "Selling",
"name": "Sales Person-wise Transaction Summary",

View File

@ -4,6 +4,7 @@
from __future__ import unicode_literals
import frappe
from frappe import msgprint, _
from frappe.utils import flt
def execute(filters=None):
if not filters: filters = {}
@ -12,13 +13,22 @@ def execute(filters=None):
entries = get_entries(filters)
item_details = get_item_details()
data = []
total_contribution_amoount = 0
for d in entries:
total_contribution_amoount += flt(d.contribution_amt)
data.append([
d.name, d.customer, d.territory, d.posting_date, d.item_code,
item_details.get(d.item_code, {}).get("item_group"), item_details.get(d.item_code, {}).get("brand"),
d.qty, d.base_net_amount, d.sales_person, d.allocated_percentage, d.contribution_amt
])
if data:
total_row = [""]*len(data[0])
total_row[0] = _("Total")
total_row[-1] = total_contribution_amoount
data.append(total_row)
return columns, data
def get_columns(filters):
@ -60,8 +70,8 @@ def get_conditions(filters, date_field):
values.append(filters[field])
if filters.get("sales_person"):
conditions.append("st.sales_person=%s")
values.append(filters["sales_person"])
lft, rgt = frappe.get_value("Sales Person", filters.get("sales_person"), ["lft", "rgt"])
conditions.append("exists(select name from `tabSales Person` where lft >= %s and rgt <= %s and name=st.sales_person)" % (lft, rgt))
if filters.get("from_date"):
conditions.append("dt.{0}>=%s".format(date_field))