From f6a61b999f5edfd19c79206159cdeda6e03b3bfc Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Fri, 4 Nov 2022 08:11:38 +0530 Subject: [PATCH] chore: fix patch --- erpnext/patches/v14_0/update_tds_fields.py | 35 ++++++++++++---------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/erpnext/patches/v14_0/update_tds_fields.py b/erpnext/patches/v14_0/update_tds_fields.py index fd33d5450d..a333c5d7a5 100644 --- a/erpnext/patches/v14_0/update_tds_fields.py +++ b/erpnext/patches/v14_0/update_tds_fields.py @@ -1,26 +1,29 @@ import frappe from frappe.utils import nowdate -from erpnext.accounts.utils import get_fiscal_year +from erpnext.accounts.utils import FiscalYearError, get_fiscal_year def execute(): # Only do for current fiscal year, no need to repost for all years for company in frappe.get_all("Company"): - fiscal_year_details = get_fiscal_year(date=nowdate(), company=company.name, as_dict=True) + try: + fiscal_year_details = get_fiscal_year(date=nowdate(), company=company.name, as_dict=True) - purchase_invoice = frappe.qb.DocType("Purchase Invoice") + purchase_invoice = frappe.qb.DocType("Purchase Invoice") - frappe.qb.update(purchase_invoice).set( - purchase_invoice.tax_withholding_net_total, purchase_invoice.net_total - ).set( - purchase_invoice.base_tax_withholding_net_total, purchase_invoice.base_net_total - ).where( - purchase_invoice.company == company.name - ).where( - purchase_invoice.apply_tds == 1 - ).where( - purchase_invoice.posting_date >= fiscal_year_details.year_start_date - ).where( - purchase_invoice.docstatus == 1 - ).run() + frappe.qb.update(purchase_invoice).set( + purchase_invoice.tax_withholding_net_total, purchase_invoice.net_total + ).set( + purchase_invoice.base_tax_withholding_net_total, purchase_invoice.base_net_total + ).where( + purchase_invoice.company == company.name + ).where( + purchase_invoice.apply_tds == 1 + ).where( + purchase_invoice.posting_date >= fiscal_year_details.year_start_date + ).where( + purchase_invoice.docstatus == 1 + ).run() + except FiscalYearError: + pass