From f31ff74a75ca5da616264638fde9a24f867dfdb5 Mon Sep 17 00:00:00 2001 From: deepeshgarg007 Date: Wed, 24 Jul 2019 20:52:25 +0530 Subject: [PATCH] fix: GSTR-1 report fixes --- erpnext/regional/report/gstr_1/gstr_1.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/erpnext/regional/report/gstr_1/gstr_1.py b/erpnext/regional/report/gstr_1/gstr_1.py index 696dc73ef32..c1be406e92b 100644 --- a/erpnext/regional/report/gstr_1/gstr_1.py +++ b/erpnext/regional/report/gstr_1/gstr_1.py @@ -152,9 +152,9 @@ class Gstr1Report(object): customers = frappe.get_all("Customer", filters={"disabled": 0}) - if self.filters.get("type_of_business") == "B2B": + if self.filters.get("type_of_business") == "B2B" and customers: conditions += """ and ifnull(invoice_type, '') != 'Export' and is_return != 1 - and customer in ('{0}') and (customer_gstin IS NOT NULL AND customer_gstin NOT IN ('', 'NA'))""".\ + and customer in ('{0}') and (billing_address_gstin IS NOT NULL AND customer_gstin NOT IN ('', 'NA'))""".\ format("', '".join([frappe.db.escape(c.name) for c in customers])) if self.filters.get("type_of_business") in ("B2C Large", "B2C Small"): @@ -162,14 +162,14 @@ class Gstr1Report(object): if not b2c_limit: frappe.throw(_("Please set B2C Limit in GST Settings.")) - if self.filters.get("type_of_business") == "B2C Large": + if self.filters.get("type_of_business") == "B2C Large" and customers: conditions += """ and SUBSTR(place_of_supply, 1, 2) != SUBSTR(company_gstin, 1, 2) - and grand_total > {0} and is_return != 1 and customer in ('{1}')""".\ + and grand_total > {0} and is_return != 1 and customer in ('{1}') and (customer_gstin IS NULL OR customer_gstin IN ('', 'NA'))""".\ format(flt(b2c_limit), "', '".join([frappe.db.escape(c.name) for c in customers])) - elif self.filters.get("type_of_business") == "B2C Small": + elif self.filters.get("type_of_business") == "B2C Small" and customers: conditions += """ and ( SUBSTR(place_of_supply, 1, 2) = SUBSTR(company_gstin, 1, 2) - or grand_total <= {0}) and is_return != 1 and customer in ('{1}')""".\ + or grand_total <= {0}) and is_return != 1 and customer in ('{1}') and (customer_gstin IS NULL OR customer_gstin IN ('', 'NA'))""".\ format(flt(b2c_limit), "', '".join([frappe.db.escape(c.name) for c in customers])) elif self.filters.get("type_of_business") == "CDNR":