details:   https://code.openbravo.com/erp/devel/pi/rev/8d3c284d86d9
changeset: 20462:8d3c284d86d9
user:      David Miguelez <david.miguelez <at> openbravo.com>
date:      Wed May 22 10:36:43 2013 +0200
summary:   Fixes Issue 23741. When the Cost of a Transaction is calculated
the related Document is set to Not Posted if it was not posted previously.

diffstat:

 src/org/openbravo/costing/CostingServer.java       |  72 ++++++++++++++++++++++
 src/org/openbravo/erpCommon/ad_forms/DocInOut.java |   3 +-
 2 files changed, 74 insertions(+), 1 deletions(-)

diffs (109 lines):

diff -r a013006eeb9b -r 8d3c284d86d9 
src/org/openbravo/costing/CostingServer.java
--- a/src/org/openbravo/costing/CostingServer.java      Wed May 15 12:19:51 
2013 +0200
+++ b/src/org/openbravo/costing/CostingServer.java      Wed May 22 10:36:43 
2013 +0200
@@ -34,7 +34,11 @@
 import org.openbravo.model.common.enterprise.Organization;
 import org.openbravo.model.materialmgmt.cost.CostingRule;
 import org.openbravo.model.materialmgmt.cost.TransactionCost;
+import org.openbravo.model.materialmgmt.transaction.InternalConsumption;
+import org.openbravo.model.materialmgmt.transaction.InternalMovement;
+import org.openbravo.model.materialmgmt.transaction.InventoryCount;
 import org.openbravo.model.materialmgmt.transaction.MaterialTransaction;
+import org.openbravo.model.materialmgmt.transaction.ProductionTransaction;
 
 /**
  * @author gorkaion
@@ -96,12 +100,80 @@
       // insert on m_transaction_cost
       createTransactionCost();
       OBDal.getInstance().save(transaction);
+      setNotPostedTransaction();
     } finally {
       OBContext.restorePreviousMode();
     }
     return;
   }
 
+  private void setNotPostedTransaction() {
+    TrxType trxType = TrxType.getTrxType(transaction);
+    switch (trxType) {
+    case Shipment:
+    case ShipmentReturn:
+    case ShipmentVoid:
+    case ShipmentNegative:
+    case Receipt:
+    case ReceiptReturn:
+    case ReceiptVoid:
+    case ReceiptNegative: {
+      org.openbravo.model.materialmgmt.transaction.ShipmentInOut inout = 
transaction
+          .getGoodsShipmentLine().getShipmentReceipt();
+      if (!"N".equals(inout.getPosted()) || !"Y".equals(inout.getPosted())) {
+        inout.setPosted("N");
+        OBDal.getInstance().save(inout);
+      }
+      break;
+    }
+    case InventoryDecrease:
+    case InventoryIncrease: {
+      InventoryCount inventory = 
transaction.getPhysicalInventoryLine().getPhysInventory();
+      if (!"N".equals(inventory.getPosted()) || 
!"Y".equals(inventory.getPosted())) {
+        inventory.setPosted("N");
+        OBDal.getInstance().save(inventory);
+      }
+      break;
+    }
+    case IntMovementFrom:
+    case IntMovementTo: {
+      InternalMovement movement = transaction.getMovementLine().getMovement();
+      if (!"N".equals(movement.getPosted()) || 
!"Y".equals(movement.getPosted())) {
+        movement.setPosted("N");
+        OBDal.getInstance().save(movement);
+      }
+      break;
+    }
+    case InternalCons:
+    case InternalConsNegative:
+    case InternalConsVoid: {
+      InternalConsumption consumption = 
transaction.getInternalConsumptionLine()
+          .getInternalConsumption();
+      if (!"N".equals(consumption.getPosted()) || 
!"Y".equals(consumption.getPosted())) {
+        consumption.setPosted("N");
+        OBDal.getInstance().save(consumption);
+      }
+      break;
+    }
+    case BOMPart:
+    case BOMProduct:
+    case ManufacturingConsumed:
+    case ManufacturingProduced: {
+      ProductionTransaction production = 
transaction.getProductionLine().getProductionPlan()
+          .getProduction();
+      if (!"N".equals(production.getPosted()) || 
!"Y".equals(production.getPosted())) {
+        production.setPosted("N");
+        OBDal.getInstance().save(production);
+      }
+      break;
+    }
+    case Unknown:
+      throw new OBException("@UnknownTrxType@: " + 
transaction.getIdentifier());
+    default:
+      throw new OBException("@UnknownTrxType@: " + 
transaction.getIdentifier());
+    }
+  }
+
   private CostingAlgorithm getCostingAlgorithm() {
     // Algorithm class is retrieved from costDimensionRule
     org.openbravo.model.materialmgmt.cost.CostingAlgorithm costAlgorithm = 
costingRule
diff -r a013006eeb9b -r 8d3c284d86d9 
src/org/openbravo/erpCommon/ad_forms/DocInOut.java
--- a/src/org/openbravo/erpCommon/ad_forms/DocInOut.java        Wed May 15 
12:19:51 2013 +0200
+++ b/src/org/openbravo/erpCommon/ad_forms/DocInOut.java        Wed May 22 
10:36:43 2013 +0200
@@ -558,7 +558,8 @@
             if (trxCost == null) {
               Map<String, String> parameters = 
getNotCalculatedCostParameters(trx);
               setMessageResult(conn, STATUS_NotCalculatedCost, "error", 
parameters);
-              throw new IllegalStateException();
+              setStatus(STATUS_NotCalculatedCost);
+              return false;
             }
           } finally {
             OBContext.restorePreviousMode();

------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service 
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to