ilscipio/scipio-erp

View on GitHub
applications/accounting/widget/invoice/InvoiceScreens.xml

Summary

Maintainability
Test Coverage
<?xml version="1.0" encoding="UTF-8"?>
<!--
This file is subject to the terms and conditions defined in the
files 'LICENSE' and 'NOTICE', which are part of this source
code package.
-->

<screens xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/widget-screen.xsd">

    <!-- SCIPIO: NOTE: The old parameters.invoiceDecoratorLocation pattern that existed here has been supplanted
        by the decorator default-fallback-location pattern for parameters.mainDecoratorLocation (see CommonScreens.xml). -->

    <screen name="FindInvoices">
        <section>
            <actions>
                <set field="activeSubMenuItem" value="Invoices"/>
                <set field="titleProperty" value="PageTitleFindInvoice"/>
            </actions>
            <widgets>
                <decorator-screen name="CommonInvoicesDecorator" location="${parameters.mainDecoratorLocation}">
                    <decorator-section name="body">
                        <decorator-screen name="FindScreenDecorator" location="component://common/widget/CommonScreens.xml">
                            <decorator-section name="menu-bar">
                                <include-menu name="InvoiceSubTabBar" location="component://accounting/widget/AccountingMenus.xml"/>
                                <container style="clear"/>
                            </decorator-section>
                            <decorator-section name="search-options">
                                <include-form name="FindInvoices" location="component://accounting/widget/invoice/InvoiceForms.xml"/>
                            </decorator-section>
                            <decorator-section name="search-results">
                                <include-form name="ListInvoices"  location="component://accounting/widget/invoice/InvoiceForms.xml"/>
                            </decorator-section>
                        </decorator-screen>
                    </decorator-section>
                </decorator-screen>
            </widgets>
        </section>
    </screen>

    <screen name="NewInvoice">
        <section>
            <actions>
                <set field="titleProperty" value="AccountingCreateNewInvoice"/>
                <set field="activeSubMenuItem" value="Invoices"/>
                <entity-one entity-name="Invoice" value-field="invoice"/>
            </actions>
            <widgets>
                <decorator-screen name="CommonInvoicesDecorator" location="${parameters.mainDecoratorLocation}">
                    <decorator-section name="body">
                        <screenlet title="${uiLabelMap.AccountingCreateNewSalesInvoice}">
                            <include-form name="NewSalesInvoice" location="component://accounting/widget/invoice/InvoiceForms.xml"/>
                        </screenlet>
                        <screenlet title="${uiLabelMap.AccountingCreateNewPurchaseInvoice}">
                            <include-form name="NewPurchaseInvoice" location="component://accounting/widget/invoice/InvoiceForms.xml"/>
                        </screenlet>
                    </decorator-section>
                </decorator-screen>
            </widgets>
        </section>
    </screen>

    <screen name="EditInvoice">
        <section>
            <actions>
                <set field="titleProperty" value="PageTitleEditInvoice"/>
                <set field="activeSubMenuItem" value="editInvoice"/>
                <set field="invoiceId" from-field="parameters.invoiceId"/>
                <entity-one entity-name="Invoice" value-field="invoice"/>
                <entity-one entity-name="InvoiceType" value-field="invoiceType">
                    <field-map field-name="invoiceTypeId" from-field="invoice.invoiceTypeId"/>
                </entity-one>
            </actions>
            <widgets>
                <decorator-screen name="InvoiceDecorator" location="${parameters.mainDecoratorLocation}">
                    <decorator-section name="body">
                        <section>
                            <condition>
                                <if-compare field="invoice.statusId" operator="equals" value="INVOICE_IN_PROCESS"/>
                            </condition>
                            <widgets>
                                <screenlet>
                                    <include-form name="EditInvoice" location="component://accounting/widget/invoice/InvoiceForms.xml"/>
                                </screenlet>
                            </widgets>
                            <fail-widgets>
                                <!-- 
                                <screenlet>
                                    <include-form name="invoiceHeader" location="component://accounting/widget/invoice/InvoiceForms.xml"/>
                                </screenlet>
                                -->
                            </fail-widgets>
                        </section>
                    </decorator-section>
                </decorator-screen>
            </widgets>
        </section>
    </screen>

    <!-- SCIPIO: ToDo Cleanup screen -->
    <screen name="invoiceOverview">
        <section>
            <actions>
                <property-map resource="PartyUiLabels" map-name="uiLabelMap" global="true"/>
                <property-map resource="ProductUiLabels" map-name="uiLabelMap" global="true"/>
                <property-map resource="AccountingUiLabels" map-name="uiLabelMap" global="true"/>
                <set field="title" value="${uiLabelMap.AccountingInvoice}: ${parameters.invoiceId}"/>
                <set field="activeSubMenuItem" value="invoiceOverview"/>
                <set field="invoiceId" from-field="parameters.invoiceId"/>
                <entity-one entity-name="Invoice" value-field="invoice"/>
                <entity-and entity-name="InvoiceRole" list="invoiceRoles">
                    <field-map field-name="invoiceId" from-field="parameters.invoiceId"/>
                    <order-by field-name="partyId"/>
                </entity-and>
                <entity-and entity-name="InvoiceStatus" list="invoiceStatus">
                    <field-map field-name="invoiceId" from-field="parameters.invoiceId"/>
                    <order-by field-name="statusDate"/>
                </entity-and>
                <entity-and entity-name="InvoiceTerm" list="invoiceTerms">
                    <field-map field-name="invoiceId" from-field="parameters.invoiceId"/>
                    <order-by field-name="invoiceTermId"/>
                </entity-and>
                <entity-and entity-name="TimeEntry" list="timeEntries">
                    <field-map field-name="invoiceId" from-field="parameters.invoiceId"/>
                    <order-by field-name="invoiceItemSeqId"/>
                </entity-and>
                <script location="component://accounting/webapp/accounting/WEB-INF/actions/invoice/CreateApplicationList.groovy"/>
                <set field="invoiceAmount" value="${groovy:org.ofbiz.accounting.invoice.InvoiceWorker.getInvoiceTotal(invoice)}" type="BigDecimal"/>
                <set field="notAppliedAmount" value="${groovy:org.ofbiz.accounting.invoice.InvoiceWorker.getInvoiceNotApplied(invoice)}" type="BigDecimal"/>
                <set field="appliedAmount" value="${groovy:org.ofbiz.accounting.invoice.InvoiceWorker.getInvoiceApplied(invoice)}" type="BigDecimal"/>
                <entity-condition entity-name="InvItemAndOrdItem" list="invItemAndOrdItems">
                    <condition-expr field-name="invoiceId"  operator="equals" from-field="invoiceId"/>
                    <order-by field-name="invoiceItemSeqId"/>
                </entity-condition>
                <entity-condition entity-name="AcctgTransAndEntries" list="acctgTransAndEntries">
                    <condition-expr field-name="invoiceId"  operator="equals" from-field="invoiceId"/>
                    <order-by field-name="acctgTransId"/>
                    <order-by field-name="acctgTransEntrySeqId"/>
                </entity-condition>
            </actions>
            <widgets>
                <decorator-screen name="InvoiceDecorator" location="${parameters.mainDecoratorLocation}">
                    <decorator-section name="body">
                        <section>
                            <condition>
                                <not><if-empty field="invoice"/></not>
                            </condition>
                            <widgets>
                                <section>
                            <condition>
                                <if-compare field="invoice.statusId" operator="equals" value="INVOICE_IN_PROCESS"/>
                            </condition>
                            <widgets>
                                <container style="${styles.grid_row}">
                                    <container style="${styles.grid_large}6 ${styles.grid_cell}">
                                        <include-screen name="ScipioInvoiceInfo"/>
                                    </container>
                                    <container style="${styles.grid_large}6 ${styles.grid_cell}">
                                        <include-screen name="ScipioInvoiceTerms"/>
                                        <include-screen name="ScipioInvoicePaymentInfo"/>
                                        <include-screen name="ScipioInvoiceAppliedPayment"/>
                                    </container>
                                </container>
                            
                                <!-- TODO: Migrate?
                                    <link target="editInvoice" text="${uiLabelMap.CommonUpdate}" style="${styles.link_nav} ${styles.action_update}">
                                        <parameter param-name="invoiceId"/>
                                    </link>
                                    
                                    <link target="listInvoiceItems" text="${uiLabelMap.CommonUpdate}" style="${styles.link_nav} ${styles.action_update}">
                                        <parameter param-name="invoiceId"/>
                                    </link>
                                -->
                                
                                <container style="${styles.grid_row}">
                                    <container style="${styles.grid_large}12 ${styles.grid_cell}">
                                        <include-screen name="ScipioInvoiceItems"/>
                                    </container>
                               </container>
                                <!--    
                                <screenlet title="${uiLabelMap.AccountingInvoiceRoles}" navigation-form-name="invoiceRoles">
                                    <container>
                                        <link target="invoiceRoles" text="${uiLabelMap.CommonUpdate}" style="${styles.link_nav} ${styles.action_update}">
                                            <parameter param-name="invoiceId"/>
                                        </link>
                                    </container>
                                    <include-form name="invoiceRoles" location="component://accounting/widget/invoice/InvoiceForms.xml"/>
                                </screenlet>                             
                                <section>
                                    <condition>
                                        <not><if-empty field="timeEntries"/></not>
                                    </condition>
                                    <widgets>
                                        <screenlet title="${uiLabelMap.AccountingInvoiceTimeEntries}" navigation-form-name="ListTimeEntries">
                                            <link target="editInvoiceTimeEntries" text="${uiLabelMap.CommonUpdate}" style="${styles.link_nav} ${styles.action_update}">
                                                <parameter param-name="invoiceId"/>
                                            </link>
                                            <include-form name="ListTimeEntries" location="component://accounting/widget/invoice/InvoiceForms.xml"/>
                                        </screenlet>
                                    </widgets>
                                </section>
                                <screenlet title="${uiLabelMap.AccountingTransactions}" navigation-form-name="AcctgTransAndEntries">
                                    <include-form name="AcctgTransAndEntries" location="component://accounting/widget/invoice/InvoiceForms.xml"/>
                                </screenlet>-->  
                            </widgets>
                            <fail-widgets>
                               <container style="${styles.grid_row}">
                                    <container style="${styles.grid_large}6 ${styles.grid_cell}">
                                        <include-screen name="ScipioInvoiceInfo"/>
                                    </container>
                                    <container style="${styles.grid_large}6 ${styles.grid_cell}">
                                        <include-screen name="ScipioInvoiceTerms"/>
                                        <include-screen name="ScipioInvoicePaymentInfo"/>
                                        <include-screen name="ScipioInvoiceAppliedPayment"/>
                                    </container>
                               </container>
                               <container style="${styles.grid_row}">
                                    <container style="${styles.grid_large}12 ${styles.grid_cell}">
                                        <include-screen name="ScipioInvoiceItems"/>
                                    </container>
                               </container>
                                <!-- 
                                <container style="${styles.grid_large}6">
                                    <screenlet title="${uiLabelMap.AccountingInvoiceRoles}" navigation-form-name="invoiceRoles">
                                        <include-form name="invoiceRoles" location="component://accounting/widget/invoice/InvoiceForms.xml"/>
                                    </screenlet>
                                </container>
                                <section>
                                    <condition>
                                        <not><if-empty field="timeEntries"/></not>
                                    </condition>
                                    <widgets>
                                        <screenlet title="${uiLabelMap.AccountingInvoiceTimeEntries}" navigation-form-name="ListTimeEntries">
                                            <include-form name="ListTimeEntries" location="component://accounting/widget/invoice/InvoiceForms.xml"/>
                                        </screenlet>
                                    </widgets>
                                </section>
                                <screenlet title="${uiLabelMap.AccountingTransactions}" navigation-form-name="AcctgTransAndEntries">
                                    <include-form name="AcctgTransAndEntries" location="component://accounting/widget/invoice/InvoiceForms.xml"/>
                                </screenlet>
                                -->
                            </fail-widgets>
                                </section>
                            </widgets>
                            <fail-widgets>
                                <label text="${uiLabelMap.AccountingInvoiceDoesNotExists}"></label>
                            </fail-widgets>
                        </section>
                    </decorator-section>
                </decorator-screen>
            </widgets>
        </section>
    </screen>

    <screen name="EditInvoiceApplications">
        <section>
            <actions>
                <set field="titleProperty" value="PageTitleListEditInvoiceApplications"/>
                <set field="activeSubMenuItem" value="editInvoiceApplications"/>

                <set field="invoiceId" from-field="parameters.invoiceId"/>
                <entity-one entity-name="Invoice" value-field="invoice"/>
                <script location="component://accounting/webapp/accounting/WEB-INF/actions/invoice/CreateApplicationList.groovy"/>
                <script location="component://accounting/webapp/accounting/WEB-INF/actions/invoice/ListNotAppliedPayments.groovy"/>
                <set field="invoiceAmount" value="${groovy:org.ofbiz.accounting.invoice.InvoiceWorker.getInvoiceTotal(invoice)}" type="BigDecimal"/>
                <set field="notAppliedAmount" value="${groovy:org.ofbiz.accounting.invoice.InvoiceWorker.getInvoiceNotApplied(invoice)}" type="BigDecimal"/>
                <set field="appliedAmount" value="${groovy:org.ofbiz.accounting.invoice.InvoiceWorker.getInvoiceApplied(invoice)}" type="BigDecimal"/>
            </actions>
            <widgets>
                <decorator-screen name="InvoiceDecorator" location="${parameters.mainDecoratorLocation}">
                    <decorator-section name="body">
                        <section>
                            <condition>
                                <if-compare field="notAppliedAmount" operator="greater" value="0"/>
                            </condition>
                            <widgets>
                                <screenlet title="${uiLabelMap.AccountingAssignPaymentToInvoice}">
                                    <include-form name="AddPayment" location="component://accounting/widget/invoice/InvoiceForms.xml"/>
                                </screenlet>
                                <screenlet title="${uiLabelMap.AccountingPaymentsApplied} ${appliedAmount?currency(${invoice.currencyUomId})} ${uiLabelMap.AccountingOpenPayments} ${notAppliedAmount?currency(${invoice.currencyUomId})}">
                                   <include-form name="EditInvoiceApplications" location="component://accounting/widget/invoice/InvoiceForms.xml"/>
                                </screenlet>
                                <section>
                                    <condition>
                                        <or>
                                            <not><if-empty field="payments"/></not>
                                            <not><if-empty field="paymentsActualCurrency"/></not>
                                        </or>
                                    </condition>
                                    <widgets>
                                        <screenlet title="${uiLabelMap.AccountingListPaymentsNotYetApplied} [${invoice.partyIdFrom}] ${uiLabelMap.AccountingPaymentSentForm} [${invoice.partyId}]">
                                            <section>
                                                <condition>
                                                    <not><if-empty field="payments"/></not>
                                                </condition>
                                                <widgets>
                                                    <include-form name="ListPaymentsNotApplied" location="component://accounting/widget/invoice/InvoiceForms.xml"/>
                                                </widgets>
                                            </section>
                                            <section>
                                                <condition>
                                                    <not><if-empty field="paymentsActualCurrency"/></not>
                                                </condition>
                                                <widgets>
                                                    <include-form name="ListPaymentsNotAppliedForeignCurrency" location="component://accounting/widget/invoice/InvoiceForms.xml"/>
                                                </widgets>
                                            </section>
                                        </screenlet>
                                    </widgets>
                                </section>
                            </widgets>
                            <fail-widgets>
                                <screenlet title="${uiLabelMap.AccountingPaymentsApplied} ${appliedAmount?currency(${invoice.currencyUomId})}  ${uiLabelMap.AccountingOpenPayments} ${notAppliedAmount?currency(${invoice.currencyUomId})}">
                                    <include-form name="EditInvoiceApplications" location="component://accounting/widget/invoice/InvoiceForms.xml"/>
                                </screenlet>
                            </fail-widgets>
                        </section>
                    </decorator-section>
                </decorator-screen>
            </widgets>
        </section>
    </screen>

    <screen name="EditInvoiceItems">
        <section>
            <actions>                
                <set field="viewIndex" from-field="parameters.viewIndex"/>
                <set field="viewSize" from-field="parameters.viewSize"/>
                <set field="titleProperty" value="PageTitleListInvoices"/>
                <set field="activeSubMenuItem" value="listInvoiceItems"/>
                <set field="invoiceId" from-field="parameters.invoiceId"/>
                <set field="invoiceItemSeqd" from-field="parameters.invoiceItemSeqId"/>
                <property-to-field field="defaultCurrencyUomId" resource="general" property="currency.uom.id.default" default="USD"/>
                <entity-one entity-name="Invoice" value-field="invoice"/>
                <entity-one entity-name="InvoiceItem" value-field="invoiceItem"/>
                <entity-and entity-name="InvoiceItem" list="invoiceItems">
                    <field-map field-name="invoiceId" from-field="parameters.invoiceId"/>
                    <order-by field-name="invoiceItemSeqId"/>
                </entity-and>
                <entity-condition entity-name="InvoiceItemType" list="PayrolGroup">
                    <condition-expr field-name="parentTypeId" value="PAYROL"/>
                </entity-condition>
                <entity-condition entity-name="InvoiceItemType" list="PayrolList"/>
                <script location="component://accounting/webapp/accounting/WEB-INF/actions/invoice/GetAccountOrganizationAndClass.groovy"/>
            </actions>
            <widgets>
                <decorator-screen name="InvoiceDecorator" location="${parameters.mainDecoratorLocation}">
                    <decorator-section name="body">
                        <screenlet title="${uiLabelMap.AccountingInvoiceItemAdd} - ${uiLabelMap.AccountingInvoice}: ${invoiceId}">
                            <section>
                                <condition>
                                    <not><if-compare field="invoice.invoiceTypeId" operator="equals" value="PAYROL_INVOICE"/></not>
                                </condition>
                                <widgets>
                                    <include-form name="EditInvoiceItem" location="component://accounting/widget/invoice/InvoiceForms.xml"/>
                                </widgets>
                                <fail-widgets>
                                    <platform-specific><html><html-template location="component://accounting/webapp/accounting/invoice/InvoiceItemsPayrol.ftl"/></html></platform-specific>
                                </fail-widgets>
                            </section>
                        </screenlet>
                        <screenlet title="${uiLabelMap.AccountingInvoiceItems}">
                            <include-form name="EditInvoiceItems" location="component://accounting/widget/invoice/InvoiceForms.xml"/>
                        </screenlet>
                    </decorator-section>
                </decorator-screen>
            </widgets>
        </section>
    </screen>

    <screen name="EditInvoiceTimeEntries">
        <section>
            <actions>
                <set field="viewIndex" from-field="parameters.viewIndex"/>
                <set field="viewSize" from-field="parameters.viewSize"/>
                <set field="titleProperty" value="PageTitleListInvoiceTimeEntries"/>
                <set field="activeSubMenuItem" value="EditInvoiceTimeEntries"/>
                <set field="invoiceId" from-field="parameters.invoiceId"/>
                <entity-one entity-name="Invoice" value-field="invoice"/>
                <entity-and entity-name="TimeEntry" list="timeEntries">
                    <field-map field-name="invoiceId" from-field="parameters.invoiceId"/>
                    <order-by field-name="timeEntryId"/>
                </entity-and>
            </actions>
            <widgets>
                <decorator-screen name="InvoiceDecorator" location="${parameters.mainDecoratorLocation}">
                    <decorator-section name="body">
                        <screenlet title="${uiLabelMap.AccountingInvoiceTimeEntries}">
                            <include-form name="EditTimeEntries" location="component://accounting/widget/invoice/InvoiceForms.xml"/>
                        </screenlet>
                    </decorator-section>
                </decorator-screen>
            </widgets>
        </section>
    </screen>

    <screen name="InvoiceRoles">
        <section>
            <actions>
                <set field="titleProperty" value="PageTitleListInvoiceRoles"/>
                <set field="activeSubMenuItem" value="invoiceRoles"/>
                <set field="invoiceId" from-field="parameters.invoiceId"/>
                <entity-one entity-name="Invoice" value-field="invoice"/>
                <entity-and entity-name="InvoiceRole" list="invoiceRoles">
                    <field-map field-name="invoiceId" from-field="invoiceId"/>
                    <order-by field-name="partyId"/>
                </entity-and>
            </actions>
            <widgets>
                <decorator-screen name="InvoiceDecorator" location="${parameters.mainDecoratorLocation}">
                    <decorator-section name="body">
                        <screenlet id="PartyInvoiceRolePanel" title="${uiLabelMap.AccountingPartyRoleAdd}" collapsible="true">
                            <include-form name="EditInvoiceRole" location="component://accounting/widget/invoice/InvoiceForms.xml"/>
                        </screenlet>
                        <include-form name="ListInvoiceRoles" location="component://accounting/widget/invoice/InvoiceForms.xml"/>
                    </decorator-section>
                </decorator-screen>
            </widgets>
        </section>
    </screen>

    <screen name="InvoiceTerms">
        <section>
            <actions>
                <set field="titleProperty" value="PageTitleListEditInvoiceTerms"/>
                <set field="activeSubMenuItem" value="invoiceTerms"/>
                <set field="invoiceId" from-field="parameters.invoiceId"/>
                <entity-one entity-name="Invoice" value-field="invoice"/>
                <entity-and entity-name="InvoiceTerm" list="invoiceTerms">
                    <field-map field-name="invoiceId" from-field="invoiceId"/>
                    <order-by field-name="invoiceTermId"/>
                </entity-and>
            </actions>
            <widgets>
                <decorator-screen name="InvoiceDecorator" location="${parameters.mainDecoratorLocation}">
                    <decorator-section name="body">
                        <screenlet id="PartyInvoiceTermPanel" collapsible="true" title="${uiLabelMap.PageTitleNewInvoiceTerm}">
                            <include-form name="EditInvoiceTerm" location="component://accounting/widget/invoice/InvoiceForms.xml"/>
                        </screenlet>
                        <screenlet title="${uiLabelMap.CommonTerms}">
                            <include-form name="ListInvoiceTerms" location="component://accounting/widget/invoice/InvoiceForms.xml" />
                        </screenlet>
                    </decorator-section>
                </decorator-screen>
            </widgets>
        </section>
    </screen>

    
    <screen name="SendPerEmail">
        <section>
            <actions>
                <set field="titleProperty" value="PageTitleSendInvoicePerEmail"/>
                <set field="invoiceId" from-field="parameters.invoiceId"/>
                <entity-one entity-name="Invoice" value-field="invoice"/>
                <set field="activeSubMenuItem" value="sendPerEmail"/>
            </actions>
            <widgets>
                <decorator-screen name="CommonInvoicesDecorator" location="${parameters.mainDecoratorLocation}">
                    <decorator-section name="body">
                        <screenlet title="${uiLabelMap.CommonSendPerEmail}">
                            <include-form name="SendPerEmail" location="component://accounting/widget/invoice/InvoiceForms.xml"/>
                        </screenlet>
                    </decorator-section>
                </decorator-screen>
            </widgets>
        </section>
    </screen>

    <screen name="sendPerEmailBody">
        <section>
            <widgets>
                <!-- SCIPIO: FIXME?: There is no sendPerEmail.ftl in stock 14-17.
                <platform-specific><html><html-template location="component://accounting/webapp/accounting/invoice/sendPerEmail.ftl"/></html></platform-specific>-->
                <label text="${uiLabelMap.CommonNotImplementedSentence}"/>
            </widgets>
        </section>
    </screen>

    <screen name="ListCustomerInvoices">
        <section>
            <actions>
                <property-map resource="AccountingUiLabels" map-name="uiLabelMap" global="true"/>
                <script location="component://party/webapp/partymgr/WEB-INF/actions/party/GetMyCompany.groovy"/>
                <entity-condition entity-name="Invoice" list="invoices">
                    <condition-list combine="and">
                        <condition-expr field-name="partyId" operator="equals" from-field="myCompanyId"/>
                        <condition-list combine="or">
                            <condition-expr field-name="statusId" operator="equals" value="INVOICE_APPROVED"/>
                            <condition-expr field-name="statusId" operator="equals" value="INVOICE_SENT"/>
                            <condition-expr field-name="statusId" operator="equals" value="INVOICE_READY"/>
                            <condition-expr field-name="statusId" operator="equals" value="INVOICE_PAID"/>
                        </condition-list>
                    </condition-list>
                    <order-by field-name="invoiceDate DESC"/>
                </entity-condition>
            </actions>
            <widgets>
                <screenlet title="${uiLabelMap.PageTitleListInvoices}" navigation-form-name="ListInvoices">
                    <include-form name="ListCustomerInvoices"  location="component://accounting/widget/invoice/InvoiceForms.xml"/>
                </screenlet>
            </widgets>
        </section>
    </screen>

    <screen name="ListSupplierInvoices">
        <section>
            <actions>
                <set field="myCompanyId" from-field="userLogin.partyId"/>
                <entity-condition entity-name="Invoice" list="invoiceslistexternal">
                    <condition-list combine="and">
                        <condition-expr field-name="partyIdFrom" operator="equals" from-field="myCompanyId"/>
                        <condition-expr field-name="invoiceTypeId" operator="equals" value="PURCHASE_INVOICE"/>
                        <condition-list combine="or">
                            <condition-expr field-name="statusId" operator="equals" value="INVOICE_APPROVED"/>
                            <condition-expr field-name="statusId" operator="equals" value="INVOICE_SENT"/>
                            <condition-expr field-name="statusId" operator="equals" value="INVOICE_READY"/>
                            <condition-expr field-name="statusId" operator="equals" value="INVOICE_PAID"/>
                        </condition-list>
                    </condition-list>
                    <order-by field-name="invoiceDate DESC"/>
                </entity-condition>
            </actions>
            <widgets>
                <screenlet title="${uiLabelMap.PageTitleListInvoices}" navigation-form-name="ListInvoices">
                    <include-form name="ListSupplierInvoices"  location="component://accounting/widget/invoice/InvoiceForms.xml"/>
                </screenlet>
            </widgets>
        </section>
    </screen>

    <screen name="DownloadInvoices">
        <section>
            <actions>
                <script location="component://party/webapp/partymgr/WEB-INF/actions/party/GetMyCompany.groovy"/>
                <entity-condition entity-name="StatusItem" list="invoiceStatuses">
                    <condition-expr field-name="statusTypeId" operator="equals" value="INVOICE_STATUS"/>
                </entity-condition>
                <entity-condition entity-name="InvoiceType" list="invoiceTypes">
                    <condition-expr field-name="parentTypeId" operator="equals" value="INVOICE"/>
                </entity-condition>
            </actions>
            <widgets>
                <decorator-screen name="CommonInvoicesDecorator" location="${parameters.mainDecoratorLocation}">
                    <decorator-section name="body">
                        <screenlet title="${uiLabelMap.PageTitleDownloadInvoices}" navigation-form-name="DownloadInvoices">
                            <platform-specific>
                                <html><html-template location="component://accounting/webapp/accounting/invoice/ScipioDownloadInvoices.ftl"/></html>
                            </platform-specific>
                        </screenlet>
                    </decorator-section>
                </decorator-screen>
            </widgets>
        </section>
    </screen>
    
    <!-- 
    ********************
    * Accounts Payable
    ********************
     -->
    <screen name="CommissionRun">
        <section>
            <actions>
                <set field="titleProperty" value="AccountingFindSalesInvoicesForCommissionRun"/>
                <set field="activeSubMenuItem" value="commissionRun"/>
                <set field="salesRepPartyList" type="List" from-field="parameters.partyIds"/>
                <script location="component://accounting/webapp/ap/WEB-INF/actions/invoices/CommissionRun.groovy"/>
                
                <!-- asmslect parameters, must be prefixed by asm_ for setMultipleSelectJs.ftl -->
                <set field="asm_multipleSelectForm"  value="CommissionRun"/>
                <set field="asm_multipleSelect"  value="CommissionRun_partyId"/>
                <set field="asm_formSize" value="700"/>
                <set field="asm_listItemPercentOfForm" value="95"/>
                <set field="asm_sortable" value="false"/>
                <property-map resource="AccountingUiLabels" map-name="uiLabelMap" global="true"/>
                <set field="asm_title" value="${uiLabelMap.AccountingSelectPartiesForCommissionInvoice}"/>
            </actions>
            <widgets>
                <decorator-screen name="CommonInvoicesDecorator" location="${parameters.mainDecoratorLocation}">
                    <decorator-section name="body"> 
                        <platform-specific><html><html-template location="component://common/webcommon/includes/setMultipleSelectJs.ftl"/></html></platform-specific>
                        <decorator-screen name="FindScreenDecorator" location="component://common/widget/CommonScreens.xml">
                            <decorator-section name="search-options">
                                <include-form name="CommissionRun" location="component://accounting/widget/invoice/InvoiceForms.xml"/>
                            </decorator-section>
                            <decorator-section name="search-results">
                                <platform-specific>
                                    <html><html-template location="component://accounting/webapp/ap/invoices/CommissionRun.ftl"/></html>
                                </platform-specific>
                            </decorator-section>
                        </decorator-screen>
                    </decorator-section>
                </decorator-screen>
            </widgets>
        </section>
    </screen>

    <screen name="CommissionReport">
        <section>
            <actions>
                <set field="titleProperty" value="AccountingCommissionReport"/>
                <set field="activeSubMenuItem" value="commissionReport"/>
                <script location="component://accounting/webapp/ap/WEB-INF/actions/invoices/CommissionReport.groovy"/>
            </actions>
            <widgets>
                <decorator-screen name="CommonInvoicesDecorator" location="${parameters.mainDecoratorLocation}">
                    <decorator-section name="body">
                        <decorator-screen name="FindScreenDecorator" location="component://common/widget/CommonScreens.xml">
                            <decorator-section name="search-options">
                                <include-form name="CommissionReport" location="component://accounting/widget/invoice/InvoiceForms.xml"/>
                            </decorator-section>
                            <decorator-section name="search-results">
                                <platform-specific>
                                    <html><html-template location="component://accounting/webapp/ap/invoices/CommissionReport.ftl"/></html>
                                </platform-specific>
                            </decorator-section>
                        </decorator-screen>
                    </decorator-section>
                </decorator-screen>
            </widgets>
        </section>
    </screen>
    
    <!-- Migrated from AP/InvoiceScreens.xml -->
    <screen name="ListAPReports">
        <section>
            <actions>
                <set field="titleProperty" value="AccountingArPageTitleListReports"/>
                <set field="activeSubMenuItem" value="apReports"/>
                <set field="invoiceTypeId" value="PURCHASE_INVOICE"/>
                <set field="organizationPartyId" from-field="userPreferences.ORGANIZATION_PARTY" default-value="${defaultOrganizationPartyId}"/>
                <script location="component://accounting/webapp/accounting/WEB-INF/actions/invoice/InvoiceReport.groovy"/>
            </actions>
            <widgets>
                <decorator-screen name="CommonApDecorator" location="${parameters.mainDecoratorLocation}">
                    <decorator-section name="body">
                        <screenlet title="${uiLabelMap.AccountingPastDueInvoices}: (${PastDueInvoicestotalAmount})" navigation-form-name="ListReports">
                            <section>
                                <actions>
                                    <set field="invoices" from-field="PastDueInvoices"/>
                                </actions>
                                <widgets>
                                    <include-screen name="ScipioInvoices" location="component://accounting/widget/invoice/InvoiceScreens.xml"/>
                                </widgets>
                            </section>
                        </screenlet>
                        <screenlet title="${uiLabelMap.AccountingInvoicesDueSoon}: (${InvoicesDueSoonTotalAmount})" navigation-form-name="ListReports">
                            <section>
                                <actions>
                                    <set field="invoices" from-field="InvoicesDueSoon"/>
                                </actions>
                                <widgets>
                                    <include-screen name="ScipioInvoices" location="component://accounting/widget/invoice/InvoiceScreens.xml"/>
                                </widgets>
                            </section>
                        </screenlet>
                    </decorator-section>
                </decorator-screen>
            </widgets>
        </section>
    </screen>
    
    <screen name="FindApInvoices">
        <section>
            <actions>
                <set field="titleProperty" value="AccountingFindApInvoices"/>
                <set field="activeSubMenuItem" value="findApInvoices"/>
                <service service-name="performFind" result-map="result">
                    <field-map field-name="inputFields" from-field="parameters"/>
                    <field-map field-name="entityName" value="InvoiceAndType"/>
                    <field-map field-name="orderBy" value="invoiceDate DESC"/>
                </service>
                <!-- SCIPIO: DON'T DO THIS; causes exceptions due to ftl iteration. get rid of the EntityListIterator.
                <set field="invoices" from-field="result.listIt"/> -->
                <script lang="groovy"><![CDATA[
                    if (context.result?.listIt != null) {
                        context.invoices = result.listIt.getCompleteList();
                        result.listIt.close();
                    } else {
                        context.invoices = [];
                    }
                ]]></script>
                
                <set field="organizationPartyId" from-field="parameters.organizationPartyId" default-value="${defaultOrganizationPartyId}"/>
                <set field="paymentPartyId" from-field="parameters.partyIdFrom" default-value="${parameters.organizationPartyId}"/>
            </actions>
            <widgets>
                <decorator-screen name="CommonApDecorator" location="${parameters.mainDecoratorLocation}">
                    <decorator-section name="body">
                        <decorator-screen name="FindScreenDecorator" location="component://common/widget/CommonScreens.xml">
                            <decorator-section name="menu-bar">
                                <container style="button-bar">
                                    <link target="NewPurchaseInvoice" text="${uiLabelMap.CommonNew} ${uiLabelMap.CommonInvoice}" style="${styles.link_nav} ${styles.action_add}"/>
                                </container>
                            </decorator-section>
                            <decorator-section name="search-options">
                                <include-form name="FindApInvoices" location="component://accounting/widget/invoice/InvoiceForms.xml"/>
                            </decorator-section>
                            <decorator-section name="search-results">
                                <platform-specific>
                                    <html><html-template location="component://accounting/webapp/ap/invoices/PurchaseInvoices.ftl"/></html>
                                </platform-specific>
                            </decorator-section>
                        </decorator-screen>
                    </decorator-section>
                </decorator-screen>
            </widgets>
            <finally-actions>
                <close-object field="result.listIt"/><!-- SCIPIO: close EntityListIterator -->
            </finally-actions>
        </section>
    </screen>
    
    <screen name="NewPurchaseInvoice">
        <section>
            <actions>
                <set field="titleProperty" value="AccountingCreateNewPurchaseInvoice"/>
                <set field="activeSubMenuItem" value="newInvoice"/><!-- "invoices" -->
                <entity-one entity-name="Invoice" value-field="invoice"/>
            </actions>
            <widgets>
                <decorator-screen name="CommonInvoicesDecorator" location="${parameters.mainDecoratorLocation}">
                    <decorator-section name="body">
                        <screenlet>
                            <include-form name="NewPurchaseInvoice" location="component://accounting/widget/invoice/InvoiceForms.xml"/>
                        </screenlet>
                    </decorator-section>
                </decorator-screen>
            </widgets>
        </section>
    </screen>
    
    <!-- 
    *******************
    * Accounts Receivable
    *******************
     -->
     <screen name="ListARReports">
        <section>
            <actions>
                <set field="activeSubMenuItem" value="arReports"/>
                <set field="titleProperty" value="AccountingArPageTitleListReports"/>
                <set field="invoiceTypeId" value="SALES_INVOICE"/>
                <set field="organizationPartyId" from-field="userPreferences.ORGANIZATION_PARTY" default-value="${defaultOrganizationPartyId}"/>
                <script location="component://accounting/webapp/accounting/WEB-INF/actions/invoice/InvoiceReport.groovy"/>
            </actions>
            <widgets>
                <decorator-screen name="CommonArDecorator" location="${parameters.mainDecoratorLocation}">
                    <decorator-section name="body">
                        <screenlet title="${uiLabelMap.AccountingPastDueInvoices}: (${PastDueInvoicestotalAmount})">
                            <section>
                                <actions>
                                    <set field="invoices" from-field="PastDueInvoices"/>
                                </actions>
                                <widgets>
                                    <include-screen name="ScipioInvoices" location="component://accounting/widget/invoice/InvoiceScreens.xml"/>
                                </widgets>
                            </section>
                        </screenlet>
                        <screenlet title="${uiLabelMap.AccountingInvoicesDueSoon}: (${InvoicesDueSoonTotalAmount})">
                            <section>
                                <actions>
                                    <set field="invoices" from-field="InvoicesDueSoon"/>
                                </actions>
                                <widgets>
                                    <include-screen name="ScipioInvoices"  location="component://accounting/widget/invoice/InvoiceScreens.xml"/>
                                </widgets>
                            </section>
                        </screenlet>
                    </decorator-section>
                </decorator-screen>
            </widgets>
        </section>
    </screen>
    
    <screen name="FindArInvoices">
        <section>
            <actions>
                <set field="activeSubMenuItem" value="findArInvoices"/>
                <set field="titleProperty" value="AccountingFindArInvoices"/>
                <service service-name="performFind" result-map="result">
                    <field-map field-name="inputFields" from-field="parameters"/>
                    <field-map field-name="entityName" value="InvoiceAndType"/>
                    <field-map field-name="orderBy" value="invoiceDate DESC"/>
                </service>
                <set field="invoices" from-field="result.listIt"/>
            </actions>
            <widgets>
                <decorator-screen name="CommonArDecorator" location="${parameters.mainDecoratorLocation}">
                    <decorator-section name="body">
                        <decorator-screen name="FindScreenDecorator" location="component://common/widget/CommonScreens.xml">
                            <decorator-section name="menu-bar">
                                <container style="button-bar">
                                    <link target="newInvoice" text="${uiLabelMap.AccountingCreateNewInvoice}" style="${styles.link_nav} ${styles.action_add}"/>
                                </container>
                            </decorator-section>
                            <decorator-section name="search-options">
                                <include-form name="FindArInvoices" location="component://accounting/widget/invoice/InvoiceForms.xml"/>
                            </decorator-section>
                            <decorator-section name="search-results">
                                <platform-specific>
                                    <html><html-template location="component://accounting/webapp/ar/invoice/ListInvoices.ftl"/></html>
                                </platform-specific>
                            </decorator-section>
                        </decorator-screen>
                    </decorator-section>
                </decorator-screen>
            </widgets>
            <finally-actions>
                <close-object field="result.listIt"/><!-- SCIPIO: close EntityListIterator -->
            </finally-actions>
        </section>
    </screen>

    <screen name="NewSalesInvoice">
        <section>
            <actions>
                <set field="titleProperty" value="AccountingCreateNewSalesInvoice"/>
            </actions>
            <widgets>
                <decorator-screen name="CommonInvoicesDecorator" location="${parameters.mainDecoratorLocation}">
                    <decorator-section name="body">
                        <screenlet>
                            <include-form name="NewSalesInvoice" location="component://accounting/widget/invoice/InvoiceForms.xml"/>
                        </screenlet>
                    </decorator-section>
                </decorator-screen>
            </widgets>
        </section>
    </screen>
    
    <!-- SCIPIO: Form migration -->
    <!-- SCIPIO: Form widget replacement: component://accounting/widget/invoice/InvoiceForms.xml#invoiceHeader 
                                        component://accounting/widget/invoice/InvoiceForms.xml#ListInvoiceStatus
    -->
    <screen name="ScipioInvoiceInfo">
        <section>
            <actions>
                <set field="total" value="${groovy:return(org.ofbiz.accounting.invoice.InvoiceWorker.getInvoiceTotal(invoice));}"/>
                <service service-name="getPartyNameForDate" result-map="partyNameResultFrom">
                    <field-map field-name="partyId" from-field="invoice.partyIdFrom"/>
                    <field-map field-name="compareDate" from-field="invoice.invoiceDate"/>
                    <field-map field-name="lastNameFirst" value="Y"/>
                </service>
                <service service-name="getPartyNameForDate" result-map="partyNameResultTo">
                    <field-map field-name="partyId" from-field="invoice.partyId"/>
                    <field-map field-name="compareDate" from-field="invoice.invoiceDate"/>
                    <field-map field-name="lastNameFirst" value="Y"/>
                </service>
            </actions>
            <widgets>
                <section>
                    <condition>
                        <not>
                            <if-empty field="parameters.invoiceId"/>
                        </not>
                    </condition>
                    <widgets>
                        <screenlet>        
                            <platform-specific>
                                <html><html-template location="component://accounting/webapp/accounting/invoice/ScipioInvoiceInfo.ftl"/></html>
                            </platform-specific>
                        </screenlet>
                    </widgets>
                </section>
            </widgets>
        </section>
    </screen>
    
    <!-- SCIPIO: Form widget replacement: component://accounting/widget/invoice/InvoiceForms.xml#ListInvoiceApplications -->
    <screen name="ScipioInvoiceAppliedPayment">
        <section>
            <condition>
                <not>
                    <if-empty field="invoiceApplications"/>
                </not>
            </condition>
            <actions>
            </actions>
            <widgets>
                <screenlet>
                    <platform-specific>
                        <html><html-template location="component://accounting/webapp/accounting/invoice/ScipioInvoiceAppliedPayment.ftl"/></html>
                    </platform-specific>
                </screenlet>
            </widgets>
        </section>
    </screen>
    
    <!-- SCIPIO: Form widget replacement: component://accounting/widget/invoice/InvoiceForms.xml#invoiceItems -->
    <screen name="ScipioInvoiceItems">
        <section>
            <condition>
                <not>
                    <if-empty field="invItemAndOrdItems"/>
                </not>
            </condition>
            <actions>
            </actions>
            <widgets>
                <screenlet>
                    <platform-specific>
                        <html><html-template location="component://accounting/webapp/accounting/invoice/ScipioInvoiceItems.ftl"/></html>
                    </platform-specific>
                </screenlet>
            </widgets>
        </section>
    </screen>
    
    <!-- SCIPIO: Form widget replacement: component://accounting/widget/ap/InvoiceForms.xml#ListReports
                                        component://accounting/widget/ar/InvoiceForms.xml#ListReports
    -->
    <screen name="ScipioInvoices">
        <section>
            <actions>
                <!-- INTERFACE: expects an "invoices" list in context -->
                
                <set field="organizationPartyId" from-field="organizationPartyId" default-value="${defaultOrganizationPartyId}"/><!--  global="true" -->
            </actions>
            <widgets>
                <screenlet>
                    <platform-specific>
                        <html><html-template location="component://accounting/webapp/accounting/invoice/ScipioInvoices.ftl"/></html>
                    </platform-specific>
                </screenlet>
            </widgets>
        </section>
    </screen>
    
    <!-- SCIPIO: Form widget replacement: component://accounting/widget/invoice/InvoiceForms.xml#ListInvoiceTerms -->
    <screen name="ScipioInvoiceTerms">
        <section>
            <condition>
                <not>
                    <if-empty field="invoiceTerms"/>
                </not>
            </condition>
            <actions>
            </actions>
            <widgets>
                <screenlet>
                    <platform-specific>
                        <html><html-template location="component://accounting/webapp/accounting/invoice/ScipioInvoiceTerms.ftl"/></html>
                    </platform-specific>
                </screenlet>
            </widgets>
        </section>
    </screen>
    
    <!-- SCIPIO: Form widget replacement: component://accounting/widget/invoice/InvoiceForms.xml#ListInvoicePaymentInfo -->
    <screen name="ScipioInvoicePaymentInfo">
        <section>
            <actions>
                <service service-name="getInvoicePaymentInfoList" result-map="result">
                    <field-map field-name="invoiceId" from-field="parameters.invoiceId"/>
                </service>
                <set field="invoicePaymentInfoList" from-field="result.invoicePaymentInfoList" />
            </actions>
            <widgets>
                <section>
                     <condition>
                         <not>
                             <if-empty field="invoicePaymentInfoList"/>
                         </not>
                     </condition>
                     <widgets>
                         <screenlet>
                             <platform-specific>
                                 <html><html-template location="component://accounting/webapp/accounting/invoice/ScipioInvoicePaymentInfo.ftl"/></html>
                             </platform-specific>
                         </screenlet>
                     </widgets>
                </section>
            </widgets>
        </section>
    </screen>
</screens>