public PeriodisedRequiredPaymentEvent Create(EarningType earningType, int transactionType) { PeriodisedRequiredPaymentEvent paymentEvent = null; switch (earningType) { case EarningType.CoInvested: if (IsValidPaymentType <OnProgrammeEarningType>(transactionType)) { paymentEvent = new CalculatedRequiredCoInvestedAmount { OnProgrammeEarningType = (OnProgrammeEarningType)transactionType, }; } break; case EarningType.Incentive: if (IsValidPaymentType <IncentivePaymentType>(transactionType)) { paymentEvent = new CalculatedRequiredIncentiveAmount { Type = (IncentivePaymentType)transactionType, }; } break; case EarningType.Levy: if (IsValidPaymentType <OnProgrammeEarningType>(transactionType)) { paymentEvent = new CalculatedRequiredLevyAmount { OnProgrammeEarningType = (OnProgrammeEarningType)transactionType, }; } break; default: throw new InvalidOperationException( $"Unknown earning type found: {earningType:G}. Cannot create the PeriodisedRequiredPaymentEvent."); } if (paymentEvent == null) { logger.LogError( $"Invalid EarningType and TransactionType combination: EarningType: {earningType:G}, TransactionType: {transactionType}"); } return(paymentEvent); }
private void MapCommon(RequiredPayment requiredPayment, PeriodisedRequiredPaymentEvent paymentEvent) { paymentEvent.Learner = TestSession.Learner.ToLearner(); paymentEvent.Ukprn = TestSession.Ukprn; paymentEvent.AmountDue = requiredPayment.Amount; paymentEvent.JobId = TestSession.JobId; paymentEvent.EventTime = DateTimeOffset.UtcNow; paymentEvent.CollectionPeriod = CollectionPeriodFactory.CreateFromAcademicYearAndPeriod(AcademicYear, CollectionPeriod); paymentEvent.DeliveryPeriod = requiredPayment.DeliveryPeriod; paymentEvent.IlrSubmissionDateTime = TestSession.IlrSubmissionTime; paymentEvent.LearningAim = TestSession.Learner.Course.ToLearningAim(); paymentEvent.PriceEpisodeIdentifier = requiredPayment.PriceEpisodeIdentifier; }
private static void AssertCommonProperties(PeriodisedRequiredPaymentEvent requiredPayment, IEarningEvent earning) { Assert.AreEqual(requiredPayment.Learner.Uln, earning.Learner.Uln); Assert.AreEqual(requiredPayment.Learner.ReferenceNumber, earning.Learner.ReferenceNumber); Assert.AreEqual(requiredPayment.Ukprn, earning.Ukprn); Assert.AreEqual(requiredPayment.CollectionPeriod.Period, earning.CollectionPeriod.Period); Assert.AreEqual(requiredPayment.CollectionPeriod.AcademicYear, earning.CollectionPeriod.AcademicYear); Assert.AreEqual(requiredPayment.LearningAim.PathwayCode, earning.LearningAim.PathwayCode); Assert.AreEqual(requiredPayment.LearningAim.FrameworkCode, earning.LearningAim.FrameworkCode); Assert.AreEqual(requiredPayment.LearningAim.ProgrammeType, earning.LearningAim.ProgrammeType); Assert.AreEqual(requiredPayment.LearningAim.Reference, earning.LearningAim.Reference); Assert.AreEqual(requiredPayment.LearningAim.StandardCode, earning.LearningAim.StandardCode); Assert.AreEqual(requiredPayment.JobId, earning.JobId); Assert.AreEqual(requiredPayment.IlrSubmissionDateTime, earning.IlrSubmissionDateTime); }
public static void ShouldBeMappedTo(this PeriodisedRequiredPaymentEvent paymentEvent, IdentifiedRemovedLearningAim identifiedLearningAim) { paymentEvent.EarningEventId.Should().Be(Guid.Empty); paymentEvent.EventId.Should().NotBe(Guid.Empty); paymentEvent.CollectionPeriod.AcademicYear.Should().Be(identifiedLearningAim.CollectionPeriod.AcademicYear); paymentEvent.CollectionPeriod.Period.Should().Be(identifiedLearningAim.CollectionPeriod.Period); paymentEvent.IlrSubmissionDateTime.Should().Be(identifiedLearningAim.IlrSubmissionDateTime); paymentEvent.JobId.Should().Be(identifiedLearningAim.JobId); paymentEvent.Learner.ReferenceNumber.Should().Be(identifiedLearningAim.Learner.ReferenceNumber); paymentEvent.LearningAim.Reference.Should().Be(identifiedLearningAim.LearningAim.Reference); paymentEvent.LearningAim.FrameworkCode.Should().Be(identifiedLearningAim.LearningAim.FrameworkCode); paymentEvent.LearningAim.FundingLineType.Should().Be(identifiedLearningAim.LearningAim.FundingLineType); paymentEvent.LearningAim.PathwayCode.Should().Be(identifiedLearningAim.LearningAim.PathwayCode); paymentEvent.LearningAim.ProgrammeType.Should().Be(identifiedLearningAim.LearningAim.ProgrammeType); paymentEvent.LearningAim.StandardCode.Should().Be(identifiedLearningAim.LearningAim.StandardCode); }
public static void ShouldBeMappedTo(this PeriodisedRequiredPaymentEvent paymentEvent, PaymentHistoryEntity historicPayment) { paymentEvent.EarningEventId.Should().Be(Guid.Empty); paymentEvent.EventId.Should().NotBe(Guid.Empty); paymentEvent.AccountId.Should().Be(historicPayment.AccountId); paymentEvent.ApprenticeshipEmployerType.Should().Be(historicPayment.ApprenticeshipEmployerType); paymentEvent.EventId.Should().NotBe(historicPayment.ExternalId); paymentEvent.EventId.Should().NotBe(Guid.Empty); paymentEvent.ActualEndDate.Should().Be(historicPayment.ActualEndDate); paymentEvent.CompletionAmount.Should().Be(historicPayment.CompletionAmount); paymentEvent.ContractType.Should().Be(historicPayment.ContractType); paymentEvent.CompletionStatus.Should().Be(historicPayment.CompletionStatus); paymentEvent.DeliveryPeriod.Should().Be(historicPayment.DeliveryPeriod); paymentEvent.InstalmentAmount.Should().Be(historicPayment.InstalmentAmount); paymentEvent.ActualEndDate.Should().Be(historicPayment.ActualEndDate); }
private static void AddRefundCommitmentDetails(RequiredPayment requiredPayment, PeriodisedRequiredPaymentEvent requiredPaymentEvent) { if (requiredPayment.Amount < 0) { requiredPaymentEvent.ApprenticeshipId = requiredPayment.ApprenticeshipId; requiredPaymentEvent.ApprenticeshipPriceEpisodeId = requiredPayment.ApprenticeshipPriceEpisodeId; requiredPaymentEvent.ApprenticeshipEmployerType = requiredPayment.ApprenticeshipEmployerType; } }
private static void AddAimSeqNumber(EarningPeriod period, TEarningEvent earningEvent, PeriodisedRequiredPaymentEvent requiredPaymentEvent) { var priceEpisode = earningEvent?.PriceEpisodes.FirstOrDefault(x => x.Identifier == period.PriceEpisodeIdentifier); requiredPaymentEvent.LearningAimSequenceNumber = priceEpisode != null ? priceEpisode.LearningAimSequenceNumber : earningEvent.LearningAim.SequenceNumber; }