Refactor checkout status logic in LeaveController for improved clarity and handling of check-in dates
All checks were successful
Build & Deploy Leave Service / build (push) Successful in 1m46s

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

View file

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