public IList <InterestSummaryDto> GetCardInterests(List <PersonDto> people) { IList <InterestSummaryDto> cardInterestSummaries = new List <InterestSummaryDto>(); foreach (PersonDto person in people) { InterestSummaryDto cardInterestSummary = new InterestSummaryDto { PersonId = person.Id }; List <CardInterestsDto> creditInterestTotal = new List <CardInterestsDto>(); foreach (CreditStatementsDto creditStatement in person.CreditStatements) { CardInterestsDto interestForWallet = new CardInterestsDto { VisaInterest = GetInterest(creditStatement.AmountsOwedVisa, VisaInterestRate), MCInterest = GetInterest(creditStatement.AmountsOwedMC, MCInterestRate), DiscoverInterest = GetInterest(creditStatement.AmountsOwedDiscover, DiscoverInterestRate) }; creditInterestTotal.Add(interestForWallet); cardInterestSummary.TotalDuePlusInterest = GetTotalOwed(interestForWallet, creditStatement, cardInterestSummary.TotalDuePlusInterest); cardInterestSummary.TotalInterestDue = interestForWallet.VisaInterest.Sum() + interestForWallet.MCInterest.Sum() + interestForWallet.DiscoverInterest.Sum() + cardInterestSummary.TotalInterestDue; } cardInterestSummary.OriginalStatementValues = person.CreditStatements; cardInterestSummary.IndividualInterestDue = creditInterestTotal; cardInterestSummaries.Add(cardInterestSummary); } return(cardInterestSummaries); }
private static decimal GetTotalOwed(CardInterestsDto interestForStatement, CreditStatementsDto creditStatement, decimal totalDueWithInterest) { return(interestForStatement.VisaInterest.Sum() + interestForStatement.MCInterest.Sum() + interestForStatement.DiscoverInterest.Sum() + totalDueWithInterest + creditStatement.AmountsOwedDiscover.Sum() + creditStatement.AmountsOwedVisa.Sum() + creditStatement.AmountsOwedMC.Sum()); }