From b7438894f62943cec156b470098131010a5b03af Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 5 Jun 2014 16:14:28 +0530 Subject: [PATCH 1/4] Fixes in trends report --- erpnext/config/selling.py | 2 +- erpnext/controllers/trends.py | 14 +++++++------- erpnext/public/js/purchase_trends_filters.js | 4 ++-- erpnext/public/js/sales_trends_filters.js | 6 +++--- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/erpnext/config/selling.py b/erpnext/config/selling.py index bb70ac9607..a332bc425c 100644 --- a/erpnext/config/selling.py +++ b/erpnext/config/selling.py @@ -245,7 +245,7 @@ def get_data(): { "type": "report", "is_query_report": True, - "name": "Quotation Trend", + "name": "Quotation Trends", "doctype": "Quotation" }, { diff --git a/erpnext/controllers/trends.py b/erpnext/controllers/trends.py index 2c3483c311..7ef91007be 100644 --- a/erpnext/controllers/trends.py +++ b/erpnext/controllers/trends.py @@ -10,9 +10,9 @@ def get_columns(filters, trans): validate_filters(filters) # get conditions for based_on filter cond - based_on_details = based_wise_colums_query(filters.get("based_on"), trans) + based_on_details = based_wise_columns_query(filters.get("based_on"), trans) # get conditions for periodic filter cond - period_cols, period_select = period_wise_colums_query(filters, trans) + period_cols, period_select = period_wise_columns_query(filters, trans) # get conditions for grouping filter cond group_by_cols = group_wise_column(filters.get("group_by")) @@ -115,7 +115,7 @@ def get_data(filters, conditions): def get_mon(dt): return getdate(dt).strftime("%b") -def period_wise_colums_query(filters, trans): +def period_wise_columns_query(filters, trans): query_details = '' pwc = [] bet_dates = get_period_date_ranges(filters.get("period"), filters.get("fiscal_year")) @@ -132,9 +132,9 @@ def period_wise_colums_query(filters, trans): else: pwc = [filters.get("fiscal_year") + " (Qty):Float:120", filters.get("fiscal_year") + " (Amt):Currency:120"] - query_details = " SUM(t2.qty), SUM(t1.grand_total)," + query_details = " SUM(t2.qty), SUM(t2.base_amount)," - query_details += 'SUM(t2.qty), SUM(t1.grand_total)' + query_details += 'SUM(t2.qty), SUM(t2.base_amount)' return pwc, query_details def get_period_wise_columns(bet_dates, period, pwc): @@ -147,7 +147,7 @@ def get_period_wise_columns(bet_dates, period, pwc): def get_period_wise_query(bet_dates, trans_date, query_details): query_details += """SUM(IF(t1.%(trans_date)s BETWEEN '%(sd)s' AND '%(ed)s', t2.qty, NULL)), - SUM(IF(t1.%(trans_date)s BETWEEN '%(sd)s' AND '%(ed)s', t1.grand_total, NULL)), + SUM(IF(t1.%(trans_date)s BETWEEN '%(sd)s' AND '%(ed)s', t2.base_amount, NULL)), """ % {"trans_date": trans_date, "sd": bet_dates[0],"ed": bet_dates[1]} return query_details @@ -191,7 +191,7 @@ def get_period_month_ranges(period, fiscal_year): return period_month_ranges -def based_wise_colums_query(based_on, trans): +def based_wise_columns_query(based_on, trans): based_on_details = {} # based_on_cols, based_on_select, based_on_group_by, addl_tables diff --git a/erpnext/public/js/purchase_trends_filters.js b/erpnext/public/js/purchase_trends_filters.js index 168b9ad660..d60b915f48 100644 --- a/erpnext/public/js/purchase_trends_filters.js +++ b/erpnext/public/js/purchase_trends_filters.js @@ -21,7 +21,7 @@ var get_filters = function(){ "fieldname":"group_by", "label": __("Group By"), "fieldtype": "Select", - "options": ["Item", "Supplier"].join("\n"), + "options": ["", "Item", "Supplier"].join("\n"), "default": "" }, { @@ -39,4 +39,4 @@ var get_filters = function(){ "default": frappe.defaults.get_user_default("company") }, ]; -} \ No newline at end of file +} diff --git a/erpnext/public/js/sales_trends_filters.js b/erpnext/public/js/sales_trends_filters.js index a1254c1af0..89c269e339 100644 --- a/erpnext/public/js/sales_trends_filters.js +++ b/erpnext/public/js/sales_trends_filters.js @@ -21,7 +21,7 @@ var get_filters = function(){ "fieldname":"group_by", "label": __("Group By"), "fieldtype": "Select", - "options": ["Item", "Customer"].join("\n"), + "options": ["", "Item", "Customer"].join("\n"), "default": "" }, { @@ -37,6 +37,6 @@ var get_filters = function(){ "fieldtype": "Link", "options": "Company", "default": frappe.defaults.get_user_default("company") - }, + }, ]; -} \ No newline at end of file +} From 704a453b7aeffe3ec463f1395597442fd48c6736 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 5 Jun 2014 16:55:31 +0530 Subject: [PATCH 2/4] Set missing values only in unsubmitted documents --- erpnext/controllers/accounts_controller.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index 4567dd7005..a1bce2d213 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -12,7 +12,8 @@ import json class AccountsController(TransactionBase): def validate(self): - self.set_missing_values(for_validate=True) + if self.docstatus == 0: + self.set_missing_values(for_validate=True) self.validate_date_with_fiscal_year() if self.meta.get_field("currency"): self.calculate_taxes_and_totals() From 86207afe159709aa73b7b692f2b768c8c2410c47 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 5 Jun 2014 17:00:53 +0530 Subject: [PATCH 3/4] Set missing values only in unsubmitted documents --- erpnext/controllers/accounts_controller.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index a1bce2d213..167f6c276e 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -12,7 +12,7 @@ import json class AccountsController(TransactionBase): def validate(self): - if self.docstatus == 0: + if self._actions != "update_after_submit": self.set_missing_values(for_validate=True) self.validate_date_with_fiscal_year() if self.meta.get_field("currency"): From 977331806bce95485976984e8d0724f8dae2e9cb Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 5 Jun 2014 17:10:48 +0530 Subject: [PATCH 4/4] Set missing values only in unsubmitted documents --- erpnext/controllers/accounts_controller.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index 167f6c276e..3af82903a6 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -12,7 +12,7 @@ import json class AccountsController(TransactionBase): def validate(self): - if self._actions != "update_after_submit": + if self._action != "update_after_submit": self.set_missing_values(for_validate=True) self.validate_date_with_fiscal_year() if self.meta.get_field("currency"):