From 7733afc0ae7e5e3a67b8e498a282ac5fb54afabf Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Thu, 21 Oct 2021 16:13:00 +0530 Subject: [PATCH] fix(minor): Filters and fixes in Tax Withholding Category --- .../tax_withholding_category/tax_withholding_category.js | 3 ++- .../tax_withholding_category/tax_withholding_category.py | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/tax_withholding_category/tax_withholding_category.js b/erpnext/accounts/doctype/tax_withholding_category/tax_withholding_category.js index b8d6c9af3a..7b47974946 100644 --- a/erpnext/accounts/doctype/tax_withholding_category/tax_withholding_category.js +++ b/erpnext/accounts/doctype/tax_withholding_category/tax_withholding_category.js @@ -8,7 +8,8 @@ frappe.ui.form.on('Tax Withholding Category', { if (child.company) { return { filters: { - 'company': child.company + 'company': child.company, + 'root_type': ['in', ['Asset', 'Liability']] } }; } 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 c3cb8396d0..c36f3cb201 100644 --- a/erpnext/accounts/doctype/tax_withholding_category/tax_withholding_category.py +++ b/erpnext/accounts/doctype/tax_withholding_category/tax_withholding_category.py @@ -13,6 +13,7 @@ from frappe.utils import cint, getdate class TaxWithholdingCategory(Document): def validate(self): self.validate_dates() + self.validate_accounts() self.validate_thresholds() def validate_dates(self): @@ -25,6 +26,14 @@ class TaxWithholdingCategory(Document): if last_date and getdate(d.to_date) < getdate(last_date): frappe.throw(_("Row #{0}: Dates overlapping with other row").format(d.idx)) + def validate_accounts(self): + existing_accounts = [] + for d in self.get('accounts'): + if d.get('account') in existing_accounts: + frappe.throw(_("Account {0} added multiple times").format(frappe.bold(d.get('account')))) + + existing_accounts.append(d.get('account')) + def validate_thresholds(self): for d in self.get('rates'): if d.cumulative_threshold and d.cumulative_threshold < d.single_threshold: