blob: 3ba07f57bf08dd47fea81d527c0633623ed70465 [file] [log] [blame]
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<simple-methods xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/simple-methods.xsd">
<simple-method method-name="updateRateAmount" short-description="update/create a rate amount value">
<set value="_CREATE" field="securityAction"/>
<check-permission permission="ACCOUNTING" action="${securityAction}"><fail-property resource="AccountingUiLabels" property="AccountingPermissionError"/></check-permission>
<check-errors/>
<!-- set defaults -->
<if-empty field="parameters.rateCurrencyUomId">
<property-to-field resource="general.properties" property="currency.uom.id.default" field="parameters.rateCurrencyUomId"/>
</if-empty>
<if-empty field="parameters.periodTypeId">
<set field="parameters.periodTypeId" value="RATE_HOUR"/>
</if-empty>
<if-empty field="parameters.emplPositionTypeId">
<set field="parameters.emplPositionTypeId" value="_NA_"/>
</if-empty>
<if-empty field="parameters.partyId">
<set field="parameters.partyId" value="_NA_"/>
</if-empty>
<if-empty field="parameters.workEffortId">
<set field="parameters.workEffortId" value="_NA_"/>
</if-empty>
<!-- try to find existing value -->
<entity-and entity-name="RateAmount" list="rateAmounts" filter-by-date="true">
<field-map field-name="rateTypeId" from-field="parameters.rateTypeId"/>
<field-map field-name="workEffortId" from-field="parameters.workEffortId"/>
<field-map field-name="rateCurrencyUomId" from-field="parameters.rateCurrencyUomId"/>
<field-map field-name="emplPositionTypeId" from-field="parameters.emplPositionTypeId"/>
<field-map field-name="partyId" from-field="parameters.partyId"/>
<field-map field-name="periodTypeId" from-field="parameters.periodTypeId"/>
</entity-and>
<!-- end existing value -->
<if-not-empty field="rateAmounts">
<first-from-list entry="rateAmount" list="rateAmounts"/>
<if-compare-field field="rateAmount.rateAmount" operator="not-equals" to-field="parameters.rateAmount">
<set-service-fields service-name="deleteRateAmount" map="rateAmount" to-map="delRateAmount"/>
<call-service service-name="deleteRateAmount" in-map-name="delRateAmount"/>
</if-compare-field>
</if-not-empty>
<make-value entity-name="RateAmount" value-field="newEntity"/>
<set-pk-fields map="parameters" value-field="newEntity"/>
<set-nonpk-fields map="parameters" value-field="newEntity"/>
<now-timestamp field="newEntity.fromDate"/>
<clear-field field="newEntity.thruDate"/>
<create-value value-field="newEntity"/>
</simple-method>
<simple-method method-name="deleteRateAmount" short-description="update/create a rate amount value">
<set value="_CREATE" field="securityAction"/>
<check-permission permission="ACCOUNTING" action="${securityAction}"><fail-property resource="AccountingUiLabels" property="AccountingPermissionError"/></check-permission>
<check-errors/>
<!-- set defaults -->
<if-empty field="parameters.rateCurrencyUomId">
<property-to-field resource="general.properties" property="currency.uom.id.default" field="parameters.rateCurrencyUomId"/>
</if-empty>
<if-empty field="parameters.periodTypeId">
<set field="parameters.periodTypeId" value="RATE_HOUR"/>
</if-empty>
<if-empty field="parameters.emplPositionTypeId">
<set field="parameters.emplPositionTypeId" value="_NA_"/>
</if-empty>
<if-empty field="parameters.partyId">
<set field="parameters.partyId" value="_NA_"/>
</if-empty>
<if-empty field="parameters.workEffortId">
<set field="parameters.workEffortId" value="_NA_"/>
</if-empty>
<entity-one entity-name="RateAmount" value-field="rateAmount"/>
<if-not-empty field="rateAmount">
<now-timestamp field="rateAmount.thruDate"/>
<store-value value-field="rateAmount"/>
<else>
<add-error><fail-message message="could not find record to be deleted"/></add-error>
</else>
</if-not-empty>
</simple-method>
<simple-method method-name="getRateAmount" short-description="Get the applicable rate amount value">
<set value="_READ" field="securityAction"/>
<check-permission permission="ACCOUNTING" action="${securityAction}"><fail-property resource="AccountingUiLabels" property="AccountingPermissionError"/></check-permission>
<check-errors/>
<!--
Search for the applicable rate from most specific to most general in the RateAmount entity
Defaults for periodTypeId is per hour and default currency is the currency in general.properties
The order is:
1. for specific rateTypeId, workEffortId (workEffort)
2. for specific rateTypeId, partyId (party)
3. for specific rateTypeId, emplPositionTypeId (emplPositionType)
4. for specific rateTypeId (rateType)
Then will be checked if the requested periodTypeId and currency can be found, if not isue an error message
-->
<if-empty field="parameters.rateCurrencyUomId">
<property-to-field resource="general.properties" property="currency.uom.id.default" field="parameters.rateCurrencyUomId"/>
</if-empty>
<if-empty field="parameters.periodTypeId">
<set field="parameters.periodTypeId" value="RATE_HOUR"/>
</if-empty>
<if><!-- workeffort level -->
<condition>
<and>
<not><if-empty field="parameters.workEffortId"/></not>
<if-compare field="parameters.workEffortId" value="_NA_" operator="not-equals"/>
</and>
</condition>
<then>
<entity-and entity-name="RateAmount" list="amounts" filter-by-date="true">
<field-map field-name="rateTypeId" from-field="parameters.rateTypeId"/>
<field-map field-name="workEffortId" from-field="parameters.workEffortId"/>
</entity-and>
<if-not-empty field="amounts">
<first-from-list entry="amount" list="amounts"/>
<if-not-empty field="amount.rateAmount">
<set field="level" value="workEffort"/>
</if-not-empty>
</if-not-empty>
</then>
</if>
<if><!-- party level -->
<condition>
<and>
<if-empty field="level"/>
<not><if-empty field="parameters.partyId"/></not>
<if-compare field="parameters.partyId" value="_NA_" operator="not-equals"/>
</and>
</condition>
<then>
<entity-and entity-name="RateAmount" list="amounts" filter-by-date="true">
<field-map field-name="rateTypeId" from-field="parameters.rateTypeId"/>
<field-map field-name="partyId" from-field="parameters.partyId"/>
</entity-and>
<if-not-empty field="amounts">
<first-from-list entry="amount" list="amounts"/>
<if-not-empty field="amount.rateAmount">
<set field="level" value="party"/>
</if-not-empty>
</if-not-empty>
</then>
</if>
<if><!-- emplPositionType level -->
<condition>
<and>
<if-empty field="level"/>
<not><if-empty field="parameters.emplPositionTypeId"/></not>
<if-compare field="parameters.emplPositionTypeId" value="_NA_" operator="not-equals"/>
</and>
</condition>
<then>
<entity-and entity-name="RateAmount" list="amounts" filter-by-date="true">
<field-map field-name="rateTypeId" from-field="parameters.rateTypeId"/>
<field-map field-name="emplPositionTypeId" from-field="parameters.emplPositionTypeId"/>
</entity-and>
<if-not-empty field="amounts">
<first-from-list entry="amount" list="amounts"/>
<if-not-empty field="amount.rateAmount">
<set field="level" value="emplPositionType"/>
</if-not-empty>
</if-not-empty>
</then>
</if>
<if-empty field="level">
<entity-and entity-name="RateAmount" list="amounts" filter-by-date="true">
<field-map field-name="rateTypeId" from-field="parameters.rateTypeId"/>
</entity-and>
<set field="level" value="rateType"/>
</if-empty>
<if-empty field="amounts">
<entity-one entity-name="RateType" value-field="rateType"/>
<log level="error" message="A valid rate amount could not be found for rateType: ${rateType.description}"/>
</if-empty>
<if-compare field="level" value="workEffort" operator="equals">
<entity-and entity-name="RateAmount" list="amounts" filter-by-date="true">
<field-map field-name="rateTypeId" from-field="parameters.rateTypeId"/>
<field-map field-name="partyId" from-field="parameters.partyId"/>
<field-map field-name="workEffortId" from-field="parameters.workEffortId"/>
<field-map field-name="periodTypeId" from-field="parameters.periodTypeId"/>
<field-map field-name="rateCurrencyUomId" from-field="parameters.rateCurrencyUomId"/>
</entity-and>
<if-empty field="amounts">
<entity-one entity-name="Uom" value-field="currencyUomId">
<field-map field-name="uomId" from-field="parameters.rateCurrencyUomId"/>
</entity-one>
<entity-one entity-name="PeriodType" value-field="periodType"/>
<entity-one entity-name="RateType" value-field="rateType"/>
<entity-one entity-name="WorkEffort" value-field="workEffort"/>
<entity-one entity-name="PartyNameView" value-field="partyNameView"/>
<log level="error" message="A valid rate entry could be found for rateType: ${rateType.description}, workEffort: ${workEffort.workEffortName}, party: ${partyNameView.lastName} ${partyNameView.middleName} ${partyNameView.firstName}${partyNameView.groupName} However.....not for the period: ${period.description} and currency: ${currencyUomId.description}"/>
</if-empty>
</if-compare>
<if-compare field="level" value="party" operator="equals">
<entity-and entity-name="RateAmount" list="amounts" filter-by-date="true">
<field-map field-name="rateTypeId" from-field="parameters.rateTypeId"/>
<field-map field-name="partyId" from-field="parameters.partyId"/>
<field-map field-name="periodTypeId" from-field="parameters.periodTypeId"/>
<field-map field-name="rateCurrencyUomId" from-field="parameters.rateCurrencyUomId"/>
</entity-and>
<if-empty field="amounts">
<entity-one entity-name="Uom" value-field="currencyUomId">
<field-map field-name="uomId" from-field="parameters.rateCurrencyUomId"/>
</entity-one>
<entity-one entity-name="PeriodType" value-field="periodType"/>
<entity-one entity-name="RateType" value-field="rateType"/>
<entity-one entity-name="PartyNameView" value-field="partyNameView"/>
<log level="error" message="A valid rate entry could be found for rateType: ${rateType.description}, party: ${partyNameView.lastName} ${partyNameView.middleName} ${partyNameView.firstName}${partyNameView.groupName} However..... NOT for the period: ${period.description} and currency: ${currencyUomId.description}"/>
</if-empty>
</if-compare>
<if-compare field="level" value="emplPositionType" operator="equals">
<entity-and entity-name="RateAmount" list="amounts" filter-by-date="true">
<field-map field-name="rateTypeId" from-field="parameters.rateTypeId"/>
<field-map field-name="emplPositionTypeId" from-field="parameters.emplPositionTypeId"/>
<field-map field-name="periodTypeId" from-field="parameters.periodTypeId"/>
<field-map field-name="rateCurrencyUomId" from-field="parameters.rateCurrencyUomId"/>
</entity-and>
<if-empty field="amounts">
<entity-one entity-name="Uom" value-field="currencyUomId">
<field-map field-name="uomId" from-field="parameters.rateCurrencyUomId"/>
</entity-one>
<entity-one entity-name="PeriodType" value-field="periodType"/>
<entity-one entity-name="RateType" value-field="rateType"/>
<entity-one entity-name="EmplPositionType" value-field="emplPositionType"/>
<log level="error" message="A valid rate entry could be found for rateType: ${rateType.description}, emplPositionType: ${emplPositionType.description}.... However.....NOT for the period: ${period.description} and currency: ${currencyUomId.description}"/>
<check-errors/>
</if-empty>
</if-compare>
<if-compare field="level" value="rateType" operator="equals">
<entity-and entity-name="RateAmount" list="amounts" filter-by-date="true">
<field-map field-name="rateTypeId" from-field="parameters.rateTypeId"/>
<field-map field-name="periodTypeId" from-field="parameters.periodTypeId"/>
<field-map field-name="rateCurrencyUomId" from-field="parameters.rateCurrencyUomId"/>
</entity-and>
<if-empty field="amounts">
<entity-one entity-name="Uom" value-field="currencyUomId">
<field-map field-name="uomId" from-field="parameters.rateCurrencyUomId"/>
</entity-one>
<entity-one entity-name="PeriodType" value-field="periodType"/>
<entity-one entity-name="RateType" value-field="rateType"/>
<entity-one entity-name="PartyNameView" value-field="partyNameView"/>
<log level="error" message="A valid rate entry could be found for rateType: ${rateType.description}, However.....NOT for the period: ${period.description} and currency: ${currencyUomId.description}"/>
<check-errors/>
</if-empty>
</if-compare>
<if-not-empty field="amounts">
<first-from-list entry="amount" list="amounts"/>
<if-empty field="amount.rateAmount">
<set field="amount.rateAmount" value="0" type="BigDecimal"/>
</if-empty>
<field-to-result field="amount.rateAmount" result-name="rateAmount"/>
<field-to-result field="amount.periodTypeId" result-name="periodTypeId"/>
<field-to-result field="amount.rateCurrencyUomId" result-name="rateCurrencyUomId"/>
<field-to-result field="level"/>
<field-to-result field="amount.fromDate" result-name="fromDate"/>
</if-not-empty>
</simple-method>
<!-- party rate services -->
<simple-method method-name="updatePartyRate" short-description="Update/Create PartyRate">
<set value="_CREATE" field="securityAction"/>
<check-permission permission="ACCOUNTING" action="${securityAction}"><fail-property resource="AccountingUiLabels" property="AccountingPermissionError"/></check-permission>
<check-errors/>
<!-- check if already exist is so expire current record -->
<entity-and entity-name="PartyRate" list="partyRates" filter-by-date="true">
<field-map field-name="partyId" from-field="parameters.partyId"/>
<field-map field-name="rateTypeId" from-field="parameters.rateTypeId"/>
</entity-and>
<if-not-empty field="partyRates">
<first-from-list entry="partyRate" list="partyRates"/>
<now-timestamp field="partyRate.thruDate"/>
<store-value value-field="partyRate"/>
</if-not-empty>
<make-value value-field="newEntity" entity-name="PartyRate"/>
<set-pk-fields map="parameters" value-field="newEntity"/>
<if-empty field="newEntity.fromDate"><now-timestamp field="newEntity.fromDate"/></if-empty>
<set-nonpk-fields map="parameters" value-field="newEntity"/>
<call-simple-method method-name="checkOtherDefaultRate"/>
<create-value value-field="newEntity"/>
<if-not-empty field="parameters.rateAmount">
<set-service-fields service-name="updateRateAmount" map="parameters" to-map="updRate"/>
<call-service service-name="updateRateAmount" in-map-name="updRate"/>
</if-not-empty>
</simple-method>
<simple-method method-name="checkOtherDefaultRate" short-description="remove an other defaultRate flag">
<set value="_CREATE" field="securityAction"/>
<check-permission permission="ACCOUNTING" action="${securityAction}"><fail-property resource="AccountingUiLabels" property="AccountingPermissionError"/></check-permission>
<check-errors/>
<if-compare field="newEntity.defaultRate" value="Y" operator="equals">
<entity-and entity-name="PartyRate" list="rates" filter-by-date="true">
<field-map field-name="partyId" from-field="newEntity.partyId"/>
<field-map field-name="defaultRate" value="Y"/>
</entity-and>
<if-not-empty field="rates">
<first-from-list entry="rate" list="rates"/>
<set field="rate.defaultRate" value="N"/>
<store-value value-field="rate"/>
</if-not-empty>
</if-compare>
</simple-method>
<simple-method method-name="deletePartyRate" short-description="Delete PartyRate">
<set value="_UPDATE" field="securityAction"/>
<check-permission permission="ACCOUNTING" action="${securityAction}"><fail-property resource="AccountingUiLabels" property="AccountingPermissionError"/></check-permission>
<check-errors/>
<entity-one entity-name="PartyRate" value-field="lookedUpValue"/>
<now-timestamp field="lookedUpValue.thruDate"/>
<store-value value-field="lookedUpValue"/>
<set-service-fields service-name="deleteRateAmount" map="parameters" to-map="delRateAmount"/>
<set field="delRateAmount.fromDate" from-field="parameters.rateAmountFromDate"/>
<call-service service-name="deleteRateAmount" in-map-name="delRateAmount"/>
</simple-method>
<!-- migrate service -->
<simple-method method-name="migrateRateFactor" short-description="migrate the several entities which were change in the rate refactor activity">
<entity-condition entity-name="OldEmplPositionTypeRate" list="posRates"/>
<iterate entry="posRate" list="posRates">
<make-value value-field="emplPositionTypeRate" entity-name="EmplPositionTypeRate"/>
<set-pk-fields value-field="posRate" map="emplPositionTypeRate"/>
<set-nonpk-fields value-field="posRate" map="emplPositionTypeRate"/>
<create-value value-field="emplPositionTypeRate"/>
<make-value value-field="rateAmount" entity-name="RateAmount"/>
<set-pk-fields value-field="posRate" map="rateAmount"/>
<set-nonpk-fields value-field="posRate" map="rateAmount"/>
<set field="rateAmount.workeffortId" value="_NA_"/>
<set field="rateAmount.partyId" value="_NA_"/>
<property-to-field resource="general.properties" property="currency.uom.id.default" field="rateAmount.rateCurrencyUomId"/>
<create-value value-field="rateAmount"/>
</iterate>
<entity-condition entity-name="OldPartyRate" list="partyRates"/>
<iterate entry="oldPartyRate" list="oldPartyRates">
<make-value value-field="partyRate" entity-name="PartyRate"/>
<set-pk-fields value-field="oldPartyRate" map="partyRate"/>
<set-nonpk-fields value-field="oldPartyRate" map="partyRate"/>
<create-value value-field="partyRate"/>
<make-value value-field="rateAmount" entity-name="RateAmount"/>
<set-pk-fields value-field="oldPartyRate" map="rateAmount"/>
<set-nonpk-fields value-field="oldPartyRate" map="rateAmount"/>
<set field="rateAmount.workeffortId" value="_NA_"/>
<set field="rateAmount.emplPositionTypeId" value="_NA_"/>
<set field="rateAmount.periodTypeId" value="RATE_HOUR"/>
<create-value value-field="rateAmount"/>
</iterate>
</simple-method>
</simple-methods>