| <?xml version="1.0" encoding="UTF-8"?> |
| <!-- |
| Licensed to the Apache Software Foundation (ASF) under one |
| or more contributor license agreements. See the NOTICE file |
| distributed with this work for additional information |
| regarding copyright ownership. The ASF licenses this file |
| to you under the Apache License, Version 2.0 (the |
| "License"); you may not use this file except in compliance |
| with the License. You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, |
| software distributed under the License is distributed on an |
| "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| KIND, either express or implied. See the License for the |
| specific language governing permissions and limitations |
| under the License. |
| --> |
| |
| <simple-methods xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/simple-methods-v2.xsd"> |
| |
| <simple-method method-name="orderAdjustmentPermissionCheck" short-description="Permission service for the creation and editing of order adjustments"> |
| <set field="primaryPermission" value="ORDERMGR"/> |
| <set field="altPermission" value="ORDERMGR_ROLE"/> |
| <set field="mainAction" from-field="parameters.mainAction"/> |
| <call-simple-method method-name="genericBasePermissionCheck" xml-resource="component://common/script/org/ofbiz/common/permission/CommonPermissionServices.xml"/> |
| <if-compare field="hasPermission" operator="not-equals" value="true"> |
| <set field="resourceDescription" from-field="parameters.resourceDescription"/> |
| <if-empty field="resourceDescription"> |
| <property-to-field resource="CommonUiLabels" property="CommonPermissionThisOperation" field="resourceDescription"/> |
| </if-empty> |
| <if-compare field="mainAction" value="CREATE" operator="equals"> |
| <property-to-field resource="OrderErrorUiLabels" property="OrderSecurityErrorToRunCreateOrderAdjustement" field="failMessage"/> |
| </if-compare> |
| <if-compare field="mainAction" value="UPDATE" operator="equals"> |
| <property-to-field resource="OrderErrorUiLabels" property="OrderSecurityErrorToRunAutoCreateOrderAdjustments" field="failMessage"/> |
| </if-compare> |
| <set field="hasPermission" type="Boolean" value="false"/> |
| <field-to-result field="failMessage"/> |
| <else> |
| <field-to-result field="hasPermission"/> |
| </else> |
| </if-compare> |
| </simple-method> |
| |
| <simple-method method-name="createOrderAdjustment" short-description="Create an OrderAdjustment"> |
| |
| <make-value entity-name="OrderAdjustment" value-field="newEntity"/> |
| <set-nonpk-fields map="parameters" value-field="newEntity"/> |
| |
| <sequenced-id sequence-name="OrderAdjustment" field="newEntity.orderAdjustmentId"/> |
| <field-to-result field="newEntity.orderAdjustmentId" result-name="orderAdjustmentId"/> |
| |
| <now-timestamp field="newEntity.createdDate"/> |
| <set from-field="userLogin.userLoginId" field="newEntity.createdByUserLogin"/> |
| |
| <create-value value-field="newEntity"/> |
| </simple-method> |
| <simple-method method-name="updateOrderAdjustment" short-description="Update an OrderAdjustment"> |
| <check-permission permission="ORDERMGR" action="_UPDATE"><fail-property resource="OrderErrorUiLabels" property="OrderSecurityErrorToRunUpdateOrderAdjustement"/></check-permission> |
| <check-errors/> |
| <entity-one entity-name="OrderAdjustment" value-field="lookedUpValue"/> |
| <set-nonpk-fields map="parameters" value-field="lookedUpValue"/> |
| <store-value value-field="lookedUpValue"/> |
| </simple-method> |
| <simple-method method-name="deleteOrderAdjustment" short-description="Delete an OrderAdjustment"> |
| <check-permission permission="ORDERMGR" action="_DELETE"><fail-property resource="OrderErrorUiLabels" property="OrderSecurityErrorToRunDeleteOrderAdjustement"/></check-permission> |
| <check-errors/> |
| <entity-one entity-name="OrderAdjustment" value-field="lookedUpValue"/> |
| <remove-value value-field="lookedUpValue"/> |
| |
| <if-not-empty field="parameters.productPromoCodeId"> |
| <entity-one entity-name="OrderProductPromoCode" value-field="lookedUpValue"/> |
| <if-not-empty field="lookedUpValue"> |
| <remove-value value-field="lookedUpValue"/> |
| </if-not-empty> |
| </if-not-empty> |
| </simple-method> |
| |
| <simple-method method-name="createOrderAdjustmentBilling" short-description="Create an OrderAdjustmentBilling"> |
| <make-value entity-name="OrderAdjustmentBilling" value-field="newEntity"/> |
| <set-nonpk-fields map="parameters" value-field="newEntity"/> |
| <set-pk-fields map="parameters" value-field="newEntity"/> |
| <create-value value-field="newEntity"/> |
| </simple-method> |
| |
| <simple-method method-name="createOrderItemBilling" short-description="Create an OrderItemBilling"> |
| <make-value entity-name="OrderItemBilling" value-field="newEntity"/> |
| <set-nonpk-fields map="parameters" value-field="newEntity"/> |
| <set-pk-fields map="parameters" value-field="newEntity"/> |
| <create-value value-field="newEntity"/> |
| </simple-method> |
| |
| <simple-method method-name="createNotificationLog" short-description="Log an order notification" login-required="false"> |
| <make-value entity-name="OrderNotification" value-field="orderNotification"/> |
| <sequenced-id sequence-name="OrderNotification" field="orderNotification.orderNotificationId"/> |
| <set from-field="parameters.orderId" field="orderNotification.orderId"/> |
| <set from-field="parameters.emailType" field="orderNotification.emailType"/> |
| <set from-field="parameters.comments" field="orderNotification.comments"/> |
| <now-timestamp field="orderNotification.notificationDate"/> |
| <create-value value-field="orderNotification"/> |
| </simple-method> |
| |
| <simple-method method-name="updateOrderStatusFromReceipt" short-description="Update Order Status From ShipmentReceipt"> |
| <check-permission permission="ORDERMGR" action="_UPDATE"><fail-property resource="OrderErrorUiLabels" property="OrderSecurityErrorToRunUpdateOrderStatusFromReceipt"/></check-permission> |
| <check-errors/> |
| |
| <entity-one entity-name="OrderHeader" value-field="orderHeader"/> |
| <entity-and entity-name="ShipmentReceipt" list="shipmentReceipts"> |
| <field-map field-name="orderId" from-field="parameters.orderId"/> |
| </entity-and> |
| <iterate list="shipmentReceipts" entry="receipt"> |
| <if-empty field="totalsMap[receipt.orderItemSeqId]"> |
| <set field="totalsMap[receipt.orderItemSeqId]" value="0" type="BigDecimal"/> |
| </if-empty> |
| <calculate field="totalsMap[receipt.orderItemSeqId]"> |
| <calcop field="totalsMap[receipt.orderItemSeqId]" operator="add"> |
| <calcop field="receipt.quantityAccepted" operator="get"/> |
| <calcop field="receipt.quantityRejected" operator="get"/> |
| </calcop> |
| </calculate> |
| <set from-field="receipt.orderId" field="newLookupMap.orderId"/> |
| <set from-field="receipt.orderItemSeqId" field="newLookupMap.orderItemSeqId"/> |
| <find-by-primary-key entity-name="OrderItem" map="newLookupMap" value-field="orderItem"/> |
| <if-compare field="orderItem.statusId" operator="not-equals" value="ITEM_COMPLETED"> |
| <if-compare-field field="orderItem.quantity" to-field="totalsMap[receipt.orderItemSeqId]" operator="less-equals" type="BigDecimal"> |
| <!-- update the status for the item --> |
| <set field="orderItem.statusId" value="ITEM_COMPLETED"/> |
| <store-value value-field="orderItem"/> |
| <!-- create status change history --> |
| <make-value entity-name="OrderStatus" value-field="newValue"/> |
| <sequenced-id sequence-name="OrderStatus" field="newValue.orderStatusId"/> |
| <set from-field="orderItem.orderItemSeqId" field="newValue.orderItemSeqId"/> |
| <set from-field="orderItem.orderId" field="newValue.orderId"/> |
| <set from-field="orderItem.statusId" field="newValue.statusId"/> |
| <set from-field="parameters.userLogin.userLoginId" field="newValue.statusUserLogin"/> |
| <now-timestamp field="newValue.statusDatetime"/> |
| |
| <create-value value-field="newValue"/> |
| </if-compare-field> |
| </if-compare> |
| </iterate> |
| |
| <!-- check to see if all items have been completed --> |
| <entity-and entity-name="OrderItem" list="allOrderItems"> |
| <field-map field-name="orderId" from-field="parameters.orderId"/> |
| </entity-and> |
| <set value="true" field="allCompleted"/> |
| <iterate list="allOrderItems" entry="item"> |
| <if-compare field="item.statusId" operator="not-equals" value="ITEM_COMPLETED"> |
| <set value="false" field="allCompleted"/> |
| </if-compare> |
| </iterate> |
| |
| <if-compare field="allCompleted" operator="equals" value="true"> |
| <!-- update the order header --> |
| <set field="orderHeader.statusId" value="ORDER_COMPLETED"/> |
| <store-value value-field="orderHeader"/> |
| <!-- create the status history --> |
| <make-value entity-name="OrderStatus" value-field="newValue"/> |
| <sequenced-id sequence-name="OrderStatus" field="newValue.orderStatusId"/> |
| |
| <set from-field="orderHeader.orderId" field="newValue.orderId"/> |
| <set from-field="orderHeader.statusId" field="newValue.statusId"/> |
| <set from-field="parameters.userLogin.userLoginId" field="newValue.statusUserLogin"/> |
| <now-timestamp field="newValue.statusDatetime"/> |
| |
| <create-value value-field="newValue"/> |
| </if-compare> |
| |
| <!-- return the current return header status --> |
| <field-to-result field="orderHeader.statusId" result-name="currentStatusId"/> |
| </simple-method> |
| </simple-methods> |