Skip to main content
se añadieron 4 caracteres en el cuerpo
Origen Enlace
Joacer
  • 5.8k
  • 11
  • 34
  • 54

Cursor aIds = querySql("SELECT DISTINCT CLiente, FechaCobro FROM " + SqliteDB.DBhelper.TABLE_NAME_DETALLECLIENTE + " WHERE " + SqliteDB.DBhelper.COLUMN_NAME_Status + " = " + " '" + true + "'", null); SimpleDateFormat DateFormatterd = new SimpleDateFormat("E MMM dd HH:mm:ss Z yyyy", Locale.ENGLISH); int cont = aIds.getCount(); if (aIds.getCount() > 0) { while (aIds.moveToNext()) { int _Cliente = aIds.getInt(aIds.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_CLiente)); Date _Fecha = null; try { _Fecha = (DateFormatterd.parse(aIds.getString(aIds.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_FechaCobro)))); } catch (ParseException e) { e.printStackTrace(); }

Cursor aIds = querySql("SELECT DISTINCT CLiente, FechaCobro FROM " + SqliteDB.DBhelper.TABLE_NAME_DETALLECLIENTE + " WHERE " + SqliteDB.DBhelper.COLUMN_NAME_Status + " = " + " '" + true + "'", null);
        SimpleDateFormat DateFormatterd = new SimpleDateFormat("E MMM dd HH:mm:ss Z yyyy", Locale.ENGLISH);
        int cont = aIds.getCount();
        if (aIds.getCount() > 0) {
            while (aIds.moveToNext()) {
                int _Cliente = aIds.getInt(aIds.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_CLiente));
                Date _Fecha = null;
                try {
                    _Fecha = (DateFormatterd.parse(aIds.getString(aIds.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_FechaCobro))));
                } catch (ParseException e) {
                    e.printStackTrace();
                }

                Cursor aRs = querySql("SELECT * FROM " + SqliteDB.DBhelper.TABLE_NAME_DETALLECLIENTE + " WHERE " + SqliteDB.DBhelper.COLUMN_NAME_Status + " = " + " '" + true + "'" + " AND CLiente=" + _Cliente +  " AND FechaCobro " + "=" + "'" + _Fecha + "'" , null);
                SimpleDateFormat DateFormatterD  = new SimpleDateFormat("E MMM dd HH:mm:ss Z yyyy", Locale.ENGLISH);

                if (aRs.getCount() > 0  || aRs.getCount() == _Cliente)  {
                    while (aRs.moveToNext()) {

                        Id = aRs.getInt(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_ID));
                        Folio = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Folio));
                        ClientClave = aRs.getInt(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_CLiente));
                        try {
                            Date Fecha = DateFormatterD.parse(aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Fecha)));
                        } catch (ParseException e) {
                            e.printStackTrace();
                        }
                        DocumentoD = aRs.getInt(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Documento));
                        DocumentoDescripcion = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_DocumentoDescripcion));
                        IdCliente = aRs.getInt(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_CLiente));
                        MonedaD = aRs.getInt(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_MonedaD));
                        ImporteD = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Importe));
                        DescuentoD = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Descuento));
                        SubTotalD = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_SubTotal));
                        Retencion1D = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Retencion1));
                        Retencion2D = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Retencion2));
                        IEPSD = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_IEPS));
                        IVAD = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_IVA));
                        TotalD = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Total));
                        Saldo = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_SaldoD));
                        Double SaldoVencido = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_SaldovencidoD));
                        String ParcialidadD = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Parcialidad));
                        Double ParcialidadTotal = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_ParcialidadTotal));
                        String PagoCondicionDescripcion = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_PagoCondicionDescripcion));
                        UltimoCobroObservacion = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_UltimoCobroObservacion));
                        TotalAplicado += aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_TotalApli));
                        TotalApli =  aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_TotalApli));
                        UrlD = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_URL));
                        DireccionD = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Direccion));

                    }
                    if (aRs.getCount() > 1)
                    {
                        if (TotalAplicado > 0 || TotalAplicado == 0 ) {
                            Factor = TotalAplicado / TotalD;

                            Importe += ImporteD * Factor;
                            Descuento += DescuentoD * Factor;
                            SubTotal += SubTotalD * Factor;
                            IVA += IVAD * Factor;
                            Retencion1 += Retencion1D * Factor;
                            Retencion2 += Retencion2D * Factor;
                            IEPS += IEPSD * Factor;
                            Total += TotalD * Factor;
                            Url = UrlD;
                            Direccion = DireccionD;
                            Cliente = IdCliente;
                            Moneda = MonedaD;
                            Observaciones = UltimoCobroObservacion;

                            O_ResultadoEncabezado = O_WS.LLenarEncabezadoCXCP("I",    //Accion I
                                    0,      //Id = 0
                                    "",
                                    new Date(),
                                    Cliente,
                                    0,
                                    Moneda,
                                    1.0,      //Tipo de Cambio por default 1
                                    0,      //Cuenta Bancaria
                                    1,          //Pago Forma
                                    Total,          //Saldo
                                    Importe,    //Importe
                                    0,          //Financiamiento
                                    Descuento,
                                    SubTotal,
                                    Retencion1,
                                    Retencion2,
                                    IEPS,
                                    IVA,
                                    0,          //ISH,
                                    Total,      //Total
                                    Total,      //totalaplicado,
                                    "A",        //status,
                                    "",         //usucariocancela,
                                    0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,   //Numero1...Numero10
                                    Url, //Texto1
                                    Direccion,  //Texto2
                                    "", "", "", "", "", "", "", "",                      //Texto1...Texto10
                                    new Date(), new Date(), new Date(), new Date(), new Date(), new Date(),  //Fecha1...Texto6
                                    Observaciones,         //Observacion
                                    0, 0, 0, 0, 0, 0,         //Catalogo1...Catalogo6
                                    "",         //ordencompra
                                    0,          //concepto
                                    "",         //observacioncancelacion
                                    0,          //origenventacompra,
                                    0           //origeninventario
                            );

                        }
                    }else{
                        if (TotalApli > 0 || TotalApli == 0) {
                            Factor = TotalApli / TotalD;

                            Importe += ImporteD * Factor;
                            Descuento += DescuentoD * Factor;
                            SubTotal += SubTotalD * Factor;
                            IVA += IVAD * Factor;
                            Retencion1 += Retencion1D * Factor;
                            Retencion2 += Retencion2D * Factor;
                            IEPS += IEPSD * Factor;
                            Total += TotalD * Factor;
                            Url = UrlD;
                            Direccion = DireccionD;
                            Cliente = IdCliente;
                            Moneda = MonedaD;
                            Observaciones = UltimoCobroObservacion;

                            O_ResultadoEncabezado = O_WS.LLenarEncabezadoCXCP("I",    //Accion I
                                    0,      //Id = 0
                                    "",
                                    new Date(),
                                    Cliente,
                                    0,
                                    Moneda,
                                    1.0,      //Tipo de Cambio por default 1
                                    0,      //Cuenta Bancaria
                                    1,          //Pago Forma
                                    Total,          //Saldo
                                    Importe,    //Importe
                                    0,          //Financiamiento
                                    Descuento,
                                    SubTotal,
                                    Retencion1,
                                    Retencion2,
                                    IEPS,
                                    IVA,
                                    0,          //ISH,
                                    Total,      //Total
                                    Total,      //totalaplicado,
                                    "A",        //status,
                                    "",         //usucariocancela,
                                    0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,   //Numero1...Numero10
                                    Url, //Texto1
                                    Direccion,  //Texto2
                                    "", "", "", "", "", "", "", "",                      //Texto1...Texto10
                                    new Date(), new Date(), new Date(), new Date(), new Date(), new Date(),  //Fecha1...Texto6
                                    Observaciones,         //Observacion
                                    0, 0, 0, 0, 0, 0,         //Catalogo1...Catalogo6
                                    "",         //ordencompra
                                    0,          //concepto
                                    "",         //observacioncancelacion
                                    0,          //origenventacompra,
                                    0           //origeninventario
                            );

                        }

                    }


                }

                if (O_ResultadoEncabezado.ErrorId == 0) {
                    aRs.moveToFirst();

                        while (aRs.moveToNext()) {

                            if (aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_TotalApli)) > 0 || aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_TotalApli)) == 0)
                            {
                                DFactor = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_TotalApli)) / aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Total));


                                Resultado = Integer.parseInt(O_WS.LLenarDetalleCXCP

                                        ("I", //Accion
                                                0, //id
                                                Id,  //Origen
                                                aRs.getInt(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Documento)),  //OrigenDocumento
                                                aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Importe)) * DFactor,   //Importe
                                                (Double) 0.0,  //Financiamiento
                                                aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Descuento)), //Descuento
                                                aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_SubTotal)) * DFactor,   //Subtotal
                                                aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Retencion1)) * DFactor, //Retencion1
                                                aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Retencion2)) * DFactor,  //Retencion2
                                                aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_IEPS)) * DFactor,   //IEPS
                                                aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_IVA)) * DFactor, //IVA
                                                (Double) 0.0, //ISH
                                                aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Total)) * DFactor,  //Total
                                                aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_SaldoD)),//Saldo
                                                "Android App Desconectado"      //Referencia
                                        ));
                            }

                        }
                }

                webService.STR_Resultado O_Resultado = null;

                if (Resultado == 0) {

                    ArrayList<DetalleMenu> ArrayMenu = new ArrayList<DetalleMenu>();
                    Cursor arS = querySql("SELECT * FROM " + SqliteDB.DBhelper.TABLE_NAME_Menu , null);
                    if (arS.getCount() > 0) {

                        while (arS.moveToNext()) {

                            DetalleMenu newDetalle = new DetalleMenu(
                                    (arS.getInt(arS.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_IdMenu))),
                                    (arS.getInt(arS.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_EmpresaM))),
                                    (arS.getString(arS.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_DescripcionMenu))),
                                    (arS.getString(arS.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Evento))),
                                    (arS.getInt(arS.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Modulo))),
                                    (arS.getInt(arS.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Operacion))),
                                    (arS.getInt(arS.getColumnIndex(SqliteDB.DBhelper.COLIMN_NAME_Documento))));
                            ArrayMenu.add(newDetalle);
                        }

                    }

                    for (int i=0; i< ArrayMenu.size();i++)
                    {
                        Modulo = ((DetalleMenu)ArrayMenu.get(i)).getModulo();
                        Operacion =  ((DetalleMenu)ArrayMenu.get(i)).getOperacion();
                        Documento =  ((DetalleMenu)ArrayMenu.get(i)).getDocumento();
                    }


                    O_Resultado = O_WS.GrabarCxCP(Modulo,      //Modulo
                            Operacion,      //Operacion
                            Documento,      //Documento
                            0,      //OrigenId
                            0);     //OrigenDocumento

                }

                //Se inicializan Variables
                ImporteD = 0.0;
                DescuentoD = 0.0;
                SubTotalD = 0.0;
                IVAD = 0.0;
                TotalD = 0.0;
                Importe = 0.0;
                Descuento = 0.0;
                SubTotal = 0.0;
                IVA = 0.0;
                Total = 0.0;
                TotalAplicado = 0.0;
            }

Cursor aIds = querySql("SELECT DISTINCT CLiente, FechaCobro FROM " + SqliteDB.DBhelper.TABLE_NAME_DETALLECLIENTE + " WHERE " + SqliteDB.DBhelper.COLUMN_NAME_Status + " = " + " '" + true + "'", null); SimpleDateFormat DateFormatterd = new SimpleDateFormat("E MMM dd HH:mm:ss Z yyyy", Locale.ENGLISH); int cont = aIds.getCount(); if (aIds.getCount() > 0) { while (aIds.moveToNext()) { int _Cliente = aIds.getInt(aIds.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_CLiente)); Date _Fecha = null; try { _Fecha = (DateFormatterd.parse(aIds.getString(aIds.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_FechaCobro)))); } catch (ParseException e) { e.printStackTrace(); }

                Cursor aRs = querySql("SELECT * FROM " + SqliteDB.DBhelper.TABLE_NAME_DETALLECLIENTE + " WHERE " + SqliteDB.DBhelper.COLUMN_NAME_Status + " = " + " '" + true + "'" + " AND CLiente=" + _Cliente +  " AND FechaCobro " + "=" + "'" + _Fecha + "'" , null);
                SimpleDateFormat DateFormatterD  = new SimpleDateFormat("E MMM dd HH:mm:ss Z yyyy", Locale.ENGLISH);

                if (aRs.getCount() > 0  || aRs.getCount() == _Cliente)  {
                    while (aRs.moveToNext()) {

                        Id = aRs.getInt(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_ID));
                        Folio = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Folio));
                        ClientClave = aRs.getInt(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_CLiente));
                        try {
                            Date Fecha = DateFormatterD.parse(aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Fecha)));
                        } catch (ParseException e) {
                            e.printStackTrace();
                        }
                        DocumentoD = aRs.getInt(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Documento));
                        DocumentoDescripcion = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_DocumentoDescripcion));
                        IdCliente = aRs.getInt(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_CLiente));
                        MonedaD = aRs.getInt(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_MonedaD));
                        ImporteD = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Importe));
                        DescuentoD = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Descuento));
                        SubTotalD = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_SubTotal));
                        Retencion1D = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Retencion1));
                        Retencion2D = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Retencion2));
                        IEPSD = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_IEPS));
                        IVAD = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_IVA));
                        TotalD = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Total));
                        Saldo = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_SaldoD));
                        Double SaldoVencido = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_SaldovencidoD));
                        String ParcialidadD = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Parcialidad));
                        Double ParcialidadTotal = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_ParcialidadTotal));
                        String PagoCondicionDescripcion = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_PagoCondicionDescripcion));
                        UltimoCobroObservacion = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_UltimoCobroObservacion));
                        TotalAplicado += aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_TotalApli));
                        TotalApli =  aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_TotalApli));
                        UrlD = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_URL));
                        DireccionD = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Direccion));

                    }
                    if (aRs.getCount() > 1)
                    {
                        if (TotalAplicado > 0 || TotalAplicado == 0 ) {
                            Factor = TotalAplicado / TotalD;

                            Importe += ImporteD * Factor;
                            Descuento += DescuentoD * Factor;
                            SubTotal += SubTotalD * Factor;
                            IVA += IVAD * Factor;
                            Retencion1 += Retencion1D * Factor;
                            Retencion2 += Retencion2D * Factor;
                            IEPS += IEPSD * Factor;
                            Total += TotalD * Factor;
                            Url = UrlD;
                            Direccion = DireccionD;
                            Cliente = IdCliente;
                            Moneda = MonedaD;
                            Observaciones = UltimoCobroObservacion;

                            O_ResultadoEncabezado = O_WS.LLenarEncabezadoCXCP("I",    //Accion I
                                    0,      //Id = 0
                                    "",
                                    new Date(),
                                    Cliente,
                                    0,
                                    Moneda,
                                    1.0,      //Tipo de Cambio por default 1
                                    0,      //Cuenta Bancaria
                                    1,          //Pago Forma
                                    Total,          //Saldo
                                    Importe,    //Importe
                                    0,          //Financiamiento
                                    Descuento,
                                    SubTotal,
                                    Retencion1,
                                    Retencion2,
                                    IEPS,
                                    IVA,
                                    0,          //ISH,
                                    Total,      //Total
                                    Total,      //totalaplicado,
                                    "A",        //status,
                                    "",         //usucariocancela,
                                    0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,   //Numero1...Numero10
                                    Url, //Texto1
                                    Direccion,  //Texto2
                                    "", "", "", "", "", "", "", "",                      //Texto1...Texto10
                                    new Date(), new Date(), new Date(), new Date(), new Date(), new Date(),  //Fecha1...Texto6
                                    Observaciones,         //Observacion
                                    0, 0, 0, 0, 0, 0,         //Catalogo1...Catalogo6
                                    "",         //ordencompra
                                    0,          //concepto
                                    "",         //observacioncancelacion
                                    0,          //origenventacompra,
                                    0           //origeninventario
                            );

                        }
                    }else{
                        if (TotalApli > 0 || TotalApli == 0) {
                            Factor = TotalApli / TotalD;

                            Importe += ImporteD * Factor;
                            Descuento += DescuentoD * Factor;
                            SubTotal += SubTotalD * Factor;
                            IVA += IVAD * Factor;
                            Retencion1 += Retencion1D * Factor;
                            Retencion2 += Retencion2D * Factor;
                            IEPS += IEPSD * Factor;
                            Total += TotalD * Factor;
                            Url = UrlD;
                            Direccion = DireccionD;
                            Cliente = IdCliente;
                            Moneda = MonedaD;
                            Observaciones = UltimoCobroObservacion;

                            O_ResultadoEncabezado = O_WS.LLenarEncabezadoCXCP("I",    //Accion I
                                    0,      //Id = 0
                                    "",
                                    new Date(),
                                    Cliente,
                                    0,
                                    Moneda,
                                    1.0,      //Tipo de Cambio por default 1
                                    0,      //Cuenta Bancaria
                                    1,          //Pago Forma
                                    Total,          //Saldo
                                    Importe,    //Importe
                                    0,          //Financiamiento
                                    Descuento,
                                    SubTotal,
                                    Retencion1,
                                    Retencion2,
                                    IEPS,
                                    IVA,
                                    0,          //ISH,
                                    Total,      //Total
                                    Total,      //totalaplicado,
                                    "A",        //status,
                                    "",         //usucariocancela,
                                    0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,   //Numero1...Numero10
                                    Url, //Texto1
                                    Direccion,  //Texto2
                                    "", "", "", "", "", "", "", "",                      //Texto1...Texto10
                                    new Date(), new Date(), new Date(), new Date(), new Date(), new Date(),  //Fecha1...Texto6
                                    Observaciones,         //Observacion
                                    0, 0, 0, 0, 0, 0,         //Catalogo1...Catalogo6
                                    "",         //ordencompra
                                    0,          //concepto
                                    "",         //observacioncancelacion
                                    0,          //origenventacompra,
                                    0           //origeninventario
                            );

                        }

                    }


                }

                if (O_ResultadoEncabezado.ErrorId == 0) {
                    aRs.moveToFirst();

                        while (aRs.moveToNext()) {

                            if (aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_TotalApli)) > 0 || aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_TotalApli)) == 0)
                            {
                                DFactor = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_TotalApli)) / aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Total));


                                Resultado = Integer.parseInt(O_WS.LLenarDetalleCXCP

                                        ("I", //Accion
                                                0, //id
                                                Id,  //Origen
                                                aRs.getInt(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Documento)),  //OrigenDocumento
                                                aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Importe)) * DFactor,   //Importe
                                                (Double) 0.0,  //Financiamiento
                                                aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Descuento)), //Descuento
                                                aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_SubTotal)) * DFactor,   //Subtotal
                                                aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Retencion1)) * DFactor, //Retencion1
                                                aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Retencion2)) * DFactor,  //Retencion2
                                                aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_IEPS)) * DFactor,   //IEPS
                                                aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_IVA)) * DFactor, //IVA
                                                (Double) 0.0, //ISH
                                                aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Total)) * DFactor,  //Total
                                                aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_SaldoD)),//Saldo
                                                "Android App Desconectado"      //Referencia
                                        ));
                            }

                        }
                }

                webService.STR_Resultado O_Resultado = null;

                if (Resultado == 0) {

                    ArrayList<DetalleMenu> ArrayMenu = new ArrayList<DetalleMenu>();
                    Cursor arS = querySql("SELECT * FROM " + SqliteDB.DBhelper.TABLE_NAME_Menu , null);
                    if (arS.getCount() > 0) {

                        while (arS.moveToNext()) {

                            DetalleMenu newDetalle = new DetalleMenu(
                                    (arS.getInt(arS.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_IdMenu))),
                                    (arS.getInt(arS.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_EmpresaM))),
                                    (arS.getString(arS.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_DescripcionMenu))),
                                    (arS.getString(arS.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Evento))),
                                    (arS.getInt(arS.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Modulo))),
                                    (arS.getInt(arS.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Operacion))),
                                    (arS.getInt(arS.getColumnIndex(SqliteDB.DBhelper.COLIMN_NAME_Documento))));
                            ArrayMenu.add(newDetalle);
                        }

                    }

                    for (int i=0; i< ArrayMenu.size();i++)
                    {
                        Modulo = ((DetalleMenu)ArrayMenu.get(i)).getModulo();
                        Operacion =  ((DetalleMenu)ArrayMenu.get(i)).getOperacion();
                        Documento =  ((DetalleMenu)ArrayMenu.get(i)).getDocumento();
                    }


                    O_Resultado = O_WS.GrabarCxCP(Modulo,      //Modulo
                            Operacion,      //Operacion
                            Documento,      //Documento
                            0,      //OrigenId
                            0);     //OrigenDocumento

                }

                //Se inicializan Variables
                ImporteD = 0.0;
                DescuentoD = 0.0;
                SubTotalD = 0.0;
                IVAD = 0.0;
                TotalD = 0.0;
                Importe = 0.0;
                Descuento = 0.0;
                SubTotal = 0.0;
                IVA = 0.0;
                Total = 0.0;
                TotalAplicado = 0.0;
            }
Cursor aIds = querySql("SELECT DISTINCT CLiente, FechaCobro FROM " + SqliteDB.DBhelper.TABLE_NAME_DETALLECLIENTE + " WHERE " + SqliteDB.DBhelper.COLUMN_NAME_Status + " = " + " '" + true + "'", null);
        SimpleDateFormat DateFormatterd = new SimpleDateFormat("E MMM dd HH:mm:ss Z yyyy", Locale.ENGLISH);
        int cont = aIds.getCount();
        if (aIds.getCount() > 0) {
            while (aIds.moveToNext()) {
                int _Cliente = aIds.getInt(aIds.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_CLiente));
                Date _Fecha = null;
                try {
                    _Fecha = (DateFormatterd.parse(aIds.getString(aIds.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_FechaCobro))));
                } catch (ParseException e) {
                    e.printStackTrace();
                }

                Cursor aRs = querySql("SELECT * FROM " + SqliteDB.DBhelper.TABLE_NAME_DETALLECLIENTE + " WHERE " + SqliteDB.DBhelper.COLUMN_NAME_Status + " = " + " '" + true + "'" + " AND CLiente=" + _Cliente +  " AND FechaCobro " + "=" + "'" + _Fecha + "'" , null);
                SimpleDateFormat DateFormatterD  = new SimpleDateFormat("E MMM dd HH:mm:ss Z yyyy", Locale.ENGLISH);

                if (aRs.getCount() > 0  || aRs.getCount() == _Cliente)  {
                    while (aRs.moveToNext()) {

                        Id = aRs.getInt(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_ID));
                        Folio = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Folio));
                        ClientClave = aRs.getInt(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_CLiente));
                        try {
                            Date Fecha = DateFormatterD.parse(aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Fecha)));
                        } catch (ParseException e) {
                            e.printStackTrace();
                        }
                        DocumentoD = aRs.getInt(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Documento));
                        DocumentoDescripcion = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_DocumentoDescripcion));
                        IdCliente = aRs.getInt(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_CLiente));
                        MonedaD = aRs.getInt(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_MonedaD));
                        ImporteD = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Importe));
                        DescuentoD = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Descuento));
                        SubTotalD = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_SubTotal));
                        Retencion1D = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Retencion1));
                        Retencion2D = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Retencion2));
                        IEPSD = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_IEPS));
                        IVAD = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_IVA));
                        TotalD = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Total));
                        Saldo = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_SaldoD));
                        Double SaldoVencido = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_SaldovencidoD));
                        String ParcialidadD = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Parcialidad));
                        Double ParcialidadTotal = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_ParcialidadTotal));
                        String PagoCondicionDescripcion = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_PagoCondicionDescripcion));
                        UltimoCobroObservacion = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_UltimoCobroObservacion));
                        TotalAplicado += aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_TotalApli));
                        TotalApli =  aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_TotalApli));
                        UrlD = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_URL));
                        DireccionD = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Direccion));

                    }
                    if (aRs.getCount() > 1)
                    {
                        if (TotalAplicado > 0 || TotalAplicado == 0 ) {
                            Factor = TotalAplicado / TotalD;

                            Importe += ImporteD * Factor;
                            Descuento += DescuentoD * Factor;
                            SubTotal += SubTotalD * Factor;
                            IVA += IVAD * Factor;
                            Retencion1 += Retencion1D * Factor;
                            Retencion2 += Retencion2D * Factor;
                            IEPS += IEPSD * Factor;
                            Total += TotalD * Factor;
                            Url = UrlD;
                            Direccion = DireccionD;
                            Cliente = IdCliente;
                            Moneda = MonedaD;
                            Observaciones = UltimoCobroObservacion;

                            O_ResultadoEncabezado = O_WS.LLenarEncabezadoCXCP("I",    //Accion I
                                    0,      //Id = 0
                                    "",
                                    new Date(),
                                    Cliente,
                                    0,
                                    Moneda,
                                    1.0,      //Tipo de Cambio por default 1
                                    0,      //Cuenta Bancaria
                                    1,          //Pago Forma
                                    Total,          //Saldo
                                    Importe,    //Importe
                                    0,          //Financiamiento
                                    Descuento,
                                    SubTotal,
                                    Retencion1,
                                    Retencion2,
                                    IEPS,
                                    IVA,
                                    0,          //ISH,
                                    Total,      //Total
                                    Total,      //totalaplicado,
                                    "A",        //status,
                                    "",         //usucariocancela,
                                    0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,   //Numero1...Numero10
                                    Url, //Texto1
                                    Direccion,  //Texto2
                                    "", "", "", "", "", "", "", "",                      //Texto1...Texto10
                                    new Date(), new Date(), new Date(), new Date(), new Date(), new Date(),  //Fecha1...Texto6
                                    Observaciones,         //Observacion
                                    0, 0, 0, 0, 0, 0,         //Catalogo1...Catalogo6
                                    "",         //ordencompra
                                    0,          //concepto
                                    "",         //observacioncancelacion
                                    0,          //origenventacompra,
                                    0           //origeninventario
                            );

                        }
                    }else{
                        if (TotalApli > 0 || TotalApli == 0) {
                            Factor = TotalApli / TotalD;

                            Importe += ImporteD * Factor;
                            Descuento += DescuentoD * Factor;
                            SubTotal += SubTotalD * Factor;
                            IVA += IVAD * Factor;
                            Retencion1 += Retencion1D * Factor;
                            Retencion2 += Retencion2D * Factor;
                            IEPS += IEPSD * Factor;
                            Total += TotalD * Factor;
                            Url = UrlD;
                            Direccion = DireccionD;
                            Cliente = IdCliente;
                            Moneda = MonedaD;
                            Observaciones = UltimoCobroObservacion;

                            O_ResultadoEncabezado = O_WS.LLenarEncabezadoCXCP("I",    //Accion I
                                    0,      //Id = 0
                                    "",
                                    new Date(),
                                    Cliente,
                                    0,
                                    Moneda,
                                    1.0,      //Tipo de Cambio por default 1
                                    0,      //Cuenta Bancaria
                                    1,          //Pago Forma
                                    Total,          //Saldo
                                    Importe,    //Importe
                                    0,          //Financiamiento
                                    Descuento,
                                    SubTotal,
                                    Retencion1,
                                    Retencion2,
                                    IEPS,
                                    IVA,
                                    0,          //ISH,
                                    Total,      //Total
                                    Total,      //totalaplicado,
                                    "A",        //status,
                                    "",         //usucariocancela,
                                    0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,   //Numero1...Numero10
                                    Url, //Texto1
                                    Direccion,  //Texto2
                                    "", "", "", "", "", "", "", "",                      //Texto1...Texto10
                                    new Date(), new Date(), new Date(), new Date(), new Date(), new Date(),  //Fecha1...Texto6
                                    Observaciones,         //Observacion
                                    0, 0, 0, 0, 0, 0,         //Catalogo1...Catalogo6
                                    "",         //ordencompra
                                    0,          //concepto
                                    "",         //observacioncancelacion
                                    0,          //origenventacompra,
                                    0           //origeninventario
                            );

                        }

                    }


                }

                if (O_ResultadoEncabezado.ErrorId == 0) {
                    aRs.moveToFirst();

                        while (aRs.moveToNext()) {

                            if (aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_TotalApli)) > 0 || aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_TotalApli)) == 0)
                            {
                                DFactor = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_TotalApli)) / aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Total));


                                Resultado = Integer.parseInt(O_WS.LLenarDetalleCXCP

                                        ("I", //Accion
                                                0, //id
                                                Id,  //Origen
                                                aRs.getInt(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Documento)),  //OrigenDocumento
                                                aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Importe)) * DFactor,   //Importe
                                                (Double) 0.0,  //Financiamiento
                                                aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Descuento)), //Descuento
                                                aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_SubTotal)) * DFactor,   //Subtotal
                                                aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Retencion1)) * DFactor, //Retencion1
                                                aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Retencion2)) * DFactor,  //Retencion2
                                                aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_IEPS)) * DFactor,   //IEPS
                                                aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_IVA)) * DFactor, //IVA
                                                (Double) 0.0, //ISH
                                                aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Total)) * DFactor,  //Total
                                                aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_SaldoD)),//Saldo
                                                "Android App Desconectado"      //Referencia
                                        ));
                            }

                        }
                }

                webService.STR_Resultado O_Resultado = null;

                if (Resultado == 0) {

                    ArrayList<DetalleMenu> ArrayMenu = new ArrayList<DetalleMenu>();
                    Cursor arS = querySql("SELECT * FROM " + SqliteDB.DBhelper.TABLE_NAME_Menu , null);
                    if (arS.getCount() > 0) {

                        while (arS.moveToNext()) {

                            DetalleMenu newDetalle = new DetalleMenu(
                                    (arS.getInt(arS.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_IdMenu))),
                                    (arS.getInt(arS.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_EmpresaM))),
                                    (arS.getString(arS.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_DescripcionMenu))),
                                    (arS.getString(arS.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Evento))),
                                    (arS.getInt(arS.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Modulo))),
                                    (arS.getInt(arS.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Operacion))),
                                    (arS.getInt(arS.getColumnIndex(SqliteDB.DBhelper.COLIMN_NAME_Documento))));
                            ArrayMenu.add(newDetalle);
                        }

                    }

                    for (int i=0; i< ArrayMenu.size();i++)
                    {
                        Modulo = ((DetalleMenu)ArrayMenu.get(i)).getModulo();
                        Operacion =  ((DetalleMenu)ArrayMenu.get(i)).getOperacion();
                        Documento =  ((DetalleMenu)ArrayMenu.get(i)).getDocumento();
                    }


                    O_Resultado = O_WS.GrabarCxCP(Modulo,      //Modulo
                            Operacion,      //Operacion
                            Documento,      //Documento
                            0,      //OrigenId
                            0);     //OrigenDocumento

                }

                //Se inicializan Variables
                ImporteD = 0.0;
                DescuentoD = 0.0;
                SubTotalD = 0.0;
                IVAD = 0.0;
                TotalD = 0.0;
                Importe = 0.0;
                Descuento = 0.0;
                SubTotal = 0.0;
                IVA = 0.0;
                Total = 0.0;
                TotalAplicado = 0.0;
            }
se añadieron 2752 caracteres en el cuerpo
Origen Enlace

Cursor aIds = querySql("SELECT DISTINCT CLiente, FechaCobro FROM " + SqliteDB.DBhelper.TABLE_NAME_DETALLECLIENTE + " WHERE " + SqliteDB.DBhelper.COLUMN_NAME_Status + " = " + " '" + true + "'", null); SimpleDateFormat DateFormatterd = new SimpleDateFormat("E MMM dd HH:mm:ss Z yyyy", Locale.ENGLISH); int cont = aIds.getCount(); if (aIds.getCount() > 0) { while (aIds.moveToNext()) { int _Cliente = aIds.getInt(aIds.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_CLiente)); Date _Fecha = null; try { _Fecha = (DateFormatterd.parse(aIds.getString(aIds.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_FechaCobro)))); } catch (ParseException e) { e.printStackTrace(); }

                Cursor aRs = querySql("SELECT * FROM " + SqliteDB.DBhelper.TABLE_NAME_DETALLECLIENTE + " WHERE " + SqliteDB.DBhelper.COLUMN_NAME_Status + " = " + " '" + true + "'" + " AND CLiente=" + _Cliente +  " AND FechaCobro " + "=" + "'" + _Fecha + "'" , null);
                    SimpleDateFormat DateFormatterD  = new SimpleDateFormat("E MMM dd HH:mm:ss Z yyyy", Locale.ENGLISH);

                    if (aRs.getCount() > 0  || aRs.getCount() == _Cliente)  {
                        while (aRs.moveToNext()) {

                            Id =if aRs.getInt(aRs.getColumnIndexgetCount(SqliteDB.DBhelper.COLUMN_NAME_ID));
                          > 0 Folio =|| aRs.getString(aRs.getColumnIndexgetCount(SqliteDB.DBhelper.COLUMN_NAME_Folio));
                            ClientClave === aRs.getInt(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_CLiente)_Cliente);
                            try {
                                Date Fecha =while DateFormatterD.parse(aRs.getString(aRs.getColumnIndexmoveToNext(SqliteDB.DBhelper.COLUMN_NAME_Fecha)));
                            } catch (ParseException e) {
                                e.printStackTrace();
                            }
                            DocumentoD = aRs.getInt(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Documento));
                            DocumentoDescripcion = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_DocumentoDescripcion));
                            IdCliente = aRs.getInt(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_CLiente));
                            MonedaD = aRs.getInt(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_MonedaD));
                            ImporteD = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Importe));
                            DescuentoD = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Descuento));
                            SubTotalD = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_SubTotal));
                            Retencion1D = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Retencion1));
                            Retencion2D = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Retencion2));
                            IEPSD = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_IEPS));
                            IVAD = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_IVA));
                            TotalD = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Total));
                            Saldo = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_SaldoD));
                            Double SaldoVencido = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_SaldovencidoD));
                            String ParcialidadD = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Parcialidad));
                            Double ParcialidadTotal = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_ParcialidadTotal));
                            String PagoCondicionDescripcion = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_PagoCondicionDescripcion));
                            UltimoCobroObservacion = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_UltimoCobroObservacion));
                            TotalAplicado += aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_TotalApli));
                            TotalApli =  aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_TotalApli));
                            UrlD = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_URL));
                            DireccionD = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Direccion));

                        Id = aRs.getInt(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_ID));
                        Folio = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Folio));
                        ClientClave = aRs.getInt(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_CLiente));
                        try {
                            Date Fecha = DateFormatterD.parse(aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Fecha)));
                        } catch (ParseException e) {
                            e.printStackTrace();
                        }
                        ifDocumentoD = aRs.getInt(aRs.getCountgetColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Documento));
 > 1                      DocumentoDescripcion = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_DocumentoDescripcion));
                        {IdCliente = aRs.getInt(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_CLiente));
                        MonedaD = aRs.getInt(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_MonedaD));
  if                      ImporteD = aRs.getDouble(TotalAplicadoaRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Importe));
 > 0 || TotalAplicado == 0                  DescuentoD = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Descuento));
 {                       SubTotalD = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_SubTotal));
                        Retencion1D = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Retencion1));
      Factor                  Retencion2D = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Retencion2));
                        IEPSD = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_IEPS));
                        IVAD = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_IVA));
                        TotalD = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Total));
                        Saldo = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_SaldoD));
                        Double SaldoVencido = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_SaldovencidoD));
                        String ParcialidadD = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Parcialidad));
                        Double ParcialidadTotal = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_ParcialidadTotal));
                        String PagoCondicionDescripcion = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_PagoCondicionDescripcion));
                        UltimoCobroObservacion = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_UltimoCobroObservacion));
                        TotalAplicado /+= TotalD;aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_TotalApli));
                        TotalApli =  aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_TotalApli));
                        UrlD = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_URL));
                        DireccionD = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Direccion));

                                Importe += ImporteD * Factor;
                                Descuento += DescuentoD * Factor;
                                SubTotal += SubTotalD * Factor;
                                IVA += IVAD * Factor;
                                Retencion1 += Retencion1D * Factor;
                                Retencion2 += Retencion2D * Factor;
                                IEPS += IEPSD * Factor;
                                Total += TotalD * Factor;}
                               if Url(aRs.getCount() => UrlD;1)
                                Direccion = DireccionD;{
                         if (TotalAplicado > 0 || TotalAplicado == Cliente0 =) IdCliente;{
                                MonedaFactor = MonedaD;
                                ObservacionesTotalAplicado =/ UltimoCobroObservacion;TotalD;

                                O_ResultadoEncabezado = O_WS.LLenarEncabezadoCXCP("I",    //Accion I
                                        0,      //Id = 0
                                        "",
                                        new Date(),
                                        Cliente,
                                        0,
                                        Moneda,
                                        1.0,      //Tipo de Cambio por default 1
                                        0,      //Cuenta Bancaria
                                        1,          //Pago Forma
                                        Total,          //Saldo
                                        Importe,    //Importe
                                        0,       += ImporteD * //FinanciamientoFactor;
                                        Descuento,
                                        SubTotal,
                                        Retencion1,
                                     += DescuentoD * Retencion2,Factor;
                                    SubTotal += SubTotalD * IEPS,Factor;
                                        IVA,
                                        0,          //ISH,
                                        Total,   += IVAD * //TotalFactor;
                                        Total,  Retencion1 += Retencion1D * //totalaplicado,Factor;
                                        "A",    Retencion2 += Retencion2D * //status,Factor;
                                        "",     IEPS += IEPSD * //usucariocancela,Factor;
                                        0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,Total 0.0,+= TotalD * //Numero1...Numero10Factor;
                                        Url, //Texto1
           = UrlD;
                            Direccion, = //Texto2DireccionD;
                                        "", "", "", "", "", "", "", "",                    Cliente = //Texto1...Texto10IdCliente;
                                        new Date(), new Date(), new Date(), new Date(), new Date(), new Date(),Moneda = //Fecha1...Texto6MonedaD;
                                        Observaciones,         //Observacion
                                        0, 0, 0, 0, 0, 0,         //Catalogo1...Catalogo6
                                        "",         //ordencompra
                                        0,          //concepto
                                        "",         //observacioncancelacion
                                        0,          //origenventacompra,
                                        0           //origeninventario
                               = );UltimoCobroObservacion;

                            }O_ResultadoEncabezado = O_WS.LLenarEncabezadoCXCP("I",    //Accion I
                        }else{            0,      //Id = 0
                            if        "",
                                    new Date(TotalApli),
 >                                   Cliente,
                                    0,
 || TotalApli ==                                 Moneda,
                                    1.0,      //Tipo de Cambio por default 1
                                    0,      //Cuenta Bancaria
                                    1,          //Pago Forma
                                    Total,          //Saldo
                                    Importe,    //Importe
                                    0,          //Financiamiento
                                    Descuento,
                                    SubTotal,
                                    Retencion1,
                                    Retencion2,
                                    IEPS,
                                    IVA,
                                    0,          //ISH,
                                    Total,      //Total
                                    Total,      //totalaplicado,
                                    "A",        //status,
                                    "",         //usucariocancela,
                                    0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,   //Numero1...Numero10
                                    Url, //Texto1
                                    Direccion,  //Texto2
                                    "", "", "", "", "", "", "", "",                      //Texto1...Texto10
                                    new Date(), {new Date(), new Date(), new Date(), new Date(), new Date(),  //Fecha1...Texto6
                                Factor = TotalApli  Observaciones,         //Observacion
 TotalD;                                   0, 0, 0, 0, 0, 0,         //Catalogo1...Catalogo6
                                    "",         //ordencompra
                                    0,          //concepto
                                    "",         //observacioncancelacion
                                    0,          //origenventacompra,
                                    0           //origeninventario
                            );

                                Importe += ImporteD * Factor;
                                Descuento += DescuentoD * Factor;
                                SubTotal += SubTotalD * Factor;
                                IVA += IVAD * Factor;
                                Retencion1 += Retencion1D * Factor;
                                Retencion2 += Retencion2D * Factor;
                                IEPS += IEPSD * Factor;
                                Total += TotalD * Factor;
                                Url = UrlD;}
                                Direccion = DireccionD;}else{
                          if (TotalApli > 0 || TotalApli Cliente== =0) IdCliente;{
                                MonedaFactor = MonedaD;
                                ObservacionesTotalApli =/ UltimoCobroObservacion;TotalD;

                                O_ResultadoEncabezado = O_WS.LLenarEncabezadoCXCP("I",    //Accion I
                                        0,      //Id = 0
                                        "",
                                        new Date(),
                                        Cliente,
                                        0,
                                        Moneda,
                                        1.0,      //Tipo de Cambio por default 1
                                        0,      //Cuenta Bancaria
                                        1,          //Pago Forma
                                        Total,          //Saldo
                                        Importe,    //Importe
                                        0,       += ImporteD * //FinanciamientoFactor;
                                        Descuento,
                                        SubTotal,
                                        Retencion1,
                                     += DescuentoD * Retencion2,Factor;
                                    SubTotal += SubTotalD * IEPS,Factor;
                                        IVA,
                                        0,          //ISH,
                                        Total,   += IVAD * //TotalFactor;
                                        Total,  Retencion1 += Retencion1D * //totalaplicado,Factor;
                                        "A",    Retencion2 += Retencion2D * //status,Factor;
                                        "",     IEPS += IEPSD * //usucariocancela,Factor;
                                        0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,Total 0.0,+= TotalD * //Numero1...Numero10Factor;
                                        Url, //Texto1
           = UrlD;
                            Direccion, = //Texto2DireccionD;
                                        "", "", "", "", "", "", "", "",                    Cliente = //Texto1...Texto10IdCliente;
                                        new Date(), new Date(), new Date(), new Date(), new Date(), new Date(),Moneda = //Fecha1...Texto6MonedaD;
                                        Observaciones,         //Observacion
                                        0, 0, 0, 0, 0, 0,         //Catalogo1...Catalogo6
                                        "",         //ordencompra
                                        0,          //concepto
                                        "",         //observacioncancelacion
                                        0,          //origenventacompra,
                                        0           //origeninventario
                               = );UltimoCobroObservacion;

                            }O_ResultadoEncabezado = O_WS.LLenarEncabezadoCXCP("I",    //Accion I
                                    0,      //Id = 0
                                    "",
                                    new Date(),
                                    Cliente,
                                    0,
                                    Moneda,
                                    1.0,      //Tipo de Cambio por default 1
                                    0,      //Cuenta Bancaria
                                    1,          //Pago Forma
                                    Total,          //Saldo
                                    Importe,    //Importe
                                    0,          //Financiamiento
                                    Descuento,
                                    SubTotal,
                                    Retencion1,
                                    Retencion2,
                                    IEPS,
                                    IVA,
                                    0,          //ISH,
                                    Total,      //Total
                                    Total,      //totalaplicado,
                                    "A",        //status,
                                    "",         //usucariocancela,
                                    0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,   //Numero1...Numero10
                                    Url, //Texto1
                                    Direccion,  //Texto2
                                    "", "", "", "", "", "", "", "",                      //Texto1...Texto10
                                    new Date(), new Date(), new Date(), new Date(), new Date(), new Date(),  //Fecha1...Texto6
                                    Observaciones,         //Observacion
                                    0, 0, 0, 0, 0, 0,         //Catalogo1...Catalogo6
                                    "",         //ordencompra
                                    0,          //concepto
                                    "",         //observacioncancelacion
                                    0,          //origenventacompra,
                                    0           //origeninventario
                            );

                        }

 
                    }

                    if (O_ResultadoEncabezado.ErrorId == 0) {
                        aRs.moveToFirst();

                            while (aRs.moveToNext()) {}

                                if (aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_TotalApli)) > 0 || aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelperO_ResultadoEncabezado.COLUMN_NAME_TotalApli))ErrorId == 0)
                                {
                                    DFactor = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_TotalApli)) / aRs.getDouble(aRs.getColumnIndexmoveToFirst(SqliteDB.DBhelper.COLUMN_NAME_Total));

                        while (aRs.moveToNext()) {

                            if (aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_TotalApli)) > 0 || aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_TotalApli)) == 0)
 Resultado                           {
                                DFactor = IntegeraRs.parseIntgetDouble(O_WSaRs.LLenarDetalleCXCPgetColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_TotalApli)) / aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Total));

                                            ("I", //Accion
                                                    0, //id
                                                    Id,  //Origen
                                                    aRs.getInt(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Documento)),  //OrigenDocumento
                                                    aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Importe)) * DFactor,   //Importe
                                                    (Double) 0.0,  //Financiamiento
                                                    aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Descuento)), //Descuento
                                                    aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_SubTotal)) * DFactor,   //Subtotal
                                                    aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Retencion1)) * DFactor, //Retencion1
                                                    aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Retencion2)) * DFactor,  //Retencion2
                                                    aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_IEPS)) * DFactor,   //IEPS
                                                    aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_IVA)) * DFactor, //IVA
                                                    (Double) 0.0, //ISH
                                                    aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Total)) * DFactor,  //Total
                                                    aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_SaldoD)),//Saldo
                                                    "Android App Desconectado"      //Referencia
                                            ));
                                }

                                Resultado = Integer.parseInt(O_WS.LLenarDetalleCXCP

                                        ("I", //Accion
                                                0, //id
                                                Id,  //Origen
                                                aRs.getInt(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Documento)),  //OrigenDocumento
                                                aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Importe)) * DFactor,   //Importe
                                                (Double) 0.0,  //Financiamiento
                                                aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Descuento)), //Descuento
                                                aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_SubTotal)) * DFactor,   //Subtotal
                                                aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Retencion1)) * DFactor, //Retencion1
                                                aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Retencion2)) * DFactor,  //Retencion2
                                                aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_IEPS)) * DFactor,   //IEPS
                                                aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_IVA)) * DFactor, //IVA
                                                (Double) 0.0, //ISH
                                                aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Total)) * DFactor,  //Total
                                                aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_SaldoD)),//Saldo
                                                "Android App Desconectado"      //Referencia
                                        ));
                            }

                        }
                }

                webService.STR_Resultado O_Resultado = null;

                if (Resultado == 0) {

                    ArrayList<DetalleMenu> ArrayMenu = new ArrayList<DetalleMenu>();
                    Cursor arS = querySql("SELECT * FROM " + SqliteDB.DBhelper.TABLE_NAME_Menu , null);
                    if (arS.getCount() > 0) {

                        while (arS.moveToNext()) {

                            DetalleMenu newDetalle = new DetalleMenu(
                                    (arS.getInt(arS.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_IdMenu))),
                                    (arS.getInt(arS.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_EmpresaM))),
                                    (arS.getString(arS.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_DescripcionMenu))),
                                    (arS.getString(arS.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Evento))),
                                    (arS.getInt(arS.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Modulo))),
                                    (arS.getInt(arS.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Operacion))),
                                    (arS.getInt(arS.getColumnIndex(SqliteDB.DBhelper.COLIMN_NAME_Documento))));
                            ArrayMenu.add(newDetalle);
                        }

                    }

                    for (int i=0; i< ArrayMenu.size();i++)
                    {
                        Modulo = ((DetalleMenu)ArrayMenu.get(i)).getModulo();
                        Operacion =  ((DetalleMenu)ArrayMenu.get(i)).getOperacion();
                        Documento =  ((DetalleMenu)ArrayMenu.get(i)).getDocumento();
                    }


                    O_Resultado = O_WS.GrabarCxCP(Modulo,      //Modulo
                            Operacion,      //Operacion
                            Documento,      //Documento
                            0,      //OrigenId
                            0);     //OrigenDocumento

                }

                //Se inicializan Variables
                ImporteD = 0.0;
                DescuentoD = 0.0;
                SubTotalD = 0.0;
                IVAD = 0.0;
                TotalD = 0.0;
                Importe = 0.0;
                Descuento = 0.0;
                SubTotal = 0.0;
                IVA = 0.0;
                Total = 0.0;
                TotalAplicado = 0.0;
            }
