fix: skip approver check if no commander is assigned; update leave data retrieval logic
Some checks failed
release-dev / release-dev (push) Failing after 13s
Some checks failed
release-dev / release-dev (push) Failing after 13s
This commit is contained in:
parent
2981f865b3
commit
6b9767449c
2 changed files with 15 additions and 5 deletions
|
|
@ -1103,9 +1103,17 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
throw new Exception(GlobalMessages.DataNotFound);
|
||||
}
|
||||
|
||||
if (rawData.ApproveStep != "st3")
|
||||
// ถ้าไม่มี commander ข้ามไปเช็ค approver ได้เลย
|
||||
var commanders = rawData.Approvers
|
||||
.Where(x => x.ApproveType!.ToUpper() == "COMMANDER")
|
||||
.OrderBy(x => x.Seq)
|
||||
.ToList();
|
||||
if(commanders.Count > 0 || commanders != null)
|
||||
{
|
||||
throw new Exception("คำขอนี้ยังไม่ได้อยู่ในขั้นตอนที่สามารถอนุมัติได้ ไม่สามารถทำรายการได้");
|
||||
if (rawData.ApproveStep != "st3")
|
||||
{
|
||||
throw new Exception("คำขอนี้ยังไม่ได้อยู่ในขั้นตอนที่สามารถอนุมัติได้ ไม่สามารถทำรายการได้");
|
||||
}
|
||||
}
|
||||
|
||||
// check commander approve
|
||||
|
|
|
|||
|
|
@ -238,11 +238,13 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
if (toDay >= new DateTime(toDay.Year, 10, 1) && toDay <= new DateTime(toDay.Year, 12, 31))
|
||||
thisYear = thisYear + 1;
|
||||
|
||||
var leaveData = await _leaveBeginningRepository.GetByYearAndTypeIdForUserAsync(thisYear, data.Type.Id, data.KeycloakUserId);
|
||||
|
||||
var sumLeave = await _leaveRequestRepository.GetSumApproveLeaveTotalByTypeAndRangeForUser(data.KeycloakUserId, data.Type.Id, startFiscalYear, endFiscalYear);
|
||||
var leaveData = await _leaveBeginningRepository.GetByYearAndTypeIdForUser2Async(thisYear, data.Type.Id, data.KeycloakUserId);
|
||||
//var leaveData = await _leaveBeginningRepository.GetByYearAndTypeIdForUser2Async(thisYear, rawData.Type.Id, rawData.KeycloakUserId);
|
||||
//var leaveSummary = leaveData == null ? 0.0 : leaveData.LeaveDaysUsed;
|
||||
|
||||
//var sumLeave = await _leaveRequestRepository.GetSumApproveLeaveTotalByTypeAndRangeForUser(data.KeycloakUserId, data.Type.Id, startFiscalYear, endFiscalYear);
|
||||
|
||||
var sumLeave = leaveData == null ? 0.0 : leaveData.LeaveDaysUsed;
|
||||
var leaveLimit = leaveData == null ? 0.0 : leaveData.LeaveDays;
|
||||
var extendLeave = leaveLimit - 10;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue