details:   https://code.openbravo.com/erp/devel/pi/rev/ba4bca8ad196
changeset: 27896:ba4bca8ad196
user:      Alvaro Ferraz <alvaro.ferraz <at> openbravo.com>
date:      Fri Nov 06 13:14:15 2015 +0100
summary:   Fixes issue 31207: Error when the FixBackdatedFrom is before 
StartingDate

The costing background process was failing when the 'fixbackdated from' is 
defined before the costing rule's starting date.
Check transaction movement date is equals or after than costing rule fix 
backdated from date, when creating BDT cost adjustments.
getCostingRuleFixBackdatedFrom method in CostingUtils was wrongly retrieving 
costing rule starting date instead of fix backdated from date.

diffstat:

 src/org/openbravo/costing/CostingServer.java |  21 ++++++++++++---------
 src/org/openbravo/costing/CostingUtils.java  |   4 ++--
 2 files changed, 14 insertions(+), 11 deletions(-)

diffs (66 lines):

diff -r ce8fad1f9f02 -r ba4bca8ad196 
src/org/openbravo/costing/CostingServer.java
--- a/src/org/openbravo/costing/CostingServer.java      Mon Nov 16 11:19:34 
2015 +0100
+++ b/src/org/openbravo/costing/CostingServer.java      Fri Nov 06 13:14:15 
2015 +0100
@@ -235,20 +235,23 @@
     if 
(StringUtils.equals(transaction.getCostingAlgorithm().getJavaClassName(),
         "org.openbravo.costing.StandardAlgorithm")) {
 
-      if (transaction.getMovementDate().after(
-          CostingUtils.getCostingRuleStartingDate(getCostingRule()))
-          && CostAdjustmentUtils.isNeededBackdatedCostAdjustment(transaction, 
getCostingRule()
-              .isWarehouseDimension(), 
CostingUtils.getCostingRuleStartingDate(getCostingRule()))) {
+      if (CostAdjustmentUtils.isNeededBackdatedCostAdjustment(transaction, 
getCostingRule()
+          .isWarehouseDimension(), 
CostingUtils.getCostingRuleStartingDate(getCostingRule()))) {
 
         // Case transaction backdated (modifying the stock in the past)
-        if (trxType != TrxType.InventoryClosing && trxType != 
TrxType.InventoryOpening
-            && getCostingRule().isBackdatedTransactionsFixed()) {
+        if (trxType != TrxType.InventoryClosing
+            && trxType != TrxType.InventoryOpening
+            && getCostingRule().isBackdatedTransactionsFixed()
+            && transaction.getMovementDate().compareTo(
+                CostingUtils.getCostingRuleFixBackdatedFrom(getCostingRule())) 
>= 0) {
           // BDT = Backdated transaction
           createAdjustment("BDT", BigDecimal.ZERO);
         }
 
         // Case Inventory Amount Update backdated (modifying the cost in the 
past)
-        if (trxType == TrxType.InventoryOpening) {
+        if (trxType == TrxType.InventoryOpening
+            && transaction.getMovementDate().compareTo(
+                CostingUtils.getCostingRuleStartingDate(getCostingRule())) >= 
0) {
           
OBDal.getInstance().refresh(transaction.getPhysicalInventoryLine().getPhysInventory());
           if (transaction.getPhysicalInventoryLine().getPhysInventory()
               
.getInventoryAmountUpdateLineInventoriesInitInventoryList().size() > 0
@@ -269,8 +272,8 @@
     }
 
     if (getCostingRule().isBackdatedTransactionsFixed()
-        && transaction.getMovementDate().after(
-            CostingUtils.getCostingRuleStartingDate(getCostingRule()))
+        && transaction.getMovementDate().compareTo(
+            CostingUtils.getCostingRuleFixBackdatedFrom(getCostingRule())) >= 0
         && CostAdjustmentUtils.isNeededBackdatedCostAdjustment(transaction, 
getCostingRule()
             .isWarehouseDimension(), 
CostingUtils.getCostingRuleStartingDate(getCostingRule()))) {
       // BDT = Backdated transaction
diff -r ce8fad1f9f02 -r ba4bca8ad196 src/org/openbravo/costing/CostingUtils.java
--- a/src/org/openbravo/costing/CostingUtils.java       Mon Nov 16 11:19:34 
2015 +0100
+++ b/src/org/openbravo/costing/CostingUtils.java       Fri Nov 06 13:14:15 
2015 +0100
@@ -576,7 +576,7 @@
    * Returns the Fix Backdated From of a Costing Rule, if is null returns 
01/01/1900
    */
   public static Date getCostingRuleFixBackdatedFrom(CostingRule rule) {
-    if (rule.getStartingDate() == null) {
+    if (rule.getFixbackdatedfrom() == null) {
       SimpleDateFormat outputFormat = new SimpleDateFormat("dd-MM-yyyy");
       try {
         return outputFormat.parse("01-01-1900");
@@ -586,7 +586,7 @@
         return null;
       }
     }
-    return rule.getStartingDate();
+    return rule.getFixbackdatedfrom();
   }
 
   /**

------------------------------------------------------------------------------
Presto, an open source distributed SQL query engine for big data, initially
developed by Facebook, enables you to easily query your data on Hadoop in a 
more interactive manner. Teradata is also now providing full enterprise
support for Presto. Download a free open source copy now.
http://pubads.g.doubleclick.net/gampad/clk?id=250295911&iu=/4140
_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to