Add IsProbatin property to GetProfileByKeycloakIdDto and update leave request logic for probationary users #2266
This commit is contained in:
parent
970319e8c2
commit
358fd47b99
3 changed files with 43 additions and 24 deletions
|
|
@ -44,6 +44,8 @@ namespace BMA.EHR.Application.Responses.Profiles
|
||||||
public string? ProfileType { get; set; }
|
public string? ProfileType { get; set; }
|
||||||
public bool? IsLeave { get; set; }
|
public bool? IsLeave { get; set; }
|
||||||
|
|
||||||
|
public bool? IsProbatin { get; set; }
|
||||||
|
|
||||||
public string? Root { get; set; }
|
public string? Root { get; set; }
|
||||||
public string? Child1 { get; set; }
|
public string? Child1 { get; set; }
|
||||||
public string? Child2 { get; set; }
|
public string? Child2 { get; set; }
|
||||||
|
|
|
||||||
|
|
@ -926,9 +926,17 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdNewAsync(userId, data.Token);
|
var profile = await _userProfileRepository.GetProfileByKeycloakIdNewAsync(userId, data.Token);
|
||||||
|
|
||||||
if (profile == null)
|
if (profile == null)
|
||||||
|
{
|
||||||
|
await _checkInJobStatusRepository.UpdateToFailedAsync(taskId, "ไม่พบข้อมูลผู้ใช้");
|
||||||
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
||||||
|
}
|
||||||
|
|
||||||
if (data.CheckInFileName == "no-file") throw new Exception(GlobalMessages.NoFileToUpload);
|
if (data.CheckInFileName == "no-file")
|
||||||
|
{
|
||||||
|
//throw new Exception(GlobalMessages.NoFileToUpload);
|
||||||
|
await _checkInJobStatusRepository.UpdateToFailedAsync(taskId, GlobalMessages.NoFileToUpload);
|
||||||
|
return Error(GlobalMessages.NoFileToUpload, StatusCodes.Status400BadRequest);
|
||||||
|
}
|
||||||
var currentDate = data.CurrentDate ?? DateTime.Now;
|
var currentDate = data.CurrentDate ?? DateTime.Now;
|
||||||
|
|
||||||
var check_status = data.CheckInId == null ? "check-in-picture" : "check-out-picture";
|
var check_status = data.CheckInId == null ? "check-in-picture" : "check-out-picture";
|
||||||
|
|
@ -970,6 +978,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
|
|
||||||
if (currentCheckIn != null)
|
if (currentCheckIn != null)
|
||||||
{
|
{
|
||||||
|
await _checkInJobStatusRepository.UpdateToFailedAsync(taskId, "ไม่สามารถลงเวลาได้ เนื่องจากมีการลงเวลาในวันนี้แล้ว");
|
||||||
return Error(new Exception("ไม่สามารถลงเวลาได้ เนื่องจากมีการลงเวลาในวันนี้แล้ว!"), StatusCodes.Status400BadRequest);
|
return Error(new Exception("ไม่สามารถลงเวลาได้ เนื่องจากมีการลงเวลาในวันนี้แล้ว!"), StatusCodes.Status400BadRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1105,30 +1114,34 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
{
|
{
|
||||||
var checkout = await _userTimeStampRepository.GetByIdAsync(data.CheckInId.Value);
|
var checkout = await _userTimeStampRepository.GetByIdAsync(data.CheckInId.Value);
|
||||||
|
|
||||||
var currentCheckInProcess = await _processUserTimeStampRepository.GetTimestampByDateAsync(userId, checkout.CheckIn.Date);
|
if (checkout == null)
|
||||||
|
|
||||||
var checkout_process = await _processUserTimeStampRepository.GetByIdAsync(currentCheckInProcess.Id);
|
|
||||||
|
|
||||||
|
|
||||||
if (checkout != null)
|
|
||||||
{
|
|
||||||
checkout.CheckOutLat = data.Lat;
|
|
||||||
checkout.CheckOutLon = data.Lon;
|
|
||||||
checkout.IsLocationCheckOut = data.IsLocation;
|
|
||||||
checkout.CheckOutLocationName = data.LocationName;
|
|
||||||
checkout.CheckOutPOI = data.POI;
|
|
||||||
checkout.CheckOutRemark = data.Remark;
|
|
||||||
checkout.CheckOutImageUrl = fileName;
|
|
||||||
checkout.CheckOut = currentDate;
|
|
||||||
|
|
||||||
await _userTimeStampRepository.UpdateAsync(checkout);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
await _checkInJobStatusRepository.UpdateToFailedAsync(taskId, "ไม่พบข้อมูลการลงเวลาทำงาน");
|
await _checkInJobStatusRepository.UpdateToFailedAsync(taskId, "ไม่พบข้อมูลการลงเวลาทำงาน");
|
||||||
return Error(new Exception(GlobalMessages.DataNotFound), StatusCodes.Status404NotFound);
|
return Error(new Exception(GlobalMessages.DataNotFound), StatusCodes.Status404NotFound);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var currentCheckInProcess = await _processUserTimeStampRepository.GetTimestampByDateAsync(userId, checkout.CheckIn.Date);
|
||||||
|
|
||||||
|
if (currentCheckInProcess == null)
|
||||||
|
{
|
||||||
|
await _checkInJobStatusRepository.UpdateToFailedAsync(taskId, "ไม่พบข้อมูลการประมวลผลเวลาทำงาน (CheckIn)");
|
||||||
|
return Error(new Exception(GlobalMessages.DataNotFound), StatusCodes.Status404NotFound);
|
||||||
|
}
|
||||||
|
|
||||||
|
var checkout_process = await _processUserTimeStampRepository.GetByIdAsync(currentCheckInProcess.Id);
|
||||||
|
|
||||||
|
// Update checkout record
|
||||||
|
checkout.CheckOutLat = data.Lat;
|
||||||
|
checkout.CheckOutLon = data.Lon;
|
||||||
|
checkout.IsLocationCheckOut = data.IsLocation;
|
||||||
|
checkout.CheckOutLocationName = data.LocationName;
|
||||||
|
checkout.CheckOutPOI = data.POI;
|
||||||
|
checkout.CheckOutRemark = data.Remark;
|
||||||
|
checkout.CheckOutImageUrl = fileName;
|
||||||
|
checkout.CheckOut = currentDate;
|
||||||
|
|
||||||
|
await _userTimeStampRepository.UpdateAsync(checkout);
|
||||||
|
|
||||||
var endTime = "";
|
var endTime = "";
|
||||||
var startTime = "";
|
var startTime = "";
|
||||||
var endTimeMorning = "";
|
var endTimeMorning = "";
|
||||||
|
|
@ -1289,7 +1302,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
{
|
{
|
||||||
await _checkInJobStatusRepository.UpdateToFailedAsync(taskId, ex.Message);
|
await _checkInJobStatusRepository.UpdateToFailedAsync(taskId, ex.Message);
|
||||||
}
|
}
|
||||||
throw;
|
return Error(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1084,8 +1084,12 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
// fix issue : ระบบลา (ขรก.) >> ลาพักผ่อน (กรณีรับราชการไม่ถึง 6 เดือน) #838
|
// fix issue : ระบบลา (ขรก.) >> ลาพักผ่อน (กรณีรับราชการไม่ถึง 6 เดือน) #838
|
||||||
//var leavePrevYear = (await _leaveRequestRepository.GetSumApproveLeaveAsync(fiscalYear - 1)).Where(x => x.LeaveTypeCode == "LV-005" && x.KeycloakUserId == userId).FirstOrDefault();
|
//var leavePrevYear = (await _leaveRequestRepository.GetSumApproveLeaveAsync(fiscalYear - 1)).Where(x => x.LeaveTypeCode == "LV-005" && x.KeycloakUserId == userId).FirstOrDefault();
|
||||||
//var leavePrevYearRemain = 10 - (leavePrevYear == null ? 0 : leavePrevYear.SumLeaveDay); // หายอดวันลาที่เหลือของปีก่อน
|
//var leavePrevYearRemain = 10 - (leavePrevYear == null ? 0 : leavePrevYear.SumLeaveDay); // หายอดวันลาที่เหลือของปีก่อน
|
||||||
|
if (profile.IsProbatin! == true)
|
||||||
if (govAge >= 180)
|
{
|
||||||
|
isLeave = false;
|
||||||
|
if (!isLeave) message = "ยังอยู่ในช่วงทดลองปฏิบัติราชการ ไม่สามารถลาพักผ่อนได้";
|
||||||
|
}
|
||||||
|
else if (govAge >= 180)
|
||||||
{
|
{
|
||||||
isLeave = (totalDay - (sumWorkDay + sumWeekend) + approveDay) <= (limitDay);
|
isLeave = (totalDay - (sumWorkDay + sumWeekend) + approveDay) <= (limitDay);
|
||||||
if (!isLeave) message = "จำนวนวันลาเกินที่กำหนด";
|
if (!isLeave) message = "จำนวนวันลาเกินที่กำหนด";
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue