Esempio n. 1
0
        private MessageLearnerLearningDelivery GenerateZESF0001LD()
        {
            MessageLearnerLearningDelivery ld = new MessageLearnerLearningDelivery();

            ld.AimTypeSpecified   = true;
            ld.FundModel          = (int)FundModel.ESF;
            ld.FundModelSpecified = true;
            ld.LearnAimRef        = "ZESF0001";
            ld.AimType            = (long)AimType.StandAlone;

            ld.AimSeqNumber          = 1;
            ld.AimSeqNumberSpecified = true;
            ld.LearnStartDate        = DateTime.Parse(DCT.TestDataGenerator.Helpers.ValueOrFunction("[AY|OCT|14]"));
            if (Options.LD.OverrideLearnStartDate.HasValue)
            {
                ld.LearnStartDate = Options.LD.OverrideLearnStartDate.Value;
            }

            ld.LearnStartDateSpecified = true;

            ld.LearnPlanEndDate          = AYPlus1July31();
            ld.LearnPlanEndDateSpecified = true;
            ld.DelLocPostCode            = "ZZ99 9ZZ";
            ld.CompStatus          = (long)CompStatus.Continuing;
            ld.CompStatusSpecified = true;
            if (Options.LD.IncludeContract)
            {
                ld.ConRefNumber = _cache.ESFContractNumber();
            }

            ld.LearningDeliveryFAM = LDFAMs(ld);

            return(ld);
        }
Esempio n. 2
0
        private void MutateCompletionStatusForLearner(MessageLearnerLearningDelivery delivery, int completionStatus, DateTime?actualEndDate)
        {
            delivery.CompStatus          = completionStatus;
            delivery.CompStatusSpecified = true;

            if (actualEndDate.HasValue && actualEndDate.Value != DateTime.MinValue)
            {
                delivery.LearnActEndDate          = actualEndDate.Value;
                delivery.LearnActEndDateSpecified = true;
            }

            switch (completionStatus)
            {
            case (int)CompletionStatus.Completed:
                delivery.Outcome          = (int)Outcome.Achieved;
                delivery.OutcomeSpecified = true;
                break;

            case (int)CompletionStatus.Withdrawn:
                delivery.Outcome                 = (int)Outcome.NoAchievement;
                delivery.OutcomeSpecified        = true;
                delivery.WithdrawReason          = (int)WithDrawalReason.FinancialReasons;
                delivery.WithdrawReasonSpecified = true;
                break;

            default:
            {
                break;
            }
            }
        }
Esempio n. 3
0
        private MessageLearnerLearningDeliveryAppFinRecord[] LDAppFinancialRecord(MessageLearnerLearningDelivery ld)
        {
            List <MessageLearnerLearningDeliveryAppFinRecord> result = new List <MessageLearnerLearningDeliveryAppFinRecord>();

            LearnDelAppFinCode[] code = { LearnDelAppFinCode.TotalTrainingPrice, LearnDelAppFinCode.TotalAssessmentPrice, LearnDelAppFinCode.TrainingPayment, LearnDelAppFinCode.TrainingPayment };
            DateTime[]           date = { ld.LearnStartDate, ld.LearnStartDate, ld.LearnStartDate + TimeSpan.FromDays(30), ld.LearnStartDate + TimeSpan.FromDays(30) };
            long[] amount             = { 1200, 59, 110, 98 };
            LearnDelAppFinType[] type = { LearnDelAppFinType.TNP, LearnDelAppFinType.TNP, LearnDelAppFinType.PMR, LearnDelAppFinType.PMR };
            switch (Options.AimDefaultType)
            {
            case GenerationOptions.AimTypes.ApprenticeshipFM36ValidAims:
                result.Add(new MessageLearnerLearningDeliveryAppFinRecord()
                {
                    AFinType            = type[0].ToString(),
                    AFinCode            = (long)code[0],
                    AFinAmount          = amount[0],
                    AFinAmountSpecified = true,
                    AFinCodeSpecified   = true,
                    AFinDate            = date[0],
                    AFinDateSpecified   = true
                });
                break;
            }

            return(result.ToArray());
        }
Esempio n. 4
0
        private DateTime?SetLearningDeliveryDates(Aim aim, MessageLearnerLearningDelivery learningDelivery)
        {
            learningDelivery.LearnStartDate          = aim.StartDate.ToDate();
            learningDelivery.LearnStartDateSpecified = true;

            if (aim.PlannedDurationAsTimespan.HasValue)
            {
                if (aim.ProgrammeType == StandardProgrammeType)
                {
                    learningDelivery.LearnPlanEndDate =
                        learningDelivery.LearnStartDate.Add(aim.PlannedDurationAsTimespan.Value).AddDays(StandardProgrammeEpaDuration);
                    learningDelivery.LearnPlanEndDateSpecified = true;
                }
                else
                {
                    learningDelivery.LearnPlanEndDate          = learningDelivery.LearnStartDate.Add(aim.PlannedDurationAsTimespan.Value);
                    learningDelivery.LearnPlanEndDateSpecified = true;
                }
            }

            DateTime?actualEndDate = null;

            if (aim.ActualDurationAsTimespan.HasValue)
            {
                actualEndDate = aim.ProgrammeType == StandardProgrammeType
                                    ? learningDelivery.LearnStartDate.Add(aim.ActualDurationAsTimespan.Value)
                                .AddDays(StandardProgrammeEpaDuration)
                                    : learningDelivery.LearnStartDate.Add(aim.ActualDurationAsTimespan.Value);
            }


            return(actualEndDate);
        }
Esempio n. 5
0
        public void Validate_NoErrors()
        {
            var learningDelivery = new MessageLearnerLearningDelivery()
            {
                LearnStartDate = new DateTime(2017, 1, 1),
            };

            var learner = new MessageLearner()
            {
                LearningDelivery = new MessageLearnerLearningDelivery[]
                {
                    learningDelivery
                }
            };

            var validationDataMock = new Mock <IValidationData>();
            var dd07Mock           = new Mock <IDD07Rule>();

            validationDataMock.SetupGet(vd => vd.AcademicYearEnd).Returns(new DateTime(2017, 8, 1));
            dd07Mock.Setup(dd => dd.Evaluate(learningDelivery)).Returns("Y");

            var rule = new LearnStartDate_12Rule(dd07Mock.Object, validationDataMock.Object, null);

            rule.Validate(learner);
        }
Esempio n. 6
0
        public void Validate_Errors()
        {
            var learningDelivery = new MessageLearnerLearningDelivery()
            {
                LearnStartDate = new DateTime(2020, 1, 1),
                ProgType       = 1
            };

            var learner = new MessageLearner()
            {
                LearningDelivery = new MessageLearnerLearningDelivery[]
                {
                    learningDelivery,
                }
            };

            var validationDataMock         = new Mock <IValidationData>();
            var validationErrorHandlerMock = new Mock <IValidationErrorHandler <MessageLearner> >();
            var dd07Mock = new Mock <IDD07Rule>();

            validationDataMock.SetupGet(vd => vd.AcademicYearEnd).Returns(new DateTime(2018, 7, 31));
            dd07Mock.Setup(dd => dd.Evaluate(learningDelivery)).Returns("Y");

            Expression <Action <IValidationErrorHandler <MessageLearner> > > handle = veh => veh.Handle(learner, "LearnStartDate_12");

            validationErrorHandlerMock.Setup(handle);

            var rule = new LearnStartDate_12Rule(dd07Mock.Object, validationDataMock.Object, validationErrorHandlerMock.Object);

            rule.Validate(learner);

            validationErrorHandlerMock.Verify(handle, Times.Once);
        }
Esempio n. 7
0
        protected void SetupLearningDeliveryActFam(MessageLearnerLearningDelivery delivery)
        {
            var learningDeliveryFam = delivery.LearningDeliveryFAM.Single(ldf => ldf.LearnDelFAMType == LearnDelFAMType.ACT.ToString());

            learningDeliveryFam.LearnDelFAMDateTo          = delivery.LearnActEndDate;
            learningDeliveryFam.LearnDelFAMDateToSpecified = true;
        }
        public static string LearningDeliveryFAMCodeForType(this MessageLearnerLearningDelivery learningDelivery, string famType)
        {
            if (learningDelivery.LearningDeliveryFAM == null)
            {
                return(null);
            }

            return(learningDelivery.LearningDeliveryFAM.Where(ldfam => ldfam.LearnDelFAMType == famType).Select(ldfam => ldfam.LearnDelFAMCode).FirstOrDefault());
        }
Esempio n. 9
0
        /// <summary>
        /// The Learning start date must be after the learner's Date of birth
        /// </summary>
        /// <param name="ld"></param>
        /// <returns></returns>
        internal void ValidateLearnStartDate05(MessageLearnerLearningDelivery ld, MessageLearner learner)
        {
            var result = learner.DateOfBirth >= ld.LearnStartDate;

            if (result)
            {
                _validationErrorHandler.Handle(learner, "Error - ValidateLearnStartDate05");
            }
        }
        public void LearningDeliveryFAMCodeForType_Null()
        {
            var learningDelivery = new MessageLearnerLearningDelivery
            {
                LearningDeliveryFAM = null
            };

            learningDelivery.LearningDeliveryFAMCodeForType("Type").Should().BeNull();
        }
Esempio n. 11
0
        public void LearnStartEndDate_Specified_False()
        {
            var learningDelivery = new MessageLearnerLearningDelivery();

            learningDelivery.LearnStartDateSpecified = false;
            learningDelivery.LearnStartDate          = new DateTime(2018, 1, 1);

            learningDelivery.LearnStartDateNullable.Should().BeNull();
        }
Esempio n. 12
0
        /// <summary>
        /// The Learning start date must not be more than 10 years before the start of the current teaching year
        /// </summary>
        /// <param name="ld"></param>
        /// <returns></returns>
        internal void ValidateLearnStartDate02(MessageLearnerLearningDelivery ld, MessageLearner learner)
        {
            var academicStart = DateTime.Parse(_referenceData.Get("AcademicYearStart"));
            var result        = (ld.LearnStartDate.AddYears(10) - academicStart).TotalDays > 0;

            if (!result)
            {
                _validationErrorHandler.Handle(learner, "Error - ValidateLearnStartDate02");
            }
        }
Esempio n. 13
0
        private void MutateMainAimForLearner(Aim aim, MessageLearnerLearningDelivery learningDelivery)
        {
            learningDelivery.LearnAimRef = aim.AimReference;

            var actualEndDate = SetLearningDeliveryDates(aim, learningDelivery);

            MutateCompletionStatusForLearner(learningDelivery, (int)aim.CompletionStatus, actualEndDate);

            MutateLearningDeliveryFamsForLearner(learningDelivery, aim);

            SetCourseCodes(aim, learningDelivery);
        }
Esempio n. 14
0
        public void LearnActEndDate_Specified_True()
        {
            var learningDelivery = new MessageLearnerLearningDelivery();

            var date = new DateTime(2018, 1, 1);

            learningDelivery.LearnActEndDateSpecified = true;
            learningDelivery.LearnActEndDate          = date;

            learningDelivery.LearnActEndDateNullable.Should().Be(date);
            learningDelivery.LearnActEndDateNullable.Should().NotBeNull();
        }
        public bool Evaluate(MessageLearnerLearningDelivery ld)
        {
            List <SimpleRule> rules = new List <SimpleRule>
            {
                new SimpleRule("DateOfBirth", "GreaterThanOrEqual", "LearnStartDate")                     //LearnStartDate_05
            };


            Func <MessageLearnerLearningDelivery, bool> compiledRule = CompileRule <MessageLearnerLearningDelivery>(rules[0]);
            var result = compiledRule(ld);

            return(result);
        }
Esempio n. 16
0
        /// <summary>
        /// If the learning aim is not part of an apprenticeship or traineeship, then the Learning start date must not be after the current teaching year
        /// </summary>
        /// <param name="ld"></param>
        /// <returns></returns>
        internal void ValidateLearnStartDate03(MessageLearnerLearningDelivery ld, MessageLearner learner)
        {
            var dd07Result    = _dd07IsYRule.Evaluate(ld);
            var academicStart = DateTime.Parse(_referenceData.Get("AcademicYearStart"));

            var result = dd07Result == DDO7_RULE_NO &&
                         ld.ProgType != 24 &&
                         (ld.LearnStartDate - academicStart.AddDays(364)).TotalDays > 0;

            if (result)
            {
                _validationErrorHandler.Handle(learner, "Error - ValidateLearnStartDate03");
            }
        }
Esempio n. 17
0
        private IEnumerable <MessageLearnerLearningDelivery> GenerateCommunityLearningLD()
        {
            int required = Math.Max(1, Options.LD.GenerateMultipleLDs);
            List <MessageLearnerLearningDelivery> result = new List <MessageLearnerLearningDelivery>(required);

            for (int i = 0; i != required; ++i)
            {
                MessageLearnerLearningDelivery ld = new MessageLearnerLearningDelivery();

                ld.AimTypeSpecified   = true;
                ld.FundModel          = (int)FundModel.CommunityLearning;
                ld.FundModelSpecified = true;
                ld.LearnAimRef        = "60021238";
                ld.AimType            = (long)AimType.StandAlone;

                ld.AimSeqNumber          = i + 1;
                ld.AimSeqNumberSpecified = true;
                ld.LearnStartDate        = DateTime.Parse(DCT.TestDataGenerator.Helpers.ValueOrFunction("[AY|OCT|14]"));
                if (Options.LD.OverrideLearnStartDate.HasValue)
                {
                    ld.LearnStartDate = Options.LD.OverrideLearnStartDate.Value;
                }

                ld.LearnStartDateSpecified = true;

                ld.LearnPlanEndDate          = AYPlus1July31();
                ld.LearnPlanEndDateSpecified = true;
                ld.DelLocPostCode            = "ZZ99 9ZZ";
                ld.CompStatus          = (long)CompStatus.Continuing;
                ld.CompStatusSpecified = true;

                if (Options.LD.IncludeContract)
                {
                    ld.ConRefNumber = _cache.ESFContractNumber();
                }

                if (Options.LD.IncludeOutcome)
                {
                    ld.Outcome          = (int)Outcome.Achieved;
                    ld.OutcomeSpecified = true;
                }

                ld.LearningDeliveryFAM = LDFAMs(ld);
                ld.LearningDeliveryHE  = LDHEs(ld);
                result.Add(ld);
            }

            return(result);
        }
        public void LearningDeliveryFAMCodeForType_NotFound()
        {
            var learningDelivery = new MessageLearnerLearningDelivery
            {
                LearningDeliveryFAM = new MessageLearnerLearningDeliveryLearningDeliveryFAM[]
                {
                    new MessageLearnerLearningDeliveryLearningDeliveryFAM()
                    {
                        LearnDelFAMType = "Type"
                    }
                }
            };

            learningDelivery.LearningDeliveryFAMCodeForType("TypeNotFound").Should().BeNull();
        }
Esempio n. 19
0
        protected void SetDeliveryAsWithdrawn(MessageLearnerLearningDelivery delivery, Aim learnerRequestAim)
        {
            delivery.CompStatus              = (int)CompletionStatus.Withdrawn;
            delivery.CompStatusSpecified     = true;
            delivery.Outcome                 = (int)Outcome.NoAchievement;
            delivery.OutcomeSpecified        = true;
            delivery.WithdrawReason          = (int)WithDrawalReason.FinancialReasons;
            delivery.WithdrawReasonSpecified = true;
            if (learnerRequestAim.ActualDurationAsTimespan.HasValue)
            {
                delivery.LearnActEndDate =
                    learnerRequestAim.StartDate.ToDate().Add(learnerRequestAim.ActualDurationAsTimespan.Value);

                delivery.LearnActEndDateSpecified = true;
            }
        }
Esempio n. 20
0
        protected void SetupTnpAppFinRecord(MessageLearner messageLearner, MessageLearnerLearningDelivery delivery)
        {
            var appFinRecord =
                delivery.AppFinRecord.SingleOrDefault(afr => afr.AFinType == LearnDelAppFinType.TNP.ToString());

            if (appFinRecord == null)
            {
                // generate dummy record
                DCT.TestDataGenerator.Helpers.AddAfninRecord(messageLearner, LearnDelAppFinType.TNP.ToString(), (int)LearnDelAppFinCode.TotalTrainingPrice, 15000);

                appFinRecord =
                    delivery.AppFinRecord.SingleOrDefault(afr => afr.AFinType == LearnDelAppFinType.TNP.ToString());
            }

            appFinRecord.AFinDate          = delivery.LearnStartDate;
            appFinRecord.AFinDateSpecified = true;
        }
Esempio n. 21
0
        private void MutatePriceEpisodeForFam(MessageLearnerLearningDelivery delivery, List <MessageLearnerLearningDeliveryLearningDeliveryFAM> listOfLearningDeliveryFams, Price priceEpisode, Aim aim)
        {
            listOfLearningDeliveryFams.Add(new MessageLearnerLearningDeliveryLearningDeliveryFAM()
            {
                LearnDelFAMType              = LearnDelFAMType.ACT.ToString(),
                LearnDelFAMCode              = ((int)priceEpisode.ContractType).ToString(),
                LearnDelFAMDateFrom          = delivery.LearnStartDate,
                LearnDelFAMDateFromSpecified = true,
                LearnDelFAMDateTo            = delivery.LearnActEndDate,
                LearnDelFAMDateToSpecified   = aim.ActualDurationAsTimespan.HasValue,
            });

            if (aim.IsMainAim)
            {
                MutateMainAim(delivery, aim, priceEpisode);
            }
        }
Esempio n. 22
0
        private IEnumerable <MessageLearnerLearningDelivery> GenerateComponentLD()
        {
            int required = Math.Max(1, Options.LD.GenerateMultipleLDs);
            List <MessageLearnerLearningDelivery> result = new List <MessageLearnerLearningDelivery>(required);

            for (int i = 0; i != required; ++i)
            {
                MessageLearnerLearningDelivery ld = new MessageLearnerLearningDelivery();

                ld.AimTypeSpecified   = true;
                ld.FundModel          = (int)FundModel.Apprenticeships;
                ld.FundModelSpecified = true;
                ld.LearnAimRef        = "50104767";
                ld.AimType            = (long)AimType.ComponentAim;

                ld.AimSeqNumber          = 2;
                ld.AimSeqNumberSpecified = true;
                ld.LearnStartDate        = DateTime.Parse(DCT.TestDataGenerator.Helpers.ValueOrFunction("[AY|OCT|14]"));
                if (Options.LD.OverrideLearnStartDate.HasValue)
                {
                    ld.LearnStartDate = Options.LD.OverrideLearnStartDate.Value;
                }

                ld.LearnStartDateSpecified = true;

                ld.LearnPlanEndDate          = AYPlus1July31();
                ld.LearnPlanEndDateSpecified = true;
                ld.DelLocPostCode            = "ZZ99 9ZZ";
                ld.CompStatus          = (long)CompStatus.Continuing;
                ld.CompStatusSpecified = true;

                ld.FworkCode           = 420;
                ld.FworkCodeSpecified  = true;
                ld.PwayCode            = 1;
                ld.PwayCodeSpecified   = true;
                ld.ProgType            = (long)ProgType.AdvancedLevelApprenticeship;
                ld.ProgTypeSpecified   = true;
                ld.LearningDeliveryFAM = LDFAMs(ld);
                ld.LearningDeliveryHE  = LDHEs(ld);

                result.Add(ld);
            }

            return(result);
        }
        public void Exclude_False_Null()
        {
            var uln_02 = new ULN_02Rule(null);

            var learningDelivery = new MessageLearnerLearningDelivery()
            {
                LearningDeliveryFAM = new MessageLearnerLearningDeliveryLearningDeliveryFAM[]
                {
                    new MessageLearnerLearningDeliveryLearningDeliveryFAM()
                    {
                        LearnDelFAMType = "No",
                        LearnDelFAMCode = "2"
                    }
                }
            };

            uln_02.Exclude(learningDelivery).Should().BeFalse();
        }
Esempio n. 24
0
 public static void SetEndDates(MessageLearnerLearningDelivery ld, DateTime endDate, SetAchDate modifyAch)
 {
     ld.LearnPlanEndDate         = endDate;
     ld.LearnActEndDate          = endDate;
     ld.LearnActEndDateSpecified = true;
     ld.CompStatus       = (int)CompStatus.Completed;
     ld.Outcome          = (int)Outcome.Achieved;
     ld.OutcomeSpecified = true;
     if (modifyAch == SetAchDate.SetAchDate)
     {
         ld.AchDate          = ld.LearnActEndDate;
         ld.AchDateSpecified = true;
     }
     else
     {
         ld.AchDateSpecified = false;
     }
 }
        public void Exclude_True()
        {
            var rule = new ULN_03Rule(null, null);

            var learningDelivery = new MessageLearnerLearningDelivery()
            {
                LearningDeliveryFAM = new MessageLearnerLearningDeliveryLearningDeliveryFAM[]
                {
                    new MessageLearnerLearningDeliveryLearningDeliveryFAM()
                    {
                        LearnDelFAMType = "ACT",
                        LearnDelFAMCode = "1"
                    }
                }
            };

            rule.Exclude(learningDelivery).Should().BeTrue();
        }
Esempio n. 26
0
        private void Mutate19(MessageLearner learner, bool valid)
        {
            // add a new core aim as a copy and then mutate the old one to something else
            List <MessageLearnerLearningDelivery> lds   = learner.LearningDelivery.ToList();
            MessageLearnerLearningDelivery        newLd = lds[0].DeepClone();

            lds.Add(newLd);
            var lastld = lds.Last();

            lastld.LearnAimRef = "50023494";
            lastld.AimSeqNumber++;
            learner.LearningDelivery = lds.ToArray();

            Helpers.AddOrChangeSourceOfFunding(learner.LearningDelivery[0], LearnDelFAMCode.SOF_ESFA_Adult);
            learner.LearningDelivery[0].AimType = (int)AimType.StandAlone;

            Helpers.MutateDOB(learner, valid, Helpers.AgeRequired.Exact19, Helpers.BasedOn.SchoolAYStart, Helpers.MakeOlderOrYoungerWhenInvalid.Younger);
        }
        public void Exclude_False_NoMatch()
        {
            var rule = new ULN_06Rule(null, null);

            var learningDelivery = new MessageLearnerLearningDelivery()
            {
                LearningDeliveryFAM = new MessageLearnerLearningDeliveryLearningDeliveryFAM[]
                {
                    new MessageLearnerLearningDeliveryLearningDeliveryFAM()
                    {
                        LearnDelFAMType = "ACT",
                        LearnDelFAMCode = "2"
                    }
                }
            };

            rule.Exclude(learningDelivery).Should().BeFalse();
        }
        public void Exclude_True(string famType, string famCode)
        {
            var rule = new ULN_06Rule(null, null);

            var learningDelivery = new MessageLearnerLearningDelivery()
            {
                LearningDeliveryFAM = new MessageLearnerLearningDeliveryLearningDeliveryFAM[]
                {
                    new MessageLearnerLearningDeliveryLearningDeliveryFAM()
                    {
                        LearnDelFAMType = famType,
                        LearnDelFAMCode = famCode
                    }
                }
            };

            rule.Exclude(learningDelivery).Should().BeTrue();
        }
        public void Exclude_True()
        {
            var uln_02 = new ULN_02Rule(null);

            var learningDelivery = new MessageLearnerLearningDelivery()
            {
                LearningDeliveryFAM = new MessageLearnerLearningDeliveryLearningDeliveryFAM[]
                {
                    new MessageLearnerLearningDeliveryLearningDeliveryFAM()
                    {
                        LearnDelFAMType = "SOF",
                        LearnDelFAMCode = "1"
                    }
                }
            };

            uln_02.Exclude(learningDelivery).Should().BeTrue();
        }
Esempio n. 30
0
        private void MutateDeliveryAppFinRecordToPMR(MessageLearnerLearningDelivery delivery, Price priceEpisode)
        {
            var appFinRecords = new List <MessageLearnerLearningDeliveryAppFinRecord>();

            appFinRecords.Add(new MessageLearnerLearningDeliveryAppFinRecord()
            {
                AFinAmount = CalculateEmployerContribution(priceEpisode.SfaContributionPercentage,
                                                           priceEpisode.TotalTrainingPrice),
                AFinAmountSpecified = true,
                AFinType            = LearnDelAppFinType.PMR.ToString(),
                AFinCode            = (int)LearnDelAppFinCode.TrainingPayment,
                AFinCodeSpecified   = true,
                AFinDate            = delivery.LearnActEndDate.AddMonths(-1),
                AFinDateSpecified   = true
            });

            delivery.AppFinRecord = appFinRecords.ToArray();
        }