Example #1
0
        public ExcelSheet ApplyGroups()
        {
            var tmp          = new List <ExcelTransaction>();
            var groupBuilder = new TransactionGroupBuilder();

            foreach (var transaction in this.Transactions)
            {
                // AddPastDatedTransactions
                groupBuilder.AddPastDatedTransactions(tmp, transaction.AccountingDate);

                if (!String.IsNullOrWhiteSpace(transaction.GroupId))
                {
                    // StoreCurrentGroupedTransaction
                    groupBuilder.StoreCurrentGroupedTransaction(transaction, transaction.GroupId);
                }
                else
                {
                    tmp.Add(transaction);
                }
            }

            // Remaining end-of-dates group
            foreach (var keyValue in groupBuilder.GroupDict)
            {
                tmp.Add(keyValue.Value);
            }

            this.Transactions = tmp;
            return(this);
        }
Example #2
0
        public ExcelSheet <T> ApplyGroups()
        {
            if (!typeof(ExcelTransactionExtended).IsAssignableFrom(typeof(T)))
            {
                Console.WriteLine("ExcelSheet is not ExcelTransactionExtended!");
                return(this);
            }

            var tmp          = new List <ExcelTransactionExtended>();
            var castList     = this.Transactions as List <ExcelTransactionExtended>;
            var groupBuilder = new TransactionGroupBuilder();

            foreach (var transaction in castList)
            {
                // AddPastDatedTransactions
                groupBuilder.AddPastDatedTransactions(tmp, transaction.AccountingDate);

                if (!String.IsNullOrWhiteSpace(transaction.GroupId))
                {
                    // StoreCurrentGroupedTransaction
                    groupBuilder.StoreCurrentGroupedTransaction(transaction, transaction.GroupId);
                }
                else
                {
                    tmp.Add(transaction);
                }
            }

            // Remaining end-of-dates group
            foreach (var keyValue in groupBuilder.GroupDict)
            {
                tmp.Add(keyValue.Value);
            }

            this.Transactions = tmp as List <T>;
            return(this);
        }