This commit is contained in:
parent
9bf7ee2e9a
commit
66d4a08f3c
4 changed files with 60 additions and 4 deletions
|
|
@ -308,6 +308,33 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
return await rawData.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<List<LeaveRequest>> GetLeaveRequestForAdminWithAuthAsync(int year, Guid type, string status, DateTime startDate, DateTime endDate,List<Guid> keycloakIdList)
|
||||
{
|
||||
var rawData = _dbContext.Set<LeaveRequest>().AsNoTracking()
|
||||
.Include(x => x.Type)
|
||||
.Where(x => keycloakIdList.Contains(x.KeycloakUserId))
|
||||
.Where(x => x.LeaveStatus != "DRAFT")
|
||||
.OrderByDescending(x => x.CreatedAt)
|
||||
.AsQueryable();
|
||||
|
||||
if (year != 0)
|
||||
rawData = rawData.Where(x => x.LeaveStartDate.Year == year);
|
||||
|
||||
if (type != Guid.Empty)
|
||||
rawData = rawData.Where(x => x.Type.Id == type);
|
||||
|
||||
if (status.Trim().ToUpper() != "ALL")
|
||||
rawData = rawData.Where(x => x.LeaveStatus == status);
|
||||
|
||||
if (startDate != DateTime.MinValue)
|
||||
rawData = rawData.Where(x => x.LeaveStartDate >= startDate);
|
||||
|
||||
if (endDate != DateTime.MinValue)
|
||||
rawData = rawData.Where(x => x.LeaveEndDate <= endDate);
|
||||
|
||||
return await rawData.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<double> GetRestDayTotalByYearForUserAsync(Guid keycloakUserId, int year)
|
||||
{
|
||||
var startFiscalDate = new DateTime(year - 1, 10, 1);
|
||||
|
|
@ -425,7 +452,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
return await rawData.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<LeaveRequest> ApproveCancelLeaveRequestAsync(LeaveRequest data, string Reason)
|
||||
public async Task<LeaveRequest> ApproveCancelLeaveRequestAsync(LeaveRequest data, string Reason,string LeaveReason)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -438,6 +465,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
|
||||
data.LeaveCancelStatus = "APPROVE";
|
||||
data.LeaveDirectorComment = Reason;
|
||||
data.LeaveCancelComment = LeaveReason;
|
||||
|
||||
// TODO : Update ไปตาราง beginning
|
||||
if (data.ApproveStep == "st4") // ถ้ามีการอนุมัติจากผู้มีอำนาจแล้ว
|
||||
|
|
|
|||
|
|
@ -11,7 +11,8 @@
|
|||
<RootNamespace>BMA.EHR.Leave.Service</RootNamespace>
|
||||
<AssemblyName>BMA.EHR.Leave</AssemblyName>
|
||||
|
||||
<NoWarn>$(NoWarn);</NoWarn>
|
||||
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
|
||||
<NoWarn>$(NoWarn);$(WarningsNotAsErrors)</NoWarn>
|
||||
|
||||
</PropertyGroup>
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ using BMA.EHR.Application.Repositories.Commands;
|
|||
using BMA.EHR.Application.Repositories.Leaves.LeaveRequests;
|
||||
using BMA.EHR.Application.Repositories.Leaves.TimeAttendants;
|
||||
using BMA.EHR.Application.Repositories.MetaData;
|
||||
using BMA.EHR.Application.Responses.Profiles;
|
||||
using BMA.EHR.Domain.Common;
|
||||
using BMA.EHR.Domain.Extensions;
|
||||
using BMA.EHR.Domain.Models.Leave.Commons;
|
||||
|
|
@ -1552,7 +1553,27 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
{
|
||||
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||
}
|
||||
var rawData = await _leaveRequestRepository.GetLeaveRequestForAdminAsync(req.Year, req.Type, req.Status, req.StartDate, req.EndDate);
|
||||
|
||||
// เพิ่มเติมการดึงคนตามสิทธิ์แบบที่ bright ทำ #1462
|
||||
var profileList = new List<GetProfileByKeycloakIdRootDto>();
|
||||
if (req.ProfileType.Trim().ToUpper() == "OFFICER")
|
||||
{
|
||||
|
||||
profileList = await _userProfileRepository.GetProfileWithNoneValidateKeycloakAllOfficerAndRevision(AccessToken, req.Node, req.NodeId, jsonData["result"] == "OWNER" || jsonData["result"] == "CHILD", req.RevisionId);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
profileList = await _userProfileRepository.GetProfileWithNoneValidateKeycloakAllEmployeeAndRevision(AccessToken, req.Node, req.NodeId, jsonData["result"] == "OWNER" || jsonData["result"] == "CHILD", req.RevisionId);
|
||||
}
|
||||
|
||||
var keycloakList = new List<Guid>();
|
||||
if(profileList != null)
|
||||
{
|
||||
keycloakList = profileList.Where(x => x.Keycloak != null).Select(x => x.Keycloak!.Value).ToList();
|
||||
}
|
||||
|
||||
var rawData = await _leaveRequestRepository.GetLeaveRequestForAdminWithAuthAsync(req.Year, req.Type, req.Status, req.StartDate, req.EndDate, keycloakList);
|
||||
|
||||
var result = new List<GetLeaveRequestForAdminResultDto>();
|
||||
|
||||
|
|
@ -1650,7 +1671,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
}
|
||||
else
|
||||
{
|
||||
data = await _leaveRequestRepository.ApproveCancelLeaveRequestAsync(data, "อนุมัติการขอยกเลิกการลา โดยระบบ");
|
||||
data = await _leaveRequestRepository.ApproveCancelLeaveRequestAsync(data, "อนุมัติการขอยกเลิกการลา โดยระบบ", req.Reason ?? "");
|
||||
}
|
||||
|
||||
// upload leave cancel document
|
||||
|
|
|
|||
|
|
@ -28,5 +28,11 @@ namespace BMA.EHR.Leave.Service.DTOs.LeaveRequest
|
|||
|
||||
public string ProfileType { get; set; } = string.Empty;
|
||||
|
||||
public string NodeId { get; set; } = string.Empty;
|
||||
|
||||
public int Node { get; set; }
|
||||
|
||||
public string? RevisionId { get; set; } = string.Empty;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue