Files
ofbiz-framework/applications/order/minilang/requirement/RequirementServices.xml
T
Suraj Khurana ffd6686220 Improved: Converted all RequirementRole related CRUD services from simple to entity-auto (#105)
(OFBIZ-11641)
It was using same permission for all CRUD operation, updated logical permissions corresponding to each action.
2020-05-08 09:31:53 +05:30

89 lines
5.5 KiB
XML

<?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="deleteRequirementAndRelated" short-description="Delete a requirement after deleting related entity records">
<entity-one entity-name="Requirement" value-field="requirement" auto-field-map="true"/>
<check-errors/>
<remove-related value-field="requirement" relation-name="RequirementRole"/>
<remove-related value-field="requirement" relation-name="RequirementCustRequest"/>
<remove-value value-field="requirement"/>
</simple-method>
<simple-method method-name="autoAssignRequirementToSupplier" short-description="If the requirement is a product requirement (purchasing) try to assign it to the primary supplier">
<entity-one entity-name="Requirement" value-field="requirement" auto-field-map="true"/>
<check-errors/>
<if-compare field="requirement.requirementTypeId" operator="equals" value="PRODUCT_REQUIREMENT">
<if-not-empty field="requirement.productId">
<if-not-empty field="requirement.quantity">
<entity-condition entity-name="SupplierProduct" list="supplierProducts">
<condition-list>
<condition-expr field-name="productId" from-field="requirement.productId"/>
<condition-expr field-name="minimumOrderQuantity" operator="less-equals" from-field="requirement.quantity"/>
</condition-list>
<order-by field-name="lastPrice"/>
<order-by field-name="supplierPrefOrderId"/>
</entity-condition>
<filter-list-by-date list="supplierProducts" valid-date="requirement.requiredByDate" from-field-name="availableFromDate" thru-field-name="availableThruDate"/>
<first-from-list list="supplierProducts" entry="supplierProduct"/>
<if-not-empty field="supplierProduct.partyId">
<make-value entity-name="RequirementRole" value-field="requirementSupplier"/>
<set field="requirementSupplier.requirementId" from-field="requirement.requirementId"/>
<set field="requirementSupplier.partyId" from-field="supplierProduct.partyId"/>
<set field="requirementSupplier.roleTypeId" value="SUPPLIER"/>
<now-timestamp field="requirementSupplier.fromDate"/>
<create-value value-field="requirementSupplier"/>
</if-not-empty>
</if-not-empty>
</if-not-empty>
</if-compare>
</simple-method>
<simple-method method-name="createTransferFromRequirement" short-description="Create the inventory transfers required to fulfill the requirement.">
<check-permission permission="ORDERMGR" action="_CREATE">
<fail-property resource="OrderErrorUiLabels" property="OrderErrorCreatePermissionError"/>
</check-permission>
<check-errors/>
<entity-one entity-name="Requirement" value-field="requirement" auto-field-map="true"/>
<check-errors/>
<set field="inputMap.productId" from-field="requirement.productId"/>
<set field="inputMap.facilityId" from-field="parameters.fromFacilityId"/>
<set field="inputMap.facilityIdTo" from-field="requirement.facilityId"/>
<set field="inputMap.quantity" from-field="requirement.quantity"/>
<set field="inputMap.sendDate" from-field="requirement.requiredByDate"/>
<call-service service-name="createInventoryTransfersForProduct" in-map-name="inputMap">
<result-to-field result-name="quantityNotTransferred" field="quantityNotTransferred"/>
</call-service>
<check-errors/>
<if-compare field="quantityNotTransferred" value="0.0" operator="greater" type="BigDecimal">
<!-- we create a new requirement for the quantity not trasferred (because not available) -->
<clear-field field="inputMap"/>
<set-service-fields service-name="createRequirement" map="requirement" to-map="inputMap"/>
<set field="inputMap.quantity" from-field="quantityNotTransferred"/>
<call-service service-name="createRequirement" in-map-name="inputMap"/>
<check-errors/>
</if-compare>
<check-errors/>
<clear-field field="inputMap"/>
<set field="inputMap.requirementId" from-field="requirement.requirementId"/>
<set field="inputMap.statusId" value="REQ_ORDERED"/>
<call-service service-name="updateRequirement" in-map-name="inputMap"/>
</simple-method>
</simple-methods>