fix : Add วันลาใช้ไป เพิ่มเติมไปใน func หาวันที่มีการ approve
This commit is contained in:
parent
db483ce18d
commit
a7b8c2786c
3 changed files with 43 additions and 9 deletions
|
|
@ -109,7 +109,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
{
|
||||
throw;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public override async Task<LeaveRequest> AddAsync(LeaveRequest entity)
|
||||
|
|
@ -966,6 +966,31 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
|
||||
public async Task<List<GetSumApproveLeaveByTypeDto>> GetSumApproveLeaveAsync(int year)
|
||||
{
|
||||
// Get จาก LeaveBeginning
|
||||
var beginning = await _dbContext.Set<LeaveBeginning>().AsNoTracking()
|
||||
.Include(x => x.LeaveType)
|
||||
.Where(x => x.LeaveYear == year)
|
||||
|
||||
.ToListAsync();
|
||||
|
||||
var beginningData = new List<GetSumApproveLeaveByTypeDto>();
|
||||
|
||||
foreach (var b in beginning)
|
||||
{
|
||||
var pf = await _userProfileRepository.GetProfileByProfileIdAsync(b.ProfileId, AccessToken);
|
||||
if (pf != null)
|
||||
{
|
||||
beginningData.Add(new GetSumApproveLeaveByTypeDto
|
||||
{
|
||||
KeycloakUserId = pf.Keycloak == null ? Guid.Empty : pf.Keycloak.Value,
|
||||
LeaveTypeId = b.LeaveTypeId,
|
||||
LeaveTypeCode = b.LeaveType!.Code,
|
||||
SumLeaveDay = b.LeaveDaysUsed
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// fix issue : #729
|
||||
var startFiscalDate = new DateTime(year - 1, 10, 1);
|
||||
var endFiscalDate = new DateTime(year, 9, 30);
|
||||
|
|
@ -977,6 +1002,8 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
.Where(x => x.LeaveStatus == "APPROVE")
|
||||
.ToListAsync();
|
||||
|
||||
|
||||
|
||||
var res = (from d in data
|
||||
group d by new { d.KeycloakUserId, LeaveTypeId = d.Type.Id, LeaveTypeCode = d.Type.Code } into grp
|
||||
select new GetSumApproveLeaveByTypeDto
|
||||
|
|
@ -988,7 +1015,19 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
})
|
||||
.ToList();
|
||||
|
||||
return res;
|
||||
|
||||
var resUnion = (from d in res.Union(beginningData)
|
||||
group d by new { d.KeycloakUserId, d.LeaveTypeId, d.LeaveTypeCode } into grp
|
||||
select new GetSumApproveLeaveByTypeDto
|
||||
{
|
||||
KeycloakUserId = grp.Key.KeycloakUserId,
|
||||
LeaveTypeId = grp.Key.LeaveTypeId,
|
||||
LeaveTypeCode = grp.Key.LeaveTypeCode,
|
||||
SumLeaveDay = grp.Sum(x => x.SumLeaveDay)
|
||||
})
|
||||
.ToList();
|
||||
|
||||
return resUnion;
|
||||
}
|
||||
|
||||
public async Task<List<GetSumApproveLeaveByTypeDto>> GetSumRejectLeaveAsync(int year)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue