From 1999b7a6c5cdff5432644d8f63069e7b62887fb7 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Fri, 3 May 2024 11:47:43 +0530 Subject: [PATCH] fix: Do not deduct TCS for opening invoices (cherry picked from commit eb9f579b8f1493c6b4822258f6addc575fa4deca) --- erpnext/accounts/doctype/sales_invoice/sales_invoice.py | 3 +++ .../tax_withholding_category/tax_withholding_category.py | 3 +++ 2 files changed, 6 insertions(+) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index abdfcaeb512..63f13ae251f 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -388,6 +388,9 @@ class SalesInvoice(SellingController): validate_account_head(item.idx, item.income_account, self.company, "Income") def set_tax_withholding(self): + if self.get("is_opening") == "Yes": + return + tax_withholding_details = get_party_tax_withholding_details(self) if not tax_withholding_details: diff --git a/erpnext/accounts/doctype/tax_withholding_category/tax_withholding_category.py b/erpnext/accounts/doctype/tax_withholding_category/tax_withholding_category.py index a9a4090a02c..44096714ca7 100644 --- a/erpnext/accounts/doctype/tax_withholding_category/tax_withholding_category.py +++ b/erpnext/accounts/doctype/tax_withholding_category/tax_withholding_category.py @@ -9,6 +9,8 @@ from frappe.query_builder import Criterion from frappe.query_builder.functions import Abs, Sum from frappe.utils import cint, flt, getdate +from erpnext.controllers.accounts_controller import validate_account_head + class TaxWithholdingCategory(Document): # begin: auto-generated types @@ -53,6 +55,7 @@ class TaxWithholdingCategory(Document): if d.get("account") in existing_accounts: frappe.throw(_("Account {0} added multiple times").format(frappe.bold(d.get("account")))) + validate_account_head(d.idx, d.get("account"), d.get("company")) existing_accounts.append(d.get("account")) def validate_thresholds(self):