Add GetLastLeaveRequestByTypeForUserAsync2 method and update LeaveReportController to use new method for fetching last leave request #2305
All checks were successful
Build & Deploy Leave Service / build (push) Successful in 2m0s
All checks were successful
Build & Deploy Leave Service / build (push) Successful in 2m0s
This commit is contained in:
parent
d748308419
commit
65feb994ee
2 changed files with 18 additions and 2 deletions
|
|
@ -569,6 +569,22 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<LeaveRequest?> GetLastLeaveRequestByTypeForUserAsync2(Guid keycloakUserId, Guid leaveTypeId, DateTime beforeDate)
|
||||||
|
{
|
||||||
|
var data = await _dbContext.Set<LeaveRequest>().AsQueryable().AsNoTracking()
|
||||||
|
.Include(x => x.Type)
|
||||||
|
//.Where(x => x.LeaveStartDate.Date < beforeDate.Date)
|
||||||
|
.Where(x => x.CreatedAt < beforeDate)
|
||||||
|
.Where(x => x.KeycloakUserId == keycloakUserId)
|
||||||
|
.Where(x => x.Type.Id == leaveTypeId)
|
||||||
|
.Where(x => x.LeaveStatus == "APPROVE" || x.LeaveStatus == "DELETING")
|
||||||
|
//.Where(x => x.LeaveStatus != "REJECT" && x.LeaveStatus != "DELETE")
|
||||||
|
.OrderByDescending(x => x.LeaveStartDate.Date)
|
||||||
|
.FirstOrDefaultAsync();
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<List<LeaveRequest>> GetCancelLeaveRequestForAdminAsync(int year, Guid type, string status, string role, string? nodeId, int? node)
|
public async Task<List<LeaveRequest>> GetCancelLeaveRequestForAdminAsync(int year, Guid type, string status, string role, string? nodeId, int? node)
|
||||||
{
|
{
|
||||||
var rawData = _dbContext.Set<LeaveRequest>().AsNoTracking()
|
var rawData = _dbContext.Set<LeaveRequest>().AsNoTracking()
|
||||||
|
|
|
||||||
|
|
@ -152,8 +152,8 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
|
|
||||||
|
|
||||||
var lastLeaveRequest =
|
var lastLeaveRequest =
|
||||||
await _leaveRequestRepository.GetLastLeaveRequestByTypeForUserAsync(data.KeycloakUserId,
|
await _leaveRequestRepository.GetLastLeaveRequestByTypeForUserAsync2(data.KeycloakUserId,
|
||||||
data.Type.Id, data.LeaveStartDate.Date);
|
data.Type.Id, data.CreatedAt);
|
||||||
|
|
||||||
var startFiscalYear = new DateTime(data.LeaveStartDate.Year - 1, 10, 1);
|
var startFiscalYear = new DateTime(data.LeaveStartDate.Year - 1, 10, 1);
|
||||||
var endFiscalYear = data.CreatedAt;
|
var endFiscalYear = data.CreatedAt;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue