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 bool? IsLeave { get; set; }
|
||||
|
||||
public bool? IsProbatin { get; set; }
|
||||
|
||||
public string? Root { get; set; }
|
||||
public string? Child1 { 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);
|
||||
|
||||
if (profile == null)
|
||||
{
|
||||
await _checkInJobStatusRepository.UpdateToFailedAsync(taskId, "ไม่พบข้อมูลผู้ใช้");
|
||||
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 check_status = data.CheckInId == null ? "check-in-picture" : "check-out-picture";
|
||||
|
|
@ -970,6 +978,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
|
||||
if (currentCheckIn != null)
|
||||
{
|
||||
await _checkInJobStatusRepository.UpdateToFailedAsync(taskId, "ไม่สามารถลงเวลาได้ เนื่องจากมีการลงเวลาในวันนี้แล้ว");
|
||||
return Error(new Exception("ไม่สามารถลงเวลาได้ เนื่องจากมีการลงเวลาในวันนี้แล้ว!"), StatusCodes.Status400BadRequest);
|
||||
}
|
||||
|
||||
|
|
@ -1104,31 +1113,35 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
else
|
||||
{
|
||||
var checkout = await _userTimeStampRepository.GetByIdAsync(data.CheckInId.Value);
|
||||
|
||||
var currentCheckInProcess = await _processUserTimeStampRepository.GetTimestampByDateAsync(userId, checkout.CheckIn.Date);
|
||||
|
||||
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
|
||||
|
||||
if (checkout == null)
|
||||
{
|
||||
await _checkInJobStatusRepository.UpdateToFailedAsync(taskId, "ไม่พบข้อมูลการลงเวลาทำงาน");
|
||||
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 startTime = "";
|
||||
var endTimeMorning = "";
|
||||
|
|
@ -1289,7 +1302,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
{
|
||||
await _checkInJobStatusRepository.UpdateToFailedAsync(taskId, ex.Message);
|
||||
}
|
||||
throw;
|
||||
return Error(ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1084,8 +1084,12 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
// fix issue : ระบบลา (ขรก.) >> ลาพักผ่อน (กรณีรับราชการไม่ถึง 6 เดือน) #838
|
||||
//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); // หายอดวันลาที่เหลือของปีก่อน
|
||||
|
||||
if (govAge >= 180)
|
||||
if (profile.IsProbatin! == true)
|
||||
{
|
||||
isLeave = false;
|
||||
if (!isLeave) message = "ยังอยู่ในช่วงทดลองปฏิบัติราชการ ไม่สามารถลาพักผ่อนได้";
|
||||
}
|
||||
else if (govAge >= 180)
|
||||
{
|
||||
isLeave = (totalDay - (sumWorkDay + sumWeekend) + approveDay) <= (limitDay);
|
||||
if (!isLeave) message = "จำนวนวันลาเกินที่กำหนด";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue