From 44acce75106977ab2711e6174c0748b7e5c7e6e9 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Mon, 13 Jan 2025 11:49:30 +0530 Subject: [PATCH] fix: create single leave ledger encashment entry for carry forwarding leave type (backport #2614) (#2627) Co-authored-by: Asmita Hase <44727809+asmitahase@users.noreply.github.com> --- hrms/hr/doctype/leave_encashment/leave_encashment.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hrms/hr/doctype/leave_encashment/leave_encashment.py b/hrms/hr/doctype/leave_encashment/leave_encashment.py index b32f9ebd67..66481f6bea 100644 --- a/hrms/hr/doctype/leave_encashment/leave_encashment.py +++ b/hrms/hr/doctype/leave_encashment/leave_encashment.py @@ -204,7 +204,9 @@ def create_leave_ledger_entry(self, submit=True): return to_date = leave_allocation.get("to_date") - if to_date < getdate(): + + can_expire = not frappe.db.get_value("Leave Type", self.leave_type, "is_carry_forward") + if to_date < getdate() and can_expire: args = frappe._dict( leaves=self.encashment_days, from_date=to_date, to_date=to_date, is_carry_forward=0 )