details:   https://code.openbravo.com/erp/devel/pi/rev/b506447bc782
changeset: 18586:b506447bc782
user:      Ioritz Cia <ioritz.cia <at> openbravo.com>
date:      Tue Nov 20 15:48:41 2012 +0100
summary:   Fixes issue 21899: Wrong error when processing payment
choosing 'Refund to customer' option.

details:   https://code.openbravo.com/erp/devel/pi/rev/59865865bbe8
changeset: 18587:59865865bbe8
user:      Ioritz Cia <ioritz.cia <at> openbravo.com>
date:      Wed Nov 21 12:32:38 2012 +0100
summary:   Fixes issue 21906: Line Gross Amount not updated when closing order.

diffstat:

 
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/AddOrderOrInvoice.java
 |   3 +-
 src-db/database/model/functions/C_ORDER_POST1.xml                              
                              |  14 ++++++---
 2 files changed, 11 insertions(+), 6 deletions(-)

diffs (79 lines):

diff -r c0bf245121ad -r 59865865bbe8 
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/AddOrderOrInvoice.java
--- 
a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/AddOrderOrInvoice.java
      Tue Nov 20 10:43:12 2012 +0100
+++ 
b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/AddOrderOrInvoice.java
      Wed Nov 21 12:32:38 2012 +0100
@@ -226,7 +226,8 @@
               message = FIN_AddPayment.processPayment(vars, this,
                   (strAction.equals("PRP") || strAction.equals("PPP")) ? "P" : 
"D", payment);
             }
-            if (strDifferenceAction.equals("refund")) {
+            if (strDifferenceAction.equals("refund")
+                && !"Error".equalsIgnoreCase(message.getType())) {
               Boolean newPayment = 
!payment.getFINPaymentDetailList().isEmpty();
               FIN_Payment refundPayment = 
FIN_AddPayment.createRefundPayment(this, vars, payment,
                   refundAmount.negate(), exchangeRate);
diff -r c0bf245121ad -r 59865865bbe8 
src-db/database/model/functions/C_ORDER_POST1.xml
--- a/src-db/database/model/functions/C_ORDER_POST1.xml Tue Nov 20 10:43:12 
2012 +0100
+++ b/src-db/database/model/functions/C_ORDER_POST1.xml Wed Nov 21 12:32:38 
2012 +0100
@@ -439,6 +439,7 @@
           v_QtyOrdered NUMBER;
           v_QuantityOrder NUMBER;
           v_linenetamt NUMBER;
+          v_linegrossamt NUMBER;
           v_ProductUOM M_PRODUCT_UOM.C_UOM_ID%TYPE;
       BEGIN
 
@@ -448,7 +449,7 @@
           -- Cancel undelivered Items
           IF (v_isSoTrx='Y') THEN --Sales orders
             FOR Cur_Inventory IN (
-              SELECT QtyInvoiced, QtyDelivered ,QtyOrdered, QuantityOrder, 
priceactual,
+              SELECT QtyInvoiced, QtyDelivered ,QtyOrdered, QuantityOrder, 
priceactual, gross_unit_price,
              
              C_ORDERLINE_ID AS ID,
              M_Product_ID,
@@ -467,8 +468,8 @@
             )
             LOOP
               v_QtyOrdered := CASE WHEN (Cur_Inventory.QtyDelivered < 0) THEN 
LEAST(Cur_Inventory.QtyDelivered, Cur_Inventory.QtyInvoiced) ELSE 
GREATEST(Cur_Inventory.QtyDelivered, Cur_Inventory.QtyInvoiced) END;
-              v_linenetamt := ROUND((CASE WHEN (Cur_Inventory.QtyDelivered < 
0) THEN LEAST(Cur_Inventory.QtyDelivered, Cur_Inventory.QtyInvoiced) ELSE 
GREATEST(Cur_Inventory.QtyDelivered, Cur_Inventory.QtyInvoiced) END) * 
Cur_Inventory.priceactual,
-                    C_GET_CURRENCY_PRECISION(Cur_Inventory.C_Currency_ID, 
'A'));
+              v_linenetamt := ROUND(v_QtyOrdered * Cur_Inventory.priceactual, 
C_GET_CURRENCY_PRECISION(Cur_Inventory.C_Currency_ID, 'A'));
+              v_linegrossamt := ROUND(v_QtyOrdered * 
Cur_Inventory.gross_unit_price, 
C_GET_CURRENCY_PRECISION(Cur_Inventory.C_Currency_ID, 'A'));
               SELECT MAX(UOM.C_UOM_ID)
               INTO v_ProductUOM
               FROM M_PRODUCT_UOM UOM 
@@ -486,6 +487,7 @@
               UPDATE C_ORDERLINE
               SET QtyOrdered=v_QtyOrdered,
                 linenetamt=v_linenetamt,
+                line_gross_amount=v_linegrossamt,
                 QuantityOrder=v_QuantityOrder,
                 Updated=now()
               WHERE C_ORDERLINE_ID = Cur_Inventory.ID;
@@ -503,6 +505,7 @@
                 QtyOrdered,
                 QuantityOrder,
                priceactual,
+               gross_unit_price,
                linenetamt,
                 C_ORDERLINE_ID AS ID,
                M_Product_ID,
@@ -529,8 +532,8 @@
             )
             LOOP
               v_QtyOrdered := COALESCE(CASE WHEN (Cur_Inventory.QtyDelivered < 
0) THEN LEAST(Cur_Inventory.QtyDelivered, Cur_Inventory.QtyInvoiced) ELSE 
GREATEST(Cur_Inventory.QtyDelivered, Cur_Inventory.QtyInvoiced) END, 0);
-              v_linenetamt := ROUND(COALESCE((CASE WHEN 
(Cur_Inventory.QtyDelivered < 0) THEN LEAST(Cur_Inventory.QtyDelivered, 
Cur_Inventory.QtyInvoiced) ELSE GREATEST(Cur_Inventory.QtyDelivered, 
Cur_Inventory.QtyInvoiced) END), 0) * Cur_Inventory.priceactual,
-                    C_GET_CURRENCY_PRECISION(Cur_Inventory.C_Currency_ID, 
'A'));
+              v_linenetamt := ROUND(COALESCE(v_QtyOrdered, 0) * 
Cur_Inventory.priceactual, 
C_GET_CURRENCY_PRECISION(Cur_Inventory.C_Currency_ID, 'A'));
+              v_linegrossamt := ROUND(COALESCE(v_QtyOrdered, 0) * 
Cur_Inventory.gross_unit_price, 
C_GET_CURRENCY_PRECISION(Cur_Inventory.C_Currency_ID, 'A'));
               SELECT MAX(UOM.C_UOM_ID)
               INTO v_ProductUOM
               FROM M_PRODUCT_UOM UOM 
@@ -547,6 +550,7 @@
               UPDATE C_ORDERLINE
               SET QtyOrdered=v_QtyOrdered,
                 linenetamt=v_linenetamt,
+                line_gross_amount=v_linegrossamt,
                 QuantityOrder=v_QuantityOrder,
                 Updated=now()
               WHERE C_ORDERLINE_ID = Cur_Inventory.ID;

------------------------------------------------------------------------------
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to