private OnProgrammeEarning CreateOnProgramEarning(OnProgrammeEarningType type) { var onProgrammeEarning = new OnProgrammeEarning() { Type = type, Periods = CreatePeriods(12, 1000m) }; return(onProgrammeEarning); }
private void AddOnProgPayment(Payment paymentToValidate, List <PeriodisedRequiredPaymentEvent> expectedPayments, decimal amountDue, OnProgrammeEarningType type) { var deliveryPeriod = new DeliveryPeriodBuilder().WithSpecDate(paymentToValidate.DeliveryPeriod).Build(); var payment = CreateContractTypeRequiredPaymentEvent(amountDue, type, deliveryPeriod); if (payment.AmountDue != 0) { expectedPayments.Add(payment); } }
public void CanMapOnProgrammeEarnings(OnProgrammeEarningType type) { var payableEarning = Mapper.Map <ApprenticeshipContractType1EarningEvent, PayableEarningEvent>(earningEventPayment); payableEarning.OnProgrammeEarnings.Should().NotBeNull(); var payment = payableEarning.OnProgrammeEarnings.Single(o => o.Type == type); payment.Periods.Count().Should().Be(12); payment.Periods.First().Amount.Should().Be(100); payment.Periods.First().PriceEpisodeIdentifier.Should().BeEquivalentTo("p-1"); }
// ReSharper disable once InconsistentNaming private static string OnProgrammeEarningTypeToFM36AttributeName(OnProgrammeEarningType onProgrammeEarningType) { switch (onProgrammeEarningType) { case OnProgrammeEarningType.Balancing: return("PriceEpisodeBalancePayment"); case OnProgrammeEarningType.Completion: return("PriceEpisodeCompletionPayment"); case OnProgrammeEarningType.Learning: return("PriceEpisodeOnProgPayment"); default: throw new InvalidOperationException($"Cannot get FM36 attribute name for unknown on-programme earning type: {onProgrammeEarningType}"); } }
private PeriodisedRequiredPaymentEvent CreateContractTypeRequiredPaymentEvent(decimal amountDue, OnProgrammeEarningType onProgrammeEarningType, byte deliveryPeriod) { var contractType = EnumHelper.GetContractType(currentIlr, currentPriceEpisodes); switch (contractType) { case ContractType.Act1: return(new CalculatedRequiredLevyAmount { AmountDue = amountDue, OnProgrammeEarningType = onProgrammeEarningType, DeliveryPeriod = deliveryPeriod }); case ContractType.Act2: return(new CalculatedRequiredCoInvestedAmount { AmountDue = amountDue, OnProgrammeEarningType = onProgrammeEarningType, DeliveryPeriod = deliveryPeriod }); default: throw new InvalidOperationException("Cannot create the RequiredPaymentMatcher invalid contract type "); } }
private OnProgrammeEarning CreateOnProgrammeEarning(IntermediateLearningAim source, OnProgrammeEarningType onProgrammeEarningType) { var attributeName = OnProgrammeEarningTypeToFM36AttributeName(onProgrammeEarningType); var allPeriods = source.PriceEpisodes.Select(p => p.PriceEpisodePeriodisedValues.SingleOrDefault(v => v.AttributeName == attributeName)) .Where(p => p != null) .ToArray(); var periods = new EarningPeriod[12]; for (byte i = 1; i <= 12; i++) { var periodValues = allPeriods.Select(p => p.GetPeriodValue(i)).ToArray(); var periodValue = periodValues.SingleOrDefault(v => v.GetValueOrDefault(0) != 0).GetValueOrDefault(0); var priceEpisodeIdentifier = periodValue == 0 ? null : source.PriceEpisodes[periodValues.IndexOf(periodValue)].PriceEpisodeIdentifier; var sfaContributionPercentage = source.PriceEpisodes.CalculateSfaContributionPercentage(i, priceEpisodeIdentifier); periods[i - 1] = new EarningPeriod { Period = i, Amount = periodValue.AsRounded(), PriceEpisodeIdentifier = priceEpisodeIdentifier, SfaContributionPercentage = sfaContributionPercentage, }; } return(new OnProgrammeEarning { Type = onProgrammeEarningType, Periods = new ReadOnlyCollection <EarningPeriod>(periods) }); }