| <?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="getOrderedSummaryInformation" short-description="Get Summary Information About Orders for a Customer"> |
| <!-- The permission checking is commented out to make this service work also when triggered from ecommerce --> |
| <!--if> |
| <condition> |
| <and> |
| <not><if-has-permission permission="ORDERMGR" action="_VIEW"/></not> |
| <if-compare-field field="parameters.partyId" to-field="userLogin.partyId" operator="not-equals"/> |
| </and> |
| </condition> |
| <then> |
| <string-to-list string="To get order summary information you must have the ORDERMGR_VIEW permission, or be logged in as the party to get the summary information for." list="error_list"/> |
| </then> |
| </if> |
| <check-errors/> |
| --> |
| <if-not-empty field="monthsToInclude"> |
| <now-timestamp field="nowTimestamp"/> |
| <!-- TODO: Change this to use the <set-calendar> operation --> |
| <script>groovy: |
| calendar = com.ibm.icu.util.Calendar.getInstance(); |
| calendar.setTimeInMillis(nowTimestamp.getTime()); |
| calendar.add(com.ibm.icu.util.Calendar.MONTH, -monthsToInclude.intValue()); |
| parameters.put("fromDate", new Timestamp(calendar.getTimeInMillis())); |
| </script> |
| <set from-field="nowTimestamp" field="parameters.thruDate"/> |
| </if-not-empty> |
| |
| <if-empty field="parameters.roleTypeId"> |
| <set value="PLACING_CUSTOMER" field="parameters.roleTypeId"/> |
| </if-empty> |
| <if-empty field="parameters.orderTypeId"> |
| <set value="SALES_ORDER" field="parameters.orderTypeId"/> |
| </if-empty> |
| <if-empty field="parameters.statusId"> |
| <set value="ORDER_COMPLETED" field="parameters.statusId"/> |
| </if-empty> |
| |
| <entity-condition entity-name="OrderHeaderAndRoleSummary" list="orderInfoList"> |
| <condition-list combine="and"> |
| <condition-expr field-name="partyId" operator="equals" from-field="parameters.partyId"/> |
| <condition-expr field-name="roleTypeId" operator="equals" from-field="parameters.roleTypeId"/> |
| <condition-expr field-name="orderTypeId" operator="equals" from-field="parameters.orderTypeId"/> |
| <condition-expr field-name="statusId" operator="equals" from-field="parameters.statusId"/> |
| <condition-expr field-name="orderDate" operator="greater-equals" from-field="parameters.fromDate" ignore-if-null="true"/> |
| <condition-expr field-name="orderDate" operator="less-equals" from-field="parameters.thruDate" ignore-if-null="true"/> |
| </condition-list> |
| <select-field field-name="partyId"/> |
| <select-field field-name="roleTypeId"/> |
| <select-field field-name="totalGrandAmount"/> |
| <select-field field-name="totalSubRemainingAmount"/> |
| <select-field field-name="totalOrders"/> |
| </entity-condition> |
| |
| <!-- first set the required OUT fields to zero --> |
| <calculate field="plainDoubleZero"><number value="0.0"/></calculate> |
| <calculate field="plainLongZero" type="Long"><number value="0"/></calculate> |
| <field-to-result field="plainDoubleZero" result-name="totalGrandAmount"/> |
| <field-to-result field="plainDoubleZero" result-name="totalSubRemainingAmount"/> |
| <field-to-result field="plainLongZero" result-name="totalOrders"/> |
| |
| <!-- because we specified the partyId and the roleTypeId, should only be one item in list returned --> |
| <first-from-list list="orderInfoList" entry="orderInfo"/> |
| <if-not-empty field="orderInfo"> |
| <field-to-result field="orderInfo.totalGrandAmount" result-name="totalGrandAmount"/> |
| <field-to-result field="orderInfo.totalSubRemainingAmount" result-name="totalSubRemainingAmount"/> |
| <field-to-result field="orderInfo.totalOrders" result-name="totalOrders"/> |
| </if-not-empty> |
| </simple-method> |
| |
| <!-- order requirement methods --> |
| <simple-method method-name="createRequirementAndCommitment" short-description="create a requirement and commitment for it"> |
| <set value="PRODUCT_REQUIREMENT" field="inputMap.requirementTypeId"/> |
| |
| <!-- Include the facilityId corresponding to this order by looking up the ProductStore --> |
| <entity-one entity-name="OrderHeader" value-field="orderHeader" auto-field-map="true"/> |
| <get-related-one value-field="orderHeader" relation-name="ProductStore" to-value-field="productStore" use-cache="true"/> |
| <if-not-empty field="productStore.inventoryFacilityId"> |
| <set from-field="productStore.inventoryFacilityId" field="inputMap.facilityId"/> |
| </if-not-empty> |
| |
| <call-service service-name="createRequirement" in-map-name="inputMap"> |
| <result-to-field result-name="requirementId" field="parameters.requirementId"/> |
| </call-service> |
| |
| <!-- create the OrderRequirementCommitment to record the Requirement created for an order item --> |
| <set-service-fields service-name="createOrderRequirementCommitment" map="parameters" to-map="orderReqCommitParams"/> |
| <call-service service-name="createOrderRequirementCommitment" in-map-name="orderReqCommitParams"/> |
| |
| <field-to-result field="parameters.requirementId" result-name="requirementId"/> |
| </simple-method> |
| |
| <simple-method method-name="getProductFacilityAndQuantities" short-description="finds ProductFacility and QOH, ATP inventory for an inventoryItem"> |
| <!-- Get the ProductFacility for the minimum stock level --> |
| <entity-one entity-name="ProductFacility" value-field="productFacility"> |
| <field-map field-name="productId" from-field="inventoryItem.productId"/> |
| <field-map field-name="facilityId" from-field="inventoryItem.facilityId"/> |
| </entity-one> |
| |
| <!-- Get the product's total quantityOnHand in the facility --> |
| <set from-field="inventoryItem.productId" field="inputMap.productId"/> |
| <set from-field="inventoryItem.facilityId" field="inputMap.facilityId"/> |
| <call-service service-name="getInventoryAvailableByFacility" in-map-name="inputMap"> |
| <result-to-field result-name="quantityOnHandTotal" field="quantityOnHandTotal"/> |
| <result-to-field result-name="availableToPromiseTotal" field="availableToPromiseTotal"/> |
| </call-service> |
| <clear-field field="inputMap"/> |
| </simple-method> |
| |
| <simple-method method-name="getProductRequirementMethod" short-description="finds the requirement method for the product"> |
| <if-not-empty field="parameters.orderId"> |
| <entity-one entity-name="OrderHeader" auto-field-map="true" value-field="order"/> |
| </if-not-empty> |
| <entity-one entity-name="Product" auto-field-map="true" value-field="product"/> |
| <set from-field="product.requirementMethodEnumId" field="requirementMethodId"/> |
| <if-empty field="requirementMethodId"> |
| <set field="isMarketingPkg" value="${groovy: org.apache.ofbiz.entity.util.EntityTypeUtil.hasParentType(delegator, 'ProductType', 'productTypeId', product.productTypeId, 'parentTypeId', 'MARKETING_PKG')}" type="Boolean"/> |
| <if> |
| <condition> |
| <and> |
| <if-compare field="isMarketingPkg" operator="equals" value="false" type="Boolean"/> |
| <if-compare field="product.productTypeId" operator="not-equals" value="DIGITAL_GOOD"/> |
| <not><if-empty field="order"/></not> |
| </and> |
| </condition> |
| <then> |
| <entity-one entity-name="ProductStore" value-field="productStore"> |
| <field-map field-name="productStoreId" from-field="order.productStoreId"/> |
| </entity-one> |
| <set from-field="productStore.requirementMethodEnumId" field="requirementMethodId"/> |
| </then> |
| </if> |
| </if-empty> |
| </simple-method> |
| |
| <simple-method method-name="checkCreateOrderRequirement" short-description="Create OrderRequirementCommitment and Requirement"> |
| <check-permission permission="ORDERMGR" action="_CREATE"> |
| <fail-property resource="OrderErrorUiLabels" property="OrderSecurityErrorToRunCheckCreateOrderRequirement"/> |
| </check-permission> |
| <check-errors/> |
| <call-simple-method method-name="getProductRequirementMethod"/> |
| <if-compare field="order.orderTypeId" operator="equals" value="SALES_ORDER"> |
| <if-compare field="requirementMethodId" operator="equals" value="PRODRQM_AUTO"> |
| <!-- create the requirement --> |
| <set from-field="parameters.productId" field="inputMap.productId"/> |
| <set from-field="parameters.quantity" field="inputMap.quantity"/> |
| <call-simple-method method-name="createRequirementAndCommitment"/> |
| </if-compare> |
| </if-compare> |
| </simple-method> |
| |
| <simple-method method-name="checkCreateStockRequirementQoh" short-description="Create a Requirement if QOH goes under the minimum stock level"> |
| <check-permission permission="ORDERMGR" action="_CREATE"> |
| <fail-property resource="OrderErrorUiLabels" property="OrderSecurityErrorToRunCheckCreateStockRequirement"/> |
| </check-permission> |
| <check-errors/> |
| |
| <!-- If the service is triggered by the updateItemIssuance service, get the ItemIssuance by the passed itemIssuanceId --> |
| <if-not-empty field="parameters.itemIssuanceId"> |
| <entity-one entity-name="ItemIssuance" auto-field-map="true" value-field="itemIssuance"/> |
| <entity-one entity-name="InventoryItem" value-field="inventoryItem"> |
| <field-map field-name="inventoryItemId" from-field="itemIssuance.inventoryItemId"/> |
| </entity-one> |
| <else> |
| <entity-one entity-name="InventoryItem" auto-field-map="true" value-field="inventoryItem"/> |
| </else> |
| </if-not-empty> |
| |
| <set from-field="inventoryItem.productId" field="parameters.productId"/> |
| <call-simple-method method-name="getProductRequirementMethod"/> |
| |
| <if-compare field="requirementMethodId" operator="equals" value="PRODRQM_STOCK"> |
| <!-- get QOH, ATP quantities and find ProductFacility which has the minimum stock --> |
| <call-simple-method method-name="getProductFacilityAndQuantities"/> |
| |
| <if-not-empty field="productFacility.minimumStock"> |
| <!-- No requirements are created if we are already under stock --> |
| <if-compare-field field="quantityOnHandTotal" to-field="productFacility.minimumStock" operator="greater-equals" type="BigDecimal"> |
| <calculate field="newQuantityOnHand"> |
| <calcop operator="subtract" field="quantityOnHandTotal"> |
| <calcop operator="get" field="parameters.quantity"/> |
| </calcop> |
| </calculate> |
| <!-- If this new issuance will cause the quantityOnHandTotal to go below the minimumStock, create a new requirement --> |
| <if-compare-field field="newQuantityOnHand" to-field="productFacility.minimumStock" operator="less" type="BigDecimal"> |
| <set from-field="inventoryItem.productId" field="inputMap.productId"/> |
| <set from-field="productFacility.facilityId" field="inputMap.facilityId"/> |
| <if-not-empty field="productFacility.reorderQuantity"> |
| <set from-field="productFacility.reorderQuantity" field="inputMap.quantity"/> |
| <else> |
| <set from-field="parameters.quantity" field="inputMap.quantity"/> |
| </else> |
| </if-not-empty> |
| <set value="PRODUCT_REQUIREMENT" field="inputMap.requirementTypeId"/> |
| <call-service service-name="createRequirement" in-map-name="inputMap"> |
| <result-to-field result-name="requirementId" field="parameters.requirementId"/> |
| </call-service> |
| <field-to-result field="parameters.requirementId" result-name="requirementId"/> |
| </if-compare-field> |
| </if-compare-field> |
| </if-not-empty> |
| </if-compare> |
| </simple-method> |
| |
| <simple-method method-name="checkCreateStockRequirementAtp" short-description="Create a Requirement if ATP goes under the minimum stock level"> |
| <check-permission permission="ORDERMGR" action="_CREATE"> |
| <fail-property resource="OrderErrorUiLabels" property="OrderSecurityErrorToRunCheckCreateStockRequirement"/> |
| </check-permission> |
| <check-errors/> |
| |
| <!-- assumes that inventoryItemId is one of the parameters and get the inventory item of the reservation --> |
| <entity-one entity-name="InventoryItem" value-field="inventoryItem" auto-field-map="true"/> |
| |
| <!-- find the requirement method for this product --> |
| <set from-field="inventoryItem.productId" field="parameters.productId"/> |
| <call-simple-method method-name="getProductRequirementMethod"/> |
| |
| <if-compare field="requirementMethodId" operator="equals" value="PRODRQM_STOCK_ATP"> |
| <!-- get QOH, ATP quantities and find ProductFacility which has the minimum stock --> |
| <call-simple-method method-name="getProductFacilityAndQuantities"/> |
| |
| <if-not-empty field="productFacility.minimumStock"> |
| <!-- No requirements are created if we are not under stock --> |
| <!-- this service is supposed to be called after inventory is reserved, so inventory should have been updated already --> |
| <if-compare-field field="availableToPromiseTotal" to-field="productFacility.minimumStock" operator="less" type="BigDecimal"> |
| <calculate field="oldAvailableToPromise"> |
| <calcop operator="add" field="availableToPromiseTotal"> |
| <calcop operator="get" field="parameters.quantity"/> |
| </calcop> |
| </calculate> |
| <!-- If before this reservation the availableToPromiseTotal was over minimumStock, create a new requirement --> |
| <if-compare-field field="oldAvailableToPromise" to-field="productFacility.minimumStock" operator="greater-equals" type="BigDecimal"> |
| <set from-field="inventoryItem.productId" field="inputMap.productId"/> |
| <set from-field="productFacility.facilityId" field="inputMap.facilityId"/> |
| <if-not-empty field="productFacility.reorderQuantity"> |
| <set from-field="productFacility.reorderQuantity" field="inputMap.quantity"/> |
| <else> |
| <set from-field="parameters.quantity" field="inputMap.quantity"/> |
| </else> |
| </if-not-empty> |
| <set value="PRODUCT_REQUIREMENT" field="inputMap.requirementTypeId"/> |
| <call-service service-name="createRequirement" in-map-name="inputMap"> |
| <result-to-field result-name="requirementId" field="parameters.requirementId"/> |
| </call-service> |
| <field-to-result field="parameters.requirementId" result-name="requirementId"/> |
| </if-compare-field> |
| </if-compare-field> |
| </if-not-empty> |
| </if-compare> |
| </simple-method> |
| |
| <simple-method method-name="createRequirementFromItemATP" short-description="Create a Requirement for an item based on ATP inventory quantity and minimum"> |
| <!-- NOTE DEJ20090902: this service is not called anywhere, instead the createATPRequirementsForOrder service (written in Java) is called; why this is the case I don't know... --> |
| <check-permission permission="ORDERMGR" action="_CREATE"> |
| <fail-property resource="OrderErrorUiLabels" property="OrderSecurityErrorToRunCreateRequirementFromItemATP"/> |
| </check-permission> |
| <check-errors/> |
| |
| <!-- assumes that inventoryItemId is one of the parameters and get the inventory item of the reservation --> |
| <entity-one entity-name="InventoryItem" value-field="inventoryItem" auto-field-map="true"/> |
| |
| <!-- find the requirement method for this product --> |
| <set from-field="inventoryItem.productId" field="parameters.productId"/> |
| <call-simple-method method-name="getProductRequirementMethod"/> |
| |
| <if-compare field="requirementMethodId" operator="equals" value="PRODRQM_ATP"> |
| <!-- get the ATP, QOH quantities and the product facility's minimum stock --> |
| <call-simple-method method-name="getProductFacilityAndQuantities"/> |
| |
| <if-empty field="productFacility"> |
| <set field="minimumStock" value="0"/> |
| <else> |
| <set field="minimumStock" from-field="productFacility.minimumStock"/> |
| </else> |
| </if-empty> |
| <!-- are we below minimum stock? this service is supposed to be called after inventory is reserved, so inventory should have been updated already --> |
| <if-compare-field field="availableToPromiseTotal" to-field="minimumStock" operator="less" type="BigDecimal"> |
| <!-- what is the right quantity? It is the lesser of the actual quantity and the quantity required to bring us back up to minimum stock --> |
| <calculate field="quantityShortfall"> |
| <calcop operator="subtract" field="minimumStock"> |
| <calcop operator="get" field="availableToPromiseTotal"/> |
| </calcop> |
| </calculate> |
| <if-compare-field field="quantityShortfall" operator="less" to-field="parameters.quantity" type="BigDecimal"> |
| <set from-field="quantityShortfall" field="inputMap.quantity"/> |
| <else> |
| <set from-field="parameters.quantity" field="inputMap.quantity"/> |
| </else> |
| </if-compare-field> |
| |
| <!-- TODO: we're not supporting the reorderQuantity of the productFacility. It seems that altering the requirement quantity |
| due to reorder quantities would affect the ability to link requirements and hence PO items back to the original order. |
| If we can support it while at the same time linking requirements back to the original sales order, that would be better. --> |
| <set from-field="parameters.productId" field="inputMap.productId"/> |
| <set from-field="inventoryItem.facilityId" field="inputMap.facilityId"/> |
| |
| <!-- Retrieve and total the quantities of existing requirements for the product/facility --> |
| <entity-condition entity-name="Requirement" list="requirements"> |
| <condition-list combine="and"> |
| <condition-expr field-name="productId" operator="equals" from-field="parameters.productId"/> |
| <condition-expr field-name="requirementTypeId" operator="equals" value="PRODUCT_REQUIREMENT"/> |
| <condition-expr field-name="facilityId" operator="equals" from-field="facilityId"/> |
| <condition-expr field-name="statusId" operator="not-equals" value="REQ_ORDERED"/> |
| <condition-expr field-name="statusId" operator="not-equals" value="REQ_REJECTED"/> |
| </condition-list> |
| </entity-condition> |
| <iterate list="requirements" entry="requirement"> |
| <calculate field="existingRequirementTotal"> |
| <calcop operator="get" field="existingRequirementTotal"/> |
| <calcop operator="get" field="requirement.quantity"/> |
| </calculate> |
| </iterate> |
| |
| <!-- Subtract the total quantity of existing requirements from the required quantity to determine if a new requirement needs to be created --> |
| <calculate field="newRequirementTotal"> |
| <calcop operator="subtract" field="inputMap.quantity"> |
| <calcop operator="get" field="existingRequirementTotal"/> |
| </calcop> |
| </calculate> |
| |
| <!-- If a new requirement needs to be created, create it for the difference between the required quantity and the total quantity of existing requirements --> |
| <if-compare field="newRequirementTotal" operator="greater-equals" value="0"> |
| <set from-field="inputMap.quantity" field="newRequirementTotal"/> |
| <call-simple-method method-name="createRequirementAndCommitment"/> |
| </if-compare> |
| |
| </if-compare-field> |
| </if-compare> |
| </simple-method> |
| |
| <simple-method method-name="checkCreateProductRequirementForFacility" short-description="Create Requirements for all the products in a facility with QOH under the minimum stock level"> |
| <check-permission permission="ORDERMGR" action="_CREATE"> |
| <fail-property resource="OrderErrorUiLabels" property="OrderSecurityErrorToRunCheckCreateStockRequirement"/> |
| </check-permission> |
| <check-errors/> |
| |
| <entity-and entity-name="ProductFacility" list="products"> |
| <field-map field-name="facilityId" from-field="parameters.facilityId"/> |
| </entity-and> |
| |
| <iterate list="products" entry="productFacility"> |
| <set from-field="productFacility.productId" field="parameters.productId"/> |
| <clear-field field="requirementMethodId"/> |
| <call-simple-method method-name="getProductRequirementMethod"/> |
| <if-empty field="requirementMethodId"> |
| <set field="requirementMethodId" from-field="parameters.defaultRequirementMethodId"/> |
| </if-empty> |
| <if> |
| <condition> |
| <or> |
| <if-compare field="requirementMethodId" operator="equals" value="PRODRQM_STOCK"/> |
| <if-compare field="requirementMethodId" operator="equals" value="PRODRQM_STOCK_ATP"/> |
| </or> |
| </condition> |
| <then> |
| |
| <!-- get QOH, ATP and find ProductFacility which has the minimum stock --> |
| |
| <if-not-empty field="productFacility.minimumStock"> |
| <!-- Get the product's total quantityOnHand in the facility --> |
| <clear-field field="inputMap"/> |
| <set from-field="productFacility.productId" field="inputMap.productId"/> |
| <set from-field="productFacility.facilityId" field="inputMap.facilityId"/> |
| <call-service service-name="getInventoryAvailableByFacility" in-map-name="inputMap"> |
| <result-to-field result-name="quantityOnHandTotal" field="quantityOnHandTotal"/> |
| <result-to-field result-name="availableToPromiseTotal" field="availableToPromiseTotal"/> |
| </call-service> |
| |
| <if-compare field="requirementMethodId" operator="equals" value="PRODRQM_STOCK"> |
| <set from-field="quantityOnHandTotal" field="currentQuantity"/> |
| <else> |
| <set from-field="availableToPromiseTotal" field="currentQuantity"/> |
| </else> |
| </if-compare> |
| |
| <!-- No requirements are created if we are already under stock --> |
| <if-compare-field field="currentQuantity" to-field="productFacility.minimumStock" operator="less" type="BigDecimal"> |
| <clear-field field="inputMap"/> |
| <set from-field="productFacility.productId" field="inputMap.productId"/> |
| <if-not-empty field="productFacility.reorderQuantity"> |
| <set from-field="productFacility.reorderQuantity" field="inputMap.quantity" type="BigDecimal"/> |
| <else> |
| <set value="0" field="inputMap.quantity" type="BigDecimal"/> |
| </else> |
| </if-not-empty> |
| |
| <calculate field="quantityShortfall"> |
| <calcop operator="subtract" field="productFacility.minimumStock"> |
| <calcop operator="get" field="currentQuantity"/> |
| </calcop> |
| </calculate> |
| <if-compare-field field="inputMap.quantity" to-field="quantityShortfall" operator="less" type="BigDecimal"> |
| <set from-field="quantityShortfall" field="inputMap.quantity" type="BigDecimal"/> |
| </if-compare-field> |
| |
| <set value="PRODUCT_REQUIREMENT" field="inputMap.requirementTypeId"/> |
| <set from-field="parameters.facilityId" field="inputMap.facilityId"/> |
| <call-service service-name="createRequirement" in-map-name="inputMap"> |
| <result-to-field result-name="requirementId" field="requirementId"/> |
| </call-service> |
| <log level="info" message="Requirement creted with id [${requirementId}] for product with id [${productFacility.productId}]."/> |
| </if-compare-field> |
| </if-not-empty> |
| </then> |
| </if> |
| </iterate> |
| </simple-method> |
| |
| <simple-method method-name="getNextOrderId" short-description="Get Next orderId"> |
| <!-- try to find PartyAcctgPreference for parameters.partyId, see if we need any special order number sequencing --> |
| <entity-one entity-name="PartyAcctgPreference" value-field="partyAcctgPreference"/> |
| <log level="info" message="In getNextOrderId partyId is [${parameters.partyId}], partyAcctgPreference: ${partyAcctgPreference}"/> |
| |
| <if-not-empty field="partyAcctgPreference"> |
| <get-related-one relation-name="OrderCustomMethod" value-field="partyAcctgPreference" to-value-field="customMethod"/> |
| <else> |
| <log level="warning" message="Acctg preference not defined for partyId [${parameters.partyId}]"/> |
| </else> |
| </if-not-empty> |
| |
| <if-not-empty field="customMethod"> |
| <set field="customMethodName" from-field="customMethod.customMethodName"/> |
| <else><!-- retreive service from deprecated enumeration --> |
| <if-compare operator="equals" value="ODRSQ_ENF_SEQ" field="partyAcctgPreference.oldOrderSequenceEnumId"> |
| <set field="customMethodName" value="orderSequence_enforced"/> |
| </if-compare> |
| </else> |
| </if-not-empty> |
| |
| <if-not-empty field="customMethodName"> |
| <set-service-fields service-name="${customMethodName}" map="parameters" to-map="customMethodMap"/> |
| <set field="customMethodMap.partyAcctgPreference" from-field="partyAcctgPreference"/> |
| <call-service service-name="${customMethodName}" in-map-name="customMethodMap"> |
| <result-to-field result-name="orderId" field="orderIdTemp"/> |
| </call-service> |
| <else> |
| <!-- <log level="info" message="In getNextOrderId sequence by Standard"/> --> |
| <!-- default to the default sequencing: ODRSQ_STANDARD --> |
| <set from-field="parameters.orderId" field="orderIdTemp"/> |
| <if-empty field="orderIdTemp"> |
| <sequenced-id sequence-name="OrderHeader" field="orderIdTemp"/> |
| <else> |
| <!-- check the provided ID --> |
| <check-id field="orderIdTemp"/> |
| <check-errors/> |
| </else> |
| </if-empty> |
| </else> |
| </if-not-empty> |
| |
| <if-not-empty field="parameters.productStoreId"> |
| <entity-one entity-name="ProductStore" value-field="productStore"/> |
| </if-not-empty> |
| |
| <!-- use orderIdTemp along with the orderIdPrefix to create the real ID --> |
| <set field="orderId" value="${productStore.orderNumberPrefix}${partyAcctgPreference.orderIdPrefix}${str:toString(orderIdTemp)}"/> |
| <field-to-result field="orderId" result-name="orderId"/> |
| </simple-method> |
| |
| <simple-method method-name="orderSequence_enforced" short-description="Enforced Sequence (no gaps, per organization)"> |
| <log level="info" message="In getNextOrderId sequence enum Enforced"/> |
| <set field="partyAcctgPreference" from-field="parameters.partyAcctgPreference"/> |
| <!-- this is sequential sequencing, we can't skip a number, also it must be a unique sequence per partyIdFrom --> |
| |
| <if-not-empty field="partyAcctgPreference.lastOrderNumber"> |
| <calculate field="partyAcctgPreference.lastOrderNumber" type="Long"> |
| <calcop operator="add" field="partyAcctgPreference.lastOrderNumber"/> |
| <number value="1"/> |
| </calculate> |
| <else> |
| <calculate field="partyAcctgPreference.lastOrderNumber" type="Long"><number value="1"/></calculate> |
| </else> |
| </if-not-empty> |
| |
| <store-value value-field="partyAcctgPreference"/> |
| <set from-field="partyAcctgPreference.lastOrderNumber" field="orderId"/> |
| <field-to-result field="orderId" result-name="orderId"/> |
| </simple-method> |
| |
| <simple-method method-name="createOrderHeader" short-description="Create OrderHeader"> |
| <now-timestamp field="nowTimestamp"/> |
| |
| <set value="Create OrderHeader" field="operationName"/> |
| <check-permission permission="ORDERMGR" action="_CREATE"> |
| <fail-property resource="OrderErrorUiLabels" property="OrderSecurityErrorToRunCreateOrderShipment"/> |
| </check-permission> |
| <check-errors/> |
| |
| <make-value value-field="newEntity" entity-name="OrderHeader"/> |
| |
| <if-not-empty field="parameters.orderId"> |
| <set field="newEntity.orderId" from-field="parameters.orderId"/> |
| <else> |
| <sequenced-id sequence-name="OrderHeader" field="newEntity.orderId"/> |
| </else> |
| </if-not-empty> |
| <field-to-result field="newEntity.orderId" result-name="orderId"/> |
| |
| <set-nonpk-fields map="parameters" value-field="newEntity"/> |
| |
| <if-empty field="newEntity.statusId"> |
| <set field="newEntity.statusId" value="ORDER_CREATED"/> |
| </if-empty> |
| <if-empty field="newEntity.orderDate"> |
| <set field="newEntity.orderDate" from-field="nowTimestamp"/> |
| </if-empty> |
| <if-empty field="newEntity.entryDate"> |
| <set field="newEntity.entryDate" from-field="nowTimestamp"/> |
| </if-empty> |
| |
| <create-value value-field="newEntity"/> |
| </simple-method> |
| <simple-method method-name="updateOrderHeader" short-description="Update OrderHeader"> |
| <set value="Update OrderHeader" field="operationName"/> |
| <check-permission permission="ORDERMGR" action="_UPDATE"> |
| <fail-property resource="OrderErrorUiLabels" property="OrderSecurityErrorToRunCreateOrderShipment"/> |
| </check-permission> |
| <check-errors/> |
| |
| <entity-one entity-name="OrderHeader" value-field="orderHeader"/> |
| <if-empty field="orderHeader"> |
| <add-error> |
| <fail-property resource="OrderErrorUiLabels" property="OrderOrderIdDoesNotExists"/> |
| </add-error> |
| </if-empty> |
| <check-errors/> |
| <set-nonpk-fields map="parameters" value-field="orderHeader"/> |
| <store-value value-field="orderHeader"/> |
| </simple-method> |
| |
| <simple-method method-name="recreateOrderAdjustments" short-description="Auto create OrderAdjustments"> |
| <entity-one entity-name="OrderHeader" value-field="order" auto-field-map="true"/> |
| <!-- all existing promo order items are cancelled --> |
| <get-related value-field="order" relation-name="OrderItem" list="orderItems"/> |
| <iterate list="orderItems" entry="orderItem"> |
| <if> |
| <condition> |
| <and> |
| <if-compare field="orderItem.isPromo" value="Y" operator="equals"/> |
| <if-compare field="orderItem.statusId" value="ITEM_CANCELLED" operator="not-equals"/> |
| </and> |
| </condition> |
| <then> |
| <clear-field field="cancelOrderItemInMap"/> |
| <set-service-fields service-name="cancelOrderItemNoActions" map="parameters" to-map="cancelOrderItemInMap"/> |
| <set from-field="orderItem.orderItemSeqId" field="cancelOrderItemInMap.orderItemSeqId"/> |
| <call-service service-name="cancelOrderItemNoActions" in-map-name="cancelOrderItemInMap"/> |
| </then> |
| </if> |
| </iterate> |
| |
| <get-related value-field="order" relation-name="OrderAdjustment" list="orderAdjustments"/> |
| |
| <!-- Accumulate the total existing promotional adjustment --> |
| <set field="existingOrderAdjustmentTotal" value="0" type="BigDecimal"/> |
| <iterate list="orderAdjustments" entry="orderAdjustment"> |
| <if> |
| <condition> |
| <and> |
| <not><if-empty field="orderAdjustment.orderAdjustmentTypeId"/></not> |
| <if-compare operator="equals" value="PROMOTION_ADJUSTMENT" field="orderAdjustment.orderAdjustmentTypeId"></if-compare> |
| </and> |
| </condition> |
| <then> |
| <calculate field="existingOrderAdjustmentTotal" decimal-scale="3"> |
| <calcop operator="add"> |
| <calcop operator="get" field="orderAdjustment.amount"/> |
| <calcop operator="get" field="existingOrderAdjustmentTotal"/> |
| </calcop> |
| </calculate> |
| </then> |
| </if> |
| </iterate> |
| |
| <!-- Recalculate the promotions for the order --> |
| <set-service-fields service-name="loadCartFromOrder" map="parameters" to-map="loadCartFromOrderInMap"/> |
| <set value="true" field="loadCartFromOrderInMap.skipInventoryChecks" type="Boolean"/> |
| <set value="true" field="loadCartFromOrderInMap.skipProductChecks" type="Boolean"/> |
| <call-service service-name="loadCartFromOrder" in-map-name="loadCartFromOrderInMap"> |
| <result-to-field result-name="shoppingCart" field="cart"/> |
| </call-service> |
| <call-object-method obj-field="cart" method-name="items" ret-field="items"/> |
| <iterate list="items" entry="item"> |
| <call-object-method obj-field="item" method-name="getOrderItemSeqId" ret-field="orderItemSeqId"/> |
| <if-empty field="orderItemSeqId"> |
| <!-- this is a new (promo) item --> |
| <!-- a new order item is created --> |
| <make-value value-field="newOrderItem" entity-name="OrderItem"/> |
| <set field="newOrderItem.orderId" from-field="parameters.orderId"/> |
| <call-object-method obj-field="item" method-name="getItemType" ret-field="newOrderItem.orderItemTypeId"/> |
| <call-object-method obj-field="item" method-name="getSelectedAmount" ret-field="newOrderItem.selectedAmount"/> |
| <call-object-method obj-field="item" method-name="getBasePrice" ret-field="newOrderItem.unitPrice"/> |
| <call-object-method obj-field="item" method-name="getListPrice" ret-field="newOrderItem.unitListPrice"/> |
| <call-object-method obj-field="item" method-name="getName" ret-field="newOrderItem.itemDescription"/> |
| <call-object-method obj-field="item" method-name="getStatusId" ret-field="newOrderItem.statusId"/> |
| <call-object-method obj-field="item" method-name="getProductId" ret-field="newOrderItem.productId"/> |
| <call-object-method obj-field="item" method-name="getQuantity" ret-field="newOrderItem.quantity"/> |
| <set field="newOrderItem.isModifiedPrice" value="N"/> |
| <set field="newOrderItem.isPromo" value="Y"/> |
| <if-empty field="newOrderItem.statusId"> |
| <set field="newOrderItem.statusId" value="ITEM_CREATED"/> |
| </if-empty> |
| <make-next-seq-id value-field="newOrderItem" seq-field-name="orderItemSeqId"/> |
| <create-value value-field="newOrderItem"/> |
| <!-- and the orderItemSeqId is assigned to the shopping cart item--> |
| <call-object-method obj-field="item" method-name="setOrderItemSeqId"> |
| <field field="newOrderItem.orderItemSeqId" type="String"/> |
| </call-object-method> |
| </if-empty> |
| </iterate> |
| <call-object-method obj-field="cart" method-name="makeAllAdjustments" ret-field="adjustments"/> |
| |
| <!-- Accumulate the new promotion total from the recalculated promotion adjustments --> |
| <set field="newOrderAdjustmentTotal" value="0" type="BigDecimal"/> |
| <iterate list="adjustments" entry="adjustment"> |
| <if> |
| <condition> |
| <and> |
| <not><if-empty field="adjustment.productPromoId"/></not> |
| <if-empty field="adjustment.orderAdjustmentId"/> |
| </and> |
| </condition> |
| <then> |
| <calculate field="newOrderAdjustmentTotal" decimal-scale="3"> |
| <calcop operator="add"> |
| <calcop operator="get" field="adjustment.amount"/> |
| <calcop operator="get" field="newOrderAdjustmentTotal"/> |
| </calcop> |
| </calculate> |
| </then> |
| </if> |
| </iterate> |
| |
| <!-- Determine the difference between existing and new promotion adjustment totals, if any --> |
| <calculate field="orderAdjustmentTotalDifference" decimal-scale="3" type="BigDecimal"> |
| <calcop operator="subtract" field="newOrderAdjustmentTotal"> |
| <calcop operator="get" field="existingOrderAdjustmentTotal"/> |
| </calcop> |
| </calculate> |
| |
| <!-- If the total has changed, create an OrderAdjustment to reflect the fact --> |
| <if-compare field="orderAdjustmentTotalDifference" value="0" operator="not-equals" type="BigDecimal"> |
| <set field="createOrderAdjContext.orderAdjustmentTypeId" value="PROMOTION_ADJUSTMENT"/> |
| <set field="createOrderAdjContext.orderId" from-field="parameters.orderId"/> |
| <set field="createOrderAdjContext.orderItemSeqId" value="_NA_"/> |
| <set field="createOrderAdjContext.shipGroupSeqId" value="_NA_"/> |
| <set field="createOrderAdjContext.description" value="Adjustment due to order change"/> |
| <set field="createOrderAdjContext.amount" from-field="orderAdjustmentTotalDifference" type="BigDecimal"/> |
| <call-service service-name="createOrderAdjustment" in-map-name="createOrderAdjContext" include-user-login="true"/> |
| <check-errors/> |
| </if-compare> |
| </simple-method> |
| |
| <!--UpdateOrderContactMech--> |
| |
| <simple-method method-name="updateOrderContactMech" short-description="Update OrderContactMech"> |
| <check-permission permission="ORDERMGR" action="_UPDATE"> |
| <fail-property resource="OrderErrorUiLabels" property="OrderSecurityErrorToRunUpdateOrderContactMech"/> |
| </check-permission> |
| <check-errors/> |
| <make-value value-field="orderContactMechMap" entity-name="OrderContactMech"/> |
| <set-pk-fields map="parameters" value-field="orderContactMechMap"/> |
| <set from-field="parameters.orderId" field="inputMap.orderId"/> |
| <set from-field="parameters.contactMechPurposeTypeId" field="inputMap.contactMechPurposeTypeId"/> |
| <set from-field="parameters.contactMechId" field="inputMap.contactMechId"/> |
| <if-compare field="parameters.contactMechPurposeTypeId" operator="equals" value="SHIPPING_LOCATION"> |
| <if-compare field="parameters.contactMechId" operator="not-equals" value="parameters.oldContactMechId"> |
| <set field="orderItemShipGroupMap.orderId" from-field="parameters.orderId"/> |
| <set field="orderItemShipGroupMap.contactMechId" from-field="parameters.oldContactMechId"/> |
| <find-by-and entity-name="OrderItemShipGroup" list="shipGroupList" map="orderItemShipGroupMap"/> |
| <if-not-empty field="shipGroupList"> |
| <iterate list="shipGroupList" entry="shipGroup"> |
| <set field="inputMap.shipGroupSeqId" from-field="shipGroup.shipGroupSeqId"/> |
| <set field="inputMap.shipmentMethod" value="${shipGroup.shipmentMethodTypeId}@${shipGroup.carrierPartyId}@${shipGroup.carrierRoleTypeId}"/> |
| <set field="inputMap.oldContactMechId" from-field="parameters.oldContactMechId"/> |
| <set-service-fields service-name="updateOrderItemShipGroup" map="inputMap" to-map="orderItemShipGroupMap"/> |
| <call-service service-name="updateOrderItemShipGroup" in-map-name="orderItemShipGroupMap" include-user-login="true"/> |
| </iterate> |
| </if-not-empty> |
| </if-compare> |
| <else> |
| <find-by-and entity-name="OrderContactMech" map="inputMap" list="orderContactMechList"/> |
| <!-- If orderContactMechList value is null then create new entry in OrderContactMech entity--> |
| <if-empty field="orderContactMechList"> |
| <set-service-fields service-name="createOrderContactMech" map="parameters" to-map="createOrderContactMechMap"/> |
| <call-service service-name="createOrderContactMech" in-map-name="createOrderContactMechMap" include-user-login="true"/> |
| <set from-field="parameters.orderId" field="orderContactMechLookupMap.orderId"/> |
| <set from-field="parameters.oldContactMechId" field="orderContactMechLookupMap.contactMechId"/> |
| <set from-field="parameters.contactMechPurposeTypeId" field="orderContactMechLookupMap.contactMechPurposeTypeId"/> |
| <set-service-fields service-name="removeOrderContactMech" map="orderContactMechLookupMap" to-map="removeOrderContactMechMap"/> |
| <call-service service-name="removeOrderContactMech" in-map-name="removeOrderContactMechMap" include-user-login="true"/> |
| </if-empty> |
| <store-value value-field="orderContactMechMap"/> |
| </else> |
| </if-compare> |
| </simple-method> |
| |
| <!-- OrderItemShipGroup --> |
| <simple-method method-name="updateOrderItemShipGroup" short-description="Update OrderItemShipGroup"> |
| <check-permission permission="ORDERMGR" action="_UPDATE"> |
| <fail-property resource="OrderErrorUiLabels" property="OrderSecurityErrorToRunUpdateOrderItemShipGroup"/> |
| </check-permission> |
| <check-errors/> |
| <make-value value-field="lookupPKMap" entity-name="OrderItemShipGroup"/> |
| <set-pk-fields map="parameters" value-field="lookupPKMap"/> |
| <find-by-primary-key entity-name="OrderItemShipGroup" map="lookupPKMap" value-field="lookedUpValue"/> |
| <!-- splitting shipmentMethod request parameter value that contains "@" symbol |
| into "shipmentMethodTypeId", "carrierPartyId" and "carrierRoleTypeId". |
| --> |
| <script>groovy: |
| shipmentMethod = parameters.get("shipmentMethod"); |
| if(shipmentMethod != null){ |
| arr = shipmentMethod.split( "@" ); |
| parameters.put("shipmentMethodTypeId", arr[0]); |
| parameters.put("carrierPartyId", arr[1]); |
| parameters.put("carrierRoleTypeId", arr[2]); |
| } |
| </script> |
| <set-nonpk-fields map="parameters" value-field="lookedUpValue"/> |
| |
| <set from-field="parameters.orderId" field="inputMap.orderId"/> |
| <set from-field="parameters.contactMechPurposeTypeId" field="inputMap.contactMechPurposeTypeId"/> |
| <set from-field="parameters.contactMechId" field="inputMap.contactMechId"/> |
| <find-by-and entity-name="OrderContactMech" map="inputMap" list="orderContactMechList"/> |
| <!-- If orderContactMechList value is null then create new entry in OrderContactMech entity--> |
| <if-empty field="orderContactMechList"> |
| <set-service-fields service-name="createOrderContactMech" map="parameters" to-map="createOrderContactMechMap"/> |
| <call-service service-name="createOrderContactMech" in-map-name="createOrderContactMechMap" include-user-login="true"/> |
| </if-empty> |
| <store-value value-field="lookedUpValue"/> |
| <!-- Remove the old values from OrderContactMech entity with the help of oldContactMechId --> |
| <set from-field="parameters.orderId" field="shipGroupLookupMap.orderId"/> |
| <set from-field="parameters.oldContactMechId" field="shipGroupLookupMap.contactMechId"/> |
| <find-by-and entity-name="OrderItemShipGroup" map="shipGroupLookupMap" list="orderItemShipGroupList"/> |
| <if-empty field="orderItemShipGroupList"> |
| <set from-field="parameters.orderId" field="inputMap.orderId"/> |
| <set from-field="parameters.contactMechPurposeTypeId" field="inputMap.contactMechPurposeTypeId"/> |
| <set from-field="parameters.oldContactMechId" field="inputMap.contactMechId"/> |
| <find-by-and entity-name="OrderContactMech" map="inputMap" list="orderContactMechList"/> |
| <set-service-fields service-name="createOrderContactMech" map="inputMap" to-map="removeOrderContactMechMap"/> |
| <call-service service-name="removeOrderContactMech" in-map-name="removeOrderContactMechMap" include-user-login="true"/> |
| </if-empty> |
| </simple-method> |
| |
| <simple-method method-name="getOrderItemShipGroupEstimatedShipDate" short-description="Compute and return the OrderItemShipGroup estimated ship date based on the associated items."> |
| <entity-one entity-name="OrderItemShipGroup" value-field="orderItemShipGroup"/> |
| <if-compare field="orderItemShipGroup.maySplit" operator="equals" value="Y"> |
| <set field="orderByList[]" value="+promisedDatetime"/> |
| <else> |
| <set field="orderByList[]" value="-promisedDatetime"/> |
| </else> |
| </if-compare> |
| <get-related value-field="orderItemShipGroup" relation-name="OrderItemShipGrpInvRes" list="orderItemShipGroupInvResList" order-by-list="orderByList"/> |
| <first-from-list list="orderItemShipGroupInvResList" entry="orderItemShipGroupInvRes"/> |
| <field-to-result field="orderItemShipGroupInvRes.promisedDatetime" result-name="estimatedShipDate"/> |
| </simple-method> |
| |
| <simple-method method-name="updateOrderNote" short-description="Update OrderNote"> |
| <check-permission permission="ORDERMGR" action="_UPDATE"> |
| <fail-property resource="OrderErrorUiLabels" property="OrderSecurityErrorToRunUpdateOrderNote"/> |
| </check-permission> |
| <check-errors/> |
| <entity-one entity-name="OrderHeaderNote" value-field="orderHeaderNote"/> |
| <set-nonpk-fields map="parameters" value-field="orderHeaderNote"/> |
| <store-value value-field="orderHeaderNote"/> |
| </simple-method> |
| |
| <simple-method method-name="addPaymentMethodToOrder" short-description="Create an PaymentMethodToOrder"> |
| <check-permission permission="ORDERMGR" action="_CREATE"> |
| <fail-property resource="OrderErrorUiLabels" property="OrderSecurityErrorToRunAddPaymentMethodToOrder"/> |
| </check-permission> |
| <check-errors/> |
| <set field="inputMap.paymentMethodId" from-field="parameters.paymentMethodId"/> |
| <set field="inputMap.maxAmount" from-field="parameters.maxAmount"/> |
| <set field="inputMap.orderId" from-field="parameters.orderId"/> |
| <entity-one entity-name="PaymentMethod" value-field="paymentMethod"> |
| <field-map field-name="paymentMethodId" from-field="parameters.paymentMethodId"/> |
| </entity-one> |
| <set field="inputMap.paymentMethodTypeId" from-field="paymentMethod.paymentMethodTypeId"/> |
| <!--In this method we calls createOrderPaymentPreference and returns orderPaymentPreferenceId field to authOrderPaymentPreference --> |
| <call-service service-name="createOrderPaymentPreference" in-map-name="inputMap" include-user-login="true"> |
| <result-to-field result-name="orderPaymentPreferenceId" field="parameters.orderPaymentPreferenceId"/> |
| </call-service> |
| <field-to-result field="parameters.orderPaymentPreferenceId" result-name="orderPaymentPreferenceId"/> |
| </simple-method> |
| |
| <simple-method method-name="getOrderStatus" short-description="Gets an order status" login-required="false"> |
| <entity-one entity-name="OrderHeader" value-field="order"/> |
| <if-empty field="order"> |
| <add-error> |
| <fail-property resource="OrderErrorUiLabels" property="OrderOrderIdDoesNotExists"/> |
| </add-error> |
| <check-errors/> |
| </if-empty> |
| <field-to-result field="order.statusId" result-name="statusId"/> |
| </simple-method> |
| |
| <simple-method method-name="checkOrderIsOnBackOrder" short-description="Check if an Order is on Back Order" login-required="false"> |
| <set field="zeroEnv" value="0" type="BigDecimal"/> |
| <entity-condition entity-name="OrderItemShipGrpInvRes" list="orderItemShipGrpInvResList"> |
| <condition-list combine="and"> |
| <condition-expr field-name="orderId" from-field="parameters.orderId"/> |
| <condition-expr field-name="quantityNotAvailable" operator="not-equals" from-field="nullField"/> |
| <condition-expr field-name="quantityNotAvailable" operator="greater" from-field="zeroEnv"/> |
| </condition-list> |
| </entity-condition> |
| <if-empty field="orderItemShipGrpInvResList"> |
| <set field="isBackOrder" value="false" type="Boolean"/> |
| <else> |
| <set field="isBackOrder" value="true" type="Boolean"/> |
| </else> |
| </if-empty> |
| <field-to-result field="isBackOrder" result-name="isBackOrder"/> |
| </simple-method> |
| |
| <simple-method method-name="createOrderItemChange" short-description="Creates a new Order Item Change record"> |
| <make-value value-field="newEntity" entity-name="OrderItemChange"/> |
| <set-nonpk-fields map="parameters" value-field="newEntity"/> |
| <if-empty field="parameters.changeDatetime"> |
| <now-timestamp field="nowTimestamp"/> |
| <set field="newEntity.changeDatetime" from-field="nowTimestamp"/> |
| </if-empty> |
| <if-empty field="parameters.changeUserLogin"> |
| <set field="newEntity.changeUserLogin" from-field="userLogin.userLoginId"/> |
| </if-empty> |
| <sequenced-id sequence-name="OrderItemChange" field="newEntity.orderItemChangeId"/> |
| <create-value value-field="newEntity"/> |
| <field-to-result field="newEntity.orderItemChangeId" result-name="orderItemChangeId"/> |
| </simple-method> |
| |
| <simple-method method-name="createUpdateShippingAddress" short-description="create and update Shipping address" login-required="false"> |
| <set field="keepAddressBook" from-field="parameters.keepAddressBook" default-value="Y"/> |
| <call-map-processor xml-resource="component://order/minilang/customer/CheckoutMapProcs.xml" |
| processor-name="shipToAddress" in-map-name="parameters" out-map-name="shipToAddressCtx"/> |
| <check-errors/> |
| <set field="shipToAddressCtx.partyId" from-field="parameters.partyId"/> |
| |
| <if-empty field="shipToAddressCtx.contactMechId"> |
| <set field="shipToAddressCtx.contactMechPurposeTypeId" value="SHIPPING_LOCATION"/> |
| <call-service service-name="createPartyPostalAddress" in-map-name="shipToAddressCtx"> |
| <result-to-field result-name="contactMechId" field="parameters.shipToContactMechId"/> |
| </call-service> |
| <log level="info" message="Shipping address created with contactMechId ${parameters.shipToContactMechId}"/> |
| <else> |
| <if-compare field="keepAddressBook" operator="equals" value="Y"> |
| <make-value entity-name="PostalAddress" value-field="newValue"/> |
| <set-pk-fields value-field="newValue" map="shipToAddressCtx"/> |
| <find-by-primary-key entity-name="PostalAddress" map="newValue" value-field="oldValue"/> |
| <set-nonpk-fields map="shipToAddressCtx" value-field="newValue"/> |
| <if-compare-field field="oldValue" to-field="newValue" operator="not-equals" type="Object"> |
| <set field="shipToAddressCtx.contactMechId" from-field="nullField"/> |
| <call-service service-name="createPartyPostalAddress" in-map-name="shipToAddressCtx"> |
| <result-to-field result-name="contactMechId" field="parameters.shipToContactMechId"/> |
| </call-service> |
| </if-compare-field> |
| <entity-and entity-name="PartyContactMechPurpose" list="pcmpShipList" filter-by-date="true"> |
| <field-map field-name="partyId" from-field="userLogin.partyId"/> |
| <field-map field-name="contactMechId" from-field="parameters.shipToContactMechId"/> |
| <field-map field-name="contactMechPurposeTypeId" value="SHIPPING_LOCATION"/> |
| </entity-and> |
| <!-- If purpose is not exists then create --> |
| <if-empty field="pcmpShipList"> |
| <set-service-fields service-name="createPartyContactMechPurpose" map="parameters" to-map="serviceContext"/> |
| <set field="serviceContext.partyId" from-field="userLogin.partyId"/> |
| |
| <entity-and entity-name="PartyContactMechPurpose" list="pcmpList" filter-by-date="true"> |
| <field-map field-name="partyId" from-field="userLogin.partyId"/> |
| <field-map field-name="contactMechPurposeTypeId" value="SHIPPING_LOCATION"/> |
| </entity-and> |
| <if-not-empty field="pcmpList"> |
| <first-from-list list="pcmpList" entry="pcmp"/> |
| <set-service-fields service-name="deletePartyContactMechPurposeIfExists" map="pcmp" to-map="serviceInMap"/> |
| <call-service service-name="deletePartyContactMechPurposeIfExists" in-map-name="serviceInMap"/> |
| <clear-field field="serviceInMap"/> |
| </if-not-empty> |
| <set field="serviceContext.partyId" from-field="userLogin.partyId"/> |
| <set field="serviceContext.contactMechId" from-field="parameters.shipToContactMechId"/> |
| <set field="serviceContext.contactMechPurposeTypeId" value="SHIPPING_LOCATION"/> |
| <call-service service-name="createPartyContactMechPurpose" in-map-name="serviceContext"/> |
| <clear-field field="pcmpList"/> |
| <clear-field field="serviceContext"/> |
| </if-empty> |
| <if-compare field="parameters.setDefaultShipping" operator="equals" value="Y"> |
| <set-service-fields service-name="setPartyProfileDefaults" map="parameters" to-map="partyProfileDefaultsCtx"/> |
| <set field="partyProfileDefaultsCtx.defaultShipAddr" from-field="parameters.shipToContactMechId"/> |
| <set field="partyProfileDefaultsCtx.partyId" from-field="userLogin.partyId"/> |
| <call-service service-name="setPartyProfileDefaults" in-map-name="partyProfileDefaultsCtx"/> |
| </if-compare> |
| </if-compare> |
| <if-compare field="keepAddressBook" operator="equals" value="N"> |
| <set field="shipToAddressCtx.shipToContactMechId" from-field="shipToAddressCtx.contactMechId"></set> |
| <if-compare-field field="shipToAddressCtx.shipToContactMechId" operator="equals" to-field="parameters.billToContactMechId"> |
| <make-value entity-name="PostalAddress" value-field="newValue"/> |
| <set-pk-fields value-field="newValue" map="shipToAddressCtx"/> |
| <find-by-primary-key entity-name="PostalAddress" map="newValue" value-field="oldValue"/> |
| <set-nonpk-fields map="shipToAddressCtx" value-field="newValue"/> |
| <if-compare-field field="oldValue" to-field="newValue" operator="not-equals" type="Object"> |
| <entity-and entity-name="PartyContactMechPurpose" list="pcmpList" filter-by-date="true"> |
| <field-map field-name="contactMechId" from-field="shipToAddressCtx.shipToContactMechId"/> |
| <field-map field-name="partyId" from-field="userLogin.partyId"/> |
| <field-map field-name="contactMechPurposeTypeId" value="SHIPPING_LOCATION"/> |
| </entity-and> |
| <first-from-list list="pcmpList" entry="pcmp"/> |
| <if-not-empty field="pcmp"> |
| <set-service-fields service-name="deletePartyContactMechPurposeIfExists" map="pcmp" to-map="serviceInMap"/> |
| <call-service service-name="deletePartyContactMechPurposeIfExists" in-map-name="serviceInMap"/> |
| </if-not-empty> |
| <set field="shipToAddressCtx.contactMechPurposeTypeId" value="SHIPPING_LOCATION"/> |
| <set field="shipToAddressCtx.contactMechId" from-field="nullField"/> |
| <call-service service-name="createPartyPostalAddress" in-map-name="shipToAddressCtx"> |
| <result-to-field result-name="contactMechId" field="parameters.shipToContactMechId"/> |
| </call-service> |
| <log level="info" message="Shipping address updated with contactMechId ${shipToAddressCtx.shipToContactMechId}"/> |
| </if-compare-field> |
| <else> |
| <set field="shipToAddressCtx.userLogin" from-field="parameters.userLogin"/> |
| <call-service service-name="updatePartyPostalAddress" in-map-name="shipToAddressCtx"> |
| <result-to-field result-name="contactMechId" field="parameters.shipToContactMechId"/> |
| </call-service> |
| <log level="info" message="Shipping address updated with contactMechId ${shipToAddressCtx.shipToContactMechId}"/> |
| </else> |
| </if-compare-field> |
| </if-compare> |
| </else> |
| </if-empty> |
| <field-to-result field="parameters.shipToContactMechId" result-name="contactMechId"/> |
| </simple-method> |
| |
| <simple-method method-name="createUpdateBillingAddress" short-description="create and update billing address"> |
| |
| <set field="keepAddressBook" from-field="parameters.keepAddressBook" default-value="Y"/> |
| <if-compare field="parameters.useShippingAddressForBilling" operator="not-equals" value="Y"> |
| <call-map-processor xml-resource="component://order/minilang/customer/CheckoutMapProcs.xml" |
| processor-name="billToAddress" in-map-name="parameters" out-map-name="billToAddressCtx"/> |
| </if-compare> |
| <check-errors/> |
| <set field="partyId" from-field="parameters.partyId"/> |
| <set field="billToAddressCtx.partyId" from-field="partyId"/> |
| |
| <if-compare field="parameters.useShippingAddressForBilling" operator="equals" value="Y"> |
| <if-empty field="parameters.billToContactMechId"> |
| <set field="billToAddressCtx.contactMechPurposeTypeId" value="BILLING_LOCATION"/> |
| <set-service-fields service-name="createPartyContactMechPurpose" map="billToAddressCtx" to-map="serviceInMap"/> |
| <set field="serviceInMap.contactMechId" from-field="parameters.shipToContactMechId"/> |
| <call-service service-name="createPartyContactMechPurpose" in-map-name="serviceInMap"/> |
| <else> |
| <if-compare-field field="parameters.shipToContactMechId" operator="not-equals" to-field="parameters.billToContactMechId"> |
| <entity-and entity-name="PartyContactMechPurpose" list="pcmpList" filter-by-date="true"> |
| <field-map field-name="contactMechId" from-field="parameters.billToContactMechId"/> |
| <field-map field-name="partyId" from-field="partyId"/> |
| <field-map field-name="contactMechPurposeTypeId" value="BILLING_LOCATION"/> |
| </entity-and> |
| <first-from-list list="pcmpList" entry="pcmp"/> |
| <if-not-empty field="pcmp"> |
| <set-service-fields service-name="deletePartyContactMechPurposeIfExists" map="pcmp" to-map="serviceInMap"/> |
| <call-service service-name="deletePartyContactMechPurposeIfExists" in-map-name="serviceInMap"/> |
| <clear-field field="serviceInMap"/> |
| </if-not-empty> |
| <if-compare field="keepAddressBook" operator="equals" value="N"> |
| <set field="serviceInMap.contactMechId" from-field="parameters.billToContactMechId"/> |
| <call-service service-name="deletePartyContactMech" in-map-name="serviceInMap"/> |
| <clear-field field="serviceInMap"/> |
| </if-compare> |
| <!-- Check that the ship-to address doesn't already have a bill-to purpose --> |
| <entity-and entity-name="PartyContactMechPurpose" list="pcmpList" filter-by-date="true"> |
| <field-map field-name="contactMechId" from-field="parameters.shipToContactMechId"/> |
| <field-map field-name="partyId" from-field="partyId"/> |
| <field-map field-name="contactMechPurposeTypeId" value="BILLING_LOCATION"/> |
| </entity-and> |
| <if-empty field="pcmpList"> |
| <set field="billToAddressCtx.contactMechPurposeTypeId" value="BILLING_LOCATION"/> |
| <set-service-fields service-name="createPartyContactMechPurpose" map="billToAddressCtx" to-map="serviceInMap"/> |
| <set field="serviceInMap.contactMechId" from-field="parameters.shipToContactMechId"/> |
| <call-service service-name="createPartyContactMechPurpose" in-map-name="serviceInMap"/> |
| </if-empty> |
| <log level="info" message="Billing address updated with contactMechId ${parameters.billToContactMechId}"/> |
| </if-compare-field> |
| </else> |
| </if-empty> |
| <set field="parameters.billToContactMechId" from-field="parameters.shipToContactMechId"/> |
| </if-compare> |
| <if-compare field="parameters.useShippingAddressForBilling" operator="not-equals" value="Y"> |
| <if-empty field="parameters.billToContactMechId"> |
| <set field="billToAddressCtx.contactMechPurposeTypeId" value="BILLING_LOCATION"/> |
| <call-service service-name="createPartyPostalAddress" in-map-name="billToAddressCtx"> |
| <result-to-field result-name="contactMechId" field="parameters.billToContactMechId"/> |
| </call-service> |
| <log level="info" message="Billing address created with contactmechId ${parameters.billToContactMechId}"/> |
| <else> |
| <if-compare-field field="parameters.shipToContactMechId" operator="equals" to-field="parameters.billToContactMechId"> |
| <set field="billToAddressCtx.contactMechId" from-field="nullField"/> |
| <call-service service-name="createPartyPostalAddress" in-map-name="billToAddressCtx"> |
| <result-to-field result-name="contactMechId" field="parameters.billToContactMechId"/> |
| </call-service> |
| <log level="info" message="Billing address updated with contactMechId ${parameters.billToContactMechId}"/> |
| <else> |
| <if-compare field="keepAddressBook" operator="equals" value="N"> |
| <call-service service-name="updatePartyPostalAddress" in-map-name="billToAddressCtx"> |
| <result-to-field result-name="contactMechId" field="parameters.billToContactMechId"/> |
| </call-service> |
| </if-compare> |
| <if-compare field="keepAddressBook" operator="equals" value="Y"> |
| <make-value entity-name="PostalAddress" value-field="newValue"/> |
| <set-pk-fields value-field="newValue" map="billToAddressCtx"/> |
| <set-nonpk-fields map="billToAddressCtx" value-field="newValue"/> |
| <entity-one entity-name="PostalAddress" value-field="oldValue" auto-field-map="false"> |
| <field-map field-name="contactMechId" from-field="billToAddressCtx.contactMechId"/> |
| </entity-one> |
| <if-compare-field field="oldValue" to-field="newValue" operator="not-equals" type="Object"> |
| <set field="billToAddressCtx.contactMechId" from-field="nullField"/> |
| <call-service service-name="createPartyPostalAddress" in-map-name="billToAddressCtx"> |
| <result-to-field result-name="contactMechId" field="parameters.billToContactMechId"/> |
| </call-service> |
| </if-compare-field> |
| </if-compare> |
| <log level="info" message="Billing Postal Address created billToContactMechId is ${parameters.billToContactMechId}"/> |
| </else> |
| </if-compare-field> |
| |
| <entity-and entity-name="PartyContactMechPurpose" list="pcmpBillList" filter-by-date="true"> |
| <field-map field-name="partyId" from-field="userLogin.partyId"/> |
| <field-map field-name="contactMechId" from-field="parameters.billToContactMechId"/> |
| <field-map field-name="contactMechPurposeTypeId" value="BILLING_LOCATION"/> |
| </entity-and> |
| <!-- If purpose is not exists then create --> |
| <if-empty field="pcmpBillList"> |
| <set-service-fields service-name="createPartyContactMechPurpose" map="parameters" to-map="serviceContext"/> |
| <set field="serviceContext.partyId" from-field="userLogin.partyId"/> |
| |
| <entity-and entity-name="PartyContactMechPurpose" list="pcmpList" filter-by-date="true"> |
| <field-map field-name="partyId" from-field="userLogin.partyId"/> |
| <field-map field-name="contactMechPurposeTypeId" value="BILLING_LOCATION"/> |
| </entity-and> |
| <if-not-empty field="pcmpList"> |
| <first-from-list list="pcmpList" entry="pcmp"/> |
| <set-service-fields service-name="deletePartyContactMechPurposeIfExists" map="pcmp" to-map="serviceInMap"/> |
| <call-service service-name="deletePartyContactMechPurposeIfExists" in-map-name="serviceInMap"/> |
| <clear-field field="serviceInMap"/> |
| </if-not-empty> |
| <set field="serviceContext.partyId" from-field="userLogin.partyId"/> |
| <set field="serviceContext.contactMechId" from-field="parameters.billToContactMechId"/> |
| <set field="serviceContext.contactMechPurposeTypeId" value="BILLING_LOCATION"/> |
| <call-service service-name="createPartyContactMechPurpose" in-map-name="serviceContext"/> |
| <clear-field field="pcmpList"/> |
| <clear-field field="serviceContext"/> |
| </if-empty> |
| <if-compare field="parameters.setDefaultBilling" operator="equals" value="Y"> |
| <set-service-fields service-name="setPartyProfileDefaults" map="parameters" to-map="partyProfileDefaultsCtx"/> |
| <set field="partyProfileDefaultsCtx.defaultBillAddr" from-field="parameters.billToContactMechId"/> |
| <set field="partyProfileDefaultsCtx.partyId" from-field="userLogin.partyId"/> |
| <call-service service-name="setPartyProfileDefaults" in-map-name="partyProfileDefaultsCtx"/> |
| </if-compare> |
| </else> |
| </if-empty> |
| </if-compare> |
| <field-to-result field="parameters.billToContactMechId" result-name="contactMechId"/> |
| </simple-method> |
| <simple-method method-name="createUpdateCreditCard" short-description="create and update credit card"> |
| <set-service-fields service-name="createCreditCard" map="parameters" to-map="creditCardContext"/> |
| <set field="creditCardContext.partyId" from-field="parameters.partyId"/> |
| <set field="creditCardContext.contactMechId" from-field="parameters.contactMechId"/> |
| <if-empty field="parameters.paymentMethodId"> |
| <!-- call create Credit Card --> |
| <call-service service-name="createCreditCard" in-map-name="creditCardContext"> |
| <result-to-field result-name="paymentMethodId" field="parameters.paymentMethodId"/> |
| </call-service> |
| <else> |
| <!-- call update Credit Card --> |
| <entity-and entity-name="PaymentMethod" list="paymentMethodList" filter-by-date="true"> |
| <field-map field-name="partyId" from-field="partyId"/> |
| <field-map field-name="paymentMethodTypeId" value="CREDIT_CARD"/> |
| <order-by field-name="-fromDate"/> |
| </entity-and> |
| <first-from-list list="paymentMethodList" entry="paymentMethod"/> |
| <set field="creditCardContext.paymentMethodId" from-field="paymentMethod.paymentMethodId"/> |
| <call-service service-name="updateCreditCard" in-map-name="creditCardContext"> |
| <result-to-field result-name="paymentMethodId" field="parameters.paymentMethodId"/> |
| </call-service> |
| </else> |
| </if-empty> |
| <set field="paymentMethodId" from-field="parameters.paymentMethodId"/> |
| <field-to-result field="parameters.paymentMethodId" result-name="paymentMethodId"/> |
| </simple-method> |
| |
| <simple-method method-name="setUnitPriceAsLastPrice" short-description="Set unitPrice as lastPrice on create purchase order, edit purchase order items and on receive inventory against a purchase order"> |
| <if> |
| <condition> |
| <and> |
| <not><if-empty field="parameters.facilityId"/></not> |
| <not><if-empty field="parameters.orderId"/></not> |
| </and> |
| </condition> |
| <then> |
| <entity-and list="orderSuppliers" entity-name="OrderHeaderItemAndRoles"> |
| <field-map field-name="orderId" from-field="parameters.orderId"/> |
| <field-map field-name="roleTypeId" value="BILL_FROM_VENDOR"/> |
| <field-map field-name="orderTypeId" value="PURCHASE_ORDER"/> |
| </entity-and> |
| <first-from-list list="orderSuppliers" entry="orderSupplier"/> |
| <entity-and list="supplierProducts" entity-name="SupplierProduct"> |
| <field-map field-name="productId" from-field="parameters.productId"/> |
| <field-map field-name="partyId" from-field="orderSupplier.partyId"/> |
| <field-map field-name="availableThruDate" from-field="nullField"/> |
| </entity-and> |
| <iterate list="supplierProducts" entry="supplierProduct"> |
| <now-timestamp field="nowTimestamp"/> |
| <if-not-empty field="parameters.orderCurrencyUnitPrice"> |
| <if-compare-field field="parameters.orderCurrencyUnitPrice" operator="not-equals" to-field="supplierProduct.lastPrice" type="BigDecimal"> |
| <clone-value value-field="supplierProduct" new-value-field="newSupplierProduct"/> |
| <set field="newSupplierProduct.availableFromDate" from-field="nowTimestamp"/> |
| <set field="newSupplierProduct.lastPrice" from-field="parameters.orderCurrencyUnitPrice" type="BigDecimal"/> |
| <create-value value-field="newSupplierProduct"/> |
| <set field="supplierProduct.availableThruDate" from-field="nowTimestamp"/> |
| <store-value value-field="supplierProduct"/> |
| </if-compare-field> |
| <else> |
| <if-compare-field field="parameters.unitCost" operator="not-equals" to-field="supplierProduct.lastPrice" type="BigDecimal"> |
| <clone-value value-field="supplierProduct" new-value-field="newSupplierProduct"/> |
| <set field="newSupplierProduct.availableFromDate" from-field="nowTimestamp"/> |
| <set field="newSupplierProduct.lastPrice" from-field="parameters.unitCost" type="BigDecimal"/> |
| <create-value value-field="newSupplierProduct"/> |
| <set field="supplierProduct.availableThruDate" from-field="nowTimestamp"/> |
| <store-value value-field="supplierProduct"/> |
| </if-compare-field> |
| </else> |
| </if-not-empty> |
| </iterate> |
| </then> |
| <else> |
| <if> |
| <condition> |
| <and> |
| <if-empty field="parameters.orderItems"/> |
| <not><if-empty field="parameters.orderId"/></not> |
| </and> |
| </condition> |
| <then> |
| <entity-and entity-name="OrderItem" list="orderItems"> |
| <field-map field-name="orderId" from-field="parameters.orderId"/> |
| </entity-and> |
| <iterate list="orderItems" entry="orderItem"> |
| <iterate-map key="orderItemSeqId" value="unitPrice" map="parameters.itemPriceMap"> |
| <if> |
| <condition> |
| <if-compare-field field="orderItem.orderItemSeqId" operator="equals" to-field="orderItemSeqId"/> |
| </condition> |
| <then> |
| <iterate-map key="orderItemSeqId" value="Y" map="parameters.overridePriceMap"> |
| <if> |
| <condition> |
| <if-compare-field field="orderItem.orderItemSeqId" operator="equals" to-field="orderItemSeqId"/> |
| </condition> |
| <then> |
| <set field="orderItem.unitPrice" from-field="unitPrice" type="BigDecimal"/> |
| <entity-and list="supplierProducts" entity-name="SupplierProduct"> |
| <field-map field-name="productId" from-field="orderItem.productId"/> |
| <field-map field-name="partyId" from-field="parameters.supplierPartyId"/> |
| <field-map field-name="availableThruDate" from-field="nullField"/> |
| </entity-and> |
| <iterate list="supplierProducts" entry="supplierProduct"> |
| <now-timestamp field="nowTimestamp"/> |
| <if> |
| <condition> |
| <if-compare-field field="orderItem.unitPrice" to-field="supplierProduct.lastPrice" operator="not-equals" type="BigDecimal"/> |
| </condition> |
| <then> |
| <make-value value-field="newSupplierProduct" entity-name="SupplierProduct"/> |
| <clone-value value-field="supplierProduct" new-value-field="newSupplierProduct"/> |
| <set from-field="nowTimestamp" field="newSupplierProduct.availableFromDate"/> |
| <set from-field="orderItem.unitPrice" field="newSupplierProduct.lastPrice"/> |
| <create-value value-field="newSupplierProduct"/> |
| <set from-field="nowTimestamp" field="supplierProduct.availableThruDate"/> |
| <store-value value-field="supplierProduct"/> |
| </then> |
| </if> |
| </iterate> |
| </then> |
| </if> |
| </iterate-map> |
| </then> |
| </if> |
| </iterate-map> |
| </iterate> |
| </then> |
| <else> |
| <iterate entry="orderItem" list="parameters.orderItems"> |
| <entity-and list="supplierProducts" entity-name="SupplierProduct"> |
| <field-map field-name="productId" from-field="orderItem.productId"/> |
| <field-map field-name="partyId" from-field="parameters.supplierPartyId"/> |
| <field-map field-name="availableThruDate" from-field="nullField"/> |
| </entity-and> |
| <iterate entry="supplierProduct" list="supplierProducts"> |
| <now-timestamp field="nowTimestamp"/> |
| <if> |
| <condition> |
| <if-compare-field field="orderItem.unitPrice" to-field="supplierProduct.lastPrice" operator="not-equals" type="BigDecimal"/> |
| </condition> |
| <then> |
| <make-value value-field="newSupplierProduct" entity-name="SupplierProduct"/> |
| <clone-value value-field="supplierProduct" new-value-field="newSupplierProduct"/> |
| <set from-field="nowTimestamp" field="newSupplierProduct.availableFromDate"/> |
| <set from-field="orderItem.unitPrice" field="newSupplierProduct.lastPrice" type="BigDecimal"/> |
| <create-value value-field="newSupplierProduct"/> |
| <set from-field="nowTimestamp" field="supplierProduct.availableThruDate"/> |
| <store-value value-field="supplierProduct"/> |
| </then> |
| </if> |
| </iterate> |
| </iterate> |
| </else> |
| </if> |
| </else> |
| </if> |
| </simple-method> |
| |
| <simple-method method-name="cancelAllBackOrders" short-description="Cancels those back orders from suppliers whose cancel back order date (cancelBackOrderDate) has passed the current date"> |
| <now-timestamp field="nowTimestamp"/> |
| <entity-condition entity-name="OrderHeader" list="orders"> |
| <condition-list combine="and"> |
| <condition-expr field-name="orderTypeId" operator="equals" value="PURCHASE_ORDER"/> |
| <condition-expr field-name="statusId" operator="not-equals" value="ORDER_CANCELLED"/> |
| <condition-expr field-name="statusId" operator="not-equals" value="ORDER_COMPLETED"/> |
| </condition-list> |
| </entity-condition> |
| <iterate list="orders" entry="currentOrder"> |
| <entity-and list="orderItems" entity-name="OrderItem"> |
| <field-map field-name="orderId" from-field="currentOrder.orderId"/> |
| </entity-and> |
| <iterate list="orderItems" entry="currentOrderItem"> |
| <set field="backOrderDate" from-field="currentOrderItem.cancelBackOrderDate" type="Timestamp"/> |
| <if> |
| <condition> |
| <and> |
| <not><if-empty field="backOrderDate"/></not> |
| <if-compare-field field="nowTimestamp" to-field="backOrderDate" operator="greater" type="Timestamp"/> |
| </and> |
| </condition> |
| <then> |
| <set field="orderItemMap.orderId" from-field="currentOrder.orderId"/> |
| <set field="orderItemMap.orderItemSeqId" from-field="currentOrderItem.orderItemSeqId"/> |
| <call-service service-name="cancelOrderItem" in-map-name="orderItemMap"/> |
| </then> |
| </if> |
| </iterate> |
| </iterate> |
| </simple-method> |
| |
| <simple-method method-name="updateShippingMethodAndCharges" short-description="Updates shipping method and shipping charges from Order View page when Shipment is in picked status and items of Order are packed"> |
| <!-- splitting shipmentMethodAndAmount request parameter value that contains "*" symbol |
| into "shipmentMethod" and "newAmount". |
| --> |
| <!-- shipmentMethod request parameter value contains "@" symbol |
| between "shipmentMethodTypeId" and "carrierPartyId".This will be splitted in updateOrderItemShipGroup method |
| --> |
| |
| <script>groovy: |
| shipmentMethodAndAmount = parameters.get("shipmentMethodAndAmount"); |
| if (shipmentMethodAndAmount != null) { |
| parameters.put("shipmentMethod", shipmentMethodAndAmount.substring(0, shipmentMethodAndAmount.indexOf("*"))); |
| parameters.put("amount", shipmentMethodAndAmount.substring(shipmentMethodAndAmount.indexOf("*")+1)); |
| parameters.put("shipmentMethodTypeId", shipmentMethodAndAmount.substring(0, shipmentMethodAndAmount.indexOf("@"))); |
| } |
| </script> |
| <set field="newAmount" from-field="parameters.amount" type="BigDecimal"/> |
| <set field="shippingAmount" from-field="parameters.shippingAmount" type="BigDecimal"/> |
| <property-to-field field="percentAllowed" resource="shipment" property="shipment.default.cost_actual_over_estimated_percent_allowed"/> |
| <if-compare-field field="newAmount" operator="greater" to-field="shippingAmount" type="BigDecimal"> |
| <set field="diffPercentage" value="${(newAmount - shippingAmount/shippingAmount)*100}" type="BigDecimal"/> |
| <else> |
| <set field="diffPercentage" value="${(shippingAmount - newAmount/newAmount)*100}" type="BigDecimal"/> |
| </else> |
| </if-compare-field> |
| <if-compare-field field="diffPercentage" operator="greater" to-field="percentAllowed" type="BigDecimal"> |
| <set-service-fields service-name="updateOrderItemShipGroup" map="parameters" to-map="updateOrderItemShipGroupContext"/> |
| <call-service service-name="updateOrderItemShipGroup" in-map-name="updateOrderItemShipGroupContext"/> |
| <set-service-fields service-name="updateOrderAdjustment" map="parameters" to-map="updateOrderAdjustmentContext"/> |
| <call-service service-name="updateOrderAdjustment" in-map-name="updateOrderAdjustmentContext"/> |
| <set-service-fields service-name="updateShipmentRouteSegment" map="parameters" to-map="updateShipmentRouteSegmentContext"/> |
| <clear-field field="updateShipmentRouteSegmentContext.trackingIdNumber"/> |
| <clear-field field="updateShipmentRouteSegmentContext.trackingDigest"/> |
| <clear-field field="updateShipmentRouteSegmentContext.carrierServiceStatusId"/> |
| <call-service service-name="updateShipmentRouteSegment" in-map-name="updateShipmentRouteSegmentContext"/> |
| <set-service-fields service-name="upsShipmentConfirm" map="parameters" to-map="upsShipmentConfirmContext"/> |
| <call-service service-name="upsShipmentConfirm" in-map-name="upsShipmentConfirmContext"/> |
| <else> |
| <set-service-fields service-name="updateOrderItemShipGroup" map="parameters" to-map="updateOrderItemShipGroupContext"/> |
| <call-service service-name="updateOrderItemShipGroup" in-map-name="updateOrderItemShipGroupContext"/> |
| <set-service-fields service-name="updateShipmentRouteSegment" map="parameters" to-map="updateShipmentRouteSegmentContext"/> |
| <clear-field field="updateShipmentRouteSegmentContext.trackingIdNumber"/> |
| <clear-field field="updateShipmentRouteSegmentContext.trackingDigest"/> |
| <clear-field field="updateShipmentRouteSegmentContext.carrierServiceStatusId"/> |
| <call-service service-name="updateShipmentRouteSegment" in-map-name="updateShipmentRouteSegmentContext"/> |
| <set-service-fields service-name="upsShipmentConfirm" map="parameters" to-map="upsShipmentConfirmContext"/> |
| <call-service service-name="upsShipmentConfirm" in-map-name="upsShipmentConfirmContext"/> |
| </else> |
| </if-compare-field> |
| </simple-method> |
| |
| <simple-method method-name="productAvailabalityByFacility" short-description="Calculate ATP and Qoh According For each facility"> |
| <set field="facilityMap.ownerPartyId" from-field="parameters.ownerPartyId"/> |
| <find-by-and map="facilityMap" list="facilityList" entity-name="Facility"/> |
| <iterate list="facilityList" entry="facility"> |
| <set field="getInventoryAvailableByFacilityMap.facilityId" from-field="facility.facilityId"/> |
| <set field="getInventoryAvailableByFacilityMap.productId" from-field="parameters.productId"/> |
| <call-service service-name="getInventoryAvailableByFacility" in-map-name="getInventoryAvailableByFacilityMap"> |
| <result-to-field result-name="quantityOnHandTotal"/> |
| <result-to-field result-name="availableToPromiseTotal"/> |
| </call-service> |
| <set field="availabalityMap.facilityId" from-field="facility.facilityId"/> |
| <set field="availabalityMap.quantityOnHandTotal" from-field="quantityOnHandTotal"/> |
| <set field="availabalityMap.availableToPromiseTotal" from-field="availableToPromiseTotal"/> |
| <field-to-list field="availabalityMap" list="availabalityList"/> |
| <clear-field field="availabalityMap"/> |
| </iterate> |
| <field-to-result field="availabalityList"/> |
| </simple-method> |
| |
| <simple-method method-name="createOrderPaymentApplication" short-description="Create Order Payment Application"> |
| <entity-one entity-name="Payment" value-field="paymentMap"/> |
| <set field="createCtx.amountApplied" from-field="paymentMap.amount" type="BigDecimal"/> |
| <set field="createCtx.paymentId" from-field="paymentMap.paymentId"/> |
| <entity-one entity-name="OrderPaymentPreference" value-field="orderPaymentPreMap"> |
| <field-map field-name="orderPaymentPreferenceId" from-field="paymentMap.paymentPreferenceId"/> |
| </entity-one> |
| <entity-and entity-name="OrderItemBilling" list="orderItemBilList"> |
| <field-map field-name="orderId" from-field="orderPaymentPreMap.orderId"/> |
| <order-by field-name="invoiceId"/> |
| </entity-and> |
| <if-not-empty field="orderItemBilList"> |
| <set field="createCtx.invoiceId" from-field="orderItemBilList[0].invoiceId"/> |
| <call-service service-name="createPaymentApplication" in-map-name="createCtx"/> |
| </if-not-empty> |
| </simple-method> |
| |
| <simple-method method-name="MoveItemBetweenShipGroups" short-description="Move order items between ship groups"> |
| <entity-one entity-name="OrderItemShipGroupAssoc" value-field="orderItemShipGroupAssoc"> |
| <field-map field-name="orderId" from-field="parameters.orderId"/> |
| <field-map field-name="orderItemSeqId" from-field="parameters.orderItemSeqId"/> |
| <field-map field-name="shipGroupSeqId" from-field="parameters.toGroupIndex"/> |
| </entity-one> |
| <if-empty field="orderItemShipGroupAssoc"> |
| <set-service-fields service-name="addOrderItemShipGroupAssoc" map="parameters" to-map="map"/> |
| <set field="map.quantity" value="0" type="BigDecimal"/> |
| <set field="map.shipGroupSeqId" from="parameters.toGroupIndex"/> |
| <call-service service-name="addOrderItemShipGroupAssoc" in-map-name="map"/> |
| <entity-one entity-name="OrderItemShipGroupAssoc" value-field="orderItemShipGroupAssoc"> |
| <field-map field-name="orderId" from-field="parameters.orderId"/> |
| <field-map field-name="orderItemSeqId" from-field="parameters.orderItemSeqId"/> |
| <field-map field-name="shipGroupSeqId" from-field="parameters.toGroupIndex"/> |
| </entity-one> |
| </if-empty> |
| <clear-field field="map"/> |
| <set field="map.orderId" from-field="parameters.orderId"/> |
| <set field="map.orderItemSeqId" from-field="parameters.orderItemSeqId"/> |
| <set field="map.shipGroupSeqId" from-field="parameters.toGroupIndex"/> |
| <set field="map.quantity" value="${orderItemShipGroupAssoc.quantity + parameters.quantity}" type="BigDecimal"/> |
| <call-service service-name="updateOrderItemShipGroupAssoc" in-map-name="map"/> |
| |
| <entity-one entity-name="OrderItemShipGroupAssoc" value-field="orderItemShipGroupAssoc"> |
| <field-map field-name="orderId" from-field="parameters.orderId"/> |
| <field-map field-name="orderItemSeqId" from-field="parameters.orderItemSeqId"/> |
| <field-map field-name="shipGroupSeqId" from-field="parameters.fromGroupIndex"/> |
| </entity-one> |
| <if-empty field="orderItemShipGroupAssoc"> |
| <add-error> |
| <fail-message message="The orderItemShipGroupAssoc qualified by orderId=${parameters.orderId} orderItemSeqId=${parameters.orderItemSeqId} shipGroupSeqId=${parameters.fromGroupIndex} does not exist"/> |
| </add-error> |
| </if-empty> |
| <check-errors/> |
| |
| <clear-field field="map"/> |
| <set field="map.orderId" from-field="parameters.orderId"/> |
| <set field="map.orderItemSeqId" from-field="parameters.orderItemSeqId"/> |
| <set field="map.shipGroupSeqId" from-field="parameters.fromGroupIndex"/> |
| <set field="map.quantity" value="${orderItemShipGroupAssoc.quantity - parameters.quantity}" type="BigDecimal"/> |
| <call-service service-name="updateOrderItemShipGroupAssoc" in-map-name="map"/> |
| </simple-method> |
| |
| </simple-methods> |