feat: add methods for creating institution contract amendment changes and enhance personnel count handling

This commit is contained in:
2025-10-26 14:00:03 +03:30
parent 6e902011ca
commit e6977b29fc
3 changed files with 110 additions and 22 deletions

View File

@@ -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;
}
/// <summary>
/// تغییر تعداد پرسنل
/// </summary>
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);
}
/// <summary>
/// تغییر خدمات
/// </summary>
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);
}
/// <summary>
/// ایجاد کارگاه جدید
/// </summary>
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; }
@@ -372,6 +443,12 @@ public class InstitutionContractAmendmentChange : EntityBase
/// </summary>
public int? PersonnelCount { get; private set; }
/// <summary>
/// مقدار تغییرات تعداد پرسنل
/// </summary>
public int PersonnelCountDifference { get; set; }
/// <summary>
/// تعداد کارگاه
/// </summary>

View File

@@ -2808,9 +2808,8 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
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)).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<long, InstitutionCon
// اگر تغییری وجود داشته باشد، آن را به لیست تغییرات اضافه کن
if (changedBooleans.Any())
{
var change = new InstitutionContractAmendmentChange(
InstitutionContractAmendmentChangeType.Services,
var change = InstitutionContractAmendmentChange.CreateServicesChange(
DateTime.Now,
changedWorkshop.WorkshopId,
changedWorkshop.RollCall,
changedWorkshop.RollCallInPerson,
changedWorkshop.CustomizeCheckout,
changedWorkshop.ContractAndCheckout,
changedWorkshop.ContractAndCheckoutInPerson,
changedWorkshop.Insurance,
changedWorkshop.InsuranceInPerson,
changedWorkshop.CountPerson,
changedWorkshop.RollCall,
changedWorkshop.RollCallInPerson,
changedWorkshop.WorkshopId);
changedWorkshop.InsuranceInPerson);
changes.Add(change);
}
if (changedWorkshop.CountPerson != prev.CountPerson)
{
var change = new InstitutionContractAmendmentChange(
InstitutionContractAmendmentChangeType.PersonCount,
var difference = changedWorkshop.CountPerson - prev.CountPerson;
var change = InstitutionContractAmendmentChange.CreatePersonCountChange(
DateTime.Now,
changedWorkshop.CustomizeCheckout,
changedWorkshop.ContractAndCheckout,
changedWorkshop.ContractAndCheckoutInPerson,
changedWorkshop.Insurance,
changedWorkshop.InsuranceInPerson,
changedWorkshop.CountPerson,
changedWorkshop.RollCall,
changedWorkshop.RollCallInPerson,
changedWorkshop.WorkshopId);
difference,changedWorkshop.WorkshopId);
changes.Add(change);
}

View File

@@ -566,6 +566,27 @@ public class institutionContractController : AdminBaseController
}
/// <summary>
///
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpGet("/api/institutionContract/amendment-Verification/{id:guid}")]
[AllowAnonymous]
public async Task<ActionResult<GetInstitutionVerificationDetailsViewModel>> GetAmendmentVerificationDetails(Guid id)
{
return await _institutionContractApplication.GetAmendmentVerificationDetails(id);
}
[HttpPost("/api/institutionContract/Verify-amendment")]
[AllowAnonymous]
public async Task<ActionResult<OperationResult>> VerifyAmendment([FromBody] InstitutionVerificationRequest command)
{
var res = await _institutionContractApplication.AmendmentVerifyOtp(command.Id, command.Code);
return res;
}
[HttpGet("edit-old/{id}")]
public ActionResult<EditInstitutionContract> GetEditOldDetails(long id)