コード例 #1
0
        private List <YearMonth> GetMonthYearList()
        {
            YearMonth min = statements.OrderBy(x => x.TransactionDate).First().TransactionDate.ToYearMonth();
            YearMonth max = statements.OrderBy(x => x.TransactionDate).Last().TransactionDate.ToYearMonth();

            List <YearMonth> results = new List <YearMonth>();

            for (YearMonth i = min; i <= max; i = i.NextMonth())
            {
                results.Add(i);
            }

            return(results);
        }
コード例 #2
0
 public virtual void IncludeLines(List <TransactionLine> lines, YearMonth from, YearMonth to)
 {
     for (YearMonth i = ChooseInitialYearMonth(from); i <= ChooseFinalYearMonth(to); i = i.NextMonth())
     {
         if (!ExistsExecutedRecurringTransactionLine(lines, i))
         {
             lines.Add(
                 new RecurringTransactionLine(Id, new TransactionLineInfo(i.ToDate(Day), Amount, Description), Classification));
         }
     }
 }
コード例 #3
0
        public void ProcessLines(List <TransactionLine> statements)
        {
            YearMonth initialYearMonth = statements.Min(x => x.TransactionDate).ToYearMonth();
            YearMonth finalYearMonth   = statements.Max(x => x.TransactionDate).ToYearMonth();

            List <TransactionLine> singleLineStatements = statements
                                                          .Where(x => !(x is MultiCategoryTransactionLine))
                                                          .ToList();

            List <TransactionLine> explodedStatements = statements
                                                        .Where(x => x is MultiCategoryTransactionLine)
                                                        .Select(x => (MultiCategoryTransactionLine)x)
                                                        .SelectMany(x => x.Lines.ToList())
                                                        .Select(x => (TransactionLine)x)
                                                        .ToList();

            explodedStatements.AddRange(singleLineStatements);

            for (YearMonth yearMonth = initialYearMonth; yearMonth <= finalYearMonth; yearMonth = yearMonth.NextMonth())
            {
                budgetPerMonth.Add(yearMonth, new List <MontlyBudget>());

                foreach (MontlyBudget budget in budgets)
                {
                    List <TransactionLine> monthStatements = explodedStatements.Where(x => yearMonth.Equals(x.TransactionDate)).ToList();

                    MontlyBudget currentBudget = budget.Process(monthStatements);
                    budgetPerMonth[yearMonth].Add(currentBudget);
                    currentBudget.IncludeLine(statements, yearMonth);
                }
            }
        }