<?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</description>
    <vendor>OFBiz</vendor>
    <version>1.0</version>


    <service name="getNextInvoiceId" engine="groovy"
        location="component://accounting/src/main/groovy/org/apache/ofbiz/accounting/invoice/InvoiceServicesScript.groovy" invoke="getNextInvoiceId">
        <description>Get the Next Invoice ID According to Settings on the PartyAcctgPreference Entity for the given Party</description>
        <implements service="createInvoice"/>
        <attribute name="partyId" type="String" mode="IN"/>
        <attribute name="invoiceId" type="String" mode="OUT"/>
    </service>

    <service name="invoiceSequenceEnforced" engine="groovy"
        location="component://accounting/src/main/groovy/org/apache/ofbiz/accounting/invoice/InvoiceServicesScript.groovy" invoke="invoiceSequenceEnforced">
        <implements service="getNextInvoiceId"/>
        <attribute name="partyAcctgPreference" type="org.apache.ofbiz.entity.GenericValue" mode="IN"/>
        <override name="invoiceId" type="Long" mode="OUT"/>
    </service>

    <service name="invoiceSequenceRestart" engine="groovy"
        location="component://accounting/src/main/groovy/org/apache/ofbiz/accounting/invoice/InvoiceServicesScript.groovy" invoke="invoiceSequenceRestart">
        <implements service="getNextInvoiceId"/>
        <attribute name="partyAcctgPreference" type="org.apache.ofbiz.entity.GenericValue" mode="IN"/>
    </service>

    <!-- Invoice services -->
    <service name="createInvoice" engine="groovy" default-entity-name="Invoice"
        location="component://accounting/src/main/groovy/org/apache/ofbiz/accounting/invoice/InvoiceServicesScript.groovy" invoke="createInvoice">
        <description>Create Invoice Record</description>
        <permission-service service-name="acctgInvoicePermissionCheck" main-action="CREATE"/>
        <auto-attributes mode="INOUT" include="pk" optional="true"/>
        <auto-attributes mode="IN" include="nonpk" optional="true"/>
        <override name="invoiceTypeId" mode="IN"/>
        <override name="partyIdFrom" mode = "IN"/>
        <override name="partyId" mode = "IN"/>
        <override name="description" allow-html="safe"/>
        <override name="invoiceMessage" allow-html="safe"/>
        <override name="invoiceDate" default-value="${date:nowTimestamp()}"/>
        <override name="statusId" default-value="INVOICE_IN_PROCESS"/>
    </service>
    <service name="copyInvoice" engine="groovy" default-entity-name="Invoice"
        location="component://accounting/src/main/groovy/org/apache/ofbiz/accounting/invoice/InvoiceServicesScript.groovy" invoke="copyInvoice">
        <description>Create Invoice Record/items from an existing invoice</description>
        <permission-service service-name="acctgInvoicePermissionCheck" main-action="CREATE"/>
        <auto-attributes mode="INOUT" include="pk" optional="true"/>
        <attribute name="invoiceIdToCopyFrom" type="String" mode="IN"/>
    </service>
    <service name="getInvoice" engine="groovy" default-entity-name="Invoice"
        location="component://accounting/src/main/groovy/org/apache/ofbiz/accounting/invoice/InvoiceServicesScript.groovy" invoke="getInvoice">
        <description>Retrieve an existing Invoice/Items</description>
        <permission-service service-name="acctgInvoicePermissionCheck" main-action="VIEW"/>
        <auto-attributes mode="IN" include="pk"/>
        <attribute name="invoice" type="org.apache.ofbiz.entity.GenericValue" mode="OUT"/>
        <attribute name="invoiceItems" type="List" mode="OUT"/><!-- list of invoiceItem GenericValues -->
    </service>
    <service name="updateInvoice" engine="groovy" default-entity-name="Invoice"
        location="component://accounting/src/main/groovy/org/apache/ofbiz/accounting/invoice/InvoiceServicesScript.groovy" invoke="updateInvoice">
        <description>Update an existing Invoice Record</description>
        <permission-service service-name="checkInvoiceStatusInProgress"/>
        <auto-attributes mode="IN" include="pk"/>
        <auto-attributes mode="IN" include="nonpk" optional="true"/>
        <override name="description" allow-html="safe"/>
        <override name="invoiceMessage" allow-html="safe"/>
    </service>
    <service name="setInvoiceStatus" engine="groovy"
        location="component://accounting/src/main/groovy/org/apache/ofbiz/accounting/invoice/InvoiceServicesScript.groovy" invoke="setInvoiceStatus">
        <description>Set the Invoice  Status</description>
        <permission-service service-name="acctgInvoicePermissionCheck" main-action="UPDATE"/>
        <attribute name="invoiceId" type="String" mode="IN"/>
        <attribute name="statusId" type="String" mode="IN"/>
        <attribute name="statusDate" type="Timestamp" mode="IN" default-value="${date:nowTimestamp()}"/>
        <attribute name="paidDate" type="Timestamp" mode="IN" optional="true"/> <!-- only relevant for changes to PAID -->
        <attribute name="invoiceTypeId" type="String" mode="OUT" optional="true"/>
        <attribute name="oldStatusId" type="String" mode="OUT" optional="true"/>
    </service>
    <service name="copyInvoiceToTemplate" engine="groovy"
             location="component://accounting/src/main/groovy/org/apache/ofbiz/accounting/invoice/InvoiceServicesScript.groovy" invoke="copyInvoiceToTemplate">
        <description>Save a Invoice data to a template.</description>
        <permission-service service-name="acctgInvoicePermissionCheck" main-action="CREATE"/>
        <attribute name="invoiceId" type="String" mode="INOUT"/>
        <attribute name="invoiceTypeId" type="String" mode="IN"/>
    </service>
    <service name="checkInvoiceStatusInProgress" engine="groovy"
             location="component://accounting/src/main/groovy/org/apache/ofbiz/accounting/invoice/InvoiceServicesScript.groovy" invoke="checkInvoiceStatusInProgress">
        <description>Check if the invoiceStatus is in progress</description>
        <permission-service service-name="acctgInvoicePermissionCheck" main-action="UPDATE"/>
        <implements service="permissionInterface"/>
        <attribute name="invoiceId" type="String" mode="IN"/>
    </service>

    <!--
    TODO: There is a big problem with the taxableFlag. Currently, all adjustments are treated as having the same taxableFlag as
    the product except when it is a sales tax. This is not very flexible. Additionally, when the invoices are computed, a
    null taxableFlag is considered to be "N" when it should be "unknown". At some point we'll have to implement the adjustment.includeInTax
    field properly so we don't have to rely on Product.taxable and checking by hand each type that is not taxable. The old way is already
    creating an issue with return-wide adjustments: How do we know that such an adjustment is to be taxed or not?  Because of this problem,
    we will continue to have null taxableFlags for awhile yet, which is why the mandatory taxableFlag of this method was taken out.
    -->
    <service name="createInvoiceItem" engine="groovy" default-entity-name="InvoiceItem"
        location="component://accounting/src/main/groovy/org/apache/ofbiz/accounting/invoice/InvoiceServicesScript.groovy" invoke="createInvoiceItem">
        <description>Create a new Invoice Item Record</description>
        <permission-service service-name="checkInvoiceStatusInProgress"/>
        <auto-attributes mode="IN" include="pk"/>
        <auto-attributes mode="IN" include="nonpk" optional="true"/>
        <override name="invoiceItemSeqId" mode="INOUT" optional="true"/><!-- will optionally be assigned by the system -->
        <override name="description" allow-html="safe"/>
    </service>
    <service name="updateInvoiceItem" engine="groovy" default-entity-name="InvoiceItem"
        location="component://accounting/src/main/groovy/org/apache/ofbiz/accounting/invoice/InvoiceServicesScript.groovy" invoke="updateInvoiceItem">
        <description>Update existing Invoice Item Record</description>
        <permission-service service-name="checkInvoiceStatusInProgress"/>
        <auto-attributes mode="INOUT" include="pk"/>
        <auto-attributes mode="IN" include="nonpk" optional="true"/>
        <override name="description" allow-html="safe"/>
    </service>
    <service name="removeInvoiceItem" engine="groovy" default-entity-name="InvoiceItem"
        location="component://accounting/src/main/groovy/org/apache/ofbiz/accounting/invoice/InvoiceServicesScript.groovy" invoke="removeInvoiceItem">
        <description>Remove an existing Invoice Item Record</description>
        <permission-service service-name="checkInvoiceStatusInProgress"/>
        <auto-attributes mode="IN" include="pk"/>
    </service>

    <service name="createInvoiceStatus" engine="entity-auto" default-entity-name="InvoiceStatus" invoke="create" auth="true">
        <description>Create a Invoice Status Record</description>
        <auto-attributes mode="IN" include="pk"/>
        <override name="statusDate" mode="IN" default-value="${date:nowTimestamp()}"/>
    </service>

    <service name="createInvoiceRole" engine="entity-auto" default-entity-name="InvoiceRole" invoke="create">
        <description>Create a new Invoice Role Record</description>
        <permission-service service-name="checkInvoiceStatusInProgress"/>
        <auto-attributes mode="IN" include="pk"/>
        <auto-attributes mode="IN" include="nonpk" optional="true"/>
        <override name="datetimePerformed" default-value="${date:nowTimestamp()}"/>
    </service>
    <service name="removeInvoiceRole" engine="entity-auto" default-entity-name="InvoiceRole" invoke="remove">
        <description>Remove an existing Invoice Role Record</description>
        <permission-service service-name="checkInvoiceStatusInProgress"/>
        <auto-attributes mode="IN" include="pk"/>
    </service>
    <service name="createInvoiceTerm" engine="entity-auto" default-entity-name="InvoiceTerm" invoke="create">
        <description>Create Invoice (Item) Term Record</description>
        <permission-service service-name="checkInvoiceStatusInProgress"/>
        <auto-attributes mode="OUT" include="pk"/>
        <auto-attributes mode="IN" include="nonpk" optional="true"/>
    </service>
    <service name="updateInvoiceTerm" engine="entity-auto" default-entity-name="InvoiceTerm" invoke="update">
        <description>Update Invoice (Item) Term Record</description>
        <permission-service service-name="acctgInvoicePermissionCheck" main-action="UPDATE"/>
        <auto-attributes mode="IN" include="pk"/>
        <auto-attributes mode="IN" include="nonpk" optional="true"/>
    </service>
    <service name="deleteInvoiceTerm" engine="entity-auto" default-entity-name="InvoiceTerm" invoke="delete">
        <description>Delete Invoice (Item) Term Record</description>
        <permission-service service-name="acctgInvoicePermissionCheck" main-action="DELETE"/>
        <auto-attributes mode="IN" include="pk"/>
    </service>
    <service name="createInvoiceForOrderAllItems" engine="java"
        location="org.apache.ofbiz.accounting.invoice.InvoiceServices" invoke="createInvoiceForOrderAllItems">
        <description>
            Create an invoice from existing order using all order items
            orderId = The orderId to associate the invoice with
        </description>
        <attribute name="orderId" type="String" mode="IN"/>
        <attribute name="invoiceId" type="String" mode="OUT" optional="true"/>
    </service>
    <service name="createInvoiceForOrder" engine="java"
        location="org.apache.ofbiz.accounting.invoice.InvoiceServices" invoke="createInvoiceForOrder">
        <description>
            Create an invoice from existing order
            orderId = The orderId to associate the invoice with
            billItems = List of ItemIssuance records to use for creating the invoice
        </description>
        <attribute name="orderId" type="String" mode="IN"/>
        <attribute name="billItems" type="List" mode="IN"/>
        <attribute name="eventDate" type="Timestamp" mode="IN" optional="true"/>
        <attribute name="invoiceId" type="String" mode="INOUT" optional="true"/>
        <attribute name="invoiceTypeId" type="String" mode="OUT" optional="true"/>
    </service>
    <service name="createInvoiceFromReturn" engine="java"
        location="org.apache.ofbiz.accounting.invoice.InvoiceServices" invoke="createInvoiceFromReturn">
        <description>
            Create an invoice from a return
            returnId = The returnId to associate the invoice with
            billItems = List of ShipmentReceipts (for sales return) or ItemIssuance (for purchase return) to use for creating the invoice
        </description>
        <attribute name="returnId" type="String" mode="IN"/>
        <attribute name="billItems" type="List" mode="IN" optional="true"/>
        <attribute name="invoiceId" type="String" mode="OUT" optional="true"/>
    </service>
    <service name="createCommissionInvoices" engine="java"
        location="org.apache.ofbiz.accounting.invoice.InvoiceServices" invoke="createCommissionInvoices">
        <description>
            Create commission invoice for the list of sales invoices.  
            Returns a List of Maps, one for each invoice created containing: 
                commissionInvoiceId: the invoiceId of the invoice created 
                salesRepresentative: the invoice partyIdFrom 
        </description>
        <attribute name="partyIds" type="List" mode="IN" optional="true"/>
        <attribute name="invoiceIds" type="List" mode="IN"/>
        <attribute name="invoicesCreated" type="List" mode="OUT" optional="true"/>
    </service>
    <service name="readyInvoices" engine="java"
        location="org.apache.ofbiz.accounting.invoice.InvoiceServices" invoke="readyInvoices">
        <description>
            Sets status of each invoice in the list of invoices to INVOICE_READY.
        </description>
        <attribute name="invoicesCreated" type="List" mode="IN"/>
    </service>
    <service name="createInvoicesFromShipment" engine="java"
        location="org.apache.ofbiz.accounting.invoice.InvoiceServices" invoke="createInvoicesFromShipment">
        <description>
            Create invoice(s) from a Shipment
            All the order items associated with the shipment will be selected and
            one invoice for each order in the shipment will be created.
            invoicesCreated = List of invoiceIds which were created by this service
        </description>
        <attribute name="shipmentId" type="String" mode="IN"/>
        <attribute name="eventDate" type="Timestamp" mode="IN" optional="true"/>
        <attribute name="invoicesCreated" type="List" mode="OUT" optional="true"/>
    </service>
    <service name="setInvoicesToReadyFromShipment" engine="java"
        location="org.apache.ofbiz.accounting.invoice.InvoiceServices" invoke="setInvoicesToReadyFromShipment">
        <description>Set invoice(s) to Ready from Shipment</description>
        <attribute name="shipmentId" type="String" mode="IN"/>
    </service>

    <service name="createSalesInvoicesFromDropShipment" engine="java"
        location="org.apache.ofbiz.accounting.invoice.InvoiceServices" invoke="createSalesInvoicesFromDropShipment">
        <description>
            Create sales invoice(s) from a drop shipment by wrapping a call to
            createInvoicesFromShipments with the createSalesInvoicesForDropShipments parameter
        </description>
        <attribute name="shipmentId" type="String" mode="IN"/>
        <attribute name="invoicesCreated" type="List" mode="OUT" optional="true"/>
    </service>
    <service name="createInvoicesFromShipments" engine="java"
        location="org.apache.ofbiz.accounting.invoice.InvoiceServices" invoke="createInvoicesFromShipments">
        <description>
            Create invoice(s) from a shipment list.
            All the order items associated with the shipments will be selected and
            one invoice for each order will be created (each invoice could contain
            items shipped in different shipments).
            If the shipments are drop shipments, the type of invoices (purchase or sales) created
            will be controlled by the createSalesInvoicesForDropShipments parameter (purchase by default).
            invoicesCreated = List of invoiceIds which were created by this service
        </description>
        <attribute name="shipmentIds" type="List" mode="IN"/>
        <attribute name="createSalesInvoicesForDropShipments" type="Boolean" mode="IN" optional="true"/>
        <attribute name="eventDate" type="Timestamp" mode="IN" optional="true"/>
        <attribute name="invoicesCreated" type="List" mode="OUT" optional="true"/>
    </service>
    <service name="createInvoicesFromReturnShipment" engine="java"
        location="org.apache.ofbiz.accounting.invoice.InvoiceServices" invoke="createInvoicesFromReturnShipment">
        <description>
            Create invoice(s) from a return Shipment
            invoicesCreated = List of invoiceIds which were created by this service
        </description>
        <attribute name="shipmentId" type="String" mode="IN"/>
        <attribute name="invoicesCreated" type="List" mode="OUT" optional="true"/>
    </service>
    <service name="sendInvoicePerEmail" engine="groovy"
        location="component://accounting/src/main/groovy/org/apache/ofbiz/accounting/invoice/InvoiceServicesScript.groovy" invoke="sendInvoicePerEmail">
        <description>Send an invoice per email</description>
        <attribute name="invoiceId" type="String" mode="IN"/>
        <attribute name="sendFrom" type="String" mode="IN"/>
        <attribute name="sendTo" type="String" mode="IN"/>
        <attribute name="sendCc" type="String" mode="IN" optional="true"/>
        <attribute name="subject" type="String" mode="IN" optional="true"/>
        <attribute name="bodyText" type="String" mode="IN" optional="true" allow-html="any"/>
        <attribute name="other" type="String" mode="IN" optional="true"/><!-- to send the invoice in the 'other' currency (y) -->
    </service>
    <service name="checkInvoicePaymentApplications" engine="java"
            location="org.apache.ofbiz.accounting.invoice.InvoiceServices" invoke="checkInvoicePaymentApplications">
        <description>Checks to see if the payments applied to an invoice total up to the invoice total; if so sets to PAID</description>
        <attribute name="invoiceId" type="String" mode="IN"/>
    </service>
    <service name="createInvoiceContactMech" engine="entity-auto" invoke="create" default-entity-name="InvoiceContactMech">
        <description>Create a ContactMech for an invoice</description>
        <permission-service service-name="acctgInvoicePermissionCheck" main-action="CREATE"/>
        <auto-attributes include="pk" mode="IN"/>
    </service>
    <service name="deleteInvoiceContactMech" engine="entity-auto" invoke="delete" default-entity-name="InvoiceContactMech">
        <description>Delete a ContactMech for an invoice</description>
        <permission-service service-name="acctgInvoicePermissionCheck" main-action="DELETE"/>
        <auto-attributes include="pk" mode="IN"/>
    </service>
    <service name="calculateInvoicedAdjustmentTotal" engine="java"
            location="org.apache.ofbiz.accounting.invoice.InvoiceServices" invoke="calculateInvoicedAdjustmentTotal">
        <description>Calculate the previously invoiced amount for an OrderAdjustment</description>
        <attribute name="orderAdjustment" type="org.apache.ofbiz.entity.GenericValue" mode="IN"/>
        <attribute name="invoicedTotal" type="BigDecimal" mode="OUT"/>
    </service>

    <service name="updateInvoiceItemType" default-entity-name="InvoiceItemType" engine="entity-auto" invoke="update">
        <description>Update Invoice Item Type Record</description>
        <auto-attributes mode="IN" include="pk"/>
        <auto-attributes mode="IN" include="nonpk" optional="true"/>
    </service>
    <!-- Auto generate Invoice for fixed period -->
    <service name="autoGenerateInvoiceFromExistingInvoice" engine="groovy"
             location="component://accounting/src/main/groovy/org/apache/ofbiz/accounting/invoice/InvoiceServicesScript.groovy" invoke="autoGenerateInvoiceFromExistingInvoice">
        <description>Scheduled service to generate Invoice from an existing Invoice</description>
        <attribute name="recurrenceInfoId" mode="IN" type="String"/>
    </service>

    <service name="cancelInvoice" engine="groovy"
             location="component://accounting/src/main/groovy/org/apache/ofbiz/accounting/invoice/InvoiceServicesScript.groovy" invoke="cancelInvoice">
        <description>Cancel Invoice</description>
        <attribute name="invoiceId" type="String" mode="IN"/>
        <attribute name="invoiceTypeId" type="String" mode="OUT"/>
    </service>

    <service name="getInvoiceRunningTotal" engine="groovy" auth="true"
            location="component://accounting/src/main/groovy/org/apache/ofbiz/accounting/invoice/InvoiceServicesScript.groovy" invoke="getInvoiceRunningTotal">
        <description>calculate running total for selected Invoices</description>
        <attribute name="invoiceIds" type="List" mode="IN"/>
        <attribute name="organizationPartyId" type="String" mode="IN" optional="true"/>
        <attribute name="invoiceRunningTotal" type="String" mode="OUT"/>
    </service>

    <service name="addTaxOnInvoice" engine="groovy"
        location="component://accounting/src/main/groovy/org/apache/ofbiz/accounting/invoice/InvoiceServicesScript.groovy" invoke="addTaxOnInvoice">
        <description>Call Tax Calculate Service</description>
        <attribute name="invoiceId" type="String" mode="IN"/>
    </service>

    <service name="getInvoicesFilterByAssocType" engine="groovy" auth="true"
            location="component://accounting/src/main/groovy/org/apache/ofbiz/accounting/invoice/InvoiceServicesScript.groovy" invoke="getInvoicesFilterByAssocType">
        <description>Filter invoices by invoiceItemAssocTypeId</description>
        <attribute name="invoiceList" type="List" mode="IN"/>
        <attribute name="invoiceItemAssocTypeId" type="String" mode="IN"/>
        <attribute name="filteredInvoiceList" type="List" mode="OUT" optional="true"/>
    </service>

    <!-- Invoice Association Services -->
    <service name="createInvoiceItemAssoc" default-entity-name="InvoiceItemAssoc" engine="entity-auto" invoke="create" auth="true">
        <description>Create a InvoiceItemAssoc</description>
        <auto-attributes include="pk" mode="IN"/>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
        <override name="fromDate" optional="true"/>
    </service>
    <service name="updateInvoiceItemAssoc" default-entity-name="InvoiceItemAssoc" engine="entity-auto" invoke="update" auth="true">
        <description>Update a InvoiceItemAssoc</description>
        <auto-attributes include="pk" mode="IN"/>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
    </service>
    <service name="deleteInvoiceItemAssoc" default-entity-name="InvoiceItemAssoc" engine="entity-auto" invoke="delete" auth="true">
        <description>Delete a InvoiceItemAssoc</description>
        <auto-attributes include="pk" mode="IN"/>
    </service>

    <service name="removeInvoiceItemAssocOnCancelInvoice" engine="groovy" auth="true"
            location="component://accounting/src/main/groovy/org/apache/ofbiz/accounting/invoice/InvoiceServicesScript.groovy" invoke="removeInvoiceItemAssocOnCancelInvoice">
        <description>Remove invoiceItemAssoc record on cancel invoice</description>
        <attribute name="invoiceId" type="String" mode="IN"/>
    </service>

    <service name="resetOrderItemBillingAndOrderAdjustmentBillingOnCancelInvoice" engine="groovy" auth="true"
            location="component://accounting/src/main/groovy/org/apache/ofbiz/accounting/invoice/InvoiceServicesScript.groovy" invoke="resetOrderItemBillingAndOrderAdjustmentBillingOnCancelInvoice">
        <description>Reset OrderItemBilling and OrderAdjustmentBilling records on cancel invoice, so it is isn't considered invoiced any more by createInvoiceForOrder service</description>
        <attribute name="invoiceId" type="String" mode="IN"/>
    </service>

    <service name="massChangeInvoiceStatus" engine="groovy" auth="true"
            location="component://accounting/src/main/groovy/org/apache/ofbiz/accounting/invoice/InvoiceServicesScript.groovy" invoke="massChangeInvoiceStatus">
        <description>Set status of invoices in bulk.</description>
        <attribute name="invoiceIds" type="List" mode="IN"/>
        <attribute name="statusId" type="String" mode="IN"/>
    </service>
    
    <service name="createInvoiceFromOrder" engine="groovy"
            location="component://accounting/src/main/groovy/org/apache/ofbiz/accounting/invoice/InvoiceServicesScript.groovy" invoke="createInvoiceFromOrder">
        <description>Create an invoice from existing order when invoicePerShipment is N</description>
        <attribute name="orderId" type="String" mode="IN"/>
        <attribute name="invoiceId" type="String" mode="OUT" optional="true"/>
    </service>
    
    <!-- Invoice content services -->
    <service name="createInvoiceContent" default-entity-name="InvoiceContent" engine="entity-auto" invoke="create" auth="true">
        <description>Add Content To Invoice</description>
        <auto-attributes include="pk" mode="INOUT"/>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
        <override name="fromDate" optional="true"/>
    </service>
    <service name="updateInvoiceContent" default-entity-name="InvoiceContent" engine="entity-auto" invoke="update" auth="true">
        <description>Update Content To Invoice</description>
        <auto-attributes include="pk" mode="IN"/>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
    </service>
    <service name="removeInvoiceContent" default-entity-name="InvoiceContent" engine="entity-auto" invoke="delete" auth="true">
        <description>Remove Content From Invoice</description>
        <auto-attributes include="pk" mode="IN"/>
    </service>
    <service name="createInvoiceContentAndUpdateContent" engine="group" auth="true">
        <description>Add Content To Invoice and update the content</description>
        <group>
            <invoke name="createInvoiceContent"/>
            <invoke name="updateContent"/>
        </group>
    </service>
    <service name="updateInvoiceContentAndContent" engine="group" auth="true">
        <description>update the content Invoice link and the content</description>
        <group>
            <invoke name="updateInvoiceContent"/>
            <invoke name="updateContent"/>
        </group>
    </service>
    <service name="createSimpleTextContentForInvoice" engine="group" auth="true">
        <group>
            <invoke name="createSimpleTextContent" result-to-context="true"/>
            <invoke name="createInvoiceContentAndUpdateContent"/>
        </group>
    </service>
    <service name="updateSimpleTextContentForInvoice" engine="group" auth="true">
        <group>
            <invoke name="updateSimpleTextContent"/>
            <invoke name="updateInvoiceContentAndContent"/>
        </group>
    </service>

    <service name="isInvoiceInForeignCurrency" engine="groovy" auth="true"
            location="component://accounting/src/main/groovy/org/apache/ofbiz/accounting/invoice/InvoiceServicesScript.groovy" invoke="isInvoiceInForeignCurrency">
        <description>check if an invoice is in a foreign currency related to the accounting company.</description>
        <attribute name="invoiceId" type="String" mode="IN"/>
        <attribute name="isForeign" type="Boolean" mode="OUT"/>
    </service>
    <service name="importInvoice" engine="java"
        location="org.apache.ofbiz.accounting.invoice.InvoiceServices" invoke="importInvoice" auth="true">
        <description>Import an invoice with invoice items in csv format</description>
        <permission-service service-name="acctgInvoicePermissionCheck" main-action="CREATE"/>
        <attribute mode="INOUT" name="organizationPartyId" type="String"/>
        <attribute mode="IN" name="uploadedFile" type="java.nio.ByteBuffer" optional="true" />
    </service>
    <service name="createInvoiceItemAttribute" default-entity-name="InvoiceItemAttribute" engine="entity-auto" invoke="create" auth="true">
        <description>Create a InvoiceItemAttribute record</description>
        <auto-attributes include="pk" mode="IN"/>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
    </service>
    <service name="updateInvoiceItemAttribute" default-entity-name="InvoiceItemAttribute" engine="entity-auto" invoke="update" auth="true">
        <description>Update a InvoiceItemAttribute record</description>
        <auto-attributes include="pk" mode="IN"/>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
    </service>
    <service name="deleteInvoiceItemAttribute" default-entity-name="InvoiceItemAttribute" engine="entity-auto" invoke="delete" auth="true">
        <description>Delete a InvoiceItemAttribute record</description>
        <auto-attributes include="pk" mode="IN"/>
    </service>
    <service name="createInvoiceTermAttribute" default-entity-name="InvoiceTermAttribute" engine="entity-auto" invoke="create" auth="true">
        <description>Create a InvoiceTermAttribute record</description>
        <auto-attributes include="pk" mode="IN"/>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
    </service>
    <service name="updateInvoiceTermAttribute" default-entity-name="InvoiceTermAttribute" engine="entity-auto" invoke="update" auth="true">
        <description>Update a InvoiceTermAttribute record</description>
        <auto-attributes include="pk" mode="IN"/>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
    </service>
    <service name="deleteInvoiceTermAttribute" default-entity-name="InvoiceTermAttribute" engine="entity-auto" invoke="delete" auth="true">
        <description>Delete a InvoiceTermAttribute record</description>
        <auto-attributes include="pk" mode="IN"/>
    </service>

    <service name="createInvoiceTypeAttr" default-entity-name="InvoiceTypeAttr" engine="entity-auto" invoke="create" auth="true">
        <description>Create a InvoiceTypeAttr record</description>
        <auto-attributes include="pk" mode="IN"/>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
    </service>
    <service name="updateInvoiceTypeAttr" default-entity-name="InvoiceTypeAttr" engine="entity-auto" invoke="update" auth="true">
        <description>Update a InvoiceTypeAttr record</description>
        <auto-attributes include="pk" mode="IN"/>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
    </service>
    <service name="deleteInvoiceTypeAttr" default-entity-name="InvoiceTypeAttr" engine="entity-auto" invoke="delete" auth="true">
        <description>Delete a InvoiceTypeAttr record</description>
        <auto-attributes include="pk" mode="IN"/>
    </service>

    <!-- InvoiceAttribute services -->
    <service name="createInvoiceAttribute" default-entity-name="InvoiceAttribute" engine="entity-auto" invoke="create" auth="true">
        <description>Create a InvoiceAttribute</description>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
        <auto-attributes include="pk" mode="INOUT"/>
    </service>
    <service name="updateInvoiceAttribute" default-entity-name="InvoiceAttribute" engine="entity-auto" invoke="update" auth="true">
        <description>Update a InvoiceAttribute</description>
        <auto-attributes include="pk" mode="IN"/>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
    </service>
    <service name="deleteInvoiceAttribute" default-entity-name="InvoiceAttribute" engine="entity-auto" invoke="delete" auth="true">
        <description>Delete a InvoiceAttribute</description>
        <auto-attributes include="pk" mode="IN"/>
    </service>

    <!-- InvoiceItemAssocType services -->
    <service name="createInvoiceItemAssocType" default-entity-name="InvoiceItemAssocType" engine="entity-auto" invoke="create" auth="true">
        <description>Create a InvoiceItemAssocType</description>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
        <auto-attributes include="pk" mode="INOUT" optional="true"/>
    </service>
    <service name="updateInvoiceItemAssocType" default-entity-name="InvoiceItemAssocType" engine="entity-auto" invoke="update" auth="true">
        <description>Update a InvoiceItemAssocType</description>
        <auto-attributes include="pk" mode="IN"/>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
    </service>
    <service name="deleteInvoiceItemAssocType" default-entity-name="InvoiceItemAssocType" engine="entity-auto" invoke="delete" auth="true">
        <description>Delete a InvoiceItemAssocType</description>
        <auto-attributes include="pk" mode="IN"/>
    </service>

    <!-- InvoiceNote services -->
    <service name="createInvoiceNote" default-entity-name="InvoiceNote" engine="entity-auto" invoke="create" auth="true">
        <description>Create a InvoiceNote</description>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
        <auto-attributes include="pk" mode="INOUT"/>
    </service>
    <service name="deleteInvoiceNote" default-entity-name="InvoiceNote" engine="entity-auto" invoke="delete" auth="true">
        <description>Delete a InvoiceNote</description>
        <auto-attributes include="pk" mode="IN"/>
    </service>

    <service name="createInvoiceContentType" default-entity-name="InvoiceContentType" engine="entity-auto" invoke="create" auth="true">
        <description>Create a InvoiceContentType</description>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
        <auto-attributes include="pk" mode="INOUT" optional="true"/>
    </service>
    <service name="updateInvoiceContentType" default-entity-name="InvoiceContentType" engine="entity-auto" invoke="update" auth="true">
        <description>Update a InvoiceContentType</description>
        <auto-attributes include="pk" mode="IN"/>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
    </service>
    <service name="deleteInvoiceContentType" default-entity-name="InvoiceContentType" engine="entity-auto" invoke="delete" auth="true">
        <description>Delete a InvoiceContentType</description>
        <auto-attributes include="pk" mode="IN"/>
    </service>

    <!-- InvoiceItemTypeAttr services -->
    <service name="createInvoiceItemTypeAttr" default-entity-name="InvoiceItemTypeAttr" engine="entity-auto" invoke="create" auth="true">
        <description>Create InvoiceItemTypeAttr</description>
        <auto-attributes include="pk" mode="IN"/>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
    </service>
    <service name="updateInvoiceItemTypeAttr" default-entity-name="InvoiceItemTypeAttr" engine="entity-auto" invoke="update" auth="true">
        <description>Update InvoiceItemTypeAttr</description>
        <auto-attributes include="pk" mode="IN"/>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
    </service>
    <service name="deleteInvoiceItemTypeAttr" default-entity-name="InvoiceItemTypeAttr" engine="entity-auto" invoke="delete" auth="true">
        <description>Delete InvoiceItemTypeAttr</description>
        <auto-attributes include="pk" mode="IN"/>
    </service>

    <service name="createInvoiceItemTypeMap" default-entity-name="InvoiceItemTypeMap" engine="entity-auto" invoke="create" auth="true">
        <description>Create InvoiceItemTypeMap</description>
        <auto-attributes include="pk" mode="IN"/>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
    </service>
    <service name="updateInvoiceItemTypeMap" default-entity-name="InvoiceItemTypeMap" engine="entity-auto" invoke="update" auth="true">
        <description>Update InvoiceItemTypeMap</description>
        <auto-attributes include="pk" mode="IN"/>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
    </service>
    <service name="deleteInvoiceItemTypeMap" default-entity-name="InvoiceItemTypeMap" engine="entity-auto" invoke="delete" auth="true">
        <description>Delete InvoiceItemTypeMap</description>
        <auto-attributes include="pk" mode="IN"/>
    </service>

    <service name="createInvoiceType" default-entity-name="InvoiceType" engine="entity-auto" invoke="create" auth="true">
        <description>Create a InvoiceType</description>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
        <auto-attributes include="pk" mode="INOUT" optional="true"/>
    </service>
    <service name="updateInvoiceType" default-entity-name="InvoiceType" engine="entity-auto" invoke="update" auth="true">
        <description>Update a InvoiceType</description>
        <auto-attributes include="pk" mode="IN"/>
        <auto-attributes include="nonpk" mode="IN" optional="true"/>
    </service>
    <service name="deleteInvoiceType" default-entity-name="InvoiceType" engine="entity-auto" invoke="delete" auth="true">
        <description>Delete a InvoiceType</description>
        <auto-attributes include="pk" mode="IN"/>
    </service>
</services>
