diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 1b0ab04afa9..82f58d1d5a9 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -494,4 +494,5 @@ erpnext.patches.v10_0.set_default_payment_terms_based_on_company erpnext.patches.v10_0.update_sales_order_link_to_purchase_order erpnext.patches.v10_0.added_extra_gst_custom_field_in_gstr2 #2018-02-13 erpnext.patches.v10_0.item_barcode_childtable_migrate -erpnext.patches.v10_0.update_translatable_fields \ No newline at end of file +erpnext.patches.v10_0.set_b2c_limit +erpnext.patches.v10_0.update_translatable_fields diff --git a/erpnext/patches/v10_0/set_b2c_limit.py b/erpnext/patches/v10_0/set_b2c_limit.py new file mode 100644 index 00000000000..93b5719c10f --- /dev/null +++ b/erpnext/patches/v10_0/set_b2c_limit.py @@ -0,0 +1,11 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import frappe + +def execute(): + frappe.reload_doc("regional", "doctype", "gst_settings") + gst_settings = frappe.get_doc("GST Settings") + gst_settings.b2c_limit = 250000 + gst_settings.save() \ No newline at end of file diff --git a/erpnext/regional/doctype/gst_settings/gst_settings.json b/erpnext/regional/doctype/gst_settings/gst_settings.json index ebd0865f41f..98c33ad33bb 100644 --- a/erpnext/regional/doctype/gst_settings/gst_settings.json +++ b/erpnext/regional/doctype/gst_settings/gst_settings.json @@ -160,6 +160,38 @@ "search_index": 0, "set_only_once": 0, "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "default": "250000", + "description": "Set Invoice Value for B2C. B2CL and B2CS calculated based on this invoice value.", + "fieldname": "b2c_limit", + "fieldtype": "Data", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 1, + "in_standard_filter": 0, + "label": "B2C Limit", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 1, + "search_index": 0, + "set_only_once": 0, + "unique": 0 } ], "has_web_view": 0, @@ -172,7 +204,7 @@ "issingle": 1, "istable": 0, "max_attachments": 0, - "modified": "2018-01-02 15:53:13.489144", + "modified": "2018-02-14 08:14:15.375181", "modified_by": "Administrator", "module": "Regional", "name": "GST Settings", diff --git a/erpnext/regional/report/gstr_1/gstr_1.py b/erpnext/regional/report/gstr_1/gstr_1.py index 4dd1300fc8d..912092344b0 100644 --- a/erpnext/regional/report/gstr_1/gstr_1.py +++ b/erpnext/regional/report/gstr_1/gstr_1.py @@ -111,16 +111,21 @@ class Gstr1Report(object): conditions += " and invoice_type != 'Export' and is_return != 1 and customer in ('{0}')".\ format("', '".join([frappe.db.escape(c.name) for c in customers])) + if self.filters.get("type_of_business") in ("B2C Large", "B2C Small"): + b2c_limit = frappe.db.get_single_value('GSt Settings', 'b2c_limit') + if not b2c_limit: + frappe.throw(_("Please set B2C Limit in GST Settings.")) + if self.filters.get("type_of_business") == "B2C Large": conditions += """ and SUBSTR(place_of_supply, 1, 2) != SUBSTR(company_gstin, 1, 2) - and grand_total > 250000 and is_return != 1 and customer in ('{0}')""".\ - format("', '".join([frappe.db.escape(c.name) for c in customers])) - + and grand_total > {0} and is_return != 1 and customer in ('{1}')""".\ + format((flt(b2c_limit), "', '".join([frappe.db.escape(c.name) for c in customers]) ) + elif self.filters.get("type_of_business") == "B2C Small": conditions += """ and ( SUBSTR(place_of_supply, 1, 2) = SUBSTR(company_gstin, 1, 2) - or grand_total <= 250000 ) and is_return != 1 and customer in ('{0}')""".\ - format("', '".join([frappe.db.escape(c.name) for c in customers])) + or grand_total <= {0}) and is_return != 1 and customer in ('{1}')""".\ + format(flt(b2c_limit), "', '".join([frappe.db.escape(c.name) for c in customers])) elif self.filters.get("type_of_business") == "CDNR": conditions += """ and is_return = 1 """