diff --git a/Company.Domain/InstitutionPlanAgg/IPlanPercentageRepository.cs b/Company.Domain/InstitutionPlanAgg/IPlanPercentageRepository.cs index ad2575f3..9395f968 100644 --- a/Company.Domain/InstitutionPlanAgg/IPlanPercentageRepository.cs +++ b/Company.Domain/InstitutionPlanAgg/IPlanPercentageRepository.cs @@ -1,4 +1,5 @@ -using _0_Framework.Domain; +using _0_Framework.Application; +using _0_Framework.Domain; using CompanyManagment.App.Contracts.InstitutionPlan; using CompanyManagment.App.Contracts.TemporaryClientRegistration; using System.Collections.Generic; @@ -33,4 +34,12 @@ public interface IPlanPercentageRepository : IRepository /// /// Task GetCreateModalData(); + + /// + /// دریافت لیست مبالغ سرویس ها + /// + /// + /// + Task> GetList( + InstitutionPlanSearchModel searchModel); } \ No newline at end of file diff --git a/CompanyManagment.App.Contracts/InstitutionPlan/IInstitutionPlanApplication.cs b/CompanyManagment.App.Contracts/InstitutionPlan/IInstitutionPlanApplication.cs index 2eb91460..0a359530 100644 --- a/CompanyManagment.App.Contracts/InstitutionPlan/IInstitutionPlanApplication.cs +++ b/CompanyManagment.App.Contracts/InstitutionPlan/IInstitutionPlanApplication.cs @@ -49,4 +49,13 @@ public interface IInstitutionPlanApplication /// /// Task CreateInstitutionPlanPercentage(CreateServiceAmountDto command); + + + /// + /// دریافت لیست مبالغ سرویس ها + /// + /// + /// + Task> GetList( + InstitutionPlanSearchModel searchModel); } \ No newline at end of file diff --git a/CompanyManagment.App.Contracts/InstitutionPlan/InstitutionPlanListDto.cs b/CompanyManagment.App.Contracts/InstitutionPlan/InstitutionPlanListDto.cs new file mode 100644 index 00000000..d8d9f389 --- /dev/null +++ b/CompanyManagment.App.Contracts/InstitutionPlan/InstitutionPlanListDto.cs @@ -0,0 +1,84 @@ +namespace CompanyManagment.App.Contracts.InstitutionPlan; + +public class InstitutionPlanListDto +{ + + + /// + /// تعداد پرسنل + /// + public int CountPerson { get; set; } + + /// + /// مبلغ قرارداد و تصفیه + /// + public string ContractAndCheckout { get; set; } + + /// + /// مبلغ بیمه + /// + public string Insurance { get; set; } + + /// + /// مبلغ حضورغباب + /// + public string RollCall { get; set; } + + /// + /// مبلغ فیش غیر رسمی + /// + public string CustomizeCheckout { get; set; } + + /// + /// مبلغ خدمات حضوری قرداد و تصفیه + /// + public string ContractAndCheckoutInPerson { get; set; } + + /// + /// مبلغ خدمات حضوری بیمه + /// + public string InsuranceInPerson { get; set; } + + + + + #region Total + + + /// + /// مبلغ کل خدمات حضوری + /// + public string InPersonSumAmountStr { get; set; } + + /// + /// مبلغ کل خدمات آنلاین + /// + public string OnlineOnlySumAmountStr { get; set; } + + /// + /// مبلغ کل خدمات حضوری و آنلاین + /// + public string OnlineAndInPersonSumAmountStr { get; set; } + + /// + /// مبلغ کل خدمات حضوری و آنلاین + /// double + /// + public double OnlineAndInPersonSumAmountDouble { get; set; } + + + /// + /// مبلغ کل خدمات حضوری + /// double + /// + public double InPersonSumAmountDouble { get; set; } + + /// + /// مبلغ کل خدمات آنلاین + /// double + /// + public double OnlineOnlySumAmountDouble { get; set; } + + + #endregion +} \ No newline at end of file diff --git a/CompanyManagment.App.Contracts/InstitutionPlan/InstitutionPlanSearchModel.cs b/CompanyManagment.App.Contracts/InstitutionPlan/InstitutionPlanSearchModel.cs new file mode 100644 index 00000000..34e5d347 --- /dev/null +++ b/CompanyManagment.App.Contracts/InstitutionPlan/InstitutionPlanSearchModel.cs @@ -0,0 +1,11 @@ +using _0_Framework.Application; + +namespace CompanyManagment.App.Contracts.InstitutionPlan; + +public class InstitutionPlanSearchModel : PaginationRequest +{ + /// + /// تعدلد پرسنل برای جستجو + /// + public int CountPeron { get; set; } +} \ No newline at end of file diff --git a/CompanyManagment.Application/InstitutionPlanApplication.cs b/CompanyManagment.Application/InstitutionPlanApplication.cs index 53e2f1f7..2b4aba06 100644 --- a/CompanyManagment.Application/InstitutionPlanApplication.cs +++ b/CompanyManagment.Application/InstitutionPlanApplication.cs @@ -148,5 +148,10 @@ public class InstitutionPlanApplication : IInstitutionPlanApplication return op.Succcedded(); } + public async Task> GetList(InstitutionPlanSearchModel searchModel) + { + return await _planPercentageRepository.GetList(searchModel); + } + #endregion } \ No newline at end of file diff --git a/CompanyManagment.EFCore/Repository/PlanPercentageRepository.cs b/CompanyManagment.EFCore/Repository/PlanPercentageRepository.cs index 91b2366b..b5b6db6b 100644 --- a/CompanyManagment.EFCore/Repository/PlanPercentageRepository.cs +++ b/CompanyManagment.EFCore/Repository/PlanPercentageRepository.cs @@ -1,13 +1,14 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using _0_Framework.Application; +using _0_Framework.Application; using _0_Framework.InfraStructure; using Company.Domain.InstitutionPlanAgg; +using CompanyManagment.App.Contracts.InstitutionContract; using CompanyManagment.App.Contracts.InstitutionPlan; using CompanyManagment.App.Contracts.TemporaryClientRegistration; using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; namespace CompanyManagment.EFCore.Repository; @@ -45,7 +46,7 @@ public class PlanPercentageRepository : RepositoryBase, IP }).FirstOrDefault(); } - + public List GetInstitutionPlanList(int pageIndex, int countPeron) { var planPercentage = _context.PlanPercentages.FirstOrDefault(); @@ -323,5 +324,89 @@ public class PlanPercentageRepository : RepositoryBase, IP }).FirstOrDefaultAsync(); } + + public async Task> GetList( + InstitutionPlanSearchModel searchModel) + { + var planPercentage = await _context.PlanPercentages.FirstOrDefaultAsync(); + if (planPercentage == null) + return new PagedResult(); + var dailyWageYearlySalery = await _context.YearlySalaries.Include(i => i.YearlySalaryItemsList).FirstOrDefaultAsync(x => + x.StartDate.Date <= DateTime.Now.Date && x.EndDate >= DateTime.Now.Date); + if (dailyWageYearlySalery == null) + return new PagedResult(); + + var dailyWage = dailyWageYearlySalery.YearlySalaryItemsList.Where(x => x.ItemName == "مزد روزانه") + .Select(x => x.ItemValue).FirstOrDefault(); + + var plans = _context.InstitutionPlans.AsQueryable(); + if (searchModel.CountPeron > 0) + plans = plans.Where(x => x.CountPerson == searchModel.CountPeron); + + var planQueryFilter =await plans.ApplyPagination(searchModel.PageIndex, searchModel.PageSize).ToListAsync(); + var planResult = planQueryFilter.Select(plan => + new InstitutionPlanViewModel + { + CountPerson = plan.CountPerson, + + ContractAndCheckoutDouble = + ((dailyWage * planPercentage.ContractAndCheckoutPercent / 100) * plan.CountPerson * + plan.IncreasePercentage), + + InsuranceDouble = (((dailyWage * planPercentage.InsurancePercent) / 100) * plan.CountPerson * + plan.IncreasePercentage), + + RollCallDouble = (((dailyWage * planPercentage.RollCallPercent) / 100) * plan.CountPerson * + plan.IncreasePercentage), + + CustomizeCheckoutDouble = (((dailyWage * planPercentage.CustomizeCheckoutPercent) / 100) * + plan.CountPerson * + plan.IncreasePercentage), + + ContractAndCheckoutInPersonDouble = + (((dailyWage * planPercentage.ContractAndCheckoutInPersonPercent) / 100) * plan.CountPerson * + plan.IncreasePercentage), + + InsuranceInPersonDouble = (((dailyWage * planPercentage.InsuranceInPersonPercent) / 100) * + plan.CountPerson * + plan.IncreasePercentage) + }).ToList(); + + var finalResult = planResult.Select(plan => new InstitutionPlanListDto() + { + CountPerson = plan.CountPerson, + + ContractAndCheckout = plan.ContractAndCheckoutDouble.ToMoney(), + + Insurance = plan.InsuranceDouble.ToMoney(), + + RollCall = plan.RollCallDouble.ToMoney(), + + CustomizeCheckout = plan.CustomizeCheckoutDouble.ToMoney(), + + ContractAndCheckoutInPerson = plan.ContractAndCheckoutInPersonDouble.ToMoney(), + + InsuranceInPerson = plan.InsuranceInPersonDouble.ToMoney(), + + InPersonSumAmountStr = + (plan.ContractAndCheckoutDouble + plan.InsuranceDouble + plan.ContractAndCheckoutInPersonDouble + + plan.InsuranceInPersonDouble).ToMoney(), + + OnlineAndInPersonSumAmountStr = (plan.ContractAndCheckoutDouble + plan.InsuranceDouble + + plan.ContractAndCheckoutInPersonDouble + plan.InsuranceInPersonDouble + + plan.RollCallDouble + plan.CustomizeCheckoutDouble).ToMoney(), + + OnlineOnlySumAmountStr = + (plan.ContractAndCheckoutDouble + plan.InsuranceDouble + plan.RollCallDouble + + plan.CustomizeCheckoutDouble).ToMoney(), + }).ToList(); + + return new PagedResult() + { + TotalCount = finalResult.Count, + List = finalResult + }; + + } #endregion } \ No newline at end of file diff --git a/ServiceHost/Areas/Admin/Controllers/ServiceAmountsManagement.cs b/ServiceHost/Areas/Admin/Controllers/ServiceAmountsManagement.cs index 81e32e2b..d8bbc852 100644 --- a/ServiceHost/Areas/Admin/Controllers/ServiceAmountsManagement.cs +++ b/ServiceHost/Areas/Admin/Controllers/ServiceAmountsManagement.cs @@ -44,13 +44,21 @@ public class ServiceAmountsManagement : AdminBaseController { if (!_authHelper.HasPermission(315)) - return new OperationResult().Failed("اجازه دسترسی ندارید"); + return Forbid(); var result = await _institutionPlanApplication.CreateInstitutionPlanPercentage(command); return result; } - - + /// + /// دریافت لیست مبالغ سرویس ها + /// + /// + /// + [HttpGet("GetList")] + public async Task>> GetList(InstitutionPlanSearchModel searchModel) + { + return await _institutionPlanApplication.GetList(searchModel); + } } \ No newline at end of file