blob: 387b3f108de7ce7c739a039cb9038048c7fe156b [file] [log] [blame]
<?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="createShoppingList" short-description="Create a ShoppingList" login-required="false">
<if>
<condition>
<and>
<not><if-empty field="userLogin"/></not>
<not><if-compare field="userLogin.userLoginId" operator="equals" value="anonymous"/></not>
<not><if-empty field="parameters.partyId"/></not>
<not><if-compare-field to-field="userLogin.partyId" field="parameters.partyId" operator="equals"/></not>
<not><if-has-permission permission="PARTYMGR" action="_CREATE"/></not>
</and>
</condition>
<then>
<add-error><fail-property resource="OrderErrorUiLabels" property="OrderSecurityErrorToRunCreateShoppingListForAnotherParty"/></add-error>
</then>
</if>
<check-errors/>
<make-value value-field="newEntity" entity-name="ShoppingList"/>
<set-nonpk-fields map="parameters" value-field="newEntity"/>
<if-empty field="newEntity.partyId">
<set from-field="userLogin.partyId" field="newEntity.partyId"/>
</if-empty>
<if-empty field="newEntity.shoppingListTypeId">
<set value="SLT_WISH_LIST" field="newEntity.shoppingListTypeId"/>
</if-empty>
<if-empty field="newEntity.listName">
<property-to-field field="newEntity.listName"
resource="OrderUiLabels" property="OrderNewShoppingList" default="New Shopping List"/>
</if-empty>
<if-empty field="newEntity.isPublic">
<set value="N" field="newEntity.isPublic"/>
</if-empty>
<if-empty field="newEntity.isActive">
<if-compare field="newEntity.shoppingListTypeId" operator="equals" value="SLT_AUTO_REODR">
<set value="N" field="newEntity.isActive"/>
<else>
<set value="Y" field="newEntity.isActive"/>
</else>
</if-compare>
</if-empty>
<sequenced-id sequence-name="ShoppingList" field="newEntity.shoppingListId"/>
<field-to-result field="newEntity.shoppingListId" result-name="shoppingListId"/>
<create-value value-field="newEntity"/>
</simple-method>
<simple-method method-name="updateShoppingList" short-description="Update a ShoppingList">
<entity-one entity-name="ShoppingList" value-field="shoppingList"/>
<set field="parentMethodName" value="updateShoppingList"/>
<set field="permissionAction" value="UPDATE"/>
<call-simple-method method-name="checkShoppingListSecurity"/>
<check-errors/>
<set-nonpk-fields map="parameters" value-field="shoppingList"/>
<!-- don't let auto-reorders be active unless there is some recurrence info -->
<if>
<condition>
<and>
<if-compare field="shoppingList.shoppingListTypeId" operator="equals" value="SLT_AUTO_REODR"/>
<or>
<if-empty field="shoppingList.recurrenceInfoId"/>
<if-empty field="shoppingList.paymentMethodId"/>
<if-empty field="shoppingList.contactMechId"/>
<if-empty field="shoppingList.shipmentMethodTypeId"/>
</or>
</and>
</condition>
<then>
<set value="N" field="shoppingList.isActive"/>
</then>
</if>
<store-value value-field="shoppingList"/>
</simple-method>
<simple-method method-name="removeShoppingList" short-description="Remove a ShoppingList">
<entity-one entity-name="ShoppingList" value-field="shoppingList"/>
<set field="parentMethodName" value="removeShoppingList"/>
<set field="permissionAction" value="DELETE"/>
<call-simple-method method-name="checkShoppingListSecurity"/>
<check-errors/>
<remove-value value-field="shoppingList"/>
</simple-method>
<simple-method method-name="createShoppingListItem" short-description="Create a ShoppingList Item" login-required="false">
<entity-and entity-name="ShoppingListItem" list="shoppingListItems">
<field-map field-name="productId" from-field="parameters.productId"></field-map>
<field-map field-name="shoppingListId" from-field="parameters.shoppingListId"></field-map>
</entity-and>
<if-empty field="shoppingListItems">
<set field="parentMethodName" value="createShoppingListItem"/>
<set field="permissionAction" value="CREATE"/>
<entity-one entity-name="ShoppingList" value-field="shoppingList"/>
<if>
<condition>
<and>
<not><if-empty field="shoppingList.partyId"/></not>
<not><if-compare-field field="userLogin.partyId" to-field="shoppingList.partyId" operator="equals"/></not>
<not><if-has-permission permission="PARTYMGR" action="_${permissionAction}"/></not>
</and>
</condition>
<then>
<add-error><fail-property resource="OrderErrorUiLabels" property="OrderSecurityErrorToRunForAnotherParty"/></add-error>
</then>
</if>
<check-errors/>
<entity-one entity-name="Product" value-field="product"/>
<if-empty field="product">
<add-error> <fail-property resource="ProductUiLabels" property="ProductErrorProductNotFound"/> </add-error>
<check-errors/>
</if-empty>
<make-value value-field="newEntity" entity-name="ShoppingListItem"/>
<set from-field="parameters.shoppingListId" field="newEntity.shoppingListId"/>
<make-next-seq-id value-field="newEntity" seq-field-name="shoppingListItemSeqId" numeric-padding="5"/>
<set-nonpk-fields map="parameters" value-field="newEntity"/>
<field-to-result field="newEntity.shoppingListItemSeqId" result-name="shoppingListItemSeqId"/>
<create-value value-field="newEntity"/>
<if-compare-field field="shoppingList.partyId" to-field="userLogin.partyId" operator="not-equals">
<now-timestamp field="shoppingList.lastAdminModified"/>
<store-value value-field="shoppingList"/>
</if-compare-field>
<else>
<first-from-list list="shoppingListItems" entry="shoppingListItem"/>
<calculate field="totalquantity" >
<calcop operator="add" field="shoppingListItem.quantity">
<calcop operator="get" field="parameters.quantity"/>
</calcop>
</calculate>
<field-to-result field="shoppingListItem.shoppingListItemSeqId" result-name="shoppingListItemSeqId"/>
<set-service-fields service-name="updateShoppingListItem" map="shoppingListItem" to-map="shoppingListItemParameters"/>
<set field="shoppingListItemParameters.quantity" from-field="totalquantity"/>
<call-service service-name="updateShoppingListItem" in-map-name="shoppingListItemParameters"/>
</else>
</if-empty>
</simple-method>
<simple-method method-name="updateShoppingListItem" short-description="Update a ShoppingListItem">
<set field="parentMethodName" value="updateShoppingListItem"/>
<set field="permissionAction" value="UPDATE"/>
<call-simple-method method-name="checkShoppingListItemSecurity"/>
<check-errors/>
<entity-one entity-name="ShoppingList" value-field="shoppingList"/>
<entity-one entity-name="ShoppingListItem" value-field="shoppingListItem"/>
<set-nonpk-fields map="parameters" value-field="shoppingListItem"/>
<store-value value-field="shoppingListItem"/>
<if-compare-field field="shoppingList.partyId" to-field="userLogin.partyId" operator="not-equals">
<now-timestamp field="shoppingList.lastAdminModified"/>
<store-value value-field="shoppingList"/>
</if-compare-field>
</simple-method>
<simple-method method-name="removeShoppingListItem" short-description="Remove a ShoppingListItem">
<set field="parentMethodName" value="removeShoppingListItem"/>
<set field="permissionAction" value="DELETE"/>
<call-simple-method method-name="checkShoppingListItemSecurity"/>
<check-errors/>
<entity-one entity-name="ShoppingList" value-field="shoppingList"/>
<entity-one entity-name="ShoppingListItem" value-field="shoppingListItem"/>
<remove-value value-field="shoppingListItem"/>
<if-compare-field field="shoppingList.partyId" to-field="userLogin.partyId" operator="not-equals">
<now-timestamp field="shoppingList.lastAdminModified"/>
<store-value value-field="shoppingList"/>
</if-compare-field>
</simple-method>
<simple-method method-name="addDistinctShoppingListItem"
short-description="Adds a shopping list item if one with the same productId does not exist">
<entity-condition entity-name="ShoppingListItem" list="shoppingListItemList">
<condition-expr field-name="shoppingListId" from-field="parameters.shoppingListId"/>
</entity-condition>
<iterate list="shoppingListItemList" entry="shoppingListItem">
<if-compare-field field="parameters.productId" to-field="shoppingListItem.productId" operator="equals">
<field-to-result field="shoppingListItem.shoppingListItemSeqId" result-name="shoppingListItemSeqId"/>
<return />
</if-compare-field>
</iterate>
<call-service service-name="createShoppingListItem" in-map-name="parameters">
<result-to-result result-name="shoppingListItemSeqId"/>
</call-service>
</simple-method>
<simple-method method-name="calculateShoppingListDeepTotalPrice" short-description="Calculate Deep Total Price for a ShoppingList">
<set field="parentMethodName" value="calculateShoppingListDeepTotalPrice"/>
<set field="permissionAction" value="VIEW"/>
<call-simple-method method-name="checkShoppingListItemSecurity"/>
<check-errors/>
<set from-field="parameters.prodCatalogId" field="calcPriceInBaseMap.prodCatalogId"/>
<set from-field="parameters.webSiteId" field="calcPriceInBaseMap.webSiteId"/>
<set from-field="parameters.partyId" field="calcPriceInBaseMap.partyId"/>
<set from-field="parameters.productStoreId" field="calcPriceInBaseMap.productStoreId"/>
<set from-field="parameters.productStoreGroupId" field="calcPriceInBaseMap.productStoreGroupId"/>
<set from-field="parameters.currencyUomId" field="calcPriceInBaseMap.currencyUomId"/>
<set from-field="parameters.autoUserLogin" field="calcPriceInBaseMap.autoUserLogin"/>
<entity-and entity-name="ShoppingListItem" list="shoppingListItems" use-cache="true">
<field-map field-name="shoppingListId" from-field="parameters.shoppingListId"/>
</entity-and>
<set field="totalPrice" type="BigDecimal" value="0.0"/>
<iterate list="shoppingListItems" entry="shoppingListItem">
<entity-one entity-name="Product" value-field="product" use-cache="true" auto-field-map="false">
<field-map field-name="productId" from-field="shoppingListItem.productId"/>
</entity-one>
<map-to-map map="calcPriceInBaseMap" to-map="calcPriceInMap"/>
<set field="calcPriceInMap.product" from-field="product"/>
<set field="calcPriceInMap.quantity" from-field="shoppingListItem.quantity"/>
<if-not-empty field="shoppingListItem.modifiedPrice">
<call-service service-name="calculateProductPrice" in-map-name="calcPriceInMap">
<result-to-field result-name="price" field="calcPriceOutMap.price"/>
</call-service>
</if-not-empty>
<set field="itemPrice" from-field="shoppingListItem.modifiedPrice" default-value="${calcPriceOutMap.price}"/>
<calculate field="totalPrice">
<calcop operator="add" field="totalPrice"/>
<calcop operator="multiply">
<calcop operator="get" field="itemPrice"/>
<calcop operator="get" field="shoppingListItem.quantity"/>
</calcop>
</calculate>
<clear-field field="calcPriceInMap"/>
</iterate>
<entity-and entity-name="ShoppingList" list="childshoppingLists" use-cache="true">
<field-map field-name="parentShoppingListId" from-field="parameters.shoppingListId"/>
<field-map field-name="partyId" from-field="userLogin.partyId"/>
</entity-and>
<iterate list="childshoppingLists" entry="childshoppingList">
<map-to-map map="calcPriceInBaseMap" to-map="calcChildPriceInMap"/>
<set from-field="childshoppingList.shoppingListId" field="calcChildPriceInMap.shoppingListId"/>
<call-service service-name="calculateShoppingListDeepTotalPrice" in-map-name="calcChildPriceInMap">
<result-to-field result-name="totalPrice" field="calcPriceOutMap.totalPrice"/>
</call-service>
<calculate field="totalPrice">
<calcop operator="get" field="totalPrice"/>
<calcop operator="get" field="calcPriceOutMap.totalPrice"/>
</calculate>
<clear-field field="calcChildPriceInMap"/>
</iterate>
<field-to-result field="totalPrice" result-name="totalPrice"/>
</simple-method>
<simple-method method-name="checkShoppingListSecurity" short-description="Checks security on a ShoppingList">
<if>
<condition>
<and>
<not><if-compare-field to-field="shoppingList.partyId" field="userLogin.partyId" operator="equals"/></not>
<not><if-has-permission permission="PARTYMGR" action="_${permissionAction}"/></not>
</and>
</condition>
<then>
<add-error><fail-property resource="OrderErrorUiLabels" property="OrderSecurityErrorToRunForAnotherParty"/></add-error>
</then>
</if>
</simple-method>
<simple-method method-name="checkShoppingListItemSecurity" short-description="Checks security on a ShoppingListItem">
<entity-one entity-name="ShoppingList" value-field="shoppingList"/>
<if>
<condition>
<and>
<not><if-compare-field field="userLogin.partyId" to-field="shoppingList.partyId" operator="equals"/></not>
<not><if-has-permission permission="PARTYMGR" action="_${permissionAction}"/></not>
</and>
</condition>
<then>
<add-error><fail-property resource="OrderErrorUiLabels" property="OrderSecurityErrorToRunForAnotherParty"/></add-error>
</then>
</if>
</simple-method>
<simple-method method-name="addSuggestionsToShoppingList" short-description="Add suggestions to a shopping list">
<!-- first check the ProductStore.enableAutoSuggestionList indicator -->
<entity-one entity-name="OrderHeader" value-field="orderHeader"/>
<if-empty field="orderHeader.productStoreId"><return/></if-empty>
<entity-one entity-name="ProductStore" value-field="productStore" auto-field-map="false">
<field-map field-name="productStoreId" from-field="orderHeader.productStoreId"/>
</entity-one>
<if-compare field="productStore.enableAutoSuggestionList" operator="not-equals" value="Y"><return/></if-compare>
<entity-condition entity-name="OrderRole" list="orderRoleList">
<condition-list combine="and">
<condition-expr field-name="orderId" from-field="parameters.orderId"/>
<condition-expr field-name="roleTypeId" value="PLACING_CUSTOMER"/>
</condition-list>
</entity-condition>
<first-from-list list="orderRoleList" entry="orderRole"/>
<entity-condition entity-name="ShoppingList" list="shoppingListList">
<condition-list combine="and">
<condition-expr field-name="partyId" from-field="orderRole.partyId"/>
<condition-expr field-name="listName" value="Auto Suggestions"/>
</condition-list>
</entity-condition>
<first-from-list list="shoppingListList" entry="shoppingList"/>
<if-empty field="shoppingList">
<set field="createShoppingListInMap.partyId" from-field="orderRole.partyId"/>
<set field="createShoppingListInMap.listName" value="Auto Suggestions"/>
<set field="createShoppingListInMap.shoppingListTypeId" value="SLT_WISH_LIST"/>
<set field="createShoppingListInMap.productStoreId" from-field="parameters.productStoreId"/>
<call-service service-name="createShoppingList" in-map-name="createShoppingListInMap" require-new-transaction="true">
<result-to-field result-name="shoppingListId"/>
</call-service>
<else>
<set field="shoppingListId" from-field="shoppingList.shoppingListId"/>
</else>
</if-empty>
<entity-condition entity-name="OrderItem" list="orderItemList">
<condition-expr field-name="orderId" from-field="parameters.orderId"/>
<order-by field-name="orderItemSeqId"/>
</entity-condition>
<iterate list="orderItemList" entry="orderItem">
<if-not-empty field="orderItem.productId">
<entity-condition entity-name="ProductAssoc" list="compProductAssocList" filter-by-date="true">
<condition-list combine="and">
<condition-expr field-name="productId" from-field="orderItem.productId"/>
<condition-expr field-name="productAssocTypeId" value="PRODUCT_COMPLEMENT"/>
</condition-list>
</entity-condition>
<iterate list="compProductAssocList" entry="compProductAssoc">
<clear-field field="shoppingListParameters"/>
<set field="shoppingListParameters.productId" from-field="compProductAssoc.productIdTo"/>
<set field="shoppingListParameters.shoppingListId" from-field="shoppingListId"/>
<set field="shoppingListParameters.quantity" value="1" type="BigDecimal"/>
<call-service service-name="addDistinctShoppingListItem" in-map-name="shoppingListParameters"/>
</iterate>
<entity-one entity-name="Product" value-field="product" auto-field-map="false" >
<field-map field-name="productId" from-field="orderItem.productId"/>
</entity-one>
<if-compare field="product.isVariant" operator="equals" value="Y">
<entity-condition entity-name="ProductAssoc" list="virtualProductAssocList" filter-by-date="true">
<condition-list combine="and">
<condition-expr field-name="productIdTo" from-field="orderItem.productId"/>
<condition-expr field-name="productAssocTypeId" value="PRODUCT_VARIANT"/>
</condition-list>
</entity-condition>
<first-from-list list="virtualProductAssocList" entry="virtualProductAssoc"/>
<if-not-empty field="virtualProductAssoc">
<entity-condition entity-name="ProductAssoc" list="compProductAssocList" filter-by-date="true">
<condition-list combine="and">
<condition-expr field-name="productId" from-field="virtualProductAssoc.productId"/>
<condition-expr field-name="productAssocTypeId" value="PRODUCT_COMPLEMENT"/>
</condition-list>
</entity-condition>
<iterate list="compProductAssocList" entry="compProductAssoc">
<clear-field field="shoppingListParameters"/>
<set field="shoppingListParameters.productId" from-field="compProductAssoc.productIdTo"/>
<set field="shoppingListParameters.shoppingListId" from-field="shoppingListId"/>
<set field="shoppingListParameters.quantity" value="1" type="BigDecimal"/>
<call-service service-name="addDistinctShoppingListItem" in-map-name="shoppingListParameters"/>
</iterate>
</if-not-empty>
</if-compare>
</if-not-empty>
</iterate>
</simple-method>
</simple-methods>