Skip to content

Commit

Permalink
fix: rectify and add more info to Leave Ledger validation message
Browse files Browse the repository at this point in the history
(cherry picked from commit 0504c74)
  • Loading branch information
ruchamahabal authored and mergify[bot] committed Jan 10, 2025
1 parent 233024d commit 17e1546
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions hrms/hr/doctype/leave_ledger_entry/leave_ledger_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,26 @@
import frappe
from frappe import _
from frappe.model.document import Document
from frappe.utils import DATE_FORMAT, flt, get_link_to_form, getdate, today
from frappe.utils import DATE_FORMAT, flt, formatdate, get_link_to_form, getdate, today


class InvalidLeaveLedgerEntry(frappe.ValidationError):
pass


class LeaveLedgerEntry(Document):
def validate(self):
if getdate(self.from_date) > getdate(self.to_date):
frappe.throw(_("To date needs to be before from date"))
frappe.throw(
_(
"Leave Ledger Entry's To date needs to be after From date. Currently, From Date is {0} and To Date is {1}"
).format(
frappe.bold(formatdate(self.from_date)),
frappe.bold(formatdate(self.to_date)),
),
exc=InvalidLeaveLedgerEntry,
title=_("Invalid Leave Ledger Entry"),
)

def on_cancel(self):
# allow cancellation of expiry leaves
Expand Down

0 comments on commit 17e1546

Please sign in to comment.