From b33fd6acc769dbfaa43c665c19f378e8e041d010 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Fri, 17 Dec 2021 15:59:21 +0530 Subject: [PATCH 1/3] fix: Is Reverse Charge check in Tax Category --- erpnext/patches.txt | 1 + .../v13_0/update_tax_category_for_rcm.py | 31 +++++++++++++++++++ erpnext/regional/india/setup.py | 4 ++- erpnext/regional/india/utils.py | 5 +-- 4 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 erpnext/patches/v13_0/update_tax_category_for_rcm.py diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 09ca3df92fdc..80f52c607c11 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -337,3 +337,4 @@ erpnext.patches.v13_0.update_category_in_ltds_certificate erpnext.patches.v13_0.create_ksa_vat_custom_fields erpnext.patches.v13_0.rename_ksa_qr_field erpnext.patches.v13_0.disable_ksa_print_format_for_others +erpnext.patches.v13_0.update_tax_category_for_rcm #1 \ No newline at end of file diff --git a/erpnext/patches/v13_0/update_tax_category_for_rcm.py b/erpnext/patches/v13_0/update_tax_category_for_rcm.py new file mode 100644 index 000000000000..7af2366bf0a4 --- /dev/null +++ b/erpnext/patches/v13_0/update_tax_category_for_rcm.py @@ -0,0 +1,31 @@ +import frappe +from frappe.custom.doctype.custom_field.custom_field import create_custom_fields + +from erpnext.regional.india import states + + +def execute(): + company = frappe.get_all('Company', filters = {'country': 'India'}) + if not company: + return + + create_custom_fields({ + 'Tax Category': [ + dict(fieldname='is_inter_state', label='Is Inter State', + fieldtype='Check', insert_after='disabled', print_hide=1), + dict(fieldname='is_reverse_charge', label='Is Reverse Charge', fieldtype='Check', + insert_after='is_inter_state', print_hide=1), + dict(fieldname='tax_category_column_break', fieldtype='Column Break', + insert_after='is_reverse_charge'), + dict(fieldname='gst_state', label='Source State', fieldtype='Select', + options='\n'.join(states), insert_after='company') + ] + }, update=True) + + tax_category = frappe.qb.DocType("Tax Category") + + frappe.qb.update(tax_category).set( + tax_category.is_reverse_charge, 1 + ).where( + tax_category.name.isin(['Reverse Charge Out-State', 'Reverse Charge In-State']) + ).run() \ No newline at end of file diff --git a/erpnext/regional/india/setup.py b/erpnext/regional/india/setup.py index d942f2b6c7dd..f84b0e7bd295 100644 --- a/erpnext/regional/india/setup.py +++ b/erpnext/regional/india/setup.py @@ -284,8 +284,10 @@ def get_custom_fields(): inter_state_gst_field = [ dict(fieldname='is_inter_state', label='Is Inter State', fieldtype='Check', insert_after='disabled', print_hide=1), + dict(fieldname='is_reverse_charge', label='Is Reverse Charge', fieldtype='Check', + insert_after='is_inter_state', print_hide=1), dict(fieldname='tax_category_column_break', fieldtype='Column Break', - insert_after='is_inter_state'), + insert_after='is_reverse_charge'), dict(fieldname='gst_state', label='Source State', fieldtype='Select', options='\n'.join(states), insert_after='company') ] diff --git a/erpnext/regional/india/utils.py b/erpnext/regional/india/utils.py index 9512a0d4a835..5b260c252d1d 100644 --- a/erpnext/regional/india/utils.py +++ b/erpnext/regional/india/utils.py @@ -69,7 +69,8 @@ def validate_pan_for_india(doc, method): frappe.throw(_("Invalid PAN No. The input you've entered doesn't match the format of PAN.")) def validate_tax_category(doc, method): - if doc.get('gst_state') and frappe.db.get_value('Tax Category', {'gst_state': doc.gst_state, 'is_inter_state': doc.is_inter_state}): + if doc.get('gst_state') and frappe.db.get_value('Tax Category', {'gst_state': doc.gst_state, 'is_inter_state': doc.is_inter_state, + 'is_reverse_charge': doc.is_reverse_charge}): if doc.is_inter_state: frappe.throw(_("Inter State tax category for GST State {0} already exists").format(doc.gst_state)) else: @@ -266,7 +267,7 @@ def get_tax_template_based_on_category(master_doctype, company, party_details): def get_tax_template(master_doctype, company, is_inter_state, state_code): tax_categories = frappe.get_all('Tax Category', fields = ['name', 'is_inter_state', 'gst_state'], - filters = {'is_inter_state': is_inter_state}) + filters = {'is_inter_state': is_inter_state, 'is_reverse_charge': 0}) default_tax = '' From 7c1bfe6b46ac3deedacfa666d0695b53b86ec3f6 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Fri, 17 Dec 2021 16:02:40 +0530 Subject: [PATCH 2/3] chore: Remove patch comment --- erpnext/patches.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 80f52c607c11..f2c0ff5ca6b1 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -337,4 +337,4 @@ erpnext.patches.v13_0.update_category_in_ltds_certificate erpnext.patches.v13_0.create_ksa_vat_custom_fields erpnext.patches.v13_0.rename_ksa_qr_field erpnext.patches.v13_0.disable_ksa_print_format_for_others -erpnext.patches.v13_0.update_tax_category_for_rcm #1 \ No newline at end of file +erpnext.patches.v13_0.update_tax_category_for_rcm \ No newline at end of file From 7e912db4b13ee2b1b88a68fc6110eb527a0375d5 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Tue, 21 Dec 2021 12:54:40 +0530 Subject: [PATCH 3/3] fix: Add is reverse charge in country wise tax --- erpnext/setup/setup_wizard/data/country_wise_tax.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/erpnext/setup/setup_wizard/data/country_wise_tax.json b/erpnext/setup/setup_wizard/data/country_wise_tax.json index 14b79510c12c..91e8eff89fd0 100644 --- a/erpnext/setup/setup_wizard/data/country_wise_tax.json +++ b/erpnext/setup/setup_wizard/data/country_wise_tax.json @@ -1178,11 +1178,13 @@ { "title": "Reverse Charge In-State", "is_inter_state": 0, + "is_reverse_charge": 1, "gst_state": "" }, { "title": "Reverse Charge Out-State", "is_inter_state": 1, + "is_reverse_charge": 1, "gst_state": "" }, {