| <?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" xmlns="http://ofbiz.apache.org/Simple-Method" xsi:schemaLocation="http://ofbiz.apache.org/Simple-Method http://ofbiz.apache.org/dtds/simple-methods.xsd"> |
| <simple-method method-name="addPromoCode" short-description="Add Promotion Code" login-required="true"> |
| <clear-field field="posTerminalId"/> |
| <call-class-method class-name="org.apache.ofbiz.webpos.WebPosEvents" method-name="getWebPosSession" ret-field="webPosSession"> |
| <field field="request" type="javax.servlet.http.HttpServletRequest"/> |
| <field field="posTerminalId" type="String"/> |
| </call-class-method> |
| <if-not-empty field="webPosSession"> |
| <call-object-method obj-field="webPosSession" method-name="getCurrentTransaction" ret-field="webPosTransaction"/> |
| <check-errors/> |
| <call-object-method obj-field="webPosTransaction" method-name="isOpen" ret-field="isOpen"/> |
| <if-compare field="isOpen" operator="equals" value="true" type="String"> |
| <set field="promoCode" from-field="parameters.promoCode"/> |
| <call-object-method obj-field="webPosTransaction" method-name="addProductPromoCode" ret-field="result"> |
| <field field="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> |
| </simple-method> |
| </simple-methods> |