Fixes bug 28266 ParentCostAdjustmentLine should always be assigned in the same order
authorAlvaro Ferraz <alvaro.ferraz@openbravo.com>
Mon, 01 Dec 2014 16:54:02 +0100
changeset 25495 51adc29c2514
parent 25494 4ae6c365fd3e
child 25496 5bb50e44ea69
Fixes bug 28266 ParentCostAdjustmentLine should always be assigned in the same order

In order to help JUnit tests assert Cost Adjustment lines, an orderBy clause has been added when assigning the field "Parent Cost Adjustment Line" to follow always the same order
src/org/openbravo/costing/CostAdjustmentProcess.java
--- a/src/org/openbravo/costing/CostAdjustmentProcess.java	Mon Dec 01 16:50:51 2014 +0100
+++ b/src/org/openbravo/costing/CostAdjustmentProcess.java	Mon Dec 01 16:54:02 2014 +0100
@@ -249,8 +249,9 @@
     critLines.createAlias(CostAdjustmentLine.PROPERTY_COSTADJUSTMENT, "ca");
     critLines.add(Restrictions.eq("ca.id", strCostAdjustmentId));
     critLines.add(Restrictions.eq(CostAdjustmentLine.PROPERTY_ISRELATEDTRANSACTIONADJUSTED, false));
+    critLines.addOrder(Order.asc("trx." + MaterialTransaction.PROPERTY_TRANSACTIONPROCESSDATE));
+    critLines.addOrder(Order.asc(CostAdjustmentLine.PROPERTY_ADJUSTMENTAMOUNT));
     critLines.addOrder(Order.asc("trx." + MaterialTransaction.PROPERTY_MOVEMENTDATE));
-    critLines.addOrder(Order.asc("trx." + MaterialTransaction.PROPERTY_TRANSACTIONPROCESSDATE));
     critLines.setMaxResults(1);
     return (CostAdjustmentLine) critLines.uniqueResult();
   }