new EntityExpr("paymentMethodTypeId", EntityOperator.EQUALS, "EXT_BILLACT"),
new EntityExpr("statusId", EntityOperator.NOT_IN, UtilMisc.toList("ORDER_CANCELLED", "ORDER_REJECTED")),
new EntityExpr("preferenceStatusId", EntityOperator.NOT_IN, UtilMisc.toList("PAYMENT_SETTLED", "PAYMENT_RECEIVED", "PAYMENT_DECLINED", "PAYMENT_CANCELLED")) // PAYMENT_NOT_AUTH
), EntityOperator.AND);
List orderPaymentPreferenceSums = delegator.findByCondition("OrderPurchasePaymentSummary", whereConditions, null, UtilMisc.toList("maxAmount"), null, null);
if (orderPaymentPreferenceSums != null) {
for (Iterator oppsi = orderPaymentPreferenceSums.iterator(); oppsi.hasNext(); ) {
GenericValue orderPaymentPreferenceSum = (GenericValue) oppsi.next();
balance = balance.subtract(orderPaymentPreferenceSum.getBigDecimal("maxAmount"));
}