Related to Issue 28148 Cost Adjustment Lines created ordered by trxprocessdate
authorAlvaro Ferraz <alvaro.ferraz@openbravo.com>
Mon, 01 Dec 2014 16:55:05 +0100
changeset 25639 816b718112f1
parent 25638 3a0b18f1e0bb
child 25640 4358cc01e873
Related to Issue 28148 Cost Adjustment Lines created ordered by trxprocessdate

In order to help JUnit tests assert Cost Adjustment lines, an orderBy clause has been added when creating cost adjustment lines of type Landed Cost to follow always the same order
src/org/openbravo/costing/LCMatchingProcess.java
--- a/src/org/openbravo/costing/LCMatchingProcess.java	Fri Dec 05 14:11:17 2014 +0100
+++ b/src/org/openbravo/costing/LCMatchingProcess.java	Mon Dec 01 16:55:05 2014 +0100
@@ -152,10 +152,15 @@
     StringBuffer hql = new StringBuffer();
     hql.append(" select sum(rla." + LCReceiptLineAmt.PROPERTY_AMOUNT + ") as amt");
     hql.append("   , rla." + LCReceipt.PROPERTY_GOODSSHIPMENTLINE + ".id as receipt");
+    hql.append("   , (select " + MaterialTransaction.PROPERTY_TRANSACTIONPROCESSDATE + " from "
+        + MaterialTransaction.ENTITY_NAME + " as transaction where "
+        + MaterialTransaction.PROPERTY_GOODSSHIPMENTLINE + ".id = rla."
+        + LCReceipt.PROPERTY_GOODSSHIPMENTLINE + ".id) as trxprocessdate");
     hql.append(" from " + LCReceiptLineAmt.ENTITY_NAME + " as rla");
     hql.append(" where rla." + LCReceiptLineAmt.PROPERTY_LANDEDCOSTCOST + " = :lcc");
     hql.append("   and rla." + LCReceiptLineAmt.PROPERTY_ISMATCHINGADJUSTMENT + " = true ");
     hql.append(" group by rla." + LCReceipt.PROPERTY_GOODSSHIPMENTLINE + ".id");
+    hql.append(" order by trxprocessdate, amt");
 
     Query qryLCRLA = OBDal.getInstance().getSession().createQuery(hql.toString());
     qryLCRLA.setParameter("lcc", lcCost);