Browse Source

fix: Is Reverse Charge check in Tax Category

(cherry picked from commit b33fd6acc769dbfaa43c665c19f378e8e041d010)

# Conflicts:
#	erpnext/patches.txt
develop
Deepesh Garg 3 years ago
committed by mergify-bot
parent
commit
12a65eef8a
  1. 7
      erpnext/patches.txt
  2. 31
      erpnext/patches/v13_0/update_tax_category_for_rcm.py
  3. 4
      erpnext/regional/india/setup.py
  4. 5
      erpnext/regional/india/utils.py

7
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.rename_ongoing_status_in_sla_documents
erpnext.patches.v14_0.migrate_crm_settings erpnext.patches.v14_0.migrate_crm_settings
erpnext.patches.v13_0.rename_ksa_qr_field erpnext.patches.v13_0.rename_ksa_qr_field
<<<<<<< HEAD
erpnext.patches.v13_0.disable_ksa_print_format_for_others # 16-12-2021 erpnext.patches.v13_0.disable_ksa_print_format_for_others # 16-12-2021
erpnext.patches.v14_0.add_default_exit_questionnaire_notification_template 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)

31
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()

4
erpnext/regional/india/setup.py

@ -277,8 +277,10 @@ def get_custom_fields():
inter_state_gst_field = [ inter_state_gst_field = [
dict(fieldname='is_inter_state', label='Is Inter State', dict(fieldname='is_inter_state', label='Is Inter State',
fieldtype='Check', insert_after='disabled', print_hide=1), 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', 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', dict(fieldname='gst_state', label='Source State', fieldtype='Select',
options='\n'.join(states), insert_after='company') options='\n'.join(states), insert_after='company')
] ]

5
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.")) frappe.throw(_("Invalid PAN No. The input you've entered doesn't match the format of PAN."))
def validate_tax_category(doc, method): 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: if doc.is_inter_state:
frappe.throw(_("Inter State tax category for GST State {0} already exists").format(doc.gst_state)) frappe.throw(_("Inter State tax category for GST State {0} already exists").format(doc.gst_state))
else: 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): 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'], 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 = '' default_tax = ''

Loading…
Cancel
Save