diff --git a/BMA.EHR.Application/Responses/Profiles/GetProfileByKeycloakIdDto.cs b/BMA.EHR.Application/Responses/Profiles/GetProfileByKeycloakIdDto.cs index 2012e197..3ba42944 100644 --- a/BMA.EHR.Application/Responses/Profiles/GetProfileByKeycloakIdDto.cs +++ b/BMA.EHR.Application/Responses/Profiles/GetProfileByKeycloakIdDto.cs @@ -55,6 +55,8 @@ namespace BMA.EHR.Application.Responses.Profiles public string? Child4 { get; set; } public double? Amount { get; set; } + public string? Commander { get; set; } + } public class PosLevel diff --git a/BMA.EHR.Discipline.Service/Controllers/DisciplineDisciplinaryController.cs b/BMA.EHR.Discipline.Service/Controllers/DisciplineDisciplinaryController.cs index 1636c784..494b25fe 100644 --- a/BMA.EHR.Discipline.Service/Controllers/DisciplineDisciplinaryController.cs +++ b/BMA.EHR.Discipline.Service/Controllers/DisciplineDisciplinaryController.cs @@ -1739,7 +1739,12 @@ namespace BMA.EHR.DisciplineDisciplinary.Service.Controllers Prefix = item.Prefix, FirstName = item.FirstName, LastName = item.LastName, - Organization = item.Organization, + //Organization = item.Organization, + Organization = (item.child4 == null ? "" : item.child4 + "/") + + (item.child3 == null ? "" : item.child3 + "/") + + (item.child2 == null ? "" : item.child2 + "/") + + (item.child1 == null ? "" : item.child1 + "/") + + (item.root == null ? "" : item.root), root = item.root, rootId = item.rootId, diff --git a/BMA.EHR.Leave/Controllers/LeaveRequestController.cs b/BMA.EHR.Leave/Controllers/LeaveRequestController.cs index ddab066f..1745bccf 100644 --- a/BMA.EHR.Leave/Controllers/LeaveRequestController.cs +++ b/BMA.EHR.Leave/Controllers/LeaveRequestController.cs @@ -283,10 +283,14 @@ namespace BMA.EHR.Leave.Service.Controllers case "LV-008": { var lastSalary = profile.ProfileSalary; + var lastSalaryAmount = lastSalary == null ? 0 : lastSalary.Amount == null ? 0 : lastSalary.Amount; + var lastSalaryAmountText = lastSalary == null ? "" : lastSalary.Amount == null ? "" : ((int)lastSalary.Amount).ToThaiBahtText(false); + leaveRequest.LeaveSalary = (int)lastSalaryAmount; + leaveRequest.LeaveSalaryText = lastSalaryAmountText; + //leaveRequest.LeaveSalary = lastSalary == null ? 0 : (int)lastSalary.Amount.Value; + //leaveRequest.LeaveSalaryText = + // lastSalary == null ? "" : ((int)lastSalary.Amount.Value).ToThaiBahtText(false); - leaveRequest.LeaveSalary = lastSalary == null ? 0 : (int)lastSalary.Amount.Value; - leaveRequest.LeaveSalaryText = - lastSalary == null ? "" : ((int)lastSalary.Amount.Value).ToThaiBahtText(false); leaveRequest.LeaveBirthDate = profile.BirthDate; leaveRequest.LeaveGovernmentDate = profile.DateStart; @@ -303,10 +307,13 @@ namespace BMA.EHR.Leave.Service.Controllers case "LV-010": { var lastSalary = profile.ProfileSalary; - - leaveRequest.LeaveSalary = lastSalary == null ? 0 : (int)lastSalary.Amount.Value; - leaveRequest.LeaveSalaryText = - lastSalary == null ? "" : ((int)lastSalary.Amount.Value).ToThaiBahtText(false); + var lastSalaryAmount = lastSalary == null ? 0 : lastSalary.Amount == null ? 0 : lastSalary.Amount; + var lastSalaryAmountText = lastSalary == null ? "" : lastSalary.Amount == null ? "" : ((int)lastSalary.Amount).ToThaiBahtText(false); + leaveRequest.LeaveSalary = (int)lastSalaryAmount; + leaveRequest.LeaveSalaryText = lastSalaryAmountText; + //leaveRequest.LeaveSalary = lastSalary == null ? 0 : (int)lastSalary.Amount.Value; + //leaveRequest.LeaveSalaryText = + // lastSalary == null ? "" : ((int)lastSalary.Amount.Value).ToThaiBahtText(false); leaveRequest.CoupleDayName = req.CoupleDayName ?? ""; leaveRequest.CoupleDayPosition = req.CoupleDayPosition ?? ""; @@ -327,20 +334,22 @@ namespace BMA.EHR.Leave.Service.Controllers } // add dear and oc_data - var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken); - var approver = string.Empty; - if (rootOc != null) - { - var list = await _commandRepository.GetOrgApproverAsync(rootOc ?? Guid.Empty); - if (list.Count > 0) - approver = list.First().Name; - } + //var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken); + var approver = profile.Commander ?? ""; + var userOc = profile.Root ?? ""; + //if (rootOc != null) + //{ + // var list = await _commandRepository.GetOrgApproverAsync(rootOc ?? Guid.Empty); + // if (list.Count > 0) + // approver = list.First().Name; + //} + leaveRequest.LeaveTypeCode = leaveType.Code; leaveRequest.Dear = approver; leaveRequest.PositionName = profile.Position == null ? "" : profile.Position; leaveRequest.PositionLevelName = profile.PosLevel == null ? "" : profile.PosLevel.PosLevelName; - leaveRequest.OrganizationName = profile.Root ?? ""; + leaveRequest.OrganizationName = userOc; @@ -699,14 +708,15 @@ namespace BMA.EHR.Leave.Service.Controllers var lastSalary = profile.ProfileSalary; - var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken); - var approver = string.Empty; - if (rootOc != null) - { - var list = await _commandRepository.GetOrgApproverAsync(rootOc ?? Guid.Empty); - if (list.Count > 0) - approver = list.First().Name; - } + //var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken); + var approver = profile.Commander ?? ""; + var userOc = profile.Root ?? ""; + //if (rootOc != null) + //{ + // var list = await _commandRepository.GetOrgApproverAsync(rootOc ?? Guid.Empty); + // if (list.Count > 0) + // approver = list.First().Name; + //} var leaveLast = await _leaveRequestRepository.GetLeaveLastByTypeForUserAsync(userId, req.Type); @@ -720,7 +730,7 @@ namespace BMA.EHR.Leave.Service.Controllers Dear = approver, PositionName = profile.Position == null ? "" : profile.Position, PositionLevelName = profile.PosLevel == null ? "" : profile.PosLevel.PosLevelName, - OrganizationName = profile.Oc ?? "", + OrganizationName = userOc, //profile.Oc ?? "", LeaveLimit = leaveType.Limit, LeaveTotal = sumLeave, @@ -728,8 +738,8 @@ namespace BMA.EHR.Leave.Service.Controllers RestDayTotalOld = restOldDay, BirthDate = profile.BirthDate.Date, DateAppoint = profile.DateAppoint == null ? null : profile.DateAppoint.Value.Date, - Salary = lastSalary == null ? 0 : (int)lastSalary.Amount.Value, - SalaryText = lastSalary == null ? "" : ((int)lastSalary.Amount.Value).ToThaiBahtText(false), + Salary = lastSalary == null ? 0 : lastSalary.Amount == null ? 0 : (int)lastSalary.Amount.Value, + SalaryText = lastSalary == null ? "" : lastSalary.Amount == null ? "" : ((int)lastSalary.Amount.Value).ToThaiBahtText(false), LeaveLast = leaveLast == null ? null : leaveLast };