svn commit: r630438 - /ofbiz/branches/release4.0/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r630438 - /ofbiz/branches/release4.0/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java

jleroux@apache.org
Author: jleroux
Date: Sat Feb 23 06:01:26 2008
New Revision: 630438

URL: http://svn.apache.org/viewvc?rev=630438&view=rev
Log:
Applied fix from trunk for revision: 630437  

Modified:
    ofbiz/branches/release4.0/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java

Modified: ofbiz/branches/release4.0/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release4.0/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java?rev=630438&r1=630437&r2=630438&view=diff
==============================================================================
--- ofbiz/branches/release4.0/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java (original)
+++ ofbiz/branches/release4.0/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java Sat Feb 23 06:01:26 2008
@@ -1515,7 +1515,23 @@
             errMsg = UtilProperties.getMessage(resource, "checkevents.payment_not_cover_this_order", (cart != null ? cart.getLocale() : Locale.getDefault()));
             return ServiceUtil.returnError(errMsg);
         }
-
+        if (paymentMethods != null && paymentMethods.size() > 0 && requiredAmount < selectedPaymentTotal) {
+            double changeAmount = selectedPaymentTotal - requiredAmount;
+            if (!paymentTypes.contains("CASH")){
+                Debug.logError("Change Amount : " + changeAmount + " / No cash.", module);
+                errMsg = UtilProperties.getMessage(resource, "checkhelper.change_returned_cannot_be_greater_than_cash", (cart != null ? cart.getLocale() : Locale.getDefault()));
+                return ServiceUtil.returnError(errMsg);
+            }else{
+                int cashIndex = paymentTypes.indexOf("CASH");
+                String cashId = (String) paymentTypes.get(cashIndex);
+                double cashAmount = cart.getPaymentAmount(cashId);
+                if (cashAmount < changeAmount){
+                    Debug.logError("Change Amount : " + changeAmount + " / Cash Amount : " + cashAmount, module);
+                    errMsg = UtilProperties.getMessage(resource, "checkhelper.change_returned_cannot_be_greater_than_cash", (cart != null ? cart.getLocale() : Locale.getDefault()));
+                    return ServiceUtil.returnError(errMsg);
+                }
+            }            
+        }
         return ServiceUtil.returnSuccess();
     }