/// <summary> /// If all apprenticeships share the same Funding Cap, this is it. /// If they have different funding caps, or there is no trainingprogram or apprenticeships, /// or there is not enough data to calculate the funding cap for each apprenticeship, this is null /// </summary> private int?CalculateCommonFundingCap() { if (TrainingProgramme == null || !Apprenticeships.Any()) { return(null); } if (!IsLinkedToChangeOfPartyRequest && Apprenticeships.Any(a => !a.StartDate.HasValue)) { return(null); } int firstFundingCap = IsLinkedToChangeOfPartyRequest ? TrainingProgramme.FundingCapOn(Apprenticeships.First().OriginalStartDate.Value) : TrainingProgramme.FundingCapOn(Apprenticeships.First().StartDate.Value); // check for magic 0, which means unable to calculate a funding cap (e.g. date out of bounds) if (firstFundingCap == 0) { return(null); } if (Apprenticeships.Skip(1).Any(a => TrainingProgramme.FundingCapOn(a.StartDate.Value) != firstFundingCap)) { return(null); } return(firstFundingCap); }
/// <summary> /// If all apprenticeships share the same Funding Cap, this is it. /// If they have different funding caps, or there is no trainingprogram or apprenticeships, /// or there is not enough data to calculate the funding cap for each apprenticeship, this is null /// </summary> private int?CalculateCommonFundingCap() { if (TrainingProgramme == null || !Apprenticeships.Any()) { return(null); } if (Apprenticeships.Any(a => !a.StartDate.HasValue)) { return(null); } var firstFundingCap = TrainingProgramme.FundingCapOn(Apprenticeships.First().StartDate.Value); // check for magic 0, which means unable to calculate a funding cap (e.g. date out of bounds) if (firstFundingCap == 0) { return(null); } if (Apprenticeships.Skip(1).Any(a => TrainingProgramme.FundingCapOn(a.StartDate.Value) != firstFundingCap)) { return(null); } return(firstFundingCap); }
public void ThenTheApplicableFundingPeriodIsUsed(DateTime effectiveDate, int expectCap) { //Act var result = _course.FundingCapOn(effectiveDate); //Assert Assert.AreEqual(expectCap, result); }
private int?GetFundingBandCap(TrainingProgramme course, DateTime?startDate) { if (course == null) { return(null); } var cap = course.FundingCapOn(startDate.Value); if (cap > 0) { return(cap); } return(null); }
public bool IsOverFundingLimit(TrainingProgramme trainingProgramme) { if (trainingProgramme == null) { return(false); } if (!StartDate.HasValue) { return(false); } var fundingCapAtStartDate = trainingProgramme.FundingCapOn(StartDate.Value); return(Cost.HasValue && fundingCapAtStartDate > 0 && Cost > fundingCapAtStartDate); }
public bool IsOverFundingLimit(TrainingProgramme trainingProgramme, bool isLinkedToChangeOfPartyRequest = false) { if (trainingProgramme == null) { return(false); } if (!isLinkedToChangeOfPartyRequest && !StartDate.HasValue) { return(false); } var fundingCapAtStartDate = trainingProgramme.FundingCapOn(isLinkedToChangeOfPartyRequest ? OriginalStartDate.Value : StartDate.Value); return(Cost.HasValue && fundingCapAtStartDate > 0 && Cost > fundingCapAtStartDate); }