Fixes Bug 28441:Validate Costing Rule doesn't fail if there prev transactions.
authorUnai Martirena <unai.martirena@openbravo.com>
Wed, 17 Dec 2014 18:33:43 +0100
changeset 25631 dfdc7b880446
parent 25630 dd93c7f18e34
child 25632 abaeb7e23435
Fixes Bug 28441:Validate Costing Rule doesn't fail if there prev transactions.

The process was failing while trying to create Transaction Cost records in initializeOldTrx and updateInventoriesCostAndProcessInitInventories processes. It was not setting any value to accounting date column, which is mandatory. This column has been populated in the following way: If the related transaction is a shipment the accounting date of the shipment is assigned, if not, the movement date of the transaction will be assigned.
src/org/openbravo/costing/CostingRuleProcess.java
--- a/src/org/openbravo/costing/CostingRuleProcess.java	Wed Dec 17 16:22:29 2014 +0100
+++ b/src/org/openbravo/costing/CostingRuleProcess.java	Wed Dec 17 18:33:43 2014 +0100
@@ -268,6 +268,9 @@
         transactionCost.setOrganization(trx.getOrganization());
         transactionCost.setCost(BigDecimal.ZERO);
         transactionCost.setCurrency(trx.getClient().getCurrency());
+        transactionCost.setAccountingDate(trx.getGoodsShipmentLine() != null ? trx
+            .getGoodsShipmentLine().getShipmentReceipt().getAccountingDate() : trx
+            .getMovementDate());
         List<TransactionCost> trxCosts = trx.getTransactionCostList();
         trxCosts.add(transactionCost);
         trx.setTransactionCostList(trxCosts);
@@ -516,6 +519,9 @@
           transactionCost.setOrganization(trx.getOrganization());
           transactionCost.setCost(BigDecimal.ZERO);
           transactionCost.setCurrency(trx.getClient().getCurrency());
+          transactionCost.setAccountingDate(trx.getGoodsShipmentLine() != null ? trx
+              .getGoodsShipmentLine().getShipmentReceipt().getAccountingDate() : trx
+              .getMovementDate());
           List<TransactionCost> trxCosts = trx.getTransactionCostList();
           trxCosts.add(transactionCost);
           trx.setTransactionCostList(trxCosts);