public Task <FacturaDeposito> ValidarExisteFacturaDeposito()
        {
            FacturaDeposito factura_deposito = new FacturaDeposito();

            List <OracleParameter> parameters = new List <OracleParameter>();
            var PARAM_INDICA_GENERAR          = new OracleParameter("INDICA_GENERAR", OracleDbType.Char, 1, OracleDbType.Char, ParameterDirection.Output);

            parameters.Add(PARAM_INDICA_GENERAR);

            var PARAM_FECHA_FACTURA = new OracleParameter("FECHA_FACTURA", OracleDbType.NVarchar2, 32767, OracleDbType.NVarchar2, ParameterDirection.Output);

            parameters.Add(PARAM_FECHA_FACTURA);

            _connectionBase.ExecuteByStoredProcedure("CONCILIACION.CCLPROCDOCABONO.CCLVALFACTURADEPOSITO", parameters, ConnectionBase.enuTypeDataBase.OracleConciliacion);

            if (PARAM_INDICA_GENERAR.Value != null && PARAM_INDICA_GENERAR.Value.ToString() != "")
            {
                factura_deposito.IndGeneracion = PARAM_INDICA_GENERAR.Value.ToString();
            }
            else
            {
                factura_deposito.IndGeneracion = "";
            }

            if (PARAM_FECHA_FACTURA.Value != null && PARAM_FECHA_FACTURA.Value.ToString() != "")
            {
                factura_deposito.DtFechaCreacion = Convert.ToString(PARAM_FECHA_FACTURA.Value);
            }
            else
            {
                factura_deposito.DtFechaCreacion = "";
            }

            return(Task.FromResult <FacturaDeposito>(factura_deposito));
        }
        public Task <List <FacturaDeposito> > ListarFacturaDeposito()
        {
            FacturaDeposito        factura_deposito       = null;
            List <FacturaDeposito> lista_factura_deposito = new List <FacturaDeposito>();

            List <OracleParameter> parameters = new List <OracleParameter>();

            parameters.Add(new OracleParameter("RC1", OracleDbType.RefCursor, ParameterDirection.Output));

            using (OracleDataReader dr = (OracleDataReader)_connectionBase.ExecuteByStoredProcedure("CONCILIACION.CCLPROCDOCABONO.CCLREAFACTURA_DEPOSITO", parameters, ConnectionBase.enuTypeDataBase.OracleConciliacion))
            {
                while (dr.Read())
                {
                    factura_deposito                   = new FacturaDeposito();
                    factura_deposito.IdProducto        = Convert.ToInt32(dr["ID_PRODUCTO"]);
                    factura_deposito.IdFacturaDeposito = Convert.ToInt32(dr["ID_FACTURA_DEPOSITO"]);
                    factura_deposito.MontoTotal        = Convert.ToDecimal(dr["DC_MONTO_TOTAL"]);
                    lista_factura_deposito.Add(factura_deposito);
                }
            }

            ObtenerDetalleFacturaDeposito(ref lista_factura_deposito);

            return(Task.FromResult <List <FacturaDeposito> >(lista_factura_deposito));
        }
        public Task <string> AnularFacturaDeposito(FacturaDeposito factura_deposito)
        {
            string result = string.Empty;
            List <OracleParameter> param = new List <OracleParameter>();

            param.Add(new OracleParameter("ID_FACTURA_DEPOSITO", OracleDbType.Int32, factura_deposito.IdFacturaDeposito, ParameterDirection.Input));
            var pResult = new OracleParameter("P_RESULTADO", OracleDbType.Int32, ParameterDirection.Output);

            param.Add(pResult);

            _connectionBase.ExecuteByStoredProcedure("CONCILIACION.CCLPROCDOCABONO.CCLUPDSTATEFACTURA", param, ConnectionBase.enuTypeDataBase.OracleConciliacion);

            result = pResult.Value.ToString();

            return(Task.FromResult <string>(result));
        }
        public Task <FacturaDeposito> ObtenerFacturaDeposito(DatosFacturaAbonos datosFacturaAbonos)
        {
            string numero_serie = string.Empty;

            FacturaDeposito        factura_deposito         = null;
            DetalleFacturaDeposito detalle_factura_deposito = null;

            List <Deposito> lista_deposito = new List <Deposito>();

            lista_deposito = ListarDepositoNoConciliado();

            numero_serie = ObtenerNumeroSerie();

            if (lista_deposito.Count > 0 && numero_serie != "")
            {
                factura_deposito                        = new FacturaDeposito();
                factura_deposito.IdProducto             = datosFacturaAbonos.IdProducto;
                factura_deposito.NumeroFactura          = numero_serie;
                factura_deposito.MontoTotal             = lista_deposito.Sum(x => x.Monto);
                factura_deposito.VcUsuarioCreacion      = datosFacturaAbonos.Usuario;
                factura_deposito.IddgEstado             = 1; //Generado
                factura_deposito.DetalleFacturaDeposito = new List <DetalleFacturaDeposito>();

                foreach (Deposito d in lista_deposito)
                {
                    detalle_factura_deposito                    = new DetalleFacturaDeposito();
                    detalle_factura_deposito.IdDeposito         = d.IdDeposito;
                    detalle_factura_deposito.Monto              = d.Monto;
                    detalle_factura_deposito.IdTipoMedioPago    = d.IdTipoMedioPago;
                    detalle_factura_deposito.VcUsuarioCreacion  = datosFacturaAbonos.Usuario;
                    detalle_factura_deposito.IddgEstado         = 1;    //Generado
                    detalle_factura_deposito.IddgEstadoDeposito = 1108; //Con Factura de Abono
                    factura_deposito.DetalleFacturaDeposito.Add(detalle_factura_deposito);
                }
            }

            return(Task.FromResult <FacturaDeposito>(factura_deposito));
        }
        public Task <string> RegistrarFacturaDeposito(FacturaDeposito factura_deposito)
        {
            string result = string.Empty;
            List <OracleParameter> paramfac = null;
            List <OracleParameter> paramdet = null;

            paramfac = new List <OracleParameter>();
            paramfac.Add(new OracleParameter("ID_PRODUCTO", OracleDbType.Int32, factura_deposito.IdProducto, ParameterDirection.Input));
            paramfac.Add(new OracleParameter("NUMERO_FACTURA", OracleDbType.NVarchar2, factura_deposito.NumeroFactura, ParameterDirection.Input));
            paramfac.Add(new OracleParameter("DC_MONTO_TOTAL", OracleDbType.Decimal, factura_deposito.MontoTotal, ParameterDirection.Input));
            paramfac.Add(new OracleParameter("VC_USUARIO_CREACION", OracleDbType.NVarchar2, factura_deposito.VcUsuarioCreacion, ParameterDirection.Input));
            paramfac.Add(new OracleParameter("ID_DG_ESTADO", OracleDbType.Int32, factura_deposito.IddgEstado, ParameterDirection.Input));

            var pnewId = new OracleParameter("P_RESULTADO", OracleDbType.Int32, ParameterDirection.Output);

            paramfac.Add(pnewId);

            _connectionBase.ExecuteByStoredProcedure("CONCILIACION.CCLPROCDOCABONO.CCLPOSTFACTURA_DEPOSITO", paramfac, ConnectionBase.enuTypeDataBase.OracleConciliacion);

            foreach (DetalleFacturaDeposito d in factura_deposito.DetalleFacturaDeposito)
            {
                paramdet = new List <OracleParameter>();
                paramdet.Add(new OracleParameter("ID_FACTURA_DEPOSITO", OracleDbType.Int32, pnewId.Value, ParameterDirection.Input));
                paramdet.Add(new OracleParameter("ID_DEPOSITO", OracleDbType.Int32, d.IdDeposito, ParameterDirection.Input));
                paramdet.Add(new OracleParameter("DC_MONTO", OracleDbType.Decimal, d.Monto, ParameterDirection.Input));
                paramdet.Add(new OracleParameter("ID_TIPO_MEDIO_PAGO", OracleDbType.Int32, d.IdTipoMedioPago, ParameterDirection.Input));
                paramdet.Add(new OracleParameter("VC_USUARIO_CREACION", OracleDbType.NVarchar2, d.VcUsuarioCreacion, ParameterDirection.Input));
                paramdet.Add(new OracleParameter("ID_DG_ESTADO", OracleDbType.Int32, d.IddgEstado, ParameterDirection.Input));
                paramdet.Add(new OracleParameter("P_RESULTADO", OracleDbType.Int32, ParameterDirection.Output));

                _connectionBase.ExecuteByStoredProcedure("CONCILIACION.CCLPROCDOCABONO.CCLPOSTDETFACTURA_DEPOSITO", paramdet, ConnectionBase.enuTypeDataBase.OracleConciliacion);
            }

            result = factura_deposito.NumeroFactura;

            return(Task.FromResult <string>(result));
        }