private IList <Dto.Financial.Account> BuildAccountGrouping(IList <Core.Domain.Financials.Account> allAccounts,
                                                                   int?parentAccountId)
        {
            var accountTree   = new List <Dto.Financial.Account>();
            var childAccounts = allAccounts.Where(o => o.ParentAccountId == parentAccountId).ToList();

            foreach (var account in childAccounts)
            {
                var accountDto = new Dto.Financial.Account()
                {
                    Id              = account.Id,
                    AccountClassId  = account.AccountClassId,
                    ParentAccountId = account.ParentAccountId,
                    CompanyId       = account.CompanyId,
                    AccountCode     = account.AccountCode,
                    AccountName     = account.AccountName,
                    Description     = account.Description,
                    IsCash          = account.IsCash,
                    IsContraAccount = account.IsContraAccount,
                    Balance         = account.Balance,
                    DebitBalance    = account.DebitBalance,
                    CreditBalance   = account.CreditBalance
                };
                var children = BuildAccountGrouping(allAccounts, account.Id);
                accountDto.ChildAccounts = children;
                accountTree.Add(accountDto);
            }

            return(accountTree);
        }
        public IActionResult Account(int id)
        {
            var account = _financialService.GetAccount(id);

            var accountDto = new Dto.Financial.Account()
            {
                Id              = account.Id,
                AccountClassId  = account.AccountClassId,
                ParentAccountId = account.ParentAccountId,
                CompanyId       = account.CompanyId,
                AccountCode     = account.AccountCode,
                AccountName     = account.AccountName,
                Description     = account.Description,
                IsCash          = account.IsCash,
                IsContraAccount = account.IsContraAccount,
                Balance         = account.Balance,
                DebitBalance    = account.DebitBalance,
                CreditBalance   = account.CreditBalance
            };

            return(new ObjectResult(accountDto));
        }