saludos
quisiera saber si alguien me pudiera ayudar trato de embiar 2 objetos json los cuales cada uno contendria un array basado en una consulta dada pero al estar enviando solo uno y pidiendo los datos de la misma me manda unidos los datos de las 2 consultas
public JSONObject getSaldos(BusinessPartner businessPartner) throws JSONException {
JSONObject saldos = new JSONObject();
JSONObject saldos2 = new JSONObject();
JSONArray saldosProveedor = new JSONArray();
JSONArray saldosCliente = new JSONArray();
for (FIN_Payment payment : businessPartner.getFINPaymentList()) {
// para ser saldo debe ser diferente de 0
if (payment.getGeneratedCredit().compareTo(new BigDecimal(0)) == 0 || payment.getGeneratedCredit().subtract(payment.getU sedCredit()).compareTo(new BigDecimal("0")) == 0 || !payment.isReceipt()) {
continue;
}
JSONObject paymentJSON = new JSONObject();
paymentJSON.put("id", payment.getId());
paymentJSON.put("documentno", payment.getDocumentNo());
paymentJSON.put("generatedCredit", payment.getGeneratedCredit());
paymentJSON.put("usedCredit", payment.getUsedCredit());
paymentJSON.put("saldo", payment.getGeneratedCredit().subtract(payment.getU sedCredit()));
// Por default es lo mismo que el saldo
paymentJSON.put("monto", payment.getGeneratedCredit().subtract(payment.getU sedCredit()));
paymentJSON.put("currency", ConversionRateHandler.currencyToJSON(payment.getCu rrency()));
paymentJSON.put("descripcion", payment.isReceipt());
saldosProveedor.put(paymentJSON);
}
saldos2.put("proveedor", saldosProveedor);
for (FIN_Payment payment : businessPartner.getFINPaymentList()) {
// para ser saldo debe ser diferente de 0
if (payment.getGeneratedCredit().compareTo(new BigDecimal(0)) == 0 || payment.getGeneratedCredit().subtract(payment.getU sedCredit()).compareTo(new BigDecimal("0")) == 0 || payment.isReceipt()) {
continue;
}
JSONObject paymentJSON = new JSONObject();
paymentJSON.put("id", payment.getId());
paymentJSON.put("documentno", payment.getDocumentNo());
paymentJSON.put("generatedCredit", payment.getGeneratedCredit());
paymentJSON.put("usedCredit", payment.getUsedCredit());
paymentJSON.put("saldo", payment.getGeneratedCredit().subtract(payment.getU sedCredit()));
// Por default es lo mismo que el saldo
paymentJSON.put("monto", payment.getGeneratedCredit().subtract(payment.getU sedCredit()));
paymentJSON.put("currency", ConversionRateHandler.currencyToJSON(payment.getCu rrency()));
paymentJSON.put("descripcion", payment.isReceipt());
saldosProveedor.put(paymentJSON);
}
saldos2.put("proveedor2", saldosProveedor);
return saldos2;
}