Fixes Issue 30644:Wrong quantity conversion in goods receipts under some
authorAtul Gaware <atul.gaware@openbravo.com>
Thu, 13 Aug 2015 10:45:12 +0530
changeset 27766 21aab95f70ec
parent 27765 342d80ab4640
child 27767 d8a462db52bd
Fixes Issue 30644:Wrong quantity conversion in goods receipts under some
circumstancies

When using conversion from primary UOM to secondary uom divideby rate
should be used and when vice versa multiply rate should be used.
src/org/openbravo/erpCommon/ad_forms/MaterialReceiptPending.java
--- a/src/org/openbravo/erpCommon/ad_forms/MaterialReceiptPending.java	Fri Aug 14 13:02:06 2015 +0200
+++ b/src/org/openbravo/erpCommon/ad_forms/MaterialReceiptPending.java	Thu Aug 13 10:45:12 2015 +0530
@@ -376,6 +376,7 @@
             conversion.add(Restrictions.eq(UOMConversion.PROPERTY_TOUOM,
                 OBDal.getInstance().get(ProductUOM.class, dataLine[0].mProductUomId).getUOM()));
 
+            Boolean useDivideRateBy = false;
             // Inverting search of UOM conversion if conversion list is empty
             if (conversion.list().size() == 0) {
               conversion = OBDal.getInstance().createCriteria(UOMConversion.class);
@@ -383,11 +384,17 @@
                   OBDal.getInstance().get(ProductUOM.class, dataLine[0].mProductUomId).getUOM()));
               conversion.add(Restrictions.eq(UOMConversion.PROPERTY_TOUOM,
                   OBDal.getInstance().get(UOM.class, dataLine[0].cUomId)));
+              useDivideRateBy = true;
             }
 
             for (UOMConversion conv : conversion.list()) {
-              qtyorder = new BigDecimal(strQtyordered).multiply(conv.getMultipleRateBy())
-                  .toString();
+              if (!useDivideRateBy) {
+                qtyorder = new BigDecimal(strQtyordered).multiply(conv.getMultipleRateBy())
+                    .toString();
+              } else {
+                qtyorder = new BigDecimal(strQtyordered).multiply(conv.getDivideRateBy())
+                    .toString();
+              }
             }
 
           }