public async Task ATS_Result_should_be_one_when_answer_phase_1_is_1_and_answer_phase_2_is_0_and_phase_3_has_more_than_2() { using var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled); //Arrange var identityWorkId = Guid.NewGuid(); var instanceId = Guid.NewGuid(); var employeeId = Guid.NewGuid(); var periodId = Guid.NewGuid(); var evaluationSurveyId = Guid.Parse("6EC14905-F634-418F-B0D2-EF2F315835E8");//ATS var middlewareManager = new NOMSurveyManager(); var nomSurveyReply = BuildNomSurveyReply(identityWorkId, instanceId, employeeId, periodId, evaluationSurveyId); var answerPhase1 = new NOMAnswerManagerUT().BuildAnswer(identityWorkId, instanceId, nomSurveyReply.ID); var answerPhase2 = new NOMAnswerManagerUT().BuildAnswer(identityWorkId, instanceId, nomSurveyReply.ID); var answerPhase31 = new NOMAnswerManagerUT().BuildAnswer(identityWorkId, instanceId, nomSurveyReply.ID); var answerPhase32 = new NOMAnswerManagerUT().BuildAnswer(identityWorkId, instanceId, nomSurveyReply.ID); var answerPhase33 = new NOMAnswerManagerUT().BuildAnswer(identityWorkId, instanceId, nomSurveyReply.ID); var nomEvaluationPhaseManager = new MiddlewareManager <NOMEvaluationPhase>(new BaseRecordManager <NOMEvaluationPhase>(), new NOMEvaluationPhaseValidator()); var aTSPhases = await nomEvaluationPhaseManager.FindByExpressionAsync(x => x.NOMEvaluationSurveyID == evaluationSurveyId && x.Active == true, Guid.Empty); var listATSPhasesIDs = aTSPhases.Select(x => x.ID); var PhaseI = aTSPhases.FirstOrDefault(x => x.Number == 1); var PhaseII = aTSPhases.FirstOrDefault(x => x.Number == 2); var PhaseIII = aTSPhases.FirstOrDefault(x => x.Number == 3); var questionMiddleWare = new MiddlewareManager <NOMEvaluationQuestion>(new BaseRecordManager <NOMEvaluationQuestion>(), new NOMEvaluationQuestionValidator()); var aTSQuestions = questionMiddleWare.FindByExpression(e => listATSPhasesIDs.Contains(e.NOMEvaluationPhaseID), Guid.Empty); var phaseIATSQuestions = questionMiddleWare.FindByExpression(e => e.Active && e.NOMEvaluationPhaseID == PhaseI.ID, Guid.Empty); var phaseIIATSQuestions = questionMiddleWare.FindByExpression(e => e.Active && e.NOMEvaluationPhaseID == PhaseII.ID, Guid.Empty); var phaseIIIATSQuestions = questionMiddleWare.FindByExpression(e => e.Active && e.NOMEvaluationPhaseID == PhaseIII.ID, Guid.Empty); answerPhase1.NOMEvaluationQuestionID = phaseIATSQuestions.FirstOrDefault().ID; answerPhase1.Value = 1; answerPhase2.NOMEvaluationQuestionID = phaseIIATSQuestions.FirstOrDefault().ID; answerPhase2.Value = 0; answerPhase31.NOMEvaluationQuestionID = phaseIIIATSQuestions.FirstOrDefault().ID; answerPhase31.Value = 1; answerPhase32.NOMEvaluationQuestionID = phaseIIIATSQuestions.FirstOrDefault().ID; answerPhase32.Value = 1; answerPhase33.NOMEvaluationQuestionID = phaseIIIATSQuestions.FirstOrDefault().ID; answerPhase33.Value = 1; //Act var processed = middlewareManager.ProcessFinalizationATS(nomSurveyReply, new List <NOMAnswer>() { answerPhase1, answerPhase2, answerPhase31, answerPhase32, answerPhase33 }, aTSQuestions, aTSPhases); //Arrange Assert.NotNull(processed); Assert.Equal(1, processed.Result); Assert.Equal(EvaluationStateType.Answered, processed.EvaluationState); }
public void ValidateNotChangeData(List <FonacotMovement> lstObjectsToValidate) { //all good //validar si ya tiene pagos aplicados var fonacotIDs = lstObjectsToValidate.Select(p => p.ID); var middlewareManagerFonacot = new MiddlewareManager <FonacotMovement>(new BaseRecordManager <FonacotMovement>(), new FonacotMovementValidator()); var fonacotDataExistent = middlewareManagerFonacot.FindByExpression(p => fonacotIDs.Contains(p.ID), Guid.Empty); var boolChanged = false; foreach (var exists in fonacotDataExistent) { var found = lstObjectsToValidate.FirstOrDefault(p => p.ID == exists.ID); if (exists.Month != found.Month || exists.Year != found.Year) { boolChanged = true; break; } } var employeeConceptsId = lstObjectsToValidate.Select(p => p.EmployeeConceptsRelationID); var middlewareManager = new MiddlewareManager <EmployeeConceptsRelationDetail>(new BaseRecordManager <EmployeeConceptsRelationDetail>(), new EmployeeConceptsRelationDetailValidator()); var details = middlewareManager.FindByExpression(p => employeeConceptsId.Contains(p.EmployeeConceptsRelationID), Guid.Empty); if (details.Any(p => p.ConceptsRelationPaymentStatus == ConceptsRelationPaymentStatus.Applied) && boolChanged) { throw new Exception("No se puede actualizar los datos proporcionados del crédito, debido a que ya tiene pagos aplicados al mismo. Si lo deseas puedes cambiar el estado del crédito a Inactivo, para que no se aplique."); } }
public void BeforeUpdate(List <PeriodDetail> lstObjectsToValidate) { //all good var validator = new RuleValidator <PeriodDetail>(); validator.ValidateRules(lstObjectsToValidate, createRules); var middlewareManager = new MiddlewareManager <PeriodDetail>(new BaseRecordManager <PeriodDetail>(), this); foreach (var entity in lstObjectsToValidate) { var result = middlewareManager.FindByExpression(p => p.InstanceID == entity.InstanceID && p.ID != entity.ID && p.PeriodID == entity.PeriodID && ((p.Number == (entity.Number - 1) && entity.InitialDate <= p.FinalDate) || (p.Number == (entity.Number + 1) && entity.FinalDate >= p.InitialDate)) && p.Active, Guid.Empty, null); if (result.Any()) { throw new CotorraException(8008, "8008", "No se puede actualizar este periodo, debido a que la fecha se traslapa con otros periodos.", new Exception("")); } } }
private List <PeriodDetail> CreatePeriodDetailsByPeriodType(Period period, Guid company, Guid instance, Guid user) { var lstPeriodDetail = new List <PeriodDetail>(); var payrollCompanyConfigManager = new MiddlewareManager <PayrollCompanyConfiguration>(new BaseRecordManager <PayrollCompanyConfiguration>(), new PayrollCompanyConfigurationValidator()); var payrollCompanyConfig = payrollCompanyConfigManager.FindByExpression(p => p.company == company && p.InstanceID == instance, company); if (period.PaymentPeriodicity == PaymentPeriodicity.Biweekly || period.PaymentPeriodicity == PaymentPeriodicity.Monthly || period.PaymentPeriodicity == PaymentPeriodicity.Weekly) { var currentPeriod = 1; if (payrollCompanyConfig.Any()) { currentPeriod = payrollCompanyConfig.FirstOrDefault().CurrentPeriod; } if (period.PaymentPeriodicity == PaymentPeriodicity.Weekly) { PeriodGeneratorNoMonthCalendarFixed weeklyGenerator = new PeriodGeneratorNoMonthCalendarFixed(); lstPeriodDetail.AddRange(weeklyGenerator.GeneratePeriods(period, currentPeriod, company, instance, user)); } else if (period.PaymentPeriodicity == PaymentPeriodicity.Biweekly || period.PaymentPeriodicity == PaymentPeriodicity.Monthly) { PeriodGeneratorMonthCalendarFixed periodGenerator = new PeriodGeneratorMonthCalendarFixed(); lstPeriodDetail.AddRange(periodGenerator.GeneratePeriods(period, currentPeriod, company, instance, user)); } } return(lstPeriodDetail); }
private void ValidateBeforeCreateAndUpdate(List <EmployeeSalaryIncrease> lstObjectsToValidate) { var instanceID = lstObjectsToValidate.FirstOrDefault().InstanceID; var companyID = lstObjectsToValidate.FirstOrDefault().company; var employeesIds = lstObjectsToValidate.Select(p => p.EmployeeID); //Get Employees var middlewareManagerEmployee = new MiddlewareManager <Employee>(new BaseRecordManager <Employee>(), new EmployeeValidator()); var employees = middlewareManagerEmployee.FindByExpression(p => p.InstanceID == instanceID && employeesIds.Contains(p.ID), companyID); //PeriodTypes of Employees var periodTypeIds = employees.Select(p => p.PeriodTypeID); //Get Period Details var middlewareManagerPD = new MiddlewareManager <PeriodDetail>(new BaseRecordManager <PeriodDetail>(), new PeriodDetailValidator()); var periodDetails = middlewareManagerPD.FindByExpression(p => p.InstanceID == instanceID && (p.PeriodStatus == PeriodStatus.Open || p.PeriodStatus == PeriodStatus.Calculating) && periodTypeIds.Contains(p.Period.PeriodTypeID), companyID); lstObjectsToValidate.ForEach(increase => { var modificationDate = increase.ModificationDate; var periodDetail = periodDetails.FirstOrDefault(p => p.InitialDate <= modificationDate && p.FinalDate >= modificationDate); var ids = lstObjectsToValidate.Select(p => p.ID); //El incremento de salario no debe de coincidir con otro dentro del mismo periodo var employeeSelected = employees.FirstOrDefault(p => p.ID == increase.EmployeeID); if (periodDetail != null) { //Verificar si hay otro incremento salarial para ese periodo var middlewareManagerEmployeeSalaryIncrease = new MiddlewareManager <EmployeeSalaryIncrease>(new BaseRecordManager <EmployeeSalaryIncrease>(), this); var employeeSalaryIncreases = middlewareManagerEmployeeSalaryIncrease.FindByExpression(p => p.InstanceID == instanceID && !ids.Contains(p.ID) && p.EmployeeID == employeeSelected.ID && p.ModificationDate >= periodDetail.InitialDate && p.ModificationDate <= periodDetail.FinalDate, companyID); if (employeeSalaryIncreases.Any()) { throw new CotorraException(4004, "4004", $"El incremento de salario para el colaborador {employeeSelected.FullName} para el periodo del {periodDetail.InitialDate.ToShortDateString()} al {periodDetail.FinalDate.ToShortDateString()} ya existe.", null); } } //El incremento de salario no debe de caer en un periodo cerrado else { throw new CotorraException(4005, "4005", $"El incremento de salario para el colaborador {employeeSelected.FullName} para el periodo seleccionado no se puede realizar debido a que el periodo está cerrado.", null); } }); }
public void BeforeDelete(List <Guid> lstObjectsToValidate) { var middlewareManager = new MiddlewareManager <PeriodDetail>(new BaseRecordManager <PeriodDetail>(), this); var entities = middlewareManager.FindByExpression(p => lstObjectsToValidate.Contains(p.ID), Guid.Empty, null); foreach (var entity in entities) { var result = middlewareManager.FindByExpression(p => p.InstanceID == entity.InstanceID && p.Number > entity.Number && p.Active, Guid.Empty, null); result = result.Where(p => !lstObjectsToValidate.Contains(p.ID)).ToList(); if (result.Any()) { throw new CotorraException(8007, "8007", "No se puede eliminar este periodo, debido a que tiene periodos futuros abiertos.", new Exception("")); } } }
public void BeforeDelete(List <Guid> lstObjectsToValidate) { var middlewareManagerDetails = new MiddlewareManager <OverdraftDetail>(new BaseRecordManager <OverdraftDetail>(), new OverdraftDetailValidator()); var overdraftDetails = middlewareManagerDetails.FindByExpression(p => lstObjectsToValidate.Contains(p.OverdraftID), Guid.Empty); if (overdraftDetails.Any()) { middlewareManagerDetails.Delete(overdraftDetails.Select(p => p.ID).ToList(), Guid.Empty); } }
public void BeforeDelete(List <Guid> lstObjectsToValidate) { var middlewareManagerEmployee = new MiddlewareManager <Employee>(new BaseRecordManager <Employee>(), new EmployeeValidator()); if (middlewareManagerEmployee.FindByExpression(p => p.Active == true && lstObjectsToValidate.Contains(p.EmployerRegistrationID.Value), Guid.Empty).Any()) { throw new CotorraException(4005, "4005", $"El registro patronal no se puede eliminar por que tiene colaboradores asignados.", null); } }
public void AfterCreateUpdate(List <EmployeeSalaryIncrease> lstObjectsToValidate) { var instanceID = lstObjectsToValidate.FirstOrDefault().InstanceID; var companyID = lstObjectsToValidate.FirstOrDefault().company; var user = lstObjectsToValidate.FirstOrDefault().user; var employeesIds = lstObjectsToValidate.Select(p => p.EmployeeID); //Get Employees var middlewareManagerEmployee = new MiddlewareManager <Employee>(new BaseRecordManager <Employee>(), new EmployeeValidator()); var employees = middlewareManagerEmployee.FindByExpression(p => p.InstanceID == instanceID && employeesIds.Contains(p.ID), companyID); //PeriodTypes of Employees var periodTypeIds = employees.Select(p => p.PeriodTypeID); //Get Period Details var middlewareManagerPD = new MiddlewareManager <PeriodDetail>(new BaseRecordManager <PeriodDetail>(), new PeriodDetailValidator()); var periodDetails = middlewareManagerPD.FindByExpression(p => p.InstanceID == instanceID && p.PeriodStatus == PeriodStatus.Calculating && periodTypeIds.Contains(p.Period.PeriodTypeID), companyID); //Modify directly to calcuting period foreach (var periodDetail in periodDetails) { using (var connection = new SqlConnection( ConnectionManager.ConfigConnectionString)) { if (connection.State != ConnectionState.Open) { connection.Open(); } using (var command = connection.CreateCommand()) { command.CommandType = CommandType.StoredProcedure; command.CommandText = "ApplySalaryAdjustments"; command.Parameters.AddWithValue("@PeriodDetailId", periodDetail.ID); command.Parameters.AddWithValue("@InstanceId", instanceID); command.Parameters.AddWithValue("@company", companyID); command.Parameters.AddWithValue("@user", user); //Execute SP de autorización command.ExecuteNonQuery(); } } } }
private void ValidateInDate(List <Incident> lstObjectsToValidate) { VacationInhabilityIncidentHelperValidator helperValidator = new VacationInhabilityIncidentHelperValidator(); var employeesIDs = lstObjectsToValidate.Select(x => x.EmployeeID); var inhabilityManager = new MiddlewareManager <Inhability>(new BaseRecordManager <Inhability>(), new InhabilityValidator()); var vacationManager = new MiddlewareManager <Vacation>(new BaseRecordManager <Vacation>(), new VacationValidator()); var orderListInitialDate = lstObjectsToValidate.Select(x => x.Date).OrderBy(p => p).FirstOrDefault(); var inhabilities = inhabilityManager.FindByExpression(x => (x.InitialDate >= orderListInitialDate || x.InitialDate.AddDays(x.AuthorizedDays - 1) >= orderListInitialDate) && employeesIDs.Contains(x.EmployeeID), Guid.Empty, new string[] { }); var vacations = vacationManager.FindByExpression(x => x.InitialDate >= orderListInitialDate && employeesIDs.Contains(x.EmployeeID), Guid.Empty, new string[] { }); helperValidator.ValidateInDate(vacations, inhabilities, lstObjectsToValidate); }
public void BeforeDelete(List <Guid> lstObjectsToValidate) { var employeeSalaryIncreaseMiddlewareManager = new MiddlewareManager <EmployeeSalaryIncrease>(new BaseRecordManager <EmployeeSalaryIncrease>(), new EmployeeSalaryIncreaseValidator()); if (employeeSalaryIncreaseMiddlewareManager.FindByExpression(p => lstObjectsToValidate.Contains(p.EmployeeSBCAdjustmentID), Guid.Empty).Any()) { throw new CotorraException(6901, "6901", "No se puede eliminar la modificación de SBC porque fue creado desde un incremento de salario," + " elimina el aumento de salario relacionado.", null); } //Desaplicar los ajustes de salario del periodo actual (si aplica) BeforeDeleteCommon(lstObjectsToValidate); }
private void BeforeCreateUpdate(List <Incident> lstObjectsToValidate) { var mgr = new MiddlewareManager <Employee>(new BaseRecordManager <Employee>(), new EmployeeValidator()); var employees = mgr.FindByExpression(x => lstObjectsToValidate.Select(p => p.EmployeeID).Contains(x.ID), lstObjectsToValidate.FirstOrDefault().company); employees.ForEach(employee => { var incidentsEmployee = lstObjectsToValidate.Where(x => x.EmployeeID == employee.ID); if (incidentsEmployee.Any(x => x.Date < employee.EntryDate)) { throw new CotorraException(18005, "18005", "No es posible registrar incidencias antes de la fecha de ingreso del colaborador.", null); } }); ValidateInDate(lstObjectsToValidate); }
public void BeforeDelete(List <Guid> lstObjectsToValidate) { if (lstObjectsToValidate.Any()) { var middlewareManager = new MiddlewareManager <Vacation>(new BaseRecordManager <Vacation>(), this); var vacationDaysOffManager = new MiddlewareManager <VacationDaysOff>(new BaseRecordManager <VacationDaysOff>(), new VacationDaysOffValidator()); var entities = middlewareManager.FindByExpression(p => lstObjectsToValidate.Contains(p.ID), Guid.Empty, new string[] { "VacationDaysOff" }); var daysOff = entities.SelectMany(p => p.VacationDaysOff).Select(p => p.ID); if (daysOff.Any()) { vacationDaysOffManager.Delete(daysOff.ToList(), Guid.Empty); } } }
public void BeforeCreate(List <InfonavitMovement> lstObjectsToValidate) { //all good var validator = new RuleValidator <InfonavitMovement>(); validator.ValidateRules(lstObjectsToValidate, createRules); var employeesIDs = lstObjectsToValidate.Select(x => x.EmployeeID).ToList(); var middlewareManager = new MiddlewareManager <InfonavitMovement>(new BaseRecordManager <InfonavitMovement>(), this); var entities = middlewareManager.FindByExpression(p => employeesIDs.Contains(p.EmployeeID) && p.Active, Guid.Empty, new string[] { }); if (entities.Any()) { throw new CotorraException(801, "801", "Ya se ha registrado un crédito infonavit activo para el empleado", null); } }
public void BeforeDelete(List <Guid> lstObjectsToValidate) { //all good //validar si ya tiene pagos aplicados var middlewareManager = new MiddlewareManager <EmployeeConceptsRelationDetail>(new BaseRecordManager <EmployeeConceptsRelationDetail>(), new EmployeeConceptsRelationDetailValidator()); var details = middlewareManager.FindByExpression(p => lstObjectsToValidate.Contains(p.EmployeeConceptsRelationID), Guid.Empty); if (details.Any(p => p.ConceptsRelationPaymentStatus == ConceptsRelationPaymentStatus.Applied)) { throw new Exception("No se puede eliminar el crédito, debido a que ya tiene pagos aplicados al mismo. Si lo deseas puedes cambiar el estado del crédito a Inactivo, para que no se aplique."); } if (details.Any()) { middlewareManager.Delete(details.Select(p => p.ID).ToList(), Guid.Empty); } }
public void AfterUpdate(List <PeriodType> lstObjectsToValidate) { //all good var periodMiddlewareManager = new MiddlewareManager <Period>(new BaseRecordManager <Period>(), new PeriodValidator()); var company = lstObjectsToValidate.FirstOrDefault().company; var periodTypeIDs = lstObjectsToValidate.Select(p => p.ID); //Obtener los periodos y sus detalles var periods = periodMiddlewareManager.FindByExpression(p => periodTypeIDs.Contains(p.PeriodTypeID), company, new string[] { "PeriodDetails" }); foreach (var period in periods) { var periodTypeModified = lstObjectsToValidate.FirstOrDefault(p => p.ID == period.PeriodTypeID); //Por cada periodo se update los días de pago y sus fortnight period.FortnightPaymentDays = periodTypeModified.FortnightPaymentDays; period.PaymentDays = periodTypeModified.PaymentDays; foreach (var periodDetail in period.PeriodDetails) { if (periodDetail.PeriodStatus != PeriodStatus.Authorized && periodDetail.PeriodStatus != PeriodStatus.Stamped) { //Si es por los días de pago if (periodTypeModified.FortnightPaymentDays == AdjustmentPay_16Days_Febrary.PayPaymentDays) { periodDetail.PaymentDays = periodTypeModified.PaymentDays; } //Si es por los días calendario else { periodDetail.PaymentDays = Convert.ToDecimal((periodDetail.FinalDate - periodDetail.InitialDate).TotalDays + 1); } } } } //al finalizar se actualizan periodMiddlewareManager.Update(periods, company); }
public void BeforeCreate(List <Vacation> lstObjectsToValidate) { var validator = new RuleValidator <Vacation>(); validator.ValidateRules(lstObjectsToValidate, createRules); var employeesIDs = lstObjectsToValidate.Select(x => x.EmployeeID).ToList(); var middlewareManager = new MiddlewareManager <Vacation>(new BaseRecordManager <Vacation>(), this); var entities = middlewareManager.FindByExpression(p => employeesIDs.Contains(p.EmployeeID), Guid.Empty, new string[] { }); lstObjectsToValidate.AsParallel().ForEach(toSave => { var badEntities = entities.Where(x => (toSave.InitialDate >= x.InitialDate && toSave.FinalDate <= x.FinalDate) || (toSave.InitialDate >= x.InitialDate && toSave.InitialDate <= x.FinalDate) || (toSave.FinalDate <= x.FinalDate && toSave.FinalDate >= x.InitialDate)); if (badEntities.Any()) { throw new CotorraException(601, "601", "Ya se han registrado vacaciones en esas fechas para el empleado", null); } }); entities.AsParallel().ForEach(toSave => { var badEntities = lstObjectsToValidate.Where(x => (toSave.InitialDate >= x.InitialDate && toSave.FinalDate <= x.FinalDate) || (toSave.InitialDate >= x.InitialDate && toSave.InitialDate <= x.FinalDate) || (toSave.FinalDate <= x.FinalDate && toSave.FinalDate >= x.InitialDate)); if (badEntities.Any()) { throw new CotorraException(601, "601", "Ya se han registrado vacaciones en esas fechas para el empleado", null); } }); ValidateInDate(lstObjectsToValidate); }
/// <summary> /// Borra los conceptos de infonavit que no deberían de estar ya, por actualización /// </summary> /// <param name="lstObjectsToValidate"></param> private void DeleteOverdraftConcepts(List <InfonavitMovement> lstObjectsToValidate) { var middlewareManagerOverdraft = new MiddlewareManager <Overdraft>(new BaseRecordManager <Overdraft>(), new OverdraftValidator()); var middlewareManagerOverdraftDetails = new MiddlewareManager <OverdraftDetail>(new BaseRecordManager <OverdraftDetail>(), new OverdraftDetailValidator()); var employeeIds = lstObjectsToValidate.Select(p => p.EmployeeID); var companyID = lstObjectsToValidate.FirstOrDefault().company; var overdraftActive = middlewareManagerOverdraft.FindByExpression(p => p.PeriodDetail.PeriodStatus == PeriodStatus.Calculating && employeeIds.Contains(p.EmployeeID), companyID , new string[] { "OverdraftDetails", "OverdraftDetails.ConceptPayment" }); if (overdraftActive.Any()) { var overdraft = overdraftActive.FirstOrDefault(); lstObjectsToValidate.ForEach(infonavitMovement => { if (infonavitMovement.InfonavitCreditType == InfonavitCreditType.DiscountFactor_D15) { var detailsIds = overdraft.OverdraftDetails .Where(p => (p.ConceptPayment.Code == 59 || p.ConceptPayment.Code == 16) && p.ConceptPayment.ConceptType == ConceptType.DeductionPayment) .Select(p => p.ID) .ToList(); if (detailsIds.Any()) { middlewareManagerOverdraftDetails.Delete(detailsIds, companyID); } } else if (infonavitMovement.InfonavitCreditType == InfonavitCreditType.FixQuota_D16) { var detailsIds = overdraft.OverdraftDetails .Where(p => (p.ConceptPayment.Code == 59 || p.ConceptPayment.Code == 15) && p.ConceptPayment.ConceptType == ConceptType.DeductionPayment) .Select(p => p.ID) .ToList(); if (detailsIds.Any()) { middlewareManagerOverdraftDetails.Delete(detailsIds, companyID); } } else if (infonavitMovement.InfonavitCreditType == InfonavitCreditType.Percentage_D59) { var detailsIds = overdraft.OverdraftDetails .Where(p => (p.ConceptPayment.Code == 16 || p.ConceptPayment.Code == 15) && p.ConceptPayment.ConceptType == ConceptType.DeductionPayment) .Select(p => p.ID) .ToList(); if (detailsIds.Any()) { middlewareManagerOverdraftDetails.Delete(detailsIds, companyID); } } //Seguro de vivienda infonavit if (!infonavitMovement.IncludeInsurancePayment_D14) { var detailsIds = overdraft.OverdraftDetails .Where(p => (p.ConceptPayment.Code == 14) && p.ConceptPayment.ConceptType == ConceptType.DeductionPayment) .Select(p => p.ID) .ToList(); var conceptIds = overdraft.OverdraftDetails .Where(p => (p.ConceptPayment.Code == 14) && p.ConceptPayment.ConceptType == ConceptType.DeductionPayment) .Select(p => p.ConceptPaymentID) .ToList(); if (detailsIds.Any()) { middlewareManagerOverdraftDetails.Delete(detailsIds, companyID); } //Delete employeeConceptRelated var employeeConceptRelatedMiddleware = new MiddlewareManager <EmployeeConceptsRelation>( new BaseRecordManager <EmployeeConceptsRelation>(), new EmployeeConceptsRelationValidator()); var employessRelatedToDelete = employeeConceptRelatedMiddleware.FindByExpression(p => p.EmployeeID == overdraft.EmployeeID && conceptIds.Contains(p.ConceptPaymentID), companyID); var employessRelatedToDeleteIds = employessRelatedToDelete.Select(p => p.ID).ToList(); employeeConceptRelatedMiddleware.Delete(employessRelatedToDeleteIds, companyID); } }); } }