From e6977b29fc8dc79a2d42df1779d0b863a1cbfc83 Mon Sep 17 00:00:00 2001 From: mahan Date: Sun, 26 Oct 2025 14:00:03 +0330 Subject: [PATCH] feat: add methods for creating institution contract amendment changes and enhance personnel count handling --- .../InstitutionContract.cs | 81 ++++++++++++++++++- .../InstitutionContractRepository.cs | 30 +++---- .../institutionContractController.cs | 21 +++++ 3 files changed, 110 insertions(+), 22 deletions(-) diff --git a/Company.Domain/InstitutionContractAgg/InstitutionContract.cs b/Company.Domain/InstitutionContractAgg/InstitutionContract.cs index 7d9fbdb5..78caa1ce 100644 --- a/Company.Domain/InstitutionContractAgg/InstitutionContract.cs +++ b/Company.Domain/InstitutionContractAgg/InstitutionContract.cs @@ -311,11 +311,12 @@ public class InstitutionContractAmendment : EntityBase public class InstitutionContractAmendmentChange : EntityBase { private InstitutionContractAmendmentChange() { } - public InstitutionContractAmendmentChange(InstitutionContractAmendmentChangeType changeType, + + private InstitutionContractAmendmentChange(InstitutionContractAmendmentChangeType changeType, DateTime changeDateGr, bool? hasCustomizeCheckoutPlan, bool? hasContractPlan, bool? hasContractPlanInPerson, bool? hasInsurancePlan, bool? hasInsurancePlanInPerson, int? personnelCount, bool? hasRollCallPlan, bool? hasRollCallInPerson, - long? currentWorkshopId) + long? currentWorkshopId, int personnelCountDifference) { ChangeType = changeType; ChangeDateGr = changeDateGr; @@ -326,10 +327,80 @@ public class InstitutionContractAmendmentChange : EntityBase HasInsurancePlan = hasInsurancePlan; HasInsurancePlanInPerson = hasInsurancePlanInPerson; PersonnelCount = personnelCount; + PersonnelCountDifference = personnelCountDifference; CurrentWorkshopId = currentWorkshopId; HasRollCallInPerson = hasRollCallInPerson; } + /// + /// تغییر تعداد پرسنل + /// + public static InstitutionContractAmendmentChange CreatePersonCountChange( + DateTime changeDateGr, int personnelCount, int personnelCountDifference, + long currentWorkshopId) + { + return new InstitutionContractAmendmentChange( + changeType: InstitutionContractAmendmentChangeType.PersonCount, + changeDateGr: changeDateGr, + hasCustomizeCheckoutPlan: null, + hasContractPlan: null, + hasContractPlanInPerson: null, + hasInsurancePlan: null, + hasInsurancePlanInPerson: null, + personnelCount: personnelCount, + hasRollCallPlan: null, + hasRollCallInPerson: null, + currentWorkshopId: currentWorkshopId, + personnelCountDifference: personnelCountDifference); + } + + /// + /// تغییر خدمات + /// + public static InstitutionContractAmendmentChange CreateServicesChange( + DateTime changeDateGr, long currentWorkshopId, bool hasRollCallPlan, bool hasRollCallInPerson, + bool hasCustomizeCheckoutPlan, bool hasContractPlan, bool hasContractPlanInPerson, + bool hasInsurancePlan, bool hasInsurancePlanInPerson) + { + return new InstitutionContractAmendmentChange( + changeType: InstitutionContractAmendmentChangeType.Services, + changeDateGr: changeDateGr, + hasCustomizeCheckoutPlan: hasCustomizeCheckoutPlan, + hasContractPlan: hasContractPlan, + hasContractPlanInPerson: hasContractPlanInPerson, + hasInsurancePlan: hasInsurancePlan, + hasInsurancePlanInPerson: hasInsurancePlanInPerson, + personnelCount: null, + hasRollCallPlan: hasRollCallPlan, + hasRollCallInPerson: hasRollCallInPerson, + currentWorkshopId: currentWorkshopId, + personnelCountDifference: 0); + } + + /// + /// ایجاد کارگاه جدید + /// + public static InstitutionContractAmendmentChange CreateWorkshopCreatedChange( + DateTime changeDateGr, bool hasRollCallPlan, bool hasRollCallInPerson, + bool hasCustomizeCheckoutPlan, bool hasContractPlan, bool hasContractPlanInPerson, + bool hasInsurancePlan, bool hasInsurancePlanInPerson,int personnelCount) + { + return new InstitutionContractAmendmentChange( + changeType: InstitutionContractAmendmentChangeType.WorkshopCreated, + changeDateGr: changeDateGr, + hasCustomizeCheckoutPlan: hasCustomizeCheckoutPlan, + hasContractPlan: hasContractPlan, + hasContractPlanInPerson: hasContractPlanInPerson, + hasInsurancePlan: hasInsurancePlan, + hasInsurancePlanInPerson: hasInsurancePlanInPerson, + personnelCount: personnelCount, + hasRollCallPlan: hasRollCallPlan, + hasRollCallInPerson: hasRollCallInPerson, + currentWorkshopId: null, + personnelCountDifference: 0); + } + + public long InstitutionContractAmendmentId { get; private set; } public InstitutionContractAmendment InstitutionContractAmendment { get; private set; } public InstitutionContractAmendmentChangeType ChangeType { get; private set; } @@ -371,6 +442,12 @@ public class InstitutionContractAmendmentChange : EntityBase /// تعداد پرسنل /// public int? PersonnelCount { get; private set; } + + /// + /// مقدار تغییرات تعداد پرسنل + /// + public int PersonnelCountDifference { get; set; } + /// /// تعداد کارگاه diff --git a/CompanyManagment.EFCore/Repository/InstitutionContractRepository.cs b/CompanyManagment.EFCore/Repository/InstitutionContractRepository.cs index b2e639c6..753e7674 100644 --- a/CompanyManagment.EFCore/Repository/InstitutionContractRepository.cs +++ b/CompanyManagment.EFCore/Repository/InstitutionContractRepository.cs @@ -2808,9 +2808,8 @@ public class InstitutionContractRepository : RepositoryBasex.Id).ToList(); var changes = newWorkshops.Select(x=> - new InstitutionContractAmendmentChange(InstitutionContractAmendmentChangeType.WorkshopCreated, - DateTime.Now,x.CustomizeCheckout,x.ContractAndCheckout,x.ContractAndCheckoutInPerson, - x.Insurance,x.InsuranceInPerson,x.CountPerson,x.RollCall,x.RollCallInPerson,0)).ToList(); + InstitutionContractAmendmentChange.CreateWorkshopCreatedChange(DateTime.Now,x.RollCall,x.RollCallInPerson,x.CustomizeCheckout, + x.ContractAndCheckout,x.ContractAndCheckoutInPerson,x.Insurance,x.InsuranceInPerson,x.CountPerson)).ToList(); var changedWorkshops = amendmentTemp.NewWorkshops .Where(x => !newWorkshopTempIds.Contains(x.Id)).ToList(); @@ -2848,36 +2847,27 @@ public class InstitutionContractRepository : RepositoryBase + /// + /// + /// + /// + [HttpGet("/api/institutionContract/amendment-Verification/{id:guid}")] + [AllowAnonymous] + public async Task> GetAmendmentVerificationDetails(Guid id) + { + return await _institutionContractApplication.GetAmendmentVerificationDetails(id); + } + + [HttpPost("/api/institutionContract/Verify-amendment")] + [AllowAnonymous] + public async Task> VerifyAmendment([FromBody] InstitutionVerificationRequest command) + { + var res = await _institutionContractApplication.AmendmentVerifyOtp(command.Id, command.Code); + return res; + } + + [HttpGet("edit-old/{id}")] public ActionResult GetEditOldDetails(long id)