2022-01-18 09:06:38 +00:00
|
|
|
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))
|
2022-03-28 13:22:46 +00:00
|
|
|
)
|
2022-01-18 09:06:38 +00:00
|
|
|
& (advance.status == "Paid")
|
|
|
|
)
|
|
|
|
).run()
|