details:   https://code.openbravo.com/erp/devel/pi/rev/603663ae3bb0
changeset: 25194:603663ae3bb0
user:      Unai Martirena <unai.martirena <at> openbravo.com>
date:      Tue Nov 11 09:54:03 2014 +0100
summary:   Fixes Issue 28121: Used Costing Precision instead of Standard 
Precision in LC

In Distribution by Amount Algorithm of Landed Cost, Costing Precision should be 
used instead of Standard Precision. The recommended Costing Precision is 4.
Also the Line No. of Cost Adjustment Lines has been fixed when creating a 
Landed Cost Adjustment.

details:   https://code.openbravo.com/erp/devel/pi/rev/4eec717af240
changeset: 25195:4eec717af240
user:      Unai Martirena <unai.martirena <at> openbravo.com>
date:      Tue Nov 11 10:00:36 2014 +0100
summary:   Fixes Bug 27998: Negative Stock Correction adjustments now are 
properly created

Due to Issue 27946, each time that an adjustment is created it is checked if a 
Negative Stock Correction adjustment is needed, and if so, it is created. So 
now, in Costing Server, before creating any Negative Stock Correction it is 
checked if another Cost Adjustment has been created, and if it is, this step is 
skipped.

diffstat:

 src/org/openbravo/costing/CostingServer.java                  |  13 +++++++++-
 src/org/openbravo/costing/LandedCostDistributionByAmount.java |   2 +-
 src/org/openbravo/costing/LandedCostProcess.java              |   2 +
 src/org/openbravo/costing/PriceDifferenceProcess.java         |   3 +-
 4 files changed, 16 insertions(+), 4 deletions(-)

diffs (102 lines):

diff -r 9ae96f2b5bc9 -r 4eec717af240 
src/org/openbravo/costing/CostingServer.java
--- a/src/org/openbravo/costing/CostingServer.java      Tue Oct 28 15:10:32 
2014 -0500
+++ b/src/org/openbravo/costing/CostingServer.java      Tue Nov 11 10:00:36 
2014 +0100
@@ -132,6 +132,7 @@
 
   private void checkCostAdjustments() {
     TrxType trxType = TrxType.getTrxType(transaction);
+    boolean adjustmentAlreadyCreated = false;
     if (trxType == TrxType.InventoryClosing) {
       
OBDal.getInstance().refresh(transaction.getPhysicalInventoryLine().getPhysInventory());
       if (transaction.getPhysicalInventoryLine().getPhysInventory()
@@ -153,7 +154,10 @@
       checkPriceCorrectionTrxs = false;
     }
     if (checkPriceCorrectionTrxs && transaction.isCheckpricedifference()) {
-      PriceDifferenceProcess.processPriceDifferenceTransaction(transaction);
+      JSONObject message = 
PriceDifferenceProcess.processPriceDifferenceTransaction(transaction);
+      if (message.has("documentNo")) {
+        adjustmentAlreadyCreated = true;
+      }
     }
 
     // check if landed cost need to be processed
@@ -208,6 +212,9 @@
         if (landedCost != null) {
           OBDal.getInstance().flush();
           JSONObject message = 
LandedCostProcess.doProcessLandedCost(landedCost);
+          if (message.has("documentNo")) {
+            adjustmentAlreadyCreated = true;
+          }
 
           if (message.get("severity") != "success") {
             throw new 
OBException(OBMessageUtils.parseTranslation("@ErrorProcessingLandedCost@")
@@ -242,6 +249,7 @@
           throw new 
OBException(OBMessageUtils.parseTranslation("@ErrorProcessingCostAdj@") + ": "
               + costAdjustmentHeader.getDocumentNo() + " - " + 
message.getString("text"));
         }
+        adjustmentAlreadyCreated = true;
       } catch (JSONException ignore) {
         throw new 
OBException(OBMessageUtils.parseTranslation("@ErrorProcessingCostAdj@"));
       }
@@ -264,7 +272,8 @@
         costingRule.isBackdatedTransactionsFixed());
     // the stock previous to transaction was negative
     if (checkNegativeStockCorrectionTrxs
-        && currentStock.compareTo(transaction.getMovementQuantity()) < 0 && 
modifiesAvg) {
+        && currentStock.compareTo(transaction.getMovementQuantity()) < 0 && 
modifiesAvg
+        && !adjustmentAlreadyCreated) {
 
       CostAdjustment costAdjustmentHeader = 
CostAdjustmentUtils.insertCostAdjustmentHeader(
           transaction.getOrganization(), "NSC"); // NSC= Negative Stock 
Correction
diff -r 9ae96f2b5bc9 -r 4eec717af240 
src/org/openbravo/costing/LandedCostDistributionByAmount.java
--- a/src/org/openbravo/costing/LandedCostDistributionByAmount.java     Tue Oct 
28 15:10:32 2014 -0500
+++ b/src/org/openbravo/costing/LandedCostDistributionByAmount.java     Tue Nov 
11 10:00:36 2014 +0100
@@ -52,7 +52,7 @@
     String strCurId = lcCost.getCurrency().getId();
     String strOrgId = landedCost.getOrganization().getId();
     Date dateReference = landedCost.getReferenceDate();
-    int precission = lcCost.getCurrency().getStandardPrecision().intValue();
+    int precission = lcCost.getCurrency().getCostingPrecision().intValue();
     BigDecimal baseAmt;
     if (isMatching) {
       baseAmt = lcCost.getMatchingAmount().subtract(lcCost.getAmount());
diff -r 9ae96f2b5bc9 -r 4eec717af240 
src/org/openbravo/costing/LandedCostProcess.java
--- a/src/org/openbravo/costing/LandedCostProcess.java  Tue Oct 28 15:10:32 
2014 -0500
+++ b/src/org/openbravo/costing/LandedCostProcess.java  Tue Nov 11 10:00:36 
2014 +0100
@@ -97,6 +97,7 @@
       landedCost.setDocumentStatus("CO");
       landedCost.setProcessed(Boolean.TRUE);
       OBDal.getInstance().save(landedCost);
+      message.put("documentNo", ca.getDocumentNo());
     } catch (JSONException ignore) {
     } finally {
       OBContext.restorePreviousMode();
@@ -225,6 +226,7 @@
       cal.setNeedsPosting(Boolean.FALSE);
       cal.setUnitCost(Boolean.FALSE);
       cal.setCurrency(lcCostCurrency);
+      cal.setLineNo((i + 1) * 10L);
       OBDal.getInstance().save(cal);
 
       if (i % 100 == 0) {
diff -r 9ae96f2b5bc9 -r 4eec717af240 
src/org/openbravo/costing/PriceDifferenceProcess.java
--- a/src/org/openbravo/costing/PriceDifferenceProcess.java     Tue Oct 28 
15:10:32 2014 -0500
+++ b/src/org/openbravo/costing/PriceDifferenceProcess.java     Tue Nov 11 
10:00:36 2014 +0100
@@ -153,7 +153,7 @@
       OBDal.getInstance().flush();
       JSONObject message = 
CostAdjustmentProcess.doProcessCostAdjustment(costAdjHeader);
       try {
-
+        message.put("documentNo", costAdjHeader.getDocumentNo());
         if (message.get("severity") != "success") {
           throw new 
OBException(OBMessageUtils.parseTranslation("@ErrorProcessingCostAdj@") + ": "
               + costAdjHeader.getDocumentNo() + " - " + 
message.getString("text"));
@@ -161,6 +161,7 @@
       } catch (JSONException e) {
         throw new 
OBException(OBMessageUtils.parseTranslation("@ErrorProcessingCostAdj@"));
       }
+
       return message;
     } else {
       JSONObject message = new JSONObject();

------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://pubads.g.doubleclick.net/gampad/clk?id=154624111&iu=/4140/ostg.clktrk
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to