blob: afac1ce499c78e59cd65aaf09aa1279078b78d98 [file] [log] [blame]
<?xml version="1.0" encoding="UTF-8" ?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<!--
This file contains basic services for SalesOpportunity and SalesForecast.
-->
<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="createSalesForecast" short-description="Creates a sales forecast and stores a copy in sales forecast history.">
<!-- make the value and set the fields from the parameters -->
<make-value value-field="salesForecast" entity-name="SalesForecast"/>
<sequenced-id sequence-name="SalesForecast" field="salesForecastId"/>
<set field="salesForecast.salesForecastId" from-field="salesForecastId"/>
<set-nonpk-fields map="parameters" value-field="salesForecast"/>
<!-- set the creation info -->
<set field="salesForecast.createdByUserLoginId" from-field="userLogin.userLoginId"/>
<set field="salesForecast.modifiedByUserLoginId" from-field="userLogin.userLoginId"/>
<!-- create the value -->
<create-value value-field="salesForecast"/>
<!-- save a copy to history -->
<call-simple-method method-name="saveSalesForecastHistory"/>
<!-- return the ID -->
<field-to-result result-name="salesForecastId" field="salesForecastId"/>
</simple-method>
<simple-method method-name="updateSalesForecast" short-description="Updates a sales forecast and stores a copy in sales forecast history.">
<!-- get the forecast -->
<entity-one entity-name="SalesForecast" auto-field-map="true" value-field="salesForecast"/>
<!-- set the fields from the parameters -->
<set-nonpk-fields map="parameters" value-field="salesForecast"/>
<!-- store the value -->
<store-value value-field="salesForecast"/>
<!-- save a copy to history -->
<call-simple-method method-name="saveSalesForecastHistory"/>
</simple-method>
<simple-method method-name="saveSalesForecastHistory" short-description="Given a salesForecast map, saves the data in the history.">
<!-- make the value and set the fields from the salesForecast map -->
<make-value value-field="salesForecastHistory" entity-name="SalesForecastHistory"/>
<sequenced-id sequence-name="SalesForecastHistory" field="salesForecastHistoryId"/>
<set field="salesForecastHistory.salesForecastHistoryId" from-field="salesForecastHistoryId"/>
<set-nonpk-fields value-field="salesForecastHistory" map="salesForecast"/>
<!-- get the change note from the parameters -->
<set field="salesForecastHistory.changeNote" from-field="parameters.changeNote"/>
<!-- set the modified info -->
<now-timestamp field="nowTimestamp"/>
<set field="salesForecastHistory.modifiedTimestamp" from-field="nowTimestamp"/>
<set field="salesForecast.modifiedByUserLoginId" from-field="userLogin.userLoginId"/>
<!-- create the value -->
<create-value value-field="salesForecastHistory"/>
</simple-method>
<!-- Sales Forecast Detail -->
<simple-method method-name="createSalesForecastDetail" short-description="Creates a sales forecast detail">
<make-value entity-name="SalesForecastDetail" value-field="newEntity"/>
<sequenced-id sequence-name="SalesForecastDetail" field="newEntity.salesForecastDetailId"/>
<field-to-result field="newEntity.salesForecastDetailId" result-name="salesForecastDetailId"/>
<set-pk-fields map="parameters" value-field="newEntity"/>
<set-nonpk-fields map="parameters" value-field="newEntity"/>
<create-value value-field="newEntity"/>
</simple-method>
<simple-method method-name="updateSalesForecastDetail" short-description="Updates a sales forecast detail">
<entity-one entity-name="SalesForecastDetail" value-field="lookedUpValue"/>
<set-nonpk-fields value-field="lookedUpValue" map="parameters"/>
<store-value value-field="lookedUpValue"/>
</simple-method>
<simple-method method-name="deleteSalesForecastDetail" short-description="Delete a Sales Forecast Detail">
<entity-one entity-name="SalesForecastDetail" value-field="lookedUpValue"/>
<remove-value value-field="lookedUpValue"/>
</simple-method>
<simple-method method-name="createSalesOpportunity" short-description="Create Sales Opportunity">
<make-value entity-name="SalesOpportunity" value-field="newEntity"/>
<if-empty field="parameters.salesOpportunityId">
<sequenced-id sequence-name="SalesOpportunity" field="parameters.salesOpportunityId"/>
</if-empty>
<set-nonpk-fields map="parameters" value-field="newEntity"/>
<set-pk-fields map="parameters" value-field="newEntity"/>
<set from-field="userLogin.userLoginId" field="newEntity.createdByUserLogin"/>
<field-to-result field="parameters.salesOpportunityId" result-name="salesOpportunityId"/>
<create-value value-field="newEntity"/>
</simple-method>
<simple-method method-name="updateSalesOpportunity" short-description="Update an Sales opportunity">
<entity-one entity-name="SalesOpportunity" value-field="lookedUpValue"/>
<if-compare field="parameters.opportunityStageId" operator="equals" value="SOSTG_CLOSED">
<if-empty field="parameters.estimatedCloseDate">
<now-timestamp field="nowTimestamp"/>
<call-class-method class-name="org.ofbiz.base.util.UtilDateTime" method-name="getDayStart" ret-field="parameters.estimatedCloseDate">
<field field="nowTimestamp" type="java.sql.Timestamp"/>
</call-class-method>
</if-empty>
</if-compare>
<set-nonpk-fields value-field="lookedUpValue" map="parameters"/>
<store-value value-field="lookedUpValue"/>
</simple-method>
<simple-method method-name="createSalesOpportunityRole" short-description="Create Sales Opportunity Role">
<make-value value-field="newEntity" entity-name="SalesOpportunityRole"/>
<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="createSalesOpportunityAccountRole" short-description="Create Sales Opportunity Account Role">
<entity-and list="salesOpportunityRoles" entity-name="SalesOpportunityRole">
<field-map field-name="salesOpportunityId" from-field="parameters.salesOpportunityId"/>
<field-map field-name="roleTypeId" value="ACCOUNT"/>
</entity-and>
<first-from-list entry="lookedUpValue" list="salesOpportunityRoles"/>
<if-compare-field operator="not-equals" field="lookedUpValue.partyId" to-field="parameters.accountPartyId">
<if-not-empty field="lookedUpValue">
<remove-value value-field="lookedUpValue"/>
</if-not-empty>
<!-- Check party role for create Account Role -->
<if-not-empty field="parameters.accountPartyId">
<set field="roleMap.roleTypeId" value="ACCOUNT"/>
<set field="roleMap.partyId" from-field="parameters.accountPartyId"/>
<entity-one value-field="partyRole" entity-name="PartyRole">
<field-map field-name="roleTypeId" from-field="roleMap.roleTypeId"/>
<field-map field-name="partyId" from-field="roleMap.partyId"/>
</entity-one>
<if-empty field="partyRole">
<call-service service-name="createPartyRole" in-map-name="roleMap"/>
</if-empty>
</if-not-empty>
<set field="salesOpportunityRole.roleTypeId" value="ACCOUNT"/>
<set field="salesOpportunityRole.salesOpportunityId" from-field="parameters.salesOpportunityId"/>
<set field="salesOpportunityRole.partyId" from-field="parameters.accountPartyId"/>
<call-service service-name="createSalesOpportunityRole" in-map-name="salesOpportunityRole"/>
</if-compare-field>
</simple-method>
<simple-method method-name="createSalesOpportunityLeadRole" short-description="Create Sales Opportunity Lead Role">
<entity-and list="salesOpportunityRoles" entity-name="SalesOpportunityRole">
<field-map field-name="salesOpportunityId" from-field="parameters.salesOpportunityId"/>
<field-map field-name="roleTypeId" value="LEAD"/>
</entity-and>
<first-from-list entry="lookedUpValue" list="salesOpportunityRoles"/>
<if-compare-field operator="not-equals" field="lookedUpValue.partyId" to-field="parameters.leadPartyId">
<if-not-empty field="lookedUpValue">
<remove-value value-field="lookedUpValue"/>
</if-not-empty>
<!-- Check party role for create Lead Role -->
<if-not-empty field="parameters.leadPartyId">
<entity-one value-field="leadRole" entity-name="PartyRole">
<field-map field-name="partyId" from-field="parameters.leadPartyId"/>
<field-map field-name="roleTypeId" value="LEAD"/>
</entity-one>
<if-empty field="leadRole">
<set field="roleMap.roleTypeId" value="LEAD"/>
<set field="roleMap.partyId" from-field="parameters.leadPartyId"/>
<call-service service-name="createPartyRole" in-map-name="roleMap"/>
</if-empty>
</if-not-empty>
<set field="salesOpportunityRole.roleTypeId" value="LEAD"/>
<set field="salesOpportunityRole.salesOpportunityId" from-field="parameters.salesOpportunityId"/>
<set field="salesOpportunityRole.partyId" from-field="parameters.leadPartyId"/>
<call-service service-name="createSalesOpportunityRole" in-map-name="salesOpportunityRole"/>
</if-compare-field>
</simple-method>
<simple-method method-name="findPartyInSalesOpportunityRole" short-description="find party in role specified by in parameter">
<entity-and list="salesOpportunityRoles" entity-name="SalesOpportunityRole">
<field-map field-name="roleTypeId" from-field="parameters.roleTypeId"/>
<field-map field-name="salesOpportunityId" from-field="parameters.salesOpportunityId"/>
</entity-and>
<first-from-list entry="lookedUpValue" list="salesOpportunityRoles"/>
<field-to-result field="lookedUpValue.partyId" result-name="partyId"/>
</simple-method>
</simple-methods>