Refactor check-out status logic to improve clarity and handle edge cases for same-day and next-day check-outs
This commit is contained in:
parent
1a0e712a1c
commit
19000b2e42
1 changed files with 78 additions and 24 deletions
|
|
@ -1158,35 +1158,89 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// fix issue : SIT ระบบบันทึกเวลาปฏิบัติงาน>>ลงเวลาเข้า-ออกงาน (กรณีลงเวลาออกอีกวัน) #921
|
// fix issue : SIT ระบบบันทึกเวลาปฏิบัติงาน>>ลงเวลาเข้า-ออกงาน (กรณีลงเวลาออกอีกวัน) #921
|
||||||
checkOutStatus = DateTime.Parse(currentDate.ToString("yyyy-MM-dd HH:mm")) <
|
var currentDateTime = DateTime.Parse(currentDate.ToString("yyyy-MM-dd HH:mm"));
|
||||||
DateTime.Parse($"{currentDate.ToString("yyyy-MM-dd")} {duty.EndTimeAfternoon}") ?
|
var dutyEndTimeAfternoon = DateTime.Parse($"{checkout.CheckIn.ToString("yyyy-MM-dd")} {endTime}");
|
||||||
// "ABSENT" :
|
var dutyEndTimeMorning = DateTime.Parse($"{checkout.CheckIn.ToString("yyyy-MM-dd")} {endTimeMorning}");
|
||||||
checkout.CheckIn.Date < currentDate.Date ? "NORMAL" :
|
|
||||||
DateTime.Parse(currentDate.ToString("yyyy-MM-dd HH:mm")) >=
|
|
||||||
DateTime.Parse($"{currentDate.ToString("yyyy-MM-dd")} {endTime}") ?
|
if(currentDateTime.Date > checkout.CheckIn.Date)
|
||||||
"NORMAL" :
|
{
|
||||||
"ABSENT" :
|
// ถ้า check-out เป็นวันถัดไป สถานะปกติเสมอ
|
||||||
DateTime.Parse(currentDate.ToString("yyyy-MM-dd HH:mm")) <
|
checkOutStatus = "NORMAL";
|
||||||
DateTime.Parse($"{currentDate.ToString("yyyy-MM-dd")} {endTimeMorning}") ?
|
}
|
||||||
"ABSENT" :
|
else
|
||||||
"NORMAL";
|
{
|
||||||
|
// ถ้า check-out เป็นวันเดียวกับ check-in
|
||||||
|
// ตรวจสอบเวลาว่าสิ้นสุดก่อนบ่ายหรือไม่
|
||||||
|
if(currentDateTime < dutyEndTimeMorning) // ถ้าออกก่อนเวลาสิ้นสุดตอนเช้า ขาดราชการ
|
||||||
|
{
|
||||||
|
checkOutStatus = "ABSENT";
|
||||||
|
}
|
||||||
|
else if(currentDateTime >= dutyEndTimeAfternoon) // ถ้าออกหลังเวลาสิ้นสุดตอนบ่าย ปกติ
|
||||||
|
{
|
||||||
|
checkOutStatus = "NORMAL";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
checkOutStatus = "ABSENT";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// checkOutStatus = DateTime.Parse(currentDate.ToString("yyyy-MM-dd HH:mm")) <
|
||||||
|
// DateTime.Parse($"{checkout.CheckIn.ToString("yyyy-MM-dd")} {duty.EndTimeAfternoon}") ?
|
||||||
|
// // "ABSENT" :
|
||||||
|
// checkout.CheckIn.Date < currentDate.Date ? "NORMAL" :
|
||||||
|
// DateTime.Parse(currentDate.ToString("yyyy-MM-dd HH:mm")) >=
|
||||||
|
// DateTime.Parse($"{checkout.CheckIn.ToString("yyyy-MM-dd")} {endTime}") ?
|
||||||
|
// "NORMAL" :
|
||||||
|
// "ABSENT" :
|
||||||
|
// DateTime.Parse(currentDate.ToString("yyyy-MM-dd HH:mm")) <
|
||||||
|
// DateTime.Parse($"{currentDate.ToString("yyyy-MM-dd")} {endTimeMorning}") ?
|
||||||
|
// "ABSENT" :
|
||||||
|
// "NORMAL";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// fix issue : SIT ระบบบันทึกเวลาปฏิบัติงาน>>ลงเวลาเข้า-ออกงาน (กรณีลงเวลาออกอีกวัน) #921
|
// fix issue : SIT ระบบบันทึกเวลาปฏิบัติงาน>>ลงเวลาเข้า-ออกงาน (กรณีลงเวลาออกอีกวัน) #921
|
||||||
checkOutStatus = DateTime.Parse(currentDate.ToString("yyyy-MM-dd HH:mm")) <
|
var currentDateTime = DateTime.Parse(currentDate.ToString("yyyy-MM-dd HH:mm"));
|
||||||
DateTime.Parse($"{currentDate.ToString("yyyy-MM-dd")} {duty.EndTimeAfternoon}") ?
|
var dutyEndTimeAfternoon = DateTime.Parse($"{checkout.CheckIn.ToString("yyyy-MM-dd")} {endTime}");
|
||||||
// "ABSENT" :
|
var dutyEndTimeMorning = DateTime.Parse($"{checkout.CheckIn.ToString("yyyy-MM-dd")} {endTimeMorning}");
|
||||||
checkout.CheckIn.Date < currentDate.Date ? "NORMAL" :
|
|
||||||
DateTime.Parse(currentDate.ToString("yyyy-MM-dd HH:mm")) >=
|
|
||||||
DateTime.Parse($"{currentDate.ToString("yyyy-MM-dd")} {endTime}") ?
|
if(currentDateTime.Date > checkout.CheckIn.Date)
|
||||||
"NORMAL" :
|
{
|
||||||
"ABSENT" :
|
// ถ้า check-out เป็นวันถัดไป สถานะปกติเสมอ
|
||||||
DateTime.Parse(currentDate.ToString("yyyy-MM-dd HH:mm")) <
|
checkOutStatus = "NORMAL";
|
||||||
DateTime.Parse($"{currentDate.ToString("yyyy-MM-dd")} {endTimeMorning}") ?
|
}
|
||||||
"ABSENT" :
|
else
|
||||||
"NORMAL";
|
{
|
||||||
|
// ถ้า check-out เป็นวันเดียวกับ check-in
|
||||||
|
// ตรวจสอบเวลาว่าสิ้นสุดก่อนบ่ายหรือไม่
|
||||||
|
if(currentDateTime < dutyEndTimeMorning) // ถ้าออกก่อนเวลาสิ้นสุดตอนเช้า ขาดราชการ
|
||||||
|
{
|
||||||
|
checkOutStatus = "ABSENT";
|
||||||
|
}
|
||||||
|
else if(currentDateTime >= dutyEndTimeAfternoon) // ถ้าออกหลังเวลาสิ้นสุดตอนบ่าย ปกติ
|
||||||
|
{
|
||||||
|
checkOutStatus = "NORMAL";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
checkOutStatus = "ABSENT";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// checkOutStatus = DateTime.Parse(currentDate.ToString("yyyy-MM-dd HH:mm")) <
|
||||||
|
// 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")} {endTimeMorning}") ?
|
||||||
|
// "ABSENT" :
|
||||||
|
// "NORMAL";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (checkout_process != null)
|
if (checkout_process != null)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue