|
@ -6,17 +6,19 @@ from erpnext.accounts.utils import get_fiscal_year |
|
|
|
|
|
|
|
|
def execute(): |
|
|
def execute(): |
|
|
frappe.reload_doc('accounts', 'doctype', 'Tax Withholding Rate') |
|
|
frappe.reload_doc('accounts', 'doctype', 'Tax Withholding Rate') |
|
|
tds_category_rates = frappe.get_all('Tax Withholding Rate', fields=['name', 'fiscal_year']) |
|
|
|
|
|
|
|
|
|
|
|
fiscal_year_map = {} |
|
|
if frappe.db.has_column('Tax Withholding Rate', 'fiscal_year'): |
|
|
for rate in tds_category_rates: |
|
|
tds_category_rates = frappe.get_all('Tax Withholding Rate', fields=['name', 'fiscal_year']) |
|
|
if not fiscal_year_map.get(rate.fiscal_year): |
|
|
|
|
|
fiscal_year_map[rate.fiscal_year] = get_fiscal_year(fiscal_year=rate.fiscal_year) |
|
|
|
|
|
|
|
|
|
|
|
from_date = fiscal_year_map.get(rate.fiscal_year)[1] |
|
|
fiscal_year_map = {} |
|
|
to_date = fiscal_year_map.get(rate.fiscal_year)[2] |
|
|
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 = fiscal_year_map.get(rate.fiscal_year)[1] |
|
|
'from_date': from_date, |
|
|
to_date = fiscal_year_map.get(rate.fiscal_year)[2] |
|
|
'to_date': to_date |
|
|
|
|
|
}) |
|
|
frappe.db.set_value('Tax Withholding Rate', rate.name, { |
|
|
|
|
|
'from_date': from_date, |
|
|
|
|
|
'to_date': to_date |
|
|
|
|
|
}) |