Merge branch '1310' of github.com:webnotes/erpnext into 1310
This commit is contained in:
commit
7373a83043
@ -17,7 +17,6 @@ def execute(filters=None):
|
|||||||
cam_map = get_costcenter_account_month_map(filters)
|
cam_map = get_costcenter_account_month_map(filters)
|
||||||
|
|
||||||
data = []
|
data = []
|
||||||
|
|
||||||
for cost_center, cost_center_items in cam_map.items():
|
for cost_center, cost_center_items in cam_map.items():
|
||||||
for account, monthwise_data in cost_center_items.items():
|
for account, monthwise_data in cost_center_items.items():
|
||||||
row = [cost_center, account]
|
row = [cost_center, account]
|
||||||
@ -120,8 +119,7 @@ def get_costcenter_account_month_map(filters):
|
|||||||
tav_dict.target = flt(ccd.budget_allocated) * month_percentage /100
|
tav_dict.target = flt(ccd.budget_allocated) * month_percentage /100
|
||||||
|
|
||||||
for ad in actual_details.get(ccd.name, {}).get(ccd.account, []):
|
for ad in actual_details.get(ccd.name, {}).get(ccd.account, []):
|
||||||
if ad.month_name == month and ad.account == ccd.account \
|
if ad.month_name == month:
|
||||||
and ad.cost_center == ccd.name:
|
|
||||||
tav_dict.actual += ad.debit - ad.credit
|
tav_dict.actual += ad.debit - ad.credit
|
||||||
|
|
||||||
return cam_map
|
return cam_map
|
||||||
@ -3,10 +3,6 @@
|
|||||||
|
|
||||||
wn.require('app/setup/doctype/contact_control/contact_control.js');
|
wn.require('app/setup/doctype/contact_control/contact_control.js');
|
||||||
|
|
||||||
cur_frm.cscript.onload = function(doc,dt,dn){
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
cur_frm.cscript.refresh = function(doc,dt,dn) {
|
cur_frm.cscript.refresh = function(doc,dt,dn) {
|
||||||
cur_frm.cscript.make_dashboard(doc);
|
cur_frm.cscript.make_dashboard(doc);
|
||||||
if(sys_defaults.supp_master_name == 'Supplier Name')
|
if(sys_defaults.supp_master_name == 'Supplier Name')
|
||||||
@ -35,7 +31,8 @@ cur_frm.cscript.make_dashboard = function(doc) {
|
|||||||
cur_frm.dashboard.reset();
|
cur_frm.dashboard.reset();
|
||||||
if(doc.__islocal)
|
if(doc.__islocal)
|
||||||
return;
|
return;
|
||||||
cur_frm.dashboard.set_headline('<span class="text-muted">Loading...</span>')
|
if (in_list(user_roles, "Accounts User") || in_list(user_roles, "Accounts Manager"))
|
||||||
|
cur_frm.dashboard.set_headline('<span class="text-muted">Loading...</span>')
|
||||||
|
|
||||||
cur_frm.dashboard.add_doctype_badge("Supplier Quotation", "supplier");
|
cur_frm.dashboard.add_doctype_badge("Supplier Quotation", "supplier");
|
||||||
cur_frm.dashboard.add_doctype_badge("Purchase Order", "supplier");
|
cur_frm.dashboard.add_doctype_badge("Purchase Order", "supplier");
|
||||||
@ -49,12 +46,14 @@ cur_frm.cscript.make_dashboard = function(doc) {
|
|||||||
supplier: cur_frm.doc.name
|
supplier: cur_frm.doc.name
|
||||||
},
|
},
|
||||||
callback: function(r) {
|
callback: function(r) {
|
||||||
cur_frm.dashboard.set_headline(
|
if (in_list(user_roles, "Accounts User") || in_list(user_roles, "Accounts Manager")) {
|
||||||
wn._("Total Billing This Year: ") + "<b>"
|
cur_frm.dashboard.set_headline(
|
||||||
+ format_currency(r.message.total_billing, cur_frm.doc.default_currency)
|
wn._("Total Billing This Year: ") + "<b>"
|
||||||
+ '</b> / <span class="text-muted">' + wn._("Unpaid") + ": <b>"
|
+ format_currency(r.message.total_billing, cur_frm.doc.default_currency)
|
||||||
+ format_currency(r.message.total_unpaid, cur_frm.doc.default_currency)
|
+ '</b> / <span class="text-muted">' + wn._("Unpaid") + ": <b>"
|
||||||
+ '</b></span>');
|
+ format_currency(r.message.total_unpaid, cur_frm.doc.default_currency)
|
||||||
|
+ '</b></span>');
|
||||||
|
}
|
||||||
cur_frm.dashboard.set_badge_count(r.message);
|
cur_frm.dashboard.set_badge_count(r.message);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@ -45,7 +45,8 @@ cur_frm.cscript.setup_dashboard = function(doc) {
|
|||||||
cur_frm.dashboard.reset(doc);
|
cur_frm.dashboard.reset(doc);
|
||||||
if(doc.__islocal)
|
if(doc.__islocal)
|
||||||
return;
|
return;
|
||||||
cur_frm.dashboard.set_headline('<span class="text-muted">'+ wn._('Loading...')+ '</span>')
|
if (in_list(user_roles, "Accounts User") || in_list(user_roles, "Accounts Manager"))
|
||||||
|
cur_frm.dashboard.set_headline('<span class="text-muted">'+ wn._('Loading...')+ '</span>')
|
||||||
|
|
||||||
cur_frm.dashboard.add_doctype_badge("Opportunity", "customer");
|
cur_frm.dashboard.add_doctype_badge("Opportunity", "customer");
|
||||||
cur_frm.dashboard.add_doctype_badge("Quotation", "customer");
|
cur_frm.dashboard.add_doctype_badge("Quotation", "customer");
|
||||||
@ -60,12 +61,14 @@ cur_frm.cscript.setup_dashboard = function(doc) {
|
|||||||
customer: cur_frm.doc.name
|
customer: cur_frm.doc.name
|
||||||
},
|
},
|
||||||
callback: function(r) {
|
callback: function(r) {
|
||||||
cur_frm.dashboard.set_headline(
|
if (in_list(user_roles, "Accounts User") || in_list(user_roles, "Accounts Manager")) {
|
||||||
wn._("Total Billing This Year: ") + "<b>"
|
cur_frm.dashboard.set_headline(
|
||||||
+ format_currency(r.message.total_billing, cur_frm.doc.default_currency)
|
wn._("Total Billing This Year: ") + "<b>"
|
||||||
+ '</b> / <span class="text-muted">' + wn._("Unpaid") + ": <b>"
|
+ format_currency(r.message.total_billing, cur_frm.doc.default_currency)
|
||||||
+ format_currency(r.message.total_unpaid, cur_frm.doc.default_currency)
|
+ '</b> / <span class="text-muted">' + wn._("Unpaid") + ": <b>"
|
||||||
+ '</b></span>');
|
+ format_currency(r.message.total_unpaid, cur_frm.doc.default_currency)
|
||||||
|
+ '</b></span>');
|
||||||
|
}
|
||||||
cur_frm.dashboard.set_badge_count(r.message);
|
cur_frm.dashboard.set_badge_count(r.message);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@ -58,7 +58,8 @@ def get_columns(filters):
|
|||||||
|
|
||||||
columns.append(label+":Float:120")
|
columns.append(label+":Float:120")
|
||||||
|
|
||||||
return columns + ["Total Target::120", "Total Achieved::120", "Total Variance::120"]
|
return columns + ["Total Target:Float:120", "Total Achieved:Float:120",
|
||||||
|
"Total Variance:Float:120"]
|
||||||
|
|
||||||
#Get sales person & item group details
|
#Get sales person & item group details
|
||||||
def get_salesperson_details(filters):
|
def get_salesperson_details(filters):
|
||||||
@ -83,7 +84,7 @@ def get_target_distribution_details(filters):
|
|||||||
def get_achieved_details(filters):
|
def get_achieved_details(filters):
|
||||||
start_date, end_date = get_fiscal_year(fiscal_year = filters["fiscal_year"])[1:]
|
start_date, end_date = get_fiscal_year(fiscal_year = filters["fiscal_year"])[1:]
|
||||||
|
|
||||||
return webnotes.conn.sql("""select soi.item_code, soi.qty, soi.amount, so.transaction_date,
|
item_details = webnotes.conn.sql("""select soi.item_code, soi.qty, soi.amount, so.transaction_date,
|
||||||
st.sales_person, MONTHNAME(so.transaction_date) as month_name
|
st.sales_person, MONTHNAME(so.transaction_date) as month_name
|
||||||
from `tabSales Order Item` soi, `tabSales Order` so, `tabSales Team` st
|
from `tabSales Order Item` soi, `tabSales Order` so, `tabSales Team` st
|
||||||
where soi.parent=so.name and so.docstatus=1 and
|
where soi.parent=so.name and so.docstatus=1 and
|
||||||
@ -91,6 +92,13 @@ def get_achieved_details(filters):
|
|||||||
so.transaction_date<=%s""" % ('%s', '%s'),
|
so.transaction_date<=%s""" % ('%s', '%s'),
|
||||||
(start_date, end_date), as_dict=1)
|
(start_date, end_date), as_dict=1)
|
||||||
|
|
||||||
|
item_actual_details = {}
|
||||||
|
for d in item_details:
|
||||||
|
item_actual_details.setdefault(d.sales_person, {}).setdefault(\
|
||||||
|
get_item_group(d.item_code), []).append(d)
|
||||||
|
|
||||||
|
return item_actual_details
|
||||||
|
|
||||||
def get_salesperson_item_month_map(filters):
|
def get_salesperson_item_month_map(filters):
|
||||||
import datetime
|
import datetime
|
||||||
salesperson_details = get_salesperson_details(filters)
|
salesperson_details = get_salesperson_details(filters)
|
||||||
@ -110,17 +118,15 @@ def get_salesperson_item_month_map(filters):
|
|||||||
month_percentage = sd.distribution_id and \
|
month_percentage = sd.distribution_id and \
|
||||||
tdd.get(sd.distribution_id, {}).get(month, 0) or 100.0/12
|
tdd.get(sd.distribution_id, {}).get(month, 0) or 100.0/12
|
||||||
|
|
||||||
for ad in achieved_details:
|
for ad in achieved_details.get(sd.name, {}).get(sd.item_group, []):
|
||||||
if (filters["target_on"] == "Quantity"):
|
if (filters["target_on"] == "Quantity"):
|
||||||
tav_dict.target = flt(flt(sd.target_qty) * month_percentage/100, 2)
|
tav_dict.target = flt(sd.target_qty) * month_percentage / 100
|
||||||
if ad.month_name == month and get_item_group(ad.item_code) == sd.item_group \
|
if ad.month_name == month:
|
||||||
and ad.sales_person == sd.name:
|
|
||||||
tav_dict.achieved += ad.qty
|
tav_dict.achieved += ad.qty
|
||||||
|
|
||||||
if (filters["target_on"] == "Amount"):
|
if (filters["target_on"] == "Amount"):
|
||||||
tav_dict.target = flt(flt(sd.target_amount) * month_percentage/100, 2)
|
tav_dict.target = flt(sd.target_amount) * month_percentage / 100
|
||||||
if ad.month_name == month and get_item_group(ad.item_code) == sd.item_group \
|
if ad.month_name == month:
|
||||||
and ad.sales_person == sd.name:
|
|
||||||
tav_dict.achieved += ad.amount
|
tav_dict.achieved += ad.amount
|
||||||
|
|
||||||
return sim_map
|
return sim_map
|
||||||
|
|||||||
@ -16,10 +16,7 @@ def execute(filters=None):
|
|||||||
period_month_ranges = get_period_month_ranges(filters["period"], filters["fiscal_year"])
|
period_month_ranges = get_period_month_ranges(filters["period"], filters["fiscal_year"])
|
||||||
tim_map = get_territory_item_month_map(filters)
|
tim_map = get_territory_item_month_map(filters)
|
||||||
|
|
||||||
precision = webnotes.conn.get_value("Global Defaults", None, "float_precision") or 2
|
|
||||||
|
|
||||||
data = []
|
data = []
|
||||||
|
|
||||||
for territory, territory_items in tim_map.items():
|
for territory, territory_items in tim_map.items():
|
||||||
for item_group, monthwise_data in territory_items.items():
|
for item_group, monthwise_data in territory_items.items():
|
||||||
row = [territory, item_group]
|
row = [territory, item_group]
|
||||||
@ -29,7 +26,7 @@ def execute(filters=None):
|
|||||||
for month in relevant_months:
|
for month in relevant_months:
|
||||||
month_data = monthwise_data.get(month, {})
|
month_data = monthwise_data.get(month, {})
|
||||||
for i, fieldname in enumerate(["target", "achieved", "variance"]):
|
for i, fieldname in enumerate(["target", "achieved", "variance"]):
|
||||||
value = flt(month_data.get(fieldname), precision)
|
value = flt(month_data.get(fieldname))
|
||||||
period_data[i] += value
|
period_data[i] += value
|
||||||
totals[i] += value
|
totals[i] += value
|
||||||
period_data[2] = period_data[0] - period_data[1]
|
period_data[2] = period_data[0] - period_data[1]
|
||||||
@ -58,7 +55,8 @@ def get_columns(filters):
|
|||||||
label = label % from_date.strftime("%b")
|
label = label % from_date.strftime("%b")
|
||||||
columns.append(label+":Float:120")
|
columns.append(label+":Float:120")
|
||||||
|
|
||||||
return columns + ["Total Target::120", "Total Achieved::120", "Total Variance::120"]
|
return columns + ["Total Target:Float:120", "Total Achieved:Float:120",
|
||||||
|
"Total Variance:Float:120"]
|
||||||
|
|
||||||
#Get territory & item group details
|
#Get territory & item group details
|
||||||
def get_territory_details(filters):
|
def get_territory_details(filters):
|
||||||
@ -83,14 +81,22 @@ def get_target_distribution_details(filters):
|
|||||||
def get_achieved_details(filters):
|
def get_achieved_details(filters):
|
||||||
start_date, end_date = get_fiscal_year(fiscal_year = filters["fiscal_year"])[1:]
|
start_date, end_date = get_fiscal_year(fiscal_year = filters["fiscal_year"])[1:]
|
||||||
|
|
||||||
return webnotes.conn.sql("""select soi.item_code, soi.qty, soi.amount, so.transaction_date,
|
item_details = webnotes.conn.sql("""select soi.item_code, soi.qty, soi.amount, so.transaction_date,
|
||||||
so.territory, MONTHNAME(so.transaction_date) as month_name
|
so.territory, MONTHNAME(so.transaction_date) as month_name
|
||||||
from `tabSales Order Item` soi, `tabSales Order` so
|
from `tabSales Order Item` soi, `tabSales Order` so
|
||||||
where soi.parent=so.name and so.docstatus=1 and so.transaction_date>=%s and
|
where soi.parent=so.name and so.docstatus=1 and so.transaction_date>=%s and
|
||||||
so.transaction_date<=%s""" % ('%s', '%s'),
|
so.transaction_date<=%s""" % ('%s', '%s'),
|
||||||
(start_date, end_date), as_dict=1)
|
(start_date, end_date), as_dict=1)
|
||||||
|
|
||||||
|
item_actual_details = {}
|
||||||
|
for d in item_details:
|
||||||
|
item_actual_details.setdefault(d.territory, {}).setdefault(\
|
||||||
|
get_item_group(d.item_code), []).append(d)
|
||||||
|
|
||||||
|
return item_actual_details
|
||||||
|
|
||||||
def get_territory_item_month_map(filters):
|
def get_territory_item_month_map(filters):
|
||||||
|
import datetime
|
||||||
territory_details = get_territory_details(filters)
|
territory_details = get_territory_details(filters)
|
||||||
tdd = get_target_distribution_details(filters)
|
tdd = get_target_distribution_details(filters)
|
||||||
achieved_details = get_achieved_details(filters)
|
achieved_details = get_achieved_details(filters)
|
||||||
@ -110,17 +116,15 @@ def get_territory_item_month_map(filters):
|
|||||||
month_percentage = td.distribution_id and \
|
month_percentage = td.distribution_id and \
|
||||||
tdd.get(td.distribution_id, {}).get(month, 0) or 100.0/12
|
tdd.get(td.distribution_id, {}).get(month, 0) or 100.0/12
|
||||||
|
|
||||||
for ad in achieved_details:
|
for ad in achieved_details.get(td.name, {}).get(td.item_group, []):
|
||||||
if (filters["target_on"] == "Quantity"):
|
if (filters["target_on"] == "Quantity"):
|
||||||
tav_dict.target = flt(flt(td.target_qty) * month_percentage /100)
|
tav_dict.target = flt(td.target_qty) * month_percentage / 100
|
||||||
if ad.month_name == month and get_item_group(ad.item_code) == td.item_group \
|
if ad.month_name == month:
|
||||||
and ad.territory == td.name:
|
|
||||||
tav_dict.achieved += ad.qty
|
tav_dict.achieved += ad.qty
|
||||||
|
|
||||||
if (filters["target_on"] == "Amount"):
|
if (filters["target_on"] == "Amount"):
|
||||||
tav_dict.target = flt(flt(td.target_amount) * month_percentage / 100)
|
tav_dict.target = flt(td.target_amount) * month_percentage / 100
|
||||||
if ad.month_name == month and get_item_group(ad.item_code) == td.item_group \
|
if ad.month_name == month:
|
||||||
and ad.territory == td.name:
|
|
||||||
tav_dict.achieved += ad.amount
|
tav_dict.achieved += ad.amount
|
||||||
|
|
||||||
return tim_map
|
return tim_map
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user