Cursor aRs = querySql("SELECT * FROM " + SqliteDB.DBhelper.TABLE_NAME_DETALLECLIENTE + " WHERE " + SqliteDB.DBhelper.COLUMN_NAME_Status + " = " + " '" + true + "'" + " AND CLiente=" + _Cliente +  " AND FechaCobro " + "=" + "'" + _Fecha + "'" , null);
                    SimpleDateFormat DateFormatterD  = new SimpleDateFormat("E MMM dd HH:mm:ss Z yyyy", Locale.ENGLISH);

                    if (aRs.getCount() > 0  || aRs.getCount() == _Cliente)  {
                        while (aRs.moveToNext()) {

                            Id = aRs.getInt(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_ID));
                            Folio = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Folio));
                            ClientClave = aRs.getInt(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_CLiente));
                            try {
                                Date Fecha = DateFormatterD.parse(aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Fecha)));
                            } catch (ParseException e) {
                                e.printStackTrace();
                            }
                            DocumentoD = aRs.getInt(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Documento));
                            DocumentoDescripcion = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_DocumentoDescripcion));
                            IdCliente = aRs.getInt(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_CLiente));
                            MonedaD = aRs.getInt(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_MonedaD));
                            ImporteD = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Importe));
                            DescuentoD = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Descuento));
                            SubTotalD = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_SubTotal));
                            Retencion1D = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Retencion1));
                            Retencion2D = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Retencion2));
                            IEPSD = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_IEPS));
                            IVAD = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_IVA));
                            TotalD = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Total));
                            Saldo = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_SaldoD));
                            Double SaldoVencido = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_SaldovencidoD));
                            String ParcialidadD = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Parcialidad));
                            Double ParcialidadTotal = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_ParcialidadTotal));
                            String PagoCondicionDescripcion = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_PagoCondicionDescripcion));
                            UltimoCobroObservacion = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_UltimoCobroObservacion));
                            TotalAplicado += aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_TotalApli));
                            TotalApli =  aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_TotalApli));
                            UrlD = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_URL));
                            DireccionD = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Direccion));

                        }
                        if (aRs.getCount() > 1)
                        {
                            if (TotalAplicado > 0 || TotalAplicado == 0 ) {
                                Factor = TotalAplicado / TotalD;

                                Importe += ImporteD * Factor;
                                Descuento += DescuentoD * Factor;
                                SubTotal += SubTotalD * Factor;
                                IVA += IVAD * Factor;
                                Retencion1 += Retencion1D * Factor;
                                Retencion2 += Retencion2D * Factor;
                                IEPS += IEPSD * Factor;
                                Total += TotalD * Factor;
                                Url = UrlD;
                                Direccion = DireccionD;
                                Cliente = IdCliente;
                                Moneda = MonedaD;
                                Observaciones = UltimoCobroObservacion;

                                O_ResultadoEncabezado = O_WS.LLenarEncabezadoCXCP("I",    //Accion I
                                        0,      //Id = 0
                                        "",
                                        new Date(),
                                        Cliente,
                                        0,
                                        Moneda,
                                        1.0,      //Tipo de Cambio por default 1
                                        0,      //Cuenta Bancaria
                                        1,          //Pago Forma
                                        Total,          //Saldo
                                        Importe,    //Importe
                                        0,          //Financiamiento
                                        Descuento,
                                        SubTotal,
                                        Retencion1,
                                        Retencion2,
                                        IEPS,
                                        IVA,
                                        0,          //ISH,
                                        Total,      //Total
                                        Total,      //totalaplicado,
                                        "A",        //status,
                                        "",         //usucariocancela,
                                        0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,   //Numero1...Numero10
                                        Url, //Texto1
                                        Direccion,  //Texto2
                                        "", "", "", "", "", "", "", "",                      //Texto1...Texto10
                                        new Date(), new Date(), new Date(), new Date(), new Date(), new Date(),  //Fecha1...Texto6
                                        Observaciones,         //Observacion
                                        0, 0, 0, 0, 0, 0,         //Catalogo1...Catalogo6
                                        "",         //ordencompra
                                        0,          //concepto
                                        "",         //observacioncancelacion
                                        0,          //origenventacompra,
                                        0           //origeninventario
                                );

                            }
                        }else{
                            if (TotalApli > 0 || TotalApli == 0) {
                                Factor = TotalApli / TotalD;

                                Importe += ImporteD * Factor;
                                Descuento += DescuentoD * Factor;
                                SubTotal += SubTotalD * Factor;
                                IVA += IVAD * Factor;
                                Retencion1 += Retencion1D * Factor;
                                Retencion2 += Retencion2D * Factor;
                                IEPS += IEPSD * Factor;
                                Total += TotalD * Factor;
                                Url = UrlD;
                                Direccion = DireccionD;
                                Cliente = IdCliente;
                                Moneda = MonedaD;
                                Observaciones = UltimoCobroObservacion;

                                O_ResultadoEncabezado = O_WS.LLenarEncabezadoCXCP("I",    //Accion I
                                        0,      //Id = 0
                                        "",
                                        new Date(),
                                        Cliente,
                                        0,
                                        Moneda,
                                        1.0,      //Tipo de Cambio por default 1
                                        0,      //Cuenta Bancaria
                                        1,          //Pago Forma
                                        Total,          //Saldo
                                        Importe,    //Importe
                                        0,          //Financiamiento
                                        Descuento,
                                        SubTotal,
                                        Retencion1,
                                        Retencion2,
                                        IEPS,
                                        IVA,
                                        0,          //ISH,
                                        Total,      //Total
                                        Total,      //totalaplicado,
                                        "A",        //status,
                                        "",         //usucariocancela,
                                        0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,   //Numero1...Numero10
                                        Url, //Texto1
                                        Direccion,  //Texto2
                                        "", "", "", "", "", "", "", "",                      //Texto1...Texto10
                                        new Date(), new Date(), new Date(), new Date(), new Date(), new Date(),  //Fecha1...Texto6
                                        Observaciones,         //Observacion
                                        0, 0, 0, 0, 0, 0,         //Catalogo1...Catalogo6
                                        "",         //ordencompra
                                        0,          //concepto
                                        "",         //observacioncancelacion
                                        0,          //origenventacompra,
                                        0           //origeninventario
                                );

                            }

                        }

 
                    }

                    if (O_ResultadoEncabezado.ErrorId == 0) {
                        aRs.moveToFirst();

                            while (aRs.moveToNext()) {

                                if (aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_TotalApli)) > 0 || aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_TotalApli)) == 0)
                                {
                                    DFactor = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_TotalApli)) / aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Total));


                                    Resultado = Integer.parseInt(O_WS.LLenarDetalleCXCP

                                            ("I", //Accion
                                                    0, //id
                                                    Id,  //Origen
                                                    aRs.getInt(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Documento)),  //OrigenDocumento
                                                    aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Importe)) * DFactor,   //Importe
                                                    (Double) 0.0,  //Financiamiento
                                                    aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Descuento)), //Descuento
                                                    aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_SubTotal)) * DFactor,   //Subtotal
                                                    aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Retencion1)) * DFactor, //Retencion1
                                                    aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Retencion2)) * DFactor,  //Retencion2
                                                    aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_IEPS)) * DFactor,   //IEPS
                                                    aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_IVA)) * DFactor, //IVA
                                                    (Double) 0.0, //ISH
                                                    aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Total)) * DFactor,  //Total
                                                    aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_SaldoD)),//Saldo
                                                    "Android App Desconectado"      //Referencia
                                            ));
                                }

                            }
                    }

Cursor aIds = querySql("SELECT DISTINCT CLiente, FechaCobro FROM " + SqliteDB.DBhelper.TABLE_NAME_DETALLECLIENTE + " WHERE " + SqliteDB.DBhelper.COLUMN_NAME_Status + " = " + " '" + true + "'", null); SimpleDateFormat DateFormatterd = new SimpleDateFormat("E MMM dd HH:mm:ss Z yyyy", Locale.ENGLISH); int cont = aIds.getCount(); if (aIds.getCount() > 0) { while (aIds.moveToNext()) { int _Cliente = aIds.getInt(aIds.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_CLiente)); Date _Fecha = null; try { _Fecha = (DateFormatterd.parse(aIds.getString(aIds.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_FechaCobro)))); } catch (ParseException e) { e.printStackTrace(); }

                Cursor aRs = querySql("SELECT * FROM " + SqliteDB.DBhelper.TABLE_NAME_DETALLECLIENTE + " WHERE " + SqliteDB.DBhelper.COLUMN_NAME_Status + " = " + " '" + true + "'" + " AND CLiente=" + _Cliente +  " AND FechaCobro " + "=" + "'" + _Fecha + "'" , null);
                SimpleDateFormat DateFormatterD  = new SimpleDateFormat("E MMM dd HH:mm:ss Z yyyy", Locale.ENGLISH);

                if (aRs.getCount() > 0  || aRs.getCount() == _Cliente)  {
                    while (aRs.moveToNext()) {

                        Id = aRs.getInt(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_ID));
                        Folio = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Folio));
                        ClientClave = aRs.getInt(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_CLiente));
                        try {
                            Date Fecha = DateFormatterD.parse(aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Fecha)));
                        } catch (ParseException e) {
                            e.printStackTrace();
                        }
                        DocumentoD = aRs.getInt(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Documento));
                        DocumentoDescripcion = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_DocumentoDescripcion));
                        IdCliente = aRs.getInt(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_CLiente));
                        MonedaD = aRs.getInt(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_MonedaD));
                        ImporteD = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Importe));
                        DescuentoD = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Descuento));
                        SubTotalD = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_SubTotal));
                        Retencion1D = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Retencion1));
                        Retencion2D = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Retencion2));
                        IEPSD = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_IEPS));
                        IVAD = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_IVA));
                        TotalD = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Total));
                        Saldo = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_SaldoD));
                        Double SaldoVencido = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_SaldovencidoD));
                        String ParcialidadD = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Parcialidad));
                        Double ParcialidadTotal = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_ParcialidadTotal));
                        String PagoCondicionDescripcion = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_PagoCondicionDescripcion));
                        UltimoCobroObservacion = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_UltimoCobroObservacion));
                        TotalAplicado += aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_TotalApli));
                        TotalApli =  aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_TotalApli));
                        UrlD = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_URL));
                        DireccionD = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Direccion));

                    }
                    if (aRs.getCount() > 1)
                    {
                        if (TotalAplicado > 0 || TotalAplicado == 0 ) {
                            Factor = TotalAplicado / TotalD;

                            Importe += ImporteD * Factor;
                            Descuento += DescuentoD * Factor;
                            SubTotal += SubTotalD * Factor;
                            IVA += IVAD * Factor;
                            Retencion1 += Retencion1D * Factor;
                            Retencion2 += Retencion2D * Factor;
                            IEPS += IEPSD * Factor;
                            Total += TotalD * Factor;
                            Url = UrlD;
                            Direccion = DireccionD;
                            Cliente = IdCliente;
                            Moneda = MonedaD;
                            Observaciones = UltimoCobroObservacion;

                            O_ResultadoEncabezado = O_WS.LLenarEncabezadoCXCP("I",    //Accion I
                                    0,      //Id = 0
                                    "",
                                    new Date(),
                                    Cliente,
                                    0,
                                    Moneda,
                                    1.0,      //Tipo de Cambio por default 1
                                    0,      //Cuenta Bancaria
                                    1,          //Pago Forma
                                    Total,          //Saldo
                                    Importe,    //Importe
                                    0,          //Financiamiento
                                    Descuento,
                                    SubTotal,
                                    Retencion1,
                                    Retencion2,
                                    IEPS,
                                    IVA,
                                    0,          //ISH,
                                    Total,      //Total
                                    Total,      //totalaplicado,
                                    "A",        //status,
                                    "",         //usucariocancela,
                                    0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,   //Numero1...Numero10
                                    Url, //Texto1
                                    Direccion,  //Texto2
                                    "", "", "", "", "", "", "", "",                      //Texto1...Texto10
                                    new Date(), new Date(), new Date(), new Date(), new Date(), new Date(),  //Fecha1...Texto6
                                    Observaciones,         //Observacion
                                    0, 0, 0, 0, 0, 0,         //Catalogo1...Catalogo6
                                    "",         //ordencompra
                                    0,          //concepto
                                    "",         //observacioncancelacion
                                    0,          //origenventacompra,
                                    0           //origeninventario
                            );

                        }
                    }else{
                        if (TotalApli > 0 || TotalApli == 0) {
                            Factor = TotalApli / TotalD;

                            Importe += ImporteD * Factor;
                            Descuento += DescuentoD * Factor;
                            SubTotal += SubTotalD * Factor;
                            IVA += IVAD * Factor;
                            Retencion1 += Retencion1D * Factor;
                            Retencion2 += Retencion2D * Factor;
                            IEPS += IEPSD * Factor;
                            Total += TotalD * Factor;
                            Url = UrlD;
                            Direccion = DireccionD;
                            Cliente = IdCliente;
                            Moneda = MonedaD;
                            Observaciones = UltimoCobroObservacion;

                            O_ResultadoEncabezado = O_WS.LLenarEncabezadoCXCP("I",    //Accion I
                                    0,      //Id = 0
                                    "",
                                    new Date(),
                                    Cliente,
                                    0,
                                    Moneda,
                                    1.0,      //Tipo de Cambio por default 1
                                    0,      //Cuenta Bancaria
                                    1,          //Pago Forma
                                    Total,          //Saldo
                                    Importe,    //Importe
                                    0,          //Financiamiento
                                    Descuento,
                                    SubTotal,
                                    Retencion1,
                                    Retencion2,
                                    IEPS,
                                    IVA,
                                    0,          //ISH,
                                    Total,      //Total
                                    Total,      //totalaplicado,
                                    "A",        //status,
                                    "",         //usucariocancela,
                                    0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,   //Numero1...Numero10
                                    Url, //Texto1
                                    Direccion,  //Texto2
                                    "", "", "", "", "", "", "", "",                      //Texto1...Texto10
                                    new Date(), new Date(), new Date(), new Date(), new Date(), new Date(),  //Fecha1...Texto6
                                    Observaciones,         //Observacion
                                    0, 0, 0, 0, 0, 0,         //Catalogo1...Catalogo6
                                    "",         //ordencompra
                                    0,          //concepto
                                    "",         //observacioncancelacion
                                    0,          //origenventacompra,
                                    0           //origeninventario
                            );

                        }

                    }


                }

                if (O_ResultadoEncabezado.ErrorId == 0) {
                    aRs.moveToFirst();

                        while (aRs.moveToNext()) {

                            if (aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_TotalApli)) > 0 || aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_TotalApli)) == 0)
                            {
                                DFactor = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_TotalApli)) / aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Total));


                                Resultado = Integer.parseInt(O_WS.LLenarDetalleCXCP

                                        ("I", //Accion
                                                0, //id
                                                Id,  //Origen
                                                aRs.getInt(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Documento)),  //OrigenDocumento
                                                aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Importe)) * DFactor,   //Importe
                                                (Double) 0.0,  //Financiamiento
                                                aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Descuento)), //Descuento
                                                aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_SubTotal)) * DFactor,   //Subtotal
                                                aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Retencion1)) * DFactor, //Retencion1
                                                aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Retencion2)) * DFactor,  //Retencion2
                                                aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_IEPS)) * DFactor,   //IEPS
                                                aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_IVA)) * DFactor, //IVA
                                                (Double) 0.0, //ISH
                                                aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Total)) * DFactor,  //Total
                                                aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_SaldoD)),//Saldo
                                                "Android App Desconectado"      //Referencia
                                        ));
                            }

                        }
                }

                webService.STR_Resultado O_Resultado = null;

                if (Resultado == 0) {

                    ArrayList<DetalleMenu> ArrayMenu = new ArrayList<DetalleMenu>();
                    Cursor arS = querySql("SELECT * FROM " + SqliteDB.DBhelper.TABLE_NAME_Menu , null);
                    if (arS.getCount() > 0) {

                        while (arS.moveToNext()) {

                            DetalleMenu newDetalle = new DetalleMenu(
                                    (arS.getInt(arS.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_IdMenu))),
                                    (arS.getInt(arS.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_EmpresaM))),
                                    (arS.getString(arS.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_DescripcionMenu))),
                                    (arS.getString(arS.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Evento))),
                                    (arS.getInt(arS.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Modulo))),
                                    (arS.getInt(arS.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Operacion))),
                                    (arS.getInt(arS.getColumnIndex(SqliteDB.DBhelper.COLIMN_NAME_Documento))));
                            ArrayMenu.add(newDetalle);
                        }

                    }

                    for (int i=0; i< ArrayMenu.size();i++)
                    {
                        Modulo = ((DetalleMenu)ArrayMenu.get(i)).getModulo();
                        Operacion =  ((DetalleMenu)ArrayMenu.get(i)).getOperacion();
                        Documento =  ((DetalleMenu)ArrayMenu.get(i)).getDocumento();
                    }


                    O_Resultado = O_WS.GrabarCxCP(Modulo,      //Modulo
                            Operacion,      //Operacion
                            Documento,      //Documento
                            0,      //OrigenId
                            0);     //OrigenDocumento

                }

                //Se inicializan Variables
                ImporteD = 0.0;
                DescuentoD = 0.0;
                SubTotalD = 0.0;
                IVAD = 0.0;
                TotalD = 0.0;
                Importe = 0.0;
                Descuento = 0.0;
                SubTotal = 0.0;
                IVA = 0.0;
                Total = 0.0;
                TotalAplicado = 0.0;
            }
se añadieron 768 caracteres en el cuerpo; etiquetas editadas
Origen Enlace
jasilva
  • 5.1k
  • 6
  • 32
  • 46

Cursor aRs = querySql("SELECT * FROM " + SqliteDB.DBhelper.TABLE_NAME_DETALLECLIENTE + " WHERE " + SqliteDB.DBhelper.COLUMN_NAME_Status + " = " + " '" + true + "'" + " AND CLiente=" + _Cliente + " AND FechaCobro " + "=" + "'" + _Fecha + "'" , null); SimpleDateFormat DateFormatterD = new SimpleDateFormat("E MMM dd HH:mm:ss Z yyyy", Locale.ENGLISH);

Cursor aRs = querySql("SELECT * FROM " + SqliteDB.DBhelper.TABLE_NAME_DETALLECLIENTE + " WHERE " + SqliteDB.DBhelper.COLUMN_NAME_Status + if" (aRs.getCount()= >" 0+ " ||'" aRs.getCount()+ ==true + "'" + " AND CLiente=" + _Cliente) + { " AND FechaCobro " + "=" + "'" + _Fecha + "'" , null);
                    whileSimpleDateFormat DateFormatterD  = new SimpleDateFormat(aRs"E MMM dd HH:mm:ss Z yyyy", Locale.moveToNext()ENGLISH) {;

                    if (aRs.getCount() > 0  || aRs.getCount() == _Cliente)  {
                        while (aRs.moveToNext()) {

                            Id = aRs.getInt(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_ID));
                            Folio = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Folio));
                            ClientClave = aRs.getInt(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_CLiente));
                            try {
                                Date Fecha = DateFormatterD.parse(aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Fecha)));
                            } catch (ParseException e) {
                                e.printStackTrace();
                            }
                            DocumentoD = aRs.getInt(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Documento));
                            DocumentoDescripcion = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_DocumentoDescripcion));
                            IdCliente = aRs.getInt(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_CLiente));
                            MonedaD = aRs.getInt(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_MonedaD));
                            ImporteD = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Importe));
                            DescuentoD = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Descuento));
                            SubTotalD = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_SubTotal));
                            Retencion1D = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Retencion1));
                            Retencion2D = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Retencion2));
                            IEPSD = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_IEPS));
                            IVAD = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_IVA));
                            TotalD = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Total));
                            Saldo = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_SaldoD));
                            Double SaldoVencido = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_SaldovencidoD));
                            String ParcialidadD = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Parcialidad));
                            Double ParcialidadTotal = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_ParcialidadTotal));
                            String PagoCondicionDescripcion = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_PagoCondicionDescripcion));
                            UltimoCobroObservacion = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_UltimoCobroObservacion));
                            TotalAplicado += aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_TotalApli));
                            TotalApli =  aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_TotalApli));
                            UrlD = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_URL));
                            DireccionD = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Direccion));

                        }
                        DocumentoD = aRs.getInt(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Documento));
                        DocumentoDescripcion = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_DocumentoDescripcion));
                        IdCliente = aRs.getInt(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_CLiente));
                        MonedaD = aRs.getInt(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_MonedaD));
                        ImporteD = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Importe));
                        DescuentoD = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Descuento));
                        SubTotalD = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_SubTotal));
                        Retencion1D = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Retencion1));
                        Retencion2D = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Retencion2));
                        IEPSD =if aRs.getDouble(aRs.getColumnIndexgetCount(SqliteDB.DBhelper.COLUMN_NAME_IEPS));
                        IVAD => aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_IVA)1);
                        TotalD = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Total));{
                        Saldo = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_SaldoD));
                        Double SaldoVencido =if aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_SaldovencidoD));
                    TotalAplicado > 0 || StringTotalAplicado ParcialidadD== =0 aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Parcialidad));
                        Double ParcialidadTotal = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_ParcialidadTotal));{
                        String PagoCondicionDescripcion = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_PagoCondicionDescripcion));
                        UltimoCobroObservacionFactor = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_UltimoCobroObservacion));
                        TotalAplicado += aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_TotalApli));
                        TotalApli =  aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_TotalApli));
                        UrlD = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_URL));
                        DireccionD =/ aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Direccion));TotalD;

                    }            Importe += ImporteD * Factor;
                    if (aRs.getCount() > 1)         Descuento += DescuentoD * Factor;
                    {            SubTotal += SubTotalD * Factor;
                        if (TotalAplicado > 0 || TotalAplicado == 0 )IVA {+= IVAD * Factor;
                            Factor    Retencion1 += Retencion1D * Factor;
                                Retencion2 += Retencion2D * Factor;
                                IEPS += IEPSD * Factor;
                                Total += TotalD * Factor;
                                Url = TotalAplicadoUrlD;
 / TotalD;                              Direccion = DireccionD;
                                Cliente = IdCliente;
                                Moneda = MonedaD;
                                Observaciones = UltimoCobroObservacion;

                                O_ResultadoEncabezado = O_WS.LLenarEncabezadoCXCP("I",    //Accion I
                                        0,      //Id = 0
                                        "",
                                        new Date(),
                                        Cliente,
                                        0,
                                        Moneda,
                                        1.0,      //Tipo de Cambio por default 1
                                        0,      //Cuenta Bancaria
                                        1,          //Pago Forma
                                        Total,          //Saldo
                                        Importe, += ImporteD * Factor;//Importe
                            Descuento += DescuentoD * Factor;        0,          //Financiamiento
                            SubTotal += SubTotalD * Factor;        Descuento,
                            IVA += IVAD * Factor;        SubTotal,
                            Retencion1 += Retencion1D * Factor;        Retencion1,
                            Retencion2 += Retencion2D * Factor;        Retencion2,
                                        IEPS,
 += IEPSD * Factor;                                    IVA,
                                        0,          //ISH,
                                        Total, += TotalD * Factor;  //Total
                            Url = UrlD;          Total,      //totalaplicado,
                                        "A",        //status,
                                        "",         //usucariocancela,
                                        0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,   //Numero1...Numero10
                                        Url, //Texto1
                                        Direccion, = DireccionD;//Texto2
                            Cliente = IdCliente;          "", "", "", "", "", "", "", "",                      //Texto1...Texto10
                            Moneda = MonedaD;          new Date(), new Date(), new Date(), new Date(), new Date(), new Date(),  //Fecha1...Texto6
                                        Observaciones, = UltimoCobroObservacion;       //Observacion
                                        0, 0, 0, 0, 0, 0,         //Catalogo1...Catalogo6
                                        "",         //ordencompra
                                        0,          //concepto
                                        "",         //observacioncancelacion
                                        0,          //origenventacompra,
                                        0           //origeninventario
                                );

                            O_ResultadoEncabezado = O_WS.LLenarEncabezadoCXCP("I",    //Accion I
                                    0,      //Id = 0}
                                    "",}else{
                                    newif Date(),
                                    Cliente,
                                    0,
                                    Moneda,
                                    1.0,      //Tipo de Cambio por default 1
                                    0,      //Cuenta Bancaria
                                    1,          //Pago Forma
                                    Total,          //Saldo
                                    Importe,    //Importe
                                    0,          //Financiamiento
                                    Descuento,
                                    SubTotal,
                                    Retencion1,
                                    Retencion2,
                                    IEPS,
                                    IVA,
                                    0,          //ISH,
                                    Total,      //Total
                                    Total,      //totalaplicado,
                                    "A",        //status,
                                    "",         //usucariocancela,
                                    0.0, 0.0, 0.0,TotalApli 0.0,> 0.0, 0.0, 0.0,|| 0.0,TotalApli 0.0,== 0.0,   //Numero1...Numero10
                                    Url, //Texto1
                                    Direccion,  //Texto2
                                    "", "", "", "", "", "", "", "",                      //Texto1...Texto10
                                    new Date(), new Date(), new Date(), new Date(), new Date(), new Date(),  //Fecha1...Texto6
                                    Observaciones,         //Observacion
                                    0, 0, 0, 0, 0, 0,         //Catalogo1...Catalogo6
                                    "",         //ordencompra
                                    0,          //concepto
                                    "",         //observacioncancelacion
                                    0,          //origenventacompra,{
                                    0        Factor = TotalApli //origeninventario
                            );TotalD;

                        }        Importe += ImporteD * Factor;
                    }else{            Descuento += DescuentoD * Factor;
                        if (TotalApli > 0 || TotalApli == 0) {SubTotal += SubTotalD * Factor;
                            Factor    IVA += IVAD * Factor;
                                Retencion1 += Retencion1D * Factor;
                                Retencion2 += Retencion2D * Factor;
                                IEPS += IEPSD * Factor;
                                Total += TotalD * Factor;
                                Url = TotalApliUrlD;
 / TotalD;                              Direccion = DireccionD;
                                Cliente = IdCliente;
                                Moneda = MonedaD;
                                Observaciones = UltimoCobroObservacion;

                                O_ResultadoEncabezado = O_WS.LLenarEncabezadoCXCP("I",    //Accion I
                                        0,      //Id = 0
                                        "",
                                        new Date(),
                                        Cliente,
                                        0,
                                        Moneda,
                                        1.0,      //Tipo de Cambio por default 1
                                        0,      //Cuenta Bancaria
                                        1,          //Pago Forma
                                        Total,          //Saldo
                                        Importe, += ImporteD * Factor;//Importe
                            Descuento += DescuentoD * Factor;        0,          //Financiamiento
                            SubTotal += SubTotalD * Factor;        Descuento,
                            IVA += IVAD * Factor;        SubTotal,
                            Retencion1 += Retencion1D * Factor;        Retencion1,
                            Retencion2 += Retencion2D * Factor;        Retencion2,
                                        IEPS,
 += IEPSD * Factor;                                    IVA,
                                        0,          //ISH,
                                        Total, += TotalD * Factor;  //Total
                            Url = UrlD;          Total,      //totalaplicado,
                                        "A",        //status,
                                        "",         //usucariocancela,
                                        0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,   //Numero1...Numero10
                                        Url, //Texto1
                                        Direccion, = DireccionD;//Texto2
                            Cliente = IdCliente;          "", "", "", "", "", "", "", "",                      //Texto1...Texto10
                            Moneda = MonedaD;          new Date(), new Date(), new Date(), new Date(), new Date(), new Date(),  //Fecha1...Texto6
                                        Observaciones, = UltimoCobroObservacion;       //Observacion
                                        0, 0, 0, 0, 0, 0,         //Catalogo1...Catalogo6
                                        "",         //ordencompra
                                        0,          //concepto
                                        "",         //observacioncancelacion
                                        0,          //origenventacompra,
                                        0           //origeninventario
                                );

                            O_ResultadoEncabezado = O_WS.LLenarEncabezadoCXCP("I",    //Accion I
                                    0,      //Id = 0
                                    "",
                                    new Date(),
                                    Cliente,
                                    0,
                                    Moneda,
                                    1.0,      //Tipo de Cambio por default 1
                                    0,      //Cuenta Bancaria
                                    1,          //Pago Forma
                                    Total,          //Saldo
                                    Importe,    //Importe
                                    0,          //Financiamiento
                                    Descuento,
                                    SubTotal,
                                    Retencion1,
                                    Retencion2,
                                    IEPS,
                                    IVA,
                                    0,          //ISH,
                                    Total,      //Total
                                    Total,      //totalaplicado,
                                    "A",        //status,
                                    "",         //usucariocancela,
                                    0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,   //Numero1...Numero10
                                    Url, //Texto1
                                    Direccion,  //Texto2
                                    "", "", "", "", "", "", "", "",                      //Texto1...Texto10
                                    new Date(), new Date(), new Date(), new Date(), new Date(), new Date(),  //Fecha1...Texto6
                                    Observaciones,         //Observacion
                                    0, 0, 0, 0, 0, 0,         //Catalogo1...Catalogo6
                                    "",         //ordencompra
                                    0,          //concepto
                                    "",         //observacioncancelacion
                                    0,          //origenventacompra,
                                    0           //origeninventario
                            );}

                        }
 

                    }

                    if (O_ResultadoEncabezado.ErrorId == 0) {
                        aRs.moveToFirst();

                }            while (aRs.moveToNext()) {

                                if (O_ResultadoEncabezadoaRs.ErrorIdgetDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_TotalApli)) > 0 || aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_TotalApli)) == 0)
                                {
                                    DFactor = aRs.moveToFirstgetDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_TotalApli)) / aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Total));

                        while (aRs.moveToNext()) {

                            if (aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_TotalApli)) > 0 || aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_TotalApli)) == 0)
                            {
                                DFactorResultado = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_TotalApli)) / aRs.getDouble(aRsInteger.getColumnIndexparseInt(SqliteDB.DBhelperO_WS.COLUMN_NAME_Total));
LLenarDetalleCXCP

                                Resultado = Integer          ("I", //Accion
                                                    0, //id
                                                    Id,  //Origen
                                                    aRs.parseIntgetInt(O_WSaRs.LLenarDetalleCXCPgetColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Documento)),  //OrigenDocumento
                                                    aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Importe)) * DFactor,   //Importe
                                                    (Double) 0.0,  //Financiamiento
                                                    aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Descuento)), //Descuento
                                                    aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_SubTotal)) * DFactor,   //Subtotal
                                                    aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Retencion1)) * DFactor, //Retencion1
                                                    aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Retencion2)) * DFactor,  //Retencion2
                                                    aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_IEPS)) * DFactor,   //IEPS
                                                    aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_IVA)) * DFactor, //IVA
                                                    (Double) 0.0, //ISH
                                                    aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Total)) * DFactor,  //Total
                                                    aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_SaldoD)),//Saldo
                                                    "Android App Desconectado"      //Referencia
                                            ));
                                }

                                        ("I", //Accion
                                                0, //id
                                                Id,  //Origen
                                                aRs.getInt(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Documento)),  //OrigenDocumento
                                                aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Importe)) * DFactor,   //Importe
                                                (Double) 0.0,  //Financiamiento
                                                aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Descuento)), //Descuento
                                                aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_SubTotal)) * DFactor,   //Subtotal
                                                aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Retencion1)) * DFactor, //Retencion1
                                                aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Retencion2)) * DFactor,  //Retencion2
                                                aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_IEPS)) * DFactor,   //IEPS
                                                aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_IVA)) * DFactor, //IVA
                                                (Double) 0.0, //ISH
                                                aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Total)) * DFactor,  //Total
                                                aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_SaldoD)),//Saldo
                                                "Android App Desconectado"      //Referencia
                                        ));
                            }

                        }
                }

Cursor aRs = querySql("SELECT * FROM " + SqliteDB.DBhelper.TABLE_NAME_DETALLECLIENTE + " WHERE " + SqliteDB.DBhelper.COLUMN_NAME_Status + " = " + " '" + true + "'" + " AND CLiente=" + _Cliente + " AND FechaCobro " + "=" + "'" + _Fecha + "'" , null); SimpleDateFormat DateFormatterD = new SimpleDateFormat("E MMM dd HH:mm:ss Z yyyy", Locale.ENGLISH);

                if (aRs.getCount() > 0  || aRs.getCount() == _Cliente)  {
                    while (aRs.moveToNext()) {

                        Id = aRs.getInt(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_ID));
                        Folio = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Folio));
                        ClientClave = aRs.getInt(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_CLiente));
                        try {
                            Date Fecha = DateFormatterD.parse(aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Fecha)));
                        } catch (ParseException e) {
                            e.printStackTrace();
                        }
                        DocumentoD = aRs.getInt(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Documento));
                        DocumentoDescripcion = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_DocumentoDescripcion));
                        IdCliente = aRs.getInt(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_CLiente));
                        MonedaD = aRs.getInt(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_MonedaD));
                        ImporteD = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Importe));
                        DescuentoD = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Descuento));
                        SubTotalD = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_SubTotal));
                        Retencion1D = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Retencion1));
                        Retencion2D = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Retencion2));
                        IEPSD = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_IEPS));
                        IVAD = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_IVA));
                        TotalD = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Total));
                        Saldo = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_SaldoD));
                        Double SaldoVencido = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_SaldovencidoD));
                        String ParcialidadD = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Parcialidad));
                        Double ParcialidadTotal = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_ParcialidadTotal));
                        String PagoCondicionDescripcion = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_PagoCondicionDescripcion));
                        UltimoCobroObservacion = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_UltimoCobroObservacion));
                        TotalAplicado += aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_TotalApli));
                        TotalApli =  aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_TotalApli));
                        UrlD = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_URL));
                        DireccionD = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Direccion));

                    }
                    if (aRs.getCount() > 1)
                    {
                        if (TotalAplicado > 0 || TotalAplicado == 0 ) {
                            Factor = TotalAplicado / TotalD;

                            Importe += ImporteD * Factor;
                            Descuento += DescuentoD * Factor;
                            SubTotal += SubTotalD * Factor;
                            IVA += IVAD * Factor;
                            Retencion1 += Retencion1D * Factor;
                            Retencion2 += Retencion2D * Factor;
                            IEPS += IEPSD * Factor;
                            Total += TotalD * Factor;
                            Url = UrlD;
                            Direccion = DireccionD;
                            Cliente = IdCliente;
                            Moneda = MonedaD;
                            Observaciones = UltimoCobroObservacion;

                            O_ResultadoEncabezado = O_WS.LLenarEncabezadoCXCP("I",    //Accion I
                                    0,      //Id = 0
                                    "",
                                    new Date(),
                                    Cliente,
                                    0,
                                    Moneda,
                                    1.0,      //Tipo de Cambio por default 1
                                    0,      //Cuenta Bancaria
                                    1,          //Pago Forma
                                    Total,          //Saldo
                                    Importe,    //Importe
                                    0,          //Financiamiento
                                    Descuento,
                                    SubTotal,
                                    Retencion1,
                                    Retencion2,
                                    IEPS,
                                    IVA,
                                    0,          //ISH,
                                    Total,      //Total
                                    Total,      //totalaplicado,
                                    "A",        //status,
                                    "",         //usucariocancela,
                                    0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,   //Numero1...Numero10
                                    Url, //Texto1
                                    Direccion,  //Texto2
                                    "", "", "", "", "", "", "", "",                      //Texto1...Texto10
                                    new Date(), new Date(), new Date(), new Date(), new Date(), new Date(),  //Fecha1...Texto6
                                    Observaciones,         //Observacion
                                    0, 0, 0, 0, 0, 0,         //Catalogo1...Catalogo6
                                    "",         //ordencompra
                                    0,          //concepto
                                    "",         //observacioncancelacion
                                    0,          //origenventacompra,
                                    0           //origeninventario
                            );

                        }
                    }else{
                        if (TotalApli > 0 || TotalApli == 0) {
                            Factor = TotalApli / TotalD;

                            Importe += ImporteD * Factor;
                            Descuento += DescuentoD * Factor;
                            SubTotal += SubTotalD * Factor;
                            IVA += IVAD * Factor;
                            Retencion1 += Retencion1D * Factor;
                            Retencion2 += Retencion2D * Factor;
                            IEPS += IEPSD * Factor;
                            Total += TotalD * Factor;
                            Url = UrlD;
                            Direccion = DireccionD;
                            Cliente = IdCliente;
                            Moneda = MonedaD;
                            Observaciones = UltimoCobroObservacion;

                            O_ResultadoEncabezado = O_WS.LLenarEncabezadoCXCP("I",    //Accion I
                                    0,      //Id = 0
                                    "",
                                    new Date(),
                                    Cliente,
                                    0,
                                    Moneda,
                                    1.0,      //Tipo de Cambio por default 1
                                    0,      //Cuenta Bancaria
                                    1,          //Pago Forma
                                    Total,          //Saldo
                                    Importe,    //Importe
                                    0,          //Financiamiento
                                    Descuento,
                                    SubTotal,
                                    Retencion1,
                                    Retencion2,
                                    IEPS,
                                    IVA,
                                    0,          //ISH,
                                    Total,      //Total
                                    Total,      //totalaplicado,
                                    "A",        //status,
                                    "",         //usucariocancela,
                                    0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,   //Numero1...Numero10
                                    Url, //Texto1
                                    Direccion,  //Texto2
                                    "", "", "", "", "", "", "", "",                      //Texto1...Texto10
                                    new Date(), new Date(), new Date(), new Date(), new Date(), new Date(),  //Fecha1...Texto6
                                    Observaciones,         //Observacion
                                    0, 0, 0, 0, 0, 0,         //Catalogo1...Catalogo6
                                    "",         //ordencompra
                                    0,          //concepto
                                    "",         //observacioncancelacion
                                    0,          //origenventacompra,
                                    0           //origeninventario
                            );

                        }

                    }


                }

                if (O_ResultadoEncabezado.ErrorId == 0) {
                    aRs.moveToFirst();

                        while (aRs.moveToNext()) {

                            if (aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_TotalApli)) > 0 || aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_TotalApli)) == 0)
                            {
                                DFactor = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_TotalApli)) / aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Total));


                                Resultado = Integer.parseInt(O_WS.LLenarDetalleCXCP

                                        ("I", //Accion
                                                0, //id
                                                Id,  //Origen
                                                aRs.getInt(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Documento)),  //OrigenDocumento
                                                aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Importe)) * DFactor,   //Importe
                                                (Double) 0.0,  //Financiamiento
                                                aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Descuento)), //Descuento
                                                aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_SubTotal)) * DFactor,   //Subtotal
                                                aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Retencion1)) * DFactor, //Retencion1
                                                aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Retencion2)) * DFactor,  //Retencion2
                                                aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_IEPS)) * DFactor,   //IEPS
                                                aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_IVA)) * DFactor, //IVA
                                                (Double) 0.0, //ISH
                                                aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Total)) * DFactor,  //Total
                                                aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_SaldoD)),//Saldo
                                                "Android App Desconectado"      //Referencia
                                        ));
                            }

                        }
                }
Cursor aRs = querySql("SELECT * FROM " + SqliteDB.DBhelper.TABLE_NAME_DETALLECLIENTE + " WHERE " + SqliteDB.DBhelper.COLUMN_NAME_Status + " = " + " '" + true + "'" + " AND CLiente=" + _Cliente +  " AND FechaCobro " + "=" + "'" + _Fecha + "'" , null);
                    SimpleDateFormat DateFormatterD  = new SimpleDateFormat("E MMM dd HH:mm:ss Z yyyy", Locale.ENGLISH);

                    if (aRs.getCount() > 0  || aRs.getCount() == _Cliente)  {
                        while (aRs.moveToNext()) {

                            Id = aRs.getInt(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_ID));
                            Folio = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Folio));
                            ClientClave = aRs.getInt(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_CLiente));
                            try {
                                Date Fecha = DateFormatterD.parse(aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Fecha)));
                            } catch (ParseException e) {
                                e.printStackTrace();
                            }
                            DocumentoD = aRs.getInt(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Documento));
                            DocumentoDescripcion = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_DocumentoDescripcion));
                            IdCliente = aRs.getInt(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_CLiente));
                            MonedaD = aRs.getInt(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_MonedaD));
                            ImporteD = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Importe));
                            DescuentoD = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Descuento));
                            SubTotalD = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_SubTotal));
                            Retencion1D = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Retencion1));
                            Retencion2D = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Retencion2));
                            IEPSD = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_IEPS));
                            IVAD = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_IVA));
                            TotalD = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Total));
                            Saldo = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_SaldoD));
                            Double SaldoVencido = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_SaldovencidoD));
                            String ParcialidadD = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Parcialidad));
                            Double ParcialidadTotal = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_ParcialidadTotal));
                            String PagoCondicionDescripcion = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_PagoCondicionDescripcion));
                            UltimoCobroObservacion = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_UltimoCobroObservacion));
                            TotalAplicado += aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_TotalApli));
                            TotalApli =  aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_TotalApli));
                            UrlD = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_URL));
                            DireccionD = aRs.getString(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Direccion));

                        }
                        if (aRs.getCount() > 1)
                        {
                            if (TotalAplicado > 0 || TotalAplicado == 0 ) {
                                Factor = TotalAplicado / TotalD;

                                Importe += ImporteD * Factor;
                                Descuento += DescuentoD * Factor;
                                SubTotal += SubTotalD * Factor;
                                IVA += IVAD * Factor;
                                Retencion1 += Retencion1D * Factor;
                                Retencion2 += Retencion2D * Factor;
                                IEPS += IEPSD * Factor;
                                Total += TotalD * Factor;
                                Url = UrlD;
                                Direccion = DireccionD;
                                Cliente = IdCliente;
                                Moneda = MonedaD;
                                Observaciones = UltimoCobroObservacion;

                                O_ResultadoEncabezado = O_WS.LLenarEncabezadoCXCP("I",    //Accion I
                                        0,      //Id = 0
                                        "",
                                        new Date(),
                                        Cliente,
                                        0,
                                        Moneda,
                                        1.0,      //Tipo de Cambio por default 1
                                        0,      //Cuenta Bancaria
                                        1,          //Pago Forma
                                        Total,          //Saldo
                                        Importe,    //Importe
                                        0,          //Financiamiento
                                        Descuento,
                                        SubTotal,
                                        Retencion1,
                                        Retencion2,
                                        IEPS,
                                        IVA,
                                        0,          //ISH,
                                        Total,      //Total
                                        Total,      //totalaplicado,
                                        "A",        //status,
                                        "",         //usucariocancela,
                                        0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,   //Numero1...Numero10
                                        Url, //Texto1
                                        Direccion,  //Texto2
                                        "", "", "", "", "", "", "", "",                      //Texto1...Texto10
                                        new Date(), new Date(), new Date(), new Date(), new Date(), new Date(),  //Fecha1...Texto6
                                        Observaciones,         //Observacion
                                        0, 0, 0, 0, 0, 0,         //Catalogo1...Catalogo6
                                        "",         //ordencompra
                                        0,          //concepto
                                        "",         //observacioncancelacion
                                        0,          //origenventacompra,
                                        0           //origeninventario
                                );

                            }
                        }else{
                            if (TotalApli > 0 || TotalApli == 0) {
                                Factor = TotalApli / TotalD;

                                Importe += ImporteD * Factor;
                                Descuento += DescuentoD * Factor;
                                SubTotal += SubTotalD * Factor;
                                IVA += IVAD * Factor;
                                Retencion1 += Retencion1D * Factor;
                                Retencion2 += Retencion2D * Factor;
                                IEPS += IEPSD * Factor;
                                Total += TotalD * Factor;
                                Url = UrlD;
                                Direccion = DireccionD;
                                Cliente = IdCliente;
                                Moneda = MonedaD;
                                Observaciones = UltimoCobroObservacion;

                                O_ResultadoEncabezado = O_WS.LLenarEncabezadoCXCP("I",    //Accion I
                                        0,      //Id = 0
                                        "",
                                        new Date(),
                                        Cliente,
                                        0,
                                        Moneda,
                                        1.0,      //Tipo de Cambio por default 1
                                        0,      //Cuenta Bancaria
                                        1,          //Pago Forma
                                        Total,          //Saldo
                                        Importe,    //Importe
                                        0,          //Financiamiento
                                        Descuento,
                                        SubTotal,
                                        Retencion1,
                                        Retencion2,
                                        IEPS,
                                        IVA,
                                        0,          //ISH,
                                        Total,      //Total
                                        Total,      //totalaplicado,
                                        "A",        //status,
                                        "",         //usucariocancela,
                                        0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,   //Numero1...Numero10
                                        Url, //Texto1
                                        Direccion,  //Texto2
                                        "", "", "", "", "", "", "", "",                      //Texto1...Texto10
                                        new Date(), new Date(), new Date(), new Date(), new Date(), new Date(),  //Fecha1...Texto6
                                        Observaciones,         //Observacion
                                        0, 0, 0, 0, 0, 0,         //Catalogo1...Catalogo6
                                        "",         //ordencompra
                                        0,          //concepto
                                        "",         //observacioncancelacion
                                        0,          //origenventacompra,
                                        0           //origeninventario
                                );

                            }

                        }
 

                    }

                    if (O_ResultadoEncabezado.ErrorId == 0) {
                        aRs.moveToFirst();

                            while (aRs.moveToNext()) {

                                if (aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_TotalApli)) > 0 || aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_TotalApli)) == 0)
                                {
                                    DFactor = aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_TotalApli)) / aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Total));


                                    Resultado = Integer.parseInt(O_WS.LLenarDetalleCXCP

                                            ("I", //Accion
                                                    0, //id
                                                    Id,  //Origen
                                                    aRs.getInt(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Documento)),  //OrigenDocumento
                                                    aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Importe)) * DFactor,   //Importe
                                                    (Double) 0.0,  //Financiamiento
                                                    aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Descuento)), //Descuento
                                                    aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_SubTotal)) * DFactor,   //Subtotal
                                                    aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Retencion1)) * DFactor, //Retencion1
                                                    aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Retencion2)) * DFactor,  //Retencion2
                                                    aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_IEPS)) * DFactor,   //IEPS
                                                    aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_IVA)) * DFactor, //IVA
                                                    (Double) 0.0, //ISH
                                                    aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_Total)) * DFactor,  //Total
                                                    aRs.getDouble(aRs.getColumnIndex(SqliteDB.DBhelper.COLUMN_NAME_SaldoD)),//Saldo
                                                    "Android App Desconectado"      //Referencia
                                            ));
                                }

                            }
                    }
Origen Enlace
Loading