Esempio n. 1
0
        private RequestBatch ProcesarLoteComprobantes(FileInfo fi, Settings oSettings)
        {
            RequestBatch requestBatch = new RequestBatch();

            string filePath = fi.FullName;
            string line;

            bool bProcessOK = true;

            StreamReader fileInput = null;

            //Totales del lote
            double Importe = 0;
            double ImporteComprobanteB = 0;
            double ImporteNoGravado = 0;
            double ImporteGravado = 0;
            double ImporteImpuestoLiquidado = 0;
            double ImporteRNI_Percepcion = 0;
            double ImporteExento = 0;
            double ImportePercepciones_PagosCuentaImpuestosNacionales = 0;
            double ImportePercepcionIIBB = 0;
            double ImportePercepcionImpuestosMunicipales = 0;
            double ImporteImpuestosInternos = 0;
            double ImporteMonedaFacturacion = 0;
            double ImporteMonedaFacturacionComprobanteB = 0;
            double ImporteNoGravadoMonedaFacturacion = 0;
            double ImporteGravadoMonedaFacturacion = 0;
            double ImporteImpuestoLiquidadoMonedaFacturacion = 0;
            double ImporteRNI_PercepcionMonedaFacturacion = 0;
            double ImporteExentoMonedaFacturacion = 0;
            double ImportePercepciones_PagosCuentaImpuestosNacionalesMonedaFacturacion = 0;
            double ImportePercepcionIIBBMonedaFacturacion = 0;
            double ImportePercepcionImpuestosMunicipalesMonedaFacturacion = 0;
            double ImporteImpuestosInternosMonedaFacturacion = 0;

            int qtyComprobantes = 0;

            try
            {
                fileInput = new StreamReader(filePath, System.Text.Encoding.GetEncoding(1252));

                line = fileInput.ReadLine();
                while (line != null)
                {
                    if (line == "CABECERA")
                    {
                        line = fileInput.ReadLine();
                        if (line != null)
                        {
                            //proceso CABECERA
                            string[] camposCabecera = line.Split(';');

                            RequestHeader thisDocument = new RequestHeader();
                            if (camposCabecera[0] == "" || camposCabecera[0] == " ")
                                thisDocument.TipoTransaccion = "0";
                            else
                                thisDocument.TipoTransaccion = camposCabecera[0];

                            thisDocument.EmpresaID = oSettings.EmpresaID;
                            thisDocument.FechaComprobante = camposCabecera[1].Substring(6, 4) + "-" + camposCabecera[1].Substring(3, 2) + "-" + camposCabecera[1].Substring(0, 2);
                            thisDocument.FechaDesdeServicioFacturado = camposCabecera[2].Substring(6, 4) + "-" + camposCabecera[2].Substring(3, 2) + "-" + camposCabecera[2].Substring(0, 2); ;
                            thisDocument.FechaHastaServicioFacturado = camposCabecera[3].Substring(6, 4) + "-" + camposCabecera[3].Substring(3, 2) + "-" + camposCabecera[3].Substring(0, 2); ;
                            thisDocument.TipoComprobante = camposCabecera[4];
                            thisDocument.PuntoVenta = camposCabecera[5];
                            thisDocument.LetraComprobante = camposCabecera[6];
                            thisDocument.NroComprobanteDesde = camposCabecera[7];
                            thisDocument.NroComprobanteHasta = camposCabecera[7];
                            thisDocument.NroInternoERP = camposCabecera[8];
                            thisDocument.FechaVencimientoPago = camposCabecera[9].Substring(6, 4) + "-" + camposCabecera[9].Substring(3, 2) + "-" + camposCabecera[9].Substring(0, 2);
                            thisDocument.CondicionPago = camposCabecera[10];
                            thisDocument.CompradorCodigoDocumento = camposCabecera[11];
                            thisDocument.CompradorNroDocumento = camposCabecera[12];
                            thisDocument.CompradorTipoResponsable = camposCabecera[13];
                            thisDocument.CompradorTipoResponsableDescripcion = camposCabecera[14];
                            thisDocument.CompradorRazonSocial = camposCabecera[15];
                            thisDocument.CompradorDireccion = camposCabecera[16];
                            thisDocument.CompradorLocalidad = camposCabecera[17];
                            thisDocument.CompradorProvincia = camposCabecera[18];
                            thisDocument.CompradorPais = camposCabecera[19];
                            thisDocument.CompradorCodigoPostal = camposCabecera[20];
                            thisDocument.CompradorNroIIBB = camposCabecera[21];
                            thisDocument.CompradorCodigoCliente = camposCabecera[22];
                            thisDocument.CompradorNroReferencia = camposCabecera[23];
                            thisDocument.CompradorEmail = camposCabecera[24];
                            thisDocument.NroRemito = camposCabecera[25];
                            thisDocument.Importe = IntegrationEngine.ImporteConDecimales(camposCabecera[26], 2);
                            thisDocument.ImporteComprobanteB = IntegrationEngine.ImporteConDecimales(camposCabecera[27], 2);
                            thisDocument.ImporteNoGravado = IntegrationEngine.ImporteConDecimales(camposCabecera[28], 2);
                            thisDocument.ImporteGravado = IntegrationEngine.ImporteConDecimales(camposCabecera[29], 2);
                            thisDocument.AlicuotaIVA = IntegrationEngine.ImporteConDecimales(camposCabecera[30], 2);
                            thisDocument.ImporteImpuestoLiquidado = IntegrationEngine.ImporteConDecimales(camposCabecera[31], 2);
                            thisDocument.ImporteRNI_Percepcion = IntegrationEngine.ImporteConDecimales(camposCabecera[32], 2);
                            thisDocument.ImporteExento = IntegrationEngine.ImporteConDecimales(camposCabecera[33], 2);
                            thisDocument.ImportePercepciones_PagosCuentaImpuestosNacionales = IntegrationEngine.ImporteConDecimales(camposCabecera[34], 2);
                            thisDocument.ImportePercepcionIIBB = IntegrationEngine.ImporteConDecimales(camposCabecera[35], 2);
                            thisDocument.TasaIIBB = IntegrationEngine.ImporteConDecimales(camposCabecera[36], 2);
                            thisDocument.CodigoJurisdiccionIIBB = camposCabecera[37];
                            thisDocument.ImportePercepcionImpuestosMunicipales = IntegrationEngine.ImporteConDecimales(camposCabecera[38], 2);
                            thisDocument.JurisdiccionImpuestosMunicipales = camposCabecera[39];
                            thisDocument.ImporteImpuestosInternos = IntegrationEngine.ImporteConDecimales(camposCabecera[40], 2);
                            thisDocument.ImporteMonedaFacturacion = IntegrationEngine.ImporteConDecimales(camposCabecera[41], 2);
                            thisDocument.ImporteMonedaFacturacionComprobanteB = IntegrationEngine.ImporteConDecimales(camposCabecera[42], 2);
                            thisDocument.ImporteNoGravadoMonedaFacturacion = IntegrationEngine.ImporteConDecimales(camposCabecera[43], 2);
                            thisDocument.ImporteGravadoMonedaFacturacion = IntegrationEngine.ImporteConDecimales(camposCabecera[44], 2);
                            thisDocument.ImporteImpuestoLiquidadoMonedaFacturacion = IntegrationEngine.ImporteConDecimales(camposCabecera[45], 2);
                            thisDocument.ImporteRNI_PercepcionMonedaFacturacion = IntegrationEngine.ImporteConDecimales(camposCabecera[46], 2);
                            thisDocument.ImporteExentoMonedaFacturacion = IntegrationEngine.ImporteConDecimales(camposCabecera[47], 2);
                            thisDocument.ImportePercepciones_PagosCuentaImpuestosNacionalesMonedaFacturacion = IntegrationEngine.ImporteConDecimales(camposCabecera[48], 2);
                            thisDocument.ImportePercepcionIIBBMonedaFacturacion = IntegrationEngine.ImporteConDecimales(camposCabecera[49], 2);
                            thisDocument.ImportePercepcionImpuestosMunicipalesMonedaFacturacion = IntegrationEngine.ImporteConDecimales(camposCabecera[50], 2);
                            thisDocument.ImporteImpuestosInternosMonedaFacturacion = IntegrationEngine.ImporteConDecimales(camposCabecera[51], 2);
                            thisDocument.CantidadAlicuotasIVA = camposCabecera[52];
                            thisDocument.CodigoOperacion = camposCabecera[53];
                            thisDocument.TasaCambio = IntegrationEngine.ImporteConDecimales(camposCabecera[54], 5);
                            thisDocument.CodigoMoneda = camposCabecera[55];
                            thisDocument.ImporteEscrito = camposCabecera[56];
                            thisDocument.CantidadRegistrosDetalle = camposCabecera[57];
                            thisDocument.CodigoMecanismoDistribucion = camposCabecera[58];
                            thisDocument.TipoExportacion = camposCabecera[59];
                            thisDocument.PermisoExistente = camposCabecera[60];
                            thisDocument.CompradorPais = camposCabecera[61];
                            thisDocument.FormaPagoDescripcion = camposCabecera[63];
                            thisDocument.IncoTerms = camposCabecera[64];
                            thisDocument.Idioma = camposCabecera[65];
                            thisDocument.Observaciones1 = camposCabecera[66];
                            thisDocument.Observaciones2 = camposCabecera[67];
                            thisDocument.Observaciones3 = camposCabecera[68];
                            thisDocument.EmisorDireccion = camposCabecera[69];
                            thisDocument.EmisorCalle = camposCabecera[70];
                            thisDocument.EmisorCP = camposCabecera[71];
                            thisDocument.EmisorLocalidad = camposCabecera[72];
                            thisDocument.EmisorProvincia = camposCabecera[73];
                            thisDocument.EmisorPais = camposCabecera[74];
                            thisDocument.EmisorTelefonos = camposCabecera[75];
                            thisDocument.EmisorEMail = camposCabecera[76];
                            thisDocument.OficinaVentas = camposCabecera[77];

                            //Actualizar los importes del lote
                            Importe += Utils.Utils.DoubleFromString(thisDocument.Importe);
                            ImporteComprobanteB += Utils.Utils.DoubleFromString(thisDocument.ImporteComprobanteB);
                            ImporteNoGravado += Utils.Utils.DoubleFromString(thisDocument.ImporteNoGravado);
                            ImporteGravado += Utils.Utils.DoubleFromString(thisDocument.ImporteGravado);
                            ImporteImpuestoLiquidado += Utils.Utils.DoubleFromString(thisDocument.ImporteImpuestoLiquidado);
                            ImporteRNI_Percepcion += Utils.Utils.DoubleFromString(thisDocument.ImporteRNI_Percepcion);
                            ImporteExento += Utils.Utils.DoubleFromString(thisDocument.ImporteExento);
                            ImportePercepciones_PagosCuentaImpuestosNacionales += Utils.Utils.DoubleFromString(thisDocument.ImportePercepciones_PagosCuentaImpuestosNacionales);
                            ImportePercepcionIIBB += Utils.Utils.DoubleFromString(thisDocument.ImportePercepcionIIBB);
                            ImportePercepcionImpuestosMunicipales += Utils.Utils.DoubleFromString(thisDocument.ImportePercepcionImpuestosMunicipales);
                            ImporteImpuestosInternos += Utils.Utils.DoubleFromString(thisDocument.ImporteImpuestosInternos);
                            ImporteMonedaFacturacion += Utils.Utils.DoubleFromString(thisDocument.ImporteMonedaFacturacion);
                            ImporteMonedaFacturacionComprobanteB += Utils.Utils.DoubleFromString(thisDocument.ImporteMonedaFacturacionComprobanteB);
                            ImporteNoGravadoMonedaFacturacion += Utils.Utils.DoubleFromString(thisDocument.ImporteNoGravadoMonedaFacturacion);
                            ImporteGravadoMonedaFacturacion += Utils.Utils.DoubleFromString(thisDocument.ImporteGravadoMonedaFacturacion);
                            ImporteImpuestoLiquidadoMonedaFacturacion += Utils.Utils.DoubleFromString(thisDocument.ImporteImpuestoLiquidadoMonedaFacturacion);
                            ImporteRNI_PercepcionMonedaFacturacion += Utils.Utils.DoubleFromString(thisDocument.ImporteRNI_PercepcionMonedaFacturacion);
                            ImporteExentoMonedaFacturacion += Utils.Utils.DoubleFromString(thisDocument.ImporteExentoMonedaFacturacion);
                            ImportePercepciones_PagosCuentaImpuestosNacionalesMonedaFacturacion += Utils.Utils.DoubleFromString(thisDocument.ImportePercepciones_PagosCuentaImpuestosNacionalesMonedaFacturacion);
                            ImportePercepcionIIBBMonedaFacturacion += Utils.Utils.DoubleFromString(thisDocument.ImportePercepcionIIBBMonedaFacturacion);
                            ImportePercepcionImpuestosMunicipalesMonedaFacturacion += Utils.Utils.DoubleFromString(thisDocument.ImportePercepcionImpuestosMunicipalesMonedaFacturacion);
                            ImporteImpuestosInternosMonedaFacturacion += Utils.Utils.DoubleFromString(thisDocument.ImporteImpuestosInternosMonedaFacturacion);

                            line = fileInput.ReadLine();
                            if (line != null && line == "DETALLE")
                            {
                                //proceso el detalle
                                RequestLine thisLine = new RequestLine();

                                line = fileInput.ReadLine();
                                if (line != null)
                                {
                                    while (line != null && line != "CABECERA")
                                    {
                                        thisLine = new RequestLine();
                                        string[] camposDetalle = line.Split(';');

                                        if (camposDetalle.Length > 10)
                                        {
                                            thisLine.CodigoProductoEmpresa = camposDetalle[0];
                                            while (thisLine.CodigoProductoEmpresa.Substring(0, 1) == "0")
                                            {
                                                thisLine.CodigoProductoEmpresa = thisLine.CodigoProductoEmpresa.Substring(1, thisLine.CodigoProductoEmpresa.Length - 1);
                                            }
                                            thisLine.CodigoProductoNCM = camposDetalle[1]; // RUTINA PARA OBTENERLO
                                            thisLine.CodigoProductoSecretaria = camposDetalle[2];
                                            thisLine.Descripcion = camposDetalle[3];
                                            thisLine.Cantidad = IntegrationEngine.ImporteConDecimales(camposDetalle[4], 3);
                                            thisLine.UnidadMedida = camposDetalle[5];
                                            thisLine.ImportePrecioUnitario = IntegrationEngine.ImporteConDecimales(camposDetalle[6], 2);
                                            thisLine.ImporteBonificacion = IntegrationEngine.ImporteConDecimales(camposDetalle[7], 2);
                                            thisLine.ImporteAjuste = IntegrationEngine.ImporteConDecimales(camposDetalle[8], 2);
                                            thisLine.ImporteSubtotal = IntegrationEngine.ImporteConDecimales(camposDetalle[9], 2);
                                            thisLine.ImportePrecioUnitarioMonedaFacturacion = IntegrationEngine.ImporteConDecimales(camposDetalle[10], 2);
                                            thisLine.ImporteBonificacionMonedaFacturacion = IntegrationEngine.ImporteConDecimales(camposDetalle[11], 2);
                                            thisLine.ImporteAjusteMonedaFacturacion = IntegrationEngine.ImporteConDecimales(camposDetalle[12], 2);
                                            thisLine.ImporteSubtotalMonedaFacturacion = IntegrationEngine.ImporteConDecimales(camposDetalle[13], 2);
                                            thisLine.ImporteSubtotalMonedaFacturacionConIVA = IntegrationEngine.ImporteConDecimales(camposDetalle[14], 2);
                                            thisLine.AlicuotaIVA = IntegrationEngine.ImporteConDecimales(camposDetalle[15], 2);
                                            thisLine.IndicadorExentoGravadoNoGravado = camposDetalle[16];
                                            thisLine.Observaciones = camposDetalle[17];
                                            //thisLine.MesPrestacion = camposDetalle[17];

                                            thisDocument.RequestLines.Add(thisLine);
                                        }
                                        line = fileInput.ReadLine();
                                    }
                                    requestBatch.RequestHeaders.Add(thisDocument);
                                    qtyComprobantes++;
                                }
                                else
                                {
                                    //error: el detalle está vacío
                                    sqlEngine.LogError("0", "0", "Leyendo archivo", "El archivo " + fi.Name + " no responde al formato esperado. El detalle está vacío.");
                                    bProcessOK = false;
                                }
                            }
                            else
                            {
                                //error: luego de la cabecera se espera el detalle
                                sqlEngine.LogError("0", "0", "Leyendo archivo", "El archivo " + fi.Name + " no responde al formato esperado. Luego de la cabecera debe venir el detalle.");
                                bProcessOK = false;
                            }
                        }
                        else
                        {
                            //error: la cabecera está vacía
                            sqlEngine.LogError("0", "0", "Leyendo archivo", "El archivo " + fi.Name + " no responde al formato esperado. La cabecera está vacía.");
                            bProcessOK = false;
                        }
                    }
                    else
                    {
                        //error
                        sqlEngine.LogError("0", "0", "Leyendo archivo", "El archivo " + fi.Name + " no responde al formato esperado. Debe comenzar con una cabecera.");
                        bProcessOK = false;
                    }
                }

                if (bProcessOK)
                {
                    requestBatch.CantidadComprobantes = qtyComprobantes.ToString();
                    requestBatch.Total = IntegrationEngine.ChangeDecimalPointToPoint(String.Format("{0:0.00}", Importe));
                    requestBatch.TotalComprobanteB = IntegrationEngine.ChangeDecimalPointToPoint(String.Format("{0:0.00}", ImporteComprobanteB));
                    requestBatch.TotalExento = IntegrationEngine.ChangeDecimalPointToPoint(String.Format("{0:0.00}", ImporteExento));
                    requestBatch.TotalExentoMonedaFacturacion = IntegrationEngine.ChangeDecimalPointToPoint(String.Format("{0:0.00}", ImporteExentoMonedaFacturacion));
                    requestBatch.TotalGravado = IntegrationEngine.ChangeDecimalPointToPoint(String.Format("{0:0.00}", ImporteGravado));
                    requestBatch.TotalGravadoMonedaFacturacion = IntegrationEngine.ChangeDecimalPointToPoint(String.Format("{0:0.00}", ImporteGravadoMonedaFacturacion));
                    requestBatch.TotalImpuestoLiquidado = IntegrationEngine.ChangeDecimalPointToPoint(String.Format("{0:0.00}", ImporteImpuestoLiquidado));
                    requestBatch.TotalImpuestoLiquidadoMonedaFacturacion = IntegrationEngine.ChangeDecimalPointToPoint(String.Format("{0:0.00}", ImporteImpuestoLiquidadoMonedaFacturacion));
                    requestBatch.TotalImpuestosInternos = IntegrationEngine.ChangeDecimalPointToPoint(String.Format("{0:0.00}", ImporteImpuestosInternos));
                    requestBatch.TotalImpuestosInternosMonedaFacturacion = IntegrationEngine.ChangeDecimalPointToPoint(String.Format("{0:0.00}", ImporteImpuestosInternosMonedaFacturacion));
                    requestBatch.TotalMonedaFacturacion = IntegrationEngine.ChangeDecimalPointToPoint(String.Format("{0:0.00}", ImporteMonedaFacturacion));
                    requestBatch.TotalMonedaFacturacionComprobanteB = IntegrationEngine.ChangeDecimalPointToPoint(String.Format("{0:0.00}", ImporteMonedaFacturacionComprobanteB));
                    requestBatch.TotalNoGravado = IntegrationEngine.ChangeDecimalPointToPoint(String.Format("{0:0.00}", ImporteNoGravado));
                    requestBatch.TotalNoGravadoMonedaFacturacion = IntegrationEngine.ChangeDecimalPointToPoint(String.Format("{0:0.00}", ImporteNoGravadoMonedaFacturacion));
                    requestBatch.TotalPercepciones_PagosCuentaImpuestosNacionales = IntegrationEngine.ChangeDecimalPointToPoint(String.Format("{0:0.00}", ImportePercepciones_PagosCuentaImpuestosNacionales));
                    requestBatch.TotalPercepciones_PagosCuentaImpuestosNacionalesMonedaFacturacion = IntegrationEngine.ChangeDecimalPointToPoint(String.Format("{0:0.00}", ImportePercepciones_PagosCuentaImpuestosNacionalesMonedaFacturacion));
                    requestBatch.TotalPercepcionIIBB = IntegrationEngine.ChangeDecimalPointToPoint(String.Format("{0:0.00}", ImportePercepcionIIBB));
                    requestBatch.TotalPercepcionIIBBMonedaFacturacion = IntegrationEngine.ChangeDecimalPointToPoint(String.Format("{0:0.00}", ImportePercepcionIIBBMonedaFacturacion));
                    requestBatch.TotalPercepcionImpuestosMunicipales = IntegrationEngine.ChangeDecimalPointToPoint(String.Format("{0:0.00}", ImportePercepcionImpuestosMunicipales));
                    requestBatch.TotalPercepcionImpuestosMunicipalesMonedaFacturacion = IntegrationEngine.ChangeDecimalPointToPoint(String.Format("{0:0.00}", ImportePercepcionImpuestosMunicipalesMonedaFacturacion));
                    requestBatch.TotalRNI_Percepcion = IntegrationEngine.ChangeDecimalPointToPoint(String.Format("{0:0.00}", ImporteRNI_Percepcion));
                    requestBatch.TotalRNI_PercepcionMonedaFacturacion = IntegrationEngine.ChangeDecimalPointToPoint(String.Format("{0:0.00}", ImporteRNI_PercepcionMonedaFacturacion));

                    //TODO: Lote automático donde configurarlo?
                    requestBatch.BatchUniqueId = "AUTO";

                    fileInput.Close();
                }
            }
            catch(Exception ex)
            {
                sqlEngine.LogError("0", "0", "Leyendo archivo", ex.Message);
            }

            return requestBatch;
        }
Esempio n. 2
0
        public bool LoadXMLStringNo(string xmlString)
        {
            try
            {
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.LoadXml(xmlString);

                BatchUniqueId = ValidXMLValue(xmlDoc, "/RequestBatch/BatchUniqueId");
                SonServicios = ValidXMLValue(xmlDoc, "/RequestBatch/SonServicios");
                Periodo = ValidXMLValue(xmlDoc, "/RequestBatch/Periodo");
                CantidadComprobantes = ValidXMLValue(xmlDoc, "/RequestBatch/CantidadComprobantes");
                CUITInformante = ValidXMLValue(xmlDoc, "/RequestBatch/CUITInformante");
                Total = ValidXMLValue(xmlDoc, "/RequestBatch/Total");
                TotalComprobanteB = ValidXMLValue(xmlDoc, "/RequestBatch/TotalComprobanteB");
                TotalNoGravado = ValidXMLValue(xmlDoc, "/RequestBatch/TotalNoGravado");
                TotalGravado = ValidXMLValue(xmlDoc, "/RequestBatch/TotalGravado");
                TotalImpuestoLiquidado = ValidXMLValue(xmlDoc, "/RequestBatch/TotalImpuestoLiquidado");
                TotalRNI_Percepcion = ValidXMLValue(xmlDoc, "/RequestBatch/TotalRNI_Percepcion");
                TotalExento = ValidXMLValue(xmlDoc, "/RequestBatch/TotalExento");
                TotalPercepciones_PagosCuentaImpuestosNacionales = ValidXMLValue(xmlDoc, "/RequestBatch/TotalPercepciones_PagosCuentaImpuestosNacionales");
                TotalPercepcionIIBB = ValidXMLValue(xmlDoc, "/RequestBatch/TotalPercepcionIIBB");
                TotalPercepcionImpuestosMunicipales = ValidXMLValue(xmlDoc, "/RequestBatch/TotalPercepcionImpuestosMunicipales");
                TotalImpuestosInternos = ValidXMLValue(xmlDoc, "/RequestBatch/TotalImpuestosInternos");
                TotalMonedaFacturacion = ValidXMLValue(xmlDoc, "/RequestBatch/TotalMonedaFacturacion");
                TotalMonedaFacturacionComprobanteB = ValidXMLValue(xmlDoc, "/RequestBatch/TotalMonedaFacturacionComprobanteB");
                TotalNoGravadoMonedaFacturacion = ValidXMLValue(xmlDoc, "/RequestBatch/TotalNoGravadoMonedaFacturacion");
                TotalGravadoMonedaFacturacion = ValidXMLValue(xmlDoc, "/RequestBatch/TotalGravadoMonedaFacturacion");
                TotalImpuestoLiquidadoMonedaFacturacion = ValidXMLValue(xmlDoc, "/RequestBatch/TotalImpuestoLiquidadoMonedaFacturacion");
                TotalRNI_PercepcionMonedaFacturacion = ValidXMLValue(xmlDoc, "/RequestBatch/TotalRNI_PercepcionMonedaFacturacion");
                TotalExentoMonedaFacturacion = ValidXMLValue(xmlDoc, "/RequestBatch/TotalExentoMonedaFacturacion");
                TotalPercepciones_PagosCuentaImpuestosNacionalesMonedaFacturacion = ValidXMLValue(xmlDoc, "/RequestBatch/TotalPercepciones_PagosCuentaImpuestosNacionalesMonedaFacturacion");
                TotalPercepcionIIBBMonedaFacturacion = ValidXMLValue(xmlDoc, "/RequestBatch/TotalPercepcionIIBBMonedaFacturacion");
                TotalPercepcionImpuestosMunicipalesMonedaFacturacion = ValidXMLValue(xmlDoc, "/RequestBatch/TotalPercepcionImpuestosMunicipalesMonedaFacturacion");
                TotalImpuestosInternosMonedaFacturacion = ValidXMLValue(xmlDoc, "/RequestBatch/TotalImpuestosInternosMonedaFacturacion");

                //Agrego todos los comprobantes
                for (int i = 0; i < xmlDoc.SelectNodes("/RequestBatch/Comprobante").Count; i++)
                {
                    RequestHeader thisHeader = new RequestHeader();
                    thisHeader.AlicuotaIVA = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "AlicuotaIVA", i);
                    thisHeader.CantidadAlicuotasIVA = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "CantidadAlicuotasIVA", i);
                    thisHeader.CantidadRegistrosDetalle = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "CantidadRegistrosDetalle", i);
                    thisHeader.CompradorCodigoCliente = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "CompradorCodigoCliente", i);
                    thisHeader.CompradorCodigoDocumento = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "CompradorCodigoDocumento", i);
                    thisHeader.CodigoJurisdiccionIIBB = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "CodigoJurisdiccionIIBB", i);
                    thisHeader.LetraComprobante = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "LetraComprobante", i);
                    thisHeader.CodigoMecanismoDistribucion = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "CodigoMecanismoDistribucion", i);
                    thisHeader.CodigoMoneda = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "CodigoMoneda", i);
                    thisHeader.CodigoOperacion = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "CodigoOperacion", i);
                    thisHeader.CompradorCodigoPostal = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "CompradorCodigoPostal", i);
                    thisHeader.CondicionPago = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "CondicionPago", i);
                    thisHeader.CompradorDireccion = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "CompradorDireccion", i);
                    thisHeader.CompradorEmail = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "CompradorEmail", i);
                    thisHeader.FechaComprobante = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "FechaComprobante", i);
                    thisHeader.FechaDesdeServicioFacturado = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "FechaDesdeServicioFacturado", i);
                    thisHeader.FechaHastaServicioFacturado = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "FechaHastaServicioFacturado", i);
                    thisHeader.FechaVencimientoPago = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "FechaVencimientoPago", i);
                    thisHeader.FormaPagoDescripcion = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "FormaPagoDescripcion", i);
                    thisHeader.Idioma = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "Idioma", i);
                    thisHeader.Importe = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "Importe", i);
                    thisHeader.ImporteComprobanteB = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "ImporteComprobanteB", i);
                    thisHeader.ImporteEscrito = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "ImporteEscrito", i);
                    thisHeader.ImporteExento = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "ImporteExento", i);
                    thisHeader.ImporteExentoMonedaFacturacion = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "ImporteExentoMonedaFacturacion", i);
                    thisHeader.ImporteGravado = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "ImporteGravado", i);
                    thisHeader.ImporteGravadoMonedaFacturacion = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "ImporteGravadoMonedaFacturacion", i);
                    thisHeader.ImporteImpuestoLiquidado = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "ImporteImpuestoLiquidado", i);
                    thisHeader.ImporteImpuestoLiquidadoMonedaFacturacion = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "ImporteImpuestoLiquidadoMonedaFacturacion", i);
                    thisHeader.ImporteImpuestosInternos = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "ImporteImpuestosInternos", i);
                    thisHeader.ImporteImpuestosInternosMonedaFacturacion = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "ImporteImpuestosInternosMonedaFacturacion", i);
                    thisHeader.ImporteMonedaFacturacion = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "ImporteMonedaFacturacion", i);
                    thisHeader.ImporteMonedaFacturacionComprobanteB = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "ImporteMonedaFacturacionComprobanteB", i);
                    thisHeader.ImporteNoGravado = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "ImporteNoGravado", i);
                    thisHeader.ImporteNoGravadoMonedaFacturacion = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "ImporteNoGravadoMonedaFacturacion", i);
                    thisHeader.ImportePercepciones_PagosCuentaImpuestosNacionales = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "ImportePercepciones_PagosCuentaImpuestosNacionales", i);
                    thisHeader.ImportePercepciones_PagosCuentaImpuestosNacionalesMonedaFacturacion = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "ImportePercepciones_PagosCuentaImpuestosNacionalesMonedaFacturacion", i);
                    thisHeader.ImportePercepcionImpuestosMunicipales = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "ImportePercepcionImpuestosMunicipales", i);
                    thisHeader.ImportePercepcionImpuestosMunicipalesMonedaFacturacion = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "ImportePercepcionImpuestosMunicipalesMonedaFacturacion", i);
                    thisHeader.ImportePercepcionIIBB = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "ImportePercepcionIIBB", i);
                    thisHeader.ImportePercepcionIIBBMonedaFacturacion = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "ImportePercepcionIIBBMonedaFacturacion", i);
                    thisHeader.ImporteRNI_Percepcion = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "ImporteRNI_Percepcion", i);
                    thisHeader.ImporteRNI_PercepcionMonedaFacturacion = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "ImporteRNI_PercepcionMonedaFacturacion", i);
                    thisHeader.IncoTerms = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "IncoTerms", i);
                    thisHeader.JurisdiccionImpuestosMunicipales = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "JurisdiccionImpuestosMunicipales", i);
                    thisHeader.CompradorLocalidad = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "CompradorLocalidad", i);
                    thisHeader.NroComprobanteDesde = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "NroComprobanteDesde", i);
                    thisHeader.NroComprobanteHasta = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "NroComprobanteHasta", i);
                    thisHeader.CompradorNroDocumento = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "CompradorNroDocumento", i);
                    thisHeader.CompradorNroIIBB = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "CompradorNroIIBB", i);
                    thisHeader.CompradorNroReferencia = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "CompradorNroReferencia", i);
                    thisHeader.NroRemito = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "NroRemito", i);
                    thisHeader.Observaciones1 = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "Observaciones1", i);
                    thisHeader.Observaciones2 = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "Observaciones2", i);
                    thisHeader.Observaciones3 = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "Observaciones3", i);
                    thisHeader.CompradorPais = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "CompradorPais", i);
                    thisHeader.PermisoExistente = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "PermisoExistente", i);
                    thisHeader.CompradorProvincia = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "CompradorProvincia", i);
                    thisHeader.PuntoVenta = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "PuntoVenta", i);
                    thisHeader.CompradorRazonSocial = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "CompradorRazonSocial", i);
                    thisHeader.TasaCambio = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "TasaCambio", i);
                    thisHeader.TasaIIBB = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "TasaIIBB", i);
                    thisHeader.TipoComprobante = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "TipoComprobante", i);
                    thisHeader.TipoExportacion = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "TipoExportacion", i);
                    thisHeader.CompradorTipoResponsable = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "CompradorTipoResponsable", i);
                    thisHeader.CompradorTipoResponsableDescripcion = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "CompradorTipoResponsableDescripcion", i);
                    thisHeader.TipoTransaccion = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "TipoTransaccion", i);
                    thisHeader.NroInternoERP = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "NroInternoERP", i);
                    thisHeader.EmisorDireccion = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "EmisorDireccion", i);
                    thisHeader.EmisorCalle = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "EmisorCalle", i);
                    thisHeader.EmisorCP = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "EmisorCP", i);
                    thisHeader.EmisorLocalidad = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "EmisorLocalidad", i);
                    thisHeader.EmisorProvincia = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "EmisorProvincia", i);
                    thisHeader.EmisorPais = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "EmisorPais", i);
                    thisHeader.EmisorTelefonos = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "EmisorTelefonos", i);
                    thisHeader.EmisorEMail = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "EmisorEMail", i);
                    thisHeader.OficinaVentas = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "OficinaVentas", i);
                    thisHeader.EmpresaID = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "EmpresaID", i);
                    thisHeader.SQLID = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "SQLID", i);
                    thisHeader.PagoFacil = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "PagoFacil", i);
                    thisHeader.RapiPago = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "RapiPago", i);
                    thisHeader.ObservacionRapiPago = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "ObservacionRapiPago", i);
                    thisHeader.OPER = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "OPER", i);
                    thisHeader.NOPER = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "NOPER", i);
                    thisHeader.DAGRUF = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "DAGRUF", i);
                    thisHeader.FACTORI = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "FACTORI", i);
                    thisHeader.FACTORI_FORMATEADO = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "FACTORI_FORMATEADO", i);
                    thisHeader.USUARIO = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "USUARIO", i);
                    thisHeader.FECPG1_FORMATEADO = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "FECPG1_FORMATEADO", i);
                    thisHeader.FECPG2_FORMATEADO = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "FECPG2_FORMATEADO", i);
                    //thisHeader.CUOTAIVA105 = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "CUOTAIVA105", i);
                    //thisHeader.CUOTAIVA21 = ValidXMLValue(xmlDoc, "/RequestBatch/Comprobante", "CUOTAIVA21", i);

                    RequestHeaders.Add(thisHeader);

                    XmlDocument xmlLines = new XmlDocument();
                    xmlLines.LoadXml(xmlDoc.SelectNodes("/LoteComprobantes/Comprobante")[i].OuterXml);

                    //Agrego todas las líneas
                    for (int j = 0; j < xmlLines.SelectNodes("/Comprobante/Linea").Count; j++)
                    {
                        RequestLine thisLine = new RequestLine();

                        thisLine.AlicuotaIVA = ValidXMLValue(xmlLines, "/Comprobante/Linea", "AlicuotaIVA", j);
                        thisLine.Cantidad = ValidXMLValue(xmlLines, "/Comprobante/Linea", "Cantidad", j);
                        thisLine.CodigoProductoEmpresa = ValidXMLValue(xmlLines, "/Comprobante/Linea", "CodigoProductoEmpresa", j);
                        thisLine.CodigoProductoNCM = ValidXMLValue(xmlLines, "/Comprobante/Linea", "CodigoProductoNCM", j);
                        thisLine.CodigoProductoSecretaria = ValidXMLValue(xmlLines, "/Comprobante/Linea", "CodigoProductoSecretaria", j);
                        thisLine.Descripcion = ValidXMLValue(xmlLines, "/Comprobante/Linea", "Descripcion", j);
                        thisLine.ImporteAjuste = ValidXMLValue(xmlLines, "/Comprobante/Linea", "ImporteAjuste", j);
                        thisLine.ImporteAjusteMonedaFacturacion = ValidXMLValue(xmlLines, "/Comprobante/Linea", "ImporteAjusteMonedaFacturacion", j);
                        thisLine.ImporteBonificacion = ValidXMLValue(xmlLines, "/Comprobante/Linea", "ImporteBonificacion", j);
                        thisLine.ImporteBonificacionMonedaFacturacion = ValidXMLValue(xmlLines, "/Comprobante/Linea", "ImporteBonificacionMonedaFacturacion", j);
                        thisLine.ImportePrecioUnitario = ValidXMLValue(xmlLines, "/Comprobante/Linea", "ImportePrecioUnitario", j);
                        thisLine.ImportePrecioUnitarioMonedaFacturacion = ValidXMLValue(xmlLines, "/Comprobante/Linea", "ImportePrecioUnitarioMonedaFacturacion", j);
                        thisLine.ImporteSubtotal = ValidXMLValue(xmlLines, "/Comprobante/Linea", "ImporteSubtotal", j);
                        thisLine.ImporteSubtotalMonedaFacturacion = ValidXMLValue(xmlLines, "/Comprobante/Linea", "ImporteSubtotalMonedaFacturacion", j);
                        thisLine.ImporteSubtotalMonedaFacturacionConIVA = ValidXMLValue(xmlLines, "/Comprobante/Linea", "ImporteSubtotalMonedaFacturacionConIVA", j);
                        thisLine.IndicadorExentoGravadoNoGravado = ValidXMLValue(xmlLines, "/Comprobante/Linea", "IndicadorExentoGravadoNoGravado", j);
                        thisLine.Observaciones = ValidXMLValue(xmlLines, "/Comprobante/Linea", "Observaciones", j);
                        thisLine.MesPrestacion = ""; //ValidXMLValue(xmlLines, "/Comprobante/Linea", "MesPrestacion", j);
                        thisLine.UnidadMedida = ValidXMLValue(xmlLines, "/Comprobante/Linea", "UnidadMedida", j);
                        thisLine.SQLID = ValidXMLValue(xmlLines, "/Comprobante/Linea", "SQLID", j);

                        thisHeader.RequestLines.Add(thisLine);
                    }

                    //Agrego todas las alicuotas
                    for (int j = 0; j < xmlLines.SelectNodes("/Comprobante/Alicuota").Count; j++)
                    {
                        RequestAlicuota thisTAlicuota = new RequestAlicuota();

                        thisTAlicuota.Id = ValidXMLValue(xmlLines, "/Comprobante/Alicuota", "Id", j);
                        thisTAlicuota.Descripcion = ValidXMLValue(xmlLines, "/Comprobante/Alicuota", "Descripcion", j);
                        thisTAlicuota.Importe = ValidXMLValue(xmlLines, "/Comprobante/Alicuota", "Importe", j);
                        thisTAlicuota.BaseImp = ValidXMLValue(xmlLines, "/Comprobante/Alicuota", "BaseImp", j);
                        thisTAlicuota.Tipo = ValidXMLValue(xmlLines, "/Comprobante/Alicuota", "Tipo", j);
                        thisTAlicuota.Codigo = ValidXMLValue(xmlLines, "/Comprobante/Alicuota", "Codigo", j);
                        thisTAlicuota.CbteID = thisHeader.SQLID;

                        thisHeader.RequestAlicuotas.Add(thisTAlicuota);
                    }

                    //Agrego todos los tributos
                    for (int j = 0; j < xmlLines.SelectNodes("/Comprobante/Tributo").Count; j++)
                    {
                        RequestTributo thisTributo = new RequestTributo();

                        thisTributo.Id = ValidXMLValue(xmlLines, "/Comprobante/Tributo", "Id", j);
                        thisTributo.Descripcion = ValidXMLValue(xmlLines, "/Comprobante/Tributo", "Descripcion", j);
                        thisTributo.Importe = ValidXMLValue(xmlLines, "/Comprobante/Tributo", "Importe", j);
                        thisTributo.BaseImp = ValidXMLValue(xmlLines, "/Comprobante/Tributo", "BaseImp", j);
                        thisTributo.Tipo = ValidXMLValue(xmlLines, "/Comprobante/Tributo", "Tipo", j);
                        thisTributo.Codigo = ValidXMLValue(xmlLines, "/Comprobante/Tributo", "Codigo", j);
                        thisTributo.Alic = ValidXMLValue(xmlLines, "/Comprobante/Tributo", "Alic", j);

                        thisTributo.CbteID = thisHeader.SQLID;

                        thisHeader.RequestTributos.Add(thisTributo);
                    }
                }
            }
            catch(Exception ex)
            {
                string msg = ex.Message;
                return false;
            }

            return true;
        }
Esempio n. 3
0
        public RequestBatch ProcessData(DataRow drCabecera, DataTable dtLineas, DataTable dtImpuestos, Settings oSettings)
        {
            RequestBatch requestBatch = new RequestBatch();
            RequestLine thisLine = new RequestLine();
            RequestAlicuota requestAlicuota = new RequestAlicuota();
            RequestTributo requestTributo = new RequestTributo();

            //Totales del lote
            double Importe = 0;
            double ImporteComprobanteB = 0;
            double ImporteNoGravado = 0;
            double ImporteGravado = 0;
            double ImporteImpuestoLiquidado = 0;
            double ImporteRNI_Percepcion = 0;
            double ImporteExento = 0;
            double ImportePercepciones_PagosCuentaImpuestosNacionales = 0;
            double ImportePercepcionIIBB = 0;
            double ImportePercepcionImpuestosMunicipales = 0;
            double ImporteImpuestosInternos = 0;
            double ImporteMonedaFacturacion = 0;
            double ImporteMonedaFacturacionComprobanteB = 0;
            double ImporteNoGravadoMonedaFacturacion = 0;
            double ImporteGravadoMonedaFacturacion = 0;
            double ImporteImpuestoLiquidadoMonedaFacturacion = 0;
            double ImporteRNI_PercepcionMonedaFacturacion = 0;
            double ImporteExentoMonedaFacturacion = 0;
            double ImportePercepciones_PagosCuentaImpuestosNacionalesMonedaFacturacion = 0;
            double ImportePercepcionIIBBMonedaFacturacion = 0;
            double ImportePercepcionImpuestosMunicipalesMonedaFacturacion = 0;
            double ImporteImpuestosInternosMonedaFacturacion = 0;

            int qtyComprobantes = 0;

            try
            {
                if(drCabecera != null)
                {
                    //DEBUG LINE
                    if (Convert.ToBoolean(oSettings.ActivarDebug))
                        drCabecera.Table.WriteXml(oSettings.PathDebug + "\\" + GetDataRowString(drCabecera["NROCOMPROBANTE"]) + "-Cabecera-" + DateTime.Now.Hour.ToString("00") + DateTime.Now.Minute.ToString("00") + DateTime.Now.Second.ToString("00") + DateTime.Now.Millisecond.ToString("000") + ".xml");

                    //DEBUG LINE
                    if (Convert.ToBoolean(oSettings.ActivarDebug))
                        dtLineas.WriteXml(oSettings.PathDebug + "\\" + GetDataRowString(drCabecera["NROCOMPROBANTE"]) + "-Lineas-" + DateTime.Now.Hour.ToString("00") + DateTime.Now.Minute.ToString("00") + DateTime.Now.Second.ToString("00") + DateTime.Now.Millisecond.ToString("000") + ".xml");

                    RequestHeader thisDocument = new RequestHeader();

                    thisDocument.SQLID = string.Empty;
                    thisDocument.EmpresaID = oSettings.EmpresaID;
                    thisDocument.TipoTransaccion = GetDataRowString(drCabecera["TIPOTRANSACCION"]);
                    thisDocument.FechaComprobante = GetDataRowString(drCabecera["FECHACOMPROBANTE"]);
                    thisDocument.FechaDesdeServicioFacturado = GetDataRowString(drCabecera["FECHACOMPROBANTE"]);
                    thisDocument.FechaHastaServicioFacturado = GetDataRowString(drCabecera["FECHACOMPROBANTE"]);
                    thisDocument.TipoComprobante = GetDataRowString(drCabecera["TIPOCOMPROBANTE"]);
                    thisDocument.PuntoVenta = GetDataRowString(drCabecera["PUNTOVENTA"]);
                    thisDocument.LetraComprobante = GetDataRowString(drCabecera["LETRACOMPROBANTE"]);
                    thisDocument.NroComprobanteDesde = GetDataRowString(drCabecera["NROCOMPROBANTE"]);
                    thisDocument.NroComprobanteHasta = GetDataRowString(drCabecera["NROCOMPROBANTE"]);
                    thisDocument.NroInternoERP = GetDataRowString(drCabecera["IDREGISTROCABECERA"]);
                    thisDocument.FechaVencimientoPago = GetDataRowString(drCabecera["FECHAVENCIMIENTOPAGO"]);
                    thisDocument.CondicionPago = GetDataRowString(drCabecera["CONDICIONPAGO"]);
                    thisDocument.CompradorCodigoDocumento = GetDataRowString(drCabecera["CODIGODOCUMENTOCOMPRADOR"]);
                    thisDocument.CompradorNroDocumento = GetDataRowString(drCabecera["NRODOCUMENTOCOMPRADOR"]);
                    thisDocument.CompradorTipoResponsable = GetDataRowString(drCabecera["TIPORESPONSABLECOMPRADOR"]);
                    thisDocument.CompradorTipoResponsableDescripcion = GetDataRowString(drCabecera["TIPORESPONSABLECOMPRADORDESCRIPCION"]);
                    thisDocument.CompradorRazonSocial = GetDataRowString(drCabecera["RAZONSOCIALCOMPRADOR"]);
                    thisDocument.CompradorDireccion = GetDataRowString(drCabecera["DIRECCIONCOMPRADOR"]);
                    thisDocument.CompradorLocalidad = GetDataRowString(drCabecera["LOCALIDADCOMPRADOR"]);
                    thisDocument.CompradorProvincia = GetDataRowString(drCabecera["PROVINCIACOMPRADOR"]);
                    thisDocument.CompradorPais = GetDataRowString(drCabecera["PAISCOMPRADOR"]);
                    thisDocument.CompradorCodigoPostal = GetDataRowString(drCabecera["CODIGOPOSTALCOMPRADOR"]);
                    thisDocument.CompradorNroIIBB = GetDataRowString(drCabecera["NROIIBBCOMPRADOR"]);
                    thisDocument.CompradorCodigoCliente = GetDataRowString(drCabecera["CODIGOCLIENTECOMPRADOR"]);
                    thisDocument.CompradorNroReferencia = string.Empty;
                    thisDocument.CompradorEmail = string.Empty;
                    thisDocument.NroRemito = string.Empty;
                    thisDocument.Importe = GetDataRowString(drCabecera["IMPORTE"]);
                    thisDocument.ImporteComprobanteB = "0";
                    thisDocument.ImporteNoGravado = GetDataRowString(drCabecera["IMPORTENOGRAVADO"]);
                    thisDocument.ImporteGravado = GetDataRowString(drCabecera["IMPORTEGRAVADO"]);
                    thisDocument.AlicuotaIVA = "0";
                    thisDocument.ImporteImpuestoLiquidado = GetDataRowString(drCabecera["IMPORTEIMPUESTOLIQUIDADO"]);
                    thisDocument.ImporteRNI_Percepcion = GetDataRowString(drCabecera["IMPORTERNI_PERCEPCION"]);
                    thisDocument.ImporteExento = GetDataRowString(drCabecera["IMPORTEEXENTO"]);
                    thisDocument.ImportePercepciones_PagosCuentaImpuestosNacionales = GetDataRowString(drCabecera["IMPORTEPERCEPCIONES_PAGOSCUENTAIMPUESTOSNACIONALES"]);
                    thisDocument.ImportePercepcionIIBB = GetDataRowString(drCabecera["IMPORTEPERCEPCIONIIBB"]);
                    thisDocument.TasaIIBB = GetDataRowString(drCabecera["TASAIIBB"]);
                    thisDocument.CodigoJurisdiccionIIBB = GetDataRowString(drCabecera["CODIGOJURISDICCIONIIBB"]);
                    thisDocument.ImportePercepcionImpuestosMunicipales = GetDataRowString(drCabecera["IMPORTEPERCEPCIONIMPUESTOSMUNICIPALES"]);
                    thisDocument.JurisdiccionImpuestosMunicipales = GetDataRowString(drCabecera["JURISDICCIONIMPUESTOSMUNICIPALES"]);
                    thisDocument.ImporteImpuestosInternos = GetDataRowString(drCabecera["IMPORTEIMPUESTOSINTERNOS"]);
                    thisDocument.ImporteMonedaFacturacion = GetDataRowString(drCabecera["IMPORTEMONEDAFACTURACION"]);
                    thisDocument.ImporteMonedaFacturacionComprobanteB = "0";
                    thisDocument.ImporteNoGravadoMonedaFacturacion = GetDataRowString(drCabecera["IMPORTENOGRAVADOMONEDAFACTURACION"]);
                    thisDocument.ImporteGravadoMonedaFacturacion = GetDataRowString(drCabecera["IMPORTEGRAVADOMONEDAFACTURACION"]);
                    thisDocument.ImporteImpuestoLiquidadoMonedaFacturacion = GetDataRowString(drCabecera["IMPORTEIMPUESTOLIQUIDADOMONEDAFACTURACION"]);
                    thisDocument.ImporteRNI_PercepcionMonedaFacturacion = GetDataRowString(drCabecera["IMPORTERNI_PERCEPCIONMONEDAFACTURACION"]);
                    thisDocument.ImporteExentoMonedaFacturacion = GetDataRowString(drCabecera["IMPORTEEXENTOMONEDAFACTURACION"]);
                    thisDocument.ImportePercepciones_PagosCuentaImpuestosNacionalesMonedaFacturacion = GetDataRowString(drCabecera["IMPORTEPERCEPCIONES_PAGOSCUENTAIMPUESTOSNACIONALESMONEDAFACTURACION"]);
                    thisDocument.ImportePercepcionIIBBMonedaFacturacion = GetDataRowString(drCabecera["IMPORTEPERCEPCIONIIBBMONEDAFACTURACION"]);
                    thisDocument.ImportePercepcionImpuestosMunicipalesMonedaFacturacion = GetDataRowString(drCabecera["IMPORTEPERCEPCIONIMPUESTOSMUNICIPALESMONEDAFACTURACION"]);
                    thisDocument.ImporteImpuestosInternosMonedaFacturacion = GetDataRowString(drCabecera["IMPORTEIMPUESTOSINTERNOSMONEDAFACTURACION"]);
                    thisDocument.CantidadAlicuotasIVA = GetDataRowString(drCabecera["CANTIDADALICUOTASIVA"]);
                    thisDocument.CodigoOperacion = GetDataRowString(drCabecera["CODIGOOPERACION"]);
                    thisDocument.TasaCambio = GetDataRowString(drCabecera["TASACAMBIO"]);
                    thisDocument.CodigoMoneda = GetDataRowString(drCabecera["CODIGOMONEDA"]);
                    thisDocument.ImporteEscrito = GetDataRowString(drCabecera["IMPORTEESCRITO"]);
                    thisDocument.CantidadRegistrosDetalle = dtLineas.Rows.Count.ToString();
                    thisDocument.CodigoMecanismoDistribucion = string.Empty;
                    thisDocument.TipoExportacion = string.Empty;
                    thisDocument.PermisoExistente = string.Empty;
                    thisDocument.FormaPagoDescripcion = string.Empty;
                    thisDocument.IncoTerms = GetDataRowString(drCabecera["INCOTERMS"]);
                    thisDocument.Idioma = string.Empty;
                    thisDocument.Observaciones1 = GetDataRowString(drCabecera["OBSERVACIONCABECERA"]);
                    thisDocument.Observaciones2 = GetDataRowString(drCabecera["INFOADIC"]);
                    thisDocument.Observaciones3 = GetDataRowString(drCabecera["OBSERVACIONPIE"]);
                    thisDocument.EmisorDireccion = string.Empty;
                    thisDocument.EmisorCalle = GetDataRowString(drCabecera["EMISORCALLE"]);
                    thisDocument.EmisorCP = GetDataRowString(drCabecera["EMISORCP"]);
                    thisDocument.EmisorLocalidad = GetDataRowString(drCabecera["EMISORLOCALIDAD"]);
                    thisDocument.EmisorProvincia = GetDataRowString(drCabecera["EMISORPROVINCIA"]);
                    thisDocument.EmisorPais = GetDataRowString(drCabecera["EMISORPAIS"]);
                    thisDocument.EmisorTelefonos = GetDataRowString(drCabecera["EMISORTELEFONOS"]);
                    thisDocument.EmisorEMail = GetDataRowString(drCabecera["EMISOREMAIL"]);
                    thisDocument.OficinaVentas = string.Empty;
                    //thisDocument.PagoFacil = GetDataRowString(drCabecera["PagoFacil"]);
                    thisDocument.RapiPago = GetDataRowString(drCabecera["RapiPago"]);
                    thisDocument.ObservacionRapiPago = GetDataRowString(drCabecera["ObservacionRapiPago"]);
                    thisDocument.OPER = GetDataRowString(drCabecera["OPER"]);
                    thisDocument.NOPER = GetDataRowString(drCabecera["NOPER"]);
                    thisDocument.FACTORI = GetDataRowString(drCabecera["FACTORI"]);
                    thisDocument.FACTORI_FORMATEADO = GetDataRowString(drCabecera["FACTORI_FORMATEADO"]);
                    thisDocument.DAGRUF = GetDataRowString(drCabecera["DAGRUF"]);
                    thisDocument.USUARIO = GetDataRowString(drCabecera["USUARIO"]);

                    thisDocument.FECPG1_FORMATEADO = GetDataRowString(drCabecera["FECPG1_FORMATEADO"]);
                    thisDocument.FECPG2_FORMATEADO = GetDataRowString(drCabecera["FECPG2_FORMATEADO"]);

                    thisDocument.CUOTAIVA105 = GetDataRowString(drCabecera["CUOTAIVA105"]);
                    thisDocument.CUOTAIVA21 = GetDataRowString(drCabecera["CUOTAIVA21"]);

                    //Actualizar los importes del lote
                    Importe += Utils.Utils.DoubleFromString(thisDocument.Importe);
                    ImporteComprobanteB += Utils.Utils.DoubleFromString(thisDocument.ImporteComprobanteB);
                    ImporteNoGravado += Utils.Utils.DoubleFromString(thisDocument.ImporteNoGravado);
                    ImporteGravado += Utils.Utils.DoubleFromString(thisDocument.ImporteGravado);
                    ImporteImpuestoLiquidado += Utils.Utils.DoubleFromString(thisDocument.ImporteImpuestoLiquidado);
                    ImporteRNI_Percepcion += Utils.Utils.DoubleFromString(thisDocument.ImporteRNI_Percepcion);
                    ImporteExento += Utils.Utils.DoubleFromString(thisDocument.ImporteExento);
                    ImportePercepciones_PagosCuentaImpuestosNacionales += Utils.Utils.DoubleFromString(thisDocument.ImportePercepciones_PagosCuentaImpuestosNacionales);
                    ImportePercepcionIIBB += Utils.Utils.DoubleFromString(thisDocument.ImportePercepcionIIBB);
                    ImportePercepcionImpuestosMunicipales += Utils.Utils.DoubleFromString(thisDocument.ImportePercepcionImpuestosMunicipales);
                    ImporteImpuestosInternos += Utils.Utils.DoubleFromString(thisDocument.ImporteImpuestosInternos);
                    ImporteMonedaFacturacion += Utils.Utils.DoubleFromString(thisDocument.ImporteMonedaFacturacion);
                    ImporteMonedaFacturacionComprobanteB += Utils.Utils.DoubleFromString(thisDocument.ImporteMonedaFacturacionComprobanteB);
                    ImporteNoGravadoMonedaFacturacion += Utils.Utils.DoubleFromString(thisDocument.ImporteNoGravadoMonedaFacturacion);
                    ImporteGravadoMonedaFacturacion += Utils.Utils.DoubleFromString(thisDocument.ImporteGravadoMonedaFacturacion);
                    ImporteImpuestoLiquidadoMonedaFacturacion += Utils.Utils.DoubleFromString(thisDocument.ImporteImpuestoLiquidadoMonedaFacturacion);
                    ImporteRNI_PercepcionMonedaFacturacion += Utils.Utils.DoubleFromString(thisDocument.ImporteRNI_PercepcionMonedaFacturacion);
                    ImporteExentoMonedaFacturacion += Utils.Utils.DoubleFromString(thisDocument.ImporteExentoMonedaFacturacion);
                    ImportePercepciones_PagosCuentaImpuestosNacionalesMonedaFacturacion += Utils.Utils.DoubleFromString(thisDocument.ImportePercepciones_PagosCuentaImpuestosNacionalesMonedaFacturacion);
                    ImportePercepcionIIBBMonedaFacturacion += Utils.Utils.DoubleFromString(thisDocument.ImportePercepcionIIBBMonedaFacturacion);
                    ImportePercepcionImpuestosMunicipalesMonedaFacturacion += Utils.Utils.DoubleFromString(thisDocument.ImportePercepcionImpuestosMunicipalesMonedaFacturacion);
                    ImporteImpuestosInternosMonedaFacturacion += Utils.Utils.DoubleFromString(thisDocument.ImporteImpuestosInternosMonedaFacturacion);

                    //proceso las lineas
                    foreach (DataRow drLine in dtLineas.Rows)
                    {
                        thisLine = new RequestLine();

                        thisLine.CodigoProductoEmpresa = GetDataRowString(drLine["CODIGOPRODUCTOEMPRESA"]);
                        thisLine.CodigoProductoNCM = string.Empty;
                        thisLine.CodigoProductoSecretaria = string.Empty;
                        thisLine.Descripcion = GetDataRowString(drLine["DESCRIPCION"]);
                        thisLine.Cantidad = GetDataRowString(drLine["CANTIDAD"]);
                        thisLine.UnidadMedida = GetDataRowString(drLine["UNIDADMEDIDA"]);
                        thisLine.ImportePrecioUnitario = GetDataRowString(drLine["IMPORTEPRECIOUNITARIO"]);
                        thisLine.ImporteBonificacion = GetDataRowString(drLine["IMPORTEBONIFICACION"]);
                        thisLine.ImporteAjuste = "0";
                        thisLine.ImporteSubtotal = GetDataRowString(drLine["IMPORTESUBTOTAL"]);
                        thisLine.ImportePrecioUnitarioMonedaFacturacion = GetDataRowString(drLine["IMPORTEPRECIOUNITARIOMONEDAFACTURACION"]);
                        thisLine.ImporteBonificacionMonedaFacturacion = GetDataRowString(drLine["IMPORTEBONIFICACIONMONEDAFACTURACION"]);
                        thisLine.ImporteAjusteMonedaFacturacion = GetDataRowString(drLine["IMPORTEAJUSTEMONEDAFACTURACION"]);
                        thisLine.ImporteSubtotalMonedaFacturacion = GetDataRowString(drLine["IMPORTESUBTOTALMONEDAFACTURACION"]);
                        thisLine.ImporteSubtotalMonedaFacturacionConIVA = GetDataRowString(drLine["IMPORTESUBTOTALMONEDAFACTURACIONCONIVA"]);
                        thisLine.AlicuotaIVA = GetDataRowString(drLine["ALICUOTAIVA"]);
                        thisLine.IndicadorExentoGravadoNoGravado = GetDataRowString(drLine["INDICADOREXENTOGRAVADONOGRAVADO"]);
                        thisLine.Observaciones = GetDataRowString(drLine["OBSERVACIONES"]); ;
                        thisLine.MesPrestacion = GetDataRowString(drLine["MESPRESTACION"]); ;

                        thisDocument.RequestLines.Add(thisLine);
                    }

                    //proceso los impuestos (Alicuotas y Tributos)
                    foreach (DataRow drImpuesto in dtImpuestos.Rows)
                    {
                        switch(GetDataRowString(drImpuesto["TIPO"]))
                        {
                            case "Alicuota":
                                requestAlicuota = new RequestAlicuota();

                                requestAlicuota.Id = GetDataRowString(drImpuesto["ID"]);
                                requestAlicuota.CbteID = GetDataRowString(drImpuesto["CBTEID"]);
                                requestAlicuota.Importe = GetDataRowString(drImpuesto["IMPORTE"]);
                                requestAlicuota.BaseImp = GetDataRowString(drImpuesto["BASEIMP"]);
                                requestAlicuota.Tipo = GetDataRowString(drImpuesto["TIPO"]);
                                requestAlicuota.Descripcion = GetDataRowString(drImpuesto["DESCRIPCION"]);

                                thisDocument.RequestAlicuotas.Add(requestAlicuota);
                                break;

                            case "Tributo":
                                requestTributo = new RequestTributo();

                                requestTributo.Id = GetDataRowString(drImpuesto["ID"]);
                                requestTributo.CbteID = GetDataRowString(drImpuesto["CBTEID"]);
                                requestTributo.Importe = GetDataRowString(drImpuesto["IMPORTE"]);
                                requestTributo.BaseImp = GetDataRowString(drImpuesto["BASEIMP"]);
                                requestTributo.Tipo = GetDataRowString(drImpuesto["TIPO"]);
                                requestTributo.Descripcion = GetDataRowString(drImpuesto["DESCRIPCION"]);
                                requestTributo.Alic = GetDataRowString(drImpuesto["ALIC"]);

                                thisDocument.RequestTributos.Add(requestTributo);
                                break;
                        }
                    }

                    requestBatch.RequestHeaders.Add(thisDocument);

                    qtyComprobantes++;

                    requestBatch.CantidadComprobantes = qtyComprobantes.ToString();
                    requestBatch.Total = IntegrationEngine.ChangeDecimalPointToPoint(String.Format("{0:0.00}", Importe));
                    requestBatch.TotalComprobanteB = IntegrationEngine.ChangeDecimalPointToPoint(String.Format("{0:0.00}", ImporteComprobanteB));
                    requestBatch.TotalExento = IntegrationEngine.ChangeDecimalPointToPoint(String.Format("{0:0.00}", ImporteExento));
                    requestBatch.TotalExentoMonedaFacturacion = IntegrationEngine.ChangeDecimalPointToPoint(String.Format("{0:0.00}", ImporteExentoMonedaFacturacion));
                    requestBatch.TotalGravado = IntegrationEngine.ChangeDecimalPointToPoint(String.Format("{0:0.00}", ImporteGravado));
                    requestBatch.TotalGravadoMonedaFacturacion = IntegrationEngine.ChangeDecimalPointToPoint(String.Format("{0:0.00}", ImporteGravadoMonedaFacturacion));
                    requestBatch.TotalImpuestoLiquidado = IntegrationEngine.ChangeDecimalPointToPoint(String.Format("{0:0.00}", ImporteImpuestoLiquidado));
                    requestBatch.TotalImpuestoLiquidadoMonedaFacturacion = IntegrationEngine.ChangeDecimalPointToPoint(String.Format("{0:0.00}", ImporteImpuestoLiquidadoMonedaFacturacion));
                    requestBatch.TotalImpuestosInternos = IntegrationEngine.ChangeDecimalPointToPoint(String.Format("{0:0.00}", ImporteImpuestosInternos));
                    requestBatch.TotalImpuestosInternosMonedaFacturacion = IntegrationEngine.ChangeDecimalPointToPoint(String.Format("{0:0.00}", ImporteImpuestosInternosMonedaFacturacion));
                    requestBatch.TotalMonedaFacturacion = IntegrationEngine.ChangeDecimalPointToPoint(String.Format("{0:0.00}", ImporteMonedaFacturacion));
                    requestBatch.TotalMonedaFacturacionComprobanteB = IntegrationEngine.ChangeDecimalPointToPoint(String.Format("{0:0.00}", ImporteMonedaFacturacionComprobanteB));
                    requestBatch.TotalNoGravado = IntegrationEngine.ChangeDecimalPointToPoint(String.Format("{0:0.00}", ImporteNoGravado));
                    requestBatch.TotalNoGravadoMonedaFacturacion = IntegrationEngine.ChangeDecimalPointToPoint(String.Format("{0:0.00}", ImporteNoGravadoMonedaFacturacion));
                    requestBatch.TotalPercepciones_PagosCuentaImpuestosNacionales = IntegrationEngine.ChangeDecimalPointToPoint(String.Format("{0:0.00}", ImportePercepciones_PagosCuentaImpuestosNacionales));
                    requestBatch.TotalPercepciones_PagosCuentaImpuestosNacionalesMonedaFacturacion = IntegrationEngine.ChangeDecimalPointToPoint(String.Format("{0:0.00}", ImportePercepciones_PagosCuentaImpuestosNacionalesMonedaFacturacion));
                    requestBatch.TotalPercepcionIIBB = IntegrationEngine.ChangeDecimalPointToPoint(String.Format("{0:0.00}", ImportePercepcionIIBB));
                    requestBatch.TotalPercepcionIIBBMonedaFacturacion = IntegrationEngine.ChangeDecimalPointToPoint(String.Format("{0:0.00}", ImportePercepcionIIBBMonedaFacturacion));
                    requestBatch.TotalPercepcionImpuestosMunicipales = IntegrationEngine.ChangeDecimalPointToPoint(String.Format("{0:0.00}", ImportePercepcionImpuestosMunicipales));
                    requestBatch.TotalPercepcionImpuestosMunicipalesMonedaFacturacion = IntegrationEngine.ChangeDecimalPointToPoint(String.Format("{0:0.00}", ImportePercepcionImpuestosMunicipalesMonedaFacturacion));
                    requestBatch.TotalRNI_Percepcion = IntegrationEngine.ChangeDecimalPointToPoint(String.Format("{0:0.00}", ImporteRNI_Percepcion));
                    requestBatch.TotalRNI_PercepcionMonedaFacturacion = IntegrationEngine.ChangeDecimalPointToPoint(String.Format("{0:0.00}", ImporteRNI_PercepcionMonedaFacturacion));

                    //TODO: Lote automático donde configurarlo?
                    requestBatch.BatchUniqueId = "AUTO";
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.EventLog.WriteEntry("Servicio Factura Electronica", "ProcessData.Error:" + ex.Message, System.Diagnostics.EventLogEntryType.Error);
            }
            return requestBatch;
        }