Skip to content

Commit

Permalink
Merge pull request #1806 from ljain112/fix-tds--category
Browse files Browse the repository at this point in the history
fix: remove validation for duplicate tax withholding category
  • Loading branch information
vorasmit authored Mar 1, 2024
2 parents 3a40960 + 9cec66c commit 12d5ba4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 29 deletions.
1 change: 0 additions & 1 deletion india_compliance/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@
"validate": "india_compliance.gst_india.overrides.tax_category.validate"
},
"Tax Withholding Category": {
"validate": "india_compliance.income_tax_india.overrides.tax_withholding_category.validate",
"on_change": "india_compliance.income_tax_india.overrides.tax_withholding_category.on_change",
},
"Unreconcile Payment": {
Expand Down
13 changes: 7 additions & 6 deletions india_compliance/income_tax_india/overrides/company.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,23 @@ def create_or_update_tax_withholding_category(company):
categories = get_tds_category_details(accounts)

for category_doc in categories:
existing_category_name = frappe.get_value(
existing_category_list = frappe.get_all(
"Tax Withholding Category",
{
"tds_section": category_doc.get("tds_section"),
"entity_type": category_doc.get("entity_type"),
},
pluck="name",
)

if not existing_category_name:
if not existing_category_list:
doc = frappe.get_doc(category_doc)
doc.insert(ignore_if_duplicate=True, ignore_mandatory=ignore_mandatory)

else:
update_existing_tax_withholding_category(
category_doc, existing_category_name, company
)
for category_name in existing_category_list:
update_existing_tax_withholding_category(
category_doc, category_name, company
)


def update_existing_tax_withholding_category(category_doc, category_name, company):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import frappe
from frappe.utils import get_link_to_form


def on_change(doc, method=None):
Expand All @@ -17,24 +16,3 @@ def _get_tax_withholding_accounts():
return frappe.cache.hget(
"tax_withholding_accounts", company, generator=_get_tax_withholding_accounts
)


def validate(doc, method=None):
if not (doc.tds_section or doc.entity_type):
return

existing_doc = frappe.db.exists(
"Tax Withholding Category",
{
"tds_section": doc.tds_section,
"entity_type": doc.entity_type,
"name": ("!=", doc.name),
},
)

if not existing_doc:
return

frappe.throw(
f'{get_link_to_form("Tax Withholding Category",existing_doc)} already exists for the TDS section - {doc.tds_section} and Entity type - {doc.entity_type}.'
)

0 comments on commit 12d5ba4

Please sign in to comment.