brotherton-erpnext/erpnext/patches/v14_0/update_employee_advance_status.py
2022-03-28 18:52:46 +05:30

30 lines
680 B
Python

import frappe
def execute():
frappe.reload_doc("hr", "doctype", "employee_advance")
advance = frappe.qb.DocType("Employee Advance")
(
frappe.qb.update(advance)
.set(advance.status, "Returned")
.where(
(advance.docstatus == 1)
& ((advance.return_amount) & (advance.paid_amount == advance.return_amount))
& (advance.status == "Paid")
)
).run()
(
frappe.qb.update(advance)
.set(advance.status, "Partly Claimed and Returned")
.where(
(advance.docstatus == 1)
& (
(advance.claimed_amount & advance.return_amount)
& (advance.paid_amount == (advance.return_amount + advance.claimed_amount))
)
& (advance.status == "Paid")
)
).run()