Author: sichen
Date: Thu Jan 18 18:22:25 2007
New Revision: 497689

URL: http://svn.apache.org/viewvc?view=rev&rev=497689
Log:
Fix bug in quickcheckout where the tax is not calculated before the payments 
are created.  As of this commit, the checkout pages for ecommerce and ordermgr 
produce correct payment maxAmounts for a variety of payment method options, 
especially Billing Account.

Modified:
    
ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java
    ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml

Modified: 
ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java?view=diff&rev=497689&r1=497688&r2=497689
==============================================================================
--- 
ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java
 (original)
+++ 
ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java
 Thu Jan 18 18:22:25 2007
@@ -42,6 +42,7 @@
 import org.ofbiz.entity.GenericEntityException;
 import org.ofbiz.entity.GenericValue;
 import org.ofbiz.marketing.tracking.TrackingCodeEvents;
+import org.ofbiz.order.shoppingcart.shipping.ShippingEvents;
 import org.ofbiz.product.catalog.CatalogWorker;
 import org.ofbiz.product.store.ProductStoreWorker;
 import org.ofbiz.service.GenericServiceException;
@@ -225,6 +226,16 @@
         }
     }
 
+    /**
+     * Use for quickcheckout submit.  It calculates the tax before setting the 
payment options.  
+     * Shipment option should already be set by the quickcheckout form.
+     */
+    public static String setQuickCheckOutOptions(HttpServletRequest request, 
HttpServletResponse response) {
+        String result = calcTax(request, response);
+        if ("error".equals(result)) return "error";
+        return setCheckOutOptions(request, response);
+    }
+
     public static String setPartialCheckOutOptions(HttpServletRequest request, 
HttpServletResponse response) {
         String resp = setCheckOutOptions(request, response);
         request.setAttribute("_ERROR_MESSAGE_", null);
@@ -274,6 +285,7 @@
         return selectedPaymentMethods;
     }
 
+    // this servlet is used by quick checkout
     public static String setCheckOutOptions(HttpServletRequest request, 
HttpServletResponse response) {
         ShoppingCart cart = (ShoppingCart) 
request.getSession().getAttribute("shoppingCart");
         LocalDispatcher dispatcher = (LocalDispatcher) 
request.getAttribute("dispatcher");

Modified: ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml?view=diff&rev=497689&r1=497688&r2=497689
==============================================================================
--- ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml 
(original)
+++ ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml Thu 
Jan 18 18:22:25 2007
@@ -568,7 +568,7 @@
         <response name="customer" type="view" value="custsetting"/>
         <response name="shipping" type="view" value="shipsetting"/>
         <response name="options" type="view" value="optionsetting"/>
-        <response name="payment" type="view" value="billsetting"/>
+        <response name="payment" type="request" 
value="calcShippingBeforePayment"/>
         <response name="term" type="view" value="orderTerm"/>
         <response name="shipGroups" type="view" value="SetItemShipGroups"/>
         <response name="sales" type="request" value="calcShipping"/>
@@ -581,15 +581,37 @@
         <response name="success" type="view" value="addrsetting"/>
     </request-map>
 
+    <!-- For checkout steps that use finalizeOrder: This request chain is for 
calculating shipping & tax before getting to the payments page, so that the 
visitor
+       will know the full shipping & tax charges when trying to split payments 
between various payment methods -->
+    <request-map uri="calcShippingBeforePayment">
+        <security direct-request="false"/>
+        <event type="java" 
path="org.ofbiz.order.shoppingcart.shipping.ShippingEvents" 
invoke="getShipEstimate"/>
+        <response name="success" type="request" value="calcTaxBeforePayment"/>
+        <response name="error" type="request" value="orderentry"/>
+    </request-map>
+    <request-map uri="calcTaxBeforePayment">
+        <security direct-request="false"/>
+        <event type="java" path="org.ofbiz.order.shoppingcart.CheckOutEvents" 
invoke="calcTax"/>
+        <response name="success" type="request" 
value="validatePaymentMethodsBeforePayment"/>
+        <response name="error" type="request" value="orderentry"/>
+    </request-map>
+    <request-map uri="validatePaymentMethodsBeforePayment">
+        <security direct-request="false"/>
+        <event type="java" path="org.ofbiz.order.shoppingcart.CheckOutEvents" 
invoke="checkPaymentMethods"/>
+        <response name="success" type="view" value="billsetting"/>
+        <response name="error" type="request" value="orderentry"/>
+    </request-map>
+
     <!-- 
         Quick Finalize Order reuses the ecommerce checkoutoptions widget and 
template. We need to
-        translate the controller requests here for use by ordermgr.
+        translate the controller requests here for use by ordermgr.  Note that 
the main entry point on submit is "checkout".
     -->
     <request-map uri="quickcheckout">
         <security https="true" auth="true"/>
         <response name="success" type="view" value="quickcheckout"/>
     </request-map>
     <request-map uri="updateCheckoutOptions">
+        <description>When user selects a shipping method, this automatically 
reloads quick checkout page with shipping estimates filled in.</description>
         <security https="true" auth="true"/>
         <event type="java" path="org.ofbiz.order.shoppingcart.CheckOutEvents" 
invoke="setPartialCheckOutOptions"/>
         <response name="success" type="view" value="checkoutshippingaddress"/>
@@ -597,9 +619,9 @@
     </request-map>
     <request-map uri="checkout">
         <security https="true" auth="true"/>
-        <event type="java" path="org.ofbiz.order.shoppingcart.CheckOutEvents" 
invoke="setCheckOutOptions"/>
-        <response name="success" type="request" value="calcShipping"/>
-        <response name="error" type="view" value="showcart"/>
+        <event type="java" path="org.ofbiz.order.shoppingcart.CheckOutEvents" 
invoke="setQuickCheckOutOptions"/>
+        <response name="success" type="view" value="confirm"/>
+        <response name="error" type="request" value="orderentry"/>
     </request-map>
     <request-map uri="createPostalAddressAndPurpose">
         <security https="true" auth="true"/>


Reply via email to