From bea858d4e7060c4cdcf215f95cdcd1144ff7429c Mon Sep 17 00:00:00 2001 From: mahan Date: Wed, 22 Oct 2025 13:33:30 +0330 Subject: [PATCH 1/6] feat: add AmendmentComplete method and request class to InstitutionContractApplication --- .../IInstitutionContractApplication.cs | 5 +++++ .../InstitutionContractApplication.cs | 5 +++++ .../Controllers/institutionContractController.cs | 11 ++++++++++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/CompanyManagment.App.Contracts/InstitutionContract/IInstitutionContractApplication.cs b/CompanyManagment.App.Contracts/InstitutionContract/IInstitutionContractApplication.cs index 1d361563..58d0508e 100644 --- a/CompanyManagment.App.Contracts/InstitutionContract/IInstitutionContractApplication.cs +++ b/CompanyManagment.App.Contracts/InstitutionContract/IInstitutionContractApplication.cs @@ -241,6 +241,11 @@ public interface IInstitutionContractApplication #endregion Task ResendVerifyLink(long institutionContractId); + Task AmendmentComplete(InstitutionContractAmendmentCompleteRequest request); +} + +public class InstitutionContractAmendmentCompleteRequest +{ } public class InsertAmendmentTempWorkshopResponse diff --git a/CompanyManagment.Application/InstitutionContractApplication.cs b/CompanyManagment.Application/InstitutionContractApplication.cs index f6599b33..df910f4e 100644 --- a/CompanyManagment.Application/InstitutionContractApplication.cs +++ b/CompanyManagment.Application/InstitutionContractApplication.cs @@ -1377,6 +1377,11 @@ public class InstitutionContractApplication : IInstitutionContractApplication return new OperationResult().Succcedded(); } + public Task AmendmentComplete(InstitutionContractAmendmentCompleteRequest request) + { + throw new NotImplementedException(); + } + private async Task> CreateLegalContractingPartyEntity( CreateInstitutionContractLegalPartyRequest request, long representativeId, string address, string city, diff --git a/ServiceHost/Areas/Admin/Controllers/institutionContractController.cs b/ServiceHost/Areas/Admin/Controllers/institutionContractController.cs index b98ecbf3..de7a798e 100644 --- a/ServiceHost/Areas/Admin/Controllers/institutionContractController.cs +++ b/ServiceHost/Areas/Admin/Controllers/institutionContractController.cs @@ -541,19 +541,28 @@ public class institutionContractController : AdminBaseController var res =await _institutionContractApplication.InsertAmendmentTempWorkshops(request); return res; } + [HttpDelete("amendment/remove-temp-workshops/{workshopTempId:guid}")] public async Task RemoveAmendmentWorkshops(Guid workshopTempId) { await _institutionContractApplication.RemoveAmendmentWorkshops(workshopTempId); return Ok(); } + [HttpPost("amendment/payment-details")] public async Task> GetAmendmentPaymentDetails([FromBody]InsitutionContractAmendmentPaymentRequest request) { var res =await _institutionContractApplication.GetAmendmentPaymentDetails(request); return res; } - + + public async Task> CompleteAmendment( + InstitutionContractAmendmentCompleteRequest request) + { + + var res = await _institutionContractApplication.AmendmentComplete(request); + return res; + } } From 1a70569a36e26b2ec64ba5aa743793e4b423203a Mon Sep 17 00:00:00 2001 From: mahan Date: Thu, 23 Oct 2025 11:44:12 +0330 Subject: [PATCH 2/6] feat: implement amendment completion functionality with payment details --- .../IInstitutionContractRepository.cs | 1 + .../InstitutionContract.cs | 9 +++- .../InstitutionContractAmendmentTemp.cs | 15 ++++++ .../IInstitutionContractApplication.cs | 5 +- .../InstitutionContractApplication.cs | 4 +- .../InstitutionContractRepository.cs | 47 ++++++++++++++++++- .../institutionContractController.cs | 8 ++-- 7 files changed, 80 insertions(+), 9 deletions(-) diff --git a/Company.Domain/InstitutionContractAgg/IInstitutionContractRepository.cs b/Company.Domain/InstitutionContractAgg/IInstitutionContractRepository.cs index d1ebe6dd..cec1b650 100644 --- a/Company.Domain/InstitutionContractAgg/IInstitutionContractRepository.cs +++ b/Company.Domain/InstitutionContractAgg/IInstitutionContractRepository.cs @@ -75,4 +75,5 @@ public interface IInstitutionContractRepository : IRepository> GetInstitutionContractSelectList(string search, string selected); + Task AmendmentComplete(InstitutionContractAmendmentCompleteRequest request); } \ No newline at end of file diff --git a/Company.Domain/InstitutionContractAgg/InstitutionContract.cs b/Company.Domain/InstitutionContractAgg/InstitutionContract.cs index 84535d30..43ddc15e 100644 --- a/Company.Domain/InstitutionContractAgg/InstitutionContract.cs +++ b/Company.Domain/InstitutionContractAgg/InstitutionContract.cs @@ -248,6 +248,11 @@ public class InstitutionContract : EntityBase { WorkshopGroup = null; } + + public void AddAmendment(InstitutionContractAmendment amendment) + { + Amendments.Add(amendment); + } } public class InstitutionContractAmendment : EntityBase @@ -255,13 +260,13 @@ public class InstitutionContractAmendment : EntityBase private InstitutionContractAmendment(){} public InstitutionContractAmendment(long institutionContractId, List installments, double amount, bool hasInstallment, - InstitutionContractAmendmentChange amendmentChange, long lawId) + List amendmentChanges, long lawId) { InstitutionContractId = institutionContractId; Installments = installments is { Count: > 0} ? installments : []; Amount = amount; HasInstallment = hasInstallment; - AmendmentChanges = [amendmentChange]; + AmendmentChanges = amendmentChanges; LawId = lawId; } diff --git a/Company.Domain/InstitutionContractAmendmentTempAgg/InstitutionContractAmendmentTemp.cs b/Company.Domain/InstitutionContractAmendmentTempAgg/InstitutionContractAmendmentTemp.cs index bac4cd56..e3d8a4c9 100644 --- a/Company.Domain/InstitutionContractAmendmentTempAgg/InstitutionContractAmendmentTemp.cs +++ b/Company.Domain/InstitutionContractAmendmentTempAgg/InstitutionContractAmendmentTemp.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using CompanyManagment.App.Contracts.InstitutionContract; using MongoDB.Bson; using MongoDB.Bson.Serialization.Attributes; @@ -25,7 +26,21 @@ public class InstitutionContractAmendmentTemp public Guid Id { get; private set; } public List PrevWorkshops { get; private set; } public List NewWorkshops { get; private set; } + + public InstitutionContractPaymentMonthlyViewModel MonthlyPayment { get; set; } + + public InstitutionContractPaymentOneTimeViewModel OneTimePayment { get; set; } + public long InstitutionContractId { get; private set; } + + public int MonthDifference { get; set; } + public void AddPaymentDetails(InstitutionContractPaymentMonthlyViewModel resMonthly, InstitutionContractPaymentOneTimeViewModel resOneTime, int monthDiff) + { + MonthlyPayment = resMonthly; + OneTimePayment = resOneTime; + MonthDifference = monthDiff; + } + } public class InstitutionContractAmendmentTempNewWorkshop : InstitutionContractAmendmentTempPrevWorkshop diff --git a/CompanyManagment.App.Contracts/InstitutionContract/IInstitutionContractApplication.cs b/CompanyManagment.App.Contracts/InstitutionContract/IInstitutionContractApplication.cs index 58d0508e..75e0fa60 100644 --- a/CompanyManagment.App.Contracts/InstitutionContract/IInstitutionContractApplication.cs +++ b/CompanyManagment.App.Contracts/InstitutionContract/IInstitutionContractApplication.cs @@ -241,11 +241,14 @@ public interface IInstitutionContractApplication #endregion Task ResendVerifyLink(long institutionContractId); - Task AmendmentComplete(InstitutionContractAmendmentCompleteRequest request); + Task AmendmentComplete(InstitutionContractAmendmentCompleteRequest request); } public class InstitutionContractAmendmentCompleteRequest { + public Guid TempId { get; set; } + public bool IsInstallment { get; set; } + public long LawId { get; set; } } public class InsertAmendmentTempWorkshopResponse diff --git a/CompanyManagment.Application/InstitutionContractApplication.cs b/CompanyManagment.Application/InstitutionContractApplication.cs index df910f4e..80ddf3e6 100644 --- a/CompanyManagment.Application/InstitutionContractApplication.cs +++ b/CompanyManagment.Application/InstitutionContractApplication.cs @@ -1377,9 +1377,9 @@ public class InstitutionContractApplication : IInstitutionContractApplication return new OperationResult().Succcedded(); } - public Task AmendmentComplete(InstitutionContractAmendmentCompleteRequest request) + public async Task AmendmentComplete(InstitutionContractAmendmentCompleteRequest request) { - throw new NotImplementedException(); + await _institutionContractRepository.AmendmentComplete(request); } diff --git a/CompanyManagment.EFCore/Repository/InstitutionContractRepository.cs b/CompanyManagment.EFCore/Repository/InstitutionContractRepository.cs index 4452dd3d..49315494 100644 --- a/CompanyManagment.EFCore/Repository/InstitutionContractRepository.cs +++ b/CompanyManagment.EFCore/Repository/InstitutionContractRepository.cs @@ -2451,7 +2451,8 @@ public class InstitutionContractRepository : RepositoryBase startDay) monthDiff++; - var sumOneMonth = institutionContractAmendmentTemp.NewWorkshops.Sum(x => x.PriceDifference); + var sumOneMonth = institutionContractAmendmentTemp + .NewWorkshops.Sum(x => x.PriceDifference); var baseAmount = monthDiff * sumOneMonth; var tax = baseAmount*0.10; @@ -2510,6 +2511,13 @@ public class InstitutionContractRepository : RepositoryBase x.Id == institutionContractAmendmentTemp.Id, institutionContractAmendmentTemp); + + + return res; } @@ -2654,6 +2662,43 @@ public class InstitutionContractRepository : RepositoryBasex.Id == request.TempId).FirstOrDefaultAsync(); + + if (amendmentTemp == null) + throw new BadRequestException("دیتای وارد شده نامعتبر است"); + + var institutionContract = await _context.InstitutionContractSet + .Include(x=>x.Amendments) + .Include(x=>x.WorkshopGroup) + .ThenInclude(x=>x.CurrentWorkshops) + .FirstOrDefaultAsync(x => x.id == amendmentTemp.InstitutionContractId); + + + List installments = []; + double amount = 0; + if (request.IsInstallment) + { + installments = amendmentTemp.MonthlyPayment.Installments.Select(x=> + new InstitutionContractInstallment(x.InstalmentDate.ToGeorgianDateTime(), + x.InstallmentAmountStr.MoneyToDouble(), "")).ToList(); + amount = amendmentTemp.MonthlyPayment.PaymentAmount.MoneyToDouble(); + } + else + { + amount = amendmentTemp.OneTimePayment.PaymentAmount.MoneyToDouble(); + } + var newWorkshops = amendmentTemp.NewWorkshops.Where(x=>x.CurrentWorkshopId ==0).ToList(); + + + var amendment = new InstitutionContractAmendment(institutionContract.id,installments,amount, + request.IsInstallment,,request.LawId); + institutionContract.AddAmendment(amendment); + + } + private InstitutionContractExtensionPaymentResponse CalculateInPersonPayment( InstitutionContractExtensionPlanDetail selectedPlan, double baseAmount, double tenPercent, diff --git a/ServiceHost/Areas/Admin/Controllers/institutionContractController.cs b/ServiceHost/Areas/Admin/Controllers/institutionContractController.cs index c520824e..7f01d917 100644 --- a/ServiceHost/Areas/Admin/Controllers/institutionContractController.cs +++ b/ServiceHost/Areas/Admin/Controllers/institutionContractController.cs @@ -556,12 +556,14 @@ public class institutionContractController : AdminBaseController return res; } - public async Task> CompleteAmendment( + [HttpPost("amendment/complete/")] + public async Task AmendmentComplete( InstitutionContractAmendmentCompleteRequest request) { - var res = await _institutionContractApplication.AmendmentComplete(request); - return res; + await _institutionContractApplication.AmendmentComplete(request); + return Ok(); + } From 818d88d85908889bcfecf4911f302b7827f93793 Mon Sep 17 00:00:00 2001 From: mahan Date: Thu, 23 Oct 2025 16:32:45 +0330 Subject: [PATCH 3/6] feat: update InstitutionContractAmendmentChange to include roll call options and current workshop ID --- .../InstitutionContract.cs | 17 ++--- .../InstitutionContractRepository.cs | 66 ++++++++++++++++++- 2 files changed, 72 insertions(+), 11 deletions(-) diff --git a/Company.Domain/InstitutionContractAgg/InstitutionContract.cs b/Company.Domain/InstitutionContractAgg/InstitutionContract.cs index 43ddc15e..5dba367e 100644 --- a/Company.Domain/InstitutionContractAgg/InstitutionContract.cs +++ b/Company.Domain/InstitutionContractAgg/InstitutionContract.cs @@ -291,14 +291,12 @@ public class InstitutionContractAmendment : EntityBase public class InstitutionContractAmendmentChange : EntityBase { private InstitutionContractAmendmentChange() { } - private InstitutionContractAmendmentChange(long institutionContractAmendmentId, - InstitutionContractAmendment institutionContractAmendment, InstitutionContractAmendmentChangeType changeType, - DateTime changeDateGr, bool? hasRollCallPlan, bool? hasCustomizeCheckoutPlan, bool? hasContractPlan, + public InstitutionContractAmendmentChange(InstitutionContractAmendmentChangeType changeType, + DateTime changeDateGr, bool? hasCustomizeCheckoutPlan, bool? hasContractPlan, bool? hasContractPlanInPerson, bool? hasInsurancePlan, bool? hasInsurancePlanInPerson, int? personnelCount, - long? workshopDetailsId) + bool? hasRollCallPlan, bool? hasRollCallInPerson, + long? currentWorkshopId) { - InstitutionContractAmendmentId = institutionContractAmendmentId; - InstitutionContractAmendment = institutionContractAmendment; ChangeType = changeType; ChangeDateGr = changeDateGr; HasRollCallPlan = hasRollCallPlan; @@ -308,7 +306,8 @@ public class InstitutionContractAmendmentChange : EntityBase HasInsurancePlan = hasInsurancePlan; HasInsurancePlanInPerson = hasInsurancePlanInPerson; PersonnelCount = personnelCount; - WorkshopDetailsId = workshopDetailsId; + CurrentWorkshopId = currentWorkshopId; + HasRollCallInPerson = hasRollCallInPerson; } public long InstitutionContractAmendmentId { get; private set; } @@ -321,6 +320,8 @@ public class InstitutionContractAmendmentChange : EntityBase /// public bool? HasRollCallPlan { get; private set; } + public bool? HasRollCallInPerson { get; set; } + /// /// پلن فیش غیر رسمی /// @@ -354,7 +355,7 @@ public class InstitutionContractAmendmentChange : EntityBase /// /// تعداد کارگاه /// - public long? WorkshopDetailsId { get; private set; } + public long? CurrentWorkshopId { get; private set; } } public enum InstitutionContractAmendmentChangeType diff --git a/CompanyManagment.EFCore/Repository/InstitutionContractRepository.cs b/CompanyManagment.EFCore/Repository/InstitutionContractRepository.cs index 49315494..dd46712d 100644 --- a/CompanyManagment.EFCore/Repository/InstitutionContractRepository.cs +++ b/CompanyManagment.EFCore/Repository/InstitutionContractRepository.cs @@ -2690,11 +2690,71 @@ public class InstitutionContractRepository : RepositoryBasex.CurrentWorkshopId ==0).ToList(); - + var newWorkshops = amendmentTemp + .NewWorkshops.Where(x=>x.CurrentWorkshopId ==0).ToList(); + + var newWorkshopTempIds = newWorkshops.Select(x=>x.Id); + + 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)); + + var changedWorkshops = amendmentTemp.NewWorkshops + .Where(x => !newWorkshopTempIds.Contains(x.Id)); + + foreach (var changedWorkshop in changedWorkshops) + { + var prev = amendmentTemp.PrevWorkshops.FirstOrDefault(x => x.Id == changedWorkshop.Id); + if (prev == null) + throw new BadRequestException("دیتای وارد شده ناقص ذخیره شده است"); + + // مقایسه مقادیر بولین بین prev و changedWorkshop برای تشخیص تغییرات + var changedBooleans = new Dictionary(); + + if (prev.CustomizeCheckout != changedWorkshop.CustomizeCheckout) + changedBooleans.Add("CustomizeCheckout", (prev.CustomizeCheckout, changedWorkshop.CustomizeCheckout)); + + if (prev.ContractAndCheckout != changedWorkshop.ContractAndCheckout) + changedBooleans.Add("ContractAndCheckout", (prev.ContractAndCheckout, changedWorkshop.ContractAndCheckout)); + + if (prev.ContractAndCheckoutInPerson != changedWorkshop.ContractAndCheckoutInPerson) + changedBooleans.Add("ContractAndCheckoutInPerson", (prev.ContractAndCheckoutInPerson, changedWorkshop.ContractAndCheckoutInPerson)); + + if (prev.Insurance != changedWorkshop.Insurance) + changedBooleans.Add("Insurance", (prev.Insurance, changedWorkshop.Insurance)); + + if (prev.InsuranceInPerson != changedWorkshop.InsuranceInPerson) + changedBooleans.Add("InsuranceInPerson", (prev.InsuranceInPerson, changedWorkshop.InsuranceInPerson)); + + if (prev.RollCall != changedWorkshop.RollCall) + changedBooleans.Add("RollCall", (prev.RollCall, changedWorkshop.RollCall)); + + if (prev.RollCallInPerson != changedWorkshop.RollCallInPerson) + changedBooleans.Add("RollCallInPerson", (prev.RollCallInPerson, changedWorkshop.RollCallInPerson)); + + // اگر تغییری وجود داشته باشد، آن را به لیست تغییرات اضافه کن + if (changedBooleans.Any()) + { + var change = new InstitutionContractAmendmentChange( + InstitutionContractAmendmentChangeType.WorkshopUpdated, + DateTime.Now, + changedWorkshop.CustomizeCheckout, + changedWorkshop.ContractAndCheckout, + changedWorkshop.ContractAndCheckoutInPerson, + changedWorkshop.Insurance, + changedWorkshop.InsuranceInPerson, + changedWorkshop.CountPerson, + changedWorkshop.RollCall, + changedWorkshop.RollCallInPerson, + changedWorkshop.Id); + + changes = changes.Append(change); + } + } var amendment = new InstitutionContractAmendment(institutionContract.id,installments,amount, - request.IsInstallment,,request.LawId); + request.IsInstallment,new List(),request.LawId); institutionContract.AddAmendment(amendment); } From c36e81e263acc6345f91db6affb0f579a6d8bf96 Mon Sep 17 00:00:00 2001 From: mahan Date: Sat, 25 Oct 2025 15:23:48 +0330 Subject: [PATCH 4/6] feat: update InstitutionContractRepository to enhance workshop change tracking and improve data handling --- .../InstitutionContractRepository.cs | 34 +++++++++++++++---- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/CompanyManagment.EFCore/Repository/InstitutionContractRepository.cs b/CompanyManagment.EFCore/Repository/InstitutionContractRepository.cs index dd46712d..bfde349f 100644 --- a/CompanyManagment.EFCore/Repository/InstitutionContractRepository.cs +++ b/CompanyManagment.EFCore/Repository/InstitutionContractRepository.cs @@ -2693,15 +2693,15 @@ public class InstitutionContractRepository : RepositoryBasex.CurrentWorkshopId ==0).ToList(); - var newWorkshopTempIds = newWorkshops.Select(x=>x.Id); + var newWorkshopTempIds = newWorkshops.Select(x=>x.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)); + x.Insurance,x.InsuranceInPerson,x.CountPerson,x.RollCall,x.RollCallInPerson,0)).ToList(); var changedWorkshops = amendmentTemp.NewWorkshops - .Where(x => !newWorkshopTempIds.Contains(x.Id)); + .Where(x => !newWorkshopTempIds.Contains(x.Id)).ToList(); foreach (var changedWorkshop in changedWorkshops) { @@ -2737,7 +2737,7 @@ public class InstitutionContractRepository : RepositoryBase(),request.LawId); + request.IsInstallment,changes,request.LawId); institutionContract.AddAmendment(amendment); + //Todo : ارسال پیامک تغییرات - و ذخیره تغییرات + } From 6e902011ca79c38e4ef95d02b381ef1aa8c461cb Mon Sep 17 00:00:00 2001 From: mahan Date: Sun, 26 Oct 2025 12:21:14 +0330 Subject: [PATCH 5/6] feat: enhance institution contract verification process and update SMS service methods --- 0_Framework/Application/Sms/ISmsService.cs | 3 ++- .../InstitutionContract.cs | 20 +++++++++++----- .../InstitutionContractApplication.cs | 4 ++-- .../InstitutionContractRepository.cs | 17 ++++++++++---- .../Services/SmsService.cs | 23 +++++++++++++++++-- 5 files changed, 52 insertions(+), 15 deletions(-) diff --git a/0_Framework/Application/Sms/ISmsService.cs b/0_Framework/Application/Sms/ISmsService.cs index d3915923..cb1fec3f 100644 --- a/0_Framework/Application/Sms/ISmsService.cs +++ b/0_Framework/Application/Sms/ISmsService.cs @@ -27,7 +27,8 @@ public interface ISmsService Task GetCreditAmount(); - public Task SendInstitutionVerificationLink(string number, string fullName, Guid institutionId, long contractingPartyId, long institutionContractId); + public Task SendInstitutionCreationVerificationLink(string number, string fullName, Guid institutionId, long contractingPartyId, long institutionContractId); + public Task SendInstitutionAmendmentVerificationLink(string number, string fullName, Guid institutionId, long contractingPartyId, long institutionContractId); public Task SendInstitutionVerificationCode(string number, string code, string contractingPartyFullName, long contractingPartyId, long institutionContractId); diff --git a/Company.Domain/InstitutionContractAgg/InstitutionContract.cs b/Company.Domain/InstitutionContractAgg/InstitutionContract.cs index 28862cf9..7d9fbdb5 100644 --- a/Company.Domain/InstitutionContractAgg/InstitutionContract.cs +++ b/Company.Domain/InstitutionContractAgg/InstitutionContract.cs @@ -272,6 +272,7 @@ public class InstitutionContractAmendment : EntityBase HasInstallment = hasInstallment; AmendmentChanges = amendmentChanges; LawId = lawId; + VerificationStatus = InstitutionContractVerificationStatus.PendingForVerify; } public long InstitutionContractId { get; set; } @@ -285,6 +286,15 @@ public class InstitutionContractAmendment : EntityBase public long LawId { get; set; } + + public string VerifierPhoneNumber { get; private set; } + + public string VerifierFullName { get; private set; } + + public InstitutionContractVerificationStatus VerificationStatus { get; set; } + + public DateTime VerifyCodeCreation { get; set; } + public void SetVerifyCode(string code,string verifierFullName, string verifierPhoneNumber) { VerifyCode = code; @@ -292,12 +302,10 @@ public class InstitutionContractAmendment : EntityBase VerifierFullName = verifierFullName; VerifierPhoneNumber = verifierPhoneNumber; } - - public string VerifierPhoneNumber { get; private set; } - - public string VerifierFullName { get; private set; } - - public DateTime VerifyCodeCreation { get; set; } + public void Verified() + { + VerificationStatus = InstitutionContractVerificationStatus.Verified; + } } public class InstitutionContractAmendmentChange : EntityBase diff --git a/CompanyManagment.Application/InstitutionContractApplication.cs b/CompanyManagment.Application/InstitutionContractApplication.cs index bfbb45f2..c01e95c2 100644 --- a/CompanyManagment.Application/InstitutionContractApplication.cs +++ b/CompanyManagment.Application/InstitutionContractApplication.cs @@ -1140,7 +1140,7 @@ public class InstitutionContractApplication : IInstitutionContractApplication CreateContractingPartyAccount(contractingParty.id, res.SendId); - await _smsService.SendInstitutionVerificationLink(contractingParty.Phone, contractingPartyFullName, + await _smsService.SendInstitutionCreationVerificationLink(contractingParty.Phone, contractingPartyFullName, entity.PublicId, contractingParty.id,entity.id ); await _institutionContractRepository.SaveChangesAsync(); @@ -1377,7 +1377,7 @@ public class InstitutionContractApplication : IInstitutionContractApplication if (contractingParty == null) throw new NotFoundException("طرف قرارداد یافت نشد"); var contractingPartyFullName = contractingParty.FName + " " + contractingParty.LName; - await _smsService.SendInstitutionVerificationLink(contractingParty.Phone, contractingPartyFullName, + await _smsService.SendInstitutionCreationVerificationLink(contractingParty.Phone, contractingPartyFullName, institutionContract.PublicId, contractingParty.id, institutionContract.id); return new OperationResult().Succcedded(); } diff --git a/CompanyManagment.EFCore/Repository/InstitutionContractRepository.cs b/CompanyManagment.EFCore/Repository/InstitutionContractRepository.cs index fd9536f5..b2e639c6 100644 --- a/CompanyManagment.EFCore/Repository/InstitutionContractRepository.cs +++ b/CompanyManagment.EFCore/Repository/InstitutionContractRepository.cs @@ -2341,7 +2341,7 @@ public class InstitutionContractRepository : RepositoryBase x.InstitutionContractId == institutionContractId);; var temp = new InstitutionContractAmendmentTemp(workshops, institutionContractId); @@ -2884,9 +2886,16 @@ public class InstitutionContractRepository : RepositoryBase SendInstitutionVerificationLink(string number, string fullName, Guid institutionId, long contractingPartyId, long institutionContractId) + public async Task SendInstitutionCreationVerificationLink(string number, string fullName, Guid institutionId, long contractingPartyId, long institutionContractId) { var guidStr=institutionId.ToString(); var firstPart = guidStr.Substring(0, 15); @@ -343,7 +343,26 @@ public class SmsService : ISmsService new("CODE1",firstPart), new("CODE2",secondPart) }); - var smsResult = new SmsResult(verificationSendResult.Data.MessageId, verificationSendResult.Message, "لینک تاییدیه قرارداد مالی", + var smsResult = new SmsResult(verificationSendResult.Data.MessageId, verificationSendResult.Message, "لینک تاییدیه ایجاد قرارداد مالی", + fullName, number, contractingPartyId, institutionContractId); + await _smsResultRepository.CreateAsync(smsResult); + await _smsResultRepository.SaveChangesAsync(); + return verificationSendResult.Status == 0; + } + + public async Task SendInstitutionAmendmentVerificationLink(string number, string fullName, Guid institutionId, + long contractingPartyId, long institutionContractId) + { + var guidStr=institutionId.ToString(); + var firstPart = guidStr.Substring(0, 15); + var secondPart = guidStr.Substring(15); + var verificationSendResult =await SmsIr.VerifySendAsync(number, 527519, new VerifySendParameter[] + { + new("FULLNAME", fullName), + new("CODE1",firstPart), + new("CODE2",secondPart) + }); + var smsResult = new SmsResult(verificationSendResult.Data.MessageId, verificationSendResult.Message, "لینک تاییدیه ارتقا قرارداد مالی", fullName, number, contractingPartyId, institutionContractId); await _smsResultRepository.CreateAsync(smsResult); await _smsResultRepository.SaveChangesAsync(); From e6977b29fc8dc79a2d42df1779d0b863a1cbfc83 Mon Sep 17 00:00:00 2001 From: mahan Date: Sun, 26 Oct 2025 14:00:03 +0330 Subject: [PATCH 6/6] 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)