svn commit: r699817 - in /ofbiz/trunk/applications/accounting: config/ script/org/ofbiz/accounting/invoice/ servicedef/ src/org/ofbiz/accounting/invoice/ webapp/accounting/WEB-INF/actions/payment/ webapp/accounting/payment/ widget/

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r699817 - in /ofbiz/trunk/applications/accounting: config/ script/org/ofbiz/accounting/invoice/ servicedef/ src/org/ofbiz/accounting/invoice/ webapp/accounting/WEB-INF/actions/payment/ webapp/accounting/payment/ widget/

hansbak-2
Author: hansbak
Date: Sun Sep 28 06:39:56 2008
New Revision: 699817

URL: http://svn.apache.org/viewvc?rev=699817&view=rev
Log:
it is now possible to apply 'home' currency payments to foreign curency invoices, converting the foreign invoice to the 'home' currency in the process and making an entry in the currency exchange table so it is still possble to display the invoice in the customer currency. To make this work, it is however required that the preferred currency of the parties are specified in the party entity. This will not affect the system if the payment and the invoice are in the same currency

Modified:
    ofbiz/trunk/applications/accounting/config/AccountingUiLabels.xml
    ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/invoice/InvoiceServices.xml
    ofbiz/trunk/applications/accounting/servicedef/services_invoice.xml
    ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java
    ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/payment/ListNotAppliedInvoices.groovy
    ofbiz/trunk/applications/accounting/webapp/accounting/payment/PaymentForms.xml
    ofbiz/trunk/applications/accounting/widget/PaymentScreens.xml

Modified: ofbiz/trunk/applications/accounting/config/AccountingUiLabels.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/config/AccountingUiLabels.xml?rev=699817&r1=699816&r2=699817&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/config/AccountingUiLabels.xml (original)
+++ ofbiz/trunk/applications/accounting/config/AccountingUiLabels.xml Sun Sep 28 06:39:56 2008
@@ -3276,7 +3276,7 @@
         <value xml:lang="zh">已付</value>
     </property>
     <property key="AccountingInvoicePaymentCurrencyProblem">
-        <value xml:lang="en">Payment currency [${paymentCurrencyId}] and invoice currency [${invoiceCurrency}] not the same
+        <value xml:lang="en">Payment currency [${paymentCurrency}] and invoice currency [${invoiceCurrency}] not the same
 </value>
         <value xml:lang="es">Moneda de pago [${paymentCurrencyId}] y moneda de factura [${invoiceCurrency}] no son iguales
 </value>

Modified: ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/invoice/InvoiceServices.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/invoice/InvoiceServices.xml?rev=699817&r1=699816&r2=699817&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/invoice/InvoiceServices.xml (original)
+++ ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/invoice/InvoiceServices.xml Sun Sep 28 06:39:56 2008
@@ -506,6 +506,57 @@
         <call-simple-method method-name="copyInvoice"/>
     </simple-method>
 
+    <simple-method method-name="convertInvoiceToOtherCurrency" short-description="service to convert an invoice to another currency having the original currency still there using the exchange rate table.">
+        <entity-one entity-name="Invoice" value-name="invoice"/>
+        <if-empty field="invoice">
+            <add-error><fail-message message="Invoice not found"/></add-error>
+        </if-empty>
+        <entity-one entity-name="Uom" value-name="newCurrencyUom">
+            <field-map field-name="uomId" env-name="parameters.newCurrencyUomId"/>
+        </entity-one>
+        <if-empty field="newCurrencyUom">
+            <add-error><fail-message message="New Currency Code not found"/></add-error>
+        </if-empty>
+        <if-compare-field field="parameters.newCurrencyUomId" operator="equals" to-field="invoice.currencyUomId">
+            <add-error><fail-message message="Invoice already has the requested currency"/></add-error>
+        </if-compare-field>
+        <check-errors/>
+    
+        <get-related value-name="invoice" relation-name="InvoiceItem" list-name="invoiceItems"/>
+        <iterate list-name="invoiceItems" entry-name="invoiceItem">
+             <calculate field-name="invoiceItem.amount" type="Double" decimal-scale="15">
+                <calcop operator="divide">
+                    <calcop operator="get" field-name="invoiceItem.amount"/>
+                    <calcop operator="get" field-name="parameters.exchangeRate"/>
+                </calcop>
+            </calculate>
+            <store-value value-name="invoiceItem"/>
+        </iterate>
+        
+        <entity-one entity-name="UomConversionDated" value-name="uomValue">
+            <field-map field-name="uomId" env-name="parameters.newCurrencyUomId"/>
+            <field-map field-name="uomIdTo" env-name="invoice.currencyUomId"/>
+            <field-map field-name="fromDate" env-name="invoice.invoiceDate"/>
+        </entity-one>
+
+        <make-value entity-name="UomConversionDated" value-name="uomConversionDated"/>
+        <set field="uomConversionDated.uomId" from-field="parameters.newCurrencyUomId"/>        
+        <set field="uomConversionDated.uomIdTo" from-field="invoice.currencyUomId"/>        
+        <set field="uomConversionDated.fromDate" from-field="invoice.invoiceDate"/>  
+        <set field="uomConversionDated.thruDate" from-field="invoice.invoiceDate"/>
+        <set field="uomConversionDated.conversionFactor" from-field="parameters.exchangeRate"/>
+        <if-empty field="uomValue">
+            <create-value value-name="uomConversionDated"/>
+            <else>
+                <store-value value-name="uomConversionDated"/>
+            </else>        
+        </if-empty>        
+        
+        <set field="invoice.currencyUomId" from-field="parameters.newCurrencyUomId"/>
+        <store-value value-name="invoice"/>
+        <field-to-result field-name="parameters.invoiceId" result-name="invoiceId"/>
+    </simple-method>
+
     <!-- ===============subroutine services =================-->
     <simple-method method-name="InvoiceStatusInProgress" short-description="Check if the invoiceStatus is in progress">
         <!-- find the current header record -->

Modified: ofbiz/trunk/applications/accounting/servicedef/services_invoice.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/servicedef/services_invoice.xml?rev=699817&r1=699816&r2=699817&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/servicedef/services_invoice.xml (original)
+++ ofbiz/trunk/applications/accounting/servicedef/services_invoice.xml Sun Sep 28 06:39:56 2008
@@ -274,11 +274,17 @@
         <description>Accounting Invoice Permission Checking Logic</description>
         <implements service="permissionInterface"/>
     </service>
-    <!-- Update InvoiceItemType -->
     <service name="updateInvoiceItemType" engine="simple" default-entity-name="InvoiceItemType"
         location="org/ofbiz/accounting/invoice/InvoiceServices.xml" invoke="updateInvoiceItemType">
         <description>Update Invoice Item Type Record</description>
         <auto-attributes mode="IN" include="pk" optional="false"/>
         <auto-attributes mode="IN" include="nonpk" optional="true"/>
     </service>
+    <service name="convertInvoiceToOtherCurrency" engine="simple"
+        location="org/ofbiz/accounting/invoice/InvoiceServices.xml" invoke="convertInvoiceToOtherCurrency">
+        <description>service to convert an invoice to another currency having the original currency still there using the exchange rate table.</description>
+        <attribute name="invoiceId" mode="INOUT" type="String"/>
+        <attribute name="newCurrencyUomId" mode="IN" type="String"/>
+        <attribute name="exchangeRate" mode="IN" type="Double"/>
+    </service>
 </services>
\ No newline at end of file

Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java?rev=699817&r1=699816&r2=699817&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java (original)
+++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java Sun Sep 28 06:39:56 2008
@@ -2256,7 +2256,9 @@
     private static String successMessage = null;
     public static Map updatePaymentApplicationDefBd(DispatchContext dctx, Map context) {
         GenericDelegator delegator = dctx.getDelegator();
+        LocalDispatcher dispatcher = dctx.getDispatcher();
         Locale locale = (Locale) context.get("locale");
+        GenericValue userLogin = (GenericValue) context.get("userLogin");
 
         if (decimals == -1 || rounding == -1) {
             return ServiceUtil.returnError(UtilProperties.getMessage(resource,"AccountingAritmeticPropertiesNotConfigured",locale));
@@ -2500,6 +2502,38 @@
                     errorMessageList.add(UtilProperties.getMessage(resource,"AccountingInvoiceCancelledCannotApplyTo",UtilMisc.toMap("invoiceId",invoiceId),locale));
                 }
                 
+                // check the currency
+                if (payment.get("currencyUomId") != null && invoice.get("currencyUomId") != null &&
+                        !payment.getString("currencyUomId").equals(invoice.getString("currencyUomId"))) {
+                    Debug.logInfo(UtilProperties.getMessage(resource, "AccountingInvoicePaymentCurrencyProblem",
+                            UtilMisc.toMap("invoiceCurrency", invoice.getString("currencyUomId"), "paymentCurrency", payment.getString("currencyUomId")),locale), module);
+                    Debug.logInfo("will convert invoice currency according original currency amount on payment", module);
+                    
+                    if (payment.get("actualCurrencyAmount") == null || payment.get("actualCurrencyUomId") == null) {
+                        errorMessageList.add("in order to properly convert the Invoice we need the actual currency and actual amount on the payment");
+                    } else {
+                     if (!payment.get("actualCurrencyUomId").equals(invoice.get("currencyUomId"))) {
+                            errorMessageList.add("actual currency on payment not the same as original invoice currency");
+                     } else {
+                     // calculate exchange rate, convert/retrieve invoice
+                     try {
+                     Double exchangeRate = new Double( payment.getDouble("actualCurrencyAmount").doubleValue() / payment.getDouble("amount").doubleValue());
+                     Map inMap = UtilMisc.toMap("userLogin", userLogin, "invoiceId", invoiceId, "newCurrencyUomId", payment.getString("currencyUomId"));
+                     inMap.put("exchangeRate", exchangeRate);
+                     dispatcher.runSync("convertInvoiceToOtherCurrency", inMap);
+                     invoice = delegator.findByPrimaryKey("Invoice", UtilMisc.toMap("invoiceId", invoiceId));
+                            } catch (GenericServiceException se) {
+                                Debug.logError(se, se.getMessage(), module);
+                                return ServiceUtil.returnError(se.getMessage());
+                            } catch (GenericEntityException e) {
+                                ServiceUtil.returnError(e.getMessage());
+                            }
+                     }
+                    }
+                    
+                    
+                }
+                
                 // check if the invoice already covered by payments
                 BigDecimal invoiceTotal = InvoiceWorker.getInvoiceTotalBd(invoice);
                 invoiceApplyAvailable = InvoiceWorker.getInvoiceNotApplied(invoice);
@@ -3082,4 +3116,5 @@
             return ServiceUtil.returnError(ee.getMessage());
         }
     }
+    
 }

Modified: ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/payment/ListNotAppliedInvoices.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/payment/ListNotAppliedInvoices.groovy?rev=699817&r1=699816&r2=699817&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/payment/ListNotAppliedInvoices.groovy (original)
+++ ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/payment/ListNotAppliedInvoices.groovy Sun Sep 28 06:39:56 2008
@@ -33,9 +33,8 @@
 decimals = UtilNumber.getBigDecimalScale("invoice.decimals");
 rounding = UtilNumber.getBigDecimalRoundingMode("invoice.rounding");
 
-// retrieve invoices for the related parties which have not been (fully) applied yet
-List invoices = delegator.findByAnd("Invoice", [partyId : payment.partyIdFrom, partyIdFrom : payment.partyIdTo], ["invoiceDate"]);
-  
+//retrieve invoices for the related parties which have not been (fully) applied yet and which have the same currency.
+List invoices = delegator.findByAnd("Invoice", [partyId : payment.partyIdFrom, partyIdFrom : payment.partyIdTo, currencyUomId : payment.currencyUomId], ["invoiceDate"]);
 if (invoices)    {
     invoicesList = [];  // to pass back to the screeen list of unapplied invoices
     paymentApplied = PaymentWorker.getPaymentAppliedBd(payment);
@@ -65,3 +64,36 @@
     }
     context.invoices = invoicesList;
 }
+
+//retrieve invoices for the related parties which have not been (fully) applied yet and which have another currency
+invoices = delegator.findByAnd("Invoice", [partyId : payment.partyIdFrom, partyIdFrom : payment.partyIdTo], ["invoiceDate"]);
+// remove same currencies
+for (int ind=0; ind < invoices.size(); ind++ ) {
+ if (invoices[ind].currencyUomId.equals(payment.currencyUomId)) {
+ invoices.remove(ind);
+ }
+}
+if (invoices)    {
+    invoicesList = [];  // to pass back to the screeen list of unapplied invoices
+    paymentApplied = PaymentWorker.getPaymentAppliedBd(payment);
+    paymentToApply = payment.getBigDecimal("amount").setScale(decimals,rounding).subtract(paymentApplied);
+    invoices.each { invoice ->
+        invoiceAmount = InvoiceWorker.getInvoiceTotalBd(invoice).setScale(decimals,rounding);
+        invoiceApplied = InvoiceWorker.getInvoiceAppliedBd(invoice).setScale(decimals,rounding);
+        if (!invoiceAmount.equals(invoiceApplied) &&
+                !invoice.statusId.equals("INVOICE_CANCELLED") &&
+                !invoice.statusId.equals("INVOICE_IN_PROCESS")) {
+            // put in the map
+            invoiceToApply = invoiceAmount.subtract(invoiceApplied);
+            invoiceMap = [:];
+            invoiceMap.invoiceId = invoice.invoiceId;
+            invoiceMap.currencyUomId = invoice.currencyUomId;
+            invoiceMap.amount = invoiceAmount;
+            invoiceMap.description = invoice.description;
+            invoiceMap.invoiceDate = invoice.invoiceDate.toString().substring(0,10); // display only YYYY-MM-DD
+            invoiceMap.amountApplied = invoiceApplied;
+            invoicesList.add(invoiceMap);
+        }
+    }
+    context.invoicesOtherCurrency = invoicesList;
+}

Modified: ofbiz/trunk/applications/accounting/webapp/accounting/payment/PaymentForms.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/webapp/accounting/payment/PaymentForms.xml?rev=699817&r1=699816&r2=699817&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/webapp/accounting/payment/PaymentForms.xml (original)
+++ ofbiz/trunk/applications/accounting/webapp/accounting/payment/PaymentForms.xml Sun Sep 28 06:39:56 2008
@@ -321,6 +321,21 @@
         </field>
     </form>
 
+    <form name="listInvoicesNotAppliedOtherCurrency" type="list" list-name="invoicesOtherCurrency" target="updatePaymentApplication" title=""
+        odd-row-style="alternate-row" default-table-style="basic-table hover-bar">
+        <field name="paymentId"><hidden/></field>
+        <field name="invoiceId" widget-style="buttontext"><hyperlink target="invoiceOverview?invoiceId=${invoiceId}" description="${invoiceId}"/></field>
+        <field name="description"><display/></field>
+        <field name="invoiceDate"><display/></field>
+        <field name="amount"><display type="currency" currency="${currencyUomId}"/></field>
+        <field name="amountApplied" parameter-name="dummy"><display  type="currency" currency="${currencyUomId}"/></field>
+        <field name="invoiceProcessing" use-when="&quot;${uiConfigMap.invoiceProcessing}&quot;.equals(&quot;Y&quot;)"><check/></field>
+        <field name="invoiceProcessing" use-when="&quot;${uiConfigMap.invoiceProcessing}&quot;.equals(&quot;N&quot;)"><check/></field>
+        <field name="applyButton" widget-style="smallSubmit" title="Convert Invoice to Payment currency and save rate">
+            <submit button-type="button"/>
+        </field>
+    </form>
+
     <form name="listPaymentsNotApplied" type="list" list-name="payments" target="updatePaymentApplication" title=""
         odd-row-style="alternate-row" default-table-style="basic-table hover-bar">
         <field name="paymentId"><hidden/></field>

Modified: ofbiz/trunk/applications/accounting/widget/PaymentScreens.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/widget/PaymentScreens.xml?rev=699817&r1=699816&r2=699817&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/widget/PaymentScreens.xml (original)
+++ ofbiz/trunk/applications/accounting/widget/PaymentScreens.xml Sun Sep 28 06:39:56 2008
@@ -197,56 +197,53 @@
                                 <container><label style="h3" text="${uiLabelMap.AccountingNoPaymentsApplicationsfound}"></label></container>
                             </widgets>
                             <fail-widgets>
-                                <container style="screenlet">
-                                    <container style="screenlet-title-bar">
-                                        <container style="h3">
-                                            <label text="${uiLabelMap.AccountingPayment} ${uiLabelMap.AccountingApplications}"/>
-                                        </container>
-                                    </container>
-                                    <container style="screenlet-body">
-                                        <section>
-                                            <condition>
-                                                <not><if-empty field-name="paymentApplicationsInv"/></not>
-                                            </condition>
-                                            <widgets>
-                                                <include-form name="editPaymentApplicationsInv" location="component://accounting/webapp/accounting/payment/PaymentForms.xml"/>
-                                            </widgets>
-                                        </section>
-                                    </container>
-                                </container>
-                                <container style="screenlet">
-                                    <container style="screenlet-title-bar">
-                                        <container style="h3">
-                                            <label text="11${uiLabelMap.CommonAmount} ${uiLabelMap.CommonTotal} ${payment.amount?currency(${payment.currencyUomId})} ${uiLabelMap.AccountingAmountNotApplied} ${notAppliedAmount?currency(${payment.currencyUomId})}"/>
-                                        </container>
-                                    </container>
-                                    <container style="screenlet-body">
-                                        <section>
-                                            <condition>
-                                                <not><if-empty field-name="paymentApplicationsPay"/></not>
-                                            </condition>
-                                            <widgets>
-                                                <include-form name="editPaymentApplicationsPay" location="component://accounting/webapp/accounting/payment/PaymentForms.xml"/>
-                                            </widgets>
-                                        </section>
-                                        <section>
-                                            <condition>
-                                                <not><if-empty field-name="paymentApplicationsBil"/></not>
-                                            </condition>
-                                            <widgets>
-                                                <include-form name="editPaymentApplicationsBil" location="component://accounting/webapp/accounting/payment/PaymentForms.xml"/>
-                                            </widgets>
-                                        </section>
-                                        <section>
-                                            <condition>
-                                                <not><if-empty field-name="paymentApplicationsTax"/></not>
-                                            </condition>
-                                            <widgets>
-                                                <include-form name="editPaymentApplicationsTax" location="component://accounting/webapp/accounting/payment/PaymentForms.xml"/>
-                                            </widgets>
-                                        </section>
-                                    </container>
-                                </container>
+                                 <section>
+                                    <condition>
+                                        <not><if-empty field-name="paymentApplicationsInv"/></not>
+                                    </condition>
+                                    <widgets>
+                                        <screenlet title="${uiLabelMap.AccountingPayment} ${uiLabelMap.AccountingApplications}">
+                                            <include-form name="editPaymentApplicationsInv" location="component://accounting/webapp/accounting/payment/PaymentForms.xml"/>
+                                        </screenlet>
+                                    </widgets>
+                                </section>
+                                <section>
+                                    <condition>
+                                        <or>
+                                            <not><if-empty field-name="paymentApplicationsPay"/></not>
+                                            <not><if-empty field-name="paymentApplicationsBil"/></not>
+                                            <not><if-empty field-name="paymentApplicationsTax"/></not>
+                                        </or>
+                                    </condition>
+                                    <widgets>
+                                        <screenlet title="${uiLabelMap.CommonAmount} ${uiLabelMap.CommonTotal} ${payment.amount?currency(${payment.currencyUomId})} ${uiLabelMap.AccountingAmountNotApplied} ${notAppliedAmount?currency(${payment.currencyUomId})}">
+                                        <section>
+                                            <condition>
+                                                <not><if-empty field-name="paymentApplicationsPay"/></not>
+                                            </condition>
+                                            <widgets>
+                                                <include-form name="editPaymentApplicationsPay" location="component://accounting/webapp/accounting/payment/PaymentForms.xml"/>
+                                            </widgets>
+                                        </section>
+                                        <section>
+                                            <condition>
+                                                <not><if-empty field-name="paymentApplicationsBil"/></not>
+                                            </condition>
+                                            <widgets>
+                                                <include-form name="editPaymentApplicationsBil" location="component://accounting/webapp/accounting/payment/PaymentForms.xml"/>
+                                            </widgets>
+                                        </section>
+                                        <section>
+                                            <condition>
+                                                <not><if-empty field-name="paymentApplicationsTax"/></not>
+                                            </condition>
+                                            <widgets>
+                                                <include-form name="editPaymentApplicationsTax" location="component://accounting/webapp/accounting/payment/PaymentForms.xml"/>
+                                            </widgets>
+                                        </section>
+                                        </screenlet>
+                                    </widgets>
+                                </section>
                             </fail-widgets>
                         </section>
                         <section>
@@ -259,24 +256,30 @@
                                         <not><if-empty field-name="invoices"/></not>
                                     </condition>
                                     <widgets>
-                                        <container style="screenlet">
-                                            <container style="screenlet-title-bar">
-                                                <container style="h3">
-                                                    <label text="${uiLabelMap.AccountingListInvoicesNotYetApplied}"/>
-                                                </container>
+                                        <screenlet title="${uiLabelMap.AccountingListInvoicesNotYetApplied}">
+                                            <container>
+                                                <label style="h2" text="${uiLabelMap.CommonFrom} ${partyNameViewTo.groupName}${partyNameViewTo.lastName},${partyNameViewTo.firstName} ${partyNameViewTo.middleName}[${payment.partyIdTo}]"/>
+                                                <label style="h2" text="${uiLabelMap.CommonTo} ${partyNameViewFrom.groupName}${partyNameViewFrom.lastName},${partyNameViewFrom.firstName} ${partyNameViewFrom.middleName} [${payment.partyIdFrom}]"/>
                                             </container>
-                                            <container style="screenlet-body">
-                                                <section>
-                                                    <widgets>    
-                                                        <container>
-                                                            <label style="h2" text="${uiLabelMap.CommonFrom} ${partyNameViewTo.groupName}${partyNameViewTo.lastName},${partyNameViewTo.firstName} ${partyNameViewTo.middleName}[${payment.partyIdTo}]"/>
-                                                            <label style="h2" text="${uiLabelMap.CommonTo} ${partyNameViewFrom.groupName}${partyNameViewFrom.lastName},${partyNameViewFrom.firstName} ${partyNameViewFrom.middleName} [${payment.partyIdFrom}]"/>
-                                                        </container>
-                                                        <include-form name="listInvoicesNotApplied" location="component://accounting/webapp/accounting/payment/PaymentForms.xml"/>
-                                                    </widgets>
-                                                </section>
+                                            <include-form name="listInvoicesNotApplied" location="component://accounting/webapp/accounting/payment/PaymentForms.xml"/>
+                                        </screenlet>
+                                    </widgets>
+                                </section>
+                                <section>
+                                    <condition>
+                                        <not><if-empty field-name="invoicesOtherCurrency"/></not>
+                                    </condition>
+                                    <widgets>
+                                        <screenlet title="${uiLabelMap.AccountingListInvoicesNotYetApplied}">
+                                            <container>
+                                                <label style="h1" text="Othercurrency invoices"/>
                                             </container>
-                                        </container>
+                                            <container>
+                                                <label style="h2" text="${uiLabelMap.CommonFrom} ${partyNameViewTo.groupName}${partyNameViewTo.lastName},${partyNameViewTo.firstName} ${partyNameViewTo.middleName}[${payment.partyIdTo}]"/>
+                                                <label style="h2" text="${uiLabelMap.CommonTo} ${partyNameViewFrom.groupName}${partyNameViewFrom.lastName},${partyNameViewFrom.firstName} ${partyNameViewFrom.middleName} [${payment.partyIdFrom}]"/>
+                                            </container>
+                                            <include-form name="listInvoicesNotAppliedOtherCurrency" location="component://accounting/webapp/accounting/payment/PaymentForms.xml"/>
+                                        </screenlet>
                                     </widgets>
                                 </section>
                                 <section>
@@ -284,42 +287,18 @@
                                         <not><if-empty field-name="payments"/></not>
                                     </condition>
                                     <widgets>
-                                        <container style="screenlet">
-                                            <container style="screenlet-title-bar">
-                                                <container style="h3">
-                                                    <label text="${uiLabelMap.AccountingListPaymentsNotYetApplied}"/>
-                                                </container>
-                                            </container>
-                                            <container style="screenlet-body">
-                                                <section>
-                                                    <widgets>    
-                                                        <container>
-                                                            <label style="h2" text="${uiLabelMap.CommonFrom}: ${partyNameViewTo.groupName}${partyNameViewTo.lastName},${partyNameViewTo.firstName} ${partyNameViewTo.middleName}[${payment.partyIdTo}]"/>
-                                                            <label style="h2" text="${uiLabelMap.CommonTo}: ${partyNameViewFrom.groupName}${partyNameViewFrom.lastName},${partyNameViewFrom.firstName} ${partyNameViewFrom.middleName} [${payment.partyIdFrom}]"/>
-                                                        </container>
-                                                        <include-form name="listPaymentsNotApplied" location="component://accounting/webapp/accounting/payment/PaymentForms.xml"/>
-                                                    </widgets>
-                                                </section>
+                                        <screenlet title="${uiLabelMap.AccountingListPaymentsNotYetApplied}">
+                                            <container>
+                                                <label style="h2" text="${uiLabelMap.CommonFrom}: ${partyNameViewTo.groupName}${partyNameViewTo.lastName},${partyNameViewTo.firstName} ${partyNameViewTo.middleName}[${payment.partyIdTo}]"/>
+                                                <label style="h2" text="${uiLabelMap.CommonTo}: ${partyNameViewFrom.groupName}${partyNameViewFrom.lastName},${partyNameViewFrom.firstName} ${partyNameViewFrom.middleName} [${payment.partyIdFrom}]"/>
                                             </container>
-                                        </container>
+                                            <include-form name="listPaymentsNotApplied" location="component://accounting/webapp/accounting/payment/PaymentForms.xml"/>
+                                        </screenlet>
                                     </widgets>
                                 </section>
-                                <container style="screenlet">
-                                    <container style="screenlet-title-bar">
-                                        <container style="h3">
-                                            <label text="${uiLabelMap.AccountingApplyPaymentoTo}"/>
-                                        </container>
-                                    </container>
-                                    <container style="screenlet-body">
-                                        <section>
-                                            <widgets>    
-                                                <container>
-                                                    <include-form name="addPaymentApplication" location="component://accounting/webapp/accounting/payment/PaymentForms.xml"/>
-                                                </container>
-                                            </widgets>
-                                        </section>
-                                    </container>
-                                </container>
+                                <screenlet title="${uiLabelMap.AccountingApplyPaymentoTo}">
+                                   <include-form name="addPaymentApplication" location="component://accounting/webapp/accounting/payment/PaymentForms.xml"/>
+                                </screenlet>
                             </widgets>
                         </section>
                     </decorator-section>