Esempio n. 1
0
 public AccountingVM(AccountingFilter filter) : this(filter.UoW)
 {
     Filter = filter;
 }
Esempio n. 2
0
        public async Task <IActionResult> GetAccountingType([FromBody] AccountingFilter _AccountingDTO)

        {
            List <AccountingDTO> Items    = new List <AccountingDTO>();
            List <Int32>         _parents = new List <int>();

            try
            {
                List <Accounting> _cuentas = new List <Accounting>();

                if (_AccountingDTO.TypeAccountId == 0 && _AccountingDTO.estadocuenta == true)
                {
                    _cuentas = await _context.Accounting.Where(m => m.IdEstado == 1).ToListAsync();
                }
                if (_AccountingDTO.TypeAccountId == 0 && _AccountingDTO.estadocuenta == false)
                {
                    _cuentas = await _context.Accounting.Where(m => m.IdEstado == 2).ToListAsync();

                    _parents = _cuentas.Select(q => q.ParentAccountId == null?0 : q.ParentAccountId.Value).ToList();
                    _cuentas.AddRange(ObtenerCategoriarJerarquia(_parents));
                }
                else if (_AccountingDTO.TypeAccountId == 0 && _AccountingDTO.estadocuenta == null)
                {
                    _cuentas = await _context.Accounting.ToListAsync();
                }
                else if (_AccountingDTO.TypeAccountId > 0 && _AccountingDTO.estadocuenta == true)
                {
                    _cuentas = await _context.Accounting
                               .Where(q => q.TypeAccountId == _AccountingDTO.TypeAccountId)
                               .Where(m => m.IdEstado == 1)
                               .ToListAsync();
                }
                else if (_AccountingDTO.TypeAccountId > 0 && _AccountingDTO.estadocuenta == false)
                {
                    _cuentas = await _context.Accounting
                               .Where(q => q.TypeAccountId == _AccountingDTO.TypeAccountId)
                               .Where(m => m.IdEstado == 2)
                               .ToListAsync();
                }
                else if (_AccountingDTO.TypeAccountId > 0 && _AccountingDTO.estadocuenta == null)
                {
                    _cuentas = await _context.Accounting
                               .Where(q => q.TypeAccountId == _AccountingDTO.TypeAccountId
                                      )
                               .ToListAsync();
                }

                Items = (from c in _cuentas
                         select new AccountingDTO
                {
                    CompanyInfoId = c.CompanyInfoId,
                    AccountId = c.AccountId,
                    AccountName = c.AccountCode + "--" + c.AccountName,
                    ParentAccountId = c.ParentAccountId,
                    // Credit = Credit(c.AccountId),
                    // Debit = Debit(c.AccountId),
                    IdEstado = c.IdEstado,
                    Estado = c.Estado,
                    AccountBalance = c.AccountBalance,
                    IsCash = c.IsCash,
                    Description = c.Description,
                    TypeAccountId = c.TypeAccountId,
                    BlockedInJournal = c.BlockedInJournal,
                    AccountCode = c.AccountCode,
                    HierarchyAccount = c.HierarchyAccount,
                    UsuarioCreacion = c.UsuarioCreacion,
                    UsuarioModificacion = c.UsuarioModificacion,
                    FechaCreacion = c.FechaCreacion,
                    FechaModificacion = c.FechaModificacion
                }
                         )
                        .ToList();
            }
            catch (Exception ex)
            {
                _logger.LogError($"Ocurrio un error: { ex.ToString() }");
                return(BadRequest($"Ocurrio un error:{ex.Message}"));
            }


            return(await Task.Run(() => Ok(Items)));
        }