From 9cb42b7cef56bc9942b1b7dd67983bf1b46e53a3 Mon Sep 17 00:00:00 2001 From: SamSys Date: Mon, 22 Dec 2025 11:16:50 +0330 Subject: [PATCH 1/4] background job changed --- .../Jobs/JobSchedulerRegistrator.cs | 9 ++++-- .../NullBoardNotificationPublisher.cs | 10 ++++++ .../Program.cs | 3 +- .../InstitutionContractViewModel.cs | 2 ++ .../InstitutionContractRepository.cs | 32 +++++++++++++------ 5 files changed, 42 insertions(+), 14 deletions(-) create mode 100644 BackgroundInstitutionContract/BackgroundInstitutionContract.Task/NullBoardNotificationPublisher.cs diff --git a/BackgroundInstitutionContract/BackgroundInstitutionContract.Task/Jobs/JobSchedulerRegistrator.cs b/BackgroundInstitutionContract/BackgroundInstitutionContract.Task/Jobs/JobSchedulerRegistrator.cs index b97ff4f8..b4487ac7 100644 --- a/BackgroundInstitutionContract/BackgroundInstitutionContract.Task/Jobs/JobSchedulerRegistrator.cs +++ b/BackgroundInstitutionContract/BackgroundInstitutionContract.Task/Jobs/JobSchedulerRegistrator.cs @@ -1,5 +1,6 @@ using _0_Framework.Application; +using _0_Framework.Application.Sms; using Company.Domain.ContarctingPartyAgg; using Company.Domain.InstitutionContractAgg; using Hangfire; @@ -13,13 +14,15 @@ public class JobSchedulerRegistrator private readonly IInstitutionContractRepository _institutionContractRepository; private static DateTime? _lastRunCreateTransaction; private static DateTime? _lastRunSendMonthlySms; + private readonly ISmsService _smsService; - public JobSchedulerRegistrator(SmsReminder smsReminder, IBackgroundJobClient backgroundJobClient, IInstitutionContractRepository institutionContractRepository) + public JobSchedulerRegistrator(SmsReminder smsReminder, IBackgroundJobClient backgroundJobClient, IInstitutionContractRepository institutionContractRepository, ISmsService smsService) { _smsReminder = smsReminder; _backgroundJobClient = backgroundJobClient; _institutionContractRepository = institutionContractRepository; + _smsService = smsService; } public void Register() @@ -91,8 +94,8 @@ public class JobSchedulerRegistrator } catch (Exception e) { - //_smsService.Alarm("09114221321", "خطا-ایجاد سند مالی"); - + await _smsService.Alarm("09114221321", "خطا-ایجاد سند مالی"); + } } diff --git a/BackgroundInstitutionContract/BackgroundInstitutionContract.Task/NullBoardNotificationPublisher.cs b/BackgroundInstitutionContract/BackgroundInstitutionContract.Task/NullBoardNotificationPublisher.cs new file mode 100644 index 00000000..ddb1796b --- /dev/null +++ b/BackgroundInstitutionContract/BackgroundInstitutionContract.Task/NullBoardNotificationPublisher.cs @@ -0,0 +1,10 @@ +using GozareshgirProgramManager.Application.Interfaces; +using GozareshgirProgramManager.Domain.ProjectAgg.Enums; + +public class NullBoardNotificationPublisher:IBoardNotificationPublisher +{ + public Task SendProjectStatusChanged(long userId, TaskSectionStatus oldStatus, TaskSectionStatus newStatus, Guid sectionId) + { + throw new NotImplementedException(); + } +} \ No newline at end of file diff --git a/BackgroundInstitutionContract/BackgroundInstitutionContract.Task/Program.cs b/BackgroundInstitutionContract/BackgroundInstitutionContract.Task/Program.cs index 3cb83458..c08fcf29 100644 --- a/BackgroundInstitutionContract/BackgroundInstitutionContract.Task/Program.cs +++ b/BackgroundInstitutionContract/BackgroundInstitutionContract.Task/Program.cs @@ -8,6 +8,7 @@ using BackgroundInstitutionContract.Task.Jobs; using CompanyManagment.App.Contracts.Hubs; using CompanyManagment.EFCore.Services; using GozareshgirProgramManager.Application._Bootstrapper; +using GozareshgirProgramManager.Application.Interfaces; using GozareshgirProgramManager.Application.Modules.Users.Commands.CreateUser; using GozareshgirProgramManager.Infrastructure; using GozareshgirProgramManager.Infrastructure.Persistence.Seed; @@ -31,7 +32,7 @@ builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.Configure(builder.Configuration); - +builder.Services.AddScoped(); #region MongoDb var mongoConnectionSection = builder.Configuration.GetSection("MongoDb"); diff --git a/CompanyManagment.App.Contracts/InstitutionContract/InstitutionContractViewModel.cs b/CompanyManagment.App.Contracts/InstitutionContract/InstitutionContractViewModel.cs index 2b3032cc..1e7ee84c 100644 --- a/CompanyManagment.App.Contracts/InstitutionContract/InstitutionContractViewModel.cs +++ b/CompanyManagment.App.Contracts/InstitutionContract/InstitutionContractViewModel.cs @@ -76,5 +76,7 @@ public class InstitutionContractViewModel public bool IsInstallment { get; set; } public InstitutionContractVerificationStatus VerificationStatus { get; set; } + public InstitutionContractSigningType? SigningType { get; set; } + public List InstallmentList { get; set; } } \ No newline at end of file diff --git a/CompanyManagment.EFCore/Repository/InstitutionContractRepository.cs b/CompanyManagment.EFCore/Repository/InstitutionContractRepository.cs index af34b1b3..6ae60e32 100644 --- a/CompanyManagment.EFCore/Repository/InstitutionContractRepository.cs +++ b/CompanyManagment.EFCore/Repository/InstitutionContractRepository.cs @@ -4364,6 +4364,7 @@ public class InstitutionContractRepository : RepositoryBase new InstitutionContractInstallmentViewModel { AmountDouble = ins.Amount, InstallmentDateGr = ins.InstallmentDateGr }) .OrderBy(ins => ins.InstallmentDateGr).Skip(1).ToList(), }).Where(x => - x.ContractStartGr < endOfMonthGr && x.ContractEndGr >= endOfMonthGr && x.ContractAmountDouble > 0) + x.ContractStartGr < endOfMonthGr && x.ContractEndGr >= endOfMonthGr && x.ContractAmountDouble > 0 && x.VerificationStatus != InstitutionContractVerificationStatus.PendingForVerify) .ToListAsync(); #endregion @@ -4438,13 +4440,13 @@ public class InstitutionContractRepository : RepositoryBase futureContractIds = futureContracts.Select(x => x.ContractingPartyId).ToList(); List deatcivedContract = await _context.InstitutionContractSet .Where(x => x.IsActiveString == "false" && futureContractIds.Contains(x.ContractingPartyId) && - x.ContractEndGr.Date == endOfCurrentMonth.Date && x.ContractAmount > 0) + x.ContractEndGr.Date == endOfCurrentMonth.Date && x.ContractAmount > 0 && x.VerificationStatus != InstitutionContractVerificationStatus.PendingForVerify) .Select(x => new InstitutionContractViewModel { Id = x.id, @@ -4459,6 +4461,7 @@ public class InstitutionContractRepository : RepositoryBase new InstitutionContractInstallmentViewModel { AmountDouble = ins.Amount, InstallmentDateGr = ins.InstallmentDateGr }) @@ -4469,6 +4472,12 @@ public class InstitutionContractRepository : RepositoryBase + x.SigningType != InstitutionContractSigningType.Legacy && x.IsInstallment == false && x.SigningType != null).ToList(); + + //حذف قراداد هایی که یکجا پرداخت شده اند از لیست ایجاد سند ماهانه + institutionContracts = institutionContracts.Except(paidInFull).ToList(); #region RollCallServicCompute @@ -4516,8 +4525,7 @@ public class InstitutionContractRepository : RepositoryBase @@ -4551,8 +4559,7 @@ public class InstitutionContractRepository : RepositoryBase @@ -4579,12 +4586,17 @@ public class InstitutionContractRepository : RepositoryBase x.ContractingPartyId == item.ContractingPartyId) .Select(x => x.id).ToListAsync(); From 19a72ac78dc08148964a3f709d255f2c3a9fe562 Mon Sep 17 00:00:00 2001 From: SamSys Date: Mon, 22 Dec 2025 12:35:51 +0330 Subject: [PATCH 2/4] load data and create service percentage --- .../IPlanPercentageRepository.cs | 7 ++ .../InstitutionPlan/CreateServiceAmountDto.cs | 51 +++++++++++++++ .../IInstitutionPlanApplication.cs | 19 +++++- .../InstitutionPlanApplication.cs | 65 +++++++++++++++++++ .../Repository/PlanPercentageRepository.cs | 21 ++++++ .../Controllers/ServiceAmountsManagement.cs | 52 +++++++++++++++ 6 files changed, 213 insertions(+), 2 deletions(-) create mode 100644 CompanyManagment.App.Contracts/InstitutionPlan/CreateServiceAmountDto.cs create mode 100644 ServiceHost/Areas/Admin/Controllers/ServiceAmountsManagement.cs diff --git a/Company.Domain/InstitutionPlanAgg/IPlanPercentageRepository.cs b/Company.Domain/InstitutionPlanAgg/IPlanPercentageRepository.cs index b8406a4f..ad2575f3 100644 --- a/Company.Domain/InstitutionPlanAgg/IPlanPercentageRepository.cs +++ b/Company.Domain/InstitutionPlanAgg/IPlanPercentageRepository.cs @@ -2,6 +2,7 @@ using CompanyManagment.App.Contracts.InstitutionPlan; using CompanyManagment.App.Contracts.TemporaryClientRegistration; using System.Collections.Generic; +using System.Threading.Tasks; namespace Company.Domain.InstitutionPlanAgg; @@ -26,4 +27,10 @@ public interface IPlanPercentageRepository : IRepository /// /// InstitutionPlanViewModel GetInstitutionPlanForWorkshop(WorkshopTempViewModel command); + + /// + /// دریافت دیتای مودال ایجاد + /// + /// + Task GetCreateModalData(); } \ No newline at end of file diff --git a/CompanyManagment.App.Contracts/InstitutionPlan/CreateServiceAmountDto.cs b/CompanyManagment.App.Contracts/InstitutionPlan/CreateServiceAmountDto.cs new file mode 100644 index 00000000..6800b2f5 --- /dev/null +++ b/CompanyManagment.App.Contracts/InstitutionPlan/CreateServiceAmountDto.cs @@ -0,0 +1,51 @@ +namespace CompanyManagment.App.Contracts.InstitutionPlan; + +public class CreateServiceAmountDto +{ + /// + /// آی دی + /// + public long Id { get; set; } + + /// + /// قرارداد و تصفیه + /// درصد از مزد روزانه + /// string + /// + public string ContractAndCheckoutPercentStr { get; set; } + + /// + /// بیمه + /// درصد از مزد روزانه + /// string + /// + public string InsurancePercentStr { get; set; } + + /// + /// حضورغباب + /// درصد از مزد روزانه + /// string + /// + public string RollCallPercentStr { get; set; } + + /// + /// فیش غیر رسمی + /// درصد از مزد روزانه + /// string + /// + public string CustomizeCheckoutPercentStr { get; set; } + + /// + /// خدمات حضوری قرداد و تصفیه + /// درصد از مزد روزانه + /// string + /// + public string ContractAndCheckoutInPersonPercentStr { get; set; } + + /// + /// خدمات حضوری بیمه + /// درصد از مزد روزانه + /// string + /// + public string InsuranceInPersonPercentStr { get; set; } +} \ No newline at end of file diff --git a/CompanyManagment.App.Contracts/InstitutionPlan/IInstitutionPlanApplication.cs b/CompanyManagment.App.Contracts/InstitutionPlan/IInstitutionPlanApplication.cs index 2e2293c0..2eb91460 100644 --- a/CompanyManagment.App.Contracts/InstitutionPlan/IInstitutionPlanApplication.cs +++ b/CompanyManagment.App.Contracts/InstitutionPlan/IInstitutionPlanApplication.cs @@ -1,6 +1,7 @@ -using System.Collections.Generic; -using _0_Framework.Application; +using _0_Framework.Application; using CompanyManagment.App.Contracts.TemporaryClientRegistration; +using System.Collections.Generic; +using System.Threading.Tasks; namespace CompanyManagment.App.Contracts.InstitutionPlan; @@ -34,4 +35,18 @@ public interface IInstitutionPlanApplication /// /// InstitutionPlanViewModel GetInstitutionPlanForWorkshop(WorkshopTempViewModel command); + + + /// + /// دریافت دیتای درصد سرویس برای مودال ایجاد + /// + /// + Task GetCreateModalData(); + + /// + /// ایجاد درصد سرویس + /// + /// + /// + Task CreateInstitutionPlanPercentage(CreateServiceAmountDto command); } \ No newline at end of file diff --git a/CompanyManagment.Application/InstitutionPlanApplication.cs b/CompanyManagment.Application/InstitutionPlanApplication.cs index 6137c992..53e2f1f7 100644 --- a/CompanyManagment.Application/InstitutionPlanApplication.cs +++ b/CompanyManagment.Application/InstitutionPlanApplication.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Threading.Tasks; using _0_Framework.Application; using Company.Domain.InstitutionPlanAgg; using CompanyManagment.App.Contracts.InstitutionPlan; @@ -84,4 +85,68 @@ public class InstitutionPlanApplication : IInstitutionPlanApplication { return _planPercentageRepository.GetInstitutionPlanForWorkshop(command); } + + + #region ForApi + + public async Task GetCreateModalData() + { + return await _planPercentageRepository.GetCreateModalData(); + } + + + public async Task CreateInstitutionPlanPercentage(CreateServiceAmountDto command) + { + var op = new OperationResult(); + if (string.IsNullOrWhiteSpace(command.ContractAndCheckoutInPersonPercentStr) || command.ContractAndCheckoutInPersonPercentStr == "0" || + string.IsNullOrWhiteSpace(command.ContractAndCheckoutPercentStr) || (command.ContractAndCheckoutPercentStr == "0" || + string.IsNullOrWhiteSpace(command.CustomizeCheckoutPercentStr) || command.CustomizeCheckoutPercentStr == "0" || + string.IsNullOrWhiteSpace(command.InsuranceInPersonPercentStr) || command.InsuranceInPersonPercentStr == "0" || + string.IsNullOrWhiteSpace(command.InsurancePercentStr) || command.InsurancePercentStr == "0" || + string.IsNullOrWhiteSpace(command.RollCallPercentStr) || command.RollCallPercentStr == "0")) + return op.Failed("هیچ یک از فیلدها نمیتوانند صفر باشند"); + + int contractAndCheckoutInPersonPercent = 0; + int contractAndCheckoutPercent = 0; + int customizeCheckoutPercent = 0; + int insuranceInPersonPercent = 0; + int insurancePercent = 0; + int rollCallPercent = 0; + + try + { + contractAndCheckoutInPersonPercent = Convert.ToInt32(command.ContractAndCheckoutInPersonPercentStr); + contractAndCheckoutPercent = Convert.ToInt32(command.ContractAndCheckoutPercentStr); + customizeCheckoutPercent = Convert.ToInt32(command.CustomizeCheckoutPercentStr); + insuranceInPersonPercent = Convert.ToInt32(command.InsuranceInPersonPercentStr); + insurancePercent = Convert.ToInt32(command.InsurancePercentStr); + rollCallPercent = Convert.ToInt32(command.RollCallPercentStr); + } + catch (Exception e) + { + return op.Failed("لطفا عدد معتبر وارد کنید"); + + } + + var firstPlan =await _planPercentageRepository.GetCreateModalData(); + if (firstPlan != null) + { + var planPercentage = _planPercentageRepository.Get(firstPlan.Id); + planPercentage.Edit(contractAndCheckoutPercent, insurancePercent, rollCallPercent, customizeCheckoutPercent, contractAndCheckoutInPersonPercent, insuranceInPersonPercent); + _planPercentageRepository.SaveChanges(); + } + else + { + var create = new PlanPercentage(contractAndCheckoutPercent, insurancePercent, rollCallPercent, + customizeCheckoutPercent, contractAndCheckoutInPersonPercent, insuranceInPersonPercent); + await _planPercentageRepository.CreateAsync(create); + await _planPercentageRepository.SaveChangesAsync(); + } + + + + return op.Succcedded(); + } + + #endregion } \ No newline at end of file diff --git a/CompanyManagment.EFCore/Repository/PlanPercentageRepository.cs b/CompanyManagment.EFCore/Repository/PlanPercentageRepository.cs index 2657de37..91b2366b 100644 --- a/CompanyManagment.EFCore/Repository/PlanPercentageRepository.cs +++ b/CompanyManagment.EFCore/Repository/PlanPercentageRepository.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Threading.Tasks; using _0_Framework.Application; using _0_Framework.InfraStructure; using Company.Domain.InstitutionPlanAgg; @@ -44,6 +45,7 @@ public class PlanPercentageRepository : RepositoryBase, IP }).FirstOrDefault(); } + public List GetInstitutionPlanList(int pageIndex, int countPeron) { var planPercentage = _context.PlanPercentages.FirstOrDefault(); @@ -303,4 +305,23 @@ public class PlanPercentageRepository : RepositoryBase, IP return new InstitutionPlanViewModel(); } + + + #region ForApi + + public async Task GetCreateModalData() + { + return await _context.PlanPercentages.Select(x => new CreateServiceAmountDto() + { + Id = x.id, + ContractAndCheckoutInPersonPercentStr = $"{x.ContractAndCheckoutInPersonPercent}", + CustomizeCheckoutPercentStr = $"{x.CustomizeCheckoutPercent}", + ContractAndCheckoutPercentStr = $"{x.ContractAndCheckoutPercent}", + InsuranceInPersonPercentStr = $"{x.InsuranceInPersonPercent}", + InsurancePercentStr = $"{x.InsurancePercent}", + RollCallPercentStr = $"{x.RollCallPercent}", + }).FirstOrDefaultAsync(); + } + + #endregion } \ No newline at end of file diff --git a/ServiceHost/Areas/Admin/Controllers/ServiceAmountsManagement.cs b/ServiceHost/Areas/Admin/Controllers/ServiceAmountsManagement.cs new file mode 100644 index 00000000..edfc1416 --- /dev/null +++ b/ServiceHost/Areas/Admin/Controllers/ServiceAmountsManagement.cs @@ -0,0 +1,52 @@ +using _0_Framework.Application; +using AccountManagement.Application.Contracts.Ticket; +using CompanyManagment.App.Contracts.InstitutionPlan; +using CompanyManagment.App.Contracts.Workshop; +using Microsoft.AspNetCore.Mvc; +using ServiceHost.BaseControllers; + +namespace ServiceHost.Areas.Admin.Controllers; + +public class ServiceAmountsManagement : AdminBaseController +{ + private readonly IInstitutionPlanApplication _institutionPlanApplication; + private readonly IAuthHelper _authHelper; + + public ServiceAmountsManagement(IInstitutionPlanApplication institutionPlanApplication, IAuthHelper authHelper) + { + _institutionPlanApplication = institutionPlanApplication; + _authHelper = authHelper; + } + + + /// + /// دریافت دیتای مودال ایجاد + /// + /// + [HttpGet("GetCreateModalData")] + public async Task> GetCreateModalData() + { + if(!_authHelper.HasPermission(315)) + return Forbid(); + var data = await _institutionPlanApplication.GetCreateModalData(); + + return data; + } + + /// + /// ذخیره درصدها + /// + /// + /// + [HttpPost("CreateServicePercentage")] + public async Task> CreateServicePercentage([FromBody] CreateServiceAmountDto command) + { + + if (!_authHelper.HasPermission(315)) + return new OperationResult().Failed("اجازه دسترسی ندارید"); + + var result = await _institutionPlanApplication.CreateInstitutionPlanPercentage(command); + + return result; + } +} \ No newline at end of file From 82bf10c2d5d061c5790357f8074ae8c5d5c96c9e Mon Sep 17 00:00:00 2001 From: SamSys Date: Mon, 22 Dec 2025 14:21:01 +0330 Subject: [PATCH 3/4] ServiceAmount GetList --- .../IPlanPercentageRepository.cs | 11 ++- .../IInstitutionPlanApplication.cs | 9 ++ .../InstitutionPlan/InstitutionPlanListDto.cs | 84 ++++++++++++++++ .../InstitutionPlanSearchModel.cs | 11 +++ .../InstitutionPlanApplication.cs | 5 + .../Repository/PlanPercentageRepository.cs | 97 +++++++++++++++++-- .../Controllers/ServiceAmountsManagement.cs | 13 ++- 7 files changed, 222 insertions(+), 8 deletions(-) create mode 100644 CompanyManagment.App.Contracts/InstitutionPlan/InstitutionPlanListDto.cs create mode 100644 CompanyManagment.App.Contracts/InstitutionPlan/InstitutionPlanSearchModel.cs 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 edfc1416..bc0c6dcf 100644 --- a/ServiceHost/Areas/Admin/Controllers/ServiceAmountsManagement.cs +++ b/ServiceHost/Areas/Admin/Controllers/ServiceAmountsManagement.cs @@ -43,10 +43,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 From 934019c6c686f90ff1af9f51f2ab89e398e3529a Mon Sep 17 00:00:00 2001 From: SamSys Date: Mon, 22 Dec 2025 16:34:42 +0330 Subject: [PATCH 4/4] InsuranceNotCreated tab backend changed --- 0_Framework/Application/StaticWorkshopAccounts.cs | 11 +++++++++++ .../Repository/InsuranceListRepository.cs | 13 +++++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/0_Framework/Application/StaticWorkshopAccounts.cs b/0_Framework/Application/StaticWorkshopAccounts.cs index c42fa9bd..44491a69 100644 --- a/0_Framework/Application/StaticWorkshopAccounts.cs +++ b/0_Framework/Application/StaticWorkshopAccounts.cs @@ -39,4 +39,15 @@ public static class StaticWorkshopAccounts /// که کاربر همچنان به کارگاه دسترسی دارد /// public static DateTime ContinuesWorkingDate = new DateTime(2150, 1, 1); + + + /// + /// لیستی آی دی نقش هایی که مسئول بیمه کارگاه هستند + /// 7 : بیمه ارشد + /// 8 : بیمه ساده + /// + public static List InsuranceAccountsRoleIds = [7, 8]; + + + } \ No newline at end of file diff --git a/CompanyManagment.EFCore/Repository/InsuranceListRepository.cs b/CompanyManagment.EFCore/Repository/InsuranceListRepository.cs index da63d47b..727fe0a4 100644 --- a/CompanyManagment.EFCore/Repository/InsuranceListRepository.cs +++ b/CompanyManagment.EFCore/Repository/InsuranceListRepository.cs @@ -1820,19 +1820,24 @@ public class InsuranceListRepository : RepositoryBase, IIns return res; } - public async Task> GetNotCreatedWorkshop(InsuranceListSearchModel searchModel) + public async Task> GetNotCreatedWorkshop(InsuranceListSearchModel searchModel) { if (string.IsNullOrEmpty(searchModel.Month) || string.IsNullOrEmpty(searchModel.Year)) { return []; } + + var workshopsHasInsuranceAccount = await _accountContext + .AccountLeftWorks + .Where(x => StaticWorkshopAccounts.InsuranceAccountsRoleIds.Contains(x.RoleId) && x.IsActive) + .Select(x => x.WorkshopId).Distinct().ToListAsync(); var acountId = _authHelper.CurrentAccountId(); - var accountWorkshopIds = _context.WorkshopAccounts.Where(x => x.AccountId == acountId) + var accountWorkshopIds = _context.WorkshopAccounts.Where(x => x.AccountId == acountId && workshopsHasInsuranceAccount.Contains(x.WorkshopId)) .Select(x => x.WorkshopId); var firstDayOfMonth = $"{searchModel.Year}/{searchModel.Month}/01".ToGeorgianDateTime(); var insuranceWorkshops = _context.Workshops - .Where(x => x.InsuranceCode != null && x.InsuranceCode.Length >= 10 && accountWorkshopIds.Contains(x.id) && + .Where(x => accountWorkshopIds.Contains(x.id) && x.IsActiveString == "true"); @@ -1855,7 +1860,7 @@ public class InsuranceListRepository : RepositoryBase, IIns WorkShopId = result.id, WorkShopCode = result.InsuranceWorkshopInfo != null ? result.InsuranceWorkshopInfo.InsuranceCode - : result.InsuranceCode, + : string.IsNullOrWhiteSpace(result.InsuranceCode) ? "کد کارگاهی ندارد" : result.InsuranceCode, WorkShopName = result.InsuranceWorkshopInfo != null ? result.InsuranceWorkshopInfo.WorkshopName : result.WorkshopFullName,