details: https://code.openbravo.com/erp/devel/pi/rev/ff6e0aa17abc
changeset: 32718:ff6e0aa17abc
user: Atul Gaware <atul.gaware <at> openbravo.com>
date: Mon Sep 18 20:43:17 2017 +0530
summary: Fixes issue 36831: Wrong average cost after negative stock correction
Total stock valuation in Costing tab is not updated
after negative stock correction.
Check if total stock valuation has changed
same as we check if total movement quantity has changed.
When a cost adjustment is done, total stock valuation and
total movement quantity of affected cost will be set as zero,
in order to recalculate them properly next time a new cost is calculated.
diffstat:
src/org/openbravo/costing/AverageCostAdjustment.java | 14 ++++++++++----
1 files changed, 10 insertions(+), 4 deletions(-)
diffs (45 lines):
diff -r 2db33b1309ea -r ff6e0aa17abc
src/org/openbravo/costing/AverageCostAdjustment.java
--- a/src/org/openbravo/costing/AverageCostAdjustment.java Mon Sep 18
17:02:16 2017 +0200
+++ b/src/org/openbravo/costing/AverageCostAdjustment.java Mon Sep 18
20:43:17 2017 +0530
@@ -11,7 +11,7 @@
* under the License.
* The Original Code is Openbravo ERP.
* The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2014-2016 Openbravo SLU
+ * All portions are Copyright (C) 2014-2017 Openbravo SLU
* All Rights Reserved.
* Contributor(s): ______________________________________.
*************************************************************************
@@ -209,7 +209,9 @@
if (curCosting.getCost().compareTo(cost) != 0
|| (curCosting.getTotalMovementQuantity() != null && curCosting
- .getTotalMovementQuantity().compareTo(currentStock) != 0)) {
+ .getTotalMovementQuantity().compareTo(currentStock) != 0)
+ || (curCosting.getTotalStockValuation() != null &&
curCosting.getTotalStockValuation()
+ .compareTo(currentValueAmt.add(adjustmentBalance)) != 0)) {
curCosting.setPermanent(Boolean.FALSE);
OBDal.getInstance().save(curCosting);
OBDal.getInstance().flush();
@@ -368,7 +370,9 @@
if (curCosting.getCost().compareTo(cost) == 0
&& StringUtils.isEmpty(bdCostingId)
&& (curCosting.getTotalMovementQuantity() != null && curCosting
- .getTotalMovementQuantity().compareTo(currentStock) == 0)) {
+ .getTotalMovementQuantity().compareTo(currentStock) == 0)
+ && (curCosting.getTotalStockValuation() != null && curCosting
+
.getTotalStockValuation().compareTo(currentValueAmt.add(adjustmentBalance)) ==
0)) {
// new cost hasn't changed and total movement qty is equal to
current stock, following
// transactions will have the same cost, so no more
// related transactions are needed to include.
@@ -433,7 +437,9 @@
}
if (curCosting.getCost().compareTo(cost) != 0
|| (curCosting.getTotalMovementQuantity() != null && curCosting
- .getTotalMovementQuantity().compareTo(currentStock) != 0))
{
+ .getTotalMovementQuantity().compareTo(currentStock) != 0)
+ || (curCosting.getTotalStockValuation() != null && curCosting
+
.getTotalStockValuation().compareTo(currentValueAmt.add(adjustmentBalance)) !=
0)) {
curCosting.setPermanent(Boolean.FALSE);
OBDal.getInstance().save(curCosting);
OBDal.getInstance().flush();
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits