Skip to content

Commit

Permalink
Merge pull request #28054 from deepeshgarg007/tax_withholding_categor…
Browse files Browse the repository at this point in the history
…y_filters

fix(minor): Filters and validations in Tax Withholding Category
  • Loading branch information
deepeshgarg007 authored Oct 26, 2021
2 parents 0c28b47 + 7733afc commit a87c201
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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']]
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
class TaxWithholdingCategory(Document):
def validate(self):
self.validate_dates()
self.validate_accounts()
self.validate_thresholds()

def validate_dates(self):
Expand All @@ -25,6 +26,14 @@ def validate_dates(self):
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:
Expand Down

0 comments on commit a87c201

Please sign in to comment.