private bool ApprenticeshipIsWithinPeriod(DataLockValidationModel dataLockValidationModel) { var periodDates = calculatePeriodStartAndEndDate .GetPeriodDate(dataLockValidationModel.EarningPeriod.Period, dataLockValidationModel.AcademicYear); return(dataLockValidationModel.Apprenticeship.EstimatedStartDate <= periodDates.periodEndDate); }
protected override List <ApprenticeshipPriceEpisodeModel> GetValidApprenticeshipPriceEpisodes( DataLockValidationModel dataLockValidationModel) { // Only DLOCK_10 when apprenticeship is stopped if (dataLockValidationModel.Apprenticeship.Status != ApprenticeshipStatus.Stopped) { return(dataLockValidationModel.Apprenticeship.ApprenticeshipPriceEpisodes); } // Only deal with Transaction Type 1 OnProgramme and incentives if (dataLockValidationModel.TransactionType == TransactionType.Balancing || dataLockValidationModel.TransactionType == TransactionType.Completion) { return(dataLockValidationModel.Apprenticeship.ApprenticeshipPriceEpisodes); } var periodDate = calculatePeriodStartAndEndDate.GetPeriodDate(dataLockValidationModel.EarningPeriod.Period, dataLockValidationModel.AcademicYear); if (dataLockValidationModel.Apprenticeship.StopDate >= periodDate.periodEndDate) { return(dataLockValidationModel.Apprenticeship.ApprenticeshipPriceEpisodes); } return(new List <ApprenticeshipPriceEpisodeModel>()); }
private bool ApprenticeshipStartWithinPeriod(ApprenticeshipModel apprenticeship, byte deliveryPeriod, int academicYear) { var periodDates = calculatePeriodStartAndEndDate.GetPeriodDate(deliveryPeriod, academicYear); if (apprenticeship.EstimatedStartDate > periodDates.periodEndDate) { return(false); } return(true); }
Validate(List <ApprenticeshipModel> apprenticeships, TransactionType transactionType, EarningPeriod earningPeriod, int academicYear) { // Only deal with Transaction Type 1 OnProgramme and incentives if (transactionType == TransactionType.Balancing || transactionType == TransactionType.Completion) { return(apprenticeships, new List <DataLockFailure>()); } var periodDate = calculatePeriodStartAndEndDate.GetPeriodDate(earningPeriod.Period, academicYear); var matchedApprenticeships = apprenticeships .Where(a => { if (a.Status != ApprenticeshipStatus.Stopped) { return(true); } if (a.StopDate >= periodDate.periodEndDate) { return(true); } return(false); }) .ToList(); if (matchedApprenticeships.Any()) { return(matchedApprenticeships, new List <DataLockFailure>()); } var dataLockFailures = apprenticeships.Select(a => new DataLockFailure { ApprenticeshipId = a.Id, ApprenticeshipPriceEpisodeIds = a.ApprenticeshipPriceEpisodes .Where(o => !o.Removed) .Select(x => x.Id).ToList(), DataLockError = DataLockErrorCode.DLOCK_10 }).ToList(); return(new List <ApprenticeshipModel>(), dataLockFailures); }