brotherton-erpnext/erpnext/patches/v14_0/update_partial_tds_fields.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

46 lines
1.4 KiB
Python
Raw Normal View History

2022-10-19 09:03:02 +00:00
import frappe
2022-11-03 19:33:45 +00:00
from frappe.utils import nowdate
2022-10-19 09:03:02 +00:00
2022-11-04 02:41:38 +00:00
from erpnext.accounts.utils import FiscalYearError, get_fiscal_year
2022-10-28 14:48:55 +00:00
2022-10-19 09:03:02 +00:00
def execute():
2022-10-28 14:48:55 +00:00
# Only do for current fiscal year, no need to repost for all years
for company in frappe.get_all("Company"):
2022-11-04 02:41:38 +00:00
try:
fiscal_year_details = get_fiscal_year(date=nowdate(), company=company.name, as_dict=True)
2022-10-28 14:48:55 +00:00
2022-11-04 02:41:38 +00:00
purchase_invoice = frappe.qb.DocType("Purchase Invoice")
2022-10-19 09:03:02 +00:00
2022-11-04 02:41:38 +00:00
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()
purchase_order = frappe.qb.DocType("Purchase Order")
frappe.qb.update(purchase_order).set(
purchase_order.tax_withholding_net_total, purchase_order.net_total
).set(
purchase_order.base_tax_withholding_net_total, purchase_order.base_net_total
).where(
purchase_order.company == company.name
).where(
purchase_order.apply_tds == 1
).where(
purchase_order.transaction_date >= fiscal_year_details.year_start_date
).where(
purchase_order.docstatus == 1
).run()
2022-11-04 02:41:38 +00:00
except FiscalYearError:
pass