Skip to content

Commit

Permalink
PaymentHistoryRepository.GetEmployerCoInvestedPaymentHistoryTotal - t…
Browse files Browse the repository at this point in the history
…rim decimal points after summing individual payment amounts.
  • Loading branch information
mandrici committed Feb 16, 2023
1 parent 85c935c commit 5c95cea
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public PaymentHistoryRepository(IPaymentsDataContext dataContext)

public async Task<decimal> GetEmployerCoInvestedPaymentHistoryTotal(ApprenticeshipKey apprenticeshipKey, CancellationToken cancellationToken = default(CancellationToken))
{
return await dataContext.Payment
var decimalSumOfAmount = await dataContext.Payment
.Where(payment => apprenticeshipKey.Ukprn == payment.Ukprn &&
apprenticeshipKey.FrameworkCode == payment.LearningAimFrameworkCode &&
apprenticeshipKey.LearnAimRef == payment.LearningAimReference &&
Expand All @@ -89,12 +89,13 @@ public PaymentHistoryRepository(IPaymentsDataContext dataContext)
apprenticeshipKey.StandardCode == payment.LearningAimStandardCode &&
apprenticeshipKey.ContractType == payment.ContractType &&
payment.TransactionType == TransactionType.Learning &&
payment.FundingSource == FundingSourceType.CoInvestedEmployer
)
//NOTE: do not remove cast to (int) this is used to remove decimal places from expectedContribution Amount i.e. 123.9997 becomes 123
.Select(payment => (int)payment.Amount)
payment.FundingSource == FundingSourceType.CoInvestedEmployer)
.Select(payment => payment.Amount)
.DefaultIfEmpty(0)
.SumAsync(cancellationToken);

//NOTE: do not remove cast to (int) this is used to remove decimal places from expectedContribution Amount i.e. 123.9997 becomes 123
return (int)decimalSumOfAmount;
}

public async Task<List<IdentifiedRemovedLearningAim>> IdentifyRemovedLearnerAims(short academicYear, byte collectionPeriod, long ukprn, DateTime ilrSubmissionDateTime, CancellationToken cancellationToken)
Expand Down

0 comments on commit 5c95cea

Please sign in to comment.