Beispiel #1
0
        public async Task GetLearnerPaymentHistoryReturnsAllPaymentsForLearner(ContractType contractType)
        {
            var payment1 = CreateTestPayment(50.99m, contractType);
            var payment2 = CreateTestPayment(-50.99m, contractType);

            context.Payment.Add(payment1);
            context.Payment.Add(payment2);
            await context.SaveChangesAsync();

            var results = await sut.GetReadOnlyLearnerPaymentHistory(101, contractType, "123456", "ref", 102, 103, 104, 105, 2021, 2, CancellationToken.None);

            results.Count.Should().Be(2);
        }
Beispiel #2
0
        public async Task DeleteOldMonthEndPayment(CollectionPeriod collectionPeriod,
                                                   long ukprn,
                                                   DateTime currentIlrSubmissionDateTime,
                                                   CancellationToken cancellationToken = default(CancellationToken))
        {
            var oldSubmittedIlrPayments = paymentsDataContext.Payment
                                          .Where(p => p.Ukprn == ukprn &&
                                                 p.CollectionPeriod.Period == collectionPeriod.Period &&
                                                 p.CollectionPeriod.AcademicYear == collectionPeriod.AcademicYear &&
                                                 p.IlrSubmissionDateTime < currentIlrSubmissionDateTime);

            paymentsDataContext.Payment.RemoveRange(oldSubmittedIlrPayments);
            await paymentsDataContext.SaveChangesAsync(cancellationToken);
        }
        public async Task ReplaceFailures(List <long> oldFailureIds, List <DataLockFailureEntity> newFailures, Guid earningEventId, Guid dataLockEventId)
        {
            if (oldFailureIds.Count > 0)
            {
                logger.LogDebug($"deleting {oldFailureIds.Count} errors");
            }
            if (newFailures.Count > 0)
            {
                logger.LogDebug($"adding {newFailures.Count} new failures for UKPRN {newFailures[0].Ukprn}");
            }

            paymentsDataContext.DataLockFailure.RemoveRange(paymentsDataContext.DataLockFailure.Where(f => oldFailureIds.Contains(f.Id)));

            await paymentsDataContext.DataLockFailure.AddRangeAsync(newFailures.Select(f => new DataLockFailureModel
            {
                EarningEventId           = earningEventId,
                DataLockEventId          = dataLockEventId,
                CollectionPeriod         = f.CollectionPeriod,
                AcademicYear             = f.AcademicYear,
                Ukprn                    = f.Ukprn,
                TransactionType          = f.TransactionType,
                DeliveryPeriod           = f.DeliveryPeriod,
                LearnerReferenceNumber   = f.LearnerReferenceNumber,
                LearnerUln               = f.LearnerUln,
                LearningAimFrameworkCode = f.LearningAimFrameworkCode,
                LearningAimPathwayCode   = f.LearningAimPathwayCode,
                LearningAimProgrammeType = f.LearningAimProgrammeType,
                LearningAimReference     = f.LearningAimReference,
                LearningAimStandardCode  = f.LearningAimStandardCode,
                Amount                   = f.EarningPeriod.Amount,
                EarningPeriod            = JsonConvert.SerializeObject(f.EarningPeriod)
            })).ConfigureAwait(false);

            await paymentsDataContext.SaveChangesAsync().ConfigureAwait(false);
        }
        public async Task GetEmployerCoInvestedPaymentHistoryTotal_RoundsAllAmountsDown()
        {
            var key      = CreateTestApprenticeshipKey();
            var payment1 = CreateTestPayment();

            payment1.Amount = 50.99m;

            var payment2 = CreateTestPayment();

            payment2.Amount = 50.99m;

            context.Payment.Add(payment1);
            context.Payment.Add(payment2);
            await context.SaveChangesAsync();

            var actual = await sut.GetEmployerCoInvestedPaymentHistoryTotal(key);

            actual.Should().Be(100);
        }
Beispiel #5
0
        private async Task UpdatePaymentHistoryTables(long ukprn, long originalUln, long newUln, string learnRefNumber)
        {
            var payments = dataContext.Payment.Where(p => p.Ukprn == ukprn && p.LearnerUln == originalUln);

            foreach (var payment in payments)
            {
                payment.LearnerReferenceNumber = learnRefNumber;
                payment.LearnerUln             = newUln;
            }

            await dataContext.SaveChangesAsync();
        }
Beispiel #6
0
        public async Task ReplaceEmployerProviderPriorities(long employerAccountId, List <EmployerProviderPriorityModel> paymentPriorityModels, CancellationToken cancellationToken = default(CancellationToken))
        {
            var previousEmployerPriorities = dataContext.EmployerProviderPriority
                                             .Where(paymentPriority => paymentPriority.EmployerAccountId == employerAccountId);

            dataContext.EmployerProviderPriority.RemoveRange(previousEmployerPriorities);

            await dataContext.EmployerProviderPriority
            .AddRangeAsync(paymentPriorityModels, cancellationToken)
            .ConfigureAwait(false);

            await dataContext.SaveChangesAsync(cancellationToken).ConfigureAwait(false);
        }
        public static async Task UpdateApprenticeship(long apprenticeshipId, ApprenticeshipStatus status, List <ApprenticeshipPriceEpisodeModel> priceEpisodes, IPaymentsDataContext dataContext)
        {
            var apprenticeship = await dataContext.Apprenticeship
                                 .Include(a => a.ApprenticeshipPriceEpisodes)
                                 .FirstOrDefaultAsync(a => a.Id == apprenticeshipId)
                                 .ConfigureAwait(false);

            if (apprenticeship == null)
            {
                throw new InvalidOperationException($"Apprenticeship not found: {apprenticeshipId}");
            }

            apprenticeship.Status = status;
            apprenticeship.ApprenticeshipPriceEpisodes.ForEach(priceEpisode => priceEpisode.Removed = true);
            apprenticeship.ApprenticeshipPriceEpisodes.AddRange(priceEpisodes);
            await dataContext.SaveChangesAsync().ConfigureAwait(false);
        }
        public async Task Add(CurrentPriceEpisode priceEpisode)
        {
            await paymentsDataContext.CurrentPriceEpisodes.AddAsync(priceEpisode);

            await paymentsDataContext.SaveChangesAsync();
        }
Beispiel #9
0
 public async Task Add(ApprenticeshipModel apprenticeship)
 {
     dataContext.Apprenticeship.Add(apprenticeship);
     await dataContext.SaveChangesAsync();
 }
        public static async Task AddApprenticeshipDuplicate(ApprenticeshipDuplicateModel apprenticeshipDuplicate, IPaymentsDataContext dataContext)
        {
            await dataContext.ApprenticeshipDuplicate.AddAsync(apprenticeshipDuplicate).ConfigureAwait(false);

            await dataContext.SaveChangesAsync().ConfigureAwait(false);
        }
        public async Task SaveClawbackPayments(IEnumerable <PaymentModel> clawbackPayments, CancellationToken cancellationToken = default(CancellationToken))
        {
            await dataContext.Payment.AddRangeAsync(clawbackPayments, cancellationToken);

            await dataContext.SaveChangesAsync(cancellationToken);
        }
Beispiel #12
0
        public async Task Add(ReceivedDataLockEvent dataLock)
        {
            await context.ReceivedDataLockEvents.AddAsync(dataLock);

            await context.SaveChangesAsync();
        }