public IAppFinRecord TNP2RecordLaterThanTNP4Record(IEnumerable <IAppFinRecord> appFinRecords, DateTime?latestTnp4Date)
        {
            var tnp2Records =
                _appFinRecordQueryService?.GetAppFinRecordsForTypeAndCode(
                    appFinRecords,
                    ApprenticeshipFinancialRecord.Types.TotalNegotiatedPrice,
                    ApprenticeshipFinancialRecord.TotalNegotiatedPriceCodes.TotalAssessmentPrice);

            return(tnp2Records?.Where(af => af.AFinDate > latestTnp4Date).FirstOrDefault());
        }
Пример #2
0
        public void Validate(ILearner objectToValidate)
        {
            if (objectToValidate.LearningDeliveries == null)
            {
                return;
            }

            foreach (var learningDelivery in objectToValidate.LearningDeliveries)
            {
                var tnp2Records =
                    _appFinRecordQueryService?.GetAppFinRecordsForTypeAndCode(
                        learningDelivery.AppFinRecords,
                        ApprenticeshipFinancialRecord.Types.TotalNegotiatedPrice,
                        ApprenticeshipFinancialRecord.TotalNegotiatedPriceCodes.TotalAssessmentPrice);

                var tnp4Dates =
                    _appFinRecordQueryService?.GetAppFinRecordsForTypeAndCode(
                        learningDelivery.AppFinRecords,
                        ApprenticeshipFinancialRecord.Types.TotalNegotiatedPrice,
                        ApprenticeshipFinancialRecord.TotalNegotiatedPriceCodes.ResidualAssessmentPrice)
                    .Select(af => af.AFinDate).ToList();

                if (tnp2Records.Any() && tnp4Dates.Any())
                {
                    var tnp2DateEqualToTnp4 = TNP2DateEqualToTNP4Date(tnp2Records, tnp4Dates);

                    if (tnp2DateEqualToTnp4 != null)
                    {
                        HandleValidationError(
                            objectToValidate.LearnRefNumber,
                            learningDelivery.AimSeqNumber,
                            BuildErrorMessageParameters(
                                tnp2DateEqualToTnp4.AFinType,
                                tnp2DateEqualToTnp4.AFinCode,
                                tnp2DateEqualToTnp4.AFinDate));
                    }
                }
            }
        }