private void CreateOrAccumulateParentWithoutSector( List <TrialBalanceEntry> returnedEntries, TrialBalanceEntry entry, EmpiriaHashTable <TrialBalanceEntry> summaryParentEntries, StandardAccount currentParent) { var helper = new TrialBalanceHelper(_command); var entryWithoutSector = returnedEntries.FirstOrDefault( a => a.Ledger.Number == entry.Ledger.Number && a.Currency.Code == entry.Currency.Code && a.SubledgerAccountIdParent == entry.SubledgerAccountId && a.Account.Number == currentParent.Number && a.NotHasSector); if (entryWithoutSector == null) { helper.SummaryByEntry(summaryParentEntries, entry, currentParent, Sector.Empty, TrialBalanceItemType.BalanceSummary); } else { entryWithoutSector.Sum(entry); } }
private void GenerateOrIncreaseParentEntries(List <TrialBalanceEntry> subsidiaryEntries, List <TrialBalanceEntry> returnedEntries) { var helper = new TrialBalanceHelper(_command); foreach (var entry in subsidiaryEntries) { int count = 0; List <TrialBalanceEntry> summaryEntries = new List <TrialBalanceEntry>(); var summaryParentEntries = new EmpiriaHashTable <TrialBalanceEntry>(); StandardAccount account = entry.Account; while (true) { var parent = returnedEntries.FirstOrDefault(a => a.Ledger.Number == entry.Ledger.Number && a.Currency.Code == entry.Currency.Code && a.SubledgerAccountId == 0 && a.SubledgerAccountIdParent == entry.SubledgerAccountId && a.Account.Number == account.Number && a.Sector.Code == entry.Sector.Code); if (parent == null) { count++; TrialBalanceItemType itemType = count == 1 ? TrialBalanceItemType.BalanceEntry : TrialBalanceItemType.BalanceSummary; helper.SummaryByEntry(summaryParentEntries, entry, account, entry.Sector, itemType); if (!account.HasParent && entry.HasSector && entry.SubledgerAccountId > 0) { CreateOrAccumulateParentWithoutSector(returnedEntries, entry, summaryParentEntries, account); break; } else if (!account.HasParent) { break; } else { account = account.GetParent(); } } else { parent.Sum(entry); if (!account.HasParent) { AccumulateSubledgerAccount(returnedEntries, entry, account); break; } else { account = account.GetParent(); } } } // while summaryEntries.AddRange(summaryParentEntries.Values.ToList()); returnedEntries.AddRange(summaryEntries); } // foreach }