public CalculationDataPreprocessor(ICalculationDataProvider dataProvider) { EnvelopeSize = dataProvider.EnvelopeSize; CalculationPeriod = dataProvider.CalculationPeriod; CashMovements = new DatedSet <CashStatement>(dataProvider.GetCashMovements()); Remainders = new DatedSet <CashStatement>(dataProvider.GetRemainders()); MonthlyCashMovements = new DatedSet <MonthlyCashStatement>(ConvertToExpenses(dataProvider)); MonthlyCashMovementCategories = new List <MonthlyCashStatementCategory>(dataProvider.GetMonthlyCashStatementCategories()); }
private void CalculateTotalRemainders() { for (var week = new BudgetWeek(Period.From); week.From < Period.To; week = new BudgetWeek(week.To)) { budget.AddWeek(week); SetLastRemainderDateOf(week); var daysToCalculate = new Set <DateTime> { week.FirstDay, week.LastDay }; daysToCalculate.AddRange(CashInvestmentDates(week)); daysToCalculate.AddRange(MonthlyExpensesDates(week)); CalculateRemaindersForDates(week, daysToCalculate); } budgetWeeks = new DatedSet <BudgetWeek>(budget.Weeks); }
private static IEnumerable <DateTime> DatesWithin <T>(BudgetWeek week, DatedSet <T> transfers) where T : IDated { return(transfers[week].Convert(i => i.Date).Distinct()); }