Merge branch 'working' into develop
All checks were successful
Build & Deploy Leave Service / build (push) Successful in 1m52s

This commit is contained in:
Suphonchai Phoonsawat 2026-04-01 12:35:00 +07:00
commit 6691303ea7

View file

@ -7,6 +7,7 @@ using BMA.EHR.Application.Responses.Profiles;
using BMA.EHR.Domain.Common;
using BMA.EHR.Domain.Extensions;
using BMA.EHR.Domain.Models.Leave.Requests;
using BMA.EHR.Domain.Models.Leave.TimeAttendants;
using BMA.EHR.Domain.Shared;
using BMA.EHR.Leave.Service.DTOs.Reports;
using Microsoft.AspNetCore.Authorization;
@ -2855,25 +2856,41 @@ namespace BMA.EHR.Leave.Service.Controllers
{
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);
foreach (var p in userTimeStamps)
{
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 userRound = await _dutyTimeRepository.GetByIdAsync(roundId);
var duty = userRound;
if (duty == null)
{
duty = await _dutyTimeRepository.GetDefaultAsync();
if (duty == null)
{
return Error("ไม่พบรอบการลงเวลา Default", StatusCodes.Status404NotFound);
}
}
var duty = userRound ?? getDefaultRound;
// var effectiveDate = await _userDutyTimeRepository.GetLastEffectRound(p.Id);
// var roundId = effectiveDate != null ? effectiveDate.DutyTimeId : Guid.Empty;
// var userRound = await _dutyTimeRepository.GetByIdAsync(roundId);
// var duty = userRound;
// if (duty == null)
// {
// duty = await _dutyTimeRepository.GetDefaultAsync();
// if (duty == null)
// {
// return Error("ไม่พบรอบการลงเวลา Default", StatusCodes.Status404NotFound);
// }
// }
DateTime? checkIn = p.CheckIn;
DateTime? checkOut = p.CheckOut ?? null;
var emp = new