add insurance print api for client
This commit is contained in:
@@ -78,6 +78,7 @@ public interface IInsuranceListRepository:IRepository<long, InsuranceList>
|
||||
#endregion
|
||||
|
||||
Task<List<InsuranceListViewModel>> GetNotCreatedWorkshop(InsuranceListSearchModel searchModel);
|
||||
Task<InsuranceClientPrintViewModel> ClientPrintOne(long id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using _0_Framework.Application;
|
||||
using CompanyManagment.App.Contracts.InsuranceList;
|
||||
using CompanyManagment.App.Contracts.Workshop;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
@@ -96,6 +97,85 @@ public interface IInsuranceListApplication
|
||||
#endregion
|
||||
|
||||
Task<List<InsuranceListViewModel>> GetNotCreatedWorkshop(InsuranceListSearchModel searchModel);
|
||||
Task<InsuranceClientPrintViewModel> ClientPrintOne(long id);
|
||||
}
|
||||
|
||||
public class InsuranceClientPrintViewModel
|
||||
{
|
||||
public List<InsuranceClientPrintItemsViewModel> Items { get; set; }
|
||||
public string EmployerShare { get; set; }
|
||||
public string InsuredShare { get; set; }
|
||||
public string UnEmploymentInsurance { get; set; }
|
||||
public string AllInsuredShare { get; set; }
|
||||
}
|
||||
public class InsuranceClientPrintItemsViewModel
|
||||
{
|
||||
/// <summary>
|
||||
/// شماره بیمه
|
||||
/// </summary>
|
||||
public string InsuranceCode { get; set; }
|
||||
/// <summary>
|
||||
/// نام و نام خانوادگی
|
||||
/// </summary>
|
||||
public string FullName { get; set; }
|
||||
/// <summary>
|
||||
/// شغل
|
||||
/// </summary>
|
||||
public string JobName { get; set; }
|
||||
/// <summary>
|
||||
/// کد ملی
|
||||
/// </summary>
|
||||
public string NationalCode { get; set; }
|
||||
/// <summary>
|
||||
/// شروع به کار
|
||||
/// </summary>
|
||||
public string StartWork { get; set; }
|
||||
/// <summary>
|
||||
/// ترک کار
|
||||
/// </summary>
|
||||
public string LeftWork { get; set; }
|
||||
/// <summary>
|
||||
/// روزهای کارکرد
|
||||
/// </summary>
|
||||
public string WorkingDays { get; set; }
|
||||
/// <summary>
|
||||
/// دستمزد روزانه
|
||||
/// </summary>
|
||||
public string DailyWage { get; set; }
|
||||
/// <summary>
|
||||
/// پایه سنوات روزانه
|
||||
/// </summary>
|
||||
public string BaseYears { get; set; }
|
||||
/// <summary>
|
||||
/// دستمزد ماهانه
|
||||
/// </summary>
|
||||
public string MonthlySalary { get; set; }
|
||||
/// <summary>
|
||||
/// مزایای ماهیانه مشمول
|
||||
/// </summary>
|
||||
public string MonthlyBenefits { get; set; }
|
||||
/// <summary>
|
||||
/// حق تاهل
|
||||
/// </summary>
|
||||
public string MarriedAllowance { get; set; }
|
||||
/// <summary>
|
||||
/// حقوق و مزایای ماهیانه مشمول
|
||||
/// </summary>
|
||||
public string BenefitsIncludedContinuous { get; set; }
|
||||
/// <summary>
|
||||
/// حقوق و مزایای ماهیانه غیر مشمول
|
||||
/// </summary>
|
||||
public string BenefitsIncludedNonContinuous { get; set; }
|
||||
/// <summary>
|
||||
/// مجموع مزایای ماهیانه مشمول و غیر مشمول
|
||||
/// </summary>
|
||||
public string IncludedAndNotIncluded { get; set; }
|
||||
/// <summary>
|
||||
/// حق بیمه سهم بیمه شده
|
||||
/// </summary>
|
||||
public string EmployerShare { get; set; }
|
||||
|
||||
|
||||
}
|
||||
|
||||
public class InsuranceClientSearchModel:PaginationRequest
|
||||
|
||||
@@ -2381,5 +2381,10 @@ public class InsuranceListApplication : IInsuranceListApplication
|
||||
return await _insuranceListRepositpry.GetNotCreatedWorkshop(searchModel);
|
||||
}
|
||||
|
||||
public async Task<InsuranceClientPrintViewModel> ClientPrintOne(long id)
|
||||
{
|
||||
return await _insuranceListRepositpry.ClientPrintOne(id);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -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>
|
||||
|
||||
@@ -19,4 +19,15 @@ public class InsuranceController:ClientBaseController
|
||||
var insurances =await _insuranceListApplication.GetInsuranceClientList(searchModel);
|
||||
return Ok(insurances);
|
||||
}
|
||||
|
||||
[HttpGet("print-one")]
|
||||
public async Task<ActionResult<InsuranceClientPrintViewModel>> ClientPrintList(long id)
|
||||
{
|
||||
InsuranceClientPrintViewModel res = await _insuranceListApplication.ClientPrintOne(id);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
public class InsuranceClientViewModel
|
||||
{
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user