Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetEmployerCoInvestedPaymentHistoryTotal - trim decimal points after sum #1157

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public async Task GetEmployerCoInvestedPaymentHistoryTotal_RoundsAllAmountsDown(

var actual = await sut.GetEmployerCoInvestedPaymentHistoryTotal(key);

actual.Should().Be(100);
actual.Should().Be(101);
}

[TestCase(TransactionType.Completion)]
Expand Down
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