refactor LeaveController to update start and end time logic for check-in and check-out #2199
This commit is contained in:
parent
5415019b3c
commit
3a6e4501fd
1 changed files with 17 additions and 5 deletions
|
|
@ -872,7 +872,8 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
var startTime = "";
|
||||
if (!data.IsLocation && data.LocationName == "ไปประชุม / อบรม / สัมมนา")
|
||||
{
|
||||
startTime = "09:30";
|
||||
//startTime = "09:30";
|
||||
startTime = "10:30";
|
||||
}
|
||||
else
|
||||
startTime = duty.StartTimeMorning;
|
||||
|
|
@ -888,7 +889,6 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
{
|
||||
checkInStatus = DateTime.Parse(currentDate.ToString("yyyy-MM-dd HH:mm")) >
|
||||
DateTime.Parse($"{currentDate.ToString("yyyy-MM-dd")} {startTime}") ?
|
||||
|
||||
DateTime.Parse(currentDate.ToString("yyyy-MM-dd HH:mm")) >
|
||||
DateTime.Parse($"{currentDate.ToString("yyyy-MM-dd")} {duty.EndTimeMorning}") ?
|
||||
"ABSENT" :
|
||||
|
|
@ -900,7 +900,6 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
{
|
||||
checkInStatus = DateTime.Parse(currentDate.ToString("yyyy-MM-dd HH:mm")) >
|
||||
DateTime.Parse($"{currentDate.ToString("yyyy-MM-dd")} {startTime}") ?
|
||||
|
||||
DateTime.Parse(currentDate.ToString("yyyy-MM-dd HH:mm")) >
|
||||
DateTime.Parse($"{currentDate.ToString("yyyy-MM-dd")} {duty.EndTimeMorning}") ?
|
||||
"ABSENT" :
|
||||
|
|
@ -956,8 +955,6 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
}
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
var checkout = await _userTimeStampRepository.GetByIdAsync(data.CheckInId.Value);
|
||||
|
||||
var currentCheckInProcess = await _processUserTimeStampRepository.GetTimestampByDateAsync(userId, checkout.CheckIn.Date);
|
||||
|
|
@ -983,6 +980,15 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
return Error(new Exception(GlobalMessages.DataNotFound), StatusCodes.Status404NotFound);
|
||||
}
|
||||
|
||||
var endTime = "";
|
||||
if (!data.IsLocation && data.LocationName == "ไปประชุม / อบรม / สัมมนา")
|
||||
{
|
||||
//startTime = "09:30";
|
||||
endTime = "14:30";
|
||||
}
|
||||
else
|
||||
endTime = duty.EndTimeAfternoon;
|
||||
|
||||
string checkOutStatus = "NORMAL";
|
||||
var leaveReq = await _leaveRequestRepository.GetLeavePeriodAsync(userId, currentDate.Date);
|
||||
if (leaveReq != null)
|
||||
|
|
@ -997,6 +1003,9 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
DateTime.Parse($"{currentDate.ToString("yyyy-MM-dd")} {duty.EndTimeAfternoon}") ?
|
||||
// "ABSENT" :
|
||||
checkout.CheckIn.Date < currentDate.Date ? "NORMAL" :
|
||||
DateTime.Parse(currentDate.ToString("yyyy-MM-dd HH:mm")) >=
|
||||
DateTime.Parse($"{currentDate.ToString("yyyy-MM-dd")} {endTime}") ?
|
||||
"NORMAL" :
|
||||
"ABSENT" :
|
||||
DateTime.Parse(currentDate.ToString("yyyy-MM-dd HH:mm")) <
|
||||
DateTime.Parse($"{currentDate.ToString("yyyy-MM-dd")} {duty.EndTimeMorning}") ?
|
||||
|
|
@ -1011,6 +1020,9 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
DateTime.Parse($"{currentDate.ToString("yyyy-MM-dd")} {duty.EndTimeAfternoon}") ?
|
||||
// "ABSENT" :
|
||||
checkout.CheckIn.Date < currentDate.Date ? "NORMAL" :
|
||||
DateTime.Parse(currentDate.ToString("yyyy-MM-dd HH:mm")) >=
|
||||
DateTime.Parse($"{currentDate.ToString("yyyy-MM-dd")} {endTime}") ?
|
||||
"NORMAL" :
|
||||
"ABSENT" :
|
||||
DateTime.Parse(currentDate.ToString("yyyy-MM-dd HH:mm")) <
|
||||
DateTime.Parse($"{currentDate.ToString("yyyy-MM-dd")} {duty.EndTimeMorning}") ?
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue