แก้บั้ก การค้นหาเงินเดือนและเงินประตำตำแหน่ง
This commit is contained in:
parent
c983f0a32e
commit
9e74086007
1 changed files with 50 additions and 14 deletions
|
|
@ -5884,6 +5884,19 @@ namespace BMA.EHR.Application.Repositories.Commands
|
|||
#region " Override "
|
||||
|
||||
public override async Task<Command?> GetByIdAsync(Guid id)
|
||||
{
|
||||
return await _dbContext.Set<Command>()
|
||||
.Include(x => x.Placement)
|
||||
.Include(x => x.CommandType)
|
||||
//.Include(x => x.Documents)
|
||||
//.ThenInclude(x => x.Document) //--REmove
|
||||
.Include(x => x.Receivers)
|
||||
.Include(x => x.CommandStatus)
|
||||
.FirstOrDefaultAsync(x => x.Id == id);
|
||||
|
||||
}
|
||||
|
||||
public async Task<Command?> GetByIdWithPlacementAsync(Guid id)
|
||||
{
|
||||
return await _dbContext.Set<Command>()
|
||||
.Include(x => x.Placement)
|
||||
|
|
@ -5893,7 +5906,6 @@ namespace BMA.EHR.Application.Repositories.Commands
|
|||
.Include(x => x.Receivers)
|
||||
.Include(x => x.CommandStatus)
|
||||
.FirstOrDefaultAsync(x => x.Id == id);
|
||||
|
||||
}
|
||||
|
||||
public override async Task<IReadOnlyList<Command>> GetAllAsync()
|
||||
|
|
@ -5962,14 +5974,34 @@ namespace BMA.EHR.Application.Repositories.Commands
|
|||
{
|
||||
try
|
||||
{
|
||||
var command = await _dbContext.Set<Command>()
|
||||
Command command = null;
|
||||
|
||||
var c = await _dbContext.Set<Command>()
|
||||
.Include(x => x.CommandType)
|
||||
.FirstOrDefaultAsync(x => x.Id == id);
|
||||
|
||||
if (c == null)
|
||||
throw new Exception(GlobalMessages.CommandNotFound);
|
||||
|
||||
switch (c.CommandType.CommandCode.ToUpper())
|
||||
{
|
||||
case "C-PM-01":
|
||||
case "C-PM-02":
|
||||
case "C-PM-03":
|
||||
case "C-PM-04":
|
||||
command = await _dbContext.Set<Command>()
|
||||
.Include(x => x.Placement)
|
||||
.Include(x => x.Receivers)
|
||||
.Include(x => x.CommandType)
|
||||
.FirstOrDefaultAsync(x => x.Id == id);
|
||||
|
||||
if (command == null)
|
||||
throw new Exception(GlobalMessages.CommandNotFound);
|
||||
break;
|
||||
default:
|
||||
command = await _dbContext.Set<Command>()
|
||||
.Include(x => x.Receivers)
|
||||
.Include(x => x.CommandType)
|
||||
.FirstOrDefaultAsync(x => x.Id == id);
|
||||
break;
|
||||
}
|
||||
|
||||
var ap = (await GetReceiverForByCommndTypeAsync(command, token)).Where(x => selected.Contains(x.RefPlacementProfileId!.Value));
|
||||
|
||||
|
|
@ -6499,21 +6531,25 @@ namespace BMA.EHR.Application.Repositories.Commands
|
|||
var profile = await _dbContext.Set<Profile>()
|
||||
.Include(x => x.Salaries)
|
||||
.FirstOrDefaultAsync(p => p.CitizenId == cmdReceiver.CitizenId);
|
||||
Double SalaryAmount = 0;
|
||||
Double PositionSalaryAmount = 0;
|
||||
Double MonthSalaryAmount = 0;
|
||||
double? SalaryAmount = 0;
|
||||
double? PositionSalaryAmount = 0;
|
||||
double? MonthSalaryAmount = 0;
|
||||
|
||||
if (profile != null && profile.Salaries.Count() > 0)
|
||||
{
|
||||
SalaryAmount = cmdReceiver.Amount == null ? profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Amount.Value : 0;
|
||||
PositionSalaryAmount = cmdReceiver.PositionSalaryAmount == null ? profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().PositionSalaryAmount.Value : 0;
|
||||
MonthSalaryAmount = cmdReceiver.MouthSalaryAmount == null ? profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().MouthSalaryAmount.Value : 0;
|
||||
SalaryAmount = cmdReceiver.Amount == null ? profile.Salaries == null ? 0 :
|
||||
profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Amount != null ? profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Amount.Value : 0 : 0;
|
||||
PositionSalaryAmount = cmdReceiver.PositionSalaryAmount == null ? profile.Salaries == null ? 0 :
|
||||
profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().PositionSalaryAmount != null ? profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().PositionSalaryAmount.Value : 0 : 0;
|
||||
MonthSalaryAmount = cmdReceiver.MouthSalaryAmount == null ? profile.Salaries == null ? 0 :
|
||||
profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().MouthSalaryAmount != null ?profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().MouthSalaryAmount.Value : 0 : 0;
|
||||
}
|
||||
|
||||
return new PlacementSalaryResponse
|
||||
{
|
||||
SalaryAmount = cmdReceiver.Amount != null ? cmdReceiver.Amount.Value : SalaryAmount,
|
||||
PositionSalaryAmount = cmdReceiver.PositionSalaryAmount != null ? cmdReceiver.PositionSalaryAmount.Value : PositionSalaryAmount,
|
||||
MonthSalaryAmount = cmdReceiver.MouthSalaryAmount != null ? cmdReceiver.MouthSalaryAmount.Value : MonthSalaryAmount,
|
||||
SalaryAmount = cmdReceiver.Amount != null ? cmdReceiver.Amount.Value : SalaryAmount ?? 0,
|
||||
PositionSalaryAmount = cmdReceiver.PositionSalaryAmount != null ? cmdReceiver.PositionSalaryAmount.Value : PositionSalaryAmount ?? 0,
|
||||
MonthSalaryAmount = cmdReceiver.MouthSalaryAmount != null ? cmdReceiver.MouthSalaryAmount.Value : MonthSalaryAmount ?? 0,
|
||||
};
|
||||
}
|
||||
catch
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue