Exemplo n.º 1
0
        public FileResult Nuevo(ats_Info model)
        {
            model.info_periodo.IdPeriodo = Convert.ToInt32(Session["IdPeriodo"]);
            bus_ats = new ats_Bus();
            string nombre_file = model.info_periodo.IdPeriodo.ToString();

            if (model.info_periodo.IdPeriodo.ToString().Length == 6)
            {
                nombre_file = "AT-" + model.info_periodo.IdPeriodo.ToString().Substring(4, 2) + model.info_periodo.IdPeriodo.ToString().Substring(0, 4);
            }
            string xml        = "";
            iva    ats        = new iva();
            int    IdEmpresa  = Convert.ToInt32(SessionFixed.IdEmpresa);
            int    IdSucursal = Convert.ToInt32(SessionFixed.IdSucursal);

            ats = bus_ats.get_ats(IdEmpresa, model.info_periodo.IdPeriodo, IdSucursal);
            var ms = new MemoryStream();
            var xw = XmlWriter.Create(ms);


            var serializer             = new XmlSerializer(ats.GetType());
            XmlSerializerNamespaces ns = new XmlSerializerNamespaces();

            ns.Add("", "");
            serializer.Serialize(xw, ats, ns);
            xw.Flush();
            ms.Seek(0, SeekOrigin.Begin);
            using (var sr = new StreamReader(ms, Encoding.UTF8))
            {
                xml = sr.ReadToEnd();
            }
            byte[] fileBytes = ms.ToArray();
            return(File(fileBytes, "application/xml", nombre_file + ".xml"));
        }
        public TablaIvaInventario(InventarioFinal invFinal, iva Iva)
        {
            InitializeComponent();
            //ajuste_iva = new AjusteIva();
            //ajuste_iva.SaldoIvaDebitoFiscal = 8320;
            //ajuste_iva.SaldoIvaCreditoFiscal = 16900;
            //ajuste_iva.getIvaAPagar();

            //this.dataGridView1.Rows.Clear();
            //this.dataGridView1.Rows.Add
            //    (2109, "IVA DEBITO FISCAL", "$ " + ajuste_iva.SaldoIvaDebitoFiscal, "");
            //this.dataGridView1.Rows.Add
            //    (1112, "IVA CREDITO FISCAL", "", "$ " + ajuste_iva.SaldoIvaCreditoFiscal);
            //this.dataGridView1.Rows.Add
            //    (211103, "IVA A PAGAR", "$ " + ajuste_iva.IvaAPagarDebe, "$ " + ajuste_iva.IvaAPagarHaber);
            //this.dataGridView1.Rows.Add
            //    ("", "AJUSTE DE IVA", "$ " + ajuste_iva.ajuste, "$ " + ajuste_iva.ajuste);
            this.dataGridView1.Rows.Add(2109, "IVA DEBITO FISCAL", "$" + 0, "$ " + Iva.ivaDebito);
            this.dataGridView1.Rows.Add(2109, "IVA CREDITO FISCAL", "$" + Iva.ivaCredito, "$" + 0);
            this.dataGridView1.Rows.Add(211103, "IVA A PAGAR", 0, "$ " + Iva.ivaPagar);
            this.dataGridView1.Rows.Add("", "AJUSTE DE IVA", "$ " + Iva.ivaCredito, "$ " + (Iva.ivaDebito + Iva.ivaPagar));
            this.dataGridView1.Rows.Add(4101, "COMPRAS", invFinal.inventarioInicial, 0);
            this.dataGridView1.Rows.Add(1109, "INVENTARIO", 0, invFinal.inventarioInicial);
            this.dataGridView1.Rows.Add(0, "MERCANCIA DISPONIBLE", invFinal.inventarioInicial, invFinal.inventarioInicial);
            this.dataGridView1.Rows.Add(1109, "INVENTARIO", invFinal.inventarioFinal, 0);
            this.dataGridView1.Rows.Add(4101, "COMPRAS", 0, invFinal.inventarioFinal);
            this.dataGridView1.Rows.Add(0, "DETERMINAR COSTO DE VENTA", invFinal.inventarioFinal, invFinal.inventarioFinal);
            this.dataGridView1.Refresh();
        }
Exemplo n.º 3
0
        private void button1_Click(object sender, EventArgs e)
        {
            InventarioFinal invFinal = new InventarioFinal();

            invFinal.CalcularInventarioFinal(this.dataGridView1);
            iva frmIva = new iva();

            frmIva.CalcularIva(this.dataGridView1);
            TablaIvaInventario frmTabla = new TablaIvaInventario(invFinal, frmIva);

            frmTabla.Show();
        }
Exemplo n.º 4
0
 static public Boolean SerializeToXML(iva data, string ruta)
 {
     try
     {
         XmlSerializer serializer = new XmlSerializer(typeof(iva));
         TextWriter    textWriter = new StreamWriter(@ruta);
         serializer.Serialize(textWriter, data);
         textWriter.Close();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Exemplo n.º 5
0
        static public Boolean SerializeToXML(iva data, string ruta)
        {
            try
            {
                XmlSerializer serializer = new XmlSerializer(typeof(iva));

                TextWriter textWriter = new StreamWriter(@ruta);
                serializer.Serialize(textWriter, data);

                textWriter.Close();

                string text = File.ReadAllText(@ruta);
                text = text.Replace("\r\n", "");
                File.WriteAllText(@ruta + ".xml", text);

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Exemplo n.º 6
0
        private iva CargaDatos()
        {
            iva iva = new iva();

            try
            {
                progressBar1.Value = 40;

                cp_codigo_SRI_Bus         dat_ti             = new cp_codigo_SRI_Bus();
                List <cp_codigo_SRI_Info> ListCodigoSRI      = new List <cp_codigo_SRI_Info>();
                List <cp_codigo_SRI_Info> ListCodigoSustento = new List <cp_codigo_SRI_Info>();
                ListCodigoSRI = dat_ti.Get_List_codigo_SRI_(param.IdEmpresa);

                ListCodigoSustento = ListCodigoSRI.FindAll(c => c.co_estado == "A" && c.IdTipoSRI == "COD_IDCREDITO");

                List <cp_TipoDocumento_Info> LstTipDoc = new List <cp_TipoDocumento_Info>();
                cp_TipoDocumento_Bus         TipDoc_B  = new cp_TipoDocumento_Bus();
                LstTipDoc = TipDoc_B.Get_List_TipoDocumento();


                cp_orden_giro_pagos_sri_Bus   formasPago_B   = new cp_orden_giro_pagos_sri_Bus();
                cp_orden_giro_Bus             OGB            = new cp_orden_giro_Bus();
                cp_proveedor_Autorizacion_Bus Autorizacion_B = new cp_proveedor_Autorizacion_Bus();
                cp_proveedor_Bus Proveedor_B = new cp_proveedor_Bus();
                tb_persona_bus   Persona_B   = new tb_persona_bus();

                List <Core.Erp.Info.CuentasxPagar.xmlATS_V_1_1_4.detalleCompras> lstDetalleCompras = new List <Core.Erp.Info.CuentasxPagar.xmlATS_V_1_1_4.detalleCompras>();
                List <cp_orden_giro_Info> listaOG = new List <cp_orden_giro_Info>();
                listaOG = OGB.Get_List_orden_giro_SRI(param.IdEmpresa, Convert.ToInt32(cmb_anio.Text), Convert.ToInt32(cmb_periodo.SelectedValue));



                iva.IdInformante = Empresa_I.em_ruc;
                iva.razonSocial  = Empresa_I.RazonSocial.Replace(".", " ").Replace("ñ", "n").Replace("Ñ", "N");
                iva.Anio         = cmb_anio.Text;
                iva.Mes          = (cmb_periodo.SelectedValue.ToString().Length == 1) ? "0" + cmb_periodo.SelectedValue.ToString() : cmb_periodo.SelectedValue.ToString();

                tb_Sucursal_Bus bus_sucursal       = new tb_Sucursal_Bus();
                int             numEstablecimiento = bus_sucursal.Get_numEstablecimiento_x_empresa_SRI(param.IdEmpresa);
                iva.numEstabRuc = numEstablecimiento.ToString("000");


                iva.TipoIDInformante = ivaTypeTipoIDInformante.R;
                iva.codigoOperativo  = codigoOperativoType.IVA;
                iva.totalVentas      = 0;



                foreach (cp_orden_giro_Info item in listaOG)
                {
                    try
                    {
                        Core.Erp.Info.CuentasxPagar.xmlATS_V_1_1_4.detalleCompras itemDetalleCompras = new Core.Erp.Info.CuentasxPagar.xmlATS_V_1_1_4.detalleCompras();
                        if (item.IdCbteCble_Ogiro == 9)
                        {
                        }
                        info_Retencion_x_RF   = Retencion_B.Get_Info_retencion_X_Retecion_FT(param.IdEmpresa, item.IdCbteCble_Ogiro, item.IdTipoCbte_Ogiro);
                        info_Retencion_x_RIVA = Retencion_B.Get_Info_retencion_X_Retecion_RTIVA(param.IdEmpresa, item.IdCbteCble_Ogiro, item.IdTipoCbte_Ogiro);

                        string secuenci_numReten = "";
                        List <Core.Erp.Info.CuentasxPagar.xmlATS_V_1_1_4.detalleAir> LstdetalleAir = new List <Core.Erp.Info.CuentasxPagar.xmlATS_V_1_1_4.detalleAir>();
                        string fecRet = info_Retencion_x_RF.fecha.ToString("dd/MM/yyyy");


                        if (info_Retencion_x_RF.ListDetalle.Count != 0)
                        {
                            foreach (var item2 in info_Retencion_x_RF.ListDetalle)
                            {
                                Core.Erp.Info.CuentasxPagar.xmlATS_V_1_1_4.detalleAir detalleAir = new Core.Erp.Info.CuentasxPagar.xmlATS_V_1_1_4.detalleAir();
                                detalleAir.codRetAir = item2.CodigoSRI.Trim();

                                detalleAir.porcentajeAir = Convert.ToDecimal(item2.re_Porcen_retencion).ToString();
                                detalleAir.baseImpAir    = Convert.ToDecimal(item2.re_baseRetencion).ToString();

                                fecRet = info_Retencion_x_RF.fecha.ToString("dd/MM/yyyy");
                                detalleAir.valRetAir = Convert.ToDecimal(item2.re_valor_retencion).ToString();
                                LstdetalleAir.Add(detalleAir);
                            }
                        }


                        itemDetalleCompras.valRetBien10      = "0";
                        itemDetalleCompras.valRetServ20      = "0";
                        itemDetalleCompras.valRetServ50      = "0";
                        itemDetalleCompras.valRetServ100     = "0";
                        itemDetalleCompras.valorRetBienes    = "0";
                        itemDetalleCompras.valorRetServicios = "0";
                        itemDetalleCompras.totbasesImpReemb  = "0";


                        if (info_Retencion_x_RIVA.ListDetalle.Count != 0)
                        {
                            foreach (var item_iva in info_Retencion_x_RIVA.ListDetalle)
                            {
                                if (item_iva.re_Porcen_retencion == 10)
                                {
                                    itemDetalleCompras.valRetBien10 = Convert.ToDecimal(item_iva.re_valor_retencion).ToString();
                                }

                                if (item_iva.re_Porcen_retencion == 20)
                                {
                                    itemDetalleCompras.valRetServ20 = Convert.ToDecimal(item_iva.re_valor_retencion).ToString();
                                }

                                if (item_iva.re_Porcen_retencion == 30)
                                {
                                    itemDetalleCompras.valorRetBienes = Convert.ToDecimal(item_iva.re_valor_retencion).ToString();
                                }

                                if (item_iva.re_Porcen_retencion == 50)
                                {
                                    itemDetalleCompras.valRetServ50 = Convert.ToDecimal(item_iva.re_valor_retencion).ToString();
                                }

                                if (item_iva.re_Porcen_retencion == 70)
                                {
                                    itemDetalleCompras.valorRetServicios = Convert.ToDecimal(item_iva.re_valor_retencion).ToString();
                                }


                                if (item_iva.re_Porcen_retencion == 100)
                                {
                                    itemDetalleCompras.valRetServ100 = Convert.ToDecimal(item_iva.re_valor_retencion).ToString();
                                }
                            }
                        }



                        if (item.IdIden_credito != 0)
                        {
                            var sustento = ListCodigoSustento.First(c => c.IdCodigo_SRI == item.IdIden_credito);
                            itemDetalleCompras.codSustento = sustento.codigoSRI;
                        }


                        if (!String.IsNullOrEmpty(item.co_serie))
                        {
                            string[] serie = Convert.ToString(item.co_serie).Split('-');

                            itemDetalleCompras.establecimiento = serie[0];
                            itemDetalleCompras.puntoEmision    = serie[1];
                        }


                        itemDetalleCompras.secuencial = item.co_factura;

                        //if (item.co_factura == "000002133") { MessageBox.Show(""); }



                        itemDetalleCompras.fechaRegistro = Convert.ToDateTime(item.co_FechaContabilizacion).ToString("dd/MM/yyyy");
                        itemDetalleCompras.idProv        = item.InfoProveedor.Persona_Info.pe_cedulaRuc.Trim();
                        itemDetalleCompras.tpIdProv      = (item.InfoProveedor.Persona_Info.IdTipoDocumento.Trim() == "RUC") ? "01" : ((item.InfoProveedor.Persona_Info.IdTipoDocumento.Trim() == "CED") ? "02" : "03");
                        itemDetalleCompras.parteRel      = (item.InfoProveedor.es_empresa_relacionada == true) ? parteRelType.SI : parteRelType.NO;
                        itemDetalleCompras.autorizacion  = (item.Num_Autorizacion == null) ? "" : item.Num_Autorizacion;



                        if (itemDetalleCompras.tpIdProv == "03")
                        {
                            itemDetalleCompras.tipoProv = (item.InfoProveedor.Persona_Info.pe_Naturaleza == "NATUR") ? "01" : "02";

                            if (item.InfoProveedor.es_empresa_relacionada == true)
                            {
                                itemDetalleCompras.parteRel = parteRelType.SI;
                            }
                            else
                            {
                                itemDetalleCompras.parteRel = parteRelType.NO;
                            }
                        }


                        var tipD = LstTipDoc.First(c => c.CodTipoDocumento == item.IdOrden_giro_Tipo);
                        itemDetalleCompras.tipoComprobante = tipD.CodSRI;
                        itemDetalleCompras.fechaEmision    = item.co_FechaFactura.ToString("dd/MM/yyyy");
                        itemDetalleCompras.autorizacion    = item.Num_Autorizacion;

                        itemDetalleCompras.baseNoGraIva  = "0";                                                                                                 //base NO objeto de IVA
                        itemDetalleCompras.baseImponible = Math.Round(Convert.ToDecimal(item.co_subtotal_siniva), 2, MidpointRounding.AwayFromZero).ToString(); // sin iva
                        itemDetalleCompras.baseImpGrav   = Math.Round(Convert.ToDecimal(item.co_subtotal_iva), 2, MidpointRounding.AwayFromZero).ToString();    //con iva
                        itemDetalleCompras.baseImpExe    = "0";

                        itemDetalleCompras.montoIce = Math.Round(Convert.ToDecimal(item.co_Ice_valor), 2, MidpointRounding.AwayFromZero).ToString();
                        itemDetalleCompras.montoIva = Math.Round(Convert.ToDecimal(item.co_valoriva), 2, MidpointRounding.AwayFromZero).ToString();

                        itemDetalleCompras.valRetBien10Specified     = true;
                        itemDetalleCompras.valRetServ20Specified     = true;
                        itemDetalleCompras.valRetServ50Specified     = true;
                        itemDetalleCompras.totbasesImpReembSpecified = true;

                        if (tipD.CodSRI == "05")
                        {
                            itemDetalleCompras.docModificado    = item.Tipodoc_a_Modificar;
                            itemDetalleCompras.estabModificado  = item.estable_a_Modificar;
                            itemDetalleCompras.ptoEmiModificado = item.ptoEmi_a_Modificar;
                            itemDetalleCompras.secModificado    = item.num_docu_Modificar;
                            itemDetalleCompras.autModificado    = item.aut_doc_Modificar;
                        }

                        if (LstdetalleAir.Count > 0)
                        {
                            itemDetalleCompras.air = LstdetalleAir;     //AREGLAR
                        }
                        if (!string.IsNullOrEmpty(info_Retencion_x_RF.NAutorizacion))
                        {
                            secuenci_numReten = info_Retencion_x_RF.NumRetencion.ToString();
                            string sSerieRetencion = "";
                            sSerieRetencion = info_Retencion_x_RF.serie1 + '-' + info_Retencion_x_RF.serie2;
                            if (!string.IsNullOrEmpty(sSerieRetencion))
                            {
                                itemDetalleCompras.estabRetencion1  = info_Retencion_x_RF.serie1;
                                itemDetalleCompras.ptoEmiRetencion1 = info_Retencion_x_RF.serie2;
                            }
                            itemDetalleCompras.secRetencion1 = secuenci_numReten;
                            itemDetalleCompras.autRetencion1 = info_Retencion_x_RF.NAutorizacion;
                            itemDetalleCompras.fechaEmiRet1  = fecRet;
                        }

                        lstDetalleCompras.Add(itemDetalleCompras);

                        pagoExterior Item_pagoExterior = new pagoExterior();

                        if (item.PagoLocExt == "LOC")
                        {
                            Item_pagoExterior.pagoLocExt = pagoLocExtType.Item01;
                        }
                        else
                        {
                            Item_pagoExterior.pagoLocExt = pagoLocExtType.Item02;
                        }


                        Item_pagoExterior.paisEfecPago = (Item_pagoExterior.pagoLocExt == pagoLocExtType.Item01) ? "NA" : (item.PaisPago != null || item.PaisPago != "") ? item.PaisPago : "NA";

                        Item_pagoExterior.aplicConvDobTrib   = (item.ConvenioTributacion == "S") ? aplicConvDobTribType.SI : (item.ConvenioTributacion == "N") ? aplicConvDobTribType.NO :aplicConvDobTribType.NA;
                        Item_pagoExterior.pagExtSujRetNorLeg = (item.PagoSujetoRetencion == "S") ? aplicConvDobTribType.SI : (item.PagoSujetoRetencion == "N") ? aplicConvDobTribType.NO : aplicConvDobTribType.NA;



                        itemDetalleCompras.pagoExterior = Item_pagoExterior;



                        List <cp_orden_giro_pagos_sri_Info> formasDePagoOG = new List <cp_orden_giro_pagos_sri_Info>();
                        formasDePagoOG = formasPago_B.Get_List_orden_giro_pagos_sri(item.IdEmpresa, item.IdCbteCble_Ogiro, item.IdTipoCbte_Ogiro);

                        string  cadena = "";
                        string  coma   = "";
                        Boolean Hay_registros_de_pagos = false;


                        if (formasDePagoOG.Count > 0)
                        {
                            foreach (var itemfp in formasDePagoOG)
                            {
                                if (itemfp.check == true)
                                {
                                    cadena = cadena + coma + itemfp.codigo_pago_sri;
                                    coma   = ",";
                                    Hay_registros_de_pagos = true;
                                }
                            }
                            if (Hay_registros_de_pagos)
                            {
                                itemDetalleCompras.formasDePago = cadena.Split(',');
                            }
                        }


                        if (Hay_registros_de_pagos == false)
                        {
                            decimal Total = 0;
                            Total = Convert.ToDecimal(itemDetalleCompras.baseNoGraIva) + Convert.ToDecimal(itemDetalleCompras.baseImpGrav);

                            if (Total >= 1000)
                            {
                                string[] arr1 = new string[] { "01" };
                                itemDetalleCompras.formasDePago = arr1;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                    }
                }

// Para las notas de debito y credito cxp
//*************************************

                cp_nota_DebCre_Bus         nota_B      = new cp_nota_DebCre_Bus();
                List <cp_nota_DebCre_Info> listaNotaDC = new List <cp_nota_DebCre_Info>();
                listaNotaDC = nota_B.Get_List_nota_DebCre(param.IdEmpresa, Convert.ToInt32(cmb_anio.Text), Convert.ToInt32(cmb_periodo.SelectedValue));



                progressBar1.Value = 70;
                foreach (cp_nota_DebCre_Info item in listaNotaDC)
                {
                    Core.Erp.Info.CuentasxPagar.xmlATS_V_1_1_4.detalleCompras itemDetalleCompras = new Core.Erp.Info.CuentasxPagar.xmlATS_V_1_1_4.detalleCompras();



                    List <Core.Erp.Info.CuentasxPagar.xmlATS_V_1_1_4.detalleAir> LstdetalleAir = new List <Core.Erp.Info.CuentasxPagar.xmlATS_V_1_1_4.detalleAir>();

                    cp_proveedor_Autorizacion_Info Autorizacion_I = new cp_proveedor_Autorizacion_Info();

                    var sustento = ListCodigoSustento.First(c => c.IdCodigo_SRI == item.IdIden_credito);
                    itemDetalleCompras.codSustento = sustento.codigoSRI;

                    itemDetalleCompras.establecimiento = item.cn_serie1;
                    itemDetalleCompras.puntoEmision    = item.cn_serie2;
                    itemDetalleCompras.secuencial      = item.cn_Nota;
                    itemDetalleCompras.autorizacion    = item.cn_Autorizacion;



                    //if ("000002133" == item.cn_Nota) { MessageBox.Show(""); }

                    if (item.Fecha_contable != null)
                    {
                        itemDetalleCompras.fechaRegistro = Convert.ToDateTime(item.Fecha_contable).ToString("dd/MM/yyyy");
                        itemDetalleCompras.fechaEmision  = Convert.ToDateTime(item.Fecha_contable).ToString("dd/MM/yyyy");
                    }

                    if (String.IsNullOrEmpty(itemDetalleCompras.fechaRegistro))
                    {
                        itemDetalleCompras.fechaRegistro = Convert.ToDateTime(item.cn_fecha).ToString("dd/MM/yyyy");
                        itemDetalleCompras.fechaEmision  = Convert.ToDateTime(item.cn_fecha).ToString("dd/MM/yyyy");
                    }



                    itemDetalleCompras.idProv   = item.InfoProveedor.Persona_Info.pe_cedulaRuc.Trim();
                    itemDetalleCompras.tpIdProv = (item.InfoProveedor.Persona_Info.IdTipoDocumento.Trim() == "RUC") ? "01" : ((item.InfoProveedor.Persona_Info.IdTipoDocumento.Trim() == "CED") ? "02" : "03");

                    if (itemDetalleCompras.tpIdProv == "03")
                    {
                        itemDetalleCompras.tipoProv = (item.InfoProveedor.Persona_Info.pe_Naturaleza == "NATUR") ? "01" : "02";
                        if (item.InfoProveedor.es_empresa_relacionada == true)
                        {
                            itemDetalleCompras.parteRel = parteRelType.SI;
                        }
                        else
                        {
                            itemDetalleCompras.parteRel = parteRelType.NO;
                        }
                    }



                    itemDetalleCompras.tipoComprobante = (item.DebCre == "C" || item.DebCre == "Credito") ? "04" : "05";
                    if (item.Fecha_contable != null)
                    {
                        itemDetalleCompras.fechaEmision = Convert.ToString(item.Fecha_contable);
                    }

                    itemDetalleCompras.baseNoGraIva  = "0";
                    itemDetalleCompras.baseImponible = Math.Round(Convert.ToDecimal(item.cn_subtotal_siniva), 2, MidpointRounding.AwayFromZero).ToString();    //sin iva
                    itemDetalleCompras.baseImpGrav   = Math.Round(Convert.ToDecimal(item.cn_subtotal_iva), 2, MidpointRounding.AwayFromZero).ToString();
                    itemDetalleCompras.baseImpExe    = "0";


                    itemDetalleCompras.montoIce = Math.Round(Convert.ToDecimal(item.cn_Ice_valor), 2, MidpointRounding.AwayFromZero).ToString();
                    itemDetalleCompras.montoIva = Math.Round(Convert.ToDecimal(item.cn_valoriva), 2, MidpointRounding.AwayFromZero).ToString();


                    itemDetalleCompras.valRetBien10      = "0.00";
                    itemDetalleCompras.valRetServ20      = "0.00";
                    itemDetalleCompras.valorRetBienes    = "0.00";
                    itemDetalleCompras.valRetServ50      = "0.00";
                    itemDetalleCompras.valorRetServicios = "0.00";
                    itemDetalleCompras.valRetServ100     = "0.00";
                    itemDetalleCompras.totbasesImpReemb  = "0.00";

                    itemDetalleCompras.valRetBien10Specified     = true;
                    itemDetalleCompras.valRetServ20Specified     = true;
                    itemDetalleCompras.valRetServ50Specified     = true;
                    itemDetalleCompras.totbasesImpReembSpecified = true;


                    if (LstdetalleAir.Count > 0)
                    {
                        itemDetalleCompras.air = LstdetalleAir;
                    }


                    itemDetalleCompras.docModificado    = item.docModificado;
                    itemDetalleCompras.estabModificado  = item.estabModificado;
                    itemDetalleCompras.ptoEmiModificado = item.ptoEmiModificado;
                    itemDetalleCompras.secModificado    = item.secModificado;
                    itemDetalleCompras.autModificado    = item.autModificado;

                    lstDetalleCompras.Add(itemDetalleCompras);

                    pagoExterior Item_pagoExterior = new pagoExterior();
                    Item_pagoExterior.pagoLocExt   = (item.PagoLocExt == "LOC") ? pagoLocExtType.Item01 : pagoLocExtType.Item02;
                    Item_pagoExterior.paisEfecPago = (Item_pagoExterior.pagoLocExt == pagoLocExtType.Item01) ? "NA"  : (item.PaisPago != null || item.PaisPago != "") ? item.PaisPago : "NA";

                    Item_pagoExterior.aplicConvDobTrib   = (item.ConvenioTributacion == "S") ? aplicConvDobTribType.SI : (item.ConvenioTributacion == "N") ? aplicConvDobTribType.NO :aplicConvDobTribType.NA;
                    Item_pagoExterior.pagExtSujRetNorLeg = (item.PagoSujetoRetencion == "S") ? aplicConvDobTribType.SI : (item.PagoSujetoRetencion == "N") ? aplicConvDobTribType.NO : aplicConvDobTribType.NA;

                    itemDetalleCompras.pagoExterior = Item_pagoExterior;
                }

                iva.compras        = lstDetalleCompras;
                progressBar1.Value = 85;

//*****ANULADOS*******
//********************

                tb_sis_Documento_Tipo_x_Empresa_Anulados_Bus         DocAnu_B  = new tb_sis_Documento_Tipo_x_Empresa_Anulados_Bus();
                List <tb_sis_Documento_Tipo_x_Empresa_Anulados_Info> LstDocAnu = new List <tb_sis_Documento_Tipo_x_Empresa_Anulados_Info>();

                LstDocAnu = DocAnu_B.ConsultaPorMesAnio(param.IdEmpresa, Convert.ToInt32(cmb_anio.Text), Convert.ToInt32(cmb_periodo.SelectedValue));

                List <Core.Erp.Info.CuentasxPagar.xmlATS_V_1_1_4.detalleAnulados> lstDetalleDocAnu = new List <Core.Erp.Info.CuentasxPagar.xmlATS_V_1_1_4.detalleAnulados>();
                foreach (var itemDA in LstDocAnu)
                {
                    if (itemDA.Autorizacion != null)
                    {
                        detalleAnulados info = new detalleAnulados();
                        info.autorizacion     = itemDA.Autorizacion;
                        info.establecimiento  = itemDA.Serie1;
                        info.puntoEmision     = itemDA.Serie2;
                        info.secuencialInicio = itemDA.Documento;
                        info.secuencialFin    = itemDA.DocumentoFin;
                        var tipD = LstTipDoc.First(c => c.CodTipoDocumento == itemDA.codDocumentoTipo);
                        info.tipoComprobante = tipD.CodSRI;
                        lstDetalleDocAnu.Add(info);
                    }
                }

                if (lstDetalleDocAnu.Count > 0)
                {
                    iva.anulados = lstDetalleDocAnu;
                }

                //// FACTURAS

                fa_factura_Bus fac_B = new fa_factura_Bus();

                List <detalleVentas> LstDV = new List <detalleVentas>();
                LstDV = fac_B.Get_List_VentasParaATS(param.IdEmpresa, Convert.ToInt32(cmb_anio.Text), Convert.ToInt32(cmb_periodo.SelectedValue));

                int IdPeriodo = (Convert.ToInt32(iva.Anio) * 100) + Convert.ToInt32(iva.Mes);

                foreach (var item in LstDV)
                {
                    item.montoIce          = 0;
                    item.montoIceSpecified = true;

                    #region Personalizacion de cliente Grafinpren

                    /// el cliente nos pide q enceremos el valor de la retencion de estos meses junio y julio 2016
                    if (param.IdCliente_Ven_x_Default == Cl_Enumeradores.eCliente_Vzen.GRAFINPRENT)
                    {
                        if (IdPeriodo >= 201606 && IdPeriodo <= 201611)
                        {
                            item.valorRetIva   = "0.00";
                            item.valorRetRenta = "0.00";
                        }
                    }
                    #endregion
                }



                if (LstDV.Count() > 0)
                {
                    iva.ventas = LstDV;
                }

                List <ventaEst> LstVenSum = new List <ventaEst>();
                LstVenSum = fac_B.Get_List_VentasXEstablecimientoParaATS(param.IdEmpresa, Convert.ToInt32(cmb_anio.Text), Convert.ToInt32(cmb_periodo.SelectedValue));

                foreach (var item in LstVenSum)
                {
                }
                if (LstVenSum.Count > 0)
                {
                    iva.ventasEstablecimiento = LstVenSum;
                    iva.totalVentas           = Math.Round(Math.Abs(LstVenSum.Sum(c => c.ventasEstab)), 2, MidpointRounding.AwayFromZero);
                }
                else
                {
                    iva.totalVentas = 0;
                }


                iva.totalVentasSpecified = true;

                return(iva);
            }
            catch (Exception ex)
            {
                Log_Error_bus.Log_Error(ex.ToString());
                MessageBox.Show(ex.ToString());
                return(iva);
            }
        }
Exemplo n.º 7
0
        private void btn_procesar_Click(object sender, EventArgs e)
        {
            try
            {
                splashScreenManager1.ShowWaitForm();
                progressBar1.Value = 30;

                DS_Iva_REOC_XML = new iva();

                DS_Iva_REOC_XML = CargaDatos();

                string ruta = "";
                saveFileDialog1.FileName         = "AT-" + param.InfoEmpresa.codigo + "-" + ((cmb_periodo.SelectedValue.ToString().Length < 2) ? "0" + cmb_periodo.SelectedValue.ToString() : cmb_periodo.SelectedValue.ToString()) + cmb_anio.Text + ".xml";
                saveFileDialog1.Filter           = "All files (*.xlm*)|*.xlm*";
                saveFileDialog1.InitialDirectory = @direcDoc;
                this.saveFileDialog1.ShowDialog();
                ruta = saveFileDialog1.FileName;


                if (SerializeToXML(DS_Iva_REOC_XML, ruta))
                {
                    progressBar1.Value = 100;

                    string msg = "";

                    if (validaXmlConXsd(ruta, Core.Erp.Info.Properties.Resources.ats_xsd_V_1_1_4, ref msg))
                    {
                        MessageBox.Show("Archivo ATS XML generado en la ruta:" + ruta + ", pero tiene los Siguientes errores:\n " + msg, "Errores en Validación con XSD", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else
                {
                    progressBar1.Value = 0;
                    MessageBox.Show("Ocurrio un inconveniente al guardar el archivo ATS XML", "SISTEMAS", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }



                List <Info.CuentasxPagar.xmlATS_V_1_1_4.detalleCompras> List_Compras = new List <Info.CuentasxPagar.xmlATS_V_1_1_4.detalleCompras>();

                List <Info.CuentasxPagar.xmlATS_V_1_1_4.detalleVentas> List_Ventas = new List <Info.CuentasxPagar.xmlATS_V_1_1_4.detalleVentas>();

                List_Compras = DS_Iva_REOC_XML.compras;
                List_Ventas  = DS_Iva_REOC_XML.ventas;


                List <cp_retencion_Info> listRetenciones = new List <cp_retencion_Info>();


                foreach (var item in List_Compras)
                {
                    cp_retencion_Info InfoRet = new cp_retencion_Info();


                    try
                    {
                        if (item.air != null)
                        {
                            foreach (var item_ret in item.air)
                            {
                                try
                                {
                                    InfoRet.Factura_Prov      = item.establecimiento + "-" + item.puntoEmision + "-" + item.secuencial;
                                    InfoRet.ced_ruc_proveedor = item.idProv;
                                    InfoRet.NumRetencion      = item.secRetencion1;
                                    InfoRet.fecha             = Convert.ToDateTime(item.fechaEmiRet1);

                                    InfoRet.Info_det_retencion.CodigoSRI           = item_ret.codRetAir;
                                    InfoRet.Info_det_retencion.re_baseRetencion    = Convert.ToDouble(item_ret.baseImpAir);
                                    InfoRet.Info_det_retencion.re_Porcen_retencion = Convert.ToDouble(item_ret.porcentajeAir);
                                    InfoRet.Info_det_retencion.re_valor_retencion  = Convert.ToDouble(item_ret.valRetAir);
                                    listRetenciones.Add(InfoRet);
                                }
                                catch (Exception ex)
                                {
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                    }
                }

                gridControlCompras.DataSource = List_Compras;
                gridControlRT.DataSource      = listRetenciones;
                gridControlVentas.DataSource  = List_Ventas;

                splashScreenManager1.CloseWaitForm();
            }
            catch (Exception ex)
            {
                Log_Error_bus.Log_Error(ex.ToString());
                MessageBox.Show(ex.Message);
                splashScreenManager1.CloseWaitForm();
            }
        }
Exemplo n.º 8
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;
            }
        }
Exemplo n.º 9
0
 public void GeneraFormularios(iva iva, byte[] xls, string descr)
 {
     /*
      * try
      * {
      *  refere.ServerComputer Cp = new refere.ServerComputer();
      *  string archiTem = Cp.FileSystem.SpecialDirectories.MyDocuments + @"\Formulario103_" + descr + ".xls";
      *
      *  if(Cp.FileSystem.FileExists(archiTem))
      *  {
      *      Cp.FileSystem.DeleteFile(archiTem);
      *  }
      *  FileStream fs = new FileStream(archiTem, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite);
      *  BinaryWriter bw = new BinaryWriter(fs);
      *
      *  bw.Write(xls);
      * //  bw.Close();
      *
      *
      * Excel.Application xlApp;
      * Excel.Workbook xlWorkBook;
      * Excel.Worksheet xlWorkSheet;
      * Excel.Range range;
      * var misValue = Type.Missing;
      *
      * // abrir el documento
      * xlApp = new Excel.Application();
      * xlWorkBook = xlApp.Workbooks.Open(archiTem, misValue, misValue,
      * misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue);
      *
      *
      * //**********************
      * Excel._Worksheet oSheet;
      * oSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(2);// selecciona la hoja del excel
      *
      * oSheet.Cells[10, 2] = iva.IdInformante;
      * oSheet.Cells[10, 16] = iva.razonSocial;
      *
      * if(iva.compras!=null)
      * foreach(var item in iva.compras)
      *  {
      *  if(item.air!=null)
      *          foreach(var item2 in item.air)
      *      {
      *           for(int i = 15; i < 46; i++)
      *    {
      *       String c = Convert.ToString(oSheet.Cells[i, 22].Value);
      *
      *        if(Convert.ToString(oSheet.Cells[i, 22].Value) == item2.codRetAir)
      *        {
      *            oSheet.Cells[i, 24].Value = Convert.ToDecimal(item2.valRetAir)+Convert.ToDecimal( oSheet.Cells[i, 24].Value);
      *        }
      *        else if(Convert.ToString(oSheet.Cells[i, 31].Value) == item2.codRetAir)
      *        {
      *            oSheet.Cells[i, 33].Value = Convert.ToDecimal(item2.valRetAir)+Convert.ToDecimal(oSheet.Cells[i, 33].Value);
      *        }
      *    }
      *      }
      *
      * }
      *
      * xlApp.Visible = true;
      * xlApp.UserControl = true;
      *
      * progressBar1.Value = 100;
      * MessageBox.Show("Formulario 103 generado correctamente en la ruta:" + archiTem, "SISTEMA", MessageBoxButtons.OK, MessageBoxIcon.Information);
      *
      * }
      * catch (Exception ex)
      * {
      *  Log_Error_bus.Log_Error(ex.ToString());
      *  progressBar1.Value = 0;
      *  MessageBox.Show("Error al generar el Formulario 103 " , "SISTEMA", MessageBoxButtons.OK, MessageBoxIcon.Information);
      *
      * }
      * */
 }