1010 add_days ,
1111 cint ,
1212 cstr ,
13- formatdate ,
13+ format_date ,
1414 get_datetime ,
1515 get_link_to_form ,
1616 getdate ,
@@ -53,9 +53,19 @@ def validate_attendance_date(self):
5353 and not self .leave_application
5454 and getdate (self .attendance_date ) > getdate (nowdate ())
5555 ):
56- frappe .throw (_ ("Attendance can not be marked for future dates" ))
56+ frappe .throw (
57+ _ ("Attendance can not be marked for future dates: {0}" ).format (
58+ frappe .bold (format_date (self .attendance_date )),
59+ )
60+ )
5761 elif date_of_joining and getdate (self .attendance_date ) < getdate (date_of_joining ):
58- frappe .throw (_ ("Attendance date can not be less than employee's joining date" ))
62+ frappe .throw (
63+ _ ("Attendance date {0} can not be less than employee {1}'s joining date: {2}" ).format (
64+ frappe .bold (format_date (self .attendance_date )),
65+ frappe .bold (self .employee ),
66+ frappe .bold (format_date (date_of_joining )),
67+ )
68+ )
5969
6070 def validate_duplicate_record (self ):
6171 duplicate = get_duplicate_attendance_record (
@@ -66,7 +76,7 @@ def validate_duplicate_record(self):
6676 frappe .throw (
6777 _ ("Attendance for employee {0} is already marked for the date {1}: {2}" ).format (
6878 frappe .bold (self .employee ),
69- frappe .bold (self .attendance_date ),
79+ frappe .bold (format_date ( self .attendance_date ) ),
7080 get_link_to_form ("Attendance" , duplicate [0 ].name ),
7181 ),
7282 title = _ ("Duplicate Attendance" ),
@@ -112,19 +122,19 @@ def check_leave_record(self):
112122 if d .half_day_date == getdate (self .attendance_date ):
113123 self .status = "Half Day"
114124 frappe .msgprint (
115- _ ("Employee {0} on Half day on {1}" ).format (self .employee , formatdate (self .attendance_date ))
125+ _ ("Employee {0} on Half day on {1}" ).format (self .employee , format_date (self .attendance_date ))
116126 )
117127 else :
118128 self .status = "On Leave"
119129 frappe .msgprint (
120- _ ("Employee {0} is on Leave on {1}" ).format (self .employee , formatdate (self .attendance_date ))
130+ _ ("Employee {0} is on Leave on {1}" ).format (self .employee , format_date (self .attendance_date ))
121131 )
122132
123133 if self .status in ("On Leave" , "Half Day" ):
124134 if not leave_record :
125135 frappe .msgprint (
126136 _ ("No leave record found for employee {0} on {1}" ).format (
127- self .employee , formatdate (self .attendance_date )
137+ self .employee , format_date (self .attendance_date )
128138 ),
129139 alert = 1 ,
130140 )
0 commit comments