fix: create leave request user commander and user oc
Some checks failed
release-dev / release-dev (push) Failing after 13s

fix: create leave handle lastSalary Amount while null value
This commit is contained in:
Suphonchai Phoonsawat 2024-11-14 20:13:40 +07:00
parent 5d8a0b842a
commit 62f2fd85cc

View file

@ -277,10 +277,14 @@ namespace BMA.EHR.Leave.Service.Controllers
case "LV-008": case "LV-008":
{ {
var lastSalary = profile.ProfileSalary; 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.LeaveBirthDate = profile.BirthDate;
leaveRequest.LeaveGovernmentDate = profile.DateStart; leaveRequest.LeaveGovernmentDate = profile.DateStart;
@ -297,10 +301,13 @@ namespace BMA.EHR.Leave.Service.Controllers
case "LV-010": case "LV-010":
{ {
var lastSalary = profile.ProfileSalary; var lastSalary = profile.ProfileSalary;
var lastSalaryAmount = lastSalary == null ? 0 : lastSalary.Amount == null ? 0 : lastSalary.Amount;
leaveRequest.LeaveSalary = lastSalary == null ? 0 : (int)lastSalary.Amount.Value; var lastSalaryAmountText = lastSalary == null ? "" : lastSalary.Amount == null ? "" : ((int)lastSalary.Amount).ToThaiBahtText(false);
leaveRequest.LeaveSalaryText = leaveRequest.LeaveSalary = (int)lastSalaryAmount;
lastSalary == null ? "" : ((int)lastSalary.Amount.Value).ToThaiBahtText(false); 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.CoupleDayName = req.CoupleDayName ?? "";
leaveRequest.CoupleDayPosition = req.CoupleDayPosition ?? ""; leaveRequest.CoupleDayPosition = req.CoupleDayPosition ?? "";
@ -321,20 +328,22 @@ namespace BMA.EHR.Leave.Service.Controllers
} }
// add dear and oc_data // add dear and oc_data
var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken); //var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken);
var approver = string.Empty; var approver = profile.Commander ?? "";
if (rootOc != null) var userOc = profile.Root ?? "";
{ //if (rootOc != null)
var list = await _commandRepository.GetOrgApproverAsync(rootOc ?? Guid.Empty); //{
if (list.Count > 0) // var list = await _commandRepository.GetOrgApproverAsync(rootOc ?? Guid.Empty);
approver = list.First().Name; // if (list.Count > 0)
} // approver = list.First().Name;
//}
leaveRequest.LeaveTypeCode = leaveType.Code; leaveRequest.LeaveTypeCode = leaveType.Code;
leaveRequest.Dear = approver; leaveRequest.Dear = approver;
leaveRequest.PositionName = profile.Position == null ? "" : profile.Position; leaveRequest.PositionName = profile.Position == null ? "" : profile.Position;
leaveRequest.PositionLevelName = profile.PosLevel == null ? "" : profile.PosLevel.PosLevelName; 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 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 approver = profile.Commander ?? "";
var userOc = profile.Root ?? ""; var userOc = profile.Root ?? "";
//if (rootOc != null) //if (rootOc != null)