details:   https://code.openbravo.com/erp/devel/pi/rev/0e29b93a2d41
changeset: 32232:0e29b93a2d41
user:      Armaignac <collazoandy4 <at> gmail.com>
date:      Tue May 23 10:49:51 2017 -0400
summary:   Fixes issue 35958: Wrong reservation when reactivating a sales order

When completing an order wich already has a reservation, the stock reservation
was updated causing a wrong reservation. Now the update of stock reservation is
made only if the order is not completed.

details:   https://code.openbravo.com/erp/devel/pi/rev/816a40caaba9
changeset: 32233:816a40caaba9
user:      Armaignac <collazoandy4 <at> gmail.com>
date:      Thu May 25 17:01:51 2017 -0400
summary:   Fixes issue 36015: Rounding issue when adding transactions in Match 
Statement

A wrong compare was made betweent bank statement line and transactions amount 
because
a rounding problem.

BigDecimal will be used for totalTrxAmt, blineAmt, trxDepositAmt, trxPaymentAmt
and trxAmt variables to avoid this rounding problem.

diffstat:

 
modules/org.openbravo.advpaymentmngt/web/org.openbravo.advpaymentmngt/js/ob-aprm-findTransaction.js
 |  16 +++++-----
 src-db/database/model/functions/C_ORDER_POST1.xml                              
                     |  14 +++++---
 2 files changed, 16 insertions(+), 14 deletions(-)

diffs (73 lines):

diff -r cd9ba7153167 -r 816a40caaba9 
modules/org.openbravo.advpaymentmngt/web/org.openbravo.advpaymentmngt/js/ob-aprm-findTransaction.js
--- 
a/modules/org.openbravo.advpaymentmngt/web/org.openbravo.advpaymentmngt/js/ob-aprm-findTransaction.js
       Mon May 29 22:08:29 2017 +0000
+++ 
b/modules/org.openbravo.advpaymentmngt/web/org.openbravo.advpaymentmngt/js/ob-aprm-findTransaction.js
       Thu May 25 17:01:51 2017 -0400
@@ -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):  ______________________________________.
  ************************************************************************
@@ -34,16 +34,16 @@
     var i, trxSelection = 
view.getContextInfo().findtransactiontomatch._selection;
 
     if (trxSelection && trxSelection[0]) {
-      var totalTrxAmt = 0,
-          blineAmt = view.callerField.record.amount,
+      var totalTrxAmt = BigDecimal.prototype.ZERO,
+          blineAmt = new BigDecimal(String(view.callerField.record.amount)),
           hideSplitConfirmation = 
OB.PropertyStore.get('APRM_MATCHSTATEMENT_HIDE_PARTIALMATCH_POPUP', 
view.windowId);
       for (i = 0; i < trxSelection.length; i++) {
-        var trxDepositAmt = trxSelection[i].depositAmount,
-            trxPaymentAmt = trxSelection[i].paymentAmount,
-            trxAmt = trxDepositAmt - trxPaymentAmt;
-        totalTrxAmt = totalTrxAmt + trxAmt;
+        var trxDepositAmt = new 
BigDecimal(String(trxSelection[i].depositAmount)),
+            trxPaymentAmt = new 
BigDecimal(String(trxSelection[i].paymentAmount)),
+            trxAmt = trxDepositAmt.subtract(trxPaymentAmt);
+        totalTrxAmt = totalTrxAmt.add(trxAmt);
       }
-      if (totalTrxAmt !== blineAmt) {
+      if (totalTrxAmt.compareTo(blineAmt) !== 0) {
         // Split required
         if (hideSplitConfirmation === 'Y') {
           // Continue with the match
diff -r cd9ba7153167 -r 816a40caaba9 
src-db/database/model/functions/C_ORDER_POST1.xml
--- a/src-db/database/model/functions/C_ORDER_POST1.xml Mon May 29 22:08:29 
2017 +0000
+++ b/src-db/database/model/functions/C_ORDER_POST1.xml Thu May 25 17:01:51 
2017 -0400
@@ -1327,13 +1327,15 @@
                     IF (v_pendingtounreserve > 0) THEN
                       RAISE_APPLICATION_ERROR(-20000, 
'@CouldNotUnreserveNeededQty@');
                     END IF;
-                    -- Delete reservation lines with zero releasedqty
-                    DELETE FROM m_reservation_stock
-                    WHERE COALESCE(releasedqty, 0) = 0
+                    IF (v_DocAction <> 'CO') THEN
+                      -- Delete reservation lines with zero releasedqty
+                      DELETE FROM m_reservation_stock
+                      WHERE COALESCE(releasedqty, 0) = 0
                       AND m_reservation_id = v_reservation_id;
+                    END IF;
                   END IF;
                   -- Order line orderedqty greater than reservation releasedqty
-                  IF (cur_orderline.qtyordered > v_releasedqty) THEN
+                  IF (cur_orderline.qtyordered > v_releasedqty AND v_DocAction 
<> 'CO') THEN
                     UPDATE m_reservation_stock
                     SET quantity = releasedqty,
                         updated = now(),
@@ -1342,11 +1344,11 @@
                   END IF;
                   UPDATE m_reservation
                   SET quantity = cur_orderline.qtyordered,
-                      res_status = 'CL',
+                      res_status = CASE WHEN v_DocAction <> 'CO' THEN 'CL' 
ELSE res_status END,
                       updated = now(),
                       updatedby = v_user
                   WHERE m_reservation_id = v_reservation_id;
-                  IF (v_quantity < cur_orderline.qtyordered AND v_res_status = 
'CO') THEN
+                  IF (v_quantity < cur_orderline.qtyordered AND v_res_status = 
'CO' AND v_DocAction <> 'CO') THEN
                     --Reservation processed with higher quantity. Try to 
reserve the new quantity.
                     M_RESERVE_STOCK_AUTO(v_reservation_id, v_user, 
v_reservedqty);
                   END IF;

------------------------------------------------------------------------------
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
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to