Beispiel #1
0
        protected ILedger GetLedger(IJournal journal)
        {
            var ledger = new Ledger.Core.Ledger();

            ledger.EntryValidators.Add(new IntegrityEntryValidator());
            ledger.EntryValidators.Add(new AccountsBalanceEntryValidator(new QueryAccountPredicate("Assets:**"), new QueryAccountPredicate("Liabilities|Equity:**")));
            ledger.BalanceValidators.Add(new AccountsBalanceBalanceValidator(new Book("Default"), new QueryAccountPredicate("Assets:**"), new QueryAccountPredicate("Liabilities|Equity:**")));
            ledger.BalanceValidators.Add(new AccountBalanceCreditZeroBalanceValidator(new Book("Default"), new QueryAccountPredicate("Equity:ProfitLoss:Expense:**")));
            ledger.BalanceValidators.Add(new AccountBalanceDebitZeroBalanceValidator(new Book("Default"), new QueryAccountPredicate("Equity:ProfitLoss:Income:**")));

            foreach (var entry in journal.Entries)
            {
                ledger.AddEntry(entry);
            }

            return(ledger);
        }
Beispiel #2
0
        public virtual ILedger MergeLedgers(IEnumerable <ILedger> ledgers, IComparable endIndex)
        {
            var entries = new List <IEntry>();

            foreach (var ledger in ledgers)
            {
                entries.AddRange(ledger.GetEntriesBefore(endIndex));
            }

            entries.Sort(new EntryComparer());

            var mergedLedger = new Ledger();

            foreach (var entry in entries)
            {
                mergedLedger.AddEntry(entry);
            }

            return(mergedLedger);
        }