fix bug!
This commit is contained in:
@@ -1613,7 +1613,9 @@ CreateWorkingHoursTemp command, bool holidayWorking)
|
||||
public CustomizeCheckoutMandatoryViewModel CustomizeCheckoutMandatoryComputeForKebabMahdi(long employeeId, long workshopId,
|
||||
DateTime contractStart, DateTime contractEnd)
|
||||
{
|
||||
if (employeeId is 45084 or 7980 or 5976 or 45214 or 45215)
|
||||
var checkoutEnd = contractEnd;
|
||||
var checkoutStart = contractStart;
|
||||
if (employeeId is 45084 or 7980 or 5976 or 45214 or 45215)
|
||||
{
|
||||
return CheckoutWithoutCalculationForKebabMahdi(workshopId,employeeId,contractStart,contractEnd);
|
||||
}
|
||||
@@ -1968,7 +1970,7 @@ CreateWorkingHoursTemp command, bool holidayWorking)
|
||||
#region SalaryAidDeduction
|
||||
|
||||
var salaryAidViewModel = _context.SalaryAids
|
||||
.Where(x => x.SalaryAidDateTime >= contractStart && x.SalaryAidDateTime <= contractEnd && x.EmployeeId == employeeId && x.WorkshopId == workshopId).Select(x => new SalaryAidViewModel()
|
||||
.Where(x => x.SalaryAidDateTime >= checkoutStart && x.SalaryAidDateTime <= checkoutEnd && x.EmployeeId == employeeId && x.WorkshopId == workshopId).Select(x => new SalaryAidViewModel()
|
||||
{
|
||||
Amount = x.Amount.ToMoney(),
|
||||
AmountDouble = x.Amount,
|
||||
@@ -2182,8 +2184,8 @@ CreateWorkingHoursTemp command, bool holidayWorking)
|
||||
#region Reward
|
||||
|
||||
var rewardViewModels = _context.Rewards.Where(x =>
|
||||
x.WorkshopId == workshopId && x.EmployeeId == employeeId && x.GrantDate <= contractEnd &&
|
||||
x.GrantDate >= contractStart).Select(x => new RewardViewModel
|
||||
x.WorkshopId == workshopId && x.EmployeeId == employeeId && x.GrantDate <= checkoutEnd &&
|
||||
x.GrantDate >= checkoutStart).Select(x => new RewardViewModel
|
||||
{
|
||||
Title = x.Title,
|
||||
Amount = x.Amount.ToMoney(),
|
||||
@@ -2414,9 +2416,89 @@ CreateWorkingHoursTemp command, bool holidayWorking)
|
||||
var mandatoryDays = totalDays;
|
||||
|
||||
|
||||
return new CustomizeCheckoutMandatoryViewModel()
|
||||
#region SalaryAidDeduction
|
||||
|
||||
var salaryAidViewModel = _context.SalaryAids
|
||||
.Where(x => x.SalaryAidDateTime >= contractStart && x.SalaryAidDateTime <= contractEnd && x.EmployeeId == employeeId && x.WorkshopId == workshopId).Select(x => new SalaryAidViewModel()
|
||||
{
|
||||
Amount = x.Amount.ToMoney(),
|
||||
AmountDouble = x.Amount,
|
||||
SalaryAidDateTimeFa = x.SalaryAidDateTime.ToFarsi(),
|
||||
SalaryAidDateTimeGe = x.SalaryAidDateTime,
|
||||
}).ToList();
|
||||
double salaryAidDeduction = salaryAidViewModel.Sum(x => x.AmountDouble);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Loan
|
||||
|
||||
var loanInstallments = _context.Loans
|
||||
.Where(x => x.EmployeeId == employeeId && x.WorkshopId == workshopId)
|
||||
.SelectMany(x => x.LoanInstallments)
|
||||
.Where(i => i.InstallmentDate > contractStart && i.InstallmentDate < contractEnd && i.IsActive == IsActive.True)
|
||||
.Select(x => new LoanInstallmentViewModel()
|
||||
{
|
||||
Month = x.Month,
|
||||
IsActive = x.IsActive,
|
||||
Amount = x.AmountForMonth.ToMoney(),
|
||||
Year = x.Year,
|
||||
AmountDouble = x.AmountForMonth,
|
||||
RemainingAmount = _context.Loans.SelectMany(l => l.LoanInstallments).Where(i => i.LoanId == x.LoanId && i.IsActive == IsActive.True && i.InstallmentDate > x.InstallmentDate)
|
||||
.Sum(i => i.AmountForMonth).ToMoney()
|
||||
}).ToList();
|
||||
|
||||
double loanDeduction = loanInstallments.Sum(x => x.AmountDouble);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Fine
|
||||
|
||||
var fineViewModels = _context.Fines.Where(x =>
|
||||
x.EmployeeId == employeeId && x.WorkshopId == workshopId && x.FineDate >= contractStart &&
|
||||
x.FineDate <= contractEnd && x.IsActive == IsActive.True).Select(x => new FineViewModel()
|
||||
{
|
||||
IsActive = x.IsActive,
|
||||
Amount = x.Amount.ToMoney(),
|
||||
FineDate = x.FineDate.ToFarsi(),
|
||||
Id = x.id,
|
||||
Title = x.Title,
|
||||
EmployeeId = x.EmployeeId,
|
||||
CreationDate = x.CreationDate.ToFarsi()
|
||||
}).ToList();
|
||||
double fineDeduction = fineViewModels.Sum(x => x.Amount.MoneyToDouble());
|
||||
|
||||
#endregion
|
||||
#region Reward
|
||||
|
||||
var rewardViewModels = _context.Rewards.Where(x =>
|
||||
x.WorkshopId == workshopId && x.EmployeeId == employeeId && x.GrantDate <= contractEnd &&
|
||||
x.GrantDate >= contractStart).Select(x => new RewardViewModel
|
||||
{
|
||||
Title = x.Title,
|
||||
Amount = x.Amount.ToMoney(),
|
||||
AmountDouble = x.Amount,
|
||||
Description = x.Description,
|
||||
GrantDateGr = x.GrantDate,
|
||||
GrantDateFa = x.GrantDate.ToFarsi(),
|
||||
IsActive = x.IsActive,
|
||||
}).ToList();
|
||||
|
||||
double rewardPay = rewardViewModels.Sum(x => x.AmountDouble);
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
return new CustomizeCheckoutMandatoryViewModel()
|
||||
{
|
||||
MonthlySalary = dailyWage * mandatoryDays,
|
||||
RewardPay = rewardPay,
|
||||
RewardViewModels = rewardViewModels,
|
||||
SalaryAidDeduction = salaryAidDeduction,
|
||||
SalaryAidViewModels = salaryAidViewModel,
|
||||
InstallmentDeduction = loanDeduction,
|
||||
InstallmentViewModels = loanInstallments,
|
||||
FineDeduction = fineDeduction,
|
||||
FineViewModels = fineViewModels
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user