private List <TrialBalanceEntry> CreateOrAccumulateTotalBySubsidiaryEntry( List <TrialBalanceEntry> returnedEntries, TrialBalanceEntry entry) { var helper = new TrialBalanceHelper(_command); var parentEntries = new EmpiriaHashTable <TrialBalanceEntry>(); var existTotalByAccount = returnedEntries.FirstOrDefault( a => a.SubledgerAccountId == entry.SubledgerAccountIdParent && a.Ledger.Number == entry.Ledger.Number && a.Currency.Code == entry.Currency.Code); if (existTotalByAccount == null) { helper.SummaryBySubsidiaryEntry(parentEntries, entry, TrialBalanceItemType.BalanceSummary); var parent = parentEntries.Values.FirstOrDefault(); parent.SubledgerAccountId = parent.SubledgerAccountIdParent; parent.SubledgerAccountNumber = SubsidiaryAccount.Parse(entry.SubledgerAccountIdParent).Number ?? ""; returnedEntries.Add(parent); } else { existTotalByAccount.Sum(entry); } return(returnedEntries); }
static private TwoColumnsTrialBalanceEntryDto MapToTwoCurrenciesBalanceEntry( TwoCurrenciesBalanceEntry trialBalanceEntry) { var dto = new TwoColumnsTrialBalanceEntryDto(); SubsidiaryAccount subledgerAccount = SubsidiaryAccount.Parse(trialBalanceEntry.SubledgerAccountId); dto.ItemType = trialBalanceEntry.ItemType; dto.LedgerUID = trialBalanceEntry.Ledger.UID; dto.LedgerNumber = trialBalanceEntry.Ledger.Number; dto.AccountId = trialBalanceEntry.AccountId; dto.CurrencyCode = trialBalanceEntry.Currency.Code; if (subledgerAccount.IsEmptyInstance) { dto.AccountName = trialBalanceEntry.GroupName != "" ? trialBalanceEntry.GroupName : trialBalanceEntry.Account.Name; dto.AccountNumber = trialBalanceEntry.GroupNumber != "" ? trialBalanceEntry.GroupNumber : trialBalanceEntry.Account.Number != "Empty" ? trialBalanceEntry.Account.Number : ""; } else { dto.AccountName = subledgerAccount.Name; dto.AccountNumber = subledgerAccount.Number; } dto.AccountRole = trialBalanceEntry.Account.Role; dto.AccountLevel = trialBalanceEntry.Account.Level; dto.SectorCode = trialBalanceEntry.Sector.Code; dto.SubledgerAccountId = trialBalanceEntry.SubledgerAccountId; dto.DomesticBalance = trialBalanceEntry.DomesticBalance; dto.ForeignBalance = trialBalanceEntry.ForeignBalance; dto.TotalBalance = trialBalanceEntry.TotalBalance; dto.ExchangeRate = trialBalanceEntry.ExchangeRate; return(dto); }
public FixedList <SubsidiaryAccountDto> SearchSubsidiaryAccounts(string keywords) { Assertion.AssertObject(keywords, "keywords"); FixedList <SubsidiaryAccount> subledgerAccountList = SubsidiaryAccount.GetList(keywords); return(SubsidiaryLedgerMapper.Map(subledgerAccountList)); }
static internal SubsidiaryAccountDto MapAccount(SubsidiaryAccount subsidiaryAccount) { return(new SubsidiaryAccountDto { Id = subsidiaryAccount.Id, Ledger = subsidiaryAccount.SubsidaryLedger.BaseLedger.MapToNamedEntity(), SubsidiaryLedger = subsidiaryAccount.SubsidaryLedger.MapToNamedEntity(), Name = subsidiaryAccount.Name, Number = subsidiaryAccount.Number, Description = subsidiaryAccount.Description }); }
public SubsidiaryAccountDto GetSubsidiaryAccount(string subsidiaryLedgerUID, int subsidiaryAccountId) { Assertion.AssertObject(subsidiaryLedgerUID, "subsidiaryLedgerUID"); Assertion.Assert(subsidiaryAccountId > 0, "subsidiaryAccountId"); var subsidiaryLedger = SubsidiaryLedger.Parse(subsidiaryLedgerUID); SubsidiaryAccount subsidiaryAccount = subsidiaryLedger.GetAccountWithId(subsidiaryAccountId); return(SubsidiaryLedgerMapper.MapAccount(subsidiaryAccount)); }
public void Init() { context = TestDbContextFactory.Build(); organization = context.Organizations.First(); expenseType = context.TransactionSubTypes.OfType <ExpenseType>().First(); var accountType = context.AccountTypes.First(); var fundType = context.FundTypes.First(); account = new SubsidiaryAccount { Id = -1, Name = "Test Account", UpdatedBy = "Foo", CreatedBy = "Foo", AccountType = accountType, Organization = organization }; fund = new SubsidiaryFund { Id = -1, Name = fundType.Name, BankNumber = "42", Code = "123", CreatedBy = "Foo", UpdatedBy = "Foo", FundType = fundType, Organization = organization }; fund.Subsidiaries.Add(account); account.Fund = fund; context.Funds.Add(fund); payee = new Payee { Name = "Test", AddressLine1 = "123 Street", City = "Foo", State = "FO", PostalCode = "98503", Organization = organization, UpdatedBy = "Foo", CreatedBy = "Foo" }; context.Payees.Add(payee); context.SaveChanges(); }
private List <TrialBalanceEntry> OrderingSubsidiaryAccountsByNumber( List <TrialBalanceEntry> totaBySubsidiaryAccountList) { var returnedEntries = new List <TrialBalanceEntry>(); foreach (var entry in totaBySubsidiaryAccountList.Where(a => a.Level == 1 && a.NotHasSector)) { entry.SubledgerAccountNumber = SubsidiaryAccount.Parse(entry.SubledgerAccountIdParent).Number ?? ""; returnedEntries.Add(entry); } returnedEntries = returnedEntries.OrderBy(a => a.Currency.Code) .ThenBy(a => a.SubledgerAccountNumber) .ToList(); return(returnedEntries); }
internal StoredBalance(StoredBalanceSet storedBalanceSet, TrialBalanceEntry entry) { var subsidiaryAccount = SubsidiaryAccount.Parse(entry.SubledgerAccountId); this.StoredBalanceSet = storedBalanceSet; this.StandardAccountId = entry.Account.Id; this.AccountNumber = entry.Account.Number; this.AccountName = entry.Account.Name; this.Ledger = entry.Ledger; this.LedgerAccountId = entry.AccountId; this.Currency = entry.Currency; this.Sector = entry.Sector; this.SubsidiaryAccountId = entry.SubledgerAccountId; this.SubsidiaryAccountName = subsidiaryAccount.Name; this.SubsidiaryAccountNumber = subsidiaryAccount.Number; this.Balance = entry.CurrentBalance; }
public void Init() { context = TestDbContextFactory.Build(); organization = context.Organizations.First(); receiptType = context.TransactionSubTypes.OfType <ReceiptType>().First(); var accountType = context.AccountTypes.First(); var fundType = context.FundTypes.First(); account = new SubsidiaryAccount { Id = -1, Name = "Test Account", UpdatedBy = "Foo", CreatedBy = "Foo", AccountType = accountType, Organization = organization }; fund = new SubsidiaryFund { Id = -1, Name = fundType.Name, BankNumber = "42", Code = "123", CreatedBy = "Foo", UpdatedBy = "Foo", FundType = fundType, Organization = organization }; fund.Subsidiaries.Add(account); account.Fund = fund; context.Funds.Add(fund); context.SaveChanges(); }
public void Can_persist_SubsidiaryFund_with_a_SubsidiaryAccount() { var fundType = context.FundTypes.First(); var fund = new SubsidiaryFund { Id = -1, Name = fundType.Name, BankNumber = "42", Code = "123", CreatedBy = "Foo", UpdatedBy = "Foo", FundType = fundType, Organization = organization }; var accountType = context.AccountTypes.First(); var subsidiaryAccount = new SubsidiaryAccount { Id = -1, Name = "SubsidiaryFund", BankNumber = "42", CreatedBy = "Foo", UpdatedBy = "Foo", AccountType = accountType, Organization = organization }; fund.Subsidiaries.Add(subsidiaryAccount); subsidiaryAccount.Fund = fund; context.Funds.Add(fund); context.SaveChanges(); Assert.AreNotEqual(-1, fund.Id); Assert.AreNotEqual(-1, subsidiaryAccount.Id); }
static private TrialBalanceEntryDto MapToTrialBalanceComparative(TrialBalanceEntry trialBalanceEntry) { var dto = new TrialBalanceEntryDto(); SubsidiaryAccount subledgerAccount = SubsidiaryAccount.Parse(trialBalanceEntry.SubledgerAccountId); dto.ItemType = trialBalanceEntry.ItemType; dto.LedgerUID = trialBalanceEntry.Ledger.UID; dto.LedgerNumber = trialBalanceEntry.Ledger.Number; dto.AccountId = trialBalanceEntry.AccountId; dto.CurrencyCode = trialBalanceEntry.ItemType == TrialBalanceItemType.BalanceTotalConsolidated ? "" : trialBalanceEntry.Currency.Code; if (subledgerAccount.IsEmptyInstance) { dto.AccountName = trialBalanceEntry.GroupName != "" ? trialBalanceEntry.GroupName : trialBalanceEntry.Account.Name; dto.AccountNumber = trialBalanceEntry.GroupNumber != "" ? trialBalanceEntry.GroupNumber : trialBalanceEntry.Account.Number != "Empty" ? trialBalanceEntry.Account.Number : ""; } else { dto.AccountName = subledgerAccount.Name; dto.AccountNumber = subledgerAccount.Number; } dto.AccountRole = trialBalanceEntry.Account.Role; dto.AccountLevel = trialBalanceEntry.Account.Level; dto.SectorCode = trialBalanceEntry.Sector.Code; dto.SubledgerAccountId = trialBalanceEntry.SubledgerAccountId; dto.InitialBalance = trialBalanceEntry.InitialBalance; dto.Debit = trialBalanceEntry.Debit; dto.Credit = trialBalanceEntry.Credit; dto.CurrentBalance = trialBalanceEntry.CurrentBalance; dto.ExchangeRate = trialBalanceEntry.ExchangeRate; return(dto); }
internal List <TrialBalanceEntry> GenerateSummaryEntries(FixedList <TrialBalanceEntry> entries) { var summaryEntries = new EmpiriaHashTable <TrialBalanceEntry>(entries.Count); var detailSummaryEntries = new List <TrialBalanceEntry>(); foreach (var entry in entries) { entry.DebtorCreditor = entry.Account.DebtorCreditor; entry.SubledgerAccountNumber = SubsidiaryAccount.Parse(entry.SubledgerAccountId).Number ?? ""; StandardAccount currentParent; if (_command.ReturnSubledgerAccounts) { currentParent = entry.Account; } else if (_command.DoNotReturnSubledgerAccounts && entry.Account.HasParent) { currentParent = entry.Account.GetParent(); } else if (_command.DoNotReturnSubledgerAccounts && entry.Account.NotHasParent) { continue; } else { throw Assertion.AssertNoReachThisCode(); } int cont = 0; while (true) { entry.DebtorCreditor = entry.Account.DebtorCreditor; entry.SubledgerAccountIdParent = entry.SubledgerAccountId; SummaryByEntry(summaryEntries, entry, currentParent, entry.Sector, TrialBalanceItemType.BalanceSummary); cont++; if (cont == 1 && _command.TrialBalanceType == TrialBalanceType.SaldosPorCuenta) { GetDetailSummaryEntries(detailSummaryEntries, summaryEntries, currentParent, entry); } if (!currentParent.HasParent && entry.HasSector) { SummaryByEntry(summaryEntries, entry, currentParent, Sector.Empty, TrialBalanceItemType.BalanceSummary); break; } else if (!currentParent.HasParent) { break; } else { currentParent = currentParent.GetParent(); } } // while } // foreach if (detailSummaryEntries.Count > 0 && _command.TrialBalanceType == TrialBalanceType.SaldosPorCuenta) { return(detailSummaryEntries); } return(summaryEntries.Values.ToList()); }