Fixes issue 31998: Wrong cost calculation in Costing Migration Process
authorAlvaro Ferraz <alvaro.ferraz@openbravo.com>
Thu, 21 Jan 2016 14:27:39 +0100
changeset 28747 16c01a9e0bde
parent 28743 b6c50283d4a8
child 28748 5d784a9454eb
Fixes issue 31998: Wrong cost calculation in Costing Migration Process

HQL in insertTrxCosts method in CostingMigrationProcess class was doing an inner join between m_transaction and m_inoutline instead of a left join.
src/org/openbravo/costing/CostingMigrationProcess.java
--- a/src/org/openbravo/costing/CostingMigrationProcess.java	Fri Jan 22 05:17:24 2016 +0000
+++ b/src/org/openbravo/costing/CostingMigrationProcess.java	Thu Jan 21 14:27:39 2016 +0100
@@ -863,13 +863,12 @@
     insert.append(", t." + MaterialTransaction.PROPERTY_TRANSACTIONCOST);
     insert.append(", t." + MaterialTransaction.PROPERTY_TRANSACTIONPROCESSDATE);
     insert.append(", t." + MaterialTransaction.PROPERTY_CURRENCY);
-    insert.append(", case when t." + MaterialTransaction.PROPERTY_GOODSSHIPMENTLINE
-        + " is null then t." + MaterialTransaction.PROPERTY_MOVEMENTDATE + " else t."
-        + MaterialTransaction.PROPERTY_GOODSSHIPMENTLINE + "."
-        + ShipmentInOutLine.PROPERTY_SHIPMENTRECEIPT + "." + ShipmentInOut.PROPERTY_ACCOUNTINGDATE
-        + " end");
+    insert.append(", coalesce(io." + ShipmentInOut.PROPERTY_ACCOUNTINGDATE + ", t."
+        + MaterialTransaction.PROPERTY_MOVEMENTDATE + ")");
     insert.append(" from  " + TransactionCost.ENTITY_NAME + " as tc ");
     insert.append("   right join tc." + TransactionCost.PROPERTY_INVENTORYTRANSACTION + " as t");
+    insert.append("   left join t." + MaterialTransaction.PROPERTY_GOODSSHIPMENTLINE + " as iol");
+    insert.append("   left join iol." + ShipmentInOutLine.PROPERTY_SHIPMENTRECEIPT + " as io");
     insert.append(", " + User.ENTITY_NAME + " as u");
     insert.append("  where t." + MaterialTransaction.PROPERTY_TRANSACTIONCOST + " is not null");
     insert.append("    and tc.id is null");