You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by mr...@apache.org on 2008/10/12 19:24:07 UTC

svn commit: r703851 - in /ofbiz/trunk/specialpurpose/webpos: config/ script/org/ofbiz/webpos/event/ servicedef/ src/org/ofbiz/webpos/ src/org/ofbiz/webpos/transaction/ webapp/webpos/WEB-INF/ webapp/webpos/WEB-INF/actions/buttons/ webapp/webpos/WEB-INF/...

Author: mrisaliti
Date: Sun Oct 12 10:24:07 2008
New Revision: 703851

URL: http://svn.apache.org/viewvc?rev=703851&view=rev
Log:
CLEAR PAYMENT button is not working correctly because it clears now only the first payment of the cart (Issue OFBIZ-1995)

Added:
    ofbiz/trunk/specialpurpose/webpos/webapp/webpos/payment/ClearPayment.ftl   (with props)
Modified:
    ofbiz/trunk/specialpurpose/webpos/config/WebPosUiLabels.xml
    ofbiz/trunk/specialpurpose/webpos/script/org/ofbiz/webpos/event/ManagerEvents.xml
    ofbiz/trunk/specialpurpose/webpos/script/org/ofbiz/webpos/event/PaymentEvents.xml
    ofbiz/trunk/specialpurpose/webpos/script/org/ofbiz/webpos/event/PromoEvents.xml
    ofbiz/trunk/specialpurpose/webpos/servicedef/services.xml
    ofbiz/trunk/specialpurpose/webpos/servicedef/services_payment.xml
    ofbiz/trunk/specialpurpose/webpos/src/org/ofbiz/webpos/WebPosEvents.java
    ofbiz/trunk/specialpurpose/webpos/src/org/ofbiz/webpos/transaction/WebPosTransaction.java
    ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/buttons/Main.groovy
    ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/buttons/Payment.groovy
    ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/cart/MicroCart.groovy
    ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/cart/ShowCart.groovy
    ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/controller.xml
    ofbiz/trunk/specialpurpose/webpos/webapp/webpos/buttons/Payment.ftl
    ofbiz/trunk/specialpurpose/webpos/widget/PaymentScreens.xml
    ofbiz/trunk/specialpurpose/webpos/widget/WebPosScreens.xml

Modified: ofbiz/trunk/specialpurpose/webpos/config/WebPosUiLabels.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/webpos/config/WebPosUiLabels.xml?rev=703851&r1=703850&r2=703851&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/webpos/config/WebPosUiLabels.xml (original)
+++ ofbiz/trunk/specialpurpose/webpos/config/WebPosUiLabels.xml Sun Oct 12 10:24:07 2008
@@ -303,6 +303,10 @@
         <value xml:lang="en">Pay Check</value>
         <value xml:lang="it">Pagamento con Assegno</value>
     </property>
+    <property key="WebPosPageTitlePayClear">
+        <value xml:lang="en">Clear Payment</value>
+        <value xml:lang="it">Rimuovi Pagamento</value>
+    </property>
     <property key="WebPosPageTitlePayGiftCard">
         <value xml:lang="en">Pay Gift Card</value>
         <value xml:lang="it">Pagamento con Carta Regalo</value>

Modified: ofbiz/trunk/specialpurpose/webpos/script/org/ofbiz/webpos/event/ManagerEvents.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/webpos/script/org/ofbiz/webpos/event/ManagerEvents.xml?rev=703851&r1=703850&r2=703851&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/webpos/script/org/ofbiz/webpos/event/ManagerEvents.xml (original)
+++ ofbiz/trunk/specialpurpose/webpos/script/org/ofbiz/webpos/event/ManagerEvents.xml Sun Oct 12 10:24:07 2008
@@ -22,6 +22,7 @@
         <if-not-empty field="parameters.confirm">
             <call-class-method class-name="org.ofbiz.webpos.WebPosEvents" method-name="getWebPosSession" ret-field-name="webPosSession">
                 <field field-name="request" type="javax.servlet.http.HttpServletRequest"/>
+                <field field-name="posTerminalId" type="String"/>
             </call-class-method>
             <if-not-empty field="webPosSession">
                 <call-object-method obj-field-name="webPosSession" method-name="isManagerLoggedIn" ret-field-name="mgrLoggedIn"/>
@@ -79,6 +80,7 @@
         <if-not-empty field="parameters.confirm">
             <call-class-method class-name="org.ofbiz.webpos.WebPosEvents" method-name="getWebPosSession" ret-field-name="webPosSession">
                 <field field-name="request" type="javax.servlet.http.HttpServletRequest"/>
+                <field field-name="posTerminalId" type="String"/>
             </call-class-method>
             <if-not-empty field="webPosSession">
                 <call-object-method obj-field-name="webPosSession" method-name="isManagerLoggedIn" ret-field-name="mgrLoggedIn"/>
@@ -184,6 +186,7 @@
         <if-not-empty field="parameters.confirm">
             <call-class-method class-name="org.ofbiz.webpos.WebPosEvents" method-name="getWebPosSession" ret-field-name="webPosSession">
                 <field field-name="request" type="javax.servlet.http.HttpServletRequest"/>
+                <field field-name="posTerminalId" type="String"/>
             </call-class-method>
             <if-not-empty field="webPosSession">
                 <call-object-method obj-field-name="webPosSession" method-name="isManagerLoggedIn" ret-field-name="mgrLoggedIn"/>
@@ -251,6 +254,7 @@
     <simple-method method-name="shutdown" short-description="Shutdown" login-required="true">
         <call-class-method class-name="org.ofbiz.webpos.WebPosEvents" method-name="getWebPosSession" ret-field-name="webPosSession">
             <field field-name="request" type="javax.servlet.http.HttpServletRequest"/>
+            <field field-name="posTerminalId" type="String"/>
         </call-class-method>
         <if-not-empty field="webPosSession">
             <call-object-method obj-field-name="webPosSession" method-name="isManagerLoggedIn" ret-field-name="mgrLoggedIn"/>
@@ -273,6 +277,7 @@
         <if-not-empty field="parameters.confirm">
             <call-class-method class-name="org.ofbiz.webpos.WebPosEvents" method-name="getWebPosSession" ret-field-name="webPosSession">
                 <field field-name="request" type="javax.servlet.http.HttpServletRequest"/>
+                <field field-name="posTerminalId" type="String"/>
             </call-class-method>
             <if-not-empty field="webPosSession">
                 <call-object-method obj-field-name="webPosSession" method-name="isManagerLoggedIn" ret-field-name="mgrLoggedIn"/>
@@ -332,6 +337,7 @@
         <if-not-empty field="parameters.confirm">
             <call-class-method class-name="org.ofbiz.webpos.WebPosEvents" method-name="getWebPosSession" ret-field-name="webPosSession">
                 <field field-name="request" type="javax.servlet.http.HttpServletRequest"/>
+                <field field-name="posTerminalId" type="String"/>
             </call-class-method>
             <if-not-empty field="webPosSession">
                 <call-object-method obj-field-name="webPosSession" method-name="getCurrentTransaction" ret-field-name="webPosTransaction"/>

Modified: ofbiz/trunk/specialpurpose/webpos/script/org/ofbiz/webpos/event/PaymentEvents.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/webpos/script/org/ofbiz/webpos/event/PaymentEvents.xml?rev=703851&r1=703850&r2=703851&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/webpos/script/org/ofbiz/webpos/event/PaymentEvents.xml (original)
+++ ofbiz/trunk/specialpurpose/webpos/script/org/ofbiz/webpos/event/PaymentEvents.xml Sun Oct 12 10:24:07 2008
@@ -22,6 +22,7 @@
         <if-not-empty field="parameters.confirm">
             <call-class-method class-name="org.ofbiz.webpos.WebPosEvents" method-name="getWebPosSession" ret-field-name="webPosSession">
                 <field field-name="request" type="javax.servlet.http.HttpServletRequest"/>
+                <field field-name="posTerminalId" type="String"/>
             </call-class-method>
             <if-not-empty field="webPosSession">
                 <call-object-method obj-field-name="webPosSession" method-name="getCurrentTransaction" ret-field-name="webPosTransaction"/>
@@ -76,6 +77,7 @@
         <if-not-empty field="parameters.confirm">
             <call-class-method class-name="org.ofbiz.webpos.WebPosEvents" method-name="getWebPosSession" ret-field-name="webPosSession">
                 <field field-name="request" type="javax.servlet.http.HttpServletRequest"/>
+                <field field-name="posTerminalId" type="String"/>
             </call-class-method>
             <if-not-empty field="webPosSession">
                 <call-object-method obj-field-name="webPosSession" method-name="getCurrentTransaction" ret-field-name="webPosTransaction"/>
@@ -151,6 +153,7 @@
         <if-not-empty field="parameters.confirm">
             <call-class-method class-name="org.ofbiz.webpos.WebPosEvents" method-name="getWebPosSession" ret-field-name="webPosSession">
                 <field field-name="request" type="javax.servlet.http.HttpServletRequest"/>
+                <field field-name="posTerminalId" type="String"/>
             </call-class-method>
             <if-not-empty field="webPosSession">
                 <call-object-method obj-field-name="webPosSession" method-name="getCurrentTransaction" ret-field-name="webPosTransaction"/>
@@ -222,6 +225,7 @@
         <if-not-empty field="parameters.confirm">
             <call-class-method class-name="org.ofbiz.webpos.WebPosEvents" method-name="getWebPosSession" ret-field-name="webPosSession">
                 <field field-name="request" type="javax.servlet.http.HttpServletRequest"/>
+                <field field-name="posTerminalId" type="String"/>
             </call-class-method>
             <if-not-empty field="webPosSession">
                 <call-object-method obj-field-name="webPosSession" method-name="getCurrentTransaction" ret-field-name="webPosTransaction"/>
@@ -379,6 +383,7 @@
     <simple-method method-name="processSale" short-description="Process Sale" login-required="true">
         <call-class-method class-name="org.ofbiz.webpos.WebPosEvents" method-name="getWebPosSession" ret-field-name="webPosSession">
             <field field-name="request" type="javax.servlet.http.HttpServletRequest"/>
+            <field field-name="posTerminalId" type="String"/>
         </call-class-method>
         <if-not-empty field="webPosSession">
             <call-object-method obj-field-name="webPosSession" method-name="getCurrentTransaction" ret-field-name="webPosTransaction"/>
@@ -397,6 +402,7 @@
         <if-not-empty field="parameters.confirm">
             <call-class-method class-name="org.ofbiz.webpos.WebPosEvents" method-name="getWebPosSession" ret-field-name="webPosSession">
                 <field field-name="request" type="javax.servlet.http.HttpServletRequest"/>
+                <field field-name="posTerminalId" type="String"/>
             </call-class-method>
             <if-not-empty field="webPosSession">
                 <call-object-method obj-field-name="webPosSession" method-name="getCurrentTransaction" ret-field-name="webPosTransaction"/>
@@ -423,27 +429,100 @@
         <if-not-empty field="parameters.confirm">
             <call-class-method class-name="org.ofbiz.webpos.WebPosEvents" method-name="getWebPosSession" ret-field-name="webPosSession">
                 <field field-name="request" type="javax.servlet.http.HttpServletRequest"/>
+                <field field-name="posTerminalId" type="String"/>
             </call-class-method>
             <if-not-empty field="webPosSession">
                 <call-object-method obj-field-name="webPosSession" method-name="getCurrentTransaction" ret-field-name="webPosTransaction"/>
-                <check-errors/>
-                <set field="idx" from-field="parameters.idx" type="Integer"/>
-                <call-object-method obj-field-name="webPosTransaction" method-name="clearPayment">
-                    <field field-name="idx" type="int"/>
-                </call-object-method>
-                <check-errors/>
-                <log level="info" message="Cleared payment ${idx}"/>
+                <check-errors/>                                
+                <set field="payment" value="0" type="Integer"/>
+                <call-object-method obj-field-name="webPosTransaction" method-name="getNumberOfPayments" ret-field-name="numPayments"/>
+                <check-errors/>
+                <while>
+                    <condition>                     
+                        <if-compare-field field="payment" to-field="numPayments" operator="less"/>
+                    </condition> 
+                    <then>
+                        <call-object-method obj-field-name="webPosTransaction" method-name="getPaymentMethodTypeId" ret-field-name="paymentMethodTypeId">
+                            <field field-name="payment" type="int"/>
+                        </call-object-method>
+                        <check-errors/>
+                        <if-not-empty field="paymentMethodTypeId">       
+                            <if-not-empty field="parameters.clearCash">
+                                <if-compare field="parameters.clearCash" value="Y" operator="equals">                         
+                                    <if-compare field="paymentMethodTypeId" value="CASH" operator="equals">
+                                        <call-object-method obj-field-name="webPosTransaction" method-name="clearPayment">
+                                            <field field-name="payment" type="int"/>
+                                        </call-object-method>
+                                        <check-errors/>
+                                        <log level="info" message="Cleared CASH payment ${payment}"/>
+                                        <call-object-method obj-field-name="webPosTransaction" method-name="getNumberOfPayments" ret-field-name="numPayments"/>
+                                        <check-errors/>
+                                        <set field="payment" value="-1" type="Integer"/>
+                                    </if-compare>
+                                </if-compare>
+                            </if-not-empty>
+                            <if-not-empty field="parameters.clearCheck">
+                                <if-compare field="parameters.clearCheck" value="Y" operator="equals">                         
+                                    <if-compare field="paymentMethodTypeId" value="PERSONAL_CHECK" operator="equals">
+                                        <call-object-method obj-field-name="webPosTransaction" method-name="clearPayment">
+                                            <field field-name="payment" type="int"/>
+                                        </call-object-method>
+                                        <check-errors/>
+                                        <log level="info" message="Cleared CHECK payment ${payment}"/>
+                                        <call-object-method obj-field-name="webPosTransaction" method-name="getNumberOfPayments" ret-field-name="numPayments"/>
+                                        <check-errors/>
+                                        <set field="payment" value="-1" type="Integer"/>
+                                    </if-compare>
+                                </if-compare>
+                            </if-not-empty>                
+                            <if-not-empty field="parameters.clearGift">
+                                <if-compare field="parameters.clearGift" value="Y" operator="equals">                         
+                                    <if-compare field="paymentMethodTypeId" value="GIFT_CARD" operator="equals">
+                                        <call-object-method obj-field-name="webPosTransaction" method-name="clearPayment">
+                                            <field field-name="payment" type="int"/>
+                                        </call-object-method>
+                                        <check-errors/>
+                                        <log level="info" message="Cleared GIFT CARD payment ${payment}"/>
+                                        <call-object-method obj-field-name="webPosTransaction" method-name="getNumberOfPayments" ret-field-name="numPayments"/>
+                                        <check-errors/>
+                                        <set field="payment" value="-1" type="Integer"/>
+                                    </if-compare>
+                                </if-compare>
+                            </if-not-empty>                
+                            <if-not-empty field="parameters.clearCredit">
+                                <if-compare field="parameters.clearCredit" value="Y" operator="equals">                         
+                                    <if-compare field="paymentMethodTypeId" value="CREDIT_CARD" operator="equals">
+                                        <call-object-method obj-field-name="webPosTransaction" method-name="clearPayment">
+                                            <field field-name="payment" type="int"/>
+                                        </call-object-method>
+                                        <check-errors/>
+                                        <log level="info" message="Cleared CREDIT CARD payment ${payment}"/>
+                                        <call-object-method obj-field-name="webPosTransaction" method-name="getNumberOfPayments" ret-field-name="numPayments"/>
+                                        <check-errors/>
+                                        <set field="payment" value="-1" type="Integer"/>
+                                    </if-compare>
+                                </if-compare>
+                            </if-not-empty>                
+                        </if-not-empty>                        
+                        <calculate field-name="payment" type="Integer">
+                            <calcop field-name="payment" operator="add"/>
+                            <number value="1"/>
+                        </calculate>
+                    </then>
+                </while>                                           
             <else>
                 <add-error><fail-property resource="WebPosUiLabels" property="WebPosNotLoggedIn"/></add-error>
                 <check-errors/>
             </else>
             </if-not-empty>
         </if-not-empty>
+        <return response-code="success"/>
     </simple-method>
     
     <simple-method method-name="clearAllPayments" short-description="Clear All Payments" login-required="true">
         <call-class-method class-name="org.ofbiz.webpos.WebPosEvents" method-name="getWebPosSession" ret-field-name="webPosSession">
             <field field-name="request" type="javax.servlet.http.HttpServletRequest"/>
+            <field field-name="posTerminalId" type="String"/>
         </call-class-method>
         <if-not-empty field="webPosSession">
             <call-object-method obj-field-name="webPosSession" method-name="getCurrentTransaction" ret-field-name="webPosTransaction"/>

Modified: ofbiz/trunk/specialpurpose/webpos/script/org/ofbiz/webpos/event/PromoEvents.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/webpos/script/org/ofbiz/webpos/event/PromoEvents.xml?rev=703851&r1=703850&r2=703851&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/webpos/script/org/ofbiz/webpos/event/PromoEvents.xml (original)
+++ ofbiz/trunk/specialpurpose/webpos/script/org/ofbiz/webpos/event/PromoEvents.xml Sun Oct 12 10:24:07 2008
@@ -22,6 +22,7 @@
         <if-not-empty field="parameters.confirm">
             <call-class-method class-name="org.ofbiz.webpos.WebPosEvents" method-name="getWebPosSession" ret-field-name="webPosSession">
                 <field field-name="request" type="javax.servlet.http.HttpServletRequest"/>
+                <field field-name="posTerminalId" type="String"/>
             </call-class-method>
             <if-not-empty field="webPosSession">
                 <call-object-method obj-field-name="webPosSession" method-name="getCurrentTransaction" ret-field-name="webPosTransaction"/>

Modified: ofbiz/trunk/specialpurpose/webpos/servicedef/services.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/webpos/servicedef/services.xml?rev=703851&r1=703850&r2=703851&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/webpos/servicedef/services.xml (original)
+++ ofbiz/trunk/specialpurpose/webpos/servicedef/services.xml Sun Oct 12 10:24:07 2008
@@ -44,4 +44,9 @@
         <description>Login for Web Pos</description>
         <attribute type="String" mode="IN" name="posTerminalId" optional="false"/>
     </service>
+    
+    <service name="existsWebPosSession" engine="java"
+             location="org.ofbiz.webpos.WebPosEvents" invoke="existsWebPosSession">
+        <description>Check if exists a Web Pos Session</description>
+    </service>
 </services>
\ No newline at end of file

Modified: ofbiz/trunk/specialpurpose/webpos/servicedef/services_payment.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/webpos/servicedef/services_payment.xml?rev=703851&r1=703850&r2=703851&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/webpos/servicedef/services_payment.xml (original)
+++ ofbiz/trunk/specialpurpose/webpos/servicedef/services_payment.xml Sun Oct 12 10:24:07 2008
@@ -73,7 +73,10 @@
     <service name="clearPayment" engine="simple" auth="false" 
              location="org/ofbiz/webpos/event/PaymentEvents.xml" invoke="clearPayment">
         <description>Clear Payment</description>
-        <attribute name="idx" type="String" mode="IN" optional="true"/>
+        <attribute name="clearCash"   type="String" mode="IN" optional="true"/>
+        <attribute name="clearCheck"  type="String" mode="IN" optional="true"/>
+        <attribute name="clearGift"   type="String" mode="IN" optional="true"/>
+        <attribute name="clearCredit" type="String" mode="IN" optional="true"/>
     </service>
 
     <service name="clearAllPayments" engine="simple" auth="false" 

Modified: ofbiz/trunk/specialpurpose/webpos/src/org/ofbiz/webpos/WebPosEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/webpos/src/org/ofbiz/webpos/WebPosEvents.java?rev=703851&r1=703850&r2=703851&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/webpos/src/org/ofbiz/webpos/WebPosEvents.java (original)
+++ ofbiz/trunk/specialpurpose/webpos/src/org/ofbiz/webpos/WebPosEvents.java Sun Oct 12 10:24:07 2008
@@ -41,13 +41,27 @@
         
         if ("success".equals(responseString)) {
             HttpSession session = request.getSession(true); 
+        	
+            // get the posTerminalId
+            String posTerminalId = (String) request.getParameter("posTerminalId");
+            session.removeAttribute("shoppingCart");
             session.removeAttribute("webPosSession");
-            WebPosEvents.getWebPosSession(request);
+            WebPosEvents.getWebPosSession(request, posTerminalId);
         }
         return responseString;
     }
     
-    public static WebPosSession getWebPosSession(HttpServletRequest request) {
+    public static String existsWebPosSession(HttpServletRequest request, HttpServletResponse response) {
+    	String responseString = "success";
+    	HttpSession session = request.getSession(true);
+    	WebPosSession webPosSession = (WebPosSession) session.getAttribute("webPosSession");
+    	
+    	if (UtilValidate.isEmpty(webPosSession)) {
+    		responseString = "error";
+    	}
+        return responseString;
+    }
+    public static WebPosSession getWebPosSession(HttpServletRequest request, String posTerminalId) {
         HttpSession session = request.getSession(true);
         GenericValue userLogin = (GenericValue) session.getAttribute("userLogin");
         WebPosSession webPosSession = (WebPosSession) session.getAttribute("webPosSession");
@@ -71,11 +85,9 @@
             if (UtilValidate.isEmpty(cart)) {
                 cart = new ShoppingCart(delegator, productStoreId, request.getLocale(), currencyUomId);
                 session.setAttribute("shoppingCart", cart);
+                
             }
             
-            // get the posTerminalId
-            String posTerminalId = (String) request.getParameter("posTerminalId");
-            
             if (UtilValidate.isNotEmpty(posTerminalId)) {
             	webPosSession = new WebPosSession(posTerminalId, null, userLogin, request.getLocale(), productStoreId, facilityId, currencyUomId, delegator, dispatcher, cart);
                 session.setAttribute("webPosSession", webPosSession);
@@ -84,19 +96,20 @@
         return webPosSession;
     }
 
-    public static void removeWebPosSession(HttpServletRequest request) {
+    public static void removeWebPosSession(HttpServletRequest request, String posTerminalId) {
         HttpSession session = request.getSession(true);        
         session.removeAttribute("shoppingCart");
         session.removeAttribute("webPosSession");
-        getWebPosSession(request);
+        getWebPosSession(request, posTerminalId);
     }
 
     public static String completeSale(HttpServletRequest request, HttpServletResponse response) throws GeneralException {
         HttpSession session = request.getSession(true);
         WebPosSession webPosSession = (WebPosSession) session.getAttribute("webPosSession");
         if (UtilValidate.isNotEmpty(webPosSession)) {
-            webPosSession.getCurrentTransaction().processSale();            
-            removeWebPosSession(request);
+            webPosSession.getCurrentTransaction().processSale();  
+            String posTerminalId = webPosSession.getId();
+            removeWebPosSession(request, posTerminalId);
         }
         return "success";
     }

Modified: ofbiz/trunk/specialpurpose/webpos/src/org/ofbiz/webpos/transaction/WebPosTransaction.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/webpos/src/org/ofbiz/webpos/transaction/WebPosTransaction.java?rev=703851&r1=703850&r2=703851&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/webpos/src/org/ofbiz/webpos/transaction/WebPosTransaction.java (original)
+++ ofbiz/trunk/specialpurpose/webpos/src/org/ofbiz/webpos/transaction/WebPosTransaction.java Sun Oct 12 10:24:07 2008
@@ -37,6 +37,7 @@
 import org.ofbiz.entity.util.EntityUtil;
 import org.ofbiz.order.shoppingcart.CheckOutHelper;
 import org.ofbiz.order.shoppingcart.ShoppingCart;
+import org.ofbiz.order.shoppingcart.ShoppingCart.CartPaymentInfo;
 import org.ofbiz.order.shoppingcart.ShoppingCartItem;
 import org.ofbiz.product.store.ProductStoreWorker;
 import org.ofbiz.service.GenericServiceException;
@@ -303,6 +304,14 @@
         getCart().clearPayment(id);
     }
     
+    public CartPaymentInfo getPaymentInfo(int index) {
+        return getCart().getPaymentInfo(index);
+    }
+    
+    public String getPaymentMethodTypeId(int index) {
+        return getCart().getPaymentInfo(index).paymentMethodTypeId;
+    }
+    
     public int checkPaymentMethodType(String paymentMethodTypeId) {
         Map<String, ? extends Object> fields = UtilMisc.toMap("paymentMethodTypeId", paymentMethodTypeId, "productStoreId", webPosSession.getProductStoreId());
         List<GenericValue> values = null;

Modified: ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/buttons/Main.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/buttons/Main.groovy?rev=703851&r1=703850&r2=703851&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/buttons/Main.groovy (original)
+++ ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/buttons/Main.groovy Sun Oct 12 10:24:07 2008
@@ -21,7 +21,7 @@
 import org.ofbiz.webpos.session.WebPosSession;
 import org.ofbiz.webpos.transaction.WebPosTransaction;
 
-webPosSession = WebPosEvents.getWebPosSession(request);
+webPosSession = WebPosEvents.getWebPosSession(request, null);
 if (webPosSession) {
     context.shoppingCartSize = webPosSession.getCart().size();
     context.isManagerLoggedIn = webPosSession.isManagerLoggedIn();

Modified: ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/buttons/Payment.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/buttons/Payment.groovy?rev=703851&r1=703850&r2=703851&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/buttons/Payment.groovy (original)
+++ ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/buttons/Payment.groovy Sun Oct 12 10:24:07 2008
@@ -20,7 +20,7 @@
 import org.ofbiz.webpos.WebPosEvents;
 import org.ofbiz.webpos.session.WebPosSession;
 
-webPosSession = WebPosEvents.getWebPosSession(request);
+webPosSession = WebPosEvents.getWebPosSession(request, null);
 if (webPosSession) {
     context.cart = webPosSession.getCart();
     
@@ -29,4 +29,5 @@
     }
     
     context.totalDue = webPosSession.getCurrentTransaction().getTotalDue();
+    context.totalPayments = webPosSession.getCurrentTransaction().getPaymentTotal();
 }
\ No newline at end of file

Modified: ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/cart/MicroCart.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/cart/MicroCart.groovy?rev=703851&r1=703850&r2=703851&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/cart/MicroCart.groovy (original)
+++ ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/cart/MicroCart.groovy Sun Oct 12 10:24:07 2008
@@ -23,7 +23,7 @@
 import org.ofbiz.webpos.transaction.WebPosTransaction;
 import java.text.SimpleDateFormat;
 
-webPosSession = WebPosEvents.getWebPosSession(request);
+webPosSession = WebPosEvents.getWebPosSession(request, null);
 if (webPosSession) {
     shoppingCart = webPosSession.getCart();
     context.transactionId = webPosSession.getCurrentTransaction().getTransactionId();
@@ -36,6 +36,11 @@
     shoppingCart = null;
 }
 
+context.cashAmount = 0;
+context.checkAmount = 0;
+context.giftAmount = 0;
+context.creditAmount = 0;
+
 // Get the Cart and Prepare Size
 if (shoppingCart) {
     context.shoppingCartSize = shoppingCart.size();

Modified: ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/cart/ShowCart.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/cart/ShowCart.groovy?rev=703851&r1=703850&r2=703851&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/cart/ShowCart.groovy (original)
+++ ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/cart/ShowCart.groovy Sun Oct 12 10:24:07 2008
@@ -20,9 +20,11 @@
 import org.ofbiz.webpos.WebPosEvents;
 import org.ofbiz.webpos.session.WebPosSession;
 
-webPosSession = WebPosEvents.getWebPosSession(request);
+webPosSession = WebPosEvents.getWebPosSession(request, null);
 if (webPosSession) {
     shoppingCart = webPosSession.getCart();
+} else {
+    shoppingCart = null;
 }
 
 // Get the Cart and Prepare Size

Modified: ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/controller.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/controller.xml?rev=703851&r1=703850&r2=703851&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/controller.xml (original)
+++ ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/controller.xml Sun Oct 12 10:24:07 2008
@@ -109,7 +109,9 @@
     
     <request-map uri="main">
         <security https="true" auth="true"/>
+        <event type="java" path="org.ofbiz.webpos.WebPosEvents" invoke="existsWebPosSession"/>
         <response name="success" type="view" value="main"/>
+        <response name="error" type="view" value="login"/>
     </request-map>
     
     <request-map uri="Login">
@@ -340,11 +342,17 @@
         <response name="error" type="view" value="AddPaySetRef"/>
     </request-map>
     
-    <request-map uri="PayClear">
+    <request-map uri="AddClearPayment">
+        <security https="true" auth="true"/>        
+        <response name="success" type="view" value="ClearPayment"/>
+        <response name="error" type="view" value="ClearPayment"/>
+    </request-map>
+
+    <request-map uri="ClearPayment">
         <security https="true" auth="true"/>
         <event type="simple" path="org/ofbiz/webpos/event/PaymentEvents.xml" invoke="clearPayment"/>
         <response name="success" type="view" value="Payment"/>
-        <response name="error" type="view" value="Payment"/>
+        <response name="error" type="view" value="ClearPayment"/>
     </request-map>
     
     <request-map uri="PayClearAll">
@@ -392,7 +400,8 @@
     <view-map name="AddPayGiftCard" type="screen" page="component://webpos/widget/PaymentScreens.xml#PayGiftCard"/>
     <view-map name="AddPayCreditCard" type="screen" page="component://webpos/widget/PaymentScreens.xml#PayCreditCard"/>
     <view-map name="AddPaySetRef" type="screen" page="component://webpos/widget/PaymentScreens.xml#PaySetRef"/>
-    
+    <view-map name="ClearPayment" type="screen" page="component://webpos/widget/PaymentScreens.xml#ClearPayment"/>        
+
     <!-- Promo view mappings -->
     <view-map name="AddPromoCode" type="screen" page="component://webpos/widget/PromoScreens.xml#PromoCode"/>
     <!-- End of View Mappings -->

Modified: ofbiz/trunk/specialpurpose/webpos/webapp/webpos/buttons/Payment.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/webpos/webapp/webpos/buttons/Payment.ftl?rev=703851&r1=703850&r2=703851&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/webpos/webapp/webpos/buttons/Payment.ftl (original)
+++ ofbiz/trunk/specialpurpose/webpos/webapp/webpos/buttons/Payment.ftl Sun Oct 12 10:24:07 2008
@@ -46,10 +46,18 @@
     </tr>
     <tr>
         <td>
-            <a href="<@o...@ofbizUrl>" class="posButton">${uiLabelMap.WebPosButtonPayClear}</a>
+            <#if (totalPayments > 0.00)>
+                <a href="<@o...@ofbizUrl>" class="posButton">${uiLabelMap.WebPosButtonPayClear}</a>
+            <#else>
+                <span class="disabled">${uiLabelMap.WebPosButtonPayClear}</span>
+            </#if>
         </td>
         <td>
-            <a href="<@o...@ofbizUrl>" class="posButton">${uiLabelMap.WebPosButtonPayClearAll}</a>
+            <#if (totalPayments > 0.00)>
+                <a href="<@o...@ofbizUrl>" class="posButton">${uiLabelMap.WebPosButtonPayClearAll}</a>
+            <#else>
+                <span class="disabled">${uiLabelMap.WebPosButtonPayClearAll}</span>
+            </#if>
         </td>
         <td>
             <a href="<@o...@ofbizUrl>" class="posButton">${uiLabelMap.WebPosButtonMain}</a>

Added: ofbiz/trunk/specialpurpose/webpos/webapp/webpos/payment/ClearPayment.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/webpos/webapp/webpos/payment/ClearPayment.ftl?rev=703851&view=auto
==============================================================================
--- ofbiz/trunk/specialpurpose/webpos/webapp/webpos/payment/ClearPayment.ftl (added)
+++ ofbiz/trunk/specialpurpose/webpos/webapp/webpos/payment/ClearPayment.ftl Sun Oct 12 10:24:07 2008
@@ -0,0 +1,66 @@
+<#--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<div id="panel">
+  <form method="post" action="<@o...@ofbizUrl>" name="ClearPaymentForm">
+    <table border="0">
+      <tr>
+        <td>&nbsp;</td>
+        <td>&nbsp;</td>
+        <td><b><u>${uiLabelMap.WebPosPageTitlePayClear}</u></b></td>
+      </tr>
+      <#if (cashAmount?default(0) > 0.00)>
+      <tr>
+        <td><b>${(paymentCash.get("description", locale))?if_exists}</b></td>
+        <td align="right"><@ofbizCurrency amount=cashAmount isoCode=shoppingCart.getCurrency()/></td>
+        <td align="center"><input type="checkbox" name="clearCash" value="Y" checked/></td>
+      </tr>
+      </#if>
+      <#if (checkAmount?default(0) > 0.00)>
+      <tr>
+        <td><b>${(paymentCheck.get("description", locale))?if_exists}</b></td>
+        <td align="right"><@ofbizCurrency amount=checkAmount isoCode=shoppingCart.getCurrency()/></td>
+        <td align="center"><input type="checkbox" name="clearCheck" value="Y" checked/></td>
+      </tr>
+      </#if>
+      <#if (giftAmount?default(0) > 0.00)>
+      <tr>
+        <td><b>${(paymentGift.get("description", locale))?if_exists}</b></td>
+        <td align="right"><@ofbizCurrency amount=giftAmount isoCode=shoppingCart.getCurrency()/></td>
+        <td align="center"><input type="checkbox" name="clearGift" value="Y" checked/></td>
+      </tr>
+      </#if>
+      <#if (creditAmount?default(0) > 0.00)>
+      <tr>
+        <td><b>${(paymentCredit.get("description", locale))?if_exists}</b></td>
+        <td align="right"><@ofbizCurrency amount=creditAmount isoCode=shoppingCart.getCurrency()/></td>
+        <td align="center"><input type="checkbox" name="clearCredit" value="Y" checked/></td>
+      </tr>
+      </#if>
+      <tr>
+        <td colspan="3">&nbsp;</td>
+      </tr>
+      <tr>
+        <td colspan="3" align="center">
+          <input type="submit" value="${uiLabelMap.CommonConfirm}" name="confirm"/>
+          <input type="submit" value="${uiLabelMap.CommonCancel}"/>
+        </td>
+      </tr>
+    </table>
+  </form>
+</div>
\ No newline at end of file

Propchange: ofbiz/trunk/specialpurpose/webpos/webapp/webpos/payment/ClearPayment.ftl
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/trunk/specialpurpose/webpos/webapp/webpos/payment/ClearPayment.ftl
------------------------------------------------------------------------------
    svn:keywords = "Date Rev Author URL Id"

Propchange: ofbiz/trunk/specialpurpose/webpos/webapp/webpos/payment/ClearPayment.ftl
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: ofbiz/trunk/specialpurpose/webpos/widget/PaymentScreens.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/webpos/widget/PaymentScreens.xml?rev=703851&r1=703850&r2=703851&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/webpos/widget/PaymentScreens.xml (original)
+++ ofbiz/trunk/specialpurpose/webpos/widget/PaymentScreens.xml Sun Oct 12 10:24:07 2008
@@ -81,6 +81,22 @@
         </section>
     </screen>
     
+    <screen name="ClearPayment">
+        <section>
+            <actions>
+                <set field="rightbarScreenName" value="rightbar_payment"/>
+                <set field="titleProperty" value="WebPosPageTitlePayClear"/>
+                <script location="component://webpos/webapp/webpos/WEB-INF/actions/cart/MicroCart.groovy"/>
+            </actions>
+            <widgets>
+                <include-screen name="SearchProducts" location="component://webpos/widget/WebPosScreens.xml"/>
+                <container id="ClearPayment">
+                    <platform-specific><html><html-template location="component://webpos/webapp/webpos/payment/ClearPayment.ftl"/></html></platform-specific>
+                </container>
+            </widgets>
+        </section>
+    </screen>
+    
     <screen name="PaySetRef">
         <section>
             <actions>

Modified: ofbiz/trunk/specialpurpose/webpos/widget/WebPosScreens.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/webpos/widget/WebPosScreens.xml?rev=703851&r1=703850&r2=703851&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/webpos/widget/WebPosScreens.xml (original)
+++ ofbiz/trunk/specialpurpose/webpos/widget/WebPosScreens.xml Sun Oct 12 10:24:07 2008
@@ -136,9 +136,16 @@
                 <script location="component://webpos/webapp/webpos/WEB-INF/actions/cart/ShowCart.groovy"/>
             </actions>
             <widgets>
-                <container>
-                    <platform-specific><html><html-template location="component://webpos/webapp/webpos/cart/ShowCart.ftl"/></html></platform-specific>
-                </container>
+	            <section>
+		            <condition>
+		                <not><if-empty field-name="shoppingCart"/></not>
+		            </condition>
+		            <widgets>
+		                <container>
+		                    <platform-specific><html><html-template location="component://webpos/webapp/webpos/cart/ShowCart.ftl"/></html></platform-specific>
+		                </container>
+		            </widgets>
+	            </section>
             </widgets>
         </section>
     </screen>