From 973ef33eb5ba0e173978a9c7452bb0861b272077 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Wed, 14 Dec 2022 20:41:00 +0530 Subject: [PATCH 1/2] fix: Cost Center for tax withholding invoices --- .../tax_withholding_category.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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 30ed91b974..a9d870da74 100644 --- a/erpnext/accounts/doctype/tax_withholding_category/tax_withholding_category.py +++ b/erpnext/accounts/doctype/tax_withholding_category/tax_withholding_category.py @@ -121,12 +121,24 @@ def get_party_tax_withholding_details(inv, tax_withholding_category=None): else: tax_row = get_tax_row_for_tcs(inv, tax_details, tax_amount, tax_deducted) + cost_center = get_cost_center(inv) + tax_row.update({"cost_center": cost_center}) + if inv.doctype == "Purchase Invoice": return tax_row, tax_deducted_on_advances, voucher_wise_amount else: return tax_row +def get_cost_center(inv): + cost_center = frappe.get_cached_value("Company", inv.company, "cost_center") + + if len(inv.get("taxes")) > 0: + cost_center = inv.get("taxes")[0].cost_center + + return cost_center + + def get_tax_withholding_details(tax_withholding_category, posting_date, company): tax_withholding = frappe.get_doc("Tax Withholding Category", tax_withholding_category) From 26277cfcf3e7bbb6b14ceb42ee77e740f2825f20 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Wed, 14 Dec 2022 21:22:48 +0530 Subject: [PATCH 2/2] chore: resolve errors in test --- .../tax_withholding_category/tax_withholding_category.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 a9d870da74..b834d1404d 100644 --- a/erpnext/accounts/doctype/tax_withholding_category/tax_withholding_category.py +++ b/erpnext/accounts/doctype/tax_withholding_category/tax_withholding_category.py @@ -133,7 +133,7 @@ def get_party_tax_withholding_details(inv, tax_withholding_category=None): def get_cost_center(inv): cost_center = frappe.get_cached_value("Company", inv.company, "cost_center") - if len(inv.get("taxes")) > 0: + if len(inv.get("taxes", [])) > 0: cost_center = inv.get("taxes")[0].cost_center return cost_center