svn commit: r698351 [2/5] - in /ofbiz/trunk/specialpurpose: ./ webpos/ webpos/build/ webpos/config/ webpos/data/ webpos/entitydef/ webpos/script/ webpos/script/org/ webpos/script/org/ofbiz/ webpos/script/org/ofbiz/webpos/ webpos/script/org/ofbiz/webpos...

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

svn commit: r698351 [2/5] - in /ofbiz/trunk/specialpurpose: ./ webpos/ webpos/build/ webpos/config/ webpos/data/ webpos/entitydef/ webpos/script/ webpos/script/org/ webpos/script/org/ofbiz/ webpos/script/org/ofbiz/webpos/ webpos/script/org/ofbiz/webpos...

mrisaliti
Added: 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=698351&view=auto
==============================================================================
--- ofbiz/trunk/specialpurpose/webpos/script/org/ofbiz/webpos/event/PaymentEvents.xml (added)
+++ ofbiz/trunk/specialpurpose/webpos/script/org/ofbiz/webpos/event/PaymentEvents.xml Tue Sep 23 14:09:28 2008
@@ -0,0 +1,460 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<simple-methods xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.ofbiz.org/dtds/simple-methods.xsd">
+    <simple-method method-name="payCash" short-description="Pay Cash" login-required="true">
+        <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"/>
+            </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="amount" from-field="parameters.amount" type="String"/>
+                <set field="allowNegative" value="false" type="Boolean"/>
+                <set field="allowPositive" value="true" type="Boolean"/>
+                <set field="minDecimal" value="0" type="Integer"/>
+                <set field="maxDecimal" value="3" type="Integer"/>
+                <call-class-method class-name="org.ofbiz.base.util.UtilValidate" method-name="isDouble" ret-field-name="isDouble">
+                    <field field-name="amount" type="String"/>
+                    <field field-name="allowNegative" type="boolean"/>
+                    <field field-name="allowPositive" type="boolean"/>
+                    <field field-name="minDecimal" type="int"/>
+                    <field field-name="maxDecimal" type="int"/>
+                </call-class-method>
+                <if-compare field="isDouble" operator="equals" value="true">
+                    <set field="paymentType" value="CASH"/>
+                    <call-object-method obj-field-name="webPosTransaction" method-name="clearPayment">
+                        <field field-name="paymentType" type="String"/>
+                    </call-object-method>
+                    <check-errors/>
+                    <set from-field="parameters.amount" field="amounStr"/>
+                    <call-object-method obj-field-name="webPosTransaction" method-name="processAmount" ret-field-name="amount">
+                        <field field-name="amounStr" type="String"/>
+                    </call-object-method>
+                    <check-errors/>
+                    <log level="info" message="Processing [Cash] Amount : ${amount}"/>
+                    <set field="refNum" value=""/>
+                    <set field="authCode" value=""/>
+                    <call-object-method obj-field-name="webPosTransaction" method-name="addPayment">
+                        <field field-name="paymentType" type="String"/>
+                        <field field-name="amount" type="double"/>
+                        <field field-name="refNum" type="String"/>
+                        <field field-name="authCode" type="String"/>
+                    </call-object-method>
+                    <check-errors/>
+                <else>
+                    <add-error><fail-property resource="WebPosUiLabels" property="WebPosPayCashNotValidAmount"/></add-error>
+                    <check-errors/>
+                </else>
+                </if-compare>
+            <else>
+                <add-error><fail-property resource="WebPosUiLabels" property="WebPosNotLoggedIn"/></add-error>
+                <check-errors/>
+            </else>
+            </if-not-empty>
+        </if-not-empty>
+    </simple-method>
+    
+    <simple-method method-name="payCheck" short-description="Pay Check" login-required="true">
+        <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"/>
+            </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="amount" from-field="parameters.amount" type="String"/>
+                <set field="allowNegative" value="false" type="Boolean"/>
+                <set field="allowPositive" value="true" type="Boolean"/>
+                <set field="minDecimal" value="0" type="Integer"/>
+                <set field="maxDecimal" value="3" type="Integer"/>
+                <call-class-method class-name="org.ofbiz.base.util.UtilValidate" method-name="isDouble" ret-field-name="isDouble">
+                    <field field-name="amount" type="String"/>
+                    <field field-name="allowNegative" type="boolean"/>
+                    <field field-name="allowPositive" type="boolean"/>
+                    <field field-name="minDecimal" type="int"/>
+                    <field field-name="maxDecimal" type="int"/>
+                </call-class-method>
+                <if-compare field="isDouble" operator="equals" value="true">
+                    <set field="paymentType" value="PERSONAL_CHECK"/>
+                    <call-object-method obj-field-name="webPosTransaction" method-name="checkPaymentMethodType" ret-field-name="paymentCheck">
+                        <field field-name="paymentType" type="String"/>
+                    </call-object-method>
+                    <check-errors/>
+                    <call-class-method class-name="org.ofbiz.webpos.transaction.WebPosTransaction" method-name="getNoPaymentCode" ret-field-name="noPaymentCode"/>
+                    <call-class-method class-name="org.ofbiz.webpos.transaction.WebPosTransaction" method-name="getExternalPaymentCode" ret-field-name="externalPaymentCode"/>            
+                    <!--  No Payment -->
+                    <if-compare-field field="paymentCheck" operator="equals" to-field="noPaymentCode">
+                        <call-object-method obj-field-name="webPosTransaction" method-name="clearPayment">
+                            <field field-name="paymentType" type="String"/>
+                        </call-object-method>
+                        <check-errors/>
+                        <call-object-method obj-field-name="webPosTransaction" method-name="processNoPayment">
+                            <field field-name="paymentType" type="String"/>
+                        </call-object-method>
+                        <check-errors/>
+                    <else>
+                        <!--  External Payment -->
+                        <if-compare-field field="paymentCheck" operator="equals" to-field="externalPaymentCode">
+                            <if-not-empty field="parameters.refNum">
+                                <set field="refNum" from-field="parameters.refNum"/>
+                                <call-object-method obj-field-name="webPosTransaction" method-name="processExternalPayment">
+                                    <field field-name="paymentType" type="String"/>
+                                    <field field-name="amount" type="String"/>
+                                    <field field-name="refNum" type="String"/>
+                                </call-object-method>
+                                <check-errors/>
+                            <else>
+                                <add-error><fail-property resource="WebPosUiLabels" property="WebPosPaymentCheckMissingRefNum"/></add-error>
+                                <check-errors/>
+                            </else>
+                            </if-not-empty>
+                        <!--  Internal Payment not yet supported -->
+                        <else>
+                            <add-error><fail-property resource="WebPosUiLabels" property="WebPosPaymentCheckInternal"/></add-error>
+                            <check-errors/>
+                        </else>
+                        </if-compare-field>
+                    </else>
+                    </if-compare-field>
+                <else>
+                    <add-error><fail-property resource="WebPosUiLabels" property="WebPosPayCheckNotValidAmount"/></add-error>
+                    <check-errors/>
+                </else>
+                </if-compare>
+            <else>
+                <add-error><fail-property resource="WebPosUiLabels" property="WebPosNotLoggedIn"/></add-error>
+                <check-errors/>
+            </else>
+            </if-not-empty>
+        </if-not-empty>
+    </simple-method>
+    
+    <simple-method method-name="payGiftCard" short-description="Pay Gift Card" login-required="true">
+        <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"/>
+            </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="amount" from-field="parameters.amount" type="String"/>
+                <set field="allowNegative" value="false" type="Boolean"/>
+                <set field="allowPositive" value="true" type="Boolean"/>
+                <set field="minDecimal" value="0" type="Integer"/>
+                <set field="maxDecimal" value="3" type="Integer"/>
+                <call-class-method class-name="org.ofbiz.base.util.UtilValidate" method-name="isDouble" ret-field-name="isDouble">
+                    <field field-name="amount" type="String"/>
+                    <field field-name="allowNegative" type="boolean"/>
+                    <field field-name="allowPositive" type="boolean"/>
+                    <field field-name="minDecimal" type="int"/>
+                    <field field-name="maxDecimal" type="int"/>
+                </call-class-method>
+                <if-compare field="isDouble" operator="equals" value="true">
+                    <set field="paymentType" value="GIFT_CARD"/>
+                    <call-object-method obj-field-name="webPosTransaction" method-name="checkPaymentMethodType" ret-field-name="paymentCheck">
+                        <field field-name="paymentType" type="String"/>
+                    </call-object-method>
+                    <check-errors/>
+                    <call-class-method class-name="org.ofbiz.webpos.transaction.WebPosTransaction" method-name="getNoPaymentCode" ret-field-name="noPaymentCode"/>
+                    <call-class-method class-name="org.ofbiz.webpos.transaction.WebPosTransaction" method-name="getExternalPaymentCode" ret-field-name="externalPaymentCode"/>            
+                    <!--  No Payment -->
+                    <if-compare-field field="paymentCheck" operator="equals" to-field="noPaymentCode">
+                        <call-object-method obj-field-name="webPosTransaction" method-name="processNoPayment">
+                            <field field-name="paymentType" type="String"/>
+                        </call-object-method>
+                        <check-errors/>
+                    <else>
+                        <!--  External Payment -->
+                        <if-compare-field field="paymentCheck" operator="equals" to-field="externalPaymentCode">
+                            <if-not-empty field="parameters.refNum">
+                                <set field="refNum" from-field="parameters.refNum"/>
+                                <call-object-method obj-field-name="webPosTransaction" method-name="processExternalPayment">
+                                    <field field-name="paymentType" type="String"/>
+                                    <field field-name="amount" type="String"/>
+                                    <field field-name="refNum" type="String"/>
+                                </call-object-method>
+                                <check-errors/>
+                            <else>
+                                <add-error><fail-property resource="WebPosUiLabels" property="WebPosPaymentGiftCardMissingRefNum"/></add-error>                            
+                                <check-errors/>
+                            </else>
+                            </if-not-empty>
+                        <!--  Internal Payment not yet supported -->
+                        <else>
+                            <add-error><fail-property resource="WebPosUiLabels" property="WebPosPaymentGiftCardInternal"/></add-error>
+                            <check-errors/>
+                        </else>
+                        </if-compare-field>
+                    </else>
+                    </if-compare-field>
+                <else>
+                    <add-error><fail-property resource="WebPosUiLabels" property="WebPosPayGiftCardNotValidAmount"/></add-error>
+                    <check-errors/>
+                </else>
+                </if-compare>
+            <else>
+                <add-error><fail-property resource="WebPosUiLabels" property="WebPosNotLoggedIn"/></add-error>
+                <check-errors/>
+            </else>
+            </if-not-empty>
+        </if-not-empty>
+    </simple-method>
+    
+    <simple-method method-name="payCredit" short-description="Pay Credit Card" login-required="true">
+        <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"/>
+            </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="amount" from-field="parameters.amount" type="String"/>
+                <set field="allowNegative" value="false" type="Boolean"/>
+                <set field="allowPositive" value="true" type="Boolean"/>
+                <set field="minDecimal" value="0" type="Integer"/>
+                <set field="maxDecimal" value="3" type="Integer"/>
+                <call-class-method class-name="org.ofbiz.base.util.UtilValidate" method-name="isDouble" ret-field-name="isDouble">
+                    <field field-name="amount" type="String"/>
+                    <field field-name="allowNegative" type="boolean"/>
+                    <field field-name="allowPositive" type="boolean"/>
+                    <field field-name="minDecimal" type="int"/>
+                    <field field-name="maxDecimal" type="int"/>
+                </call-class-method>
+                <if-compare field="isDouble" operator="equals" value="true">
+                <set field="paymentType" value="CREDIT_CARD"/>
+                    <call-object-method obj-field-name="webPosTransaction" method-name="checkPaymentMethodType" ret-field-name="paymentCheck">
+                        <field field-name="paymentType" type="String"/>
+                    </call-object-method>
+                    <check-errors/>
+                    <call-class-method class-name="org.ofbiz.webpos.transaction.WebPosTransaction" method-name="getNoPaymentCode" ret-field-name="noPaymentCode"/>
+                    <call-class-method class-name="org.ofbiz.webpos.transaction.WebPosTransaction" method-name="getExternalPaymentCode" ret-field-name="externalPaymentCode"/>            
+                    <!--  No Payment -->
+                    <if-compare-field field="paymentCheck" operator="equals" to-field="noPaymentCode">
+                        <call-object-method obj-field-name="webPosTransaction" method-name="processNoPayment">
+                            <field field-name="paymentType" type="String"/>
+                        </call-object-method>
+                        <check-errors/>
+                    <else>
+                        <!--  External Payment -->
+                        <if-compare-field field="paymentCheck" operator="equals" to-field="externalPaymentCode">
+                            <if-not-empty field="parameters.refNum">
+                                <set field="refNum" from-field="parameters.refNum"/>
+                                <call-object-method obj-field-name="webPosTransaction" method-name="processExternalPayment">
+                                    <field field-name="paymentType" type="String"/>
+                                    <field field-name="amount" type="String"/>
+                                    <field field-name="refNum" type="String"/>
+                                </call-object-method>
+                                <check-errors/>
+                            <else>
+                                <add-error><fail-property resource="WebPosUiLabels" property="WebPosPaymentCreditCardMissingRefNum"/></add-error>
+                                <check-errors/>
+                            </else>
+                            </if-not-empty>
+                        <!--  Internal Payment -->
+                        <else>
+                            <!-- test credit card -->
+                            <if-not-empty field="parameters.cardNum">
+                                <set field="cardNum" from-field="parameters.cardNum"/>
+                                <call-class-method class-name="org.ofbiz.base.util.UtilValidate" method-name="isCreditCard" ret-field-name="isCreditCard">
+                                    <field field-name="cardNum" type="String"/>
+                                </call-class-method>
+                                <if-compare field="isCreditCard" operator="equals" value="false" type="String">
+                                    <add-error><fail-property resource="WebPosUiLabels" property="WebPosPaymentCredictCardInvalid"/></add-error>
+                                    <check-errors/>
+                                </if-compare>
+                                <!-- test expiration date -->
+                                <if-not-empty field="parameters.expMonth">
+                                    <set field="cardExp" from-field="parameters.expMonth"/>
+                                    <string-append string="${parameters.expYear}" field-name="cardExp"/>
+                                    <call-object-method obj-field-name="cardExp" method-name="length" ret-field-name="length"/>
+                                    <if-compare field="length" operator="not-equals" value="6">
+                                        <add-error><fail-property resource="WebPosUiLabels" property="WebPosPaymentCredictCardInvalidExpiringDate"/></add-error>
+                                        <check-errors/>
+                                    </if-compare>
+                                <else>
+                                    <add-error><fail-property resource="WebPosUiLabels" property="WebPosPaymentCredictCardInvalidExpiringDate"/></add-error>
+                                    <check-errors/>
+                                </else>
+                                </if-not-empty>
+                                <!-- test security code - allow blank for illegible cards -->
+                                <if-not-empty field="parameters.securityCode">
+                                    <set field="securityCode" from-field="parameters.securityCode"/>
+                                    <call-object-method obj-field-name="securityCode" method-name="length" ret-field-name="length"/>                            
+                                    <if-compare field="length" operator="greater" value="4">
+                                        <add-error><fail-property resource="WebPosUiLabels" property="WebPosPaymentCredictCardInvalidSecurityCode"/></add-error>
+                                        <check-errors/>
+                                    </if-compare>
+                                </if-not-empty>
+                                <set field="amountStr" from-field="parameters.amount"/>
+                                <call-object-method obj-field-name="webPosTransaction" method-name="processAmount" ret-field-name="amount">
+                                    <field field-name="amountStr" type="String"/>
+                                </call-object-method>
+                                <check-errors/>
+                                <log level="info" message="Processing Credit Card Amount : ${amount}"/>
+                                <set from-field="parameters.firstName" field="firstName"/>
+                                <set from-field="parameters.lastName" field="lastName"/>
+                                <call-object-method obj-field-name="webPosTransaction" method-name="makeCreditCardVo" ret-field-name="paymentId">
+                                    <field field-name="cardNum" type="String"/>
+                                    <field field-name="cardExp" type="String"/>
+                                    <field field-name="firstName" type="String"/>
+                                    <field field-name="lastName" type="String"/>
+                                </call-object-method>
+                                <check-errors/>
+                                <if-not-empty field="paymentId">
+                                    <call-object-method obj-field-name="webPosTransaction" method-name="addPayment">
+                                        <field field-name="paymentId" type="String"/>
+                                        <field field-name="amount" type="double"/>
+                                    </call-object-method>
+                                    <check-errors/>
+                                    <if-not-empty field="parameters.track2">
+                                        <set field="refNum" value=""/>
+                                        <set field="securityCode" value="parameters.track2"/>
+                                        <call-object-method obj-field-name="webPosTransaction" method-name="setPaymentTrack2">
+                                            <field field-name="paymentId" type="String"/>
+                                            <field field-name="refNum" type="String"/>
+                                            <field field-name="securityCode" type="String"/>
+                                        </call-object-method>
+                                    <else>
+                                        <if-not-empty field="parameters.securityCode">
+                                            <set field="refNum" value=""/>
+                                            <set field="securityCode" value="parameters.securityCode"/>
+                                            <call-object-method obj-field-name="webPosTransaction" method-name="setPaymentSecurityCode">
+                                                <field field-name="paymentId" type="String"/>
+                                                <field field-name="refNum" type="String"/>
+                                                <field field-name="securityCode" type="String"/>
+                                            </call-object-method>
+                                        </if-not-empty>
+                                        <if-not-empty field="parameters.postalCode">
+                                            <set field="refNum" value=""/>
+                                            <set field="securityCode" value="parameters.postalCode"/>
+                                            <call-object-method obj-field-name="webPosTransaction" method-name="setPaymentPostalCode">
+                                                <field field-name="paymentId" type="String"/>
+                                                <field field-name="refNum" type="String"/>
+                                                <field field-name="securityCode" type="String"/>
+                                            </call-object-method>
+                                        </if-not-empty>
+                                    </else>
+                                    </if-not-empty>
+                                </if-not-empty>
+                            <else>
+                                <add-error><fail-property resource="WebPosUiLabels" property="WebPosPaymentCredictCardInvalid"/></add-error>
+                                <check-errors/>
+                            </else>
+                            </if-not-empty>
+                        </else>
+                        </if-compare-field>
+                    </else>
+                    </if-compare-field>
+                <else>
+                    <add-error><fail-property resource="WebPosUiLabels" property="WebPosPayCreditCardNotValidAmount"/></add-error>
+                    <check-errors/>
+                </else>
+                </if-compare>
+            <else>
+                <add-error><fail-property resource="WebPosUiLabels" property="WebPosNotLoggedIn"/></add-error>
+                <check-errors/>
+            </else>
+            </if-not-empty>
+        </if-not-empty>
+    </simple-method>
+    
+    <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"/>
+        </call-class-method>
+        <if-not-empty field="webPosSession">
+            <call-object-method obj-field-name="webPosSession" method-name="getCurrentTransaction" ret-field-name="webPosTransaction"/>
+            <check-errors/>
+            <call-object-method obj-field-name="webPosTransaction" method-name="processSale" ret-field-name="changeDue"/>
+            <check-errors/>
+            <log level="info" message="Processe sale for a change due amount of ${changeDue}"/>
+        <else>
+            <add-error><fail-property resource="WebPosUiLabels" property="WebPosNotLoggedIn"/></add-error>
+            <check-errors/>
+        </else>
+        </if-not-empty>
+    </simple-method>
+    
+    <simple-method method-name="setRefNum" short-description="Set Payment Refernce Number" login-required="true">
+        <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"/>
+            </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"/>
+                <set field="refNum" from-field="parameters.refNum"/>
+                <set field="authCode" from-field="parameters.authCode"/>
+                <call-object-method obj-field-name="webPosTransaction" method-name="setPaymentRefNum">
+                    <field field-name="idx" type="int"/>
+                    <field field-name="refNum" type="String"/>
+                    <field field-name="authCode" type="String"/>
+                </call-object-method>
+                <check-errors/>
+                <log level="info" message="Set the reference number ${idx} to ${refNum}"/>
+            <else>
+                <add-error><fail-property resource="WebPosUiLabels" property="WebPosNotLoggedIn"/></add-error>
+                <check-errors/>
+            </else>
+            </if-not-empty>
+        </if-not-empty>
+    </simple-method>
+    
+    <simple-method method-name="clearPayment" short-description="Clear Payment" login-required="true">
+        <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"/>
+            </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}"/>
+            <else>
+                <add-error><fail-property resource="WebPosUiLabels" property="WebPosNotLoggedIn"/></add-error>
+                <check-errors/>
+            </else>
+            </if-not-empty>
+        </if-not-empty>
+    </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"/>
+        </call-class-method>
+        <if-not-empty field="webPosSession">
+            <call-object-method obj-field-name="webPosSession" method-name="getCurrentTransaction" ret-field-name="webPosTransaction"/>
+            <check-errors/>
+            <call-object-method obj-field-name="webPosTransaction" method-name="clearPayments"/>
+            <check-errors/>
+            <log level="info" message="Cleared All Payments"/>
+        <else>
+            <add-error><fail-property resource="WebPosUiLabels" property="WebPosNotLoggedIn"/></add-error>
+            <check-errors/>
+        </else>
+        </if-not-empty>
+    </simple-method>
+</simple-methods>
\ No newline at end of file

Propchange: ofbiz/trunk/specialpurpose/webpos/script/org/ofbiz/webpos/event/PaymentEvents.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/trunk/specialpurpose/webpos/script/org/ofbiz/webpos/event/PaymentEvents.xml
------------------------------------------------------------------------------
    svn:executable = *

Propchange: ofbiz/trunk/specialpurpose/webpos/script/org/ofbiz/webpos/event/PaymentEvents.xml
------------------------------------------------------------------------------
    svn:keywords = "Date Rev Author URL Id"

Propchange: ofbiz/trunk/specialpurpose/webpos/script/org/ofbiz/webpos/event/PaymentEvents.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: 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=698351&view=auto
==============================================================================
--- ofbiz/trunk/specialpurpose/webpos/script/org/ofbiz/webpos/event/PromoEvents.xml (added)
+++ ofbiz/trunk/specialpurpose/webpos/script/org/ofbiz/webpos/event/PromoEvents.xml Tue Sep 23 14:09:28 2008
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<simple-methods xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.ofbiz.org/dtds/simple-methods.xsd">
+    <simple-method method-name="addPromoCode" short-description="Add Promotion Code" login-required="true">
+        <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"/>
+            </call-class-method>
+            <if-not-empty field="webPosSession">
+                <call-object-method obj-field-name="webPosSession" method-name="getCurrentTransaction" ret-field-name="webPosTransaction"/>
+                <check-errors/>
+                <call-object-method obj-field-name="webPosTransaction" method-name="isOpen" ret-field-name="isOpen"/>
+                <if-compare field="isOpen" operator="equals" value="true" type="String">
+                    <set field="promoCode" from-field="parameters.promoCode"/>
+                    <call-object-method obj-field-name="webPosTransaction" method-name="addProductPromoCode" ret-field-name="result">
+                        <field field-name="promoCode" type="String"/>
+                    </call-object-method>
+                    <check-errors/>
+                    <!-- TODO handle exceptions and errors -->
+                    <log level="info" message="Added product promotion code ${promoCode}"/>
+                <else>
+                    <add-error><fail-property resource="WebPosUiLabels" property="WebPosPromoCodeTerminalNotOpened"/></add-error>
+                    <check-errors/>
+                </else>
+                </if-compare>
+            <else>
+                <add-error><fail-property resource="WebPosUiLabels" property="WebPosNotLoggedIn"/></add-error>
+                <check-errors/>
+            </else>
+            </if-not-empty>
+        </if-not-empty>
+    </simple-method>
+</simple-methods>
\ No newline at end of file

Propchange: ofbiz/trunk/specialpurpose/webpos/script/org/ofbiz/webpos/event/PromoEvents.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/trunk/specialpurpose/webpos/script/org/ofbiz/webpos/event/PromoEvents.xml
------------------------------------------------------------------------------
    svn:executable = *

Propchange: ofbiz/trunk/specialpurpose/webpos/script/org/ofbiz/webpos/event/PromoEvents.xml
------------------------------------------------------------------------------
    svn:keywords = "Date Rev Author URL Id"

Propchange: ofbiz/trunk/specialpurpose/webpos/script/org/ofbiz/webpos/event/PromoEvents.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: ofbiz/trunk/specialpurpose/webpos/servicedef/services.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/webpos/servicedef/services.xml?rev=698351&view=auto
==============================================================================
--- ofbiz/trunk/specialpurpose/webpos/servicedef/services.xml (added)
+++ ofbiz/trunk/specialpurpose/webpos/servicedef/services.xml Tue Sep 23 14:09:28 2008
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<services xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.ofbiz.org/dtds/services.xsd">
+    <description>Web Pos Services</description>
+    <vendor>OFBiz</vendor>
+    <version>1.0</version>
+    
+    <service name="FindProducts" engine="simple"
+             location="org/ofbiz/webpos/WebPosServices.xml" invoke="FindProducts">
+        <description>Find products by name/description</description>
+        <attribute type="String" mode="IN" name="searchBy" optional="false"/>
+        <attribute type="String" mode="IN" name="productToSearch" optional="true"/>
+        <attribute type="java.util.List" mode="OUT" name="productsList" optional="true"/>
+        <attribute type="java.util.List" mode="OUT" name="productsId" optional="true"/>
+    </service>
+    
+    <service name="FindProductsByIdentification" engine="simple"
+             location="org/ofbiz/webpos/WebPosServices.xml" invoke="FindProductsByIdentification">
+        <description>Find products by good identification</description>
+        <attribute type="String" mode="IN" name="productGoodIdentification" optional="true"/>
+        <attribute type="java.util.List" mode="OUT" name="productsList" optional="true"/>
+        <attribute type="java.util.List" mode="OUT" name="productsId" optional="true"/>
+    </service>
+</services>
\ No newline at end of file

Propchange: ofbiz/trunk/specialpurpose/webpos/servicedef/services.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/trunk/specialpurpose/webpos/servicedef/services.xml
------------------------------------------------------------------------------
    svn:executable = *

Propchange: ofbiz/trunk/specialpurpose/webpos/servicedef/services.xml
------------------------------------------------------------------------------
    svn:keywords = "Date Rev Author URL Id"

Propchange: ofbiz/trunk/specialpurpose/webpos/servicedef/services.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: ofbiz/trunk/specialpurpose/webpos/servicedef/services_manager.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/webpos/servicedef/services_manager.xml?rev=698351&view=auto
==============================================================================
--- ofbiz/trunk/specialpurpose/webpos/servicedef/services_manager.xml (added)
+++ ofbiz/trunk/specialpurpose/webpos/servicedef/services_manager.xml Tue Sep 23 14:09:28 2008
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<services xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.ofbiz.org/dtds/services.xsd">
+    <description>Web Pos Manager Services</description>
+    <vendor>OFBiz</vendor>
+    <version>1.0</version>
+    
+    <service name="openTerminal" engine="simple" auth="false"
+             location="org/ofbiz/webpos/event/ManagerEvents.xml" invoke="openTerminal">
+        <description>Open Terminal</description>
+        <attribute name="startingDrawerAmount" type="Double" mode="IN" optional="false"/>
+    </service>
+    
+    <service name="closeTerminal" engine="simple" auth="false"
+             location="org/ofbiz/webpos/event/ManagerEvents.xml" invoke="closeTerminal">
+        <description>Close Terminal</description>
+        <attribute name="endingDrawerCashAmount"  type="Double" mode="IN" optional="false"/>
+        <attribute name="endingDrawerCheckAmount" type="Double" mode="IN" optional="false"/>
+        <attribute name="endingDrawerCcAmount"    type="Double" mode="IN" optional="false"/>
+        <attribute name="endingDrawerGcAmount"    type="Double" mode="IN" optional="false"/>
+        <attribute name="endingDrawerOtherAmount" type="Double" mode="IN" optional="false"/>
+    </service>
+
+    <service name="voidOrder" engine="simple" auth="false"
+             location="org/ofbiz/webpos/event/ManagerEvents.xml" invoke="voidOrder">
+        <description>Void Order</description>
+        <attribute name="orderId" type="String" mode="IN" optional="false"/>
+    </service>
+
+    <service name="shutdown" engine="simple" auth="false"
+             location="org/ofbiz/webpos/event/ManagerEvents.xml" invoke="shutdown">
+        <description>Shutdown</description>        
+    </service>
+
+    <service name="paidOutAndIn" engine="simple" auth="false"
+             location="org/ofbiz/webpos/event/ManagerEvents.xml" invoke="paidOutAndIn">
+        <description>Paid Out and In</description>
+        <attribute name="type"         type="String" mode="IN" optional="false"/>
+        <attribute name="amountInOut"  type="Double" mode="IN" optional="false"/>
+        <attribute name="reasonInOut"  type="String" mode="IN" optional="false"/>
+    </service>
+
+    <service name="modifyPrice" engine="simple" auth="false"
+             location="org/ofbiz/webpos/event/ManagerEvents.xml" invoke="modifyPrice">
+        <description>Modify Price</description>
+        <attribute name="sku"   type="String" mode="IN" optional="false"/>
+        <attribute name="price" type="Double" mode="IN" optional="false"/>
+    </service>
+</services>
\ No newline at end of file

Propchange: ofbiz/trunk/specialpurpose/webpos/servicedef/services_manager.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/trunk/specialpurpose/webpos/servicedef/services_manager.xml
------------------------------------------------------------------------------
    svn:executable = *

Propchange: ofbiz/trunk/specialpurpose/webpos/servicedef/services_manager.xml
------------------------------------------------------------------------------
    svn:keywords = "Date Rev Author URL Id"

Propchange: ofbiz/trunk/specialpurpose/webpos/servicedef/services_manager.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: ofbiz/trunk/specialpurpose/webpos/servicedef/services_payment.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/webpos/servicedef/services_payment.xml?rev=698351&view=auto
==============================================================================
--- ofbiz/trunk/specialpurpose/webpos/servicedef/services_payment.xml (added)
+++ ofbiz/trunk/specialpurpose/webpos/servicedef/services_payment.xml Tue Sep 23 14:09:28 2008
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<services xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.ofbiz.org/dtds/services.xsd">
+    <description>Web Pos Payment Services</description>
+    <vendor>OFBiz</vendor>
+    <version>1.0</version>
+    
+    <service name="payCash" engine="simple" auth="false"
+             location="org/ofbiz/webpos/event/PaymentEvents.xml" invoke="payCash">
+        <description>Pay Cash</description>
+        <attribute name="amount" type="String" mode="IN" optional="false"/>
+    </service>
+
+    <service name="payCheck" engine="simple" auth="false"
+             location="org/ofbiz/webpos/event/PaymentEvents.xml" invoke="payCheck">
+        <description>Pay Check</description>
+        <attribute name="amount" type="String" mode="IN" optional="false"/>
+        <attribute name="refNum" type="String" mode="IN" optional="true"/>
+    </service>
+
+    <service name="payGiftCard" engine="simple" auth="false"
+             location="org/ofbiz/webpos/event/PaymentEvents.xml" invoke="payGiftCard">
+        <description>Pay Gift Card</description>
+        <attribute name="amount" type="String" mode="IN" optional="false"/>
+        <attribute name="refNum" type="String" mode="IN" optional="true"/>
+    </service>
+
+    <service name="payCredit" engine="simple" auth="false"
+             location="org/ofbiz/webpos/event/PaymentEvents.xml" invoke="payCredit">
+        <description>Pay Credit Card</description>
+        <attribute name="amount" type="String" mode="IN" optional="false"/>
+        <attribute name="refNum" type="String" mode="IN" optional="true"/>
+        <attribute name="cardNum" type="String" mode="IN" optional="false"/>
+        <attribute name="expMonth" type="String" mode="IN" optional="false"/>
+        <attribute name="expYear" type="String" mode="IN" optional="false"/>
+        <attribute name="securityCode" type="String" mode="IN" optional="true"/>
+        <attribute name="postalCode" type="String" mode="IN" optional="true"/>
+        <attribute name="firstName" type="String" mode="IN" optional="false"/>
+        <attribute name="lastName" type="String" mode="IN" optional="false"/>
+        <attribute name="track2" type="String" mode="IN" optional="true"/>
+    </service>
+
+    <service name="processSale" engine="simple" auth="false"
+             location="org/ofbiz/webpos/event/PaymentEvents.xml" invoke="processSale">
+        <description>Process Sale</description>
+    </service>
+
+    <service name="setRefNum" engine="simple" auth="false"
+             location="org/ofbiz/webpos/event/PaymentEvents.xml" invoke="setRefNum">
+        <description>Set Payment Refernce Number</description>
+        <attribute name="idx" type="String" mode="IN" optional="true"/>
+        <attribute name="refNum" type="String" mode="IN" optional="true"/>
+        <attribute name="authCode" type="String" mode="IN" optional="true"/>
+    </service>
+
+    <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"/>
+    </service>
+
+    <service name="clearAllPayments" engine="simple" auth="false"
+             location="org/ofbiz/webpos/event/PaymentEvents.xml" invoke="clearAllPayments">
+        <description>Clear All Payments</description>
+    </service>
+</services>
\ No newline at end of file

Propchange: ofbiz/trunk/specialpurpose/webpos/servicedef/services_payment.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/trunk/specialpurpose/webpos/servicedef/services_payment.xml
------------------------------------------------------------------------------
    svn:executable = *

Propchange: ofbiz/trunk/specialpurpose/webpos/servicedef/services_payment.xml
------------------------------------------------------------------------------
    svn:keywords = "Date Rev Author URL Id"

Propchange: ofbiz/trunk/specialpurpose/webpos/servicedef/services_payment.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: ofbiz/trunk/specialpurpose/webpos/servicedef/services_promo.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/webpos/servicedef/services_promo.xml?rev=698351&view=auto
==============================================================================
--- ofbiz/trunk/specialpurpose/webpos/servicedef/services_promo.xml (added)
+++ ofbiz/trunk/specialpurpose/webpos/servicedef/services_promo.xml Tue Sep 23 14:09:28 2008
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<services xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.ofbiz.org/dtds/services.xsd">
+    <description>Web Pos Promotions Services</description>
+    <vendor>OFBiz</vendor>
+    <version>1.0</version>
+    
+    <service name="addPromoCode" engine="simple" auth="false"
+             location="org/ofbiz/webpos/event/PromoEvents.xml" invoke="addPromoCode">
+        <description>Add Promotion Code</description>
+        <attribute name="promoCode" type="String" mode="IN" optional="false"/>
+    </service>
+</services>
\ No newline at end of file

Propchange: ofbiz/trunk/specialpurpose/webpos/servicedef/services_promo.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/trunk/specialpurpose/webpos/servicedef/services_promo.xml
------------------------------------------------------------------------------
    svn:executable = *

Propchange: ofbiz/trunk/specialpurpose/webpos/servicedef/services_promo.xml
------------------------------------------------------------------------------
    svn:keywords = "Date Rev Author URL Id"

Propchange: ofbiz/trunk/specialpurpose/webpos/servicedef/services_promo.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: 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=698351&view=auto
==============================================================================
--- ofbiz/trunk/specialpurpose/webpos/src/org/ofbiz/webpos/WebPosEvents.java (added)
+++ ofbiz/trunk/specialpurpose/webpos/src/org/ofbiz/webpos/WebPosEvents.java Tue Sep 23 14:09:28 2008
@@ -0,0 +1,100 @@
+/*******************************************************************************
+ * 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.
+ *******************************************************************************/
+package org.ofbiz.webpos;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import org.ofbiz.base.util.GeneralException;
+import org.ofbiz.base.util.UtilValidate;
+import org.ofbiz.entity.GenericDelegator;
+import org.ofbiz.entity.GenericValue;
+import org.ofbiz.order.shoppingcart.ShoppingCart;
+import org.ofbiz.product.store.ProductStoreWorker;
+import org.ofbiz.securityext.login.LoginEvents;
+import org.ofbiz.service.LocalDispatcher;
+import org.ofbiz.webpos.session.WebPosSession;
+import org.ofbiz.webpos.transaction.WebPosTransaction;
+
+public class WebPosEvents {
+    
+    public static String module = WebPosEvents.class.getName();
+    
+    public static String posLogin(HttpServletRequest request, HttpServletResponse response) {
+        String responseString = LoginEvents.storeLogin(request, response);
+        
+        if ("success".equals(responseString)) {
+            HttpSession session = request.getSession(true);
+            session.removeAttribute("webPosSession");
+            WebPosEvents.getWebPosSession(request);
+        }
+        return responseString;
+    }
+    
+    public static WebPosSession getWebPosSession(HttpServletRequest request) {
+        HttpSession session = request.getSession(true);
+        GenericValue userLogin = (GenericValue) session.getAttribute("userLogin");
+        WebPosSession webPosSession = (WebPosSession) session.getAttribute("webPosSession");
+        ShoppingCart cart = (ShoppingCart) session.getAttribute("shoppingCart");
+        GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator");
+        LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
+        
+        if (UtilValidate.isEmpty(webPosSession)) {
+            String productStoreId = ProductStoreWorker.getProductStoreId(request);
+            GenericValue productStore = ProductStoreWorker.getProductStore(productStoreId, delegator);
+            String facilityId = null;
+            String currencyUomId = request.getParameter("currencyUomId");
+            
+            if (UtilValidate.isNotEmpty(productStore)) {
+                facilityId = productStore.getString("inventoryFacilityId");
+                if (UtilValidate.isEmpty(currencyUomId)) {
+                    currencyUomId = productStore.getString("defaultCurrencyUomId");
+                }
+            }
+            
+            if (UtilValidate.isEmpty(cart)) {
+                cart = new ShoppingCart(delegator, productStoreId, request.getLocale(), currencyUomId);
+                session.setAttribute("shoppingCart", cart);
+            }
+            
+            //TODO remove hard-coded value pos-1 and take it from login selecting the PosTerminal.
+            webPosSession = new WebPosSession("pos-1", null, userLogin, request.getLocale(), productStoreId, facilityId, currencyUomId, delegator, dispatcher, cart);
+            session.setAttribute("webPosSession", webPosSession);
+        }
+        return webPosSession;
+    }
+
+    public static void removeWebPosSession(HttpServletRequest request) {
+        HttpSession session = request.getSession(true);        
+        session.removeAttribute("shoppingCart");
+        session.removeAttribute("webPosSession");
+        getWebPosSession(request);
+    }
+
+    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);
+        }
+        return "success";
+    }
+}
\ No newline at end of file

Propchange: ofbiz/trunk/specialpurpose/webpos/src/org/ofbiz/webpos/WebPosEvents.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/trunk/specialpurpose/webpos/src/org/ofbiz/webpos/WebPosEvents.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: ofbiz/trunk/specialpurpose/webpos/src/org/ofbiz/webpos/WebPosEvents.java
------------------------------------------------------------------------------
    svn:keywords = "Date Rev Author URL Id"

Propchange: ofbiz/trunk/specialpurpose/webpos/src/org/ofbiz/webpos/WebPosEvents.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ofbiz/trunk/specialpurpose/webpos/src/org/ofbiz/webpos/session/WebPosSession.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/webpos/src/org/ofbiz/webpos/session/WebPosSession.java?rev=698351&view=auto
==============================================================================
--- ofbiz/trunk/specialpurpose/webpos/src/org/ofbiz/webpos/session/WebPosSession.java (added)
+++ ofbiz/trunk/specialpurpose/webpos/src/org/ofbiz/webpos/session/WebPosSession.java Tue Sep 23 14:09:28 2008
@@ -0,0 +1,266 @@
+/*******************************************************************************
+ * 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.
+ *******************************************************************************/
+package org.ofbiz.webpos.session;
+
+import java.util.Locale;
+import java.util.Map;
+
+import javolution.util.FastMap;
+
+import org.ofbiz.base.util.Debug;
+import org.ofbiz.base.util.GeneralException;
+import org.ofbiz.base.util.UtilMisc;
+import org.ofbiz.base.util.UtilProperties;
+import org.ofbiz.base.util.UtilValidate;
+import org.ofbiz.entity.GenericDelegator;
+import org.ofbiz.entity.GenericEntityException;
+import org.ofbiz.entity.GenericValue;
+import org.ofbiz.order.shoppingcart.ShoppingCart;
+import org.ofbiz.service.GenericServiceException;
+import org.ofbiz.service.LocalDispatcher;
+import org.ofbiz.service.ServiceUtil;
+import org.ofbiz.webapp.control.LoginWorker;
+import org.ofbiz.webpos.transaction.WebPosTransaction;
+
+public class WebPosSession {
+    
+    public static final String module = WebPosSession.class.getName();
+    
+    private String id = null;
+    private Map<String, Object> attributes = FastMap.newInstance();
+    private GenericValue userLogin = null;
+    private Locale locale = null;
+    private String productStoreId = null;
+    private String facilityId = null;
+    private String currencyUomId = null;
+    private transient GenericDelegator delegator = null;
+    private String delegatorName = null;
+    private LocalDispatcher dispatcher = null;
+    private Boolean mgrLoggedIn = null;
+    private WebPosTransaction webPosTransaction = null;
+    private ShoppingCart cart = null;
+    
+    public WebPosSession(String id, Map<String, Object> attributes, GenericValue userLogin, Locale locale, String productStoreId, String facilityId, String currencyUomId, GenericDelegator delegator, LocalDispatcher dispatcher, ShoppingCart cart) {
+        this.id = id;
+        this.attributes = attributes;
+        this.userLogin = userLogin;
+        this.locale = locale;
+        this.productStoreId = productStoreId;
+        this.facilityId = facilityId;
+        this.currencyUomId = currencyUomId;
+        
+        if (UtilValidate.isNotEmpty(delegator))
+        {
+            this.delegator = delegator;
+            this.delegatorName = delegator.getDelegatorName();
+        } else {
+            this.delegator = this.getDelegator();
+            this.delegatorName = delegator.getDelegatorName();
+        }
+        
+        this.dispatcher = dispatcher;
+        this.cart = cart;
+        Debug.logInfo("Created WebPosSession [" + id + "]", module);
+    }
+    
+    public GenericValue getUserLogin() {
+        return this.userLogin;
+    }
+    
+    public void setAttribute(String name, Object value) {
+        this.attributes.put(name, value);
+    }
+    
+    public Object getAttribute(String name) {
+        return this.attributes.get(name);
+    }
+    
+    public String getId() {
+        return this.id;
+    }
+    
+    public String getUserLoginId() {
+        if (UtilValidate.isEmpty(getUserLogin())) {
+            return null;
+        } else {
+            return this.getUserLogin().getString("userLoginId");
+        }
+    }
+    
+    public String getUserPartyId() {
+        if (UtilValidate.isEmpty(getUserLogin())) {
+            return null;
+        } else {
+            return this.getUserLogin().getString("partyId");
+        }
+    }
+    
+    public Locale getLocale() {
+        return (Locale) this.locale;
+    }
+    
+    public void setLocale(Locale locale) {
+        this.locale = locale;
+    }
+    
+    public String getProductStoreId() {
+        return this.productStoreId;
+    }
+    
+    public void setProductStoreId(String productStoreId) {
+        this.productStoreId = productStoreId;
+    }
+    
+    public String getFacilityId() {
+        return this.facilityId;
+    }
+    
+    public void setFacilityId(String facilityId) {
+        this.facilityId = facilityId;
+    }
+    
+    public String getCurrencyUomId() {
+        return this.currencyUomId;
+    }
+    
+    public void setCurrencyUomId(String currencyUomId) {
+        this.currencyUomId = currencyUomId;
+    }
+    
+    public GenericDelegator getDelegator() {
+        if (UtilValidate.isEmpty(delegator)) {
+            delegator = GenericDelegator.getGenericDelegator(delegatorName);
+        }
+        return delegator;
+    }
+    
+    public LocalDispatcher getDispatcher() {
+        return dispatcher;
+    }
+    
+    public ShoppingCart getCart() {
+        return this.cart;
+    }
+    
+    public void logout() {
+        if (UtilValidate.isNotEmpty(webPosTransaction)) {
+            webPosTransaction.closeTx();
+            webPosTransaction = null;
+        }
+        
+        if (UtilValidate.isNotEmpty(getUserLogin())) {
+            LoginWorker.setLoggedOut(this.getUserLogin().getString("userLoginId"), this.getDelegator());
+        }
+    }
+    
+    public void login(String username, String password, LocalDispatcher dispatcher) throws UserLoginFailure {
+        this.checkLogin(username, password, dispatcher);
+    }
+    
+    public GenericValue checkLogin(String username, String password, LocalDispatcher dispatcher) throws UserLoginFailure {
+        // check the required parameters and objects
+        if (UtilValidate.isEmpty(dispatcher)) {
+            throw new UserLoginFailure(UtilProperties.getMessage("WebPosUiLabels", "UnableToLogIn", getLocale()));
+        }
+        if (UtilValidate.isEmpty(username)) {
+            throw new UserLoginFailure(UtilProperties.getMessage("PartyUiLabels", "PartyUserNameMissing", getLocale()));
+        }
+        if (UtilValidate.isEmpty(password)) {
+            throw new UserLoginFailure(UtilProperties.getMessage("PartyUiLabels", "PartyPasswordMissing", getLocale()));
+        }
+        
+        // call the login service
+        Map<String, Object> result = null;
+        try {
+            result = dispatcher.runSync("userLogin", UtilMisc.toMap("login.username", username, "login.password", password));
+        } catch (GenericServiceException e) {
+            Debug.logError(e, module);
+            throw new UserLoginFailure(e);
+        } catch (Throwable t) {
+            Debug.logError(t, "Throwable caught!", module);
+        }
+        
+        // check for errors
+        if (ServiceUtil.isError(result)) {
+            throw new UserLoginFailure(ServiceUtil.getErrorMessage(result));
+        } else {
+            GenericValue ul = (GenericValue) result.get("userLogin");
+            if (ul == null) {
+                throw new UserLoginFailure(UtilProperties.getMessage("WebPosUiLabels", "UserLoginNotValid", getLocale()));
+            }
+            return ul;
+        }
+    }
+    
+    public boolean hasRole(GenericValue userLogin, String roleTypeId) {
+        if (UtilValidate.isEmpty(userLogin) || UtilValidate.isEmpty(roleTypeId)) {
+            return false;
+        }
+        String partyId = userLogin.getString("partyId");
+        GenericValue partyRole = null;
+        try {
+            partyRole = getDelegator().findOne("PartyRole", false, "partyId", partyId, "roleTypeId", roleTypeId);
+        } catch (GenericEntityException e) {
+            Debug.logError(e, module);
+            return false;
+        }
+        
+        if (UtilValidate.isEmpty(partyRole)) {
+            return false;
+        }
+        
+        return true;
+    }
+    
+    public boolean isManagerLoggedIn() {
+        if (UtilValidate.isEmpty(mgrLoggedIn)) {
+            mgrLoggedIn = new Boolean(hasRole(getUserLogin(), "MANAGER"));
+        }
+        return mgrLoggedIn.booleanValue();
+    }
+    
+    public WebPosTransaction getCurrentTransaction() {
+        if (UtilValidate.isEmpty(webPosTransaction)) {
+            webPosTransaction = new WebPosTransaction(this);
+        }
+        return webPosTransaction;
+    }
+    
+    public void setCurrentTransaction(WebPosTransaction webPosTransaction) {
+        this.webPosTransaction = webPosTransaction;
+    }
+    
+    public class UserLoginFailure extends GeneralException {
+        public UserLoginFailure() {
+            super();
+        }
+        
+        public UserLoginFailure(String str) {
+            super(str);
+        }
+        
+        public UserLoginFailure(String str, Throwable nested) {
+            super(str, nested);
+        }
+        
+        public UserLoginFailure(Throwable nested) {
+            super(nested);
+        }
+    }
+}
\ No newline at end of file

Propchange: ofbiz/trunk/specialpurpose/webpos/src/org/ofbiz/webpos/session/WebPosSession.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/trunk/specialpurpose/webpos/src/org/ofbiz/webpos/session/WebPosSession.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: ofbiz/trunk/specialpurpose/webpos/src/org/ofbiz/webpos/session/WebPosSession.java
------------------------------------------------------------------------------
    svn:keywords = "Date Rev Author URL Id"

Propchange: ofbiz/trunk/specialpurpose/webpos/src/org/ofbiz/webpos/session/WebPosSession.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain