add insurance print api for client
This commit is contained in:
@@ -1960,6 +1960,54 @@ public class InsuranceListRepository : RepositoryBase<long, InsuranceList>, IIns
|
||||
return res;
|
||||
}
|
||||
|
||||
public async Task<InsuranceClientPrintViewModel> ClientPrintOne(long id)
|
||||
{
|
||||
var insurance = await _context.InsuranceListSet.FirstOrDefaultAsync(x => x.id == id);
|
||||
if (insurance == null)
|
||||
return null;
|
||||
var employeeInsurance = _context.EmployeeInsurancListDataSet.Where(x=>x.InsuranceListId == insurance.id);
|
||||
|
||||
var employeeIds =await employeeInsurance.Select(x=>x.EmployeeId).ToListAsync();
|
||||
var employees = await _context.Employees.Where(x => employeeIds.Contains(x.id)).ToListAsync();
|
||||
var jobIds = employeeInsurance.Select(x => x.JobId).ToList();
|
||||
var jobs = await _context.Jobs.Where(x => jobIds.Contains(x.id)).ToDictionaryAsync(x=>x.id,x=>x.JobName);
|
||||
|
||||
var employeeData = employeeInsurance.ToList().Select(x =>
|
||||
{
|
||||
var employee = employees.FirstOrDefault(e => e.id == x.EmployeeId);
|
||||
return new InsuranceClientPrintItemsViewModel()
|
||||
{
|
||||
BaseYears = x.BaseYears.ToMoney(),
|
||||
BenefitsIncludedContinuous = x.BenefitsIncludedContinuous.ToMoney(),
|
||||
BenefitsIncludedNonContinuous = x.BenefitsIncludedNonContinuous.ToMoney(),
|
||||
DailyWage = x.DailyWage.ToMoney(),
|
||||
IncludedAndNotIncluded = (x.BenefitsIncludedNonContinuous + x.BenefitsIncludedContinuous).ToMoney(),
|
||||
WorkingDays = x.WorkingDays.ToString(),
|
||||
MarriedAllowance = x.MarriedAllowance.ToMoney(),
|
||||
StartWork = x.StartWorkDate.ToFarsi(),
|
||||
LeftWork = x.LeftWorkDate.ToFarsi(),
|
||||
MonthlyBenefits = x.MonthlyBenefits.ToMoney(),
|
||||
MonthlySalary = x.MonthlySalary.ToMoney(),
|
||||
NationalCode = employee.NationalCode,
|
||||
InsuranceCode = employee.InsuranceCode,
|
||||
JobName = jobs.GetValueOrDefault(x.JobId, ""),
|
||||
FullName = employee.FullName,
|
||||
};
|
||||
}).ToList();
|
||||
|
||||
var result = new InsuranceClientPrintViewModel()
|
||||
{
|
||||
Items = employeeData.ToList(),
|
||||
AllInsuredShare = (insurance.InsuredShare +
|
||||
insurance.EmployerShare +
|
||||
insurance.UnEmploymentInsurance).ToMoney(),
|
||||
EmployerShare = insurance.EmployerShare.ToMoney(),
|
||||
InsuredShare = insurance.InsuredShare.ToMoney(),
|
||||
UnEmploymentInsurance = insurance.UnEmploymentInsurance.ToMoney(),
|
||||
};
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user