<?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.
-->
<services xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="https://ofbiz.apache.org/dtds/services.xsd">
    <description>Accounting Services: Agreements </description>
    <vendor>OFBiz</vendor>
    <version>1.0</version>

    <!-- Agreement  -->
    <service name="createAgreement" default-entity-name="Agreement" engine="entity-auto" invoke="create" auth="true">
        <description>Create an Agreement</description>
        <permission-service service-name="acctgAgreementPermissionCheck" main-action="CREATE"/>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
        <auto-attributes include="pk" mode="OUT" optional="true"/>
        <override name="textData" allow-html="safe"/>
    </service>
    <service name="updateAgreement" default-entity-name="Agreement" engine="entity-auto" invoke="update" auth="true">
        <description>Update an Agreement</description>
        <permission-service service-name="acctgAgreementPermissionCheck" main-action="UPDATE"/>
        <auto-attributes include="pk" mode="IN" optional="false"/>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
        <override name="textData" allow-html="safe"/>
    </service>
    <service name="expireAgreement" engine="entity-auto" default-entity-name="Agreement" invoke="expire" auth="true">
        <description>Expire an Agreement</description>
        <permission-service service-name="acctgAgreementPermissionCheck" main-action="UPDATE"/>
        <auto-attributes include="pk" mode="IN" optional="false"/>
    </service>
    <service name="copyAgreement" default-entity-name="Agreement" engine="groovy"
                location="component://accounting/src/main/groovy/org/apache/ofbiz/accounting/agreement/AgreementServicesScript.groovy" invoke="copyAgreement" auth="true">
        <description>Copy an Agreement</description>
        <permission-service service-name="acctgAgreementPermissionCheck" main-action="CREATE"/>
        <auto-attributes include="pk" mode="INOUT" optional="false"/>
        <attribute name="copyAgreementTerms" type="String" mode="IN" optional="true"/>
        <attribute name="copyAgreementProducts" type="String" mode="IN" optional="true"/>
        <attribute name="copyAgreementParties" type="String" mode="IN" optional="true"/>
        <attribute name="copyAgreementFacilities" type="String" mode="IN" optional="true"/>
    </service>

    <!-- AgreementItem  -->
    <service name="createAgreementItem" default-entity-name="AgreementItem" engine="entity-auto" invoke="create" auth="true">
        <description>Create an AgreementItem</description>
        <permission-service service-name="acctgAgreementPermissionCheck" main-action="CREATE"/>
        <auto-attributes include="pk" mode="INOUT" optional="false"/>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
        <override name="agreementText" allow-html="safe"/>
        <override name="agreementItemSeqId" optional="true"></override>
    </service>
    <service name="updateAgreementItem" default-entity-name="AgreementItem" engine="entity-auto" invoke="update" auth="true">
        <description>Update an AgreementItem</description>
        <permission-service service-name="acctgAgreementPermissionCheck" main-action="UPDATE"/>
        <auto-attributes include="pk" mode="IN" optional="false"/>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
        <override name="agreementText" allow-html="safe"/>
    </service>
    <service name="removeAgreementItem" default-entity-name="AgreementItem" engine="entity-auto" invoke="delete" auth="true">
        <description>Remove an AgreementItem</description>
        <permission-service service-name="acctgAgreementPermissionCheck" main-action="DELETE"/>
        <auto-attributes include="pk" mode="IN" optional="false"/>
    </service>

    <!-- AgreementItemAttribute -->
    <service name="createAgreementItemAttribute" default-entity-name="AgreementItemAttribute" engine="entity-auto" invoke="create" auth="true">
        <description>Create an AgreementItemAttribute</description>
        <permission-service service-name="acctgAgreementPermissionCheck" main-action="CREATE"/>
        <auto-attributes include="pk" mode="IN" optional="false"/>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
    </service>
    <service name="updateAgreementItemAttribute" default-entity-name="AgreementItemAttribute" engine="entity-auto" invoke="update" auth="true">
        <description>Update an AgreementItemAttribute</description>
        <permission-service service-name="acctgAgreementPermissionCheck" main-action="UPDATE"/>
        <auto-attributes include="pk" mode="IN" optional="false"/>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
    </service>
    <service name="deleteAgreementItemAttribute" default-entity-name="AgreementItemAttribute" engine="entity-auto" invoke="delete" auth="true">
        <description>Delete an AgreementItemAttribute</description>
        <permission-service service-name="acctgAgreementPermissionCheck" main-action="DELETE"/>
        <auto-attributes include="pk" mode="IN" optional="false"/>
    </service>

    <!-- AgreementTerm  -->
    <service name="createAgreementTerm" default-entity-name="AgreementTerm" engine="entity-auto" invoke="create" auth="true">
        <description>Create an AgreementTerm</description>
        <permission-service service-name="acctgAgreementPermissionCheck" main-action="CREATE"/>
        <auto-attributes include="pk" mode="INOUT" optional="true"/>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
        <override name="textValue" allow-html="safe"/>
    </service>
    <service name="updateAgreementTerm" default-entity-name="AgreementTerm" engine="entity-auto" invoke="update" auth="true">
        <description>Update an AgreementTerm</description>
        <permission-service service-name="acctgAgreementPermissionCheck" main-action="UPDATE"/>
        <auto-attributes include="pk" mode="IN" optional="false"/>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
        <override name="textValue" allow-html="safe"/>
    </service>
    <service name="deleteAgreementTerm" default-entity-name="AgreementTerm" engine="entity-auto" invoke="delete" auth="true">
        <description>Delete an AgreementTerm</description>
        <permission-service service-name="acctgAgreementPermissionCheck" main-action="DELETE"/>
        <auto-attributes include="pk" mode="IN" optional="false"/>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
    </service>

    <!-- AgreementPromoAppl  -->
    <service name="createAgreementPromoAppl" default-entity-name="AgreementPromoAppl" engine="entity-auto" invoke="create" auth="true">
        <description>Create an AgreementPromoAppl</description>
        <permission-service service-name="acctgAgreementPermissionCheck" main-action="CREATE"/>
        <auto-attributes include="pk" mode="IN" optional="false"/>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
    </service>
    <service name="updateAgreementPromoAppl" default-entity-name="AgreementPromoAppl" engine="entity-auto" invoke="update" auth="true">
        <description>Update an AgreementPromoAppl</description>
        <permission-service service-name="acctgAgreementPermissionCheck" main-action="UPDATE"/>
        <auto-attributes include="pk" mode="IN" optional="false"/>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
    </service>
    <service name="removeAgreementPromoAppl" default-entity-name="AgreementPromoAppl" engine="entity-auto" invoke="delete" auth="true">
        <description>Remove an AgreementPromoAppl</description>
        <permission-service service-name="acctgAgreementPermissionCheck" main-action="DELETE"/>
        <auto-attributes include="pk" mode="IN" optional="false"/>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
    </service>

    <!-- AgreementProductAppl  -->
    <service name="createAgreementProductAppl" default-entity-name="AgreementProductAppl" engine="entity-auto" invoke="create" auth="true">
        <description>Create an AgreementProductAppl</description>
        <permission-service service-name="acctgAgreementPermissionCheck" main-action="CREATE"/>
        <auto-attributes include="pk" mode="IN" optional="false"/>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
    </service>
    <service name="updateAgreementProductAppl" default-entity-name="AgreementProductAppl" engine="entity-auto" invoke="update" auth="true">
        <description>Update an AgreementProductAppl</description>
        <permission-service service-name="acctgAgreementPermissionCheck" main-action="UPDATE"/>
        <auto-attributes include="pk" mode="IN" optional="false"/>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
    </service>
    <service name="removeAgreementProductAppl" default-entity-name="AgreementProductAppl" engine="entity-auto" invoke="delete" auth="true">
        <description>Remove an AgreementProductAppl</description>
        <permission-service service-name="acctgAgreementPermissionCheck" main-action="DELETE"/>
        <auto-attributes include="pk" mode="IN" optional="false"/>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
    </service>

    <!-- AgreementFacilityAppl  -->
    <service name="createAgreementFacilityAppl" default-entity-name="AgreementFacilityAppl" engine="entity-auto" invoke="create" auth="true">
        <description>Create an AgreementFacilityAppl</description>
        <permission-service service-name="acctgAgreementPermissionCheck" main-action="CREATE"/>
        <auto-attributes include="pk" mode="IN" optional="false"/>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
    </service>
    <service name="updateAgreementFacilityAppl" default-entity-name="AgreementFacilityAppl" engine="entity-auto" invoke="update" auth="true">
        <description>Update an AgreementFacilityAppl</description>
        <permission-service service-name="acctgAgreementPermissionCheck" main-action="UPDATE"/>
        <auto-attributes include="pk" mode="IN" optional="false"/>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
    </service>
    <service name="removeAgreementFacilityAppl" default-entity-name="AgreementFacilityAppl" engine="entity-auto" invoke="delete" auth="true">
        <description>Remove an AgreementFacilityAppl</description>
        <permission-service service-name="acctgAgreementPermissionCheck" main-action="DELETE"/>
        <auto-attributes include="pk" mode="IN" optional="false"/>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
    </service>

    <!-- AgreementPartyApplic  -->
    <service name="createAgreementPartyApplic" default-entity-name="AgreementPartyApplic" engine="entity-auto" invoke="create" auth="true">
        <description>Create an AgreementPartyApplic</description>
        <permission-service service-name="acctgAgreementPermissionCheck" main-action="CREATE"/>
        <auto-attributes include="pk" mode="IN" optional="false"/>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
    </service>
    <service name="updateAgreementPartyApplic" default-entity-name="AgreementPartyApplic" engine="entity-auto" invoke="update" auth="true">
        <description>Update an AgreementPartyApplic</description>
        <permission-service service-name="acctgAgreementPermissionCheck" main-action="UPDATE"/>
        <auto-attributes include="pk" mode="IN" optional="false"/>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
    </service>
    <service name="removeAgreementPartyApplic" default-entity-name="AgreementPartyApplic" engine="entity-auto" invoke="delete" auth="true">
        <description>Remove an AgreementPartyApplic</description>
        <permission-service service-name="acctgAgreementPermissionCheck" main-action="DELETE"/>
        <auto-attributes include="pk" mode="IN" optional="false"/>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
    </service>

    <!-- AgreementGeographicalApplic  -->
    <service name="createAgreementGeographicalApplic" default-entity-name="AgreementGeographicalApplic" engine="entity-auto" invoke="create" auth="true">
        <description>Create an AgreementGeographicalApplic</description>
        <permission-service service-name="acctgAgreementPermissionCheck" main-action="CREATE"/>
        <auto-attributes include="pk" mode="IN" optional="false"/>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
    </service>
    <service name="updateAgreementGeographicalApplic" default-entity-name="AgreementGeographicalApplic" engine="entity-auto" invoke="update" auth="true">
        <description>Update an AgreementGeographicalApplic</description>
        <permission-service service-name="acctgAgreementPermissionCheck" main-action="UPDATE"/>
        <auto-attributes include="pk" mode="IN" optional="false"/>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
    </service>
    <service name="removeAgreementGeographicalApplic" default-entity-name="AgreementGeographicalApplic" engine="entity-auto" invoke="delete" auth="true">
        <description>Remove an AgreementGeographicalApplic</description>
        <permission-service service-name="acctgAgreementPermissionCheck" main-action="DELETE"/>
        <auto-attributes include="pk" mode="IN" optional="false"/>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
    </service>

    <!-- AgreementRole -->
    <service name="createAgreementRole" default-entity-name="AgreementRole" engine="entity-auto" invoke="create" auth="true">
        <description>Create an Agreement Role</description>
        <auto-attributes mode="IN" include="pk" optional="false"/>
        <auto-attributes mode="IN" include="nonpk" optional="true"/>
    </service>
    <service name="updateAgreementRole" default-entity-name="AgreementRole" engine="entity-auto" invoke="update" auth="true">
        <description>Update an Agreement Role</description>
        <auto-attributes mode="IN" include="pk" optional="false"/>
        <auto-attributes mode="IN" include="nonpk" optional="true"/>
    </service>
    <service name="deleteAgreementRole" default-entity-name="AgreementRole" engine="entity-auto" invoke="delete" auth="true">
        <description>Delete an Agreement Role</description>
        <auto-attributes mode="IN" include="pk" optional="false"/>
    </service>

    <!-- AgreementType -->
    <service name="createAgreementType" default-entity-name="AgreementType" engine="entity-auto" invoke="create" auth="true">
        <description>Create a AgreementType record</description>
        <auto-attributes include="pk" mode="INOUT" optional="true"/>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
    </service>
    <service name="updateAgreementType" default-entity-name="AgreementType" engine="entity-auto" invoke="update" auth="true">
        <description>Update a AgreementType record</description>
        <auto-attributes include="pk" mode="IN"/>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
    </service>
    <service name="removeAgreementType" default-entity-name="AgreementType" engine="entity-auto" invoke="delete" auth="true">
        <description>Remove a AgreementType record</description>
        <auto-attributes include="pk" mode="IN"/>
    </service>

    <!-- Agreement content services -->
    <service name="createAgreementContent" default-entity-name="AgreementContent" engine="entity-auto" invoke="create" auth="true">
        <description>Create Agreement Content</description>
        <auto-attributes include="pk" mode="IN" optional="false"/>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
        <override name="fromDate" optional="true"/>
    </service>
    <service name="updateAgreementContent" default-entity-name="AgreementContent" engine="entity-auto" invoke="update" auth="true">
        <description>Update Agreement Content</description>
        <auto-attributes include="pk" mode="IN" optional="false"/>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
    </service>
    <service name="removeAgreementContent" default-entity-name="AgreementContent" engine="entity-auto" invoke="delete" auth="true">
        <description>Remove Content From Agreement</description>
        <auto-attributes mode="IN" include="pk" optional="false"/>
    </service>

    <service name="uploadAgreementContentFile" engine="group" transaction-timeout="300">
        <description>Upload and attach a file to an agreement</description>
        <group>
            <invoke name="createContentFromUploadedFile" result-to-context="true"/>
            <invoke name="createAgreementContent"/>
        </group>
    </service>

    <service name="getCommissionForProduct" engine="java"
                location="org.apache.ofbiz.accounting.agreement.AgreementServices" invoke="getCommissionForProduct" auth="true">
        <description>Get commission receiving parties and amounts for a product. &lt;br/&gt;
            amount input is for the entire quantity. &lt;br/&gt;&lt;br/&gt;
            Returns a List of Maps each containing &lt;br/&gt;
            partyIdFrom     String  commission paying party &lt;br/&gt;
            partyIdTo       String  commission receiving party &lt;br/&gt;
            commission      BigDecimal  Commission &lt;br/&gt;
            days            Long    term days &lt;br/&gt;
            currencyUomId   String  Currency &lt;br/&gt;
            productId       String  Product Id &lt;br/&gt;
            Will use the virtual product if no agreement is found for a variant product.  If no quantity is specified, defaults to one (1).
        </description>
        <permission-service service-name="acctgCommissionPermissionCheck" main-action="VIEW"/>
        <attribute name="productId" type="String" mode="IN" optional="false"/>
        <attribute name="invoiceId" type="String" mode="IN" optional="true"/>
        <attribute name="invoiceItemSeqId" type="String" mode="IN" optional="true"/>
        <attribute name="invoiceItemTypeId" type="String" mode="IN" optional="false"/>
        <attribute name="amount" type="BigDecimal" mode="IN" optional="false"/>
        <attribute name="quantity" type="BigDecimal" mode="IN" optional="true"/>
        <attribute name="commissions" type="List" mode="OUT" optional="false"/>
    </service>

    <!--AgrementWorkEffortApplic-->
    <service name="createAgreementWorkEffortApplic" default-entity-name="AgreementWorkEffortApplic" engine="entity-auto" invoke="create" auth="true">
        <description> Create AgreementWorkEffortApplic </description>
        <auto-attributes include="pk" mode="IN" optional="false"/>
        <override name="agreementItemSeqId" default-value="_NA_"/>
    </service>
    <service name="deleteAgreementWorkEffortApplic" default-entity-name="AgreementWorkEffortApplic" engine="entity-auto" invoke="delete" auth="true">
        <description>Delete AgreementWorkEffortApplic</description>
        <auto-attributes mode="IN" include="pk" optional="false"/>
    </service>
    
    
    <!-- AgreementTypeAttr services -->
    <service name="createAgreementTypeAttr" default-entity-name="AgreementTypeAttr" engine="entity-auto" invoke="create" auth="true">
        <description>Create an AgreementTypeAttr</description>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
        <auto-attributes include="pk" mode="IN" optional="false"/>
    </service>
    <service name="updateAgreementTypeAttr" default-entity-name="AgreementTypeAttr" engine="entity-auto" invoke="update" auth="true">
        <description>Update an AgreementTypeAttr</description>
        <auto-attributes include="pk" mode="IN" optional="false"/>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
    </service>
    <service name="removeAgreementTypeAttr" default-entity-name="AgreementTypeAttr" engine="entity-auto" invoke="delete" auth="true">
        <description>Remove an AgreementTypeAttr</description>
        <auto-attributes include="pk" mode="IN" optional="false"/>
    </service>
</services>
