fix(minor): Filters and fixes in Tax Withholding Category
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 b8d6c9a..7b47974 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 @@
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 c3cb839..c36f3cb 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 @@
class TaxWithholdingCategory(Document):
def validate(self):
self.validate_dates()
+ self.validate_accounts()
self.validate_thresholds()
def validate_dates(self):
@@ -25,6 +26,14 @@
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: