private bool LearnEndDateCondition(DateTime?learnActEndDate, McaDevolvedContract contract, DateTime learnPlanEndDate) { bool learnEndDateCondition = true; if (learnActEndDate.HasValue) { learnEndDateCondition = (!contract.EffectiveTo.HasValue || learnActEndDate <= contract.EffectiveTo); } else { if (!contract.EffectiveTo.HasValue || contract.EffectiveTo < _academicYearService.YearEnd) { learnEndDateCondition = (!contract.EffectiveTo.HasValue || learnPlanEndDate <= contract.EffectiveTo) || contract.EffectiveTo.Value.Year >= _academicYearService.YearEnd.Year && contract.EffectiveTo.Value.DayOfYear >= _academicYearService.YearEnd.DayOfYear && learnPlanEndDate >= contract.EffectiveTo; } } return(learnEndDateCondition); }
public void Build_SingleRow() { var reportServiceContext = new Mock <IReportServiceContext>(); reportServiceContext.Setup(rsc => rsc.Ukprn).Returns(1); var dependentDataMock = new Mock <IReportServiceDependentData>(); var learningDeliveryFams = new List <ILearningDeliveryFAM>() { new TestLearningDeliveryFAM() { LearnDelFAMType = "SOF", LearnDelFAMCode = "110", } }; var providerSpecDeliveryMonitorings = new List <IProviderSpecDeliveryMonitoring>() { new TestProviderSpecDeliveryMonitoring(), }; var learningDelivery = new TestLearningDelivery() { LearnAimRef = "learnAimRef", AimSeqNumber = 1, LearningDeliveryFAMs = learningDeliveryFams, ProviderSpecDeliveryMonitorings = providerSpecDeliveryMonitorings }; var providerSpecLearnerMonitorings = new List <IProviderSpecLearnerMonitoring>() { new TestProviderSpecLearnerMonitoring(), }; var learner = new TestLearner() { LearnRefNumber = "LearnRefNumber", LearningDeliveries = new List <ILearningDelivery>() { learningDelivery }, ProviderSpecLearnerMonitorings = providerSpecLearnerMonitorings, }; var message = new TestMessage() { Learners = new List <ILearner>() { learner } }; var larsLearningDelivery = new LARSLearningDelivery() { LearnAimRef = "learnAimRef", LARSLearningDeliveryCategories = new HashSet <LARSLearningDeliveryCategory> { new LARSLearningDeliveryCategory { CategoryRef = 123 } } }; var mcaGlaSofLookup = new McaGlaSofLookup() { SofCode = "110", McaGlaShortCode = "GMCA", McaGlaFullName = "GMCA Full", }; var mcaDevolvedContract = new McaDevolvedContract() { Ukprn = 1, McaGlaShortCode = "GMCB", EffectiveFrom = new DateTime(2000, 01, 01), EffectiveTo = new DateTime(2000, 01, 01) }; var referenceDataRoot = new ReferenceDataRoot() { LARSLearningDeliveries = new List <LARSLearningDelivery>() { larsLearningDelivery }, DevolvedPostocdes = new DevolvedPostcodes() { McaGlaSofLookups = new List <McaGlaSofLookup>() { mcaGlaSofLookup } }, McaDevolvedContracts = new List <McaDevolvedContract>() { mcaDevolvedContract }, Organisations = new List <Organisation>() { new Organisation() { UKPRN = 12345678, Name = "Partner Provider" } } }; var fm35LearningDeliveryValue = new LearningDeliveryValue(); var fm35LearningDelivery = new LearningDelivery() { AimSeqNumber = 1, LearningDeliveryValue = fm35LearningDeliveryValue, LearningDeliveryPeriodisedValues = new List <LearningDeliveryPeriodisedValue>() { BuildPeriodisedValuesForAttribute(AttributeConstants.Fm35OnProgPayment), BuildPeriodisedValuesForAttribute(AttributeConstants.Fm35AchievePayPct), BuildPeriodisedValuesForAttribute(AttributeConstants.Fm35AchievePayment), BuildPeriodisedValuesForAttribute(AttributeConstants.Fm35EmpOutcomePay), BuildPeriodisedValuesForAttribute(AttributeConstants.Fm35BalancePayment), BuildPeriodisedValuesForAttribute(AttributeConstants.Fm35LearnSuppFundCash), } }; var fm35Global = new FM35Global() { Learners = new List <FM35Learner>() { new FM35Learner() { LearnRefNumber = "LearnRefNumber", LearningDeliveries = new List <LearningDelivery>() { fm35LearningDelivery, } } } }; dependentDataMock.Setup(d => d.Get <IMessage>()).Returns(message); dependentDataMock.Setup(d => d.Get <ReferenceDataRoot>()).Returns(referenceDataRoot); dependentDataMock.Setup(d => d.Get <FM35Global>()).Returns(fm35Global); var providerSpecDeliveryMonitoringModel = new ProviderSpecDeliveryMonitoringModel(); var providerSpecLearnerMonitoringModel = new ProviderSpecLearnerMonitoringModel(); var employmentStatusMonitoring = new EmploymentStatusMonitoringModel(); var learningDeliveryFamsModel = new LearningDeliveryFAMsModel() { SOF = "110" }; var ilrModelMapperMock = new Mock <IIlrModelMapper>(); var academicYearServiceMock = new Mock <IAcademicYearService>(); ilrModelMapperMock.Setup(m => m.MapLearningDeliveryFAMs(learningDeliveryFams)).Returns(learningDeliveryFamsModel); ilrModelMapperMock.Setup(m => m.MapProviderSpecDeliveryMonitorings(providerSpecDeliveryMonitorings)).Returns(providerSpecDeliveryMonitoringModel); ilrModelMapperMock.Setup(m => m.MapProviderSpecLearnerMonitorings(providerSpecLearnerMonitorings)).Returns(providerSpecLearnerMonitoringModel); ilrModelMapperMock.Setup(m => m.MapEmploymentStatusMonitorings(It.IsAny <IEnumerable <IEmploymentStatusMonitoring> >())).Returns(employmentStatusMonitoring); var result = NewBuilder(ilrModelMapperMock.Object, academicYearServiceMock.Object).Build(reportServiceContext.Object, dependentDataMock.Object).ToList(); result.Should().HaveCount(1); var row = result[0]; row.Learner.Should().Be(learner); row.LearningDelivery.Should().Be(learningDelivery); row.LarsLearningDelivery.Should().Be(larsLearningDelivery); row.Fm35LearningDelivery.Should().Be(fm35LearningDeliveryValue); row.ProviderSpecDeliveryMonitoring.Should().Be(providerSpecDeliveryMonitoringModel); row.ProviderSpecLearnerMonitoring.Should().Be(providerSpecLearnerMonitoringModel); row.PeriodisedValues.Should().NotBeNull(); row.LearningDeliveryFAMs.Should().Be(learningDeliveryFamsModel); row.McaGlaShortCode.Should().Be("GMCA"); }