[Fixed] Merge conflict fixed

This commit is contained in:
Akhilesh Darjee 2013-06-21 13:09:18 +05:30
commit 64c8e28423
9 changed files with 143 additions and 154 deletions

View File

@ -115,11 +115,12 @@ def get_costcenter_account_month_map(filters):
for month in tdd:
cam_map.setdefault(ccd.name, {}).setdefault(ccd.account, {})\
.setdefault(month, webnotes._dict({
"target": 0.0, "actual": 0.0, "variance": 0.0
"target": 0.0, "actual": 0.0
}))
tav_dict = cam_map[ccd.name][ccd.account][month]
tav_dict.target = flt(ccd.budget_allocated)*(tdd[month]["percentage_allocation"]/100)
tav_dict.target = flt(ccd.budget_allocated) * \
(tdd[month]["percentage_allocation"]/100)
for ad in actual_details:
if ad.month_name == month and ad.account == ccd.account \

View File

@ -26,17 +26,23 @@ from utilities import build_filter_conditions
class FiscalYearError(webnotes.ValidationError): pass
def get_fiscal_year(date, verbose=1):
return get_fiscal_years(date, verbose=1)[0]
def get_fiscal_year(date=None, fiscal_year=None, verbose=1):
return get_fiscal_years(date, fiscal_year, verbose=1)[0]
def get_fiscal_years(date, verbose=1):
def get_fiscal_years(date=None, fiscal_year=None, verbose=1):
# if year start date is 2012-04-01, year end date should be 2013-03-31 (hence subdate)
cond = ""
if fiscal_year:
cond = "name = '%s'" % fiscal_year
else:
cond = "'%s' >= year_start_date and '%s' < adddate(year_start_date, interval 1 year)" % \
(date, date)
fy = webnotes.conn.sql("""select name, year_start_date,
subdate(adddate(year_start_date, interval 1 year), interval 1 day)
as year_end_date
from `tabFiscal Year`
where %s >= year_start_date and %s < adddate(year_start_date, interval 1 year)
order by year_start_date desc""", (date, date))
where %s
order by year_start_date desc""" % cond)
if not fy:
error_msg = """%s not in any Fiscal Year""" % formatdate(date)

View File

@ -128,23 +128,27 @@ erpnext.buying.BuyingController = wn.ui.form.Controller.extend({
},
currency: function() {
this.set_dynamic_labels();
if(this.frm.doc.currency === this.get_company_currency())
this.frm.set_value("conversion_rate", 1.0);
this.price_list_currency();
},
company: function() {
this.set_dynamic_labels();
if(this.frm.fields_dict.currency)
this.set_dynamic_labels();
},
price_list_currency: function() {
this.frm.toggle_reqd("plc_conversion_rate",
!!(this.frm.doc.price_list_name && this.frm.doc.price_list_currency));
this.set_dynamic_labels();
if(this.frm.doc.price_list_currency === this.get_company_currency())
this.frm.set_value("plc_conversion_rate", 1.0);
else if(this.frm.doc.price_list_currency === this.frm.doc.currency)
this.frm.set_value("plc_conversion_rate", this.frm.doc.conversion_rate || 1.0);
this.set_dynamic_labels();
},
set_dynamic_labels: function(doc, dt, dn) {

View File

@ -16,33 +16,39 @@
from __future__ import unicode_literals
import webnotes
from webnotes.utils import cint, add_days, add_months, cstr
from datetime import datetime
from webnotes.utils import add_days, add_months, cstr, getdate
from webnotes import _
def get_columns(filters, trans):
validate_filters(filters)
# based_on_cols, based_on_select, based_on_group_by, addl_tables
bonc, query_bon, based, sup_tab = basedon_wise_colums_query(filters.get("based_on"), trans)
# period_cols, period_select
pwc, query_pwc = period_wise_colums_query(filters, trans)
# group_by_cols
grbc = group_wise_column(filters.get("group_by"))
if not (filters.get("period") and filters.get("based_on")):
webnotes.msgprint("Value missing in 'Period' or 'Based On'", raise_exception=1)
columns = bonc + pwc + ["TOTAL(Qty):Float:120", "TOTAL(Amt):Currency:120"]
if grbc:
columns = bonc + grbc + pwc +["TOTAL(Qty):Float:120", "TOTAL(Amt):Currency:120"]
elif filters.get("based_on") == filters.get("group_by"):
webnotes.msgprint("Plese select different values in 'Based On' and 'Group By'", raise_exception=1)
else:
bonc, query_bon, based, sup_tab = basedon_wise_colums_query(filters.get("based_on"), trans)
pwc, query_pwc = period_wise_colums_query(filters, trans)
grbc = group_wise_column(filters.get("group_by"))
columns = bonc + pwc + ["TOTAL(Qty):Float:120", "TOTAL(Amt):Currency:120"]
if grbc:
columns = bonc + grbc + pwc +["TOTAL(Qty):Float:120", "TOTAL(Amt):Currency:120"]
details = {"query_bon": query_bon, "query_pwc": query_pwc, "columns": columns, "basedon": based,
"grbc": grbc, "sup_tab": sup_tab}
# conditions
details = {"query_bon": query_bon, "query_pwc": query_pwc, "columns": columns,
"basedon": based, "grbc": grbc, "sup_tab": sup_tab}
return details
def get_data(filters, tab, details):
def validate_filters(filters):
for f in ["Fiscal Year", "Based On", "Period", "Company"]:
if not filters.get(f.lower().replace(" ", "_")):
webnotes.msgprint(f + _(" is mandatory"), raise_exception=1)
if filters.get("based_on") == filters.get("group_by"):
webnotes.msgprint("'Based On' and 'Group By' can not be same", raise_exception=1)
def get_data(filters, tab, details):
data = []
inc, cond= '',''
query_details = details["query_bon"] + details["query_pwc"]
@ -96,17 +102,17 @@ def get_data(filters, tab, details):
row1 = webnotes.conn.sql(""" select %s , %s from `%s` t1, `%s` t2 %s
where t2.parent = t1.name and t1.company = %s and t1.fiscal_year = %s
and t1.docstatus = 1 and %s = %s and %s = %s
"""%(sel_col, details["query_pwc"], tab[0], tab[1], details["sup_tab"],
""" % (sel_col, details["query_pwc"], tab[0], tab[1], details["sup_tab"],
"%s", "%s", sel_col, "%s", details["basedon"], "%s"),
(filters.get("company"), filters.get("fiscal_year"), row[i][0], data1[d][0]),
as_list=1)
(filters.get("company"), filters.get("fiscal_year"),
row[i][0], data1[d][0]), as_list=1)
des[ind] = row[i]
for j in range(1,len(details["columns"])-inc):
des[j+inc] = row1[0][j]
data.append(des)
else:
data = webnotes.conn.sql(""" select %s from `%s` t1, `%s` t2 %s
where t2.parent = t1.name and t1.company = %s
and t1.fiscal_year = %s and t1.docstatus = 1 %s
@ -118,20 +124,13 @@ def get_data(filters, tab, details):
return data
def get_mon(date):
"""convert srting formated date into date and retrieve month abbrevation"""
return (datetime.strptime(date, '%Y-%m-%d')).strftime("%b")
def get_mon(dt):
return getdate(dt).strftime("%b")
def period_wise_colums_query(filters, trans):
from datetime import datetime
query_details = ''
pwc = []
ysd = webnotes.conn.sql("""select year_start_date from `tabFiscal Year` where name = '%s'
"""%filters.get("fiscal_year"))[0][0]
year_start_date = ysd.strftime('%Y-%m-%d')
start_month = cint(year_start_date.split('-')[1])
ysd = webnotes.conn.get_value("Fiscal year", filters.get("fiscal_year"), "year_start_date")
if trans in ['Purchase Receipt', 'Delivery Note', 'Purchase Invoice', 'Sales Invoice']:
trans_date = 'posting_date'
@ -141,27 +140,13 @@ def period_wise_colums_query(filters, trans):
if filters.get("period") == "Monthly":
month_name = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']
for month in range(start_month-1,len(month_name)):
pwc.append(month_name[month]+' (Qty):Float:120')
pwc.append(month_name[month]+' (Amt):Currency:120')
query_details += """
Sum(IF(MONTH(t1.%(trans)s)= %(mon_num)s, t2.qty, NULL)),
SUM(IF(MONTH(t1.%(trans)s)= %(mon_num)s, t1.grand_total, NULL)),
"""%{"trans": trans_date,"mon_num": cstr(month+1)}
for month in range(0, start_month-1):
pwc.append(month_name[month]+' (Qty):Float:120')
pwc.append(month_name[month]+' (Amt):Currency:120')
query_details += """
Sum(IF(MONTH(t1.%(trans)s)= %(mon_num)s, t2.qty, NULL)),
SUM(IF(MONTH(t1.%(trans)s)= %(mon_num)s, t1.grand_total, NULL)),
"""%{"trans": trans_date, "mon_num": cstr(month+1)}
for month_idx in range(ysd.month-1,len(month_name)) + range(0, ysd.month-1):
query_details = get_monthly_conditions(month_name, month_idx, trans_date,
pwc, query_details)
elif filters.get("period") == "Quarterly":
first_qsd, second_qsd, third_qsd, fourth_qsd = year_start_date, add_months(year_start_date,3), add_months(year_start_date,6), add_months(year_start_date,9)
first_qsd, second_qsd, third_qsd, fourth_qsd = ysd, add_months(ysd,3), add_months(ysd,6), add_months(ysd,9)
first_qed, second_qed, third_qed, fourth_qed = add_days(add_months(first_qsd,3),-1), add_days(add_months(second_qsd,3),-1), add_days(add_months(third_qsd,3),-1), add_days(add_months(fourth_qsd,3),-1)
bet_dates = [[first_qsd,first_qed],[second_qsd,second_qed],[third_qsd,third_qed],[fourth_qsd,fourth_qed]]
@ -178,7 +163,7 @@ def period_wise_colums_query(filters, trans):
elif filters.get("period") == "Half-yearly":
first_half_start = year_start_date
first_half_start = ysd
first_half_end = add_days(add_months(first_half_start,6),-1)
second_half_start = add_days(first_half_end,1)
second_half_end = add_days(add_months(second_half_start,6),-1)
@ -200,6 +185,17 @@ def period_wise_colums_query(filters, trans):
query_details += 'SUM(t2.qty), SUM(t1.grand_total)'
return pwc, query_details
def get_monthly_conditions(month_list, month_idx, trans_date, pwc, query_details):
pwc += [month_list[month_idx] + ' (Qty):Float:120',
month_list[month_idx] + ' (Amt):Currency:120']
query_details += """
Sum(IF(MONTH(t1.%(trans_date)s)= %(mon_num)s, t2.qty, NULL)),
SUM(IF(MONTH(t1.%(trans_date)s)= %(mon_num)s, t1.grand_total, NULL)),
""" % {"trans_date": trans_date, "mon_num": cstr(month_idx+1)}
return query_details
def basedon_wise_colums_query(based_on, trans):
sup_tab = ''
@ -242,19 +238,16 @@ def basedon_wise_colums_query(based_on, trans):
based = 't1.territory'
elif based_on == "Project":
if trans in ['Sales Invoice', 'Delivery Note', 'Sales Order']:
bon = ["Project:Link/Project:120"]
query_details = "t1.project_name,"
based = 't1.project_name'
elif trans in ['Purchase Order', 'Purchase Invoice', 'Purchase Receipt']:
bon = ["Project:Link/Project:120"]
query_details = "t2.project_name,"
based = 't2.project_name'
else:
webnotes.msgprint("Information Not Available", raise_exception=1)
webnotes.msgprint("Project-wise data is not available for Quotation", raise_exception=1)
return bon, query_details, based, sup_tab

View File

@ -16,7 +16,7 @@
from __future__ import unicode_literals
import webnotes
from controllers.trends import get_columns,get_data
from controllers.trends import get_columns, get_data
def execute(filters=None):
if not filters: filters ={}
@ -27,8 +27,5 @@ def execute(filters=None):
details = get_columns(filters, trans)
data = get_data(filters, tab, details)
if not data:
webnotes.msgprint("Data not found for selected criterias")
return details["columns"], data

View File

@ -96,7 +96,7 @@ def get_target_distribution_details(filters):
#Get achieved details from sales order
def get_achieved_details(filters):
start_date, end_date = get_fiscal_year(filters)[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,
st.sales_person, MONTHNAME(so.transaction_date) as month_name
@ -117,20 +117,22 @@ def get_salesperson_item_month_map(filters):
for month in tdd:
sim_map.setdefault(sd.name, {}).setdefault(sd.item_group, {})\
.setdefault(month, webnotes._dict({
"target": 0.0, "achieved": 0.0, "variance": 0.0
"target": 0.0, "achieved": 0.0
}))
tav_dict = sim_map[sd.name][sd.item_group][month]
for ad in achieved_details:
if (filters["target_on"] == "Quantity"):
tav_dict.target = flt(sd.target_qty)*(tdd[month]["percentage_allocation"]/100)
tav_dict.target = flt(sd.target_qty) * \
(tdd[month]["percentage_allocation"]/100)
if ad.month_name == month and get_item_group(ad.item_code) == sd.item_group \
and ad.sales_person == sd.name:
tav_dict.achieved += ad.qty
if (filters["target_on"] == "Amount"):
tav_dict.target = flt(sd.target_amount)*(tdd[month]["percentage_allocation"]/100)
tav_dict.target = flt(sd.target_amount) * \
(tdd[month]["percentage_allocation"]/100)
if ad.month_name == month and get_item_group(ad.item_code) == sd.item_group \
and ad.sales_person == sd.name:
tav_dict.achieved += ad.amount
@ -138,4 +140,4 @@ def get_salesperson_item_month_map(filters):
return sim_map
def get_item_group(item_name):
return webnotes.conn.get_value("Item", item_name, item_group)
return webnotes.conn.get_value("Item", item_name, "item_group")

View File

@ -57,8 +57,7 @@ def get_columns(filters):
for fieldname in ["fiscal_year", "period", "target_on"]:
if not filters.get(fieldname):
label = (" ".join(fieldname.split("_"))).title()
msgprint(_("Please specify") + ": " + label,
raise_exception=True)
msgprint(_("Please specify") + ": " + label, raise_exception=True)
columns = ["Territory:Link/Territory:80", "Item Group:Link/Item Group:80"]
@ -96,7 +95,7 @@ def get_target_distribution_details(filters):
#Get achieved details from sales order
def get_achieved_details(filters):
start_date, end_date = get_fiscal_year(filters)[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,
so.territory, MONTHNAME(so.transaction_date) as month_name
@ -116,20 +115,22 @@ def get_territory_item_month_map(filters):
for month in tdd:
tim_map.setdefault(td.name, {}).setdefault(td.item_group, {})\
.setdefault(month, webnotes._dict({
"target": 0.0, "achieved": 0.0, "variance": 0.0
"target": 0.0, "achieved": 0.0
}))
tav_dict = tim_map[td.name][td.item_group][month]
for ad in achieved_details:
if (filters["target_on"] == "Quantity"):
tav_dict.target = flt(td.target_qty)*(tdd[month]["percentage_allocation"]/100)
tav_dict.target = flt(td.target_qty) * \
(tdd[month]["percentage_allocation"]/100)
if ad.month_name == month and get_item_group(ad.item_code) == td.item_group \
and ad.territory == td.name:
tav_dict.achieved += ad.qty
if (filters["target_on"] == "Amount"):
tav_dict.target = flt(td.target_amount)*(tdd[month]["percentage_allocation"]/100)
tav_dict.target = flt(td.target_amount) * \
(tdd[month]["percentage_allocation"]/100)
if ad.month_name == month and get_item_group(ad.item_code) == td.item_group \
and ad.territory == td.name:
tav_dict.achieved += ad.amount
@ -137,4 +138,4 @@ def get_territory_item_month_map(filters):
return tim_map
def get_item_group(item_name):
return webnotes.conn.get_value("Item", item_name, item_group)
return webnotes.conn.get_value("Item", item_name, "item_group")

View File

@ -1,14 +1,14 @@
[
{
"creation": "2013-01-29 19:25:41",
"creation": "2013-05-16 10:59:15",
"docstatus": 0,
"modified": "2013-01-29 16:27:57",
"modified": "2013-06-20 11:23:01",
"modified_by": "Administrator",
"owner": "Administrator"
},
{
"allow_attach": 1,
"allow_rename": 1,
"allow_rename": 0,
"autoname": "field:serial_no",
"description": "Distinct unit of an Item",
"doctype": "DocType",
@ -31,7 +31,9 @@
"parent": "Serial No",
"parentfield": "permissions",
"parenttype": "DocType",
"permlevel": 0,
"read": 1,
"report": 1,
"submit": 0
},
{
@ -43,12 +45,14 @@
"fieldname": "details",
"fieldtype": "Section Break",
"label": "Details",
"oldfieldtype": "Section Break"
"oldfieldtype": "Section Break",
"read_only": 0
},
{
"doctype": "DocField",
"fieldname": "column_break0",
"fieldtype": "Column Break"
"fieldtype": "Column Break",
"read_only": 0
},
{
"default": "In Store",
@ -75,6 +79,7 @@
"no_copy": 1,
"oldfieldname": "serial_no",
"oldfieldtype": "Data",
"read_only": 0,
"reqd": 1,
"search_index": 1
},
@ -88,13 +93,15 @@
"oldfieldname": "item_code",
"oldfieldtype": "Link",
"options": "Item",
"read_only": 0,
"reqd": 1,
"search_index": 0
},
{
"doctype": "DocField",
"fieldname": "column_break1",
"fieldtype": "Column Break"
"fieldtype": "Column Break",
"read_only": 0
},
{
"doctype": "DocField",
@ -146,12 +153,14 @@
"doctype": "DocField",
"fieldname": "purchase_details",
"fieldtype": "Section Break",
"label": "Purchase Details"
"label": "Purchase Details",
"read_only": 0
},
{
"doctype": "DocField",
"fieldname": "column_break2",
"fieldtype": "Column Break",
"read_only": 0,
"width": "50%"
},
{
@ -160,7 +169,8 @@
"fieldtype": "Select",
"label": "Purchase Document Type",
"no_copy": 1,
"options": "\nPurchase Receipt\nStock Entry"
"options": "\nPurchase Receipt\nStock Entry",
"read_only": 0
},
{
"doctype": "DocField",
@ -168,7 +178,8 @@
"fieldtype": "Data",
"hidden": 0,
"label": "Purchase Document No",
"no_copy": 1
"no_copy": 1,
"read_only": 0
},
{
"doctype": "DocField",
@ -179,6 +190,7 @@
"no_copy": 1,
"oldfieldname": "purchase_date",
"oldfieldtype": "Date",
"read_only": 0,
"reqd": 0,
"search_index": 0
},
@ -188,6 +200,7 @@
"fieldtype": "Time",
"label": "Incoming Time",
"no_copy": 1,
"read_only": 0,
"reqd": 1
},
{
@ -200,6 +213,7 @@
"oldfieldname": "purchase_rate",
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
"read_only": 0,
"reqd": 1,
"search_index": 0
},
@ -207,6 +221,7 @@
"doctype": "DocField",
"fieldname": "column_break3",
"fieldtype": "Column Break",
"read_only": 0,
"width": "50%"
},
{
@ -220,6 +235,7 @@
"oldfieldname": "warehouse",
"oldfieldtype": "Link",
"options": "Warehouse",
"read_only": 0,
"reqd": 0,
"search_index": 1
},
@ -230,7 +246,8 @@
"in_filter": 1,
"label": "Supplier",
"no_copy": 1,
"options": "Supplier"
"options": "Supplier",
"read_only": 0
},
{
"doctype": "DocField",
@ -254,12 +271,14 @@
"fieldname": "delivery_details",
"fieldtype": "Section Break",
"label": "Delivery Details",
"oldfieldtype": "Column Break"
"oldfieldtype": "Column Break",
"read_only": 0
},
{
"doctype": "DocField",
"fieldname": "column_break4",
"fieldtype": "Column Break",
"read_only": 0,
"width": "50%"
},
{
@ -318,12 +337,14 @@
"oldfieldname": "is_cancelled",
"oldfieldtype": "Select",
"options": "\nYes\nNo",
"read_only": 0,
"report_hide": 1
},
{
"doctype": "DocField",
"fieldname": "column_break5",
"fieldtype": "Column Break",
"read_only": 0,
"width": "50%"
},
{
@ -378,12 +399,14 @@
"doctype": "DocField",
"fieldname": "warranty_amc_details",
"fieldtype": "Section Break",
"label": "Warranty / AMC Details"
"label": "Warranty / AMC Details",
"read_only": 0
},
{
"doctype": "DocField",
"fieldname": "column_break6",
"fieldtype": "Column Break",
"read_only": 0,
"width": "50%"
},
{
@ -396,6 +419,7 @@
"oldfieldname": "maintenance_status",
"oldfieldtype": "Select",
"options": "\nUnder Warranty\nOut of Warranty\nUnder AMC\nOut of AMC",
"read_only": 0,
"search_index": 1,
"width": "150px"
},
@ -406,12 +430,14 @@
"label": "Warranty Period (Days)",
"oldfieldname": "warranty_period",
"oldfieldtype": "Int",
"read_only": 0,
"width": "150px"
},
{
"doctype": "DocField",
"fieldname": "column_break7",
"fieldtype": "Column Break",
"read_only": 0,
"width": "50%"
},
{
@ -422,6 +448,7 @@
"label": "Warranty Expiry Date",
"oldfieldname": "warranty_expiry_date",
"oldfieldtype": "Date",
"read_only": 0,
"width": "150px"
},
{
@ -432,6 +459,7 @@
"label": "AMC Expiry Date",
"oldfieldname": "amc_expiry_date",
"oldfieldtype": "Date",
"read_only": 0,
"search_index": 0,
"width": "150px"
},
@ -439,13 +467,15 @@
"doctype": "DocField",
"fieldname": "more_info",
"fieldtype": "Section Break",
"label": "More Info"
"label": "More Info",
"read_only": 0
},
{
"doctype": "DocField",
"fieldname": "serial_no_details",
"fieldtype": "Text Editor",
"label": "Serial No Details"
"label": "Serial No Details",
"read_only": 0
},
{
"doctype": "DocField",
@ -454,6 +484,7 @@
"in_filter": 1,
"label": "Company",
"options": "link:Company",
"read_only": 0,
"reqd": 1,
"search_index": 1
},
@ -464,6 +495,7 @@
"in_filter": 1,
"label": "Fiscal Year",
"options": "link:Fiscal Year",
"read_only": 0,
"reqd": 1,
"search_index": 1
},
@ -487,54 +519,10 @@
"read_only": 1,
"report_hide": 1
},
{
"amend": 0,
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
"match": "",
"permlevel": 1,
"report": 0,
"role": "Material Manager",
"write": 0
},
{
"amend": 0,
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
"permlevel": 0,
"report": 1,
"role": "Material Manager",
"write": 0
},
{
"amend": 0,
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
"match": "",
"permlevel": 1,
"report": 0,
"role": "Material User",
"write": 0
},
{
"amend": 0,
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
"permlevel": 0,
"report": 1,
"role": "Material User",
"write": 0
},
{
"cancel": 1,
"create": 1,
"doctype": "DocPerm",
"permlevel": 0,
"report": 1,
"role": "System Manager",
"write": 1
},
@ -542,8 +530,6 @@
"cancel": 1,
"create": 1,
"doctype": "DocPerm",
"permlevel": 0,
"report": 1,
"role": "Material Master Manager",
"write": 1
},
@ -552,17 +538,15 @@
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
"match": "",
"permlevel": 1,
"role": "System Manager"
"role": "Material Manager",
"write": 0
},
{
"amend": 0,
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
"match": "",
"permlevel": 1,
"role": "Sales Master Manager"
"role": "Material User",
"write": 0
}
]

View File

@ -39,7 +39,7 @@ def execute(filters=None):
pl.get(item, {}).get("selling"),
pl.get(item, {}).get("buying"),
flt(bom_rate.get(item, 0), precision),
flt(item_map[item]["standard_rate"])
flt(item_map[item]["standard_rate"], precision)
])
return columns, data
@ -142,8 +142,9 @@ def get_valuation_rate():
item_val_rate_map = {}
for d in webnotes.conn.sql("""select item_code, avg(valuation_rate) as val_rate
from tabBin group by item_code""", as_dict=1):
item_val_rate_map.setdefault(d.item_code, flt(d.val_rate))
for d in webnotes.conn.sql("""select item_code,
sum(actual_qty*valuation_rate)/sum(actual_qty) as val_rate
from tabBin where actual_qty > 0 group by item_code""", as_dict=1):
item_val_rate_map.setdefault(d.item_code, d.val_rate)
return item_val_rate_map
return item_val_rate_map