Refactor checkout status logic in LeaveController for improved clarity and handling of check-in dates

This commit is contained in:
Suphonchai Phoonsawat 2026-03-27 09:48:10 +07:00
parent 3e3bfff7ba
commit bba6573ea8

View file

@ -1412,11 +1412,20 @@ namespace BMA.EHR.Leave.Service.Controllers
var leaveRange = leaveReq.LeaveRangeEnd == null ? "" : leaveReq.LeaveRangeEnd.ToUpper(); var leaveRange = leaveReq.LeaveRangeEnd == null ? "" : leaveReq.LeaveRangeEnd.ToUpper();
if (leaveRange == "AFTERNOON" || leaveRange == "ALL") if (leaveRange == "AFTERNOON" || leaveRange == "ALL")
{ {
if(DateTime.Parse(currentDate.ToString("yyyy-MM-dd HH:mm")) < if (checkout.CheckIn.Date < currentDate.Date)
DateTime.Parse($"{currentDate.ToString("yyyy-MM-dd")} {endTimeMorning}")) {
checkOutStatus = "ABSENT"; // ถ้า check-out เป็นวันถัดไป สถานะปกติเสมอ
else
checkOutStatus = "NORMAL"; checkOutStatus = "NORMAL";
}
else
{
if(DateTime.Parse(currentDate.ToString("yyyy-MM-dd HH:mm")) <
DateTime.Parse($"{currentDate.ToString("yyyy-MM-dd")} {endTimeMorning}"))
checkOutStatus = "ABSENT";
else
checkOutStatus = "NORMAL";
}
} }
else else
{ {