From 1ded5c618ee73166dfcba4671cd9b041baa1cd4f Mon Sep 17 00:00:00 2001 From: Akhilesh Darjee Date: Fri, 21 Jun 2013 12:47:51 +0530 Subject: [PATCH 1/2] [Report]Cleanup of territory target variance, sales person target variance & budget variance reports --- .../budget_variance_report.py | 59 +++------------ selling/page/selling_home/selling_home.js | 4 +- .../__init__.py | 0 ...person_target_variance_item_group_wise.js} | 2 +- ...person_target_variance_item_group_wise.py} | 74 ++++--------------- ...erson_target_variance_item_group_wise.txt} | 8 +- .../__init__.py | 0 ...ritory_target_variance_item_group_wise.js} | 2 +- ...ritory_target_variance_item_group_wise.py} | 74 ++++--------------- ...itory_target_variance_item_group_wise.txt} | 8 +- stock/report/item_prices/item_prices.py | 62 +++++++++++++--- 11 files changed, 106 insertions(+), 187 deletions(-) rename selling/report/{sales_person_target_variance_(item_group_wise) => sales_person_target_variance_item_group_wise}/__init__.py (100%) rename selling/report/{sales_person_target_variance_(item_group_wise)/sales_person_target_variance_(item_group_wise).js => sales_person_target_variance_item_group_wise/sales_person_target_variance_item_group_wise.js} (86%) rename selling/report/{sales_person_target_variance_(item_group_wise)/sales_person_target_variance_(item_group_wise).py => sales_person_target_variance_item_group_wise/sales_person_target_variance_item_group_wise.py} (67%) rename selling/report/{sales_person_target_variance_(item_group_wise)/sales_person_target_variance_(item_group_wise).txt => sales_person_target_variance_item_group_wise/sales_person_target_variance_item_group_wise.txt} (57%) rename selling/report/{territory_target_variance_(item_group_wise) => territory_target_variance_item_group_wise}/__init__.py (100%) rename selling/report/{territory_target_variance_(item_group_wise)/territory_target_variance_(item_group_wise).js => territory_target_variance_item_group_wise/territory_target_variance_item_group_wise.js} (87%) rename selling/report/{territory_target_variance_(item_group_wise)/territory_target_variance_(item_group_wise).py => territory_target_variance_item_group_wise/territory_target_variance_item_group_wise.py} (66%) rename selling/report/{territory_target_variance_(item_group_wise)/territory_target_variance_(item_group_wise).txt => territory_target_variance_item_group_wise/territory_target_variance_item_group_wise.txt} (57%) diff --git a/accounts/report/budget_variance_report/budget_variance_report.py b/accounts/report/budget_variance_report/budget_variance_report.py index 99e303bd20..b4959aa667 100644 --- a/accounts/report/budget_variance_report/budget_variance_report.py +++ b/accounts/report/budget_variance_report/budget_variance_report.py @@ -16,18 +16,21 @@ from __future__ import unicode_literals import webnotes -import calendar from webnotes import _, msgprint from webnotes.utils import flt import time +from accounts.utils import get_fiscal_year +from controllers.trends import get_period_date_ranges, get_period_month_ranges def execute(filters=None): if not filters: filters = {} columns = get_columns(filters) - period_month_ranges = get_period_month_ranges(filters) + period_month_ranges = get_period_month_ranges(filters["period"], filters["fiscal_year"]) cam_map = get_costcenter_account_month_map(filters) + precision = webnotes.conn.get_value("Global Defaults", None, "float_precision") or 2 + data = [] for cost_center, cost_center_items in cam_map.items(): @@ -39,7 +42,7 @@ def execute(filters=None): for month in relevant_months: month_data = monthwise_data.get(month, {}) for i, fieldname in enumerate(["target", "actual", "variance"]): - value = flt(month_data.get(fieldname)) + value = flt(month_data.get(fieldname), precision) period_data[i] += value totals[i] += value period_data[2] = period_data[0] - period_data[1] @@ -61,7 +64,7 @@ def get_columns(filters): group_months = False if filters["period"] == "Monthly" else True - for from_date, to_date in get_period_date_ranges(filters): + for from_date, to_date in get_period_date_ranges(filters["period"], filters["fiscal_year"]): for label in ["Target (%s)", "Actual (%s)", "Variance (%s)"]: if group_months: columns.append(label % (from_date.strftime("%b") + " - " + to_date.strftime("%b"))) @@ -70,41 +73,6 @@ def get_columns(filters): return columns + ["Total Target::80", "Total Actual::80", "Total Variance::80"] -def get_period_date_ranges(filters): - from dateutil.relativedelta import relativedelta - - year_start_date, year_end_date = get_year_start_end_date(filters) - - increment = { - "Monthly": 1, - "Quarterly": 3, - "Half-Yearly": 6, - "Yearly": 12 - }.get(filters["period"]) - - period_date_ranges = [] - for i in xrange(1, 13, increment): - period_end_date = year_start_date + relativedelta(months=increment, - days=-1) - period_date_ranges.append([year_start_date, period_end_date]) - year_start_date = period_end_date + relativedelta(days=1) - - return period_date_ranges - -def get_period_month_ranges(filters): - from dateutil.relativedelta import relativedelta - period_month_ranges = [] - - for start_date, end_date in get_period_date_ranges(filters): - months_in_this_period = [] - while start_date <= end_date: - months_in_this_period.append(start_date.strftime("%B")) - start_date += relativedelta(months=1) - period_month_ranges.append(months_in_this_period) - - return period_month_ranges - - #Get cost center & target details def get_costcenter_target_details(filters): return webnotes.conn.sql("""select cc.name, cc.distribution_id, @@ -122,7 +90,7 @@ def get_target_distribution_details(filters): for d in webnotes.conn.sql("""select bdd.month, bdd.percentage_allocation \ from `tabBudget Distribution Detail` bdd, `tabBudget Distribution` bd, \ `tabCost Center` cc where bdd.parent=bd.name and cc.distribution_id=bd.name and \ - bd.fiscal_year=%s""" % ('%s'), (filters.get("fiscal_year")), as_dict=1): + bd.fiscal_year=%s""", (filters["fiscal_year"]), as_dict=1): target_details.setdefault(d.month, d) return target_details @@ -151,18 +119,11 @@ def get_costcenter_account_month_map(filters): })) tav_dict = cam_map[ccd.name][ccd.account][month] - tav_dict.target = 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 \ and ad.cost_center == ccd.name: tav_dict.actual += ad.debit - ad.credit - return cam_map - -def get_year_start_end_date(filters): - return webnotes.conn.sql("""select year_start_date, - subdate(adddate(year_start_date, interval 1 year), interval 1 day) - as year_end_date - from `tabFiscal Year` - where name=%s""", filters["fiscal_year"])[0] \ No newline at end of file + return cam_map \ No newline at end of file diff --git a/selling/page/selling_home/selling_home.js b/selling/page/selling_home/selling_home.js index 87e12db904..7a0848e931 100644 --- a/selling/page/selling_home/selling_home.js +++ b/selling/page/selling_home/selling_home.js @@ -167,12 +167,12 @@ wn.module_page["Selling"] = [ }, { "label":wn._("Territory Target Variance (Item Group-Wise)"), - route: "query-report/Territory Target Variance (Item Group-Wise)", + route: "query-report/Territory Target Variance Item Group-Wise", doctype: "Sales Order" }, { "label":wn._("Sales Person Target Variance (Item Group-Wise)"), - route: "query-report/Sales Person Target Variance (Item Group-Wise)", + route: "query-report/Sales Person Target Variance Item Group-Wise", doctype: "Sales Order" }, { diff --git a/selling/report/sales_person_target_variance_(item_group_wise)/__init__.py b/selling/report/sales_person_target_variance_item_group_wise/__init__.py similarity index 100% rename from selling/report/sales_person_target_variance_(item_group_wise)/__init__.py rename to selling/report/sales_person_target_variance_item_group_wise/__init__.py diff --git a/selling/report/sales_person_target_variance_(item_group_wise)/sales_person_target_variance_(item_group_wise).js b/selling/report/sales_person_target_variance_item_group_wise/sales_person_target_variance_item_group_wise.js similarity index 86% rename from selling/report/sales_person_target_variance_(item_group_wise)/sales_person_target_variance_(item_group_wise).js rename to selling/report/sales_person_target_variance_item_group_wise/sales_person_target_variance_item_group_wise.js index 09f0d55aed..c7a5d668c4 100644 --- a/selling/report/sales_person_target_variance_(item_group_wise)/sales_person_target_variance_(item_group_wise).js +++ b/selling/report/sales_person_target_variance_item_group_wise/sales_person_target_variance_item_group_wise.js @@ -1,4 +1,4 @@ -wn.query_reports["Sales Person Target Variance (Item Group-Wise)"] = { +wn.query_reports["Sales Person Target Variance Item Group-Wise"] = { "filters": [ { fieldname: "fiscal_year", diff --git a/selling/report/sales_person_target_variance_(item_group_wise)/sales_person_target_variance_(item_group_wise).py b/selling/report/sales_person_target_variance_item_group_wise/sales_person_target_variance_item_group_wise.py similarity index 67% rename from selling/report/sales_person_target_variance_(item_group_wise)/sales_person_target_variance_(item_group_wise).py rename to selling/report/sales_person_target_variance_item_group_wise/sales_person_target_variance_item_group_wise.py index 8f5931d826..6e39143f2e 100644 --- a/selling/report/sales_person_target_variance_(item_group_wise)/sales_person_target_variance_(item_group_wise).py +++ b/selling/report/sales_person_target_variance_item_group_wise/sales_person_target_variance_item_group_wise.py @@ -16,18 +16,21 @@ from __future__ import unicode_literals import webnotes -import calendar from webnotes import _, msgprint from webnotes.utils import flt import time +from accounts.utils import get_fiscal_year +from controllers.trends import get_period_date_ranges, get_period_month_ranges def execute(filters=None): if not filters: filters = {} columns = get_columns(filters) - period_month_ranges = get_period_month_ranges(filters) + period_month_ranges = get_period_month_ranges(filters["period"], filters["fiscal_year"]) sim_map = get_salesperson_item_month_map(filters) + precision = webnotes.conn.get_value("Global Defaults", None, "float_precision") or 2 + data = [] for salesperson, salesperson_items in sim_map.items(): @@ -39,7 +42,7 @@ def execute(filters=None): for month in relevant_months: month_data = monthwise_data.get(month, {}) for i, fieldname in enumerate(["target", "achieved", "variance"]): - value = flt(month_data.get(fieldname)) + value = flt(month_data.get(fieldname), precision) period_data[i] += value totals[i] += value period_data[2] = period_data[0] - period_data[1] @@ -61,7 +64,7 @@ def get_columns(filters): group_months = False if filters["period"] == "Monthly" else True - for from_date, to_date in get_period_date_ranges(filters): + for from_date, to_date in get_period_date_ranges(filters["period"], filters["fiscal_year"]): for label in ["Target (%s)", "Achieved (%s)", "Variance (%s)"]: if group_months: columns.append(label % (from_date.strftime("%b") + " - " + to_date.strftime("%b"))) @@ -70,49 +73,14 @@ def get_columns(filters): return columns + ["Total Target::80", "Total Achieved::80", "Total Variance::80"] -def get_period_date_ranges(filters): - from dateutil.relativedelta import relativedelta - - year_start_date, year_end_date = get_year_start_end_date(filters) - - increment = { - "Monthly": 1, - "Quarterly": 3, - "Half-Yearly": 6, - "Yearly": 12 - }.get(filters["period"]) - - period_date_ranges = [] - for i in xrange(1, 13, increment): - period_end_date = year_start_date + relativedelta(months=increment, - days=-1) - period_date_ranges.append([year_start_date, period_end_date]) - year_start_date = period_end_date + relativedelta(days=1) - - return period_date_ranges - -def get_period_month_ranges(filters): - from dateutil.relativedelta import relativedelta - period_month_ranges = [] - - for start_date, end_date in get_period_date_ranges(filters): - months_in_this_period = [] - while start_date <= end_date: - months_in_this_period.append(start_date.strftime("%B")) - start_date += relativedelta(months=1) - period_month_ranges.append(months_in_this_period) - - return period_month_ranges - - #Get sales person & item group details def get_salesperson_details(filters): return webnotes.conn.sql("""select sp.name, td.item_group, td.target_qty, td.target_amount, sp.distribution_id from `tabSales Person` sp, `tabTarget Detail` td where td.parent=sp.name and td.fiscal_year=%s and - ifnull(sp.distribution_id, '')!='' order by sp.name""" % - ('%s'), (filters.get("fiscal_year")), as_dict=1) + ifnull(sp.distribution_id, '')!='' order by sp.name""", + (filters["fiscal_year"]), as_dict=1) #Get target distribution details of item group def get_target_distribution_details(filters): @@ -121,14 +89,14 @@ def get_target_distribution_details(filters): for d in webnotes.conn.sql("""select bdd.month, bdd.percentage_allocation \ from `tabBudget Distribution Detail` bdd, `tabBudget Distribution` bd, \ `tabTerritory` t where bdd.parent=bd.name and t.distribution_id=bd.name and \ - bd.fiscal_year=%s """ % ('%s'), (filters.get("fiscal_year")), as_dict=1): + bd.fiscal_year=%s""", (filters["fiscal_year"]), as_dict=1): target_details.setdefault(d.month, d) return target_details #Get achieved details from sales order def get_achieved_details(filters): - start_date, end_date = get_year_start_end_date(filters) + start_date, end_date = get_fiscal_year(filters)[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 @@ -156,28 +124,18 @@ def get_salesperson_item_month_map(filters): for ad in achieved_details: if (filters["target_on"] == "Quantity"): - tav_dict.target = sd.target_qty*(tdd[month]["percentage_allocation"]/100) - if ad.month_name == month and ''.join(get_item_group(ad.item_code)) == sd.item_group \ + 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 = sd.target_amount*(tdd[month]["percentage_allocation"]/100) - if ad.month_name == month and ''.join(get_item_group(ad.item_code)) == sd.item_group \ + 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 return sim_map -def get_year_start_end_date(filters): - return webnotes.conn.sql("""select year_start_date, - subdate(adddate(year_start_date, interval 1 year), interval 1 day) - as year_end_date - from `tabFiscal Year` - where name=%s""", filters["fiscal_year"])[0] - def get_item_group(item_name): - """Get Item Group of an item""" - - return webnotes.conn.sql_list("select item_group from `tabItem` where name=%s""" % - ('%s'), (item_name)) \ No newline at end of file + return webnotes.conn.get_value("Item", item_name, item_group) \ No newline at end of file diff --git a/selling/report/sales_person_target_variance_(item_group_wise)/sales_person_target_variance_(item_group_wise).txt b/selling/report/sales_person_target_variance_item_group_wise/sales_person_target_variance_item_group_wise.txt similarity index 57% rename from selling/report/sales_person_target_variance_(item_group_wise)/sales_person_target_variance_(item_group_wise).txt rename to selling/report/sales_person_target_variance_item_group_wise/sales_person_target_variance_item_group_wise.txt index 955cdec477..e587c2c084 100644 --- a/selling/report/sales_person_target_variance_(item_group_wise)/sales_person_target_variance_(item_group_wise).txt +++ b/selling/report/sales_person_target_variance_item_group_wise/sales_person_target_variance_item_group_wise.txt @@ -1,8 +1,8 @@ [ { - "creation": "2013-06-18 12:09:40", + "creation": "2013-06-21 12:14:15", "docstatus": 0, - "modified": "2013-06-18 12:09:40", + "modified": "2013-06-21 12:14:15", "modified_by": "Administrator", "owner": "Administrator" }, @@ -11,11 +11,11 @@ "is_standard": "Yes", "name": "__common__", "ref_doctype": "Sales Order", - "report_name": "Sales Person Target Variance (Item Group-Wise)", + "report_name": "Sales Person Target Variance Item Group-Wise", "report_type": "Script Report" }, { "doctype": "Report", - "name": "Sales Person Target Variance (Item Group-Wise)" + "name": "Sales Person Target Variance Item Group-Wise" } ] \ No newline at end of file diff --git a/selling/report/territory_target_variance_(item_group_wise)/__init__.py b/selling/report/territory_target_variance_item_group_wise/__init__.py similarity index 100% rename from selling/report/territory_target_variance_(item_group_wise)/__init__.py rename to selling/report/territory_target_variance_item_group_wise/__init__.py diff --git a/selling/report/territory_target_variance_(item_group_wise)/territory_target_variance_(item_group_wise).js b/selling/report/territory_target_variance_item_group_wise/territory_target_variance_item_group_wise.js similarity index 87% rename from selling/report/territory_target_variance_(item_group_wise)/territory_target_variance_(item_group_wise).js rename to selling/report/territory_target_variance_item_group_wise/territory_target_variance_item_group_wise.js index 58718a4e0b..146b17d02b 100644 --- a/selling/report/territory_target_variance_(item_group_wise)/territory_target_variance_(item_group_wise).js +++ b/selling/report/territory_target_variance_item_group_wise/territory_target_variance_item_group_wise.js @@ -1,4 +1,4 @@ -wn.query_reports["Territory Target Variance (Item Group-Wise)"] = { +wn.query_reports["Territory Target Variance Item Group-Wise"] = { "filters": [ { fieldname: "fiscal_year", diff --git a/selling/report/territory_target_variance_(item_group_wise)/territory_target_variance_(item_group_wise).py b/selling/report/territory_target_variance_item_group_wise/territory_target_variance_item_group_wise.py similarity index 66% rename from selling/report/territory_target_variance_(item_group_wise)/territory_target_variance_(item_group_wise).py rename to selling/report/territory_target_variance_item_group_wise/territory_target_variance_item_group_wise.py index 079f8e82a2..e7ddc6e6f9 100644 --- a/selling/report/territory_target_variance_(item_group_wise)/territory_target_variance_(item_group_wise).py +++ b/selling/report/territory_target_variance_item_group_wise/territory_target_variance_item_group_wise.py @@ -16,18 +16,21 @@ from __future__ import unicode_literals import webnotes -import calendar from webnotes import _, msgprint from webnotes.utils import flt import time +from accounts.utils import get_fiscal_year +from controllers.trends import get_period_date_ranges, get_period_month_ranges def execute(filters=None): if not filters: filters = {} columns = get_columns(filters) - period_month_ranges = get_period_month_ranges(filters) + period_month_ranges = get_period_month_ranges(filters["period"], filters["fiscal_year"]) tim_map = get_territory_item_month_map(filters) + precision = webnotes.conn.get_value("Global Defaults", None, "float_precision") or 2 + data = [] for territory, territory_items in tim_map.items(): @@ -39,7 +42,7 @@ def execute(filters=None): for month in relevant_months: month_data = monthwise_data.get(month, {}) for i, fieldname in enumerate(["target", "achieved", "variance"]): - value = flt(month_data.get(fieldname)) + value = flt(month_data.get(fieldname), precision) period_data[i] += value totals[i] += value period_data[2] = period_data[0] - period_data[1] @@ -61,7 +64,7 @@ def get_columns(filters): group_months = False if filters["period"] == "Monthly" else True - for from_date, to_date in get_period_date_ranges(filters): + for from_date, to_date in get_period_date_ranges(filters["period"], filters["fiscal_year"]): for label in ["Target (%s)", "Achieved (%s)", "Variance (%s)"]: if group_months: columns.append(label % (from_date.strftime("%b") + " - " + to_date.strftime("%b"))) @@ -70,49 +73,14 @@ def get_columns(filters): return columns + ["Total Target::80", "Total Achieved::80", "Total Variance::80"] -def get_period_date_ranges(filters): - from dateutil.relativedelta import relativedelta - - year_start_date, year_end_date = get_year_start_end_date(filters) - - increment = { - "Monthly": 1, - "Quarterly": 3, - "Half-Yearly": 6, - "Yearly": 12 - }.get(filters["period"]) - - period_date_ranges = [] - for i in xrange(1, 13, increment): - period_end_date = year_start_date + relativedelta(months=increment, - days=-1) - period_date_ranges.append([year_start_date, period_end_date]) - year_start_date = period_end_date + relativedelta(days=1) - - return period_date_ranges - -def get_period_month_ranges(filters): - from dateutil.relativedelta import relativedelta - period_month_ranges = [] - - for start_date, end_date in get_period_date_ranges(filters): - months_in_this_period = [] - while start_date <= end_date: - months_in_this_period.append(start_date.strftime("%B")) - start_date += relativedelta(months=1) - period_month_ranges.append(months_in_this_period) - - return period_month_ranges - - #Get territory & item group details def get_territory_details(filters): return webnotes.conn.sql("""select t.name, td.item_group, td.target_qty, td.target_amount, t.distribution_id from `tabTerritory` t, `tabTarget Detail` td where td.parent=t.name and td.fiscal_year=%s and - ifnull(t.distribution_id, '')!='' order by t.name""" % - ('%s'), (filters.get("fiscal_year")), as_dict=1) + ifnull(t.distribution_id, '')!='' order by t.name""", + (filters["fiscal_year"]), as_dict=1) #Get target distribution details of item group def get_target_distribution_details(filters): @@ -121,14 +89,14 @@ def get_target_distribution_details(filters): for d in webnotes.conn.sql("""select bdd.month, bdd.percentage_allocation \ from `tabBudget Distribution Detail` bdd, `tabBudget Distribution` bd, \ `tabTerritory` t where bdd.parent=bd.name and t.distribution_id=bd.name and \ - bd.fiscal_year=%s""" % ('%s'), (filters.get("fiscal_year")), as_dict=1): + bd.fiscal_year=%s""", (filters["fiscal_year"]), as_dict=1): target_details.setdefault(d.month, d) return target_details #Get achieved details from sales order def get_achieved_details(filters): - start_date, end_date = get_year_start_end_date(filters) + start_date, end_date = get_fiscal_year(filters)[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 @@ -155,28 +123,18 @@ def get_territory_item_month_map(filters): for ad in achieved_details: if (filters["target_on"] == "Quantity"): - tav_dict.target = td.target_qty*(tdd[month]["percentage_allocation"]/100) - if ad.month_name == month and ''.join(get_item_group(ad.item_code)) == td.item_group \ + 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 = td.target_amount*(tdd[month]["percentage_allocation"]/100) - if ad.month_name == month and ''.join(get_item_group(ad.item_code)) == td.item_group \ + 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 return tim_map -def get_year_start_end_date(filters): - return webnotes.conn.sql("""select year_start_date, - subdate(adddate(year_start_date, interval 1 year), interval 1 day) - as year_end_date - from `tabFiscal Year` - where name=%s""", filters["fiscal_year"])[0] - def get_item_group(item_name): - """Get Item Group of an item""" - - return webnotes.conn.sql_list("select item_group from `tabItem` where name=%s""" % - ('%s'), (item_name)) \ No newline at end of file + return webnotes.conn.get_value("Item", item_name, item_group) \ No newline at end of file diff --git a/selling/report/territory_target_variance_(item_group_wise)/territory_target_variance_(item_group_wise).txt b/selling/report/territory_target_variance_item_group_wise/territory_target_variance_item_group_wise.txt similarity index 57% rename from selling/report/territory_target_variance_(item_group_wise)/territory_target_variance_(item_group_wise).txt rename to selling/report/territory_target_variance_item_group_wise/territory_target_variance_item_group_wise.txt index 7fff64a861..6e16b64d4e 100644 --- a/selling/report/territory_target_variance_(item_group_wise)/territory_target_variance_(item_group_wise).txt +++ b/selling/report/territory_target_variance_item_group_wise/territory_target_variance_item_group_wise.txt @@ -1,8 +1,8 @@ [ { - "creation": "2013-06-07 15:13:13", + "creation": "2013-06-21 12:15:00", "docstatus": 0, - "modified": "2013-06-07 15:13:13", + "modified": "2013-06-21 12:15:00", "modified_by": "Administrator", "owner": "Administrator" }, @@ -11,11 +11,11 @@ "is_standard": "Yes", "name": "__common__", "ref_doctype": "Sales Order", - "report_name": "Territory Target Variance (Item Group-Wise)", + "report_name": "Territory Target Variance Item Group-Wise", "report_type": "Script Report" }, { "doctype": "Report", - "name": "Territory Target Variance (Item Group-Wise)" + "name": "Territory Target Variance Item Group-Wise" } ] \ No newline at end of file diff --git a/stock/report/item_prices/item_prices.py b/stock/report/item_prices/item_prices.py index 86ae085ce7..7a3877bcca 100644 --- a/stock/report/item_prices/item_prices.py +++ b/stock/report/item_prices/item_prices.py @@ -24,16 +24,22 @@ def execute(filters=None): columns = get_columns(filters) item_map = get_item_details() pl = get_price_list() + last_purchase_rate = get_last_purchase_rate() bom_rate = get_item_bom_rate() val_rate_map = get_valuation_rate() + + precision = webnotes.conn.get_value("Global Defaults", None, "float_precision") or 2 data = [] for item in sorted(item_map): data.append([item, item_map[item]["item_name"], item_map[item]["description"], item_map[item]["stock_uom"], - flt(item_map[item]["last_purchase_rate"]), val_rate_map.get(item, 0), - pl.get(item, {}).get("selling"), pl.get(item, {}).get("buying"), - bom_rate.get(item, 0), flt(item_map[item]["standard_rate"]) + flt(last_purchase_rate.get(item, 0), precision), + flt(val_rate_map.get(item, 0), precision), + pl.get(item, {}).get("selling"), + pl.get(item, {}).get("buying"), + flt(bom_rate.get(item, 0), precision), + flt(item_map[item]["standard_rate"]) ]) return columns, data @@ -53,7 +59,7 @@ def get_item_details(): item_map = {} for i in webnotes.conn.sql("select name, item_name, description, \ - stock_uom, standard_rate, last_purchase_rate from tabItem \ + stock_uom, standard_rate from tabItem \ order by item_code", as_dict=1): item_map.setdefault(i.name, i) @@ -84,24 +90,60 @@ def get_price_list(): return item_rate_map +def get_last_purchase_rate(): + + item_last_purchase_rate_map = {} + + query = """select * from (select + result.item_code, + result.purchase_rate + from ( + (select + po_item.item_code, + po_item.item_name, + po.transaction_date as posting_date, + po_item.purchase_ref_rate, + po_item.discount_rate, + po_item.purchase_rate + from `tabPurchase Order` po, `tabPurchase Order Item` po_item + where po.name = po_item.parent and po.docstatus = 1) + union + (select + pr_item.item_code, + pr_item.item_name, + pr.posting_date, + pr_item.purchase_ref_rate, + pr_item.discount_rate, + pr_item.purchase_rate + from `tabPurchase Receipt` pr, `tabPurchase Receipt Item` pr_item + where pr.name = pr_item.parent and pr.docstatus = 1) + ) result + order by result.item_code asc, result.posting_date desc) result_wrapper + group by item_code""" + + for d in webnotes.conn.sql(query, as_dict=1): + item_last_purchase_rate_map.setdefault(d.item_code, d.purchase_rate) + + return item_last_purchase_rate_map + def get_item_bom_rate(): """Get BOM rate of an item from BOM""" - bom_map = {} + item_bom_map = {} for b in webnotes.conn.sql("""select item, (total_cost/quantity) as bom_rate from `tabBOM` where is_active=1 and is_default=1""", as_dict=1): - bom_map.setdefault(b.item, flt(b.bom_rate)) + item_bom_map.setdefault(b.item, flt(b.bom_rate)) - return bom_map + return item_bom_map def get_valuation_rate(): """Get an average valuation rate of an item from all warehouses""" - val_rate_map = {} + 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): - val_rate_map.setdefault(d.item_code, d.val_rate) + item_val_rate_map.setdefault(d.item_code, flt(d.val_rate)) - return val_rate_map \ No newline at end of file + return item_val_rate_map \ No newline at end of file From a19014a8469938ea38169fba9280aadb998e6760 Mon Sep 17 00:00:00 2001 From: Akhilesh Darjee Date: Mon, 24 Jun 2013 19:05:16 +0530 Subject: [PATCH 2/2] Moved Sales BOM & Sales BOM Item to Selling module, completed 'Available Stock for packing Items' report --- .../doctype/sales_bom/__init__.py | 0 .../sales_bom/locale/_messages_doc.json | 0 .../doctype/sales_bom/locale/ar-doc.json | 0 .../doctype/sales_bom/locale/de-doc.json | 0 .../doctype/sales_bom/locale/es-doc.json | 0 .../doctype/sales_bom/locale/fr-doc.json | 0 .../doctype/sales_bom/locale/hi-doc.json | 0 .../doctype/sales_bom/locale/hr-doc.json | 0 .../doctype/sales_bom/locale/nl-doc.json | 0 .../doctype/sales_bom/locale/pt-BR-doc.json | 0 .../doctype/sales_bom/locale/pt-doc.json | 0 .../doctype/sales_bom/locale/sr-doc.json | 0 .../doctype/sales_bom/locale/ta-doc.json | 0 .../doctype/sales_bom/locale/th-doc.json | 0 .../doctype/sales_bom/sales_bom.js | 0 .../doctype/sales_bom/sales_bom.py | 0 .../doctype/sales_bom/sales_bom.txt | 0 .../doctype/sales_bom/test_sales_bom.py | 0 .../doctype/sales_bom_item/__init__.py | 0 .../sales_bom_item/locale/_messages_doc.json | 0 .../doctype/sales_bom_item/locale/ar-doc.json | 0 .../doctype/sales_bom_item/locale/de-doc.json | 0 .../doctype/sales_bom_item/locale/es-doc.json | 0 .../doctype/sales_bom_item/locale/fr-doc.json | 0 .../doctype/sales_bom_item/locale/hi-doc.json | 0 .../doctype/sales_bom_item/locale/hr-doc.json | 0 .../doctype/sales_bom_item/locale/nl-doc.json | 0 .../sales_bom_item/locale/pt-BR-doc.json | 0 .../doctype/sales_bom_item/locale/pt-doc.json | 0 .../doctype/sales_bom_item/locale/sr-doc.json | 0 .../doctype/sales_bom_item/locale/ta-doc.json | 0 .../doctype/sales_bom_item/locale/th-doc.json | 0 .../doctype/sales_bom_item/sales_bom_item.py | 0 .../doctype/sales_bom_item/sales_bom_item.txt | 0 selling/locale/_messages_js.json | 1 + selling/locale/_messages_py.json | 7 ++ selling/locale/ar-py.json | 7 ++ selling/locale/de-py.json | 7 ++ selling/locale/es-py.json | 7 ++ selling/locale/fr-py.json | 7 ++ selling/locale/hi-py.json | 7 ++ selling/locale/hr-py.json | 7 ++ selling/locale/nl-py.json | 7 ++ selling/locale/pt-BR-py.json | 7 ++ selling/locale/pt-py.json | 7 ++ selling/locale/sr-py.json | 7 ++ selling/locale/ta-py.json | 7 ++ selling/locale/th-py.json | 7 ++ selling/page/selling_home/selling_home.js | 11 ++- .../__init__.py | 0 .../available_stock_for_packing_items.py | 89 +++++++++++++++++++ .../available_stock_for_packing_items.txt | 21 +++++ 52 files changed, 209 insertions(+), 4 deletions(-) rename {stock => selling}/doctype/sales_bom/__init__.py (100%) rename {stock => selling}/doctype/sales_bom/locale/_messages_doc.json (100%) rename {stock => selling}/doctype/sales_bom/locale/ar-doc.json (100%) rename {stock => selling}/doctype/sales_bom/locale/de-doc.json (100%) rename {stock => selling}/doctype/sales_bom/locale/es-doc.json (100%) rename {stock => selling}/doctype/sales_bom/locale/fr-doc.json (100%) rename {stock => selling}/doctype/sales_bom/locale/hi-doc.json (100%) rename {stock => selling}/doctype/sales_bom/locale/hr-doc.json (100%) rename {stock => selling}/doctype/sales_bom/locale/nl-doc.json (100%) rename {stock => selling}/doctype/sales_bom/locale/pt-BR-doc.json (100%) rename {stock => selling}/doctype/sales_bom/locale/pt-doc.json (100%) rename {stock => selling}/doctype/sales_bom/locale/sr-doc.json (100%) rename {stock => selling}/doctype/sales_bom/locale/ta-doc.json (100%) rename {stock => selling}/doctype/sales_bom/locale/th-doc.json (100%) rename {stock => selling}/doctype/sales_bom/sales_bom.js (100%) rename {stock => selling}/doctype/sales_bom/sales_bom.py (100%) rename {stock => selling}/doctype/sales_bom/sales_bom.txt (100%) rename {stock => selling}/doctype/sales_bom/test_sales_bom.py (100%) rename {stock => selling}/doctype/sales_bom_item/__init__.py (100%) rename {stock => selling}/doctype/sales_bom_item/locale/_messages_doc.json (100%) rename {stock => selling}/doctype/sales_bom_item/locale/ar-doc.json (100%) rename {stock => selling}/doctype/sales_bom_item/locale/de-doc.json (100%) rename {stock => selling}/doctype/sales_bom_item/locale/es-doc.json (100%) rename {stock => selling}/doctype/sales_bom_item/locale/fr-doc.json (100%) rename {stock => selling}/doctype/sales_bom_item/locale/hi-doc.json (100%) rename {stock => selling}/doctype/sales_bom_item/locale/hr-doc.json (100%) rename {stock => selling}/doctype/sales_bom_item/locale/nl-doc.json (100%) rename {stock => selling}/doctype/sales_bom_item/locale/pt-BR-doc.json (100%) rename {stock => selling}/doctype/sales_bom_item/locale/pt-doc.json (100%) rename {stock => selling}/doctype/sales_bom_item/locale/sr-doc.json (100%) rename {stock => selling}/doctype/sales_bom_item/locale/ta-doc.json (100%) rename {stock => selling}/doctype/sales_bom_item/locale/th-doc.json (100%) rename {stock => selling}/doctype/sales_bom_item/sales_bom_item.py (100%) rename {stock => selling}/doctype/sales_bom_item/sales_bom_item.txt (100%) create mode 100644 selling/locale/_messages_js.json create mode 100644 selling/locale/_messages_py.json create mode 100644 selling/locale/ar-py.json create mode 100644 selling/locale/de-py.json create mode 100644 selling/locale/es-py.json create mode 100644 selling/locale/fr-py.json create mode 100644 selling/locale/hi-py.json create mode 100644 selling/locale/hr-py.json create mode 100644 selling/locale/nl-py.json create mode 100644 selling/locale/pt-BR-py.json create mode 100644 selling/locale/pt-py.json create mode 100644 selling/locale/sr-py.json create mode 100644 selling/locale/ta-py.json create mode 100644 selling/locale/th-py.json create mode 100644 selling/report/available_stock_for_packing_items/__init__.py create mode 100644 selling/report/available_stock_for_packing_items/available_stock_for_packing_items.py create mode 100644 selling/report/available_stock_for_packing_items/available_stock_for_packing_items.txt diff --git a/stock/doctype/sales_bom/__init__.py b/selling/doctype/sales_bom/__init__.py similarity index 100% rename from stock/doctype/sales_bom/__init__.py rename to selling/doctype/sales_bom/__init__.py diff --git a/stock/doctype/sales_bom/locale/_messages_doc.json b/selling/doctype/sales_bom/locale/_messages_doc.json similarity index 100% rename from stock/doctype/sales_bom/locale/_messages_doc.json rename to selling/doctype/sales_bom/locale/_messages_doc.json diff --git a/stock/doctype/sales_bom/locale/ar-doc.json b/selling/doctype/sales_bom/locale/ar-doc.json similarity index 100% rename from stock/doctype/sales_bom/locale/ar-doc.json rename to selling/doctype/sales_bom/locale/ar-doc.json diff --git a/stock/doctype/sales_bom/locale/de-doc.json b/selling/doctype/sales_bom/locale/de-doc.json similarity index 100% rename from stock/doctype/sales_bom/locale/de-doc.json rename to selling/doctype/sales_bom/locale/de-doc.json diff --git a/stock/doctype/sales_bom/locale/es-doc.json b/selling/doctype/sales_bom/locale/es-doc.json similarity index 100% rename from stock/doctype/sales_bom/locale/es-doc.json rename to selling/doctype/sales_bom/locale/es-doc.json diff --git a/stock/doctype/sales_bom/locale/fr-doc.json b/selling/doctype/sales_bom/locale/fr-doc.json similarity index 100% rename from stock/doctype/sales_bom/locale/fr-doc.json rename to selling/doctype/sales_bom/locale/fr-doc.json diff --git a/stock/doctype/sales_bom/locale/hi-doc.json b/selling/doctype/sales_bom/locale/hi-doc.json similarity index 100% rename from stock/doctype/sales_bom/locale/hi-doc.json rename to selling/doctype/sales_bom/locale/hi-doc.json diff --git a/stock/doctype/sales_bom/locale/hr-doc.json b/selling/doctype/sales_bom/locale/hr-doc.json similarity index 100% rename from stock/doctype/sales_bom/locale/hr-doc.json rename to selling/doctype/sales_bom/locale/hr-doc.json diff --git a/stock/doctype/sales_bom/locale/nl-doc.json b/selling/doctype/sales_bom/locale/nl-doc.json similarity index 100% rename from stock/doctype/sales_bom/locale/nl-doc.json rename to selling/doctype/sales_bom/locale/nl-doc.json diff --git a/stock/doctype/sales_bom/locale/pt-BR-doc.json b/selling/doctype/sales_bom/locale/pt-BR-doc.json similarity index 100% rename from stock/doctype/sales_bom/locale/pt-BR-doc.json rename to selling/doctype/sales_bom/locale/pt-BR-doc.json diff --git a/stock/doctype/sales_bom/locale/pt-doc.json b/selling/doctype/sales_bom/locale/pt-doc.json similarity index 100% rename from stock/doctype/sales_bom/locale/pt-doc.json rename to selling/doctype/sales_bom/locale/pt-doc.json diff --git a/stock/doctype/sales_bom/locale/sr-doc.json b/selling/doctype/sales_bom/locale/sr-doc.json similarity index 100% rename from stock/doctype/sales_bom/locale/sr-doc.json rename to selling/doctype/sales_bom/locale/sr-doc.json diff --git a/stock/doctype/sales_bom/locale/ta-doc.json b/selling/doctype/sales_bom/locale/ta-doc.json similarity index 100% rename from stock/doctype/sales_bom/locale/ta-doc.json rename to selling/doctype/sales_bom/locale/ta-doc.json diff --git a/stock/doctype/sales_bom/locale/th-doc.json b/selling/doctype/sales_bom/locale/th-doc.json similarity index 100% rename from stock/doctype/sales_bom/locale/th-doc.json rename to selling/doctype/sales_bom/locale/th-doc.json diff --git a/stock/doctype/sales_bom/sales_bom.js b/selling/doctype/sales_bom/sales_bom.js similarity index 100% rename from stock/doctype/sales_bom/sales_bom.js rename to selling/doctype/sales_bom/sales_bom.js diff --git a/stock/doctype/sales_bom/sales_bom.py b/selling/doctype/sales_bom/sales_bom.py similarity index 100% rename from stock/doctype/sales_bom/sales_bom.py rename to selling/doctype/sales_bom/sales_bom.py diff --git a/stock/doctype/sales_bom/sales_bom.txt b/selling/doctype/sales_bom/sales_bom.txt similarity index 100% rename from stock/doctype/sales_bom/sales_bom.txt rename to selling/doctype/sales_bom/sales_bom.txt diff --git a/stock/doctype/sales_bom/test_sales_bom.py b/selling/doctype/sales_bom/test_sales_bom.py similarity index 100% rename from stock/doctype/sales_bom/test_sales_bom.py rename to selling/doctype/sales_bom/test_sales_bom.py diff --git a/stock/doctype/sales_bom_item/__init__.py b/selling/doctype/sales_bom_item/__init__.py similarity index 100% rename from stock/doctype/sales_bom_item/__init__.py rename to selling/doctype/sales_bom_item/__init__.py diff --git a/stock/doctype/sales_bom_item/locale/_messages_doc.json b/selling/doctype/sales_bom_item/locale/_messages_doc.json similarity index 100% rename from stock/doctype/sales_bom_item/locale/_messages_doc.json rename to selling/doctype/sales_bom_item/locale/_messages_doc.json diff --git a/stock/doctype/sales_bom_item/locale/ar-doc.json b/selling/doctype/sales_bom_item/locale/ar-doc.json similarity index 100% rename from stock/doctype/sales_bom_item/locale/ar-doc.json rename to selling/doctype/sales_bom_item/locale/ar-doc.json diff --git a/stock/doctype/sales_bom_item/locale/de-doc.json b/selling/doctype/sales_bom_item/locale/de-doc.json similarity index 100% rename from stock/doctype/sales_bom_item/locale/de-doc.json rename to selling/doctype/sales_bom_item/locale/de-doc.json diff --git a/stock/doctype/sales_bom_item/locale/es-doc.json b/selling/doctype/sales_bom_item/locale/es-doc.json similarity index 100% rename from stock/doctype/sales_bom_item/locale/es-doc.json rename to selling/doctype/sales_bom_item/locale/es-doc.json diff --git a/stock/doctype/sales_bom_item/locale/fr-doc.json b/selling/doctype/sales_bom_item/locale/fr-doc.json similarity index 100% rename from stock/doctype/sales_bom_item/locale/fr-doc.json rename to selling/doctype/sales_bom_item/locale/fr-doc.json diff --git a/stock/doctype/sales_bom_item/locale/hi-doc.json b/selling/doctype/sales_bom_item/locale/hi-doc.json similarity index 100% rename from stock/doctype/sales_bom_item/locale/hi-doc.json rename to selling/doctype/sales_bom_item/locale/hi-doc.json diff --git a/stock/doctype/sales_bom_item/locale/hr-doc.json b/selling/doctype/sales_bom_item/locale/hr-doc.json similarity index 100% rename from stock/doctype/sales_bom_item/locale/hr-doc.json rename to selling/doctype/sales_bom_item/locale/hr-doc.json diff --git a/stock/doctype/sales_bom_item/locale/nl-doc.json b/selling/doctype/sales_bom_item/locale/nl-doc.json similarity index 100% rename from stock/doctype/sales_bom_item/locale/nl-doc.json rename to selling/doctype/sales_bom_item/locale/nl-doc.json diff --git a/stock/doctype/sales_bom_item/locale/pt-BR-doc.json b/selling/doctype/sales_bom_item/locale/pt-BR-doc.json similarity index 100% rename from stock/doctype/sales_bom_item/locale/pt-BR-doc.json rename to selling/doctype/sales_bom_item/locale/pt-BR-doc.json diff --git a/stock/doctype/sales_bom_item/locale/pt-doc.json b/selling/doctype/sales_bom_item/locale/pt-doc.json similarity index 100% rename from stock/doctype/sales_bom_item/locale/pt-doc.json rename to selling/doctype/sales_bom_item/locale/pt-doc.json diff --git a/stock/doctype/sales_bom_item/locale/sr-doc.json b/selling/doctype/sales_bom_item/locale/sr-doc.json similarity index 100% rename from stock/doctype/sales_bom_item/locale/sr-doc.json rename to selling/doctype/sales_bom_item/locale/sr-doc.json diff --git a/stock/doctype/sales_bom_item/locale/ta-doc.json b/selling/doctype/sales_bom_item/locale/ta-doc.json similarity index 100% rename from stock/doctype/sales_bom_item/locale/ta-doc.json rename to selling/doctype/sales_bom_item/locale/ta-doc.json diff --git a/stock/doctype/sales_bom_item/locale/th-doc.json b/selling/doctype/sales_bom_item/locale/th-doc.json similarity index 100% rename from stock/doctype/sales_bom_item/locale/th-doc.json rename to selling/doctype/sales_bom_item/locale/th-doc.json diff --git a/stock/doctype/sales_bom_item/sales_bom_item.py b/selling/doctype/sales_bom_item/sales_bom_item.py similarity index 100% rename from stock/doctype/sales_bom_item/sales_bom_item.py rename to selling/doctype/sales_bom_item/sales_bom_item.py diff --git a/stock/doctype/sales_bom_item/sales_bom_item.txt b/selling/doctype/sales_bom_item/sales_bom_item.txt similarity index 100% rename from stock/doctype/sales_bom_item/sales_bom_item.txt rename to selling/doctype/sales_bom_item/sales_bom_item.txt diff --git a/selling/locale/_messages_js.json b/selling/locale/_messages_js.json new file mode 100644 index 0000000000..0637a088a0 --- /dev/null +++ b/selling/locale/_messages_js.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/selling/locale/_messages_py.json b/selling/locale/_messages_py.json new file mode 100644 index 0000000000..f5b4a010f5 --- /dev/null +++ b/selling/locale/_messages_py.json @@ -0,0 +1,7 @@ +[ + "is not a Stock Item", + "Item", + "Please check", + "reached its end of life on", + "is a cancelled Item" +] \ No newline at end of file diff --git a/selling/locale/ar-py.json b/selling/locale/ar-py.json new file mode 100644 index 0000000000..b8dd151cf9 --- /dev/null +++ b/selling/locale/ar-py.json @@ -0,0 +1,7 @@ +{ + "Item": "\u0628\u0646\u062f", + "Please check": "\u064a\u0631\u062c\u0649 \u0645\u0631\u0627\u062c\u0639\u0629", + "is a cancelled Item": "\u0647\u0648 \u0628\u0646\u062f \u0625\u0644\u063a\u0627\u0621", + "is not a Stock Item": "\u0644\u064a\u0633 \u0627\u0644\u0625\u063a\u0644\u0627\u0642 \u0644\u0644\u0633\u0647\u0645", + "reached its end of life on": "\u0648\u0635\u0644 \u0625\u0644\u0649 \u0646\u0647\u0627\u064a\u062a\u0647 \u0645\u0646 \u0627\u0644\u062d\u064a\u0627\u0629 \u0639\u0644\u0649" +} \ No newline at end of file diff --git a/selling/locale/de-py.json b/selling/locale/de-py.json new file mode 100644 index 0000000000..68b58d7a4b --- /dev/null +++ b/selling/locale/de-py.json @@ -0,0 +1,7 @@ +{ + "Item": "Artikel", + "Please check": "Bitte \u00fcberpr\u00fcfen Sie", + "is a cancelled Item": "ist ein gestempeltes", + "is not a Stock Item": "ist kein Lagerartikel", + "reached its end of life on": "erreichte Ende des Lebens auf" +} \ No newline at end of file diff --git a/selling/locale/es-py.json b/selling/locale/es-py.json new file mode 100644 index 0000000000..7d145d1e4c --- /dev/null +++ b/selling/locale/es-py.json @@ -0,0 +1,7 @@ +{ + "Item": "Art\u00edculo", + "Please check": "Por favor, compruebe", + "is a cancelled Item": "Es un Tema cancelado", + "is not a Stock Item": "no es un elemento de serie", + "reached its end of life on": "llegado al final de su vida en la" +} \ No newline at end of file diff --git a/selling/locale/fr-py.json b/selling/locale/fr-py.json new file mode 100644 index 0000000000..c466df4c7f --- /dev/null +++ b/selling/locale/fr-py.json @@ -0,0 +1,7 @@ +{ + "Item": "Article", + "Please check": "S'il vous pla\u00eet v\u00e9rifier", + "is a cancelled Item": "est un \u00e9l\u00e9ment annul\u00e9e", + "is not a Stock Item": "n'est pas un \u00e9l\u00e9ment de Stock", + "reached its end of life on": "atteint la fin de sa vie sur" +} \ No newline at end of file diff --git a/selling/locale/hi-py.json b/selling/locale/hi-py.json new file mode 100644 index 0000000000..58d4e65411 --- /dev/null +++ b/selling/locale/hi-py.json @@ -0,0 +1,7 @@ +{ + "Item": "\u092e\u0926", + "Please check": "\u0915\u0943\u092a\u092f\u093e \u091c\u093e\u0901\u091a \u0915\u0930\u0947\u0902", + "is a cancelled Item": "\u0930\u0926\u094d\u0926 \u0906\u0907\u091f\u092e", + "is not a Stock Item": "\u0938\u094d\u091f\u0949\u0915 \u0906\u0907\u091f\u092e \u0928\u0939\u0940\u0902 \u0939\u0948", + "reached its end of life on": "\u092a\u0930 \u0905\u092a\u0928\u0947 \u091c\u0940\u0935\u0928 \u0915\u0947 \u0905\u0902\u0924 \u0924\u0915 \u092a\u0939\u0941\u0901\u091a" +} \ No newline at end of file diff --git a/selling/locale/hr-py.json b/selling/locale/hr-py.json new file mode 100644 index 0000000000..24f60bb1c4 --- /dev/null +++ b/selling/locale/hr-py.json @@ -0,0 +1,7 @@ +{ + "Item": "Stavka", + "Please check": "Molimo provjerite", + "is a cancelled Item": "je otkazan artikla", + "is not a Stock Item": "nije katalo\u0161ki artikla", + "reached its end of life on": "dosegla svoj kraj \u017eivota na" +} \ No newline at end of file diff --git a/selling/locale/nl-py.json b/selling/locale/nl-py.json new file mode 100644 index 0000000000..7964d37f6e --- /dev/null +++ b/selling/locale/nl-py.json @@ -0,0 +1,7 @@ +{ + "Item": "Item", + "Please check": "Controleer", + "is a cancelled Item": "is een geannuleerde artikel", + "is not a Stock Item": "is niet een Stock Item", + "reached its end of life on": "het einde van zijn leven op" +} \ No newline at end of file diff --git a/selling/locale/pt-BR-py.json b/selling/locale/pt-BR-py.json new file mode 100644 index 0000000000..0bf350cad0 --- /dev/null +++ b/selling/locale/pt-BR-py.json @@ -0,0 +1,7 @@ +{ + "Item": "Item", + "Please check": "Por favor, verifique", + "is a cancelled Item": "\u00e9 um Item cancelado", + "is not a Stock Item": "n\u00e3o \u00e9 um Item de Estoque", + "reached its end of life on": "chegou ao fim de vida em" +} \ No newline at end of file diff --git a/selling/locale/pt-py.json b/selling/locale/pt-py.json new file mode 100644 index 0000000000..cfcbcec8df --- /dev/null +++ b/selling/locale/pt-py.json @@ -0,0 +1,7 @@ +{ + "Item": "Item", + "Please check": "Por favor, verifique", + "is a cancelled Item": "\u00e9 um item cancelado", + "is not a Stock Item": "n\u00e3o \u00e9 um item de estoque", + "reached its end of life on": "chegou ao fim da vida na" +} \ No newline at end of file diff --git a/selling/locale/sr-py.json b/selling/locale/sr-py.json new file mode 100644 index 0000000000..ed1672fc6c --- /dev/null +++ b/selling/locale/sr-py.json @@ -0,0 +1,7 @@ +{ + "Item": "\u0421\u0442\u0430\u0432\u043a\u0430", + "Please check": "\u041c\u043e\u043b\u0438\u043c\u043e \u0432\u0430\u0441 \u0434\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u0435", + "is a cancelled Item": "\u0458\u0435 \u043e\u0442\u043a\u0430\u0437\u0430\u043d\u0430 \u0448\u0438\u0444\u0440\u0430", + "is not a Stock Item": "\u043d\u0438\u0458\u0435 \u0431\u0435\u0440\u0437\u0430 \u0448\u0438\u0444\u0440\u0430", + "reached its end of life on": "\u0434\u043e\u0441\u0442\u0438\u0433\u0430\u043e \u0441\u0432\u043e\u0458 \u043a\u0440\u0430\u0458 \u0436\u0438\u0432\u043e\u0442\u0430 \u043d\u0430" +} \ No newline at end of file diff --git a/selling/locale/ta-py.json b/selling/locale/ta-py.json new file mode 100644 index 0000000000..355cc0e7ce --- /dev/null +++ b/selling/locale/ta-py.json @@ -0,0 +1,7 @@ +{ + "Item": "\u0b89\u0bb0\u0bc1\u0baa\u0bcd\u0baa\u0b9f\u0bbf", + "Please check": "\u0b9a\u0bb0\u0bbf\u0baa\u0bbe\u0bb0\u0bcd\u0b95\u0bcd\u0b95\u0bb5\u0bc1\u0bae\u0bcd", + "is a cancelled Item": "\u0b92\u0bb0\u0bc1 \u0bb0\u0ba4\u0bcd\u0ba4\u0bc1 \u0b89\u0bb0\u0bc1\u0baa\u0bcd\u0baa\u0b9f\u0bbf \u0b89\u0bb3\u0bcd\u0bb3\u0ba4\u0bc1", + "is not a Stock Item": "\u0b92\u0bb0\u0bc1 \u0baa\u0b99\u0bcd\u0b95\u0bc1 \u0baa\u0bc6\u0bbe\u0bb0\u0bc1\u0bb3\u0bcd \u0b85\u0bb2\u0bcd\u0bb2", + "reached its end of life on": "\u0bb5\u0bbe\u0bb4\u0bcd\u0b95\u0bcd\u0b95\u0bc8 \u0b85\u0ba4\u0ba9\u0bcd \u0b87\u0bb1\u0bc1\u0ba4\u0bbf\u0baf\u0bbf\u0bb2\u0bcd \u0b85\u0b9f\u0bc8\u0ba8\u0bcd\u0ba4\u0ba4\u0bc1" +} \ No newline at end of file diff --git a/selling/locale/th-py.json b/selling/locale/th-py.json new file mode 100644 index 0000000000..5f31a59373 --- /dev/null +++ b/selling/locale/th-py.json @@ -0,0 +1,7 @@ +{ + "Item": "\u0e0a\u0e34\u0e49\u0e19", + "Please check": "\u0e01\u0e23\u0e38\u0e13\u0e32\u0e15\u0e23\u0e27\u0e08\u0e2a\u0e2d\u0e1a", + "is a cancelled Item": "\u0e23\u0e32\u0e22\u0e01\u0e32\u0e23\u0e22\u0e01\u0e40\u0e25\u0e34\u0e01\u0e40\u0e1b\u0e47\u0e19", + "is not a Stock Item": "\u0e44\u0e21\u0e48\u0e44\u0e14\u0e49\u0e40\u0e1b\u0e47\u0e19\u0e23\u0e32\u0e22\u0e01\u0e32\u0e23\u0e2a\u0e15\u0e47\u0e2d\u0e01", + "reached its end of life on": "\u0e16\u0e36\u0e07\u0e08\u0e38\u0e14\u0e2a\u0e34\u0e49\u0e19\u0e2a\u0e38\u0e14\u0e02\u0e2d\u0e07\u0e0a\u0e35\u0e27\u0e34\u0e15\u0e40\u0e21\u0e37\u0e48\u0e2d" +} \ No newline at end of file diff --git a/selling/page/selling_home/selling_home.js b/selling/page/selling_home/selling_home.js index 7a0848e931..4157bbb809 100644 --- a/selling/page/selling_home/selling_home.js +++ b/selling/page/selling_home/selling_home.js @@ -167,13 +167,11 @@ wn.module_page["Selling"] = [ }, { "label":wn._("Territory Target Variance (Item Group-Wise)"), - route: "query-report/Territory Target Variance Item Group-Wise", - doctype: "Sales Order" + route: "query-report/Territory Target Variance Item Group-Wise" }, { "label":wn._("Sales Person Target Variance (Item Group-Wise)"), - route: "query-report/Sales Person Target Variance Item Group-Wise", - doctype: "Sales Order" + route: "query-report/Sales Person Target Variance Item Group-Wise" }, { "label":wn._("Customers Not Buying Since Long Time"), @@ -190,6 +188,11 @@ wn.module_page["Selling"] = [ route: "query-report/Sales Order Trends", doctype: "Sales Order" }, + { + "label":wn._("Available Stock for Packing Items"), + route: "query-report/Available Stock for Packing Items", + + }, ] } ] diff --git a/selling/report/available_stock_for_packing_items/__init__.py b/selling/report/available_stock_for_packing_items/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/selling/report/available_stock_for_packing_items/available_stock_for_packing_items.py b/selling/report/available_stock_for_packing_items/available_stock_for_packing_items.py new file mode 100644 index 0000000000..d766c4487d --- /dev/null +++ b/selling/report/available_stock_for_packing_items/available_stock_for_packing_items.py @@ -0,0 +1,89 @@ +# ERPNext - web based ERP (http://erpnext.com) +# Copyright (C) 2012 Web Notes Technologies Pvt Ltd +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +from __future__ import unicode_literals +import webnotes +from webnotes.utils import cint + +def execute(filters=None): + if not filters: filters = {} + + columns = get_columns() + item_warehouse_quantity_map = get_item_warehouse_quantity_map() + + data = [] + for item, warehouse in item_warehouse_quantity_map.items(): + item_details = get_item_details(item)[0] + total = 0 + total_qty = 0 + for wh, item_qty in warehouse.items(): + total += 1 + row = [item, item_details.item_name, item_details.description, \ + item_details.stock_uom, wh] + for quantity in item_qty.items(): + max_qty = [] + max_qty.append(quantity[1]) + max_qty = min(max_qty) + total_qty += cint(max_qty.qty) + row += [max_qty.qty] + data.append(row) + if (total == len(warehouse)): + row = ["", "", "Total", "", "", total_qty] + data.append(row) + + return columns, data + +def get_columns(): + columns = ["Item Code:Link/Item:100", "Item Name::100", "Description::120", \ + "UOM:Link/UOM:80", "Warehouse:Link/Warehouse:100", "Quantity::100"] + + return columns + +def get_sales_bom(): + return webnotes.conn.sql("""select name from `tabSales BOM`""", as_dict=1) + +def get_sales_bom_items(item): + return webnotes.conn.sql("""select parent, item_code, qty from `tabSales BOM Item` + where parent=%s""", (item), as_dict=1) + +def get_item_details(item): + return webnotes.conn.sql("""select name, item_name, description, stock_uom + from `tabItem` where name=%s""", (item), as_dict=1) + +def get_item_warehouse_quantity(item): + return webnotes.conn.sql("""select item_code, warehouse, actual_qty from `tabBin` + where item_code=%s""", (item), as_dict=1) + +def get_item_warehouse_quantity_map(): + iwq_map = {} + + sales_bom = get_sales_bom() + + for item in sales_bom: + child_item = get_sales_bom_items(item.name) + for child in child_item: + item_warehouse_quantity = get_item_warehouse_quantity(child.item_code) + for iwq in item_warehouse_quantity: + iwq_map.setdefault(item.name, {}).setdefault(iwq.warehouse, {}).\ + setdefault(child.item_code, webnotes._dict({ + "qty" : 0 + })) + + q_dict = iwq_map[item.name][iwq.warehouse][child.item_code] + + q_dict.qty = cint(iwq.actual_qty / child.qty) + + return iwq_map \ No newline at end of file diff --git a/selling/report/available_stock_for_packing_items/available_stock_for_packing_items.txt b/selling/report/available_stock_for_packing_items/available_stock_for_packing_items.txt new file mode 100644 index 0000000000..5cf413393f --- /dev/null +++ b/selling/report/available_stock_for_packing_items/available_stock_for_packing_items.txt @@ -0,0 +1,21 @@ +[ + { + "creation": "2013-06-21 13:40:05", + "docstatus": 0, + "modified": "2013-06-21 15:06:40", + "modified_by": "Administrator", + "owner": "Administrator" + }, + { + "doctype": "Report", + "is_standard": "Yes", + "name": "__common__", + "ref_doctype": "Sales BOM", + "report_name": "Available Stock for Packing Items", + "report_type": "Script Report" + }, + { + "doctype": "Report", + "name": "Available Stock for Packing Items" + } +] \ No newline at end of file