public void Generate_No_Earnings_When_Fm36_Only_Has_Invalid_Contracts()
        {
            var cmd = new LearnerBuilder()
                      .BuildLearnerCommand();

            // Arrange
            cmd.Learner.PriceEpisodes.First().PriceEpisodeValues.PriceEpisodeContractType = "none";

            // Act
            var earningsEvents = sut.Build(cmd);

            // Assert
            earningsEvents.Should().BeEmpty();
        }
        public void RestartAfterPlannedBreakShouldHaveOneMainAim()
        {
            var builder = new ApprenticeshipContractTypeEarningsEventBuilder(new ApprenticeshipContractTypeEarningsEventFactory(), redundancyEarningService.Object, mapper);
            var events  = builder.Build(FileHelpers.CreateFromFile(filename, learnerRefNo));

            events.Should().HaveCount(1);
            events.First().PriceEpisodes.Should().HaveCount(2);
            events.First().OnProgrammeEarnings.Single(x => x.Type == OnProgrammeEarningType.Learning).Periods.Should().HaveCount(12);
            var learning = events.First().OnProgrammeEarnings.Single(x => x.Type == OnProgrammeEarningType.Learning);

            learning.Periods[0].Amount.Should().Be(200);
            learning.Periods[1].Amount.Should().Be(200);
            learning.Periods[2].Amount.Should().Be(0);
            learning.Periods[3].Amount.Should().Be(0);
            learning.Periods[4].Amount.Should().Be(200);
            learning.Periods[5].Amount.Should().Be(200);
            learning.Periods[6].Amount.Should().Be(200);
            events.First().IncentiveEarnings.Single(x => x.Type == IncentiveEarningType.LearningSupport).Periods.Should().HaveCount(12);
            var learningSupport = events.First().IncentiveEarnings.Single(x => x.Type == IncentiveEarningType.LearningSupport);

            learningSupport.Periods[0].Amount.Should().Be(150);
            learningSupport.Periods[1].Amount.Should().Be(150);
            learningSupport.Periods[2].Amount.Should().Be(0);
            learningSupport.Periods[3].Amount.Should().Be(0);
            learningSupport.Periods[4].Amount.Should().Be(150);
            learningSupport.Periods[5].Amount.Should().Be(150);
            learningSupport.Periods[6].Amount.Should().Be(150);
        }
        public void RestartAfterPlannedBreakMainAimShouldHaveValidLearnStartDate()
        {
            var builder = new ApprenticeshipContractTypeEarningsEventBuilder(new ApprenticeshipContractTypeEarningsEventFactory(), redundancyEarningService.Object, mapper);
            var events  = builder.Build(FileHelpers.CreateFromFile(filename, learnerRefNo));

            events.First().LearningAim.StartDate.Should().Be(DateTime.Parse("2019-08-06T00:00:00+00:00"));
            events.First().StartDate.Should().Be(DateTime.Parse("2019-08-06T00:00:00+00:00"));
        }
        public void BuildFundingLineTypeCorrectly()
        {
            var processLearnerCommand = new ProcessLearnerCommand
            {
                Ukprn                 = 1,
                JobId                 = 1,
                CollectionPeriod      = 1,
                CollectionYear        = 1920,
                IlrSubmissionDateTime = DateTime.Today,
                SubmissionDate        = DateTime.Today,
                Learner               = new FM36Learner
                {
                    LearnRefNumber     = "learner-a",
                    LearningDeliveries = new List <LearningDelivery>
                    {
                        new LearningDelivery
                        {
                            AimSeqNumber           = 1,
                            LearningDeliveryValues = new LearningDeliveryValues
                            {
                                LearnAimRef = "ZPROG001",
                                StdCode     = 100,
                                FworkCode   = 200,
                                ProgType    = 300,
                                PwayCode    = 400,
                                LearnDelInitialFundLineType = "Funding Line Type 1",
                                LearnStartDate = DateTime.Today.AddDays(-5)
                            }
                        },
                        new LearningDelivery
                        {
                            AimSeqNumber           = 2,
                            LearningDeliveryValues = new LearningDeliveryValues
                            {
                                LearnAimRef = "ZPROG001",
                                StdCode     = 100,
                                FworkCode   = 200,
                                ProgType    = 300,
                                PwayCode    = 400,
                                LearnDelInitialFundLineType = "Funding Line Type 2",
                                LearnStartDate = DateTime.Today.AddDays(-6)
                            },
                        }
                    },
                    PriceEpisodes = new List <PriceEpisode>
                    {
                        new PriceEpisode
                        {
                            PriceEpisodeIdentifier = "pe-1",
                            PriceEpisodeValues     = new PriceEpisodeValues
                            {
                                EpisodeStartDate               = DateTime.Parse("2019-08-01"),
                                PriceEpisodeActualEndDate      = null,
                                PriceEpisodeFundLineType       = "19+ Apprenticeship Non-Levy Contract (procured)",
                                EpisodeEffectiveTNPStartDate   = DateTime.Parse("2017-05-08T00:00:00+00:00"),
                                PriceEpisodeContractType       = "Non-Levy Contract",
                                PriceEpisodeAimSeqNumber       = 1,
                                PriceEpisodePlannedEndDate     = DateTime.Parse("2019-10-01"),
                                PriceEpisodePlannedInstalments = 12,
                                PriceEpisodeCompletionElement  = 3000,
                                PriceEpisodeInstalmentValue    = 1000,
                                TNP1 = 15000,
                                TNP2 = 15000,
                                PriceEpisodeCompleted      = true,
                                PriceEpisodeCumulativePMRs = 13,
                                PriceEpisodeCompExemCode   = 14,
                                PriceEpisodeTotalTNPPrice  = 30000
                            },
                            PriceEpisodePeriodisedValues = new List <PriceEpisodePeriodisedValues>
                            {
                                new PriceEpisodePeriodisedValues
                                {
                                    AttributeName = "PriceEpisodeOnProgPayment",
                                    Period1       = 1000,
                                    Period2       = 1000,
                                    Period3       = 1000,
                                    Period4       = 1000,
                                    Period5       = 1000,
                                    Period6       = 1000,
                                    Period7       = 1000,
                                    Period8       = 1000,
                                    Period9       = 1000,
                                    Period10      = 1000,
                                    Period11      = 1000,
                                    Period12      = 1000,
                                },
                                new PriceEpisodePeriodisedValues
                                {
                                    AttributeName = "PriceEpisodeCompletionPayment",
                                    Period1       = 0,
                                    Period2       = 0,
                                    Period3       = 0,
                                    Period4       = 0,
                                    Period5       = 0,
                                    Period6       = 0,
                                    Period7       = 0,
                                    Period8       = 0,
                                    Period9       = 0,
                                    Period10      = 0,
                                    Period11      = 0,
                                    Period12      = 3000,
                                },
                                new PriceEpisodePeriodisedValues
                                {
                                    AttributeName = "PriceEpisodeBalancePayment",
                                    Period1       = 0,
                                    Period2       = 0,
                                    Period3       = 0,
                                    Period4       = 0,
                                    Period5       = 0,
                                    Period6       = 0,
                                    Period7       = 0,
                                    Period8       = 0,
                                    Period9       = 0,
                                    Period10      = 0,
                                    Period11      = 0,
                                    Period12      = 3000,
                                },
                            }
                        },
                        new PriceEpisode
                        {
                            PriceEpisodeIdentifier = "pe-2",
                            PriceEpisodeValues     = new PriceEpisodeValues
                            {
                                EpisodeStartDate               = new DateTime(2019, 10, 1),
                                PriceEpisodeActualEndDate      = null,
                                PriceEpisodeFundLineType       = "19+ Apprenticeship Levy Contract (procured)",
                                EpisodeEffectiveTNPStartDate   = new DateTime(2017, 05, 1),
                                PriceEpisodeContractType       = "Levy Contract",
                                PriceEpisodeAimSeqNumber       = 2,
                                PriceEpisodePlannedEndDate     = new DateTime(2019, 12, 1),
                                PriceEpisodePlannedInstalments = 12,
                                PriceEpisodeCompletionElement  = 3000,
                                PriceEpisodeInstalmentValue    = 1000,
                                TNP1 = 15000,
                                TNP2 = 15000,
                                PriceEpisodeCompleted      = true,
                                PriceEpisodeCumulativePMRs = 13,
                                PriceEpisodeCompExemCode   = 14,
                                PriceEpisodeTotalTNPPrice  = 30000
                            },
                            PriceEpisodePeriodisedValues = new List <PriceEpisodePeriodisedValues>
                            {
                                new PriceEpisodePeriodisedValues
                                {
                                    AttributeName = "PriceEpisodeOnProgPayment",
                                    Period1       = 1000,
                                    Period2       = 1000,
                                    Period3       = 1000,
                                    Period4       = 1000,
                                    Period5       = 1000,
                                    Period6       = 1000,
                                    Period7       = 1000,
                                    Period8       = 1000,
                                    Period9       = 1000,
                                    Period10      = 1000,
                                    Period11      = 1000,
                                    Period12      = 1000,
                                },
                                new PriceEpisodePeriodisedValues
                                {
                                    AttributeName = "PriceEpisodeCompletionPayment",
                                    Period1       = 0,
                                    Period2       = 0,
                                    Period3       = 0,
                                    Period4       = 0,
                                    Period5       = 0,
                                    Period6       = 0,
                                    Period7       = 0,
                                    Period8       = 0,
                                    Period9       = 0,
                                    Period10      = 0,
                                    Period11      = 0,
                                    Period12      = 3000,
                                },
                                new PriceEpisodePeriodisedValues
                                {
                                    AttributeName = "PriceEpisodeBalancePayment",
                                    Period1       = 0,
                                    Period2       = 0,
                                    Period3       = 0,
                                    Period4       = 0,
                                    Period5       = 0,
                                    Period6       = 0,
                                    Period7       = 0,
                                    Period8       = 0,
                                    Period9       = 0,
                                    Period10      = 0,
                                    Period11      = 0,
                                    Period12      = 3000,
                                },
                            }
                        },
                    }
                }
            };

            var builder = new ApprenticeshipContractTypeEarningsEventBuilder(new ApprenticeshipContractTypeEarningsEventFactory(), mapper);

            var events = builder.Build(processLearnerCommand);

            events.Should().NotBeNull();
            events[0].PriceEpisodes[0].FundingLineType.Should().Be(processLearnerCommand.Learner.PriceEpisodes[0].PriceEpisodeValues.PriceEpisodeFundLineType);
            events[1].PriceEpisodes[0].FundingLineType.Should().Be(processLearnerCommand.Learner.PriceEpisodes[1].PriceEpisodeValues.PriceEpisodeFundLineType);
        }