From 35b3bc4e719cb0fa7504bb2cb737b78a0cfe0d6e Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Wed, 1 Sep 2021 10:11:18 +0530 Subject: [PATCH] fix: Linting and patch fixes (cherry picked from commit b6d0b17ed6930b43157c51c0e0fec8457881f7bb) # Conflicts: # erpnext/accounts/doctype/tax_withholding_category/tax_withholding_category.py # erpnext/patches/v13_0/update_dates_in_tax_withholding_category.py --- .../tax_withholding_category.py | 4 ++++ ...pdate_dates_in_tax_withholding_category.py | 23 +++++++++++++------ 2 files changed, 20 insertions(+), 7 deletions(-) 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 44e12a7331e..78af9b58ecd 100644 --- a/erpnext/accounts/doctype/tax_withholding_category/tax_withholding_category.py +++ b/erpnext/accounts/doctype/tax_withholding_category/tax_withholding_category.py @@ -24,6 +24,7 @@ class TaxWithholdingCategory(Document): frappe.throw(_("Row #{0}: From Date cannot be before To Date").format(d.idx)) # validate overlapping of dates +<<<<<<< HEAD <<<<<<< HEAD if last_date and getdate(d.to_date) < getdate(last_date): frappe.throw(_("Row #{0}: Dates overlapping with other row").format(d.idx)) @@ -41,6 +42,9 @@ class TaxWithholdingCategory(Document): ======= if last_date and getdate(r.to_date) < getdate(last_date): +======= + if last_date and getdate(d.to_date) < getdate(last_date): +>>>>>>> b6d0b17ed6 (fix: Linting and patch fixes) frappe.throw(_("Row #{0}: Dates overlapping with other row").format(d.idx)) def validate_thresholds(self): diff --git a/erpnext/patches/v13_0/update_dates_in_tax_withholding_category.py b/erpnext/patches/v13_0/update_dates_in_tax_withholding_category.py index a0dcd60935d..dc8bb9359dd 100644 --- a/erpnext/patches/v13_0/update_dates_in_tax_withholding_category.py +++ b/erpnext/patches/v13_0/update_dates_in_tax_withholding_category.py @@ -31,18 +31,27 @@ from erpnext.accounts.utils import get_fiscal_year 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) +<<<<<<< HEAD frappe.db.set_value('Tax Withholding Rate', rate.name, { 'from_date': from_date, 'to_date': to_date }) >>>>>>> 5e10e10329 (feat: Validity dates in Tax Withholding Rates) +======= + 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 + }) +>>>>>>> b6d0b17ed6 (fix: Linting and patch fixes)