From 530de12b079ff89a97b4270d85d471155d1f319b Mon Sep 17 00:00:00 2001 From: Subin Tom Date: Mon, 11 Oct 2021 17:33:41 +0530 Subject: [PATCH 1/2] feat: HSN wise tax breakup check in GST Settings --- .../doctype/gst_settings/gst_settings.json | 39 ++++++++----------- erpnext/regional/india/utils.py | 15 +++++-- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/erpnext/regional/doctype/gst_settings/gst_settings.json b/erpnext/regional/doctype/gst_settings/gst_settings.json index 95b930c4c86c..1dc30e4e234d 100644 --- a/erpnext/regional/doctype/gst_settings/gst_settings.json +++ b/erpnext/regional/doctype/gst_settings/gst_settings.json @@ -8,6 +8,7 @@ "gst_summary", "column_break_2", "round_off_gst_values", + "hsn_wise_tax_breakup", "gstin_email_sent_on", "section_break_4", "gst_accounts", @@ -17,37 +18,27 @@ { "fieldname": "gst_summary", "fieldtype": "HTML", - "label": "GST Summary", - "show_days": 1, - "show_seconds": 1 + "label": "GST Summary" }, { "fieldname": "column_break_2", - "fieldtype": "Column Break", - "show_days": 1, - "show_seconds": 1 + "fieldtype": "Column Break" }, { "fieldname": "gstin_email_sent_on", "fieldtype": "Date", "label": "GSTIN Email Sent On", - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "section_break_4", - "fieldtype": "Section Break", - "show_days": 1, - "show_seconds": 1 + "fieldtype": "Section Break" }, { "fieldname": "gst_accounts", "fieldtype": "Table", "label": "GST Accounts", - "options": "GST Account", - "show_days": 1, - "show_seconds": 1 + "options": "GST Account" }, { "default": "250000", @@ -56,24 +47,26 @@ "fieldtype": "Data", "in_list_view": 1, "label": "B2C Limit", - "reqd": 1, - "show_days": 1, - "show_seconds": 1 + "reqd": 1 }, { "default": "0", "description": "Enabling this option will round off individual GST components in all the Invoices", "fieldname": "round_off_gst_values", "fieldtype": "Check", - "label": "Round Off GST Values", - "show_days": 1, - "show_seconds": 1 + "label": "Round Off GST Values" + }, + { + "default": "0", + "fieldname": "hsn_wise_tax_breakup", + "fieldtype": "Check", + "label": "HSN Wise Tax Breakup " } ], "index_web_pages_for_search": 1, "issingle": 1, "links": [], - "modified": "2021-01-28 17:19:47.969260", + "modified": "2021-10-11 15:52:05.250159", "modified_by": "Administrator", "module": "Regional", "name": "GST Settings", @@ -83,4 +76,4 @@ "sort_field": "modified", "sort_order": "DESC", "track_changes": 1 - } \ No newline at end of file +} \ No newline at end of file diff --git a/erpnext/regional/india/utils.py b/erpnext/regional/india/utils.py index 94936143d88e..0e4128024d36 100644 --- a/erpnext/regional/india/utils.py +++ b/erpnext/regional/india/utils.py @@ -112,7 +112,11 @@ def validate_gstin_check_digit(gstin, label='GSTIN'): frappe.throw(_("""Invalid {0}! The check digit validation has failed. Please ensure you've typed the {0} correctly.""").format(label)) def get_itemised_tax_breakup_header(item_doctype, tax_accounts): - return [_("Item"), _("Taxable Amount")] + tax_accounts + hsn_wise_in_gst_settings = frappe.db.get_single_value('GST Settings','hsn_wise_tax_breakup') + if frappe.get_meta(item_doctype).has_field('gst_hsn_code') and hsn_wise_in_gst_settings: + return [_("HSN/SAC"), _("Taxable Amount")] + tax_accounts + else: + return [_("Item"), _("Taxable Amount")] + tax_accounts def get_itemised_tax_breakup_data(doc, account_wise=False, hsn_wise=False): itemised_tax = get_itemised_tax(doc.taxes, with_tax_account=account_wise) @@ -122,14 +126,17 @@ def get_itemised_tax_breakup_data(doc, account_wise=False, hsn_wise=False): if not frappe.get_meta(doc.doctype + " Item").has_field('gst_hsn_code'): return itemised_tax, itemised_taxable_amount - if hsn_wise: + hsn_wise_in_gst_settings = frappe.db.get_single_value('GST Settings','hsn_wise_tax_breakup') + + tax_breakup_hsn_wise = hsn_wise or hsn_wise_in_gst_settings + if tax_breakup_hsn_wise: item_hsn_map = frappe._dict() for d in doc.items: item_hsn_map.setdefault(d.item_code or d.item_name, d.get("gst_hsn_code")) hsn_tax = {} for item, taxes in itemised_tax.items(): - item_or_hsn = item if not hsn_wise else item_hsn_map.get(item) + item_or_hsn = item if not tax_breakup_hsn_wise else item_hsn_map.get(item) hsn_tax.setdefault(item_or_hsn, frappe._dict()) for tax_desc, tax_detail in taxes.items(): key = tax_desc @@ -142,7 +149,7 @@ def get_itemised_tax_breakup_data(doc, account_wise=False, hsn_wise=False): # set taxable amount hsn_taxable_amount = frappe._dict() for item in itemised_taxable_amount: - item_or_hsn = item if not hsn_wise else item_hsn_map.get(item) + item_or_hsn = item if not tax_breakup_hsn_wise else item_hsn_map.get(item) hsn_taxable_amount.setdefault(item_or_hsn, 0) hsn_taxable_amount[item_or_hsn] += itemised_taxable_amount.get(item) From fc4facc5dc38103819d8ade40beb5a0824589b0e Mon Sep 17 00:00:00 2001 From: Subin Tom Date: Mon, 11 Oct 2021 18:19:58 +0530 Subject: [PATCH 2/2] added new section in gst settings page --- .../doctype/gst_settings/gst_settings.json | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/erpnext/regional/doctype/gst_settings/gst_settings.json b/erpnext/regional/doctype/gst_settings/gst_settings.json index 1dc30e4e234d..fc579d4b38cc 100644 --- a/erpnext/regional/doctype/gst_settings/gst_settings.json +++ b/erpnext/regional/doctype/gst_settings/gst_settings.json @@ -6,8 +6,9 @@ "engine": "InnoDB", "field_order": [ "gst_summary", - "column_break_2", + "gst_tax_settings_section", "round_off_gst_values", + "column_break_4", "hsn_wise_tax_breakup", "gstin_email_sent_on", "section_break_4", @@ -20,10 +21,6 @@ "fieldtype": "HTML", "label": "GST Summary" }, - { - "fieldname": "column_break_2", - "fieldtype": "Column Break" - }, { "fieldname": "gstin_email_sent_on", "fieldtype": "Date", @@ -60,13 +57,22 @@ "default": "0", "fieldname": "hsn_wise_tax_breakup", "fieldtype": "Check", - "label": "HSN Wise Tax Breakup " + "label": "Tax Breakup Table Based On HSN Code" + }, + { + "fieldname": "gst_tax_settings_section", + "fieldtype": "Section Break", + "label": "GST Tax Settings" + }, + { + "fieldname": "column_break_4", + "fieldtype": "Column Break" } ], "index_web_pages_for_search": 1, "issingle": 1, "links": [], - "modified": "2021-10-11 15:52:05.250159", + "modified": "2021-10-11 18:10:14.242614", "modified_by": "Administrator", "module": "Regional", "name": "GST Settings",