update GetLastEffectRound method to accept effectiveDate parameter and adjust usage in LeaveReportController

This commit is contained in:
Suphonchai Phoonsawat 2026-01-09 18:57:24 +07:00
parent a540912202
commit 99accd44e3
2 changed files with 5 additions and 4 deletions

View file

@ -101,12 +101,12 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants
return data;
}
public async Task<UserDutyTime?> GetLastEffectRound(Guid profileId)
public async Task<UserDutyTime?> GetLastEffectRound(Guid profileId, DateTime? effectiveDate = null)
{
effectiveDate ??= DateTime.Now;
var data = await _dbContext.Set<UserDutyTime>()
.Where(x => x.ProfileId == profileId)
.Where(x => x.IsProcess)
.Where(x => x.EffectiveDate.Value.Date <= DateTime.Now.Date)
.Where(x => x.EffectiveDate.Value.Date <= effectiveDate.Value.Date)
.OrderByDescending(x => x.EffectiveDate)
.FirstOrDefaultAsync();