public tb_empresa_Info get_info(int IdEmpresa)
 {
     try
     {
         return(odata.get_info(IdEmpresa));
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemple #2
0
        public ats_Info get_info(int IdEmpresa, int IdPeriodo, int IdSucursal, int[] IntArray)
        {
            try
            {
                var    empresa_info    = data_empresa.get_info(IdEmpresa);
                var    perido_info     = data_perido.get_info(IdEmpresa, IdPeriodo);
                string Establecimiento = "";
                if (IntArray != null)
                {
                    foreach (var item in IntArray)
                    {
                        Establecimiento += item.ToString() + ",";
                    }
                }

                int      IdSucursalInicio = Convert.ToInt32(IdSucursal);
                int      IdSucursalFin    = Convert.ToInt32(IdSucursal) == 0 ? 9999 : Convert.ToInt32(IdSucursal);
                ats_Info info             = new ats_Info();
                using (Entities_contabilidad Context = new Entities_contabilidad())
                {
                    Context.generarATS(IdEmpresa, IdPeriodo, IdSucursalInicio, IdSucursalFin);

                    info.lst_compras = (from q in Context.ATS_compras
                                        where q.IdEmpresa == IdEmpresa &&
                                        q.IdPeriodo == IdPeriodo &&
                                        Establecimiento.Contains(q.IdSucursal.ToString())
                                        // && q.establecimiento.contr
                                        // && q.idProv== "0909594202001"
                                        select new compras_Info
                    {
                        IdEmpresa = q.IdEmpresa,
                        IdPeriodo = q.IdPeriodo,
                        Secuencia = q.Secuencia,
                        codSustento = q.codSustento,
                        tpIdProv = q.tpIdProv,
                        idProv = q.idProv,
                        tipoComprobante = q.tipoComprobante,
                        parteRel = q.parteRel,
                        tipoProv = q.tipoProv,
                        denopr = q.denopr,
                        fechaRegistro = q.fechaRegistro,
                        establecimiento = q.establecimiento,
                        puntoEmision = q.puntoEmision,
                        secuencial = q.secuencial,
                        fechaEmision = q.fechaEmision,
                        autorizacion = q.autorizacion,
                        baseNoGraIva = q.baseNoGraIva,
                        baseImponible = q.baseImponible,
                        baseImpGrav = q.baseImpGrav,
                        baseImpExe = q.baseImpExe,
                        montoIce = q.montoIce,
                        montoIva = q.montoIva,
                        pagoLocExt = q.pagoLocExt,
                        denopago = q.denopago,
                        paisEfecPago = q.paisEfecPago,
                        formaPago = q.formaPago,
                        docModificado = q.docModificado,
                        estabModificado = q.estabModificado,
                        ptoEmiModificado = q.ptoEmiModificado,
                        secModificado = q.secModificado,
                        autModificado = q.autModificado
                    }).ToList();



                    info.lst_ventas = (from v in Context.ATS_ventas
                                       where v.IdEmpresa == IdEmpresa &&
                                       v.IdPeriodo == IdPeriodo &&
                                       Establecimiento.Contains(v.IdSucursal.ToString())
                                       //  && v.idCliente== "0190339092001"
                                       select new ventas_Info
                    {
                        IdEmpresa = v.IdEmpresa,
                        IdPeriodo = v.IdPeriodo,
                        Secuencia = v.Secuencia,
                        tpIdCliente = v.tpIdCliente,
                        tipoCliente = v.tipoCliente,
                        idCliente = v.idCliente,
                        parteRelVtas = v.parteRel,
                        tipoComprobante = v.tipoComprobante,
                        tipoEmision = v.tipoEm,
                        numeroComprobantes = v.numeroComprobantes,
                        baseNoGraIva = v.baseNoGraIva,
                        baseImponible = v.baseImponible,
                        baseImpGrav = v.baseImpGrav,
                        montoIva = v.montoIva,
                        montoIce = v.montoIce,
                        valorRetIva = v.valorRetIva,
                        valorRetRenta = v.valorRetRenta,
                        formaPago = v.formaPago,
                        codEstab = v.codEstab,
                        ventasEstab = v.ventasEstab,
                        ivaComp = v.ivaComp,
                        DenoCli = v.DenoCli
                    }).ToList();


                    info.lst_retenciones = (from r in Context.ATS_retenciones
                                            where r.IdEmpresa == IdEmpresa &&
                                            r.IdPeriodo == IdPeriodo &&
                                            Establecimiento.Contains(r.IdSucursal.ToString())
                                            // && r.Cedula_ruc== "0909594202001"
                                            select new retenciones_Info
                    {
                        IdEmpresa = r.IdEmpresa,
                        IdPeriodo = r.IdPeriodo,
                        Secuencia = r.Secuencia,
                        co_serie = r.co_serie,
                        co_factura = r.co_factura,
                        Cedula_ruc = r.Cedula_ruc,
                        valRetBien10 = r.valRetBien10,
                        valRetServ20 = r.valRetServ20,
                        valorRetBienes = r.valorRetBienes,
                        valRetServ50 = r.valRetServ50,
                        valorRetServicios = r.valorRetServicios,
                        valRetServ100 = r.valRetServ100,
                        codRetAir = r.codRetAir,
                        estabRetencion1 = r.estabRetencion1,
                        ptoEmiRetencion1 = r.ptoEmiRetencion1,
                        secRetencion1 = r.secRetencion1,
                        autRetencion1 = r.autRetencion1,
                        fechaEmiRet1 = r.fechaEmiRet1,
                        docModificado = r.docModificado,
                        estabModificado = r.autModificado,
                        ptoEmiModificado = r.ptoEmiModificado,
                        secModificado = r.secModificado,
                        autModificado = r.autModificado,
                        baseImpAir = r.baseImpAir,
                        porcentajeAir = r.porcentajeAir,
                        valRetAir = r.valRetAir,
                        re_tipo_Ret = r.re_tipo_Ret,
                        denopr = r.denopr
                    }).ToList();

                    info.lst_exportaciones = (from e in Context.ATS_exportaciones
                                              where e.IdEmpresa == IdEmpresa &&
                                              e.IdPeriodo == IdPeriodo &&
                                              e.IdPeriodo == IdPeriodo &&
                                              Establecimiento.Contains(e.IdSucursal.ToString())
                                              select new exportaciones_Info
                    {
                        IdEmpresa = e.IdEmpresa,
                        IdPeriodo = e.IdPeriodo,
                        Secuencia = e.Secuencia,
                        tpIdClienteEx = e.tpIdClienteEx,
                        idClienteEx = e.idClienteEx,
                        parteRel = e.parteRel,
                        tipoRegi = e.tipoRegi,
                        paisEfecPagoGen = e.paisEfecPagoGen,
                        paisEfecExp = e.paisEfecExp,
                        exportacionDe = e.exportacionDe,
                        tipoComprobante = e.tipoComprobante,
                        fechaEmbarque = e.fechaEmbarque,
                        valorFOB = e.valorFOB,
                        valorFOBComprobante = e.valorFOBComprobante,
                        establecimiento = e.establecimiento,
                        puntoEmision = e.puntoEmision,
                        secuencial = e.secuencial,
                        autorizacion = e.autorizacion,
                        fechaEmision = e.fechaEmision,
                        denoExpCli = e.denoExpCli
                    }).ToList();

                    info.lst_anulados = (from a in Context.ATS_comprobantes_anulados
                                         where a.IdEmpresa == IdEmpresa &&
                                         a.IdPeriodo == IdPeriodo

                                         && Establecimiento.Contains(a.IdSucursal.ToString())
                                         select new comprobantesAnulados_info
                    {
                        IdEmpresa = a.IdEmpresa,
                        IdPeriodo = a.IdPeriodo,
                        Secuencia = a.Secuencia,
                        tipoComprobante = a.tipoComprobante,
                        Establecimiento = a.Establecimiento,
                        puntoEmision = a.puntoEmision,
                        secuencialInicio = a.secuencialInicio,
                        secuencialFin = a.secuencialFin,
                        Autorizacion = a.Autorización
                    }).ToList();
                }

                return(info);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemple #3
0
        public iva get_ats(int IdEmpresa, int IdPeriodo, int IdSucursal, int[] IntArray)
        {
            try
            {
                string registro = "";
                iva    ats      = new iva();
                info_periodo = data_periodo.get_info(IdEmpresa, IdPeriodo);
                info_empresa = data_empresa.get_info(IdEmpresa);
                ats_Info info_ats = get_info(IdEmpresa, IdPeriodo, IdSucursal, IntArray);

                #region cabecera del xml
                ats.IdInformante = info_empresa.em_ruc;
                ats.razonSocial  = info_empresa.RazonSocial.Replace(".", " ").Replace("ñ", "n").Replace("Ñ", "N");
                ats.Anio         = info_periodo.IdanioFiscal.ToString();
                ats.Mes          = info_periodo.pe_mes.ToString().PadLeft(2, '0');

                ats.TipoIDInformante = ivaTypeTipoIDInformante.R;
                ats.codigoOperativo  = codigoOperativoType.IVA;
                ats.totalVentas      = info_ats.lst_ventas.Sum(v => v.ventasEstab);
                #endregion

                #region listado de compras
                if (info_ats.lst_compras != null)
                {
                    if (info_ats.lst_compras.Count() > 0)
                    {
                        ats.compras = new List <detalleCompras>();
                    }
                    info_ats.lst_compras.ForEach(
                        comp =>
                    {
                        detalleCompras comp_det = new detalleCompras();

                        registro                           = comp.denopr + " " + comp.secuencial;
                        comp.denopr                        = cl_funciones.QuitartildesEspaciosPuntos(comp.denopr);
                        comp_det.codSustento               = comp.codSustento;
                        comp_det.tpIdProv                  = comp.tpIdProv;
                        comp_det.idProv                    = comp.idProv;
                        comp_det.tipoComprobante           = comp.tipoComprobante;
                        comp_det.parteRel                  = parteRelType.NO;
                        comp_det.fechaRegistro             = comp.fechaRegistro.ToString().Substring(0, 10);
                        comp_det.establecimiento           = comp.establecimiento;
                        comp_det.puntoEmision              = comp.puntoEmision;
                        comp_det.secuencial                = comp.secuencial;
                        comp_det.fechaEmision              = comp.fechaEmision.ToString().Substring(0, 10);
                        comp_det.autorizacion              = comp.autorizacion;
                        comp_det.baseNoGraIva              = comp.baseNoGraIva.ToString("n2");
                        comp_det.baseImponible             = comp.baseImponible.ToString("n2");
                        comp_det.baseImpGrav               = comp.baseImpGrav.ToString("n2");
                        comp_det.baseImpExe                = comp.baseImpExe.ToString("n2");
                        comp_det.montoIce                  = comp.montoIce.ToString("n2");
                        comp_det.montoIva                  = comp.montoIva.ToString("n2");
                        comp_det.valRetBien10              = "0.00";
                        comp_det.valRetServ20              = "0.00";
                        comp_det.valorRetBienes            = "0.00";
                        comp_det.valRetServ50              = "0.00";
                        comp_det.valorRetServicios         = "0.00";
                        comp_det.valRetServ100             = "0.00";
                        comp_det.totbasesImpReemb          = "0.00";
                        comp_det.valRetBien10Specified     = true;
                        comp_det.valRetServ20Specified     = true;
                        comp_det.valRetServ50Specified     = true;
                        comp_det.totbasesImpReembSpecified = true;
                        pagoExterior item_pago             = new pagoExterior();
                        item_pago.pagoLocExt               = (comp.pagoLocExt == "LOC") ? pagoLocExtType.Item01 : pagoLocExtType.Item02;
                        item_pago.paisEfecPago             = (item_pago.pagoLocExt == pagoLocExtType.Item01) ? "NA" : (comp.pagoLocExt != null || comp.pagoLocExt != "") ? comp.pagoLocExt : "NA";
                        item_pago.aplicConvDobTrib         = aplicConvDobTribType.NA;
                        item_pago.pagExtSujRetNorLeg       = aplicConvDobTribType.NA;
                        comp_det.pagoExterior              = item_pago;
                        if (comp_det.idProv == "0601895618001")
                        {
                        }
                        if ((Convert.ToDecimal(comp.baseImponible) + Convert.ToDecimal(comp.baseImpGrav) + Convert.ToDecimal(comp.montoIva)) >= 1000)
                        {
                            comp_det.formasDePago = null;
                            string[] AFormaPago   = { "20" };
                            comp_det.formasDePago = AFormaPago;
                        }
                        #region Reembolso
                        if (comp.codSustento == "41")
                        {
                            comp_det.codSustento               = "01";
                            comp_det.reembolsos                = new List <reembolso>();
                            reembolso reem                     = new reembolso();
                            reem.tipoComprobanteReemb          = "01";
                            reem.tpIdProvReemb                 = comp.tpIdProv;
                            reem.idProvReemb                   = comp.idProv;
                            reem.establecimientoReemb          = comp.establecimiento;
                            reem.puntoEmisionReemb             = comp.puntoEmision;
                            reem.secuencialReemb               = comp.secuencial;
                            reem.fechaEmisionReemb             = comp.fechaEmision.ToString().Substring(0, 10);
                            reem.autorizacionReemb             = comp.autorizacion;
                            reem.baseImponibleReemb            = comp.baseImponible;
                            reem.baseImpGravReemb              = comp.baseImpGrav;
                            reem.baseImpExeReemb               = comp.baseImpExe;
                            reem.montoIceRemb                  = comp.montoIce;
                            reem.montoIvaRemb                  = comp.montoIva;
                            comp_det.totbasesImpReembSpecified = true;
                            comp_det.totbasesImpReemb          = Convert.ToString(Convert.ToDecimal(comp.baseImponible) + Convert.ToDecimal(comp.baseImpGrav));
                            comp_det.reembolsos.Add(reem);
                        }

                        #endregion

                        #region retencion por facturas
                        if (info_ats.lst_retenciones != null)
                        {
                            if (info_ats.lst_retenciones.Count() > 0)
                            {
                                var lstret_x_fac = info_ats.lst_retenciones.Where(r => r.Cedula_ruc == comp.idProv & r.co_serie == comp.establecimiento + "-" + comp.puntoEmision & comp.secuencial == r.co_factura);
                                if (lstret_x_fac != null)
                                {
                                    if (lstret_x_fac.Count() > 0)
                                    {
                                        comp_det.air = new List <detalleAir>();
                                        foreach (var item in lstret_x_fac)
                                        {
                                            if (item.re_tipo_Ret == "RTF")
                                            {
                                                comp_det.air.Add(new detalleAir
                                                {
                                                    codRetAir     = item.codRetAir.ToString(),
                                                    baseImpAir    = item.baseImpAir.ToString(),
                                                    porcentajeAir = item.porcentajeAir.ToString(),
                                                    valRetAir     = item.valRetAir.ToString(),
                                                });
                                            }
                                            else
                                            {
                                                if (item.porcentajeAir == "10")
                                                {
                                                    comp_det.valRetBien10 = item.valRetAir.ToString();
                                                }
                                                if (item.porcentajeAir == "20")
                                                {
                                                    comp_det.valRetServ20 = item.valRetAir.ToString();
                                                }
                                                if (item.porcentajeAir == "30")
                                                {
                                                    comp_det.valorRetBienes = item.valRetAir.ToString();
                                                }
                                                if (item.porcentajeAir == "50")
                                                {
                                                    comp_det.valRetServ50 = item.valRetAir.ToString();
                                                }
                                                if (item.porcentajeAir == "70")
                                                {
                                                    comp_det.valorRetServicios = item.valRetAir.ToString();
                                                }
                                                if (item.porcentajeAir == "100")
                                                {
                                                    comp_det.valRetServ100 = item.valRetAir.ToString();
                                                }
                                            }
                                        }
                                    }
                                    else   // si no tiene retencion
                                    {
                                        comp_det.air = new List <detalleAir>();
                                        comp_det.air.Add(new detalleAir
                                        {
                                            codRetAir     = "332",
                                            baseImpAir    = Convert.ToDecimal(comp.baseImpGrav + comp.baseImponible).ToString(),
                                            porcentajeAir = "0",
                                            valRetAir     = "0.00",
                                        });
                                    }
                                }
                            }
                        }
                        #endregion
                        ats.compras.Add(comp_det);
                    });
                }
                #endregion

                #region Ventas
                if (info_ats.lst_ventas != null)
                {
                    #region Agrupando clintes



                    var lst_ventas_x_cliente = (from q in info_ats.lst_ventas

                                                group q by new
                    {
                        q.idCliente,
                        q.DenoCli,
                        q.tipoCliente,
                        q.tipoComprobante,
                        q.tpIdCliente
                    }
                                                into g
                                                select new ventas_Info
                    {
                        idCliente = g.Key.idCliente,
                        DenoCli = g.Key.DenoCli,
                        tipoCliente = g.Key.tipoCliente,
                        tpIdCliente = g.Key.tpIdCliente,
                        tipoComprobante = g.Key.tipoComprobante,
                        baseNoGraIva = g.Sum(y => y.baseNoGraIva),
                        baseImponible = g.Sum(y => y.baseImponible),
                        baseImpGrav = g.Sum(y => y.baseImpGrav),
                        montoIva = g.Sum(y => y.montoIva),
                        montoIce = g.Sum(y => y.montoIce),
                        valorRetIva = g.Sum(y => y.valorRetIva),
                        valorRetRenta = g.Sum(y => y.valorRetRenta),
                        numeroComprobantes = info_ats.lst_ventas.Count()
                    }).ToList();


                    if (lst_ventas_x_cliente.Count > 0)
                    {
                        ats.ventas = new List <detalleVentas>();
                        lst_ventas_x_cliente.ForEach(
                            vent =>
                        {
                            detalleVentas det_ventas         = new detalleVentas();
                            det_ventas.tpIdCliente           = vent.tpIdCliente;
                            det_ventas.idCliente             = vent.idCliente;
                            det_ventas.parteRelVtas          = parteRelType.NO;
                            det_ventas.parteRelVtasSpecified = true;

                            if (vent.tipoCliente == " 01" && vent.idCliente != "9999999999999")
                            {
                                det_ventas.tipoCliente = vent.tipoCliente;
                            }

                            if (det_ventas.idCliente == "9999999999999")
                            {
                                det_ventas.tpIdCliente           = "07";
                                det_ventas.parteRelVtasSpecified = false;
                            }
                            if (det_ventas.tpIdCliente == "06")
                            {
                                det_ventas.tipoCliente = vent.tipoCliente;
                                det_ventas.denoCli     = vent.DenoCli;
                            }

                            vent.DenoCli = cl_funciones.QuitartildesEspaciosPuntos(vent.DenoCli);
                            det_ventas.tipoComprobante    = "18";
                            det_ventas.tipoEmision        = tipoEmisionType.F;
                            det_ventas.numeroComprobantes = vent.numeroComprobantes.ToString();
                            det_ventas.baseNoGraIva       = vent.baseNoGraIva;
                            det_ventas.baseImponible      = vent.baseImponible;
                            det_ventas.baseImpGrav        = vent.baseImpGrav;
                            det_ventas.montoIva           = vent.montoIva;
                            det_ventas.montoIce           = vent.montoIce;
                            det_ventas.valorRetIva        = vent.valorRetIva.ToString("n2");
                            det_ventas.valorRetRenta      = vent.valorRetRenta.ToString("n2");
                            det_ventas.montoIceSpecified  = true;
                            det_ventas.formasDePago       = null;
                            string[] AFormaPago           = { "20" };
                            det_ventas.formasDePago       = AFormaPago;

                            ats.ventas.Add(det_ventas);
                        }
                            );
                    }
                }



                #endregion



                #endregion

                #region ventas por establecimientos
                if (info_ats.lst_ventas != null)
                {
                    if (info_ats.lst_ventas.Count() > 0)
                    {
                        ats.ventasEstablecimiento = new List <ventaEst>();

                        var vtas = info_ats.lst_ventas.GroupBy(x => x.codEstab)
                                   .Select(x => new
                        {
                            codEstab    = x.Key,
                            ventasEstab = x.Sum(y => y.ventasEstab)
                        }).ToList();

                        foreach (var item in vtas)
                        {
                            ventaEst vtas_esta = new ventaEst();
                            vtas_esta.codEstab    = item.codEstab;
                            vtas_esta.ventasEstab = item.ventasEstab;
                            vtas_esta.ivaComp     = Convert.ToDecimal("0.00");
                            ats.ventasEstablecimiento.Add(vtas_esta);
                        }
                    }
                }
                #endregion

                #region exportaciones
                if (info_ats.lst_exportaciones != null)
                {
                    if (info_ats.lst_exportaciones.Count() > 0)
                    {
                        ats.exportaciones = new List <detalleExportacionesType>();
                        info_ats.lst_exportaciones.ForEach
                        (
                            exp =>
                        {
                            detalleExportacionesType exp_det = new detalleExportacionesType();
                            exp_det.tpIdClienteEx            = exp.tpIdClienteEx;
                            exp_det.idClienteEx         = exp.idClienteEx;
                            exp_det.parteRelExp         = parteRelType.NO;
                            exp_det.tipoCli             = "02";
                            exp_det.denoExpCli          = exp.denoExpCli = cl_funciones.QuitartildesEspaciosPuntos(exp.denoExpCli);
                            exp_det.tipoRegi            = tipoRegiType.Item01;
                            exp_det.paisEfecPagoGen     = exp.paisEfecPagoGen;
                            exp_det.paisEfecExp         = exp.paisEfecExp;
                            exp_det.exportacionDe       = exp.exportacionDe;
                            exp_det.tipoComprobante     = exp.tipoComprobante;
                            exp_det.fechaEmbarque       = exp.fechaEmbarque.ToString().Substring(0, 10);
                            exp_det.valorFOB            = (exp.valorFOB) == null?Convert.ToDecimal(0.00):Convert.ToDecimal(exp.valorFOB);
                            exp_det.valorFOBComprobante = (exp.valorFOB) == null ? Convert.ToDecimal(0.00) : Convert.ToDecimal(exp.valorFOBComprobante);
                            exp_det.establecimiento     = exp.establecimiento;
                            exp_det.puntoEmision        = exp.puntoEmision;
                            exp_det.secuencial          = exp.secuencial;
                            exp_det.autorizacion        = (exp.autorizacion) == null?"34345454656453":exp.autorizacion;
                            exp_det.fechaEmision        = exp.fechaEmision.ToString().Substring(0, 10);
                            //exp_det.pagoRegFisSpecified = true;
                            exp_det.parteRelExpSpecified = true;
                            exp_det.tipoRegiSpecified    = true;
                            //exp_det.impuestoOtroPaisSpecified = true;
                            //exp_det.ingExtGravOtroPaisSpecified = true;
                            ats.exportaciones.Add(exp_det);
                        }
                        );
                    }
                }
                #endregion

                #region Anulados
                if (info_ats.lst_anulados != null)
                {
                    if (info_ats.lst_anulados.Count() > 0)
                    {
                        ats.anulados = new List <detalleAnulados>();
                        info_ats.lst_anulados.ForEach
                        (
                            anu =>
                        {
                            detalleAnulados anula  = new detalleAnulados();
                            anula.tipoComprobante  = anu.tipoComprobante;
                            anula.establecimiento  = anu.Establecimiento;
                            anula.puntoEmision     = anu.puntoEmision;
                            anula.secuencialInicio = anu.secuencialInicio;
                            anula.secuencialFin    = anu.secuencialFin;
                            anula.autorizacion     = anu.Autorizacion;
                            ats.anulados.Add(anula);
                        }
                        );
                    }
                }
                #endregion


                if (info_ats.lst_ventas.Count == 0)
                {
                    ats.totalVentasSpecified = false;
                }
                else
                {
                    ats.numEstabRuc = info_ats.lst_ventas.GroupBy(x => x.codEstab)
                                      .Select(x => new
                    {
                        codEstab    = x.Key,
                        ventasEstab = x.Sum(y => y.ventasEstab)
                    }).Count().ToString().PadLeft(3, '0');
                    ats.totalVentasSpecified = true;
                }
                return(ats);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemple #4
0
        public List <FAC_020_Info> get_list(int IdEmpresa, int IdSucursal, int IdBodega, decimal IdGuiaRemision)
        {
            try
            {
                List <FAC_020_Info> Lista;
                using (Entities_reportes Context = new Entities_reportes())
                {
                    Lista = (from q in Context.VWFAC_020
                             where q.gi_IdEmpresa == IdEmpresa &&
                             q.gi_IdSucursal == IdSucursal &&
                             q.gi_IdBodega == IdBodega &&
                             q.gi_IdGuiaRemision == IdGuiaRemision
                             select new FAC_020_Info
                    {
                        fa_IdEmpresa = q.fa_IdEmpresa,
                        fa_IdSucursal = q.fa_IdSucursal,
                        fa_IdBodega = q.fa_IdBodega,
                        fa_IdCbteVta = q.fa_IdCbteVta,
                        gi_IdEmpresa = q.gi_IdEmpresa,
                        gi_IdSucursal = q.gi_IdSucursal,
                        gi_IdBodega = q.gi_IdBodega,
                        gi_IdGuiaRemision = q.gi_IdGuiaRemision,
                        Secuencia = q.Secuencia,
                        IdProducto = q.IdProducto,
                        pr_codigo = q.pr_codigo,
                        pr_descripcion = q.pr_descripcion,
                        gi_cantidad = q.gi_cantidad,
                        gi_detallexItems = q.gi_detallexItems,
                        pe_nombreCompleto = q.pe_nombreCompleto,
                        pe_cedulaRuc = q.pe_cedulaRuc,
                        CodDocumentoTipo = q.CodDocumentoTipo,
                        NumGuia_Preimpresa = q.NumGuia_Preimpresa,
                        CodGuiaRemision = q.CodGuiaRemision,
                        NUAutorizacion = q.NUAutorizacion,
                        Fecha_Autorizacion = q.Fecha_Autorizacion,
                        IdCliente = q.IdCliente,
                        IdTransportista = q.IdTransportista,
                        gi_fecha = q.gi_fecha,
                        gi_FechaFinTraslado = q.gi_FechaFinTraslado,
                        gi_FechaInicioTraslado = q.gi_FechaInicioTraslado,
                        gi_Observacion = q.gi_Observacion,
                        placa = q.placa,
                        Direccion_Origen = q.Direccion_Origen,
                        Direccion_Destino = q.Direccion_Destino,
                        Estado = q.Estado,
                        tr_Descripcion = q.tr_Descripcion,
                        NumComprobanteVenta = q.NumComprobanteVenta,
                        CedulaTransportista = q.CedulaTransportista,
                        NombreTransportista = q.NombreTransportista,
                        vt_fecha = q.vt_fecha,
                        vt_autorizacion = q.vt_autorizacion,
                        Su_Direccion = q.Su_Direccion,
                        Su_Descripcion = q.Su_Descripcion
                    }).ToList();
                }

                if (Lista.Count > 0)
                {
                    var Detalle = Lista[0];
                    if (!string.IsNullOrEmpty(Detalle.NumGuia_Preimpresa) && string.IsNullOrEmpty(Detalle.NUAutorizacion))
                    {
                        tb_empresa_Data odataEmpresa = new tb_empresa_Data();
                        tb_sis_Documento_Tipo_Talonario_Data odataTalonario = new tb_sis_Documento_Tipo_Talonario_Data();
                        string[] Array = Detalle.NumGuia_Preimpresa.Split('-');
                        if (Array.Count() == 3)
                        {
                            string ClaveAcceso = odataTalonario.GeneraClaveAcceso(Detalle.gi_fecha, "06", odataEmpresa.get_info(IdEmpresa).em_ruc, Array[0] + Array[1], Array[2]);
                            Lista.ForEach(q => q.NUAutorizacion = ClaveAcceso);
                        }
                    }
                }

                return(Lista);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemple #5
0
        public List <CXP_013_Info> get_list(int IdEmpresa, decimal IdRetencion)
        {
            try
            {
                List <CXP_013_Info> Lista;
                using (Entities_reportes Context = new Entities_reportes())
                {
                    Lista = (from q in Context.VWCXP_013
                             where q.IdEmpresa == IdEmpresa &&
                             q.IdRetencion == IdRetencion
                             select new CXP_013_Info
                    {
                        IdEmpresa = q.IdEmpresa,
                        IdRetencion = q.IdRetencion,
                        Idsecuencia = q.Idsecuencia,
                        re_TipoRet = q.re_TipoRet,
                        co_factura = q.co_factura,
                        NumRetencion = q.NumRetencion,
                        TipoComprobante = q.TipoComprobante,
                        FechaDeEmision = q.FechaDeEmision,
                        EjercicioFiscal = q.EjercicioFiscal,
                        re_baseRetencion = q.re_baseRetencion,
                        re_Porcen_retencion = q.re_Porcen_retencion,
                        re_valor_retencion = q.re_valor_retencion,
                        NombreProveedor = q.NombreProveedor,
                        pr_direccion = q.pr_direccion,
                        pe_cedulaRuc = q.pe_cedulaRuc,
                        pr_correo = q.pr_correo,
                        pr_telefonos = q.pr_telefonos,
                        NAutorizacion = q.NAutorizacion,
                        Fecha_Autorizacion = q.Fecha_Autorizacion,
                        Su_Descripcion = q.Su_Descripcion,
                        co_FechaFactura = q.co_FechaFactura
                    }).ToList();
                }

                if (Lista.Count > 0)
                {
                    var Detalle = Lista[0];
                    if (!string.IsNullOrEmpty(Detalle.NumRetencion) && string.IsNullOrEmpty(Detalle.NAutorizacion))
                    {
                        tb_empresa_Data odataEmpresa = new tb_empresa_Data();
                        tb_sis_Documento_Tipo_Talonario_Data odataTalonario = new tb_sis_Documento_Tipo_Talonario_Data();
                        string[] Array = Detalle.NumRetencion.Split('-');
                        if (Array.Count() == 3)
                        {
                            string ClaveAcceso = odataTalonario.GeneraClaveAcceso(Detalle.FechaDeEmision, "07", odataEmpresa.get_info(IdEmpresa).em_ruc, Array[0] + Array[1], Array[2]);
                            Lista.ForEach(q => q.NAutorizacion = ClaveAcceso);
                        }
                    }
                }

                return(Lista);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemple #6
0
        public List <FAC_002_Info> get_list(int IdEmpresa, int IdSucursal, int IdBodega, decimal IdNota)
        {
            try
            {
                List <FAC_002_Info> Lista = new List <FAC_002_Info>();
                using (Entities_reportes Context = new Entities_reportes())
                {
                    Lista = (from q in Context.VWFAC_002
                             where q.IdEmpresa == IdEmpresa &&
                             q.IdSucursal == IdSucursal &&
                             q.IdBodega == IdBodega &&
                             q.IdNota == IdNota
                             select new FAC_002_Info
                    {
                        Fecha_Autorizacion = q.Fecha_Autorizacion,
                        IdBodega = q.IdBodega,
                        IdEmpresa = q.IdEmpresa,
                        IdProducto = q.IdProducto,
                        IdSucursal = q.IdSucursal,
                        pr_descripcion = q.pr_descripcion,
                        Secuencia = q.Secuencia,
                        Celular = q.Celular,
                        CodDocumentoTipo = q.CodDocumentoTipo,
                        Correo = q.Correo,
                        CreDeb = q.CreDeb,
                        DetalleAdicional = q.DetalleAdicional,
                        Direccion = q.Direccion,
                        DocumentoAplicado = q.DocumentoAplicado,
                        FechaDocumentoAplica = q.FechaDocumentoAplica,
                        IdNota = q.IdNota,
                        no_fecha = q.no_fecha,
                        NumAutorizacion = q.NumAutorizacion,
                        NumNota_Impresa = q.NumNota_Impresa,
                        pe_cedulaRuc = q.pe_cedulaRuc,
                        pe_nombreCompleto = q.pe_nombreCompleto,
                        pr_codigo = q.pr_codigo,
                        sc_iva = q.sc_iva,
                        sc_observacion = q.sc_observacion,
                        sc_precioFinal = q.sc_precioFinal,
                        sc_subtotal = q.sc_subtotal,
                        sc_total = q.sc_total,
                        Serie1 = q.Serie1,
                        Serie2 = q.Serie2,
                        SubtotalAntesDescuento = q.SubtotalAntesDescuento,
                        SubtotalIva = q.SubtotalIva,
                        SubtotalSinIva = q.SubtotalSinIva,
                        Telefono = q.Telefono,
                        TotalDescuento = q.TotalDescuento,
                        sc_cantidad = q.sc_cantidad
                    }).ToList();
                }

                if (Lista.Count > 0)
                {
                    var Detalle = Lista[0];

                    if (!string.IsNullOrEmpty(Detalle.NumNota_Impresa) && string.IsNullOrEmpty(Detalle.NumAutorizacion))
                    {
                        tb_empresa_Data odataEmpresa = new tb_empresa_Data();
                        tb_sis_Documento_Tipo_Talonario_Data odataTalonario = new tb_sis_Documento_Tipo_Talonario_Data();
                        string[] Array       = Detalle.NumNota_Impresa.Split('-');
                        string   ClaveAcceso = odataTalonario.GeneraClaveAcceso(Detalle.no_fecha, Detalle.CreDeb == "C" ? "04" : "05", odataEmpresa.get_info(IdEmpresa).em_ruc, Detalle.Serie1 + Detalle.Serie2, Array[2]);
                        Lista.ForEach(q => q.NumAutorizacion = ClaveAcceso);
                    }
                }

                return(Lista);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemple #7
0
        public List <CXP_020_Info> GetList(int IdEmpresa, int IdTipoCbte, decimal IdCbteCble)
        {
            try
            {
                List <CXP_020_Info> Lista = new List <CXP_020_Info>();

                using (Entities_reportes db = new Entities_reportes())
                {
                    var lst = db.VWCXP_020.Where(q => q.IdEmpresa == IdEmpresa && q.IdTipoCbte_Ogiro == IdTipoCbte && q.IdCbteCble_Ogiro == IdCbteCble).ToList();
                    foreach (var item in lst)
                    {
                        Lista.Add(new CXP_020_Info
                        {
                            IdEmpresa          = item.IdEmpresa,
                            IdTipoCbte_Ogiro   = item.IdTipoCbte_Ogiro,
                            IdCbteCble_Ogiro   = item.IdCbteCble_Ogiro,
                            NomDocumento       = item.NomDocumento,
                            co_serie           = item.co_serie,
                            co_factura         = item.co_factura,
                            Num_Autorizacion   = item.Num_Autorizacion,
                            fecha_autorizacion = item.fecha_autorizacion,
                            Su_Descripcion     = item.Su_Descripcion,
                            Su_Direccion       = item.Su_Direccion,
                            pe_nombreCompleto  = item.pe_nombreCompleto,
                            pe_cedulaRuc       = item.pe_cedulaRuc,
                            co_FechaFactura    = item.co_FechaFactura,
                            co_observacion     = item.co_observacion,
                            IdFormaPago        = item.IdFormaPago,
                            nom_FormaPago      = item.nom_FormaPago,
                            co_subtotal_iva    = item.co_subtotal_iva,
                            co_subtotal_siniva = item.co_subtotal_siniva,
                            co_subtotal        = item.co_subtotal,
                            co_total           = item.co_total,
                            co_valoriva        = item.co_valoriva,
                            pr_descripcion     = item.pr_descripcion,
                            pr_codigo          = item.pr_codigo,
                            Subtotal           = item.Subtotal,
                            Descuento          = item.Descuento,
                            TotalDetalle       = item.TotalDetalle,
                            ValorIva           = item.ValorIva,
                            pr_direccion       = item.pr_direccion,
                            pr_correo          = item.pr_correo,
                            Cantidad           = item.Cantidad,
                            CostoUni           = item.CostoUni
                        });
                    }
                }

                if (Lista.Count > 0)
                {
                    var Detalle = Lista[0];
                    if (!string.IsNullOrEmpty(Detalle.co_factura) && (string.IsNullOrEmpty(Detalle.Num_Autorizacion) || Detalle.Num_Autorizacion == "1234567890"))
                    {
                        tb_empresa_Data odataEmpresa = new tb_empresa_Data();
                        tb_sis_Documento_Tipo_Talonario_Data odataTalonario = new tb_sis_Documento_Tipo_Talonario_Data();
                        string[] Array = Detalle.co_serie.Split('-');
                        if (Array.Count() == 3)
                        {
                            string ClaveAcceso = odataTalonario.GeneraClaveAcceso(Detalle.co_FechaFactura, "06", odataEmpresa.get_info(IdEmpresa).em_ruc, Array[0] + Array[1], Detalle.co_factura);
                            Lista.ForEach(q => q.Num_Autorizacion = ClaveAcceso);
                        }
                    }
                }

                return(Lista);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemple #8
0
        public List <FAC_007_Info> get_list(int IdEmpresa, int IdSucursal, int IdBodega, decimal IdCbteVta)
        {
            try
            {
                List <FAC_007_Info> Lista;

                using (Entities_reportes Context = new Entities_reportes())
                {
                    Lista = (from q in Context.VWFAC_007
                             where q.IdEmpresa == IdEmpresa &&
                             q.IdSucursal == IdSucursal &&
                             q.IdBodega == IdBodega &&
                             q.IdCbteVta == IdCbteVta
                             select new FAC_007_Info
                    {
                        cli_cedulaRuc = q.cli_cedulaRuc,
                        cli_correo = q.cli_correo,
                        cli_direccion = q.cli_direccion,
                        cli_Nombre = q.cli_Nombre,
                        cli_Telefonos = q.cli_Telefonos,
                        DescuentoTotal = q.DescuentoTotal,
                        Fecha_Autorizacion = q.Fecha_Autorizacion,
                        FormaPago = q.FormaPago,
                        FormaDePago = q.FormaDePago,
                        nom_FormaPago = q.nom_FormaPago,
                        IdBodega = q.IdBodega,
                        IdCatalogo_FormaPago = q.IdCatalogo_FormaPago,
                        IdCbteVta = q.IdCbteVta,
                        IdEmpresa = q.IdEmpresa,
                        IdProducto = q.IdProducto,
                        IdSucursal = q.IdSucursal,
                        pr_descripcion = q.pr_descripcion,
                        Secuencia = q.Secuencia,
                        SubtotalConDscto = q.SubtotalConDscto,
                        SubtotalIVA = q.SubtotalIVA,
                        SubtotalSinDscto = q.SubtotalSinDscto,
                        SubtotalSinIVA = q.SubtotalSinIVA,
                        Su_Descripcion = q.Su_Descripcion,
                        Su_Direccion = q.Su_Direccion,
                        Su_Telefonos = q.Su_Telefonos,
                        vt_autorizacion = q.vt_autorizacion,
                        Cambio = q.Cambio,
                        vt_cantidad = q.vt_cantidad,
                        vt_fecha = q.vt_fecha,
                        vt_iva = q.vt_iva,
                        vt_NumFactura = q.vt_NumFactura,
                        vt_por_iva = q.vt_por_iva,
                        vt_Precio = q.vt_Precio,
                        Total = q.Total,
                        ValorEfectivo = q.ValorEfectivo,
                        vt_Observacion = q.vt_Observacion,

                        Descuento = q.Descuento,
                        SubtotalIVAConDscto = q.SubtotalIVAConDscto,
                        SubtotalIVASinDscto = q.SubtotalIVASinDscto,
                        SubtotalSinIVAConDscto = q.SubtotalSinIVAConDscto,
                        SubtotalSinIVASinDscto = q.SubtotalSinIVASinDscto,
                        T_SubtotalConDscto = q.T_SubtotalConDscto,
                        T_SubtotalSinDscto = q.T_SubtotalSinDscto,
                        ValorIVA = q.ValorIVA,
                        vt_total = q.vt_total,

                        vt_detallexItems = q.vt_detallexItems,
                        vt_plazo = q.vt_plazo
                    }).ToList();
                }

                if (Lista.Count > 0)
                {
                    var Detalle = Lista[0];
                    if (string.IsNullOrEmpty(Detalle.vt_autorizacion))
                    {
                        tb_empresa_Data odataEmpresa = new tb_empresa_Data();
                        tb_sis_Documento_Tipo_Talonario_Data odataTalonario = new tb_sis_Documento_Tipo_Talonario_Data();
                        string[] Array = Detalle.vt_NumFactura.Split('-');
                        if (Array.Count() == 3)
                        {
                            string ClaveAcceso = odataTalonario.GeneraClaveAcceso(Detalle.vt_fecha, "01", odataEmpresa.get_info(IdEmpresa).em_ruc, Array[0] + Array[1], Array[2]);
                            Lista.ForEach(q => q.vt_autorizacion = ClaveAcceso);
                        }
                    }
                }
                return(Lista);
            }
            catch (Exception)
            {
                throw;
            }
        }