exprs.add(EntityCondition.makeCondition("statusId", EntityOperator.NOT_EQUAL, "PAYMENT_RECEIVED"));
exprs.add(EntityCondition.makeCondition("statusId", EntityOperator.NOT_EQUAL, "PAYMENT_CANCELLED"));
exprs.add(EntityCondition.makeCondition("statusId", EntityOperator.NOT_EQUAL, "PAYMENT_DECLINED"));
exprs.add(EntityCondition.makeCondition("statusId", EntityOperator.NOT_EQUAL, "PAYMENT_SETTLED"));
exprs.add(EntityCondition.makeCondition("statusId", EntityOperator.NOT_EQUAL, "PAYMENT_REFUNDED"));
EntityCondition cond = EntityCondition.makeCondition(exprs, EntityOperator.AND);
paymentPrefsToCancel = delegator.findList("OrderPaymentPreference", cond, null, null, null, false);
} catch (GenericEntityException e) {
Debug.logError(e, module);
throw new GeneralException(e.getMessage());
}
if (paymentPrefsToCancel != null) {
Iterator<GenericValue> oppi = paymentPrefsToCancel.iterator();
while (oppi.hasNext()) {
GenericValue opp = oppi.next();
try {
opp.set("statusId", "PAYMENT_CANCELLED");
opp.store();
} catch (GenericEntityException e) {
Debug.logError(e, module);
throw new GeneralException(e.getMessage());
}
}
}
// remove the adjustments
try {
List<EntityCondition> adjExprs = new LinkedList<EntityCondition>();
adjExprs.add(EntityCondition.makeCondition("orderId", EntityOperator.EQUALS, orderId));
List<EntityCondition> exprs = new LinkedList<EntityCondition>();
exprs.add(EntityCondition.makeCondition("orderAdjustmentTypeId", EntityOperator.EQUALS, "PROMOTION_ADJUSTMENT"));
exprs.add(EntityCondition.makeCondition("orderAdjustmentTypeId", EntityOperator.EQUALS, "SHIPPING_CHARGES"));
exprs.add(EntityCondition.makeCondition("orderAdjustmentTypeId", EntityOperator.EQUALS, "SALES_TAX"));
exprs.add(EntityCondition.makeCondition("orderAdjustmentTypeId", EntityOperator.EQUALS, "VAT_TAX"));
exprs.add(EntityCondition.makeCondition("orderAdjustmentTypeId", EntityOperator.EQUALS, "VAT_PRICE_CORRECT"));
adjExprs.add(EntityCondition.makeCondition(exprs, EntityOperator.OR));
EntityCondition cond = EntityCondition.makeCondition(adjExprs, EntityOperator.AND);
delegator.removeByCondition("OrderAdjustment", cond);
} catch (GenericEntityException e) {
Debug.logError(e, module);
throw new GeneralException(e.getMessage());
}