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);
}