From 12a65eef8a75ae8350eb7487dff2738fc489f2ab Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Fri, 17 Dec 2021 15:59:21 +0530 Subject: [PATCH] fix: Is Reverse Charge check in Tax Category (cherry picked from commit b33fd6acc769dbfaa43c665c19f378e8e041d010) # Conflicts: # erpnext/patches.txt --- erpnext/patches.txt | 7 ++++- .../v13_0/update_tax_category_for_rcm.py | 31 +++++++++++++++++++ erpnext/regional/india/setup.py | 4 ++- erpnext/regional/india/utils.py | 5 +-- 4 files changed, 43 insertions(+), 4 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 d9cedab52a..8e74daa051 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -316,5 +316,10 @@ erpnext.patches.v13_0.create_ksa_vat_custom_fields erpnext.patches.v14_0.rename_ongoing_status_in_sla_documents erpnext.patches.v14_0.migrate_crm_settings erpnext.patches.v13_0.rename_ksa_qr_field +<<<<<<< HEAD erpnext.patches.v13_0.disable_ksa_print_format_for_others # 16-12-2021 -erpnext.patches.v14_0.add_default_exit_questionnaire_notification_template \ No newline at end of file +erpnext.patches.v14_0.add_default_exit_questionnaire_notification_template +======= +erpnext.patches.v13_0.disable_ksa_print_format_for_others +erpnext.patches.v13_0.update_tax_category_for_rcm #1 +>>>>>>> b33fd6acc7 (fix: Is Reverse Charge check in Tax Category) 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 0000000000..7af2366bf0 --- /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 5865424028..c0dcb70b92 100644 --- a/erpnext/regional/india/setup.py +++ b/erpnext/regional/india/setup.py @@ -277,8 +277,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 fd3ec3c08c..215b483c7a 100644 --- a/erpnext/regional/india/utils.py +++ b/erpnext/regional/india/utils.py @@ -67,7 +67,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: @@ -264,7 +265,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 = ''