private void CalculateWeekOutcomes() { foreach (var week in budget.Weeks) { var calculatedRemainder = PriorWeekRemainder(week) - EnvelopeSize + CashMovements[week].Sum(i => i.Amount) + MonthlyCashMovements[week].Sum(p => p.Amount); var remainder = Remainders.SingleOrDefault(r => r.Date == week.LastDay); if (remainder != null) { budget.AddFreeMoney(week.LastDay, remainder.Amount - calculatedRemainder); } } }
public int GetRemainder(DateTime date) { var remainder = Remainders.SingleOrDefault(r => r.Date == date); return(remainder != null ? remainder.Amount : calculatedRemainders[date]); }