Refactor LeaveReportController to improve duty time retrieval and handle default round logic
This commit is contained in:
parent
1cf780ecd0
commit
8ea572d46c
1 changed files with 27 additions and 10 deletions
|
|
@ -7,6 +7,7 @@ using BMA.EHR.Application.Responses.Profiles;
|
||||||
using BMA.EHR.Domain.Common;
|
using BMA.EHR.Domain.Common;
|
||||||
using BMA.EHR.Domain.Extensions;
|
using BMA.EHR.Domain.Extensions;
|
||||||
using BMA.EHR.Domain.Models.Leave.Requests;
|
using BMA.EHR.Domain.Models.Leave.Requests;
|
||||||
|
using BMA.EHR.Domain.Models.Leave.TimeAttendants;
|
||||||
using BMA.EHR.Domain.Shared;
|
using BMA.EHR.Domain.Shared;
|
||||||
using BMA.EHR.Leave.Service.DTOs.Reports;
|
using BMA.EHR.Leave.Service.DTOs.Reports;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
|
@ -2855,25 +2856,41 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
{
|
{
|
||||||
nodeId = profileAdmin?.RootDnaId;
|
nodeId = profileAdmin?.RootDnaId;
|
||||||
}
|
}
|
||||||
|
var getDefaultRound = await _dutyTimeRepository.GetDefaultAsync();
|
||||||
|
if (getDefaultRound == null)
|
||||||
|
{
|
||||||
|
return Error("ไม่พบรอบลงเวลา Default", StatusCodes.Status404NotFound);
|
||||||
|
}
|
||||||
|
|
||||||
var userTimeStamps = await _processUserTimeStampRepository.GetTimestampByDateLateAsync(type.Trim().ToUpper(), role, nodeId, profileAdmin.Node, req.nodeId, req.node, req.StartDate, req.EndDate);
|
var userTimeStamps = await _processUserTimeStampRepository.GetTimestampByDateLateAsync(type.Trim().ToUpper(), role, nodeId, profileAdmin.Node, req.nodeId, req.node, req.StartDate, req.EndDate);
|
||||||
foreach (var p in userTimeStamps)
|
foreach (var p in userTimeStamps)
|
||||||
{
|
{
|
||||||
var fullName = $"{p.Prefix}{p.FirstName} {p.LastName}";
|
var fullName = $"{p.Prefix}{p.FirstName} {p.LastName}";
|
||||||
|
|
||||||
var effectiveDate = await _userDutyTimeRepository.GetLastEffectRound(p.Id);
|
UserDutyTime? effectiveDate = null;
|
||||||
|
|
||||||
|
effectiveDate = await _userDutyTimeRepository.GetLastEffectRound(p.Id);
|
||||||
|
//return Error($"{data.Id} PF{data.FirstName} {data.LastName} : {GlobalMessages.DataNotFound}", StatusCodes.Status404NotFound);
|
||||||
|
|
||||||
|
//var userRound = await _dutyTimeRepository.GetByIdAsync(profile.DutyTimeId ?? Guid.Empty);
|
||||||
var roundId = effectiveDate != null ? effectiveDate.DutyTimeId : Guid.Empty;
|
var roundId = effectiveDate != null ? effectiveDate.DutyTimeId : Guid.Empty;
|
||||||
var userRound = await _dutyTimeRepository.GetByIdAsync(roundId);
|
var userRound = await _dutyTimeRepository.GetByIdAsync(roundId);
|
||||||
|
|
||||||
var duty = userRound;
|
var duty = userRound ?? getDefaultRound;
|
||||||
if (duty == null)
|
|
||||||
{
|
// var effectiveDate = await _userDutyTimeRepository.GetLastEffectRound(p.Id);
|
||||||
duty = await _dutyTimeRepository.GetDefaultAsync();
|
// var roundId = effectiveDate != null ? effectiveDate.DutyTimeId : Guid.Empty;
|
||||||
if (duty == null)
|
// var userRound = await _dutyTimeRepository.GetByIdAsync(roundId);
|
||||||
{
|
|
||||||
return Error("ไม่พบรอบการลงเวลา Default", StatusCodes.Status404NotFound);
|
// var duty = userRound;
|
||||||
}
|
// if (duty == null)
|
||||||
}
|
// {
|
||||||
|
// duty = await _dutyTimeRepository.GetDefaultAsync();
|
||||||
|
// if (duty == null)
|
||||||
|
// {
|
||||||
|
// return Error("ไม่พบรอบการลงเวลา Default", StatusCodes.Status404NotFound);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
DateTime? checkIn = p.CheckIn;
|
DateTime? checkIn = p.CheckIn;
|
||||||
DateTime? checkOut = p.CheckOut ?? null;
|
DateTime? checkOut = p.CheckOut ?? null;
|
||||||
var emp = new
|
var emp = new
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue