From 3ce4cf3966b23586c0027e5fc196544e1dbd9db4 Mon Sep 17 00:00:00 2001 From: mahan Date: Thu, 18 Dec 2025 13:34:31 +0330 Subject: [PATCH] add insurance print api for client --- .../IInsuranceListRepository.cs | 1 + .../IInsuranceListApplication.cs | 80 +++++++++++++++++++ .../InsuranceListApplication.cs | 5 ++ .../Repository/InsuranceListRepository.cs | 48 +++++++++++ .../Client/Controllers/InsuranceController.cs | 11 +++ 5 files changed, 145 insertions(+) diff --git a/Company.Domain/InsuranceListAgg/IInsuranceListRepository.cs b/Company.Domain/InsuranceListAgg/IInsuranceListRepository.cs index b8b95235..93d9f588 100644 --- a/Company.Domain/InsuranceListAgg/IInsuranceListRepository.cs +++ b/Company.Domain/InsuranceListAgg/IInsuranceListRepository.cs @@ -78,6 +78,7 @@ public interface IInsuranceListRepository:IRepository #endregion Task> GetNotCreatedWorkshop(InsuranceListSearchModel searchModel); + Task ClientPrintOne(long id); } diff --git a/CompanyManagment.App.Contracts/InsuranceList/IInsuranceListApplication.cs b/CompanyManagment.App.Contracts/InsuranceList/IInsuranceListApplication.cs index 1a36dafb..7896a271 100644 --- a/CompanyManagment.App.Contracts/InsuranceList/IInsuranceListApplication.cs +++ b/CompanyManagment.App.Contracts/InsuranceList/IInsuranceListApplication.cs @@ -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> GetNotCreatedWorkshop(InsuranceListSearchModel searchModel); + Task ClientPrintOne(long id); +} + +public class InsuranceClientPrintViewModel +{ + public List 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 +{ + /// + /// شماره بیمه + /// + public string InsuranceCode { get; set; } + /// + /// نام و نام خانوادگی + /// + public string FullName { get; set; } + /// + /// شغل + /// + public string JobName { get; set; } + /// + /// کد ملی + /// + public string NationalCode { get; set; } + /// + /// شروع به کار + /// + public string StartWork { get; set; } + /// + /// ترک کار + /// + public string LeftWork { get; set; } + /// + /// روزهای کارکرد + /// + public string WorkingDays { get; set; } + /// + /// دستمزد روزانه + /// + public string DailyWage { get; set; } + /// + /// پایه سنوات روزانه + /// + public string BaseYears { get; set; } + /// + /// دستمزد ماهانه + /// + public string MonthlySalary { get; set; } + /// + /// مزایای ماهیانه مشمول + /// + public string MonthlyBenefits { get; set; } + /// + /// حق تاهل + /// + public string MarriedAllowance { get; set; } + /// + /// حقوق و مزایای ماهیانه مشمول + /// + public string BenefitsIncludedContinuous { get; set; } + /// + /// حقوق و مزایای ماهیانه غیر مشمول + /// + public string BenefitsIncludedNonContinuous { get; set; } + /// + /// مجموع مزایای ماهیانه مشمول و غیر مشمول + /// + public string IncludedAndNotIncluded { get; set; } + /// + /// حق بیمه سهم بیمه شده + /// + public string EmployerShare { get; set; } + + } public class InsuranceClientSearchModel:PaginationRequest diff --git a/CompanyManagment.Application/InsuranceListApplication.cs b/CompanyManagment.Application/InsuranceListApplication.cs index 5a3c5fb0..d0fbb990 100644 --- a/CompanyManagment.Application/InsuranceListApplication.cs +++ b/CompanyManagment.Application/InsuranceListApplication.cs @@ -2381,5 +2381,10 @@ public class InsuranceListApplication : IInsuranceListApplication return await _insuranceListRepositpry.GetNotCreatedWorkshop(searchModel); } + public async Task ClientPrintOne(long id) + { + return await _insuranceListRepositpry.ClientPrintOne(id); + } + #endregion } \ No newline at end of file diff --git a/CompanyManagment.EFCore/Repository/InsuranceListRepository.cs b/CompanyManagment.EFCore/Repository/InsuranceListRepository.cs index da63d47b..0836a912 100644 --- a/CompanyManagment.EFCore/Repository/InsuranceListRepository.cs +++ b/CompanyManagment.EFCore/Repository/InsuranceListRepository.cs @@ -1960,6 +1960,54 @@ public class InsuranceListRepository : RepositoryBase, IIns return res; } + public async Task 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; + } + /// /// /// diff --git a/ServiceHost/Areas/Client/Controllers/InsuranceController.cs b/ServiceHost/Areas/Client/Controllers/InsuranceController.cs index 00f8ee06..8c991778 100644 --- a/ServiceHost/Areas/Client/Controllers/InsuranceController.cs +++ b/ServiceHost/Areas/Client/Controllers/InsuranceController.cs @@ -19,4 +19,15 @@ public class InsuranceController:ClientBaseController var insurances =await _insuranceListApplication.GetInsuranceClientList(searchModel); return Ok(insurances); } + + [HttpGet("print-one")] + public async Task> ClientPrintList(long id) + { + InsuranceClientPrintViewModel res = await _insuranceListApplication.ClientPrintOne(id); + return res; + } +} + +public class InsuranceClientViewModel +{ }