Skip to content

Commit

Permalink
fix: Linting and patch fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
deepeshgarg007 committed Sep 14, 2021
1 parent 5c9f2bf commit e8edeec
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def validate_dates(self):
frappe.throw(_("Row #{0}: From Date cannot be before To Date").format(d.idx))

# validate overlapping of dates
if last_date and getdate(r.to_date) < getdate(last_date):
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_thresholds(self):
Expand Down
24 changes: 13 additions & 11 deletions erpnext/patches/v13_0/update_dates_in_tax_withholding_category.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,19 @@

def execute():
frappe.reload_doc('accounts', 'doctype', 'Tax Withholding Rate')
tds_category_rates = frappe.get_all('Tax Withholding Rate', fields=['name', 'fiscal_year'])

fiscal_year_map = {}
for rate in tds_category_rates:
if not fiscal_year_map.get(rate.fiscal_year):
fiscal_year_map[rate.fiscal_year] = get_fiscal_year(fiscal_year=rate.fiscal_year)
if frappe.db.has_column('Tax Withholding Rate', 'fiscal_year'):
tds_category_rates = frappe.get_all('Tax Withholding Rate', fields=['name', 'fiscal_year'])

from_date = fiscal_year_map.get(rate.fiscal_year)[1]
to_date = fiscal_year_map.get(rate.fiscal_year)[2]
fiscal_year_map = {}
for rate in tds_category_rates:
if not fiscal_year_map.get(rate.fiscal_year):
fiscal_year_map[rate.fiscal_year] = get_fiscal_year(fiscal_year=rate.fiscal_year)

frappe.db.set_value('Tax Withholding Rate', rate.name, {
'from_date': from_date,
'to_date': to_date
})
from_date = fiscal_year_map.get(rate.fiscal_year)[1]
to_date = fiscal_year_map.get(rate.fiscal_year)[2]

frappe.db.set_value('Tax Withholding Rate', rate.name, {
'from_date': from_date,
'to_date': to_date
})

0 comments on commit e8edeec

Please sign in to comment.