From 4a3ac6e096a4e440104cd1026e9101afacf010c3 Mon Sep 17 00:00:00 2001 From: mahan Date: Wed, 8 Oct 2025 11:31:44 +0330 Subject: [PATCH] add workshops and plan amounts handling in InstitutionContractExtenstionTemp and update related services --- .../InstitutionContractExtenstionTemp.cs | 115 ++++++++++++++++++ .../CreateWorkshopTemp.cs | 1 + .../InstitutionContractRepository.cs | 51 ++++++-- 3 files changed, 157 insertions(+), 10 deletions(-) diff --git a/Company.Domain/InstitutionContractInsertTempAgg/InstitutionContractExtenstionTemp.cs b/Company.Domain/InstitutionContractInsertTempAgg/InstitutionContractExtenstionTemp.cs index d6170528..eb2767d1 100644 --- a/Company.Domain/InstitutionContractInsertTempAgg/InstitutionContractExtenstionTemp.cs +++ b/Company.Domain/InstitutionContractInsertTempAgg/InstitutionContractExtenstionTemp.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using CompanyManagment.App.Contracts.InstitutionContract; using CompanyManagment.App.Contracts.InstitutionContractContactinfo; using MongoDB.Bson; using MongoDB.Bson.Serialization.Attributes; @@ -23,6 +24,17 @@ public class InstitutionContractExtenstionTemp public string Province { get; set; } public List ContactInfos { get; set; } + public List Workshops { get; set; } + + public InstitutionContractExtensionPlanDetail OneMonth { get; set; } + public InstitutionContractExtensionPlanDetail ThreeMonths { get; set; } + public InstitutionContractExtensionPlanDetail SixMonths { get; set; } + public InstitutionContractExtensionPlanDetail TwelveMonths { get; set; } + + public bool HasContractInPerson { get; set; } + + public InstitutionContractDuration? Duration { get; set; } + public void SetContractingPartyInfos(string address, string city, string province, List contactInfos) { Address = address; @@ -30,5 +42,108 @@ public class InstitutionContractExtenstionTemp Province = province; ContactInfos = contactInfos; } + + public void SetWorkshopsAndPlanAmounts(List workshops, + InstitutionContractExtensionPlanDetail oneMonth, + InstitutionContractExtensionPlanDetail threeMonth, InstitutionContractExtensionPlanDetail sixMonth, + InstitutionContractExtensionPlanDetail twelveMonth, bool hasContractInPerson) + { + Workshops = workshops; + OneMonth = oneMonth; + ThreeMonths = threeMonth; + SixMonths = sixMonth; + TwelveMonths = twelveMonth; + HasContractInPerson = hasContractInPerson; + } } +public class InstitutionContractExtenstionTempPlan +{ + public InstitutionContractExtenstionTempPlan(string contractStart, string contractEnd, string oneMonthPaymentDiscounted, string oneMonthDiscount, string oneMonthOriginalPayment, string totalPayment, string dailyCompenseation, string obligation) + { + ContractStart = contractStart; + ContractEnd = contractEnd; + OneMonthPaymentDiscounted = oneMonthPaymentDiscounted; + OneMonthDiscount = oneMonthDiscount; + OneMonthOriginalPayment = oneMonthOriginalPayment; + TotalPayment = totalPayment; + DailyCompenseation = dailyCompenseation; + Obligation = obligation; + } + + public string ContractStart { get; set; } + public string ContractEnd { get; set; } + public string OneMonthPaymentDiscounted { get; set; } + public string OneMonthDiscount { get; set; } + public string OneMonthOriginalPayment { get; set; } + public string TotalPayment { get; set; } + public string DailyCompenseation { get; set; } + public string Obligation { get; set; } +} + +public class InstitutionContractExtenstionTempWorkshop +{ + public InstitutionContractExtenstionTempWorkshop(string workshopName, int countPerson, bool contractAndCheckout, bool contractAndCheckoutInPerson, + bool insurance, bool insuranceInPerson, + bool rollCall,bool rollCallInPerson, bool customizeCheckout) + { + WorkshopName = workshopName; + CountPerson = countPerson; + ContractAndCheckout = contractAndCheckout; + Insurance = insurance; + RollCall = rollCall; + CustomizeCheckout = customizeCheckout; + ContractAndCheckoutInPerson = contractAndCheckoutInPerson; + InsuranceInPerson = insuranceInPerson; + RollCallInPerson = rollCallInPerson; + } + + /// + /// نام کارگاه + /// + public string WorkshopName { get; private set; } + + /// + /// تعداد پرسنل + /// + public int CountPerson { get; private set; } + + + #region ServiceSelection + + /// + /// قرارداد و تصفیه + /// + public bool ContractAndCheckout { get; private set; } + + /// + /// بیمه + /// + public bool Insurance { get; private set; } + + /// + /// حضورغباب + /// + public bool RollCall { get; private set; } + + public bool RollCallInPerson { get; set; } + + /// + /// فیش غیر رسمی + /// + public bool CustomizeCheckout { get;private set; } + + /// + /// خدمات حضوری قرداد و تصفیه + /// + public bool ContractAndCheckoutInPerson { get; private set; } + + /// + /// خدمات حضوری بیمه + /// + public bool InsuranceInPerson { get; private set; } + + #endregion +} + + diff --git a/CompanyManagment.App.Contracts/TemporaryClientRegistration/CreateWorkshopTemp.cs b/CompanyManagment.App.Contracts/TemporaryClientRegistration/CreateWorkshopTemp.cs index e8cbf9f2..83e3b675 100644 --- a/CompanyManagment.App.Contracts/TemporaryClientRegistration/CreateWorkshopTemp.cs +++ b/CompanyManagment.App.Contracts/TemporaryClientRegistration/CreateWorkshopTemp.cs @@ -33,6 +33,7 @@ public class CreateWorkshopTemp /// حضورغباب /// public bool RollCall { get; set; } + public bool RollCallInPerson { get; set; } /// /// فیش غیر رسمی diff --git a/CompanyManagment.EFCore/Repository/InstitutionContractRepository.cs b/CompanyManagment.EFCore/Repository/InstitutionContractRepository.cs index 5f18b1a6..e7e720f0 100644 --- a/CompanyManagment.EFCore/Repository/InstitutionContractRepository.cs +++ b/CompanyManagment.EFCore/Repository/InstitutionContractRepository.cs @@ -16,6 +16,7 @@ using Company.Domain.FinancialStatmentAgg; using Company.Domain.FinancialTransactionAgg; using Company.Domain.InstitutionContractAgg; using Company.Domain.InstitutionContractInsertTempAgg; +using Company.Domain.InstitutionPlanAgg; using Company.Domain.WorkshopAgg; using CompanyManagment.App.Contracts.Employer; using CompanyManagment.App.Contracts.InstitutionContract; @@ -39,13 +40,15 @@ public class InstitutionContractRepository : RepositoryBase _institutionExtensionTemp; + private readonly IPlanPercentageRepository _planPercentageRepository; public InstitutionContractRepository(CompanyContext context, IEmployerRepository employerRepository, - IWorkshopRepository workshopRepository, IMongoDatabase database) : base(context) + IWorkshopRepository workshopRepository, IMongoDatabase database, IPlanPercentageRepository planPercentageRepository) : base(context) { _context = context; _employerRepository = employerRepository; _workshopRepository = workshopRepository; + _planPercentageRepository = planPercentageRepository; _institutionExtensionTemp = database.GetCollection("InstitutionContractExtenstionTemp"); } @@ -1918,7 +1921,7 @@ public class InstitutionContractRepository : RepositoryBase x.Id == extenstionTemp.Id, @@ -1931,19 +1934,38 @@ public class InstitutionContractRepository : RepositoryBase { var workshop = workshops.FirstOrDefault(w=>w.id == x.WorkshopId); + var service = x.Services; + var price = x.Price; + if (x.Price == 0) + { + var command = new WorkshopTempViewModel() + { + ContractAndCheckout = service.Contract, + ContractAndCheckoutInPerson = service.ContractInPerson, + CountPerson = x.PersonnelCount, + CustomizeCheckout = service.CustomizeCheckout, + Insurance = service.Insurance, + InsuranceInPerson = service.InsuranceInPerson, + RollCall = service.RollCall, + WorkshopName = x.WorkshopName + }; + var institutionPlanForWorkshop = _planPercentageRepository.GetInstitutionPlanForWorkshop(command); + price = institutionPlanForWorkshop.OnlineAndInPersonSumAmountDouble; + + } return new WorkshopTempViewModel() { Id = x.id, - ContractAndCheckout = x.Services.Contract, - ContractAndCheckoutInPerson = x.Services.ContractInPerson, - CustomizeCheckout = x.Services.ContractInPerson, + ContractAndCheckout = service.Contract, + ContractAndCheckoutInPerson = service.ContractInPerson, + CustomizeCheckout = service.ContractInPerson, CountPerson = x.PersonnelCount, - Insurance = x.Services.Insurance, - InsuranceInPerson = x.Services.InsuranceInPerson, - RollCall = x.Services.RollCall, + Insurance = service.Insurance, + InsuranceInPerson = service.InsuranceInPerson, + RollCall = service.RollCall, WorkshopName = workshop?.WorkshopName??"فاقد کارگاه", - WorkshopServicesAmount = x.Price, - WorkshopServicesAmountStr = x.Price.ToMoney() + WorkshopServicesAmount = price, + WorkshopServicesAmountStr = price.ToMoney() }; }).ToList(); var res = new InstitutionContractExtensionWorkshopsResponse() @@ -1989,6 +2011,15 @@ public class InstitutionContractRepository : RepositoryBase new InstitutionContractExtenstionTempWorkshop(x.WorkshopName,x.CountPerson,x.ContractAndCheckout, + x.ContractAndCheckoutInPerson,x.Insurance,x.InsuranceInPerson,x.RollCall,x.RollCall,x.RollCallInPerson)).ToList(); + + institutionTemp.SetWorkshopsAndPlanAmounts(workshops,res.OneMonth,res.ThreeMonths,res.SixMonths,res.TwelveMonths, hasInPerson); + + await _institutionExtensionTemp.ReplaceOneAsync(x=>x.Id == institutionTemp.Id, institutionTemp); + return res; }