diff --git a/india_compliance/hooks.py b/india_compliance/hooks.py index 114e56c18..c1d121a2e 100644 --- a/india_compliance/hooks.py +++ b/india_compliance/hooks.py @@ -204,6 +204,7 @@ "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": { diff --git a/india_compliance/income_tax_india/constants/__init__.py b/india_compliance/income_tax_india/constants/__init__.py new file mode 100644 index 000000000..4b9ee46be --- /dev/null +++ b/india_compliance/income_tax_india/constants/__init__.py @@ -0,0 +1,27 @@ +TDS_SECTIONS = [ + "193", + "194", + "194BB", + "194EE", + "194A", + "194B", + "194C", + "194D", + "194F", + "194G", + "194H", + "194I", + "194JA", + "194JB", + "194LA", + "194I(a)", + "194I(b)", + "194LBA", + "194DA", + "192A", + "194LBB", + "194IA", + "194N", +] + +TDS_ENTITY_TYPE = ["Individual", "Company", "Company Assessee", "No PAN / Invalid PAN"] diff --git a/india_compliance/income_tax_india/constants/custom_fields.py b/india_compliance/income_tax_india/constants/custom_fields.py index 5827e2885..35ae89a96 100644 --- a/india_compliance/income_tax_india/constants/custom_fields.py +++ b/india_compliance/income_tax_india/constants/custom_fields.py @@ -1,3 +1,8 @@ +from india_compliance.income_tax_india.constants import TDS_ENTITY_TYPE, TDS_SECTIONS + +tds_section_options = "\n" + "\n".join(sorted(TDS_SECTIONS)) +tds_entity_type_options = "\n" + "\n".join(sorted(TDS_ENTITY_TYPE)) + party_fields = [ { "fieldname": "pan", @@ -25,4 +30,24 @@ ), } ], + "Tax Withholding Category": [ + { + "label": "Section", + "fieldname": "tds_section", + "insert_after": "round_off_tax_amount", + "fieldtype": "Autocomplete", + "options": tds_section_options, + "translatable": 0, + "mandatory_depends_on": "eval:doc.entity_type", + }, + { + "label": "Entity", + "fieldname": "entity_type", + "insert_after": "tax_on_excess_amount", + "fieldtype": "Select", + "options": tds_entity_type_options, + "translatable": 0, + "mandatory_depends_on": "eval:doc.tds_section", + }, + ], } diff --git a/india_compliance/income_tax_india/data/tds_details.json b/india_compliance/income_tax_india/data/tds_details.json index 648d31570..0ddd80685 100644 --- a/india_compliance/income_tax_india/data/tds_details.json +++ b/india_compliance/income_tax_india/data/tds_details.json @@ -1,48 +1,1303 @@ -{ - "Payment to Contractors (Single / Aggregate)": [ - ["TDS - 194C - Company", 2, 30000, 100000], - ["TDS - 194C - Individual", 1, 30000, 100000], - ["TDS - 194C - No PAN / Invalid PAN", 20, 30000, 100000] - ], - "Insurance Commission": [ - ["TDS - 194D - Company", 5, 15000, 0], - ["TDS - 194D - Company Assessee", 10, 15000, 0], - ["TDS - 194D - Individual", 5, 15000, 0], - ["TDS - 194D - No PAN / Invalid PAN", 20, 15000, 0] - ], - "Non-exempt payments made under a life insurance policy": [ - ["TDS - 194DA - Company", 1, 100000, 0], - ["TDS - 194DA - Individual", 1, 100000, 0], - ["TDS - 194DA - No PAN / Invalid PAN", 20, 100000, 0] - ], - "Commission / Brokerage": [ - ["TDS - 194H - Company", 5, 15000, 0], - ["TDS - 194H - Individual", 5, 15000, 0], - ["TDS - 194H - No PAN / Invalid PAN", 20, 15000, 0] - ], - "Rent": [ - ["TDS - 194I - Rent - Company", 10, 180000, 0], - ["TDS - 194I - Rent - Individual", 10, 180000, 0], - ["TDS - 194I - Rent - No PAN / Invalid PAN", 20, 180000, 0] - ], - "Rent-Plant / Machinery": [ - ["TDS - 194I - Rent/Machinery - Company", 2, 180000, 0], - ["TDS - 194I - Rent/Machinery - Individual", 2, 180000, 0], - ["TDS - 194I - Rent/Machinery - No PAN / Invalid PAN", 20, 180000, 0] - ], - "Professional Fees": [ - ["TDS - 194J - Professional Fees - Company", 10, 30000, 0], - ["TDS - 194J - Professional Fees - Individual", 10, 30000, 0], - ["TDS - 194J - Professional Fees - No PAN / Invalid PAN", 20, 30000, 0] - ], - "Director Fees": [ - ["TDS - 194J - Director Fees - Company", 10, 0, 0], - ["TDS - 194J - Director Fees - Individual", 10, 0, 0], - ["TDS - 194J - Director Fees - No PAN / Invalid PAN", 20, 0, 0] - ], - "Dividends": [ - ["TDS - 194 - Dividends - Company", 10, 2500, 0], - ["TDS - 194 - Dividends - Individual", 10, 2500, 0], - ["TDS - 194 - Dividends - No PAN / Invalid PAN", 20, 2500, 0] - ] -} +[ + { + "name": "TDS - 194C - Company", + "category_name": "Payment to Contractors (Single / Aggregate)", + "round_off_tax_amount": 0, + "tds_section": "194C", + "consider_party_ledger_amount": 0, + "tax_on_excess_amount": 0, + "entity_type": "Company", + "rates": [ + { + "from_date": "2023-04-01", + "to_date": "2024-04-01", + "tax_withholding_rate": 2, + "single_threshold": 30000, + "cumulative_threshold": 100000 + }, + { + "from_date": "2024-04-01", + "to_date": "2025-03-31", + "tax_withholding_rate": 2, + "single_threshold": 30000, + "cumulative_threshold": 100000 + } + ] + }, + { + "name": "TDS - 194C - Individual", + "category_name": "Payment to Contractors (Single / Aggregate)", + "round_off_tax_amount": 0, + "tds_section": "194C", + "consider_party_ledger_amount": 0, + "tax_on_excess_amount": 0, + "entity_type": "Individual", + "rates": [ + { + "from_date": "2023-04-01", + "to_date": "2024-04-01", + "tax_withholding_rate": 1, + "single_threshold": 30000, + "cumulative_threshold": 100000 + }, + { + "from_date": "2024-04-01", + "to_date": "2025-03-31", + "tax_withholding_rate": 1, + "single_threshold": 30000, + "cumulative_threshold": 100000 + } + ] + }, + { + "name": "TDS - 194C - No PAN / Invalid PAN", + "category_name": "Payment to Contractors (Single / Aggregate)", + "round_off_tax_amount": 0, + "tds_section": "194C", + "consider_party_ledger_amount": 0, + "tax_on_excess_amount": 0, + "entity_type": "No PAN / Invalid PAN", + "rates": [ + { + "from_date": "2023-04-01", + "to_date": "2024-04-01", + "tax_withholding_rate": 20, + "single_threshold": 30000, + "cumulative_threshold": 100000 + }, + { + "from_date": "2024-04-01", + "to_date": "2025-03-31", + "tax_withholding_rate": 20, + "single_threshold": 30000, + "cumulative_threshold": 100000 + } + ] + }, + { + "name": "TDS - 194D - Company", + "category_name": "Insurance Commission", + "round_off_tax_amount": 0, + "tds_section": "194D", + "consider_party_ledger_amount": 0, + "tax_on_excess_amount": 0, + "entity_type": "Company", + "rates": [ + { + "from_date": "2023-04-01", + "to_date": "2024-03-31", + "tax_withholding_rate": 5, + "single_threshold": 15000, + "cumulative_threshold": 0 + }, + { + "from_date": "2024-04-01", + "to_date": "2025-03-31", + "tax_withholding_rate": 5, + "single_threshold": 15000, + "cumulative_threshold": 0 + } + ] + }, + { + "name": "TDS - 194D - Company Assessee", + "category_name": "Insurance Commission", + "round_off_tax_amount": 0, + "tds_section": "194D", + "consider_party_ledger_amount": 0, + "tax_on_excess_amount": 0, + "entity_type": "Company Assessee", + "rates": [ + { + "from_date": "2023-04-01", + "to_date": "2024-03-31", + "tax_withholding_rate": 10, + "single_threshold": 15000, + "cumulative_threshold": 0 + }, + { + "from_date": "2024-04-01", + "to_date": "2025-03-31", + "tax_withholding_rate": 10, + "single_threshold": 15000, + "cumulative_threshold": 0 + } + ] + }, + { + "name": "TDS - 194D - Individual", + "category_name": "Insurance Commission", + "round_off_tax_amount": 0, + "tds_section": "194D", + "consider_party_ledger_amount": 0, + "tax_on_excess_amount": 0, + "entity_type": "Individual", + "rates": [ + { + "from_date": "2023-04-01", + "to_date": "2024-03-31", + "tax_withholding_rate": 5, + "single_threshold": 15000, + "cumulative_threshold": 0 + }, + { + "from_date": "2024-04-01", + "to_date": "2025-03-31", + "tax_withholding_rate": 5, + "single_threshold": 15000, + "cumulative_threshold": 0 + } + ] + }, + { + "name": "TDS - 194D - No PAN / Invalid PAN", + "category_name": "Insurance Commission", + "round_off_tax_amount": 0, + "tds_section": "194D", + "consider_party_ledger_amount": 0, + "tax_on_excess_amount": 0, + "entity_type": "No PAN / Invalid PAN", + "rates": [ + { + "from_date": "2023-04-01", + "to_date": "2024-03-31", + "tax_withholding_rate": 20, + "single_threshold": 15000, + "cumulative_threshold": 0 + }, + { + "from_date": "2024-04-01", + "to_date": "2025-03-31", + "tax_withholding_rate": 20, + "single_threshold": 15000, + "cumulative_threshold": 0 + } + ] + }, + { + "name": "TDS - 194DA - Company", + "category_name": "Non-exempt payments made under a life insurance policy", + "round_off_tax_amount": 0, + "tds_section": "194DA", + "consider_party_ledger_amount": 0, + "tax_on_excess_amount": 0, + "entity_type": "Company", + "rates": [ + { + "from_date": "2023-04-01", + "to_date": "2024-03-31", + "tax_withholding_rate": 1, + "single_threshold": 100000, + "cumulative_threshold": 0 + }, + { + "from_date": "2024-04-01", + "to_date": "2025-03-31", + "tax_withholding_rate": 5, + "single_threshold": 100000, + "cumulative_threshold": 0 + } + ] + }, + { + "name": "TDS - 194DA - Individual", + "category_name": "Non-exempt payments made under a life insurance policy", + "round_off_tax_amount": 0, + "tds_section": "194DA", + "consider_party_ledger_amount": 0, + "tax_on_excess_amount": 0, + "entity_type": "Individual", + "rates": [ + { + "from_date": "2023-04-01", + "to_date": "2024-03-31", + "tax_withholding_rate": 1, + "single_threshold": 100000, + "cumulative_threshold": 0 + }, + { + "from_date": "2024-04-01", + "to_date": "2025-03-31", + "tax_withholding_rate": 5, + "single_threshold": 100000, + "cumulative_threshold": 0 + } + ] + }, + { + "name": "TDS - 194DA - No PAN / Invalid PAN", + "category_name": "Non-exempt payments made under a life insurance policy", + "round_off_tax_amount": 0, + "tds_section": "194DA", + "consider_party_ledger_amount": 0, + "tax_on_excess_amount": 0, + "entity_type": "No PAN / Invalid PAN", + "rates": [ + { + "from_date": "2023-04-01", + "to_date": "2024-03-31", + "tax_withholding_rate": 20, + "single_threshold": 100000, + "cumulative_threshold": 0 + }, + { + "from_date": "2024-04-01", + "to_date": "2025-03-31", + "tax_withholding_rate": 20, + "single_threshold": 100000, + "cumulative_threshold": 0 + } + ] + }, + { + "name": "TDS - 194H - Company", + "category_name": "Commission / Brokerage", + "round_off_tax_amount": 0, + "tds_section": "194H", + "consider_party_ledger_amount": 0, + "tax_on_excess_amount": 0, + "entity_type": "Company", + "rates": [ + { + "from_date": "2023-04-01", + "to_date": "2024-03-31", + "tax_withholding_rate": 5, + "single_threshold": 15000, + "cumulative_threshold": 0 + }, + { + "from_date": "2024-04-01", + "to_date": "2025-03-31", + "tax_withholding_rate": 5, + "single_threshold": 15000, + "cumulative_threshold": 0 + } + ] + }, + { + "name": "TDS - 194H - Individual", + "category_name": "Commission / Brokerage", + "round_off_tax_amount": 0, + "tds_section": "194H", + "consider_party_ledger_amount": 0, + "tax_on_excess_amount": 0, + "entity_type": "Individual", + "rates": [ + { + "from_date": "2023-04-01", + "to_date": "2024-03-31", + "tax_withholding_rate": 5, + "single_threshold": 15000, + "cumulative_threshold": 0 + }, + { + "from_date": "2024-04-01", + "to_date": "2025-03-31", + "tax_withholding_rate": 5, + "single_threshold": 15000, + "cumulative_threshold": 0 + } + ] + }, + { + "name": "TDS - 194H - No PAN / Invalid PAN", + "category_name": "Commission / Brokerage", + "round_off_tax_amount": 0, + "tds_section": "194H", + "consider_party_ledger_amount": 0, + "tax_on_excess_amount": 0, + "entity_type": "No PAN / Invalid PAN", + "rates": [ + { + "from_date": "2023-04-01", + "to_date": "2024-03-31", + "tax_withholding_rate": 20, + "single_threshold": 15000, + "cumulative_threshold": 0 + }, + { + "from_date": "2024-04-01", + "to_date": "2025-03-31", + "tax_withholding_rate": 20, + "single_threshold": 15000, + "cumulative_threshold": 0 + } + ] + }, + { + "name": "TDS - 194I(a) - Company", + "category_name": "Rent on plant / machinery", + "round_off_tax_amount": 0, + "tds_section": "194I(a)", + "consider_party_ledger_amount": 0, + "tax_on_excess_amount": 0, + "entity_type": "Company", + "rates": [ + { + "from_date": "2023-04-01", + "to_date": "2024-03-31", + "tax_withholding_rate": 2, + "single_threshold": 180000, + "cumulative_threshold": 0 + }, + { + "from_date": "2024-04-01", + "to_date": "2025-03-31", + "tax_withholding_rate": 2, + "single_threshold": 240000, + "cumulative_threshold": 0 + } + ] + }, + { + "name": "TDS - 194I(a) - Individual", + "category_name": "Rent on plant / machinery", + "round_off_tax_amount": 0, + "tds_section": "194I(a)", + "consider_party_ledger_amount": 0, + "tax_on_excess_amount": 0, + "entity_type": "Individual", + "rates": [ + { + "from_date": "2023-04-01", + "to_date": "2024-03-31", + "tax_withholding_rate": 2, + "single_threshold": 180000, + "cumulative_threshold": 0 + }, + { + "from_date": "2024-04-01", + "to_date": "2025-03-31", + "tax_withholding_rate": 2, + "single_threshold": 240000, + "cumulative_threshold": 0 + } + ] + }, + { + "name": "TDS - 194I(a) - No PAN / Invalid PAN", + "category_name": "Rent on plant / machinery", + "round_off_tax_amount": 0, + "tds_section": "194I(a)", + "consider_party_ledger_amount": 0, + "tax_on_excess_amount": 0, + "entity_type": "No PAN / Invalid PAN", + "rates": [ + { + "from_date": "2023-04-01", + "to_date": "2024-03-31", + "tax_withholding_rate": 20, + "single_threshold": 180000, + "cumulative_threshold": 0 + }, + { + "from_date": "2024-04-01", + "to_date": "2025-03-31", + "tax_withholding_rate": 20, + "single_threshold": 240000, + "cumulative_threshold": 0 + } + ] + }, + { + "name": "TDS - 194I(b) - Company", + "category_name": "Rent on land / building / furniture / fitting", + "round_off_tax_amount": 0, + "tds_section": "194I(b)", + "consider_party_ledger_amount": 0, + "tax_on_excess_amount": 0, + "entity_type": "Company", + "rates": [ + { + "from_date": "2023-04-01", + "to_date": "2024-03-31", + "tax_withholding_rate": 10, + "single_threshold": 180000, + "cumulative_threshold": 0 + }, + { + "from_date": "2024-04-01", + "to_date": "2025-03-31", + "tax_withholding_rate": 10, + "single_threshold": 240000, + "cumulative_threshold": 0 + } + ] + }, + { + "name": "TDS - 194I(b) - Individual", + "category_name": "Rent on land / building / furniture / fitting", + "round_off_tax_amount": 0, + "tds_section": "194I(b)", + "consider_party_ledger_amount": 0, + "tax_on_excess_amount": 0, + "entity_type": "Individual", + "rates": [ + { + "from_date": "2023-04-01", + "to_date": "2024-03-31", + "tax_withholding_rate": 10, + "single_threshold": 180000, + "cumulative_threshold": 0 + }, + { + "from_date": "2024-04-01", + "to_date": "2025-03-31", + "tax_withholding_rate": 10, + "single_threshold": 240000, + "cumulative_threshold": 0 + } + ] + }, + { + "name": "TDS - 194I(b) - No PAN / Invalid PAN", + "category_name": "Rent on land / building / furniture / fitting", + "round_off_tax_amount": 0, + "tds_section": "194I(b)", + "consider_party_ledger_amount": 0, + "tax_on_excess_amount": 0, + "entity_type": "No PAN / Invalid PAN", + "rates": [ + { + "from_date": "2023-04-01", + "to_date": "2024-03-31", + "tax_withholding_rate": 20, + "single_threshold": 180000, + "cumulative_threshold": 0 + }, + { + "from_date": "2024-04-01", + "to_date": "2025-03-31", + "tax_withholding_rate": 20, + "single_threshold": 240000, + "cumulative_threshold": 0 + } + ] + }, + { + "name": "TDS - 194JB - Company", + "category_name": "Professional Fees", + "round_off_tax_amount": 0, + "tds_section": "194JB", + "consider_party_ledger_amount": 0, + "tax_on_excess_amount": 0, + "entity_type": "Company", + "rates": [ + { + "from_date": "2023-04-01", + "to_date": "2024-03-31", + "tax_withholding_rate": 10, + "single_threshold": 30000, + "cumulative_threshold": 0 + }, + { + "from_date": "2024-04-01", + "to_date": "2025-03-31", + "tax_withholding_rate": 10, + "single_threshold": 30000, + "cumulative_threshold": 0 + } + ] + }, + { + "name": "TDS - 194JB - Individual", + "category_name": "Professional Fees", + "round_off_tax_amount": 0, + "tds_section": "194JB", + "consider_party_ledger_amount": 0, + "tax_on_excess_amount": 0, + "entity_type": "Individual", + "rates": [ + { + "from_date": "2023-04-01", + "to_date": "2024-03-31", + "tax_withholding_rate": 10, + "single_threshold": 30000, + "cumulative_threshold": 0 + }, + { + "from_date": "2024-04-01", + "to_date": "2025-03-31", + "tax_withholding_rate": 10, + "single_threshold": 30000, + "cumulative_threshold": 0 + } + ] + }, + { + "name": "TDS - 194JB - No PAN / Invalid PAN", + "category_name": "Professional Fees", + "round_off_tax_amount": 0, + "tds_section": "194JB", + "consider_party_ledger_amount": 0, + "tax_on_excess_amount": 0, + "entity_type": "No PAN / Invalid PAN", + "rates": [ + { + "from_date": "2023-04-01", + "to_date": "2024-03-31", + "tax_withholding_rate": 20, + "single_threshold": 30000, + "cumulative_threshold": 0 + }, + { + "from_date": "2024-04-01", + "to_date": "2025-03-31", + "tax_withholding_rate": 20, + "single_threshold": 30000, + "cumulative_threshold": 0 + } + ] + }, + { + "name": "TDS - 194JA - Company", + "category_name": "Technical Fees", + "round_off_tax_amount": 0, + "tds_section": "194JA", + "consider_party_ledger_amount": 0, + "tax_on_excess_amount": 0, + "entity_type": "Company", + "rates": [ + { + "from_date": "2023-04-01", + "to_date": "2024-03-31", + "tax_withholding_rate": 2, + "single_threshold": 30000, + "cumulative_threshold": 0 + }, + { + "from_date": "2024-04-01", + "to_date": "2025-03-31", + "tax_withholding_rate": 2, + "single_threshold": 30000, + "cumulative_threshold": 0 + } + ] + }, + { + "name": "TDS - 194JA - Individual", + "category_name": "Technical Fees", + "round_off_tax_amount": 0, + "tds_section": "194JA", + "consider_party_ledger_amount": 0, + "tax_on_excess_amount": 0, + "entity_type": "Individual", + "rates": [ + { + "from_date": "2023-04-01", + "to_date": "2024-03-31", + "tax_withholding_rate": 2, + "single_threshold": 30000, + "cumulative_threshold": 0 + }, + { + "from_date": "2024-04-01", + "to_date": "2025-03-31", + "tax_withholding_rate": 2, + "single_threshold": 30000, + "cumulative_threshold": 0 + } + ] + }, + { + "name": "TDS - 194JA - No PAN / Invalid PAN", + "category_name": "Technical Fees", + "round_off_tax_amount": 0, + "tds_section": "194JA", + "consider_party_ledger_amount": 0, + "tax_on_excess_amount": 0, + "entity_type": "No PAN / Invalid PAN", + "rates": [ + { + "from_date": "2023-04-01", + "to_date": "2024-03-31", + "tax_withholding_rate": 20, + "single_threshold": 30000, + "cumulative_threshold": 0 + }, + { + "from_date": "2024-04-01", + "to_date": "2025-03-31", + "tax_withholding_rate": 20, + "single_threshold": 30000, + "cumulative_threshold": 0 + } + ] + }, + { + "name": "TDS - 194 - Company", + "category_name": "Dividends", + "round_off_tax_amount": 0, + "tds_section": "194", + "consider_party_ledger_amount": 0, + "tax_on_excess_amount": 0, + "entity_type": "Company", + "rates": [ + { + "from_date": "2023-04-01", + "to_date": "2024-03-31", + "tax_withholding_rate": 10, + "single_threshold": 2500, + "cumulative_threshold": 0 + }, + { + "from_date": "2024-04-01", + "to_date": "2025-03-31", + "tax_withholding_rate": 10, + "single_threshold": 5000, + "cumulative_threshold": 0 + } + ] + }, + { + "name": "TDS - 194 - Individual", + "category_name": "Dividends", + "round_off_tax_amount": 0, + "tds_section": "194", + "consider_party_ledger_amount": 0, + "tax_on_excess_amount": 0, + "entity_type": "Individual", + "rates": [ + { + "from_date": "2023-04-01", + "to_date": "2024-03-31", + "tax_withholding_rate": 10, + "single_threshold": 2500, + "cumulative_threshold": 0 + }, + { + "from_date": "2024-04-01", + "to_date": "2025-03-31", + "tax_withholding_rate": 10, + "single_threshold": 5000, + "cumulative_threshold": 0 + }, + { + "from_date": "2025-04-01", + "to_date": "2026-03-31", + "tax_withholding_rate": 10, + "single_threshold": 5000, + "cumulative_threshold": 0 + } + ] + }, + { + "name": "TDS - 194 - No PAN / Invalid PAN", + "category_name": "Dividends", + "round_off_tax_amount": 0, + "tds_section": "194", + "consider_party_ledger_amount": 0, + "tax_on_excess_amount": 0, + "entity_type": "No PAN / Invalid PAN", + "rates": [ + { + "from_date": "2023-04-01", + "to_date": "2024-03-31", + "tax_withholding_rate": 20, + "single_threshold": 2500, + "cumulative_threshold": 0 + }, + { + "from_date": "2024-04-01", + "to_date": "2025-03-31", + "tax_withholding_rate": 20, + "single_threshold": 5000, + "cumulative_threshold": 0 + } + ] + }, + { + "name": "TDS - 193 - Company", + "category_name": "Interest on Securities", + "round_off_tax_amount": 0, + "tds_section": "193", + "consider_party_ledger_amount": 0, + "tax_on_excess_amount": 0, + "entity_type": "Company", + "rates": [ + { + "from_date": "2024-04-01", + "to_date": "2025-03-31", + "tax_withholding_rate": 10, + "single_threshold": 10000, + "cumulative_threshold": 0 + } + ] + }, + { + "name": "TDS - 193 - Individual", + "category_name": "Interest on Securities", + "round_off_tax_amount": 0, + "tds_section": "193", + "consider_party_ledger_amount": 0, + "tax_on_excess_amount": 0, + "entity_type": "Individual", + "rates": [ + { + "from_date": "2024-04-01", + "to_date": "2025-03-31", + "tax_withholding_rate": 10, + "single_threshold": 10000, + "cumulative_threshold": 0 + } + ] + }, + { + "name": "TDS - 193 - No PAN / Invalid PAN", + "category_name": "Interest on Securities", + "round_off_tax_amount": 0, + "tds_section": "193", + "consider_party_ledger_amount": 0, + "tax_on_excess_amount": 0, + "entity_type": "No PAN / Invalid PAN", + "rates": [ + { + "from_date": "2024-04-01", + "to_date": "2025-03-31", + "tax_withholding_rate": 30, + "single_threshold": 10000, + "cumulative_threshold": 0 + } + ] + }, + { + "name": "TDS - 194BB - Company", + "category_name": "Income from horse race winnings", + "round_off_tax_amount": 0, + "tds_section": "194BB", + "consider_party_ledger_amount": 0, + "tax_on_excess_amount": 0, + "entity_type": "Company", + "rates": [ + { + "from_date": "2024-04-01", + "to_date": "2025-03-31", + "tax_withholding_rate": 30, + "single_threshold": 0, + "cumulative_threshold": 10000 + } + ] + }, + { + "name": "TDS - 194BB - Individual", + "category_name": "Income from horse race winnings", + "round_off_tax_amount": 0, + "tds_section": "194BB", + "consider_party_ledger_amount": 0, + "tax_on_excess_amount": 0, + "entity_type": "Individual", + "rates": [ + { + "from_date": "2024-04-01", + "to_date": "2025-03-31", + "tax_withholding_rate": 30, + "single_threshold": 0, + "cumulative_threshold": 10000 + } + ] + }, + { + "name": "TDS - 194BB - No PAN / Invalid PAN", + "category_name": "Income from horse race winnings", + "round_off_tax_amount": 0, + "tds_section": "194BB", + "consider_party_ledger_amount": 0, + "tax_on_excess_amount": 0, + "entity_type": "No PAN / Invalid PAN", + "rates": [ + { + "from_date": "2024-04-01", + "to_date": "2025-03-31", + "tax_withholding_rate": 30, + "single_threshold": 0, + "cumulative_threshold": 10000 + } + ] + }, + { + "name": "TDS - 194EE - Company", + "category_name": "Payment of amount standing to the credit of a person under National Savings Scheme (NSS)", + "round_off_tax_amount": 0, + "tds_section": "194EE", + "consider_party_ledger_amount": 0, + "tax_on_excess_amount": 0, + "entity_type": "Company", + "rates": [ + { + "from_date": "2024-04-01", + "to_date": "2025-03-31", + "tax_withholding_rate": 10, + "single_threshold": 2500, + "cumulative_threshold": 0 + } + ] + }, + { + "name": "TDS - 194EE - Individual", + "category_name": "Payment of amount standing to the credit of a person under National Savings Scheme (NSS)", + "round_off_tax_amount": 0, + "tds_section": "194EE", + "consider_party_ledger_amount": 0, + "tax_on_excess_amount": 0, + "entity_type": "Individual", + "rates": [ + { + "from_date": "2024-04-01", + "to_date": "2025-03-31", + "tax_withholding_rate": 10, + "single_threshold": 2500, + "cumulative_threshold": 0 + } + ] + }, + { + "name": "TDS - 194EE - No PAN / Invalid PAN", + "category_name": "Payment of amount standing to the credit of a person under National Savings Scheme (NSS)", + "round_off_tax_amount": 0, + "tds_section": "194EE", + "consider_party_ledger_amount": 0, + "tax_on_excess_amount": 0, + "entity_type": "No PAN / Invalid PAN", + "rates": [ + { + "from_date": "2024-04-01", + "to_date": "2025-03-31", + "tax_withholding_rate": 20, + "single_threshold": 2500, + "cumulative_threshold": 0 + } + ] + }, + { + "name": "TDS - 194A - Company", + "category_name": "Interest from other than interest on securities", + "round_off_tax_amount": 0, + "tds_section": "194A", + "consider_party_ledger_amount": 0, + "tax_on_excess_amount": 0, + "entity_type": "Company", + "rates": [ + { + "from_date": "2024-04-01", + "to_date": "2025-03-31", + "tax_withholding_rate": 10, + "single_threshold": 5000, + "cumulative_threshold": 0 + } + ] + }, + { + "name": "TDS - 194A - Individual", + "category_name": "Interest from other than interest on securities", + "round_off_tax_amount": 0, + "tds_section": "194A", + "consider_party_ledger_amount": 0, + "tax_on_excess_amount": 0, + "entity_type": "Individual", + "rates": [ + { + "from_date": "2024-04-01", + "to_date": "2025-03-31", + "tax_withholding_rate": 10, + "single_threshold": 5000, + "cumulative_threshold": 0 + } + ] + }, + { + "name": "TDS - 194A - No PAN / Invalid PAN", + "category_name": "Interest from other than interest on securities", + "round_off_tax_amount": 0, + "tds_section": "194A", + "consider_party_ledger_amount": 0, + "tax_on_excess_amount": 0, + "entity_type": "No PAN / Invalid PAN", + "rates": [ + { + "from_date": "2024-04-01", + "to_date": "2025-03-31", + "tax_withholding_rate": 20, + "single_threshold": 5000, + "cumulative_threshold": 0 + } + ] + }, + { + "name": "TDS - 194B - Company", + "category_name": "Income from lottery winnings, card games, crossword puzzles, and other games of any type", + "round_off_tax_amount": 0, + "tds_section": "194B", + "consider_party_ledger_amount": 0, + "tax_on_excess_amount": 0, + "entity_type": "Company", + "rates": [ + { + "from_date": "2024-04-01", + "to_date": "2025-03-31", + "tax_withholding_rate": 30, + "single_threshold": 0, + "cumulative_threshold": 10000 + } + ] + }, + { + "name": "TDS - 194B - Individual", + "category_name": "Income from lottery winnings, card games, crossword puzzles, and other games of any type", + "round_off_tax_amount": 0, + "tds_section": "194B", + "consider_party_ledger_amount": 0, + "tax_on_excess_amount": 0, + "entity_type": "Individual", + "rates": [ + { + "from_date": "2024-04-01", + "to_date": "2025-03-31", + "tax_withholding_rate": 30, + "single_threshold": 0, + "cumulative_threshold": 10000 + } + ] + }, + { + "name": "TDS - 194B - No PAN / Invalid PAN", + "category_name": "Income from lottery winnings, card games, crossword puzzles, and other games of any type", + "round_off_tax_amount": 0, + "tds_section": "194B", + "consider_party_ledger_amount": 0, + "tax_on_excess_amount": 0, + "entity_type": "No PAN / Invalid PAN", + "rates": [ + { + "from_date": "2024-04-01", + "to_date": "2025-03-31", + "tax_withholding_rate": 30, + "single_threshold": 0, + "cumulative_threshold": 10000 + } + ] + }, + { + "name": "TDS - 194F - Company", + "category_name": "Payment for the repurchase of the unit by Unit Trust of India (UTI) or a Mutual Fund", + "round_off_tax_amount": 0, + "tds_section": "194F", + "consider_party_ledger_amount": 0, + "tax_on_excess_amount": 0, + "entity_type": "Company", + "rates": [ + { + "from_date": "2024-04-01", + "to_date": "2025-03-31", + "tax_withholding_rate": 20, + "single_threshold": 0, + "cumulative_threshold": 0 + } + ] + }, + { + "name": "TDS - 194F - Individual", + "category_name": "Payment for the repurchase of the unit by Unit Trust of India (UTI) or a Mutual Fund", + "round_off_tax_amount": 0, + "tds_section": "194F", + "consider_party_ledger_amount": 0, + "tax_on_excess_amount": 0, + "entity_type": "Individual", + "rates": [ + { + "from_date": "2024-04-01", + "to_date": "2025-03-31", + "tax_withholding_rate": 20, + "single_threshold": 0, + "cumulative_threshold": 0 + } + ] + }, + { + "name": "TDS - 194F - No PAN / Invalid PAN", + "category_name": "Payment for the repurchase of the unit by Unit Trust of India (UTI) or a Mutual Fund", + "round_off_tax_amount": 0, + "tds_section": "194F", + "consider_party_ledger_amount": 0, + "tax_on_excess_amount": 0, + "entity_type": "No PAN / Invalid PAN", + "rates": [ + { + "from_date": "2024-04-01", + "to_date": "2025-03-31", + "tax_withholding_rate": 20, + "single_threshold": 0, + "cumulative_threshold": 0 + } + ] + }, + { + "name": "TDS - 194G - Company", + "category_name": "Payments or commission on sale of lottery tickets", + "round_off_tax_amount": 0, + "tds_section": "194G", + "consider_party_ledger_amount": 0, + "tax_on_excess_amount": 0, + "entity_type": "Company", + "rates": [ + { + "from_date": "2023-04-01", + "to_date": "2024-03-31", + "tax_withholding_rate": 5, + "single_threshold": 15000, + "cumulative_threshold": 0 + } + ] + }, + { + "name": "TDS - 194G - Individual", + "category_name": "Payments or commission on sale of lottery tickets", + "round_off_tax_amount": 0, + "tds_section": "194G", + "consider_party_ledger_amount": 0, + "tax_on_excess_amount": 0, + "entity_type": "Individual", + "rates": [ + { + "from_date": "2023-04-01", + "to_date": "2024-03-31", + "tax_withholding_rate": 5, + "single_threshold": 15000, + "cumulative_threshold": 0 + } + ] + }, + { + "name": "TDS - 194G - No PAN / Invalid PAN", + "category_name": "Payments or commission on sale of lottery tickets", + "round_off_tax_amount": 0, + "tds_section": "194G", + "consider_party_ledger_amount": 0, + "tax_on_excess_amount": 0, + "entity_type": "No PAN / Invalid PAN", + "rates": [ + { + "from_date": "2023-04-01", + "to_date": "2024-03-31", + "tax_withholding_rate": 20, + "single_threshold": 15000, + "cumulative_threshold": 0 + } + ] + }, + { + "name": "TDS - 194LA - Company", + "category_name": "Payment in respect of compensation on acquiring certain immovable property", + "round_off_tax_amount": 0, + "tds_section": "194LA", + "consider_party_ledger_amount": 0, + "tax_on_excess_amount": 0, + "entity_type": "Company", + "rates": [ + { + "from_date": "2024-04-01", + "to_date": "2025-03-31", + "tax_withholding_rate": 10, + "single_threshold": 250000, + "cumulative_threshold": 0 + } + ] + }, + { + "name": "TDS - 194LA - Individual", + "category_name": "Payment in respect of compensation on acquiring certain immovable property", + "round_off_tax_amount": 0, + "tds_section": "194LA", + "consider_party_ledger_amount": 0, + "tax_on_excess_amount": 0, + "entity_type": "Individual", + "rates": [ + { + "from_date": "2024-04-01", + "to_date": "2025-03-31", + "tax_withholding_rate": 10, + "single_threshold": 250000, + "cumulative_threshold": 0 + } + ] + }, + { + "name": "TDS - 194LA - No PAN / Invalid PAN", + "category_name": "Payment in respect of compensation on acquiring certain immovable property", + "round_off_tax_amount": 0, + "tds_section": "194LA", + "consider_party_ledger_amount": 0, + "tax_on_excess_amount": 0, + "entity_type": "No PAN / Invalid PAN", + "rates": [ + { + "from_date": "2024-04-01", + "to_date": "2025-03-31", + "tax_withholding_rate": 20, + "single_threshold": 250000, + "cumulative_threshold": 0 + } + ] + }, + { + "name": "TDS - 192A - Company", + "category_name": "Premature EPF withdrawal", + "round_off_tax_amount": 0, + "tds_section": "192A", + "consider_party_ledger_amount": 0, + "tax_on_excess_amount": 0, + "entity_type": "Company", + "rates": [ + { + "from_date": "2024-04-01", + "to_date": "2025-03-31", + "tax_withholding_rate": 10, + "single_threshold": 50000, + "cumulative_threshold": 0 + } + ] + }, + { + "name": "TDS - 192A - Individual", + "category_name": "Premature EPF withdrawal", + "round_off_tax_amount": 0, + "tds_section": "192A", + "consider_party_ledger_amount": 0, + "tax_on_excess_amount": 0, + "entity_type": "Individual", + "rates": [ + { + "from_date": "2024-04-01", + "to_date": "2025-03-31", + "tax_withholding_rate": 10, + "single_threshold": 50000, + "cumulative_threshold": 0 + } + ] + }, + { + "name": "TDS - 192A - No PAN / Invalid PAN", + "category_name": "Premature EPF withdrawal", + "round_off_tax_amount": 0, + "tds_section": "192A", + "consider_party_ledger_amount": 0, + "tax_on_excess_amount": 0, + "entity_type": "No PAN / Invalid PAN", + "rates": [ + { + "from_date": "2024-04-01", + "to_date": "2025-03-31", + "tax_withholding_rate": 20, + "single_threshold": 50000, + "cumulative_threshold": 0 + } + ] + }, + { + "name": "TDS - 194LBB - Company", + "category_name": "Payment to a unitholder in respect of units of an investment fund", + "round_off_tax_amount": 0, + "tds_section": "194LBB", + "consider_party_ledger_amount": 0, + "tax_on_excess_amount": 0, + "entity_type": "Company", + "rates": [ + { + "from_date": "2024-04-01", + "to_date": "2025-03-31", + "tax_withholding_rate": 10, + "single_threshold": 0, + "cumulative_threshold": 0 + } + ] + }, + { + "name": "TDS - 194LBB - Individual", + "category_name": "Payment to a unitholder in respect of units of an investment fund", + "round_off_tax_amount": 0, + "tds_section": "194LBB", + "consider_party_ledger_amount": 0, + "tax_on_excess_amount": 0, + "entity_type": "Individual", + "rates": [ + { + "from_date": "2024-04-01", + "to_date": "2025-03-31", + "tax_withholding_rate": 10, + "single_threshold": 0, + "cumulative_threshold": 0 + } + ] + }, + { + "name": "TDS - 194LBB - No PAN / Invalid PAN", + "category_name": "Payment to a unitholder in respect of units of an investment fund", + "round_off_tax_amount": 0, + "tds_section": "194LBB", + "consider_party_ledger_amount": 0, + "tax_on_excess_amount": 0, + "entity_type": "No PAN / Invalid PAN", + "rates": [ + { + "from_date": "2024-04-01", + "to_date": "2025-03-31", + "tax_withholding_rate": 20, + "single_threshold": 0, + "cumulative_threshold": 0 + } + ] + }, + { + "name": "TDS - 194IA - Company", + "category_name": "Payment for transfer of immovable property other than agricultural land", + "round_off_tax_amount": 0, + "tds_section": "194IA", + "consider_party_ledger_amount": 0, + "tax_on_excess_amount": 0, + "entity_type": "Company", + "rates": [ + { + "from_date": "2024-04-01", + "to_date": "2025-03-31", + "tax_withholding_rate": 1, + "single_threshold": 5000000, + "cumulative_threshold": 0 + } + ] + }, + { + "name": "TDS - 194IA - Individual", + "category_name": "Payment for transfer of immovable property other than agricultural land", + "round_off_tax_amount": 0, + "tds_section": "194IA", + "consider_party_ledger_amount": 0, + "tax_on_excess_amount": 0, + "entity_type": "Individual", + "rates": [ + { + "from_date": "2024-04-01", + "to_date": "2025-03-31", + "tax_withholding_rate": 1, + "single_threshold": 5000000, + "cumulative_threshold": 0 + } + ] + }, + { + "name": "TDS - 194IA - No PAN / Invalid PAN", + "category_name": "Payment for transfer of immovable property other than agricultural land", + "round_off_tax_amount": 0, + "tds_section": "194IA", + "consider_party_ledger_amount": 0, + "tax_on_excess_amount": 0, + "entity_type": "No PAN / Invalid PAN", + "rates": [ + { + "from_date": "2024-04-01", + "to_date": "2025-03-31", + "tax_withholding_rate": 20, + "single_threshold": 5000000, + "cumulative_threshold": 0 + } + ] + } +] diff --git a/india_compliance/income_tax_india/overrides/company.py b/india_compliance/income_tax_india/overrides/company.py index 9ee38c9e8..0c96d3ba0 100644 --- a/india_compliance/income_tax_india/overrides/company.py +++ b/india_compliance/income_tax_india/overrides/company.py @@ -16,7 +16,7 @@ def create_company_fixtures(company): create_tds_account(company) # create records for Tax Withholding Category - set_tax_withholding_category(company) + create_or_update_tax_withholding_category(company) def create_tds_account(company): @@ -25,7 +25,7 @@ def create_tds_account(company): ) -def set_tax_withholding_category(company): +def create_or_update_tax_withholding_category(company): accounts = [] abbr = frappe.get_value("Company", company, "abbr") tds_account = frappe.get_value("Account", "TDS Payable - {0}".format(abbr), "name") @@ -33,79 +33,94 @@ def set_tax_withholding_category(company): if company and tds_account: accounts.append({"company": company, "account": tds_account}) - fiscal_year_details = get_current_fiscal_year() - docs = get_tds_details(accounts, fiscal_year_details) + categories = get_tds_category_details(accounts) + + for category_doc in categories: + existing_category_name = frappe.get_value( + "Tax Withholding Category", + { + "tds_section": category_doc.get("tds_section"), + "entity_type": category_doc.get("entity_type"), + }, + ) + + if not existing_category_name: + doc = frappe.get_doc(category_doc) + doc.insert(ignore_if_duplicate=True) - for d in docs: - if not frappe.db.exists("Tax Withholding Category", d.get("name")): - doc = frappe.get_doc(d) - doc.flags.ignore_validate = True - doc.flags.ignore_permissions = True - doc.flags.ignore_mandatory = True - doc.insert() else: - doc = frappe.get_doc( - "Tax Withholding Category", d.get("name"), for_update=True + update_existing_tax_withholding_category( + category_doc, existing_category_name, company ) - if accounts: - doc.append("accounts", accounts[0]) - - # if fiscal year doesn't match with any of the already entered data, - # append rate row - if not next( - ( - row - for row in doc.get("rates") - if row.get("from_date") <= fiscal_year_details[0] - and row.get("to_date") >= fiscal_year_details[1] - ), - None, - ): - doc.append("rates", d.get("rates")[0]) - doc.flags.ignore_permissions = True - doc.flags.ignore_validate = True - doc.flags.ignore_mandatory = True - doc.flags.ignore_links = True - doc.save() +def update_existing_tax_withholding_category(category_doc, category_name, company): + doc = frappe.get_doc("Tax Withholding Category", category_name) + + # add company account if not present for the category + for row in doc.get("accounts"): + if row.company == company: + break + + else: + accounts = category_doc.get("accounts") + if accounts: + doc.append("accounts", accounts[0]) + + # add rates if not present for the dates + largest_date = None + for doc_row in doc.get("rates"): + if not largest_date: + largest_date = getdate(doc_row.get("to_date")) + + if getdate(doc_row.get("to_date")) > largest_date: + largest_date = getdate(doc_row.get("to_date")) + for cat_row in category_doc["rates"]: + if largest_date and getdate(cat_row.get("from_date")) < largest_date: + continue -def get_tds_details(accounts, fiscal_year_details): + doc.append("rates", cat_row) + + doc.save() + + +def get_tds_category_details(accounts): tds_details = [] tds_rules = frappe.get_file_json( frappe.get_app_path( "india_compliance", "income_tax_india", "data", "tds_details.json" ) ) + for rule in tds_rules: + tds_details.append( + { + "name": rule.get("name"), + "category_name": rule.get("category_name"), + "doctype": "Tax Withholding Category", + "accounts": accounts, + "tds_section": rule.get("tds_section"), + "entity_type": rule.get("entity_type"), + "round_off_tax_amount": rule.get("round_off_tax_amount"), + "consider_party_ledger_amount": rule.get( + "consider_party_ledger_amount" + ), + "tax_on_excess_amount": rule.get("tax_on_excess_amount"), + "rates": get_prospective_tds_rates(rule["rates"]), + } + ) - for category in tds_rules: - for rule in tds_rules[category]: - tds_details.append( - { - "name": rule[0], - "category_name": category, - "doctype": "Tax Withholding Category", - "accounts": accounts, - "rates": [ - { - "from_date": fiscal_year_details[0], - "to_date": fiscal_year_details[1], - "tax_withholding_rate": rule[1], - "single_threshold": rule[2], - "cumulative_threshold": rule[3], - } - ], - } - ) return tds_details -def get_current_fiscal_year(): +def get_prospective_tds_rates(rates): + """ + Ensure TDS rules are not created for the historical rates + """ + rate_list = [] today = getdate() - start_date_year = today.year if today.month >= 4 else today.year - 1 + for row in rates: + if today <= getdate(row["to_date"]): + rate_list.append(row) - return ( - getdate(f"{start_date_year}-04-01"), - getdate(f"{start_date_year + 1}-03-31"), - ) + return rate_list diff --git a/india_compliance/income_tax_india/overrides/tax_withholding_category.py b/india_compliance/income_tax_india/overrides/tax_withholding_category.py index 536c5573e..52b1c25cb 100644 --- a/india_compliance/income_tax_india/overrides/tax_withholding_category.py +++ b/india_compliance/income_tax_india/overrides/tax_withholding_category.py @@ -1,4 +1,5 @@ import frappe +from frappe.utils import get_link_to_form def on_change(doc, method=None): @@ -16,3 +17,24 @@ 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}.' + ) diff --git a/india_compliance/income_tax_india/setup.py b/india_compliance/income_tax_india/setup.py index 3ca11115c..840bd03ad 100644 --- a/india_compliance/income_tax_india/setup.py +++ b/india_compliance/income_tax_india/setup.py @@ -1,7 +1,13 @@ -from frappe.custom.doctype.custom_field.custom_field import create_custom_fields +from frappe.custom.doctype.custom_field.custom_field import ( + create_custom_fields as _create_custom_fields, +) from india_compliance.income_tax_india.constants.custom_fields import CUSTOM_FIELDS def after_install(): - create_custom_fields(CUSTOM_FIELDS, ignore_validate=True) + create_custom_fields() + + +def create_custom_fields(): + _create_custom_fields(CUSTOM_FIELDS, ignore_validate=True) diff --git a/india_compliance/patches.txt b/india_compliance/patches.txt index 17b3c2139..b386c447d 100644 --- a/india_compliance/patches.txt +++ b/india_compliance/patches.txt @@ -5,6 +5,7 @@ execute:import frappe; frappe.delete_doc_if_exists("DocType", "GSTIN") india_compliance.patches.v14.set_default_for_overridden_accounts_setting execute:from india_compliance.gst_india.setup import create_custom_fields; create_custom_fields() #43 execute:from india_compliance.gst_india.setup import create_property_setters; create_property_setters() #7 +execute:from india_compliance.income_tax_india.setup import create_custom_fields; create_custom_fields() india_compliance.patches.post_install.remove_old_fields #1 india_compliance.patches.post_install.update_company_gstin india_compliance.patches.post_install.update_custom_role_for_e_invoice_summary @@ -31,7 +32,7 @@ execute:import frappe; frappe.db.set_single_value("GST Settings", "gstin_status_ execute:from india_compliance.gst_india.setup import create_email_template; create_email_template() india_compliance.patches.post_install.update_payment_entry_fields india_compliance.patches.v15.remove_ignore_reconciliation_field -india_compliance.patches.post_install.update_company_fixtures #1 +india_compliance.patches.post_install.update_company_fixtures #2 india_compliance.patches.post_install.update_itc_classification_field india_compliance.patches.v14.update_purchase_reco_email_template india_compliance.patches.v14.delete_purchase_receipt_standard_custom_fields diff --git a/india_compliance/patches/post_install/update_company_fixtures.py b/india_compliance/patches/post_install/update_company_fixtures.py index 7e7dd2753..f13c56516 100644 --- a/india_compliance/patches/post_install/update_company_fixtures.py +++ b/india_compliance/patches/post_install/update_company_fixtures.py @@ -1,4 +1,5 @@ import frappe +from frappe.query_builder.functions import IfNull from erpnext.setup.setup_wizard.operations.taxes_setup import get_or_create_tax_group from india_compliance.gst_india.overrides.company import ( @@ -6,6 +7,7 @@ make_default_gst_expense_accounts, make_default_tax_templates, ) +from india_compliance.income_tax_india.constants import TDS_ENTITY_TYPE, TDS_SECTIONS from india_compliance.income_tax_india.overrides.company import ( create_company_fixtures as create_income_tax_fixtures, ) @@ -15,12 +17,12 @@ def execute(): company_list = frappe.get_all( "Company", filters={"country": "India"}, pluck="name", order_by="lft asc" ) + set_section_and_entity_type_in_tax_withholding_category() # execute before creating fixtures + for company in company_list: # Income Tax fixtures - if not frappe.db.exists( - "Account", {"company": company, "account_name": "TDS Payable"} - ): - create_income_tax_fixtures(company) + + create_income_tax_fixtures(company) # GST fixtures update_root_for_rcm(company) @@ -70,3 +72,29 @@ def update_root_for_rcm(company): output_account, update_modified=False, ) + + +def set_section_and_entity_type_in_tax_withholding_category(): + doctype = frappe.qb.DocType("Tax Withholding Category") + categories = ( + frappe.qb.from_(doctype) + .select(doctype.name) + .where(IfNull(doctype.tds_section, "") == "") + .where(IfNull(doctype.entity_type, "") == "") + .run(pluck=True) + ) + + for category_name in categories: + splitted_name = category_name.split(" - ") + # old naming [TDS - SECTION - ENTITY] + if len(splitted_name) < 3: + continue + + if splitted_name[1] in TDS_SECTIONS and splitted_name[-1] in TDS_ENTITY_TYPE: + ( + frappe.qb.update(doctype) + .set("tds_section", splitted_name[1]) + .set("entity_type", splitted_name[-1]) + .where(doctype.name == category_name) + .run() + )