From 5d8a0b842aa587c4f8dd5273b356026959a392ff Mon Sep 17 00:00:00 2001 From: Suphonchai Phoonsawat Date: Thu, 14 Nov 2024 19:53:41 +0700 Subject: [PATCH 1/3] fix : Leave user commander and organization name fix: handle lastSalary amount while null value --- .../Profiles/GetProfileByKeycloakIdDto.cs | 2 ++ .../Controllers/LeaveRequestController.cs | 21 ++++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/BMA.EHR.Application/Responses/Profiles/GetProfileByKeycloakIdDto.cs b/BMA.EHR.Application/Responses/Profiles/GetProfileByKeycloakIdDto.cs index 16f80b70..6c0fb20c 100644 --- a/BMA.EHR.Application/Responses/Profiles/GetProfileByKeycloakIdDto.cs +++ b/BMA.EHR.Application/Responses/Profiles/GetProfileByKeycloakIdDto.cs @@ -54,6 +54,8 @@ namespace BMA.EHR.Application.Responses.Profiles public string? Child4 { get; set; } + public string? Commander { get; set; } + } public class PosLevel diff --git a/BMA.EHR.Leave/Controllers/LeaveRequestController.cs b/BMA.EHR.Leave/Controllers/LeaveRequestController.cs index 3eab8066..cb0d3e2d 100644 --- a/BMA.EHR.Leave/Controllers/LeaveRequestController.cs +++ b/BMA.EHR.Leave/Controllers/LeaveRequestController.cs @@ -694,13 +694,14 @@ 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 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); @@ -714,7 +715,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, @@ -722,8 +723,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 }; From 62f2fd85cc62394baa352f073aa41f8923f16c70 Mon Sep 17 00:00:00 2001 From: Suphonchai Phoonsawat Date: Thu, 14 Nov 2024 20:13:40 +0700 Subject: [PATCH 2/3] fix: create leave request user commander and user oc fix: create leave handle lastSalary Amount while null value --- .../Controllers/LeaveRequestController.cs | 43 +++++++++++-------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/BMA.EHR.Leave/Controllers/LeaveRequestController.cs b/BMA.EHR.Leave/Controllers/LeaveRequestController.cs index cb0d3e2d..d9485786 100644 --- a/BMA.EHR.Leave/Controllers/LeaveRequestController.cs +++ b/BMA.EHR.Leave/Controllers/LeaveRequestController.cs @@ -277,10 +277,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; @@ -297,10 +301,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 ?? ""; @@ -321,20 +328,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; @@ -693,7 +702,7 @@ namespace BMA.EHR.Leave.Service.Controllers var lastSalary = profile.ProfileSalary; - var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken); + //var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken); var approver = profile.Commander ?? ""; var userOc = profile.Root ?? ""; //if (rootOc != null) From 88c138762f1897a7e8fa5e72a4f9f857f9227a58 Mon Sep 17 00:00:00 2001 From: Bright Date: Fri, 15 Nov 2024 10:59:03 +0700 Subject: [PATCH 3/3] =?UTF-8?q?fix=20=E0=B8=AA=E0=B8=B1=E0=B8=87=E0=B8=81?= =?UTF-8?q?=E0=B8=B1=E0=B8=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/DisciplineDisciplinaryController.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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,