You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ha...@apache.org on 2008/09/25 06:06:09 UTC

svn commit: r698810 - in /ofbiz/trunk/applications/party: config/PartyUiLabels.xml webapp/partymgr/WEB-INF/actions/party/PartyFinancailHistory.groovy webapp/partymgr/party/PartyForms.xml widget/partymgr/PartyScreens.xml

Author: hansbak
Date: Wed Sep 24 21:06:09 2008
New Revision: 698810

URL: http://svn.apache.org/viewvc?rev=698810&view=rev
Log:
improved finanacial overview, replaced header and improoved groovy file....not perfect yet however improoved a lot..

Modified:
    ofbiz/trunk/applications/party/config/PartyUiLabels.xml
    ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/party/PartyFinancailHistory.groovy
    ofbiz/trunk/applications/party/webapp/partymgr/party/PartyForms.xml
    ofbiz/trunk/applications/party/widget/partymgr/PartyScreens.xml

Modified: ofbiz/trunk/applications/party/config/PartyUiLabels.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/config/PartyUiLabels.xml?rev=698810&r1=698809&r2=698810&view=diff
==============================================================================
--- ofbiz/trunk/applications/party/config/PartyUiLabels.xml (original)
+++ ofbiz/trunk/applications/party/config/PartyUiLabels.xml Wed Sep 24 21:06:09 2008
@@ -180,6 +180,9 @@
         <value xml:lang="en">Add Related Contact</value>
         <value xml:lang="fr">Ajouter un contact associé</value>
     </property>
+    <property key="AppliedPayments">
+        <value xml:lang="en">Applied payments to payments</value>
+    </property>
     <property key="Description">
         <value xml:lang="de">Beschreibung</value>
         <value xml:lang="en">Description</value>
@@ -1249,6 +1252,15 @@
         <value xml:lang="th">ปีกับผู้ว่าจ้าง</value>
         <value xml:lang="zh">年为雇主</value>
     </property>
+    <property key="InvoicesNotApplied">
+        <value xml:lang="en">Invoices not yet (fully) applied</value>
+    </property>
+    <property key="InvoicesOtherParties">
+        <value xml:lang="en">Invoices of other parties paid by payments from</value>
+    </property>
+    <property key="InvoicesPayments">
+        <value xml:lang="en">Invoices Payments</value>
+    </property>
     <property key="IsA"><!-- Peter 'is a' employee of company B -->
         <value xml:lang="en">is A</value>
         <value xml:lang="fr">est un</value>
@@ -3806,6 +3818,9 @@
         <value xml:lang="th">ประเภทผลที่ได้</value>
         <value xml:lang="zh">事件类型</value>
     </property>
+    <property key="PartyFinancialSummary">
+        <value xml:lang="en">Totals for Company:</value>
+    </property>
     <property key="PartyFindCommunicationEvents">
         <value xml:lang="de">Suche Kommunikationsereignis</value>
         <value xml:lang="en">Find Communication Events</value>
@@ -7448,6 +7463,9 @@
         <value xml:lang="pt_PT">Erro de Segurança: para correr a função de Comunicação de Remoção de Acontecimentos é necessário obter o PARTYMGR_DELETE ou permissão de PARTYMGR_ADMIN</value>
         <value xml:lang="th">Security Error: ในการย้ายสถานะผลการติดต่อ คุณต้องได้รับอนุญาตจาก  PARTYMGR_DELETE หรือ PARTYMGR_ADMIN ก่อน</value>
     </property>
+    <property key="PaymentsNotApplied">
+        <value xml:lang="en">Payments not yet (fully) applied</value>
+    </property>
     <property key="commeventservices.communication_event_from_contact_mech_must_be_email">
         <value xml:lang="de">FEHLER: Kommunikationsereignis muss ein "Kontaktmechanismus von" besitzen das ein E-Mail als Kommunikationereignis ID ist</value>
         <value xml:lang="en">ERROR: Communication event must have a from contact mech that is an email for comm event Id</value>

Modified: ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/party/PartyFinancailHistory.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/party/PartyFinancailHistory.groovy?rev=698810&r1=698809&r2=698810&view=diff
==============================================================================
--- ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/party/PartyFinancailHistory.groovy (original)
+++ ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/party/PartyFinancailHistory.groovy Wed Sep 24 21:06:09 2008
@@ -1,29 +1,21 @@
 /*
- *  Copyright (c) 2001-2005 The Open For Business Project - www.ofbiz.org
- *
- *  Permission is hereby granted, free of charge, to any person obtaining a
- *  copy of this software and associated documentation files (the "Software"),
- *  to deal in the Software without restriction, including without limitation
- *  the rights to use, copy, modify, merge, publish, distribute, sublicense,
- *  and/or sell copies of the Software, and to permit persons to whom the
- *  Software is furnished to do so, subject to the following conditions:
- *
- *  The above copyright notice and this permission notice shall be included
- *  in all copies or substantial portions of the Software.
- *
- *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- *  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- *  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
- *  CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
- *  OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
- *  THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- *@author     Hans Bakker (h.bakker@antwebsystems.com)
- *@version    $Rev$
- *@since      3.0
+ * 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.
  */
-
 import java.util.*;
 import java.math.*;
 import java.sql.Timestamp;
@@ -35,24 +27,24 @@
 import org.ofbiz.accounting.invoice.*;
 import org.ofbiz.accounting.payment.*;
 
-delegator = parameters.get("delegator");
-organizationPartyId = parameters.get("organizationPartyId");
-partyId = parameters.get("partyId");
+delegator = parameters.delegator;
+organizationPartyId = parameters.organizationPartyId;
+partyId = parameters.partyId;
 if (partyId == null && organizationPartyId == null) return;
 List historyList = new LinkedList();
 
 //get payment totals
 BigDecimal totalPaymentsIn = new BigDecimal("0.00").setScale(2,BigDecimal.ROUND_HALF_UP);
 BigDecimal totalPaymentsOut = new BigDecimal("0.00").setScale(2,BigDecimal.ROUND_HALF_UP);
-tpayments = delegator.findByOr("Payment",[partyIdTo:partyId,partyIdFrom:partyId]);
+tpayments = delegator.findByOr("Payment",["partyIdTo" : partyId,"partyIdFrom" : partyId]);
 Iterator pl = tpayments.iterator();
 while (pl.hasNext()) {
-	payment = pl.next();
-	if (payment.getString("statusId").equals("PMNT_CANCELLED")) continue;
-	if (payment.getString("partyIdTo").equals(organizationPartyId))
-		totalPaymentsIn = totalPaymentsIn.add(payment.getBigDecimal("amount")).setScale(2,BigDecimal.ROUND_HALF_UP);
-	else
-		totalPaymentsOut = totalPaymentsOut.add(payment.getBigDecimal("amount")).setScale(2,BigDecimal.ROUND_HALF_UP);
+    payment = (GenericValue) pl.next();
+    if (payment.statusId.equals("PMNT_CANCELLED")) continue;
+    if (payment.partyIdTo.equals(organizationPartyId))
+        totalPaymentsIn = totalPaymentsIn.add(payment.getBigDecimal("amount")).setScale(2,BigDecimal.ROUND_HALF_UP);
+    else
+        totalPaymentsOut = totalPaymentsOut.add(payment.getBigDecimal("amount")).setScale(2,BigDecimal.ROUND_HALF_UP);
 }
 
 // totals
@@ -63,250 +55,241 @@
 
 // payment and invoices list which will be updated with the amount applied
 // to see what is left over...
-List invoices = delegator.findByOr("Invoice",
-	UtilMisc.toMap("partyId",partyId,"partyIdFrom",partyId),
-	UtilMisc.toList("invoiceDate"));
-List payments = delegator.findByOr("Payment",
-	UtilMisc.toMap("partyIdTo",partyId,"partyIdFrom",partyId),
-	UtilMisc.toList("effectiveDate"));
-	
+List invoices = delegator.findByOr("Invoice",["partyId" : partyId , "partyIdFrom" : partyId] , ["invoiceDate"]);
+List payments = delegator.findByOr("Payment",["partyIdTo" : partyId , "partyIdFrom" : partyId] , ["effectiveDate"]);
+    
 List notAppliedInvoices = new LinkedList(); // to store the not fully applied invoices
-	
-// start reeading from the invoices list
+    
+// start reading from the invoices list
 if (invoices != null && invoices.size() > 0) {
-	Iterator inv = invoices.iterator();
-	while (inv.hasNext())	{
-		invoice = inv.next();
-		if (invoice.getString("statusId").equals("INVOICE_CANCELLED")) continue;
-		BigDecimal invoiceAmount = InvoiceWorker.getInvoiceTotalBd(invoice).setScale(2,BigDecimal.ROUND_HALF_UP);
-		invoiceApplied = InvoiceWorker.getInvoiceAppliedBd(invoice).setScale(2,BigDecimal.ROUND_HALF_UP);
-/*		if (invoice.getString("partyId").equals(organizationPartyId)) { //negate for outgoing payments
-			invoiceAmount = invoiceAmount.multiply(new BigDecimal("-1"));
-			invoiceApplied = invoiceApplied.multiply(new BigDecimal("-1"));
-		}
-*/		if (invoice.getString("invoiceTypeId").equals("PURCHASE_INVOICE")) totalPurchaseInvoice = totalPurchaseInvoice.add(invoiceAmount);
-		if (invoice.getString("invoiceTypeId").equals("SALES_INVOICE")) totalSalesInvoice = totalSalesInvoice.add(invoiceAmount);
-		totalInvoiceApplied = totalInvoiceApplied.add(invoiceApplied);
-//		Debug.logInfo("Invoice type: "+ invoice.getString("invoiceTypeId") + "amount: " + invoiceAmount + " applied: " + invoiceApplied,"??");
-		if (!invoiceAmount.equals(invoiceApplied))	{
-			Map notAppliedInvoice = UtilMisc.toMap(
-				"invoiceId",invoice.getString("invoiceId"),
-				"invoiceTypeId", invoice.getString("invoiceTypeId").substring(0,1), 
-				"invoiceDate", invoice.getString("invoiceDate").substring(0,10),
-				"invoiceAmount", invoiceAmount.toString(),
-				"invoiceNotApplied", invoiceAmount.subtract(invoiceApplied).toString());
-				notAppliedInvoices.add(notAppliedInvoice);
-				totalInvoiceNotApplied = totalInvoiceNotApplied.add(invoiceAmount).subtract(invoiceApplied);
-		}
-		Map historyItem = UtilMisc.toMap(
-			"invoiceId",invoice.getString("invoiceId"),
-			"invoiceTypeId", invoice.getString("invoiceTypeId").substring(0,1), 
-			"invoiceDate", invoice.getString("invoiceDate").substring(0,10),
-			"invoiceAmount", invoiceAmount.toString(),
-			"totInvoiceApplied", invoiceApplied.toString()
-			);
-			
-		// check for applications
-		List applications = invoice.getRelated("PaymentApplication",null,UtilMisc.toList("paymentId"));
-		if (applications != null && applications.size() > 0) {
-			Iterator appl = applications.iterator();
-			oldPaymentId = new String(" ");
-			BigDecimal applied = new BigDecimal("0");
-			boolean first = true;
-			while (appl.hasNext())	{	// read the applications for this invoice
-				application = appl.next();
-				paymentId = application.getString("paymentId");
-
-				//reduce the payment amount in the payment list
-				pl = payments.iterator();
-				while (pl.hasNext()) {
-					payment = pl.next();
-					if (paymentId.equals(payment.getString("paymentId"))) {
-						plInd = payments.indexOf(payment);
-						payment.put("amount",
-								payment.getBigDecimal("amount").
-								subtract(application.getBigDecimal("amountApplied")).doubleValue());
-						payments.remove(plInd);
-						payments.add(plInd,payment);
-						break;
-					}
-				}
-				
-				// check if the payment number has changed, then we have to output a line....
-				if (!first && !paymentId.equals(oldPaymentId)) { // if the payment number has changed, but not the first
-					historyItem.put("applied", applied.toString());
-					historyItem.put("paymentId", oldPaymentId);
-					payment = delegator.findByPrimaryKey("Payment",UtilMisc.toMap("paymentId",oldPaymentId));
-					BigDecimal amount = payment.getBigDecimal("amount").setScale(2,BigDecimal.ROUND_HALF_UP);
-//					if (payment.getString("partyIdFrom").equals(organizationPartyId)) amount = amount.multiply(new BigDecimal("-1"));
-					historyItem.put("amount",amount.toString());
-					historyItem.put("effectiveDate",payment.getString("effectiveDate").substring(0,10));
-					historyList.add(historyItem);
-					historyItem = new HashMap();
-					applied = new BigDecimal("0");
-				}
-				applied = applied.add(application.getBigDecimal("amountApplied")).setScale(2,BigDecimal.ROUND_HALF_UP);
-				oldPaymentId = paymentId;
-				first = false;
-			}
-			if (!applied.equals("0")) {
-				historyItem.put("applied", applied.toString());
-				historyItem.put("paymentId", oldPaymentId);
-				payment = delegator.findByPrimaryKey("Payment",UtilMisc.toMap("paymentId",oldPaymentId));
-				if (payment != null) {
-					BigDecimal amount = payment.getBigDecimal("amount").setScale(2,BigDecimal.ROUND_HALF_UP);
-//					if (payment.getString("partyIdFrom").equals(organizationPartyId))	amount = amount.multiply(new BigDecimal("-1"));
-					historyItem.put("amount",amount.toString());
-					historyItem.put("effectiveDate",payment.getString("effectiveDate").substring(0,10));
-					historyList.add(historyItem);
-				}
-			}
-		}
-	}
-	context.put("historyListInvoices",historyList);
+    Iterator inv = invoices.iterator();
+    while (inv.hasNext())   {
+        invoice = (GenericValue) inv.next();
+        if (invoice.statusId.equals("INVOICE_CANCELLED")) continue;
+        BigDecimal invoiceAmount = InvoiceWorker.getInvoiceTotalBd(invoice).setScale(2,BigDecimal.ROUND_HALF_UP);
+        invoiceApplied = InvoiceWorker.getInvoiceAppliedBd(invoice).setScale(2,BigDecimal.ROUND_HALF_UP);
+/*      if (invoice.getString("partyId").equals(organizationPartyId)) { //negate for outgoing payments
+            invoiceAmount = invoiceAmount.multiply(new BigDecimal("-1"));
+            invoiceApplied = invoiceApplied.multiply(new BigDecimal("-1"));
+        }
+*/      if (invoice.invoiceTypeId.equals("PURCHASE_INVOICE")) totalPurchaseInvoice = totalPurchaseInvoice.add(invoiceAmount);
+        if (invoice.invoiceTypeId.equals("SALES_INVOICE")) totalSalesInvoice = totalSalesInvoice.add(invoiceAmount);
+        totalInvoiceApplied = totalInvoiceApplied.add(invoiceApplied);
+//      Debug.logInfo("Invoice type: "+ invoice.getString("invoiceTypeId") + "amount: " + invoiceAmount + " applied: " + invoiceApplied,"??");
+        if (!invoiceAmount.equals(invoiceApplied))  {
+            Map notAppliedInvoice = ["invoiceId" : invoice.invoiceId,
+                                     "invoiceTypeId" : invoice.invoiceTypeId.substring(0,1), 
+                                     "invoiceDate" : invoice.invoiceDate.toString().substring(0,10),
+                                     "invoiceAmount" : invoiceAmount.toString(),
+                                     "invoiceNotApplied" : invoiceAmount.subtract(invoiceApplied).toString()];
+                notAppliedInvoices.add(notAppliedInvoice);
+                totalInvoiceNotApplied = totalInvoiceNotApplied.add(invoiceAmount).subtract(invoiceApplied);
+        }
+        Map historyItem = ["invoiceId" : invoice.invoiceId,
+                           "invoiceTypeId" : invoice.invoiceTypeId.substring(0,1), 
+                           "invoiceDate" : invoice.invoiceDate.toString().substring(0,10),
+                           "invoiceAmount" : invoiceAmount.toString(),
+                           "totInvoiceApplied" : invoiceApplied.toString()
+            ];
+        // check for applications
+        List applications = invoice.getRelated("PaymentApplication",null,["paymentId"]);
+        if (applications != null && applications.size() > 0) {
+            Iterator appl = applications.iterator();
+            oldPaymentId = new String(" ");
+            BigDecimal applied = new BigDecimal("0");
+            boolean first = true;
+            while (appl.hasNext())  {   // read the applications for this invoice
+                application = (GenericValue) appl.next();
+                paymentId = application.paymentId;
+
+                //reduce the payment amount in the payment list
+                pl = payments.iterator();
+                while (pl.hasNext()) {
+                    payment = (GenericValue) pl.next();
+                    if (paymentId.equals(payment.paymentId)) {
+                        plInd = payments.indexOf(payment);
+                        payment.amount = payment.getBigDecimal("amount").subtract(application.getBigDecimal("amountApplied")).doubleValue();
+                        payments.remove(plInd);
+                        payments.add(plInd,payment);
+                        break;
+                    }
+                }
+                
+                // check if the payment number has changed, then we have to output a line....
+                if (!first && !paymentId.equals(oldPaymentId)) { // if the payment number has changed, but not the first
+                    payment = delegator.findByPrimaryKey("Payment",["paymentId" : oldPaymentId]);
+                    BigDecimal amount = payment.getBigDecimal("amount").setScale(2,BigDecimal.ROUND_HALF_UP);
+//                  if (payment.getString("partyIdFrom").equals(organizationPartyId)) amount = amount.multiply(new BigDecimal("-1"));
+                    historyItem = ["applied" : applied.toString(),
+                                   "paymentId" : oldPaymentId,
+                                   "amount" : amount.toString(),
+                                   "effectiveDate" : payment.effectiveDate.toString().substring(0,10)];  
+                    historyList.add(historyItem);
+                    historyItem = new HashMap();
+                    applied = new BigDecimal("0");
+                }
+                applied = applied.add(application.getBigDecimal("amountApplied")).setScale(2,BigDecimal.ROUND_HALF_UP);
+                oldPaymentId = paymentId;
+                first = false;
+            }
+            if (!applied.equals("0")) {
+                payment = delegator.findByPrimaryKey("Payment",["paymentId" : oldPaymentId]);
+                if (payment != null) {
+                    BigDecimal amount = payment.getBigDecimal("amount").setScale(2,BigDecimal.ROUND_HALF_UP);
+//                  if (payment.getString("partyIdFrom").equals(organizationPartyId))   amount = amount.multiply(new BigDecimal("-1"));
+                    historyItem = ["invoiceId" : invoice.invoiceId,
+                                   "invoiceTypeId" : invoice.invoiceTypeId.substring(0,1),
+                                   "invoiceDate" : invoice.invoiceDate.toString().substring(0,10),
+                                   "invoiceAmount" : invoiceAmount.toString(),
+                                   "totInvoiceApplied" : invoiceApplied.toString(),
+                                   "applied" : applied.toString(),
+                                   "paymentId" : oldPaymentId,
+                                   "amount" : amount.toString(),
+                                   "effectiveDate" : payment.effectiveDate.toString().substring(0,10)];
+                    historyList.add(historyItem);
+                }
+            }
+        }
+    }
+    context.historyListInvoices = historyList;
 }
 
 // totals
 BigDecimal totalPaymentApplied = new BigDecimal("0.00").setScale(2,BigDecimal.ROUND_HALF_UP);
 // list of payments where payments are applied
 historyList = new LinkedList();
-if (payments != null && payments.size() > 0) {
-	pay = payments.iterator();
-	while (pay.hasNext())	{
-		payment = pay.next();
-		if (payment.getString("statusId").equals("PMNT_CANCELLED")) continue;
-		List applications = payment.getRelated("ToPaymentApplication",null,UtilMisc.toList("paymentId"));
-		if (applications == null || applications.size() == 0 ) continue; // none found				
-		Map historyItem = UtilMisc.toMap("paymentId",payment.getString("paymentId"),"effectiveDate",payment.getString("effectiveDate").substring(0,10));
-		BigDecimal amount = payment.getBigDecimal("amount").setScale(2,BigDecimal.ROUND_HALF_UP);
-//		if (payment.getString("partyIdFrom").equals(organizationPartyId)) amount = amount.multiply(new BigDecimal("-1"));
-		historyItem.put("amount",amount.toString());
-		ap = applications.iterator();
-		while (ap.hasNext())	{
-			GenericValue application = ap.next();
-			historyItem.put("toPaymentId",application.getString("paymentId"));
-			historyItem.put("applied",application.getString("amountApplied"));
-			toPayment = application.getRelatedOne("Payment");
-			historyItem.put("toEffectiveDate",toPayment.getString("effectiveDate").substring(0,10));
-			toAmount = toPayment.getBigDecimal("amount").setScale(2,BigDecimal.ROUND_HALF_UP);
-//			if (toPayment.getString("partyIdFrom").equals(organizationPartyId)) toAmount = toAmount.multiply(new BigDecimal("-1"));
-			historyItem.put("toAmount",toAmount.toString());
-			historyList.add(historyItem);
-			
-			//reduce the payment amount in the payment list
-			pl = payments.iterator();
-			while (pl.hasNext()) {
-				payment = pl.next();
-				// reduce paymentId
-				if (application.getString("paymentId").equals(payment.getString("paymentId"))) {
-					plInd = payments.indexOf(payment);
-					payment.put("amount",
-							payment.getBigDecimal("amount").
-							subtract(application.getBigDecimal("amountApplied")).doubleValue());
-					payments.remove(plInd);
-					payments.add(plInd,payment);
-					totalPaymentApplied = totalPaymentApplied.add(application.getBigDecimal("amountApplied"));
-				}
-				// reduce toPaymentId
-				if (application.getString("toPaymentId").equals(payment.getString("paymentId"))) {
-					plInd = payments.indexOf(payment);
-					payment.put("amount",
-							payment.getBigDecimal("amount").
-							subtract(application.getBigDecimal("amountApplied")).doubleValue());
-					payments.remove(plInd);
-					payments.add(plInd,payment);
-					totalPaymentApplied = totalPaymentApplied.add(application.getBigDecimal("amountApplied"));
-				}
-			}
-		}
-	}
-	context.put("historyListPayments",historyList);
+if (payments) {
+    pay = payments.iterator();
+    while (pay.hasNext())   {
+        payment = (GenericValue) pay.next();
+        if (payment.statusId.equals("PMNT_CANCELLED")) continue;
+        applications = payment.getRelated("PaymentApplication", ["paymentId"]);
+        if (!applications) continue; // none found  
+        Map historyItem = ["paymentId" : payment.paymentId , "effectiveDate" : payment.effectiveDate.toString().substring(0,10)];
+        BigDecimal amount = payment.getBigDecimal("amount").setScale(2,BigDecimal.ROUND_HALF_UP);
+        if (payment.partyIdFrom.equals(organizationPartyId)) {
+            amount = amount.multiply(new BigDecimal("-1"));
+        }
+        historyItem.amount = amount.toString();
+        ap = applications.iterator();
+        while (ap.hasNext())    {
+            application = (GenericValue) ap.next();
+            historyItem = ["toPaymentId" : application.paymentId,
+                           "applied" : application.amountApplied];
+            toPayment = application.getRelatedOne("Payment");
+            historyItem.toEffectiveDate = toPayment.effectiveDate.toString().substring(0,10);
+            toAmount = toPayment.getBigDecimal("amount").setScale(2,BigDecimal.ROUND_HALF_UP);
+            if (toPayment.partyIdFrom.equals(organizationPartyId)) toAmount = toAmount.multiply(new BigDecimal("-1"));
+            //reduce the payment amount in the payment list
+            pl = payments.iterator();
+            while (pl.hasNext()) {
+                payment = (GenericValue) pl.next();
+                // reduce paymentId
+                if (application.paymentId.equals(payment.paymentId)) {
+                    plInd = payments.indexOf(payment);
+                    payment.amount =
+                            payment.getBigDecimal("amount").
+                            subtract(application.getBigDecimal("amountApplied")).doubleValue();
+                    payments.remove(plInd);
+                    payments.add(plInd,payment);
+                    totalPaymentApplied = totalPaymentApplied.add(application.getBigDecimal("amountApplied"));
+                }
+                // reduce toPaymentId
+                if (application.toPaymentId.equals(payment.paymentId)) {
+                    plInd = payments.indexOf(payment);
+                    payment.amount =
+                            payment.getBigDecimal("amount").
+                            subtract(application.getBigDecimal("amountApplied")).doubleValue();
+                    payments.remove(plInd);
+                    payments.add(plInd,payment);
+                    totalPaymentApplied = totalPaymentApplied.add(application.getBigDecimal("amountApplied"));
+                }
+            }
+        }
+    }
+    context.historyListPayments = historyList;
 }
 
-
 // check if any invoices left not applied
 if (notAppliedInvoices != null && notAppliedInvoices.size() > 0) {
-	context.put("historyListInvoicesN",notAppliedInvoices);
+    context.historyListInvoicesN = notAppliedInvoices;
 }
-		
-
+        
 // list payments applied to other companies
 historyList = new LinkedList();
 if (payments != null && payments.size() > 0) {
-	Iterator pm = payments.iterator();
-	while (pm.hasNext())	{
-		payment = pm.next();
-		// check if payment completely applied
-		BigDecimal amount = payment.getBigDecimal("amount").setScale(2,BigDecimal.ROUND_HALF_UP);
-		if (amount.compareTo(new BigDecimal("0.00")) == 0) 
-			continue;
-		Debug.logInfo(" other company payments: " + payment.getString("paymentId") + " amount:" + payment.getBigDecimal("amount") + " applied:" + PaymentWorker.getPaymentAppliedBd(payment),"??");
-		List paymentApplications = payment.getRelated("PaymentApplication");
-		Iterator pa = paymentApplications.iterator();
-		while (pa.hasNext())	{
-			GenericValue paymentApplication = pa.next();
-			if (paymentApplication.get("invoiceId") != null) {
-				GenericValue invoice = paymentApplication.getRelatedOne("Invoice");
-				if (!invoice.getString("partyId").equals(partyId)) {
-					historyItem = new HashMap();
-					historyItem.put("paymentId",payment.getString("paymentId"));
-					historyItem.put("invoiceId",paymentApplication.getString("invoiceId"));
-					historyItem.put("invoiceItemSeqId",paymentApplication.getString("invoiceItemSeqId"));
-					historyItem.put("partyId",invoice.getString("partyIdFrom"));
-					historyItem.put("amount",amount.toString());
-					historyItem.put("applied",paymentApplication.getBigDecimal("amountApplied").setScale(2,BigDecimal.ROUND_HALF_UP).toString());
-					historyItem.put("effectiveDate",payment.getString("effectiveDate").substring(0,10));
-					historyList.add(historyItem);
-				}
-			}
-		}
-	}
-	context.put("historyListPaymentsO",historyList);
+    Iterator pm = payments.iterator();
+    while (pm.hasNext())    {
+        payment = (GenericValue) pm.next();
+        // check if payment completely applied
+        BigDecimal amount = payment.getBigDecimal("amount").setScale(2,BigDecimal.ROUND_HALF_UP);
+        if (amount.compareTo(new BigDecimal("0.00")) == 0) 
+            continue;
+        Debug.logInfo(" other company payments: " + payment.paymentId + " amount:" + payment.getBigDecimal("amount") + " applied:" + PaymentWorker.getPaymentAppliedBd(payment),"??");
+        List paymentApplications = payment.getRelated("PaymentApplication");
+        Iterator pa = paymentApplications.iterator();
+        while (pa.hasNext())    {
+            paymentApplication = (GenericValue) pa.next();
+            if (paymentApplication.invoiceId != null) {
+                invoice = paymentApplication.getRelatedOne("Invoice");
+                if (!invoice.partyId.equals(partyId)) {
+                    historyItem = new HashMap();
+                    Map historyItem = ["paymentId" : payment.paymentId,
+                                       "invoiceId" : paymentApplication.invoiceId,
+                                       "invoiceItemSeqId" : paymentApplication.invoiceItemSeqId,
+                                       "partyId" : invoice.partyIdFrom,
+                                       "amount" : amount.toString(),
+                                       "applied" : paymentApplication.getBigDecimal("amountApplied").setScale(2,BigDecimal.ROUND_HALF_UP).toString(),
+                                       "effectiveDate" : payment.effectiveDate.toString().substring(0,10)];
+                    historyList.add(historyItem);
+                }
+            }
+        }
+    }
+    context.historyListPaymentsO = historyList;
 }
 
 // list not applied payments
 BigDecimal totalPaymentNotApplied = new BigDecimal("0.00").setScale(2,BigDecimal.ROUND_HALF_UP);
 historyList = new LinkedList();
 if (payments != null && payments.size() > 0) {
-	Iterator pm = payments.iterator();
-	while (pm.hasNext())	{
-		payment = pm.next();
-		payment = delegator.findByPrimaryKey("Payment",UtilMisc.toMap("paymentId",payment.getString("paymentId")));
-		notApplied = payment.getBigDecimal("amount").subtract(PaymentWorker.getPaymentAppliedBd(payment)).setScale(2,BigDecimal.ROUND_HALF_UP);
-		// check if payment completely applied
-		Debug.logInfo(" payment: " + payment.getString("paymentId") + " amount:" + payment.getBigDecimal("amount") + " applied:" + PaymentWorker.getPaymentAppliedBd(payment),"??");  
-		if (notApplied.compareTo(new BigDecimal("0.00")) == 0) 
-			continue;
-		historyItem = new HashMap();
-		historyItem.put("paymentId",payment.getString("paymentId"));
-		BigDecimal amount = payment.getBigDecimal("amount").setScale(2,BigDecimal.ROUND_HALF_UP);
-		totalPaymentNotApplied = totalPaymentNotApplied.add(notApplied);
-		historyItem.put("amount",amount.toString());
-		historyItem.put("notApplied",notApplied.toString());
-		historyItem.put("effectiveDate",payment.getString("effectiveDate").substring(0,10));
-		historyList.add(historyItem);
-	}
-	context.put("historyListPaymentsN",historyList);
+    Iterator pm = payments.iterator();
+    while (pm.hasNext())    {
+        payment = (GenericValue) pm.next();
+        payment = delegator.findByPrimaryKey("Payment",["paymentId" : payment.paymentId]);
+        notApplied = payment.getBigDecimal("amount").subtract(PaymentWorker.getPaymentAppliedBd(payment)).setScale(2,BigDecimal.ROUND_HALF_UP);
+        // check if payment completely applied
+        Debug.logInfo(" payment: " + payment.paymentId + " amount:" + payment.getBigDecimal("amount") + " applied:" + PaymentWorker.getPaymentAppliedBd(payment),"??");  
+        if (notApplied.compareTo(new BigDecimal("0.00")) == 0) 
+            continue;
+        Map historyItem = new HashMap();
+        BigDecimal amount = payment.getBigDecimal("amount").setScale(2,BigDecimal.ROUND_HALF_UP);
+        totalPaymentNotApplied = totalPaymentNotApplied.add(notApplied);
+        historyItem = ["paymentId" : payment.paymentId,
+                       "amount" : amount.toString(),
+                       "notApplied" : notApplied.toString(),
+                       "effectiveDate" : payment.effectiveDate.toString().substring(0,10)];
+        historyList.add(historyItem);
+    }
+    context.historyListPaymentsN = historyList;
 }
 
-
 // create totals
 
-finanSummary = UtilMisc.toMap(
-	"totalSalesInvoice",totalSalesInvoice.toString(),	
-	"totalPurchaseInvoice",totalPurchaseInvoice.toString(),	
-	"totalPaymentsIn",totalPaymentsIn.toString(),	
-	"totalPaymentsOut",totalPaymentsOut.toString(),	
-	"totalInvoiceApplied",totalInvoiceApplied.toString(),
-	"totalInvoiceNotApplied",totalInvoiceNotApplied.toString());
-finanSummary.put("totalPaymentNotApplied",totalPaymentNotApplied.toString());
-finanSummary.put("totalPaymentNotApplied",totalPaymentNotApplied.toString());
+finanSummary = ["totalSalesInvoice" : totalSalesInvoice.toString(), 
+                "totalPurchaseInvoice" : totalPurchaseInvoice.toString(),   
+                "totalPaymentsIn" : totalPaymentsIn.toString(), 
+                "totalPaymentsOut" : totalPaymentsOut.toString(),   
+                "totalInvoiceApplied" : totalInvoiceApplied.toString(),
+                "totalInvoiceNotApplied" : totalInvoiceNotApplied.toString()];
+finanSummary = ["totalPaymentNotApplied" : totalPaymentNotApplied.toString(),
+                "totalPaymentNotApplied" : totalPaymentNotApplied.toString()];
 totalToBePaid = totalSalesInvoice.add(totalPurchaseInvoice).subtract(totalInvoiceApplied).subtract(totalPaymentNotApplied);
-if (totalToBePaid.compareTo(new BigDecimal("0.00")) < 0 ) finanSummary.put("totalToBePaid",totalToBePaid.toString());
-else if (totalToBePaid.compareTo(new BigDecimal("0.00")) > 0 ) finanSummary.put("totalToBeReceived",totalToBePaid.toString());
-else	{
-	finanSummary.put("totalToBePaid","0.00");
-	finanSummary.put("totalToBeReceived","0.00");
+if (totalToBePaid.compareTo(new BigDecimal("0.00")) < 0 ) finanSummary.totalToBePaid = totalToBePaid.toString();
+else if (totalToBePaid.compareTo(new BigDecimal("0.00")) > 0 ) finanSummary.totalToBeReceived = totalToBePaid.toString();
+else    {
+    finanSummary = ["totalToBePaid" : "0.00",
+                    "totalToBeReceived" : "0.00"];
 }
- context.put("finanSummary",finanSummary);
-	
\ No newline at end of file
+ context.finanSummary = finanSummary;
+    
\ No newline at end of file

Modified: ofbiz/trunk/applications/party/webapp/partymgr/party/PartyForms.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/webapp/partymgr/party/PartyForms.xml?rev=698810&r1=698809&r2=698810&view=diff
==============================================================================
--- ofbiz/trunk/applications/party/webapp/partymgr/party/PartyForms.xml (original)
+++ ofbiz/trunk/applications/party/webapp/partymgr/party/PartyForms.xml Wed Sep 24 21:06:09 2008
@@ -816,7 +816,7 @@
         <field name="effectiveDate"><display/></field>
         <field name="amount" widget-area-style="tabletextright"><display/></field>
         <field name="applied" widget-area-style="tabletextright"><display/></field>
-        <field name="toPaymentId"><hyperlink target="paymentOverview?paymentId=${paymentId}" description="${toPaymentId}"/></field>
+        <field name="toPaymentId"><hyperlink target="/accounting/control/paymentOverview?paymentId=${paymentId}" description="${toPaymentId}" target-type="inter-app"/></field>
         <field name="toEffectiveDate"><display/></field>
         <field name="toAmount" widget-area-style="tabletextright"><display/></field>
     </form>

Modified: ofbiz/trunk/applications/party/widget/partymgr/PartyScreens.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/widget/partymgr/PartyScreens.xml?rev=698810&r1=698809&r2=698810&view=diff
==============================================================================
--- ofbiz/trunk/applications/party/widget/partymgr/PartyScreens.xml (original)
+++ ofbiz/trunk/applications/party/widget/partymgr/PartyScreens.xml Wed Sep 24 21:06:09 2008
@@ -983,7 +983,7 @@
                 <decorator-screen name="CommonPartyDecorator" location="${parameters.mainDecoratorLocation}">
                     <decorator-section name="body">
                         <container><label style="h1" text="Financial History"/></container>
-                        <screenlet title="${uiLabelMap.Invoices paid by payments}" navigation-form-name="Invoices">
+                        <screenlet title="${uiLabelMap.InvoicesPayments}" navigation-form-name="Invoices">
                             <include-form name="partyFinancialHistoryInvoices" location="component://party/webapp/partymgr/party/PartyForms.xml"/>
                         </screenlet>
                         <section>
@@ -993,8 +993,8 @@
                                 </not>
                             </condition>
                             <widgets>
-                                <screenlet title="${uiLabelMap.Invoices of other parties paid by payments from }${partyId}" navigation-form-name="PaymentsO">
-                                <include-form name="partyFinancialHistoryPaymentsO" location="component://party/webapp/partymgr/party/PartyForms.xml"/>
+                                <screenlet title="${uiLabelMap.InvoicesOtherParties}" navigation-form-name="partyFinancialHistoryPayments">
+                                    <include-form name="partyFinancialHistoryPaymentsO" location="component://party/webapp/partymgr/party/PartyForms.xml"/>
                                 </screenlet>
                             </widgets>
                         </section>
@@ -1005,9 +1005,8 @@
                                 </not>
                             </condition>
                             <widgets>
-                                <screenlet title="${uiLabelMap.Applied payments to payments" navigation-form-name="Payments">
-                                <container><label style="head1" text="Applied payments to payments"/></container>
-                                <include-form name="partyFinancialHistoryPayments" location="component://party/webapp/partymgr/party/PartyForms.xml"/>
+                                <screenlet title="${uiLabelMap.AppliedPayments}" navigation-form-name="partyFinancialHistoryPayments">
+                                    <include-form name="partyFinancialHistoryPayments" location="component://party/webapp/partymgr/party/PartyForms.xml"/>
                                 </screenlet>
                             </widgets>
                         </section>
@@ -1018,8 +1017,8 @@
                                 </not>
                             </condition>
                             <widgets>
-                                <screenlet title="${uiLabelMap.Invoices not yet (fully) applied}" navigation-form-name="InvoicesN">
-                                <include-form name="partyFinancialHistoryInvoicesN" location="component://party/webapp/partymgr/party/PartyForms.xml"/>
+                                <screenlet title="${uiLabelMap.InvoicesNotApplied}" navigation-form-name="partyFinancialHistoryInvoicesN">
+                                    <include-form name="partyFinancialHistoryInvoicesN" location="component://party/webapp/partymgr/party/PartyForms.xml"/>
                                 </screenlet>
                             </widgets>
                         </section>
@@ -1030,13 +1029,13 @@
                                 </not>
                             </condition>
                             <widgets>
-                                <screenlet title="${uiLabelMap.Payments not yet (fully) applied}" navigation-form-name="PaymentsN">
-                                <include-form name="partyFinancialHistoryPaymentsN" location="component://party/webapp/partymgr/party/PartyForms.xml"/>
+                                <screenlet title="${uiLabelMap.PaymentsNotApplied}" navigation-form-name="partyFinancialHistoryPaymentsN">
+                                    <include-form name="partyFinancialHistoryPaymentsN" location="component://party/webapp/partymgr/party/PartyForms.xml"/>
                                 </screenlet>
                             </widgets>
                         </section>
-                        <screenlet title="${uiLabelMap.Totals for Company:}${organizationPartyId}" navigation-form-name="Summary">
-                        <include-form name="partyFinancialSummary" location="component://party/webapp/partymgr/party/PartyForms.xml"/>
+                        <screenlet title="${uiLabelMap.PartyFinancialSummary}${organizationPartyId}" navigation-form-name="partyFinancialSummary">
+                            <include-form name="partyFinancialSummary" location="component://party/webapp/partymgr/party/PartyForms.xml"/>
                         </screenlet>    
                     </decorator-section>
                 </decorator-screen>



Re: svn commit: r698810 - in /ofbiz/trunk/applications/party: config/PartyUiLabels.xml webapp/partymgr/WEB-INF/actions/party/PartyFinancailHistory.groovy webapp/partymgr/party/PartyForms.xml widget/partymgr/PartyScreens.xml

Posted by Jacques Le Roux <ja...@les7arts.com>.
OK, forget it. It seems to be right (payment used for another payment)

Jacques

From: "Jacques Le Roux" <ja...@les7arts.com>
> Hi Hans,
>
> I wonder if this labels is right ? I can't see a meaning to translate.
>
>> +    <property key="AppliedPayments">
>> +        <value xml:lang="en">Applied payments to payments</value>
>> +    </property>
>
> Any help would be appreciated, thanks
>
> Jacques
>
> From: <ha...@apache.org>
>> Author: hansbak
>> Date: Wed Sep 24 21:06:09 2008
>> New Revision: 698810
>>
>> URL: http://svn.apache.org/viewvc?rev=698810&view=rev
>> Log:
>> improved finanacial overview, replaced header and improoved groovy file....not perfect yet however improoved a lot..
>>
>> Modified:
>>    ofbiz/trunk/applications/party/config/PartyUiLabels.xml
>>    ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/party/PartyFinancailHistory.groovy
>>    ofbiz/trunk/applications/party/webapp/partymgr/party/PartyForms.xml
>>    ofbiz/trunk/applications/party/widget/partymgr/PartyScreens.xml
>>
>> Modified: ofbiz/trunk/applications/party/config/PartyUiLabels.xml
>> URL: 
>> http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/config/PartyUiLabels.xml?rev=698810&r1=698809&r2=698810&view=diff
>> ==============================================================================
>> --- ofbiz/trunk/applications/party/config/PartyUiLabels.xml (original)
>> +++ ofbiz/trunk/applications/party/config/PartyUiLabels.xml Wed Sep 24 21:06:09 2008
>> @@ -180,6 +180,9 @@
>>         <value xml:lang="en">Add Related Contact</value>
>>         <value xml:lang="fr">Ajouter un contact associé</value>
>>     </property>
>> +    <property key="AppliedPayments">
>> +        <value xml:lang="en">Applied payments to payments</value>
>> +    </property>
>>     <property key="Description">
>>         <value xml:lang="de">Beschreibung</value>
>>         <value xml:lang="en">Description</value>
>> @@ -1249,6 +1252,15 @@
>>         <value xml:lang="th">ปีกับผู้ว่าจ้าง</value>
>>         <value xml:lang="zh">年为雇主</value>
>>     </property>
>> +    <property key="InvoicesNotApplied">
>> +        <value xml:lang="en">Invoices not yet (fully) applied</value>
>> +    </property>
>> +    <property key="InvoicesOtherParties">
>> +        <value xml:lang="en">Invoices of other parties paid by payments from</value>
>> +    </property>
>> +    <property key="InvoicesPayments">
>> +        <value xml:lang="en">Invoices Payments</value>
>> +    </property>
>>     <property key="IsA"><!-- Peter 'is a' employee of company B -->
>>         <value xml:lang="en">is A</value>
>>         <value xml:lang="fr">est un</value>
>> @@ -3806,6 +3818,9 @@
>>         <value xml:lang="th">ประเภทผลที่ได้</value>
>>         <value xml:lang="zh">事件类型</value>
>>     </property>
>> +    <property key="PartyFinancialSummary">
>> +        <value xml:lang="en">Totals for Company:</value>
>> +    </property>
>>     <property key="PartyFindCommunicationEvents">
>>         <value xml:lang="de">Suche Kommunikationsereignis</value>
>>         <value xml:lang="en">Find Communication Events</value>
>> @@ -7448,6 +7463,9 @@
>>         <value xml:lang="pt_PT">Erro de Segurança: para correr a função de Comunicação de Remoção de Acontecimentos é 
>> necessário obter o PARTYMGR_DELETE ou permissão de PARTYMGR_ADMIN</value>
>>         <value xml:lang="th">Security Error: ในการย้ายสถานะผลการติดต่อ 
>> คุณต้องได้รับอนุญาตจาก  PARTYMGR_DELETE หรือ PARTYMGR_ADMIN 
>> ก่อน</value>
>>     </property>
>> +    <property key="PaymentsNotApplied">
>> +        <value xml:lang="en">Payments not yet (fully) applied</value>
>> +    </property>
>>     <property key="commeventservices.communication_event_from_contact_mech_must_be_email">
>>         <value xml:lang="de">FEHLER: Kommunikationsereignis muss ein "Kontaktmechanismus von" besitzen das ein E-Mail als 
>> Kommunikationereignis ID ist</value>
>>         <value xml:lang="en">ERROR: Communication event must have a from contact mech that is an email for comm event Id</value>
>>
>> Modified: ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/party/PartyFinancailHistory.groovy
>> URL: 
>> http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/party/PartyFinancailHistory.groovy?rev=698810&r1=698809&r2=698810&view=diff
>> ==============================================================================
>> --- ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/party/PartyFinancailHistory.groovy (original)
>> +++ ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/party/PartyFinancailHistory.groovy Wed Sep 24 21:06:09 2008
>> @@ -1,29 +1,21 @@
>> /*
>> - *  Copyright (c) 2001-2005 The Open For Business Project - www.ofbiz.org
>> - *
>> - *  Permission is hereby granted, free of charge, to any person obtaining a
>> - *  copy of this software and associated documentation files (the "Software"),
>> - *  to deal in the Software without restriction, including without limitation
>> - *  the rights to use, copy, modify, merge, publish, distribute, sublicense,
>> - *  and/or sell copies of the Software, and to permit persons to whom the
>> - *  Software is furnished to do so, subject to the following conditions:
>> - *
>> - *  The above copyright notice and this permission notice shall be included
>> - *  in all copies or substantial portions of the Software.
>> - *
>> - *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
>> - *  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
>> - *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
>> - *  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
>> - *  CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
>> - *  OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
>> - *  THE USE OR OTHER DEALINGS IN THE SOFTWARE.
>> - *
>> - *@author     Hans Bakker (h.bakker@antwebsystems.com)
>> - *@version    $Rev$
>> - *@since      3.0
>> + * 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.
>>  */
>> -
>> import java.util.*;
>> import java.math.*;
>> import java.sql.Timestamp;
>> @@ -35,24 +27,24 @@
>> import org.ofbiz.accounting.invoice.*;
>> import org.ofbiz.accounting.payment.*;
>>
>> -delegator = parameters.get("delegator");
>> -organizationPartyId = parameters.get("organizationPartyId");
>> -partyId = parameters.get("partyId");
>> +delegator = parameters.delegator;
>> +organizationPartyId = parameters.organizationPartyId;
>> +partyId = parameters.partyId;
>> if (partyId == null && organizationPartyId == null) return;
>> List historyList = new LinkedList();
>>
>> //get payment totals
>> BigDecimal totalPaymentsIn = new BigDecimal("0.00").setScale(2,BigDecimal.ROUND_HALF_UP);
>> BigDecimal totalPaymentsOut = new BigDecimal("0.00").setScale(2,BigDecimal.ROUND_HALF_UP);
>> -tpayments = delegator.findByOr("Payment",[partyIdTo:partyId,partyIdFrom:partyId]);
>> +tpayments = delegator.findByOr("Payment",["partyIdTo" : partyId,"partyIdFrom" : partyId]);
>> Iterator pl = tpayments.iterator();
>> while (pl.hasNext()) {
>> - payment = pl.next();
>> - if (payment.getString("statusId").equals("PMNT_CANCELLED")) continue;
>> - if (payment.getString("partyIdTo").equals(organizationPartyId))
>> - totalPaymentsIn = totalPaymentsIn.add(payment.getBigDecimal("amount")).setScale(2,BigDecimal.ROUND_HALF_UP);
>> - else
>> - totalPaymentsOut = totalPaymentsOut.add(payment.getBigDecimal("amount")).setScale(2,BigDecimal.ROUND_HALF_UP);
>> +    payment = (GenericValue) pl.next();
>> +    if (payment.statusId.equals("PMNT_CANCELLED")) continue;
>> +    if (payment.partyIdTo.equals(organizationPartyId))
>> +        totalPaymentsIn = totalPaymentsIn.add(payment.getBigDecimal("amount")).setScale(2,BigDecimal.ROUND_HALF_UP);
>> +    else
>> +        totalPaymentsOut = totalPaymentsOut.add(payment.getBigDecimal("amount")).setScale(2,BigDecimal.ROUND_HALF_UP);
>> }
>>
>> // totals
>> @@ -63,250 +55,241 @@
>>
>> // payment and invoices list which will be updated with the amount applied
>> // to see what is left over...
>> -List invoices = delegator.findByOr("Invoice",
>> - UtilMisc.toMap("partyId",partyId,"partyIdFrom",partyId),
>> - UtilMisc.toList("invoiceDate"));
>> -List payments = delegator.findByOr("Payment",
>> - UtilMisc.toMap("partyIdTo",partyId,"partyIdFrom",partyId),
>> - UtilMisc.toList("effectiveDate"));
>> -
>> +List invoices = delegator.findByOr("Invoice",["partyId" : partyId , "partyIdFrom" : partyId] , ["invoiceDate"]);
>> +List payments = delegator.findByOr("Payment",["partyIdTo" : partyId , "partyIdFrom" : partyId] , ["effectiveDate"]);
>> +
>> List notAppliedInvoices = new LinkedList(); // to store the not fully applied invoices
>> -
>> -// start reeading from the invoices list
>> +
>> +// start reading from the invoices list
>> if (invoices != null && invoices.size() > 0) {
>> - Iterator inv = invoices.iterator();
>> - while (inv.hasNext()) {
>> - invoice = inv.next();
>> - if (invoice.getString("statusId").equals("INVOICE_CANCELLED")) continue;
>> - BigDecimal invoiceAmount = InvoiceWorker.getInvoiceTotalBd(invoice).setScale(2,BigDecimal.ROUND_HALF_UP);
>> - invoiceApplied = InvoiceWorker.getInvoiceAppliedBd(invoice).setScale(2,BigDecimal.ROUND_HALF_UP);
>> -/* if (invoice.getString("partyId").equals(organizationPartyId)) { //negate for outgoing payments
>> - invoiceAmount = invoiceAmount.multiply(new BigDecimal("-1"));
>> - invoiceApplied = invoiceApplied.multiply(new BigDecimal("-1"));
>> - }
>> -*/ if (invoice.getString("invoiceTypeId").equals("PURCHASE_INVOICE")) totalPurchaseInvoice = 
>> totalPurchaseInvoice.add(invoiceAmount);
>> - if (invoice.getString("invoiceTypeId").equals("SALES_INVOICE")) totalSalesInvoice = totalSalesInvoice.add(invoiceAmount);
>> - totalInvoiceApplied = totalInvoiceApplied.add(invoiceApplied);
>> -// Debug.logInfo("Invoice type: "+ invoice.getString("invoiceTypeId") + "amount: " + invoiceAmount + " applied: " + 
>> invoiceApplied,"??");
>> - if (!invoiceAmount.equals(invoiceApplied)) {
>> - Map notAppliedInvoice = UtilMisc.toMap(
>> - "invoiceId",invoice.getString("invoiceId"),
>> - "invoiceTypeId", invoice.getString("invoiceTypeId").substring(0,1),
>> - "invoiceDate", invoice.getString("invoiceDate").substring(0,10),
>> - "invoiceAmount", invoiceAmount.toString(),
>> - "invoiceNotApplied", invoiceAmount.subtract(invoiceApplied).toString());
>> - notAppliedInvoices.add(notAppliedInvoice);
>> - totalInvoiceNotApplied = totalInvoiceNotApplied.add(invoiceAmount).subtract(invoiceApplied);
>> - }
>> - Map historyItem = UtilMisc.toMap(
>> - "invoiceId",invoice.getString("invoiceId"),
>> - "invoiceTypeId", invoice.getString("invoiceTypeId").substring(0,1),
>> - "invoiceDate", invoice.getString("invoiceDate").substring(0,10),
>> - "invoiceAmount", invoiceAmount.toString(),
>> - "totInvoiceApplied", invoiceApplied.toString()
>> - );
>> -
>> - // check for applications
>> - List applications = invoice.getRelated("PaymentApplication",null,UtilMisc.toList("paymentId"));
>> - if (applications != null && applications.size() > 0) {
>> - Iterator appl = applications.iterator();
>> - oldPaymentId = new String(" ");
>> - BigDecimal applied = new BigDecimal("0");
>> - boolean first = true;
>> - while (appl.hasNext()) { // read the applications for this invoice
>> - application = appl.next();
>> - paymentId = application.getString("paymentId");
>> -
>> - //reduce the payment amount in the payment list
>> - pl = payments.iterator();
>> - while (pl.hasNext()) {
>> - payment = pl.next();
>> - if (paymentId.equals(payment.getString("paymentId"))) {
>> - plInd = payments.indexOf(payment);
>> - payment.put("amount",
>> - payment.getBigDecimal("amount").
>> - subtract(application.getBigDecimal("amountApplied")).doubleValue());
>> - payments.remove(plInd);
>> - payments.add(plInd,payment);
>> - break;
>> - }
>> - }
>> -
>> - // check if the payment number has changed, then we have to output a line....
>> - if (!first && !paymentId.equals(oldPaymentId)) { // if the payment number has changed, but not the first
>> - historyItem.put("applied", applied.toString());
>> - historyItem.put("paymentId", oldPaymentId);
>> - payment = delegator.findByPrimaryKey("Payment",UtilMisc.toMap("paymentId",oldPaymentId));
>> - BigDecimal amount = payment.getBigDecimal("amount").setScale(2,BigDecimal.ROUND_HALF_UP);
>> -// if (payment.getString("partyIdFrom").equals(organizationPartyId)) amount = amount.multiply(new BigDecimal("-1"));
>> - historyItem.put("amount",amount.toString());
>> - historyItem.put("effectiveDate",payment.getString("effectiveDate").substring(0,10));
>> - historyList.add(historyItem);
>> - historyItem = new HashMap();
>> - applied = new BigDecimal("0");
>> - }
>> - applied = applied.add(application.getBigDecimal("amountApplied")).setScale(2,BigDecimal.ROUND_HALF_UP);
>> - oldPaymentId = paymentId;
>> - first = false;
>> - }
>> - if (!applied.equals("0")) {
>> - historyItem.put("applied", applied.toString());
>> - historyItem.put("paymentId", oldPaymentId);
>> - payment = delegator.findByPrimaryKey("Payment",UtilMisc.toMap("paymentId",oldPaymentId));
>> - if (payment != null) {
>> - BigDecimal amount = payment.getBigDecimal("amount").setScale(2,BigDecimal.ROUND_HALF_UP);
>> -// if (payment.getString("partyIdFrom").equals(organizationPartyId)) amount = amount.multiply(new BigDecimal("-1"));
>> - historyItem.put("amount",amount.toString());
>> - historyItem.put("effectiveDate",payment.getString("effectiveDate").substring(0,10));
>> - historyList.add(historyItem);
>> - }
>> - }
>> - }
>> - }
>> - context.put("historyListInvoices",historyList);
>> +    Iterator inv = invoices.iterator();
>> +    while (inv.hasNext())   {
>> +        invoice = (GenericValue) inv.next();
>> +        if (invoice.statusId.equals("INVOICE_CANCELLED")) continue;
>> +        BigDecimal invoiceAmount = InvoiceWorker.getInvoiceTotalBd(invoice).setScale(2,BigDecimal.ROUND_HALF_UP);
>> +        invoiceApplied = InvoiceWorker.getInvoiceAppliedBd(invoice).setScale(2,BigDecimal.ROUND_HALF_UP);
>> +/*      if (invoice.getString("partyId").equals(organizationPartyId)) { //negate for outgoing payments
>> +            invoiceAmount = invoiceAmount.multiply(new BigDecimal("-1"));
>> +            invoiceApplied = invoiceApplied.multiply(new BigDecimal("-1"));
>> +        }
>> +*/      if (invoice.invoiceTypeId.equals("PURCHASE_INVOICE")) totalPurchaseInvoice = totalPurchaseInvoice.add(invoiceAmount);
>> +        if (invoice.invoiceTypeId.equals("SALES_INVOICE")) totalSalesInvoice = totalSalesInvoice.add(invoiceAmount);
>> +        totalInvoiceApplied = totalInvoiceApplied.add(invoiceApplied);
>> +//      Debug.logInfo("Invoice type: "+ invoice.getString("invoiceTypeId") + "amount: " + invoiceAmount + " applied: " + 
>> invoiceApplied,"??");
>> +        if (!invoiceAmount.equals(invoiceApplied))  {
>> +            Map notAppliedInvoice = ["invoiceId" : invoice.invoiceId,
>> +                                     "invoiceTypeId" : invoice.invoiceTypeId.substring(0,1),
>> +                                     "invoiceDate" : invoice.invoiceDate.toString().substring(0,10),
>> +                                     "invoiceAmount" : invoiceAmount.toString(),
>> +                                     "invoiceNotApplied" : invoiceAmount.subtract(invoiceApplied).toString()];
>> +                notAppliedInvoices.add(notAppliedInvoice);
>> +                totalInvoiceNotApplied = totalInvoiceNotApplied.add(invoiceAmount).subtract(invoiceApplied);
>> +        }
>> +        Map historyItem = ["invoiceId" : invoice.invoiceId,
>> +                           "invoiceTypeId" : invoice.invoiceTypeId.substring(0,1),
>> +                           "invoiceDate" : invoice.invoiceDate.toString().substring(0,10),
>> +                           "invoiceAmount" : invoiceAmount.toString(),
>> +                           "totInvoiceApplied" : invoiceApplied.toString()
>> +            ];
>> +        // check for applications
>> +        List applications = invoice.getRelated("PaymentApplication",null,["paymentId"]);
>> +        if (applications != null && applications.size() > 0) {
>> +            Iterator appl = applications.iterator();
>> +            oldPaymentId = new String(" ");
>> +            BigDecimal applied = new BigDecimal("0");
>> +            boolean first = true;
>> +            while (appl.hasNext())  {   // read the applications for this invoice
>> +                application = (GenericValue) appl.next();
>> +                paymentId = application.paymentId;
>> +
>> +                //reduce the payment amount in the payment list
>> +                pl = payments.iterator();
>> +                while (pl.hasNext()) {
>> +                    payment = (GenericValue) pl.next();
>> +                    if (paymentId.equals(payment.paymentId)) {
>> +                        plInd = payments.indexOf(payment);
>> +                        payment.amount = 
>> payment.getBigDecimal("amount").subtract(application.getBigDecimal("amountApplied")).doubleValue();
>> +                        payments.remove(plInd);
>> +                        payments.add(plInd,payment);
>> +                        break;
>> +                    }
>> +                }
>> +
>> +                // check if the payment number has changed, then we have to output a line....
>> +                if (!first && !paymentId.equals(oldPaymentId)) { // if the payment number has changed, but not the first
>> +                    payment = delegator.findByPrimaryKey("Payment",["paymentId" : oldPaymentId]);
>> +                    BigDecimal amount = payment.getBigDecimal("amount").setScale(2,BigDecimal.ROUND_HALF_UP);
>> +//                  if (payment.getString("partyIdFrom").equals(organizationPartyId)) amount = amount.multiply(new 
>> BigDecimal("-1"));
>> +                    historyItem = ["applied" : applied.toString(),
>> +                                   "paymentId" : oldPaymentId,
>> +                                   "amount" : amount.toString(),
>> +                                   "effectiveDate" : payment.effectiveDate.toString().substring(0,10)];
>> +                    historyList.add(historyItem);
>> +                    historyItem = new HashMap();
>> +                    applied = new BigDecimal("0");
>> +                }
>> +                applied = applied.add(application.getBigDecimal("amountApplied")).setScale(2,BigDecimal.ROUND_HALF_UP);
>> +                oldPaymentId = paymentId;
>> +                first = false;
>> +            }
>> +            if (!applied.equals("0")) {
>> +                payment = delegator.findByPrimaryKey("Payment",["paymentId" : oldPaymentId]);
>> +                if (payment != null) {
>> +                    BigDecimal amount = payment.getBigDecimal("amount").setScale(2,BigDecimal.ROUND_HALF_UP);
>> +//                  if (payment.getString("partyIdFrom").equals(organizationPartyId))   amount = amount.multiply(new 
>> BigDecimal("-1"));
>> +                    historyItem = ["invoiceId" : invoice.invoiceId,
>> +                                   "invoiceTypeId" : invoice.invoiceTypeId.substring(0,1),
>> +                                   "invoiceDate" : invoice.invoiceDate.toString().substring(0,10),
>> +                                   "invoiceAmount" : invoiceAmount.toString(),
>> +                                   "totInvoiceApplied" : invoiceApplied.toString(),
>> +                                   "applied" : applied.toString(),
>> +                                   "paymentId" : oldPaymentId,
>> +                                   "amount" : amount.toString(),
>> +                                   "effectiveDate" : payment.effectiveDate.toString().substring(0,10)];
>> +                    historyList.add(historyItem);
>> +                }
>> +            }
>> +        }
>> +    }
>> +    context.historyListInvoices = historyList;
>> }
>>
>> // totals
>> BigDecimal totalPaymentApplied = new BigDecimal("0.00").setScale(2,BigDecimal.ROUND_HALF_UP);
>> // list of payments where payments are applied
>> historyList = new LinkedList();
>> -if (payments != null && payments.size() > 0) {
>> - pay = payments.iterator();
>> - while (pay.hasNext()) {
>> - payment = pay.next();
>> - if (payment.getString("statusId").equals("PMNT_CANCELLED")) continue;
>> - List applications = payment.getRelated("ToPaymentApplication",null,UtilMisc.toList("paymentId"));
>> - if (applications == null || applications.size() == 0 ) continue; // none found
>> - Map historyItem = 
>> UtilMisc.toMap("paymentId",payment.getString("paymentId"),"effectiveDate",payment.getString("effectiveDate").substring(0,10));
>> - BigDecimal amount = payment.getBigDecimal("amount").setScale(2,BigDecimal.ROUND_HALF_UP);
>> -// if (payment.getString("partyIdFrom").equals(organizationPartyId)) amount = amount.multiply(new BigDecimal("-1"));
>> - historyItem.put("amount",amount.toString());
>> - ap = applications.iterator();
>> - while (ap.hasNext()) {
>> - GenericValue application = ap.next();
>> - historyItem.put("toPaymentId",application.getString("paymentId"));
>> - historyItem.put("applied",application.getString("amountApplied"));
>> - toPayment = application.getRelatedOne("Payment");
>> - historyItem.put("toEffectiveDate",toPayment.getString("effectiveDate").substring(0,10));
>> - toAmount = toPayment.getBigDecimal("amount").setScale(2,BigDecimal.ROUND_HALF_UP);
>> -// if (toPayment.getString("partyIdFrom").equals(organizationPartyId)) toAmount = toAmount.multiply(new BigDecimal("-1"));
>> - historyItem.put("toAmount",toAmount.toString());
>> - historyList.add(historyItem);
>> -
>> - //reduce the payment amount in the payment list
>> - pl = payments.iterator();
>> - while (pl.hasNext()) {
>> - payment = pl.next();
>> - // reduce paymentId
>> - if (application.getString("paymentId").equals(payment.getString("paymentId"))) {
>> - plInd = payments.indexOf(payment);
>> - payment.put("amount",
>> - payment.getBigDecimal("amount").
>> - subtract(application.getBigDecimal("amountApplied")).doubleValue());
>> - payments.remove(plInd);
>> - payments.add(plInd,payment);
>> - totalPaymentApplied = totalPaymentApplied.add(application.getBigDecimal("amountApplied"));
>> - }
>> - // reduce toPaymentId
>> - if (application.getString("toPaymentId").equals(payment.getString("paymentId"))) {
>> - plInd = payments.indexOf(payment);
>> - payment.put("amount",
>> - payment.getBigDecimal("amount").
>> - subtract(application.getBigDecimal("amountApplied")).doubleValue());
>> - payments.remove(plInd);
>> - payments.add(plInd,payment);
>> - totalPaymentApplied = totalPaymentApplied.add(application.getBigDecimal("amountApplied"));
>> - }
>> - }
>> - }
>> - }
>> - context.put("historyListPayments",historyList);
>> +if (payments) {
>> +    pay = payments.iterator();
>> +    while (pay.hasNext())   {
>> +        payment = (GenericValue) pay.next();
>> +        if (payment.statusId.equals("PMNT_CANCELLED")) continue;
>> +        applications = payment.getRelated("PaymentApplication", ["paymentId"]);
>> +        if (!applications) continue; // none found
>> +        Map historyItem = ["paymentId" : payment.paymentId , "effectiveDate" : 
>> payment.effectiveDate.toString().substring(0,10)];
>> +        BigDecimal amount = payment.getBigDecimal("amount").setScale(2,BigDecimal.ROUND_HALF_UP);
>> +        if (payment.partyIdFrom.equals(organizationPartyId)) {
>> +            amount = amount.multiply(new BigDecimal("-1"));
>> +        }
>> +        historyItem.amount = amount.toString();
>> +        ap = applications.iterator();
>> +        while (ap.hasNext())    {
>> +            application = (GenericValue) ap.next();
>> +            historyItem = ["toPaymentId" : application.paymentId,
>> +                           "applied" : application.amountApplied];
>> +            toPayment = application.getRelatedOne("Payment");
>> +            historyItem.toEffectiveDate = toPayment.effectiveDate.toString().substring(0,10);
>> +            toAmount = toPayment.getBigDecimal("amount").setScale(2,BigDecimal.ROUND_HALF_UP);
>> +            if (toPayment.partyIdFrom.equals(organizationPartyId)) toAmount = toAmount.multiply(new BigDecimal("-1"));
>> +            //reduce the payment amount in the payment list
>> +            pl = payments.iterator();
>> +            while (pl.hasNext()) {
>> +                payment = (GenericValue) pl.next();
>> +                // reduce paymentId
>> +                if (application.paymentId.equals(payment.paymentId)) {
>> +                    plInd = payments.indexOf(payment);
>> +                    payment.amount =
>> +                            payment.getBigDecimal("amount").
>> +                            subtract(application.getBigDecimal("amountApplied")).doubleValue();
>> +                    payments.remove(plInd);
>> +                    payments.add(plInd,payment);
>> +                    totalPaymentApplied = totalPaymentApplied.add(application.getBigDecimal("amountApplied"));
>> +                }
>> +                // reduce toPaymentId
>> +                if (application.toPaymentId.equals(payment.paymentId)) {
>> +                    plInd = payments.indexOf(payment);
>> +                    payment.amount =
>> +                            payment.getBigDecimal("amount").
>> +                            subtract(application.getBigDecimal("amountApplied")).doubleValue();
>> +                    payments.remove(plInd);
>> +                    payments.add(plInd,payment);
>> +                    totalPaymentApplied = totalPaymentApplied.add(application.getBigDecimal("amountApplied"));
>> +                }
>> +            }
>> +        }
>> +    }
>> +    context.historyListPayments = historyList;
>> }
>>
>> -
>> // check if any invoices left not applied
>> if (notAppliedInvoices != null && notAppliedInvoices.size() > 0) {
>> - context.put("historyListInvoicesN",notAppliedInvoices);
>> +    context.historyListInvoicesN = notAppliedInvoices;
>> }
>> -
>> -
>> +
>> // list payments applied to other companies
>> historyList = new LinkedList();
>> if (payments != null && payments.size() > 0) {
>> - Iterator pm = payments.iterator();
>> - while (pm.hasNext()) {
>> - payment = pm.next();
>> - // check if payment completely applied
>> - BigDecimal amount = payment.getBigDecimal("amount").setScale(2,BigDecimal.ROUND_HALF_UP);
>> - if (amount.compareTo(new BigDecimal("0.00")) == 0)
>> - continue;
>> - Debug.logInfo(" other company payments: " + payment.getString("paymentId") + " amount:" + payment.getBigDecimal("amount") + " 
>> applied:" + PaymentWorker.getPaymentAppliedBd(payment),"??");
>> - List paymentApplications = payment.getRelated("PaymentApplication");
>> - Iterator pa = paymentApplications.iterator();
>> - while (pa.hasNext()) {
>> - GenericValue paymentApplication = pa.next();
>> - if (paymentApplication.get("invoiceId") != null) {
>> - GenericValue invoice = paymentApplication.getRelatedOne("Invoice");
>> - if (!invoice.getString("partyId").equals(partyId)) {
>> - historyItem = new HashMap();
>> - historyItem.put("paymentId",payment.getString("paymentId"));
>> - historyItem.put("invoiceId",paymentApplication.getString("invoiceId"));
>> - historyItem.put("invoiceItemSeqId",paymentApplication.getString("invoiceItemSeqId"));
>> - historyItem.put("partyId",invoice.getString("partyIdFrom"));
>> - historyItem.put("amount",amount.toString());
>> - historyItem.put("applied",paymentApplication.getBigDecimal("amountApplied").setScale(2,BigDecimal.ROUND_HALF_UP).toString());
>> - historyItem.put("effectiveDate",payment.getString("effectiveDate").substring(0,10));
>> - historyList.add(historyItem);
>> - }
>> - }
>> - }
>> - }
>> - context.put("historyListPaymentsO",historyList);
>> +    Iterator pm = payments.iterator();
>> +    while (pm.hasNext())    {
>> +        payment = (GenericValue) pm.next();
>> +        // check if payment completely applied
>> +        BigDecimal amount = payment.getBigDecimal("amount").setScale(2,BigDecimal.ROUND_HALF_UP);
>> +        if (amount.compareTo(new BigDecimal("0.00")) == 0)
>> +            continue;
>> +        Debug.logInfo(" other company payments: " + payment.paymentId + " amount:" + payment.getBigDecimal("amount") + " 
>> applied:" + PaymentWorker.getPaymentAppliedBd(payment),"??");
>> +        List paymentApplications = payment.getRelated("PaymentApplication");
>> +        Iterator pa = paymentApplications.iterator();
>> +        while (pa.hasNext())    {
>> +            paymentApplication = (GenericValue) pa.next();
>> +            if (paymentApplication.invoiceId != null) {
>> +                invoice = paymentApplication.getRelatedOne("Invoice");
>> +                if (!invoice.partyId.equals(partyId)) {
>> +                    historyItem = new HashMap();
>> +                    Map historyItem = ["paymentId" : payment.paymentId,
>> +                                       "invoiceId" : paymentApplication.invoiceId,
>> +                                       "invoiceItemSeqId" : paymentApplication.invoiceItemSeqId,
>> +                                       "partyId" : invoice.partyIdFrom,
>> +                                       "amount" : amount.toString(),
>> +                                       "applied" : 
>> paymentApplication.getBigDecimal("amountApplied").setScale(2,BigDecimal.ROUND_HALF_UP).toString(),
>> +                                       "effectiveDate" : payment.effectiveDate.toString().substring(0,10)];
>> +                    historyList.add(historyItem);
>> +                }
>> +            }
>> +        }
>> +    }
>> +    context.historyListPaymentsO = historyList;
>> }
>>
>> // list not applied payments
>> BigDecimal totalPaymentNotApplied = new BigDecimal("0.00").setScale(2,BigDecimal.ROUND_HALF_UP);
>> historyList = new LinkedList();
>> if (payments != null && payments.size() > 0) {
>> - Iterator pm = payments.iterator();
>> - while (pm.hasNext()) {
>> - payment = pm.next();
>> - payment = delegator.findByPrimaryKey("Payment",UtilMisc.toMap("paymentId",payment.getString("paymentId")));
>> - notApplied = 
>> payment.getBigDecimal("amount").subtract(PaymentWorker.getPaymentAppliedBd(payment)).setScale(2,BigDecimal.ROUND_HALF_UP);
>> - // check if payment completely applied
>> - Debug.logInfo(" payment: " + payment.getString("paymentId") + " amount:" + payment.getBigDecimal("amount") + " applied:" + 
>> PaymentWorker.getPaymentAppliedBd(payment),"??");
>> - if (notApplied.compareTo(new BigDecimal("0.00")) == 0)
>> - continue;
>> - historyItem = new HashMap();
>> - historyItem.put("paymentId",payment.getString("paymentId"));
>> - BigDecimal amount = payment.getBigDecimal("amount").setScale(2,BigDecimal.ROUND_HALF_UP);
>> - totalPaymentNotApplied = totalPaymentNotApplied.add(notApplied);
>> - historyItem.put("amount",amount.toString());
>> - historyItem.put("notApplied",notApplied.toString());
>> - historyItem.put("effectiveDate",payment.getString("effectiveDate").substring(0,10));
>> - historyList.add(historyItem);
>> - }
>> - context.put("historyListPaymentsN",historyList);
>> +    Iterator pm = payments.iterator();
>> +    while (pm.hasNext())    {
>> +        payment = (GenericValue) pm.next();
>> +        payment = delegator.findByPrimaryKey("Payment",["paymentId" : payment.paymentId]);
>> +        notApplied = 
>> payment.getBigDecimal("amount").subtract(PaymentWorker.getPaymentAppliedBd(payment)).setScale(2,BigDecimal.ROUND_HALF_UP);
>> +        // check if payment completely applied
>> +        Debug.logInfo(" payment: " + payment.paymentId + " amount:" + payment.getBigDecimal("amount") + " applied:" + 
>> PaymentWorker.getPaymentAppliedBd(payment),"??");
>> +        if (notApplied.compareTo(new BigDecimal("0.00")) == 0)
>> +            continue;
>> +        Map historyItem = new HashMap();
>> +        BigDecimal amount = payment.getBigDecimal("amount").setScale(2,BigDecimal.ROUND_HALF_UP);
>> +        totalPaymentNotApplied = totalPaymentNotApplied.add(notApplied);
>> +        historyItem = ["paymentId" : payment.paymentId,
>> +                       "amount" : amount.toString(),
>> +                       "notApplied" : notApplied.toString(),
>> +                       "effectiveDate" : payment.effectiveDate.toString().substring(0,10)];
>> +        historyList.add(historyItem);
>> +    }
>> +    context.historyListPaymentsN = historyList;
>> }
>>
>> -
>> // create totals
>>
>> -finanSummary = UtilMisc.toMap(
>> - "totalSalesInvoice",totalSalesInvoice.toString(),
>> - "totalPurchaseInvoice",totalPurchaseInvoice.toString(),
>> - "totalPaymentsIn",totalPaymentsIn.toString(),
>> - "totalPaymentsOut",totalPaymentsOut.toString(),
>> - "totalInvoiceApplied",totalInvoiceApplied.toString(),
>> - "totalInvoiceNotApplied",totalInvoiceNotApplied.toString());
>> -finanSummary.put("totalPaymentNotApplied",totalPaymentNotApplied.toString());
>> -finanSummary.put("totalPaymentNotApplied",totalPaymentNotApplied.toString());
>> +finanSummary = ["totalSalesInvoice" : totalSalesInvoice.toString(),
>> +                "totalPurchaseInvoice" : totalPurchaseInvoice.toString(),
>> +                "totalPaymentsIn" : totalPaymentsIn.toString(),
>> +                "totalPaymentsOut" : totalPaymentsOut.toString(),
>> +                "totalInvoiceApplied" : totalInvoiceApplied.toString(),
>> +                "totalInvoiceNotApplied" : totalInvoiceNotApplied.toString()];
>> +finanSummary = ["totalPaymentNotApplied" : totalPaymentNotApplied.toString(),
>> +                "totalPaymentNotApplied" : totalPaymentNotApplied.toString()];
>> totalToBePaid = totalSalesInvoice.add(totalPurchaseInvoice).subtract(totalInvoiceApplied).subtract(totalPaymentNotApplied);
>> -if (totalToBePaid.compareTo(new BigDecimal("0.00")) < 0 ) finanSummary.put("totalToBePaid",totalToBePaid.toString());
>> -else if (totalToBePaid.compareTo(new BigDecimal("0.00")) > 0 ) finanSummary.put("totalToBeReceived",totalToBePaid.toString());
>> -else {
>> - finanSummary.put("totalToBePaid","0.00");
>> - finanSummary.put("totalToBeReceived","0.00");
>> +if (totalToBePaid.compareTo(new BigDecimal("0.00")) < 0 ) finanSummary.totalToBePaid = totalToBePaid.toString();
>> +else if (totalToBePaid.compareTo(new BigDecimal("0.00")) > 0 ) finanSummary.totalToBeReceived = totalToBePaid.toString();
>> +else    {
>> +    finanSummary = ["totalToBePaid" : "0.00",
>> +                    "totalToBeReceived" : "0.00"];
>> }
>> - context.put("finanSummary",finanSummary);
>> -
>> \ No newline at end of file
>> + context.finanSummary = finanSummary;
>> +
>> \ No newline at end of file
>>
>> Modified: ofbiz/trunk/applications/party/webapp/partymgr/party/PartyForms.xml
>> URL: 
>> http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/webapp/partymgr/party/PartyForms.xml?rev=698810&r1=698809&r2=698810&view=diff
>> ==============================================================================
>> --- ofbiz/trunk/applications/party/webapp/partymgr/party/PartyForms.xml (original)
>> +++ ofbiz/trunk/applications/party/webapp/partymgr/party/PartyForms.xml Wed Sep 24 21:06:09 2008
>> @@ -816,7 +816,7 @@
>>         <field name="effectiveDate"><display/></field>
>>         <field name="amount" widget-area-style="tabletextright"><display/></field>
>>         <field name="applied" widget-area-style="tabletextright"><display/></field>
>> -        <field name="toPaymentId"><hyperlink target="paymentOverview?paymentId=${paymentId}" 
>> description="${toPaymentId}"/></field>
>> +        <field name="toPaymentId"><hyperlink target="/accounting/control/paymentOverview?paymentId=${paymentId}" 
>> description="${toPaymentId}" target-type="inter-app"/></field>
>>         <field name="toEffectiveDate"><display/></field>
>>         <field name="toAmount" widget-area-style="tabletextright"><display/></field>
>>     </form>
>>
>> Modified: ofbiz/trunk/applications/party/widget/partymgr/PartyScreens.xml
>> URL: 
>> http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/widget/partymgr/PartyScreens.xml?rev=698810&r1=698809&r2=698810&view=diff
>> ==============================================================================
>> --- ofbiz/trunk/applications/party/widget/partymgr/PartyScreens.xml (original)
>> +++ ofbiz/trunk/applications/party/widget/partymgr/PartyScreens.xml Wed Sep 24 21:06:09 2008
>> @@ -983,7 +983,7 @@
>>                 <decorator-screen name="CommonPartyDecorator" location="${parameters.mainDecoratorLocation}">
>>                     <decorator-section name="body">
>>                         <container><label style="h1" text="Financial History"/></container>
>> -                        <screenlet title="${uiLabelMap.Invoices paid by payments}" navigation-form-name="Invoices">
>> +                        <screenlet title="${uiLabelMap.InvoicesPayments}" navigation-form-name="Invoices">
>>                             <include-form name="partyFinancialHistoryInvoices" 
>> location="component://party/webapp/partymgr/party/PartyForms.xml"/>
>>                         </screenlet>
>>                         <section>
>> @@ -993,8 +993,8 @@
>>                                 </not>
>>                             </condition>
>>                             <widgets>
>> -                                <screenlet title="${uiLabelMap.Invoices of other parties paid by payments from }${partyId}" 
>> navigation-form-name="PaymentsO">
>> -                                <include-form name="partyFinancialHistoryPaymentsO" 
>> location="component://party/webapp/partymgr/party/PartyForms.xml"/>
>> +                                <screenlet title="${uiLabelMap.InvoicesOtherParties}" 
>> navigation-form-name="partyFinancialHistoryPayments">
>> +                                    <include-form name="partyFinancialHistoryPaymentsO" 
>> location="component://party/webapp/partymgr/party/PartyForms.xml"/>
>>                                 </screenlet>
>>                             </widgets>
>>                         </section>
>> @@ -1005,9 +1005,8 @@
>>                                 </not>
>>                             </condition>
>>                             <widgets>
>> -                                <screenlet title="${uiLabelMap.Applied payments to payments" navigation-form-name="Payments">
>> -                                <container><label style="head1" text="Applied payments to payments"/></container>
>> -                                <include-form name="partyFinancialHistoryPayments" 
>> location="component://party/webapp/partymgr/party/PartyForms.xml"/>
>> +                                <screenlet title="${uiLabelMap.AppliedPayments}" 
>> navigation-form-name="partyFinancialHistoryPayments">
>> +                                    <include-form name="partyFinancialHistoryPayments" 
>> location="component://party/webapp/partymgr/party/PartyForms.xml"/>
>>                                 </screenlet>
>>                             </widgets>
>>                         </section>
>> @@ -1018,8 +1017,8 @@
>>                                 </not>
>>                             </condition>
>>                             <widgets>
>> -                                <screenlet title="${uiLabelMap.Invoices not yet (fully) applied}" 
>> navigation-form-name="InvoicesN">
>> -                                <include-form name="partyFinancialHistoryInvoicesN" 
>> location="component://party/webapp/partymgr/party/PartyForms.xml"/>
>> +                                <screenlet title="${uiLabelMap.InvoicesNotApplied}" 
>> navigation-form-name="partyFinancialHistoryInvoicesN">
>> +                                    <include-form name="partyFinancialHistoryInvoicesN" 
>> location="component://party/webapp/partymgr/party/PartyForms.xml"/>
>>                                 </screenlet>
>>                             </widgets>
>>                         </section>
>> @@ -1030,13 +1029,13 @@
>>                                 </not>
>>                             </condition>
>>                             <widgets>
>> -                                <screenlet title="${uiLabelMap.Payments not yet (fully) applied}" 
>> navigation-form-name="PaymentsN">
>> -                                <include-form name="partyFinancialHistoryPaymentsN" 
>> location="component://party/webapp/partymgr/party/PartyForms.xml"/>
>> +                                <screenlet title="${uiLabelMap.PaymentsNotApplied}" 
>> navigation-form-name="partyFinancialHistoryPaymentsN">
>> +                                    <include-form name="partyFinancialHistoryPaymentsN" 
>> location="component://party/webapp/partymgr/party/PartyForms.xml"/>
>>                                 </screenlet>
>>                             </widgets>
>>                         </section>
>> -                        <screenlet title="${uiLabelMap.Totals for Company:}${organizationPartyId}" 
>> navigation-form-name="Summary">
>> -                        <include-form name="partyFinancialSummary" 
>> location="component://party/webapp/partymgr/party/PartyForms.xml"/>
>> +                        <screenlet title="${uiLabelMap.PartyFinancialSummary}${organizationPartyId}" 
>> navigation-form-name="partyFinancialSummary">
>> +                            <include-form name="partyFinancialSummary" 
>> location="component://party/webapp/partymgr/party/PartyForms.xml"/>
>>                         </screenlet>
>>                     </decorator-section>
>>                 </decorator-screen>
>>
>>
> 


Re: svn commit: r698810 - in /ofbiz/trunk/applications/party: config/PartyUiLabels.xml webapp/partymgr/WEB-INF/actions/party/PartyFinancailHistory.groovy webapp/partymgr/party/PartyForms.xml widget/partymgr/PartyScreens.xml

Posted by Jacques Le Roux <ja...@les7arts.com>.
Hi Hans,

I wonder if this labels is right ? I can't see a meaning to translate.

> +    <property key="AppliedPayments">
> +        <value xml:lang="en">Applied payments to payments</value>
> +    </property>

Any help would be appreciated, thanks

Jacques

From: <ha...@apache.org>
> Author: hansbak
> Date: Wed Sep 24 21:06:09 2008
> New Revision: 698810
>
> URL: http://svn.apache.org/viewvc?rev=698810&view=rev
> Log:
> improved finanacial overview, replaced header and improoved groovy file....not perfect yet however improoved a lot..
>
> Modified:
>    ofbiz/trunk/applications/party/config/PartyUiLabels.xml
>    ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/party/PartyFinancailHistory.groovy
>    ofbiz/trunk/applications/party/webapp/partymgr/party/PartyForms.xml
>    ofbiz/trunk/applications/party/widget/partymgr/PartyScreens.xml
>
> Modified: ofbiz/trunk/applications/party/config/PartyUiLabels.xml
> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/config/PartyUiLabels.xml?rev=698810&r1=698809&r2=698810&view=diff
> ==============================================================================
> --- ofbiz/trunk/applications/party/config/PartyUiLabels.xml (original)
> +++ ofbiz/trunk/applications/party/config/PartyUiLabels.xml Wed Sep 24 21:06:09 2008
> @@ -180,6 +180,9 @@
>         <value xml:lang="en">Add Related Contact</value>
>         <value xml:lang="fr">Ajouter un contact associé</value>
>     </property>
> +    <property key="AppliedPayments">
> +        <value xml:lang="en">Applied payments to payments</value>
> +    </property>
>     <property key="Description">
>         <value xml:lang="de">Beschreibung</value>
>         <value xml:lang="en">Description</value>
> @@ -1249,6 +1252,15 @@
>         <value xml:lang="th">ปีกับผู้ว่าจ้าง</value>
>         <value xml:lang="zh">年为雇主</value>
>     </property>
> +    <property key="InvoicesNotApplied">
> +        <value xml:lang="en">Invoices not yet (fully) applied</value>
> +    </property>
> +    <property key="InvoicesOtherParties">
> +        <value xml:lang="en">Invoices of other parties paid by payments from</value>
> +    </property>
> +    <property key="InvoicesPayments">
> +        <value xml:lang="en">Invoices Payments</value>
> +    </property>
>     <property key="IsA"><!-- Peter 'is a' employee of company B -->
>         <value xml:lang="en">is A</value>
>         <value xml:lang="fr">est un</value>
> @@ -3806,6 +3818,9 @@
>         <value xml:lang="th">ประเภทผลที่ได้</value>
>         <value xml:lang="zh">事件类型</value>
>     </property>
> +    <property key="PartyFinancialSummary">
> +        <value xml:lang="en">Totals for Company:</value>
> +    </property>
>     <property key="PartyFindCommunicationEvents">
>         <value xml:lang="de">Suche Kommunikationsereignis</value>
>         <value xml:lang="en">Find Communication Events</value>
> @@ -7448,6 +7463,9 @@
>         <value xml:lang="pt_PT">Erro de Segurança: para correr a função de Comunicação de Remoção de Acontecimentos é 
> necessário obter o PARTYMGR_DELETE ou permissão de PARTYMGR_ADMIN</value>
>         <value xml:lang="th">Security Error: ในการย้ายสถานะผลการติดต่อ 
> คุณต้องได้รับอนุญาตจาก  PARTYMGR_DELETE หรือ PARTYMGR_ADMIN 
> ก่อน</value>
>     </property>
> +    <property key="PaymentsNotApplied">
> +        <value xml:lang="en">Payments not yet (fully) applied</value>
> +    </property>
>     <property key="commeventservices.communication_event_from_contact_mech_must_be_email">
>         <value xml:lang="de">FEHLER: Kommunikationsereignis muss ein "Kontaktmechanismus von" besitzen das ein E-Mail als 
> Kommunikationereignis ID ist</value>
>         <value xml:lang="en">ERROR: Communication event must have a from contact mech that is an email for comm event Id</value>
>
> Modified: ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/party/PartyFinancailHistory.groovy
> URL: 
> http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/party/PartyFinancailHistory.groovy?rev=698810&r1=698809&r2=698810&view=diff
> ==============================================================================
> --- ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/party/PartyFinancailHistory.groovy (original)
> +++ ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/party/PartyFinancailHistory.groovy Wed Sep 24 21:06:09 2008
> @@ -1,29 +1,21 @@
> /*
> - *  Copyright (c) 2001-2005 The Open For Business Project - www.ofbiz.org
> - *
> - *  Permission is hereby granted, free of charge, to any person obtaining a
> - *  copy of this software and associated documentation files (the "Software"),
> - *  to deal in the Software without restriction, including without limitation
> - *  the rights to use, copy, modify, merge, publish, distribute, sublicense,
> - *  and/or sell copies of the Software, and to permit persons to whom the
> - *  Software is furnished to do so, subject to the following conditions:
> - *
> - *  The above copyright notice and this permission notice shall be included
> - *  in all copies or substantial portions of the Software.
> - *
> - *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
> - *  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
> - *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
> - *  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
> - *  CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
> - *  OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
> - *  THE USE OR OTHER DEALINGS IN THE SOFTWARE.
> - *
> - *@author     Hans Bakker (h.bakker@antwebsystems.com)
> - *@version    $Rev$
> - *@since      3.0
> + * 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.
>  */
> -
> import java.util.*;
> import java.math.*;
> import java.sql.Timestamp;
> @@ -35,24 +27,24 @@
> import org.ofbiz.accounting.invoice.*;
> import org.ofbiz.accounting.payment.*;
>
> -delegator = parameters.get("delegator");
> -organizationPartyId = parameters.get("organizationPartyId");
> -partyId = parameters.get("partyId");
> +delegator = parameters.delegator;
> +organizationPartyId = parameters.organizationPartyId;
> +partyId = parameters.partyId;
> if (partyId == null && organizationPartyId == null) return;
> List historyList = new LinkedList();
>
> //get payment totals
> BigDecimal totalPaymentsIn = new BigDecimal("0.00").setScale(2,BigDecimal.ROUND_HALF_UP);
> BigDecimal totalPaymentsOut = new BigDecimal("0.00").setScale(2,BigDecimal.ROUND_HALF_UP);
> -tpayments = delegator.findByOr("Payment",[partyIdTo:partyId,partyIdFrom:partyId]);
> +tpayments = delegator.findByOr("Payment",["partyIdTo" : partyId,"partyIdFrom" : partyId]);
> Iterator pl = tpayments.iterator();
> while (pl.hasNext()) {
> - payment = pl.next();
> - if (payment.getString("statusId").equals("PMNT_CANCELLED")) continue;
> - if (payment.getString("partyIdTo").equals(organizationPartyId))
> - totalPaymentsIn = totalPaymentsIn.add(payment.getBigDecimal("amount")).setScale(2,BigDecimal.ROUND_HALF_UP);
> - else
> - totalPaymentsOut = totalPaymentsOut.add(payment.getBigDecimal("amount")).setScale(2,BigDecimal.ROUND_HALF_UP);
> +    payment = (GenericValue) pl.next();
> +    if (payment.statusId.equals("PMNT_CANCELLED")) continue;
> +    if (payment.partyIdTo.equals(organizationPartyId))
> +        totalPaymentsIn = totalPaymentsIn.add(payment.getBigDecimal("amount")).setScale(2,BigDecimal.ROUND_HALF_UP);
> +    else
> +        totalPaymentsOut = totalPaymentsOut.add(payment.getBigDecimal("amount")).setScale(2,BigDecimal.ROUND_HALF_UP);
> }
>
> // totals
> @@ -63,250 +55,241 @@
>
> // payment and invoices list which will be updated with the amount applied
> // to see what is left over...
> -List invoices = delegator.findByOr("Invoice",
> - UtilMisc.toMap("partyId",partyId,"partyIdFrom",partyId),
> - UtilMisc.toList("invoiceDate"));
> -List payments = delegator.findByOr("Payment",
> - UtilMisc.toMap("partyIdTo",partyId,"partyIdFrom",partyId),
> - UtilMisc.toList("effectiveDate"));
> -
> +List invoices = delegator.findByOr("Invoice",["partyId" : partyId , "partyIdFrom" : partyId] , ["invoiceDate"]);
> +List payments = delegator.findByOr("Payment",["partyIdTo" : partyId , "partyIdFrom" : partyId] , ["effectiveDate"]);
> +
> List notAppliedInvoices = new LinkedList(); // to store the not fully applied invoices
> -
> -// start reeading from the invoices list
> +
> +// start reading from the invoices list
> if (invoices != null && invoices.size() > 0) {
> - Iterator inv = invoices.iterator();
> - while (inv.hasNext()) {
> - invoice = inv.next();
> - if (invoice.getString("statusId").equals("INVOICE_CANCELLED")) continue;
> - BigDecimal invoiceAmount = InvoiceWorker.getInvoiceTotalBd(invoice).setScale(2,BigDecimal.ROUND_HALF_UP);
> - invoiceApplied = InvoiceWorker.getInvoiceAppliedBd(invoice).setScale(2,BigDecimal.ROUND_HALF_UP);
> -/* if (invoice.getString("partyId").equals(organizationPartyId)) { //negate for outgoing payments
> - invoiceAmount = invoiceAmount.multiply(new BigDecimal("-1"));
> - invoiceApplied = invoiceApplied.multiply(new BigDecimal("-1"));
> - }
> -*/ if (invoice.getString("invoiceTypeId").equals("PURCHASE_INVOICE")) totalPurchaseInvoice = 
> totalPurchaseInvoice.add(invoiceAmount);
> - if (invoice.getString("invoiceTypeId").equals("SALES_INVOICE")) totalSalesInvoice = totalSalesInvoice.add(invoiceAmount);
> - totalInvoiceApplied = totalInvoiceApplied.add(invoiceApplied);
> -// Debug.logInfo("Invoice type: "+ invoice.getString("invoiceTypeId") + "amount: " + invoiceAmount + " applied: " + 
> invoiceApplied,"??");
> - if (!invoiceAmount.equals(invoiceApplied)) {
> - Map notAppliedInvoice = UtilMisc.toMap(
> - "invoiceId",invoice.getString("invoiceId"),
> - "invoiceTypeId", invoice.getString("invoiceTypeId").substring(0,1),
> - "invoiceDate", invoice.getString("invoiceDate").substring(0,10),
> - "invoiceAmount", invoiceAmount.toString(),
> - "invoiceNotApplied", invoiceAmount.subtract(invoiceApplied).toString());
> - notAppliedInvoices.add(notAppliedInvoice);
> - totalInvoiceNotApplied = totalInvoiceNotApplied.add(invoiceAmount).subtract(invoiceApplied);
> - }
> - Map historyItem = UtilMisc.toMap(
> - "invoiceId",invoice.getString("invoiceId"),
> - "invoiceTypeId", invoice.getString("invoiceTypeId").substring(0,1),
> - "invoiceDate", invoice.getString("invoiceDate").substring(0,10),
> - "invoiceAmount", invoiceAmount.toString(),
> - "totInvoiceApplied", invoiceApplied.toString()
> - );
> -
> - // check for applications
> - List applications = invoice.getRelated("PaymentApplication",null,UtilMisc.toList("paymentId"));
> - if (applications != null && applications.size() > 0) {
> - Iterator appl = applications.iterator();
> - oldPaymentId = new String(" ");
> - BigDecimal applied = new BigDecimal("0");
> - boolean first = true;
> - while (appl.hasNext()) { // read the applications for this invoice
> - application = appl.next();
> - paymentId = application.getString("paymentId");
> -
> - //reduce the payment amount in the payment list
> - pl = payments.iterator();
> - while (pl.hasNext()) {
> - payment = pl.next();
> - if (paymentId.equals(payment.getString("paymentId"))) {
> - plInd = payments.indexOf(payment);
> - payment.put("amount",
> - payment.getBigDecimal("amount").
> - subtract(application.getBigDecimal("amountApplied")).doubleValue());
> - payments.remove(plInd);
> - payments.add(plInd,payment);
> - break;
> - }
> - }
> -
> - // check if the payment number has changed, then we have to output a line....
> - if (!first && !paymentId.equals(oldPaymentId)) { // if the payment number has changed, but not the first
> - historyItem.put("applied", applied.toString());
> - historyItem.put("paymentId", oldPaymentId);
> - payment = delegator.findByPrimaryKey("Payment",UtilMisc.toMap("paymentId",oldPaymentId));
> - BigDecimal amount = payment.getBigDecimal("amount").setScale(2,BigDecimal.ROUND_HALF_UP);
> -// if (payment.getString("partyIdFrom").equals(organizationPartyId)) amount = amount.multiply(new BigDecimal("-1"));
> - historyItem.put("amount",amount.toString());
> - historyItem.put("effectiveDate",payment.getString("effectiveDate").substring(0,10));
> - historyList.add(historyItem);
> - historyItem = new HashMap();
> - applied = new BigDecimal("0");
> - }
> - applied = applied.add(application.getBigDecimal("amountApplied")).setScale(2,BigDecimal.ROUND_HALF_UP);
> - oldPaymentId = paymentId;
> - first = false;
> - }
> - if (!applied.equals("0")) {
> - historyItem.put("applied", applied.toString());
> - historyItem.put("paymentId", oldPaymentId);
> - payment = delegator.findByPrimaryKey("Payment",UtilMisc.toMap("paymentId",oldPaymentId));
> - if (payment != null) {
> - BigDecimal amount = payment.getBigDecimal("amount").setScale(2,BigDecimal.ROUND_HALF_UP);
> -// if (payment.getString("partyIdFrom").equals(organizationPartyId)) amount = amount.multiply(new BigDecimal("-1"));
> - historyItem.put("amount",amount.toString());
> - historyItem.put("effectiveDate",payment.getString("effectiveDate").substring(0,10));
> - historyList.add(historyItem);
> - }
> - }
> - }
> - }
> - context.put("historyListInvoices",historyList);
> +    Iterator inv = invoices.iterator();
> +    while (inv.hasNext())   {
> +        invoice = (GenericValue) inv.next();
> +        if (invoice.statusId.equals("INVOICE_CANCELLED")) continue;
> +        BigDecimal invoiceAmount = InvoiceWorker.getInvoiceTotalBd(invoice).setScale(2,BigDecimal.ROUND_HALF_UP);
> +        invoiceApplied = InvoiceWorker.getInvoiceAppliedBd(invoice).setScale(2,BigDecimal.ROUND_HALF_UP);
> +/*      if (invoice.getString("partyId").equals(organizationPartyId)) { //negate for outgoing payments
> +            invoiceAmount = invoiceAmount.multiply(new BigDecimal("-1"));
> +            invoiceApplied = invoiceApplied.multiply(new BigDecimal("-1"));
> +        }
> +*/      if (invoice.invoiceTypeId.equals("PURCHASE_INVOICE")) totalPurchaseInvoice = totalPurchaseInvoice.add(invoiceAmount);
> +        if (invoice.invoiceTypeId.equals("SALES_INVOICE")) totalSalesInvoice = totalSalesInvoice.add(invoiceAmount);
> +        totalInvoiceApplied = totalInvoiceApplied.add(invoiceApplied);
> +//      Debug.logInfo("Invoice type: "+ invoice.getString("invoiceTypeId") + "amount: " + invoiceAmount + " applied: " + 
> invoiceApplied,"??");
> +        if (!invoiceAmount.equals(invoiceApplied))  {
> +            Map notAppliedInvoice = ["invoiceId" : invoice.invoiceId,
> +                                     "invoiceTypeId" : invoice.invoiceTypeId.substring(0,1),
> +                                     "invoiceDate" : invoice.invoiceDate.toString().substring(0,10),
> +                                     "invoiceAmount" : invoiceAmount.toString(),
> +                                     "invoiceNotApplied" : invoiceAmount.subtract(invoiceApplied).toString()];
> +                notAppliedInvoices.add(notAppliedInvoice);
> +                totalInvoiceNotApplied = totalInvoiceNotApplied.add(invoiceAmount).subtract(invoiceApplied);
> +        }
> +        Map historyItem = ["invoiceId" : invoice.invoiceId,
> +                           "invoiceTypeId" : invoice.invoiceTypeId.substring(0,1),
> +                           "invoiceDate" : invoice.invoiceDate.toString().substring(0,10),
> +                           "invoiceAmount" : invoiceAmount.toString(),
> +                           "totInvoiceApplied" : invoiceApplied.toString()
> +            ];
> +        // check for applications
> +        List applications = invoice.getRelated("PaymentApplication",null,["paymentId"]);
> +        if (applications != null && applications.size() > 0) {
> +            Iterator appl = applications.iterator();
> +            oldPaymentId = new String(" ");
> +            BigDecimal applied = new BigDecimal("0");
> +            boolean first = true;
> +            while (appl.hasNext())  {   // read the applications for this invoice
> +                application = (GenericValue) appl.next();
> +                paymentId = application.paymentId;
> +
> +                //reduce the payment amount in the payment list
> +                pl = payments.iterator();
> +                while (pl.hasNext()) {
> +                    payment = (GenericValue) pl.next();
> +                    if (paymentId.equals(payment.paymentId)) {
> +                        plInd = payments.indexOf(payment);
> +                        payment.amount = 
> payment.getBigDecimal("amount").subtract(application.getBigDecimal("amountApplied")).doubleValue();
> +                        payments.remove(plInd);
> +                        payments.add(plInd,payment);
> +                        break;
> +                    }
> +                }
> +
> +                // check if the payment number has changed, then we have to output a line....
> +                if (!first && !paymentId.equals(oldPaymentId)) { // if the payment number has changed, but not the first
> +                    payment = delegator.findByPrimaryKey("Payment",["paymentId" : oldPaymentId]);
> +                    BigDecimal amount = payment.getBigDecimal("amount").setScale(2,BigDecimal.ROUND_HALF_UP);
> +//                  if (payment.getString("partyIdFrom").equals(organizationPartyId)) amount = amount.multiply(new 
> BigDecimal("-1"));
> +                    historyItem = ["applied" : applied.toString(),
> +                                   "paymentId" : oldPaymentId,
> +                                   "amount" : amount.toString(),
> +                                   "effectiveDate" : payment.effectiveDate.toString().substring(0,10)];
> +                    historyList.add(historyItem);
> +                    historyItem = new HashMap();
> +                    applied = new BigDecimal("0");
> +                }
> +                applied = applied.add(application.getBigDecimal("amountApplied")).setScale(2,BigDecimal.ROUND_HALF_UP);
> +                oldPaymentId = paymentId;
> +                first = false;
> +            }
> +            if (!applied.equals("0")) {
> +                payment = delegator.findByPrimaryKey("Payment",["paymentId" : oldPaymentId]);
> +                if (payment != null) {
> +                    BigDecimal amount = payment.getBigDecimal("amount").setScale(2,BigDecimal.ROUND_HALF_UP);
> +//                  if (payment.getString("partyIdFrom").equals(organizationPartyId))   amount = amount.multiply(new 
> BigDecimal("-1"));
> +                    historyItem = ["invoiceId" : invoice.invoiceId,
> +                                   "invoiceTypeId" : invoice.invoiceTypeId.substring(0,1),
> +                                   "invoiceDate" : invoice.invoiceDate.toString().substring(0,10),
> +                                   "invoiceAmount" : invoiceAmount.toString(),
> +                                   "totInvoiceApplied" : invoiceApplied.toString(),
> +                                   "applied" : applied.toString(),
> +                                   "paymentId" : oldPaymentId,
> +                                   "amount" : amount.toString(),
> +                                   "effectiveDate" : payment.effectiveDate.toString().substring(0,10)];
> +                    historyList.add(historyItem);
> +                }
> +            }
> +        }
> +    }
> +    context.historyListInvoices = historyList;
> }
>
> // totals
> BigDecimal totalPaymentApplied = new BigDecimal("0.00").setScale(2,BigDecimal.ROUND_HALF_UP);
> // list of payments where payments are applied
> historyList = new LinkedList();
> -if (payments != null && payments.size() > 0) {
> - pay = payments.iterator();
> - while (pay.hasNext()) {
> - payment = pay.next();
> - if (payment.getString("statusId").equals("PMNT_CANCELLED")) continue;
> - List applications = payment.getRelated("ToPaymentApplication",null,UtilMisc.toList("paymentId"));
> - if (applications == null || applications.size() == 0 ) continue; // none found
> - Map historyItem = 
> UtilMisc.toMap("paymentId",payment.getString("paymentId"),"effectiveDate",payment.getString("effectiveDate").substring(0,10));
> - BigDecimal amount = payment.getBigDecimal("amount").setScale(2,BigDecimal.ROUND_HALF_UP);
> -// if (payment.getString("partyIdFrom").equals(organizationPartyId)) amount = amount.multiply(new BigDecimal("-1"));
> - historyItem.put("amount",amount.toString());
> - ap = applications.iterator();
> - while (ap.hasNext()) {
> - GenericValue application = ap.next();
> - historyItem.put("toPaymentId",application.getString("paymentId"));
> - historyItem.put("applied",application.getString("amountApplied"));
> - toPayment = application.getRelatedOne("Payment");
> - historyItem.put("toEffectiveDate",toPayment.getString("effectiveDate").substring(0,10));
> - toAmount = toPayment.getBigDecimal("amount").setScale(2,BigDecimal.ROUND_HALF_UP);
> -// if (toPayment.getString("partyIdFrom").equals(organizationPartyId)) toAmount = toAmount.multiply(new BigDecimal("-1"));
> - historyItem.put("toAmount",toAmount.toString());
> - historyList.add(historyItem);
> -
> - //reduce the payment amount in the payment list
> - pl = payments.iterator();
> - while (pl.hasNext()) {
> - payment = pl.next();
> - // reduce paymentId
> - if (application.getString("paymentId").equals(payment.getString("paymentId"))) {
> - plInd = payments.indexOf(payment);
> - payment.put("amount",
> - payment.getBigDecimal("amount").
> - subtract(application.getBigDecimal("amountApplied")).doubleValue());
> - payments.remove(plInd);
> - payments.add(plInd,payment);
> - totalPaymentApplied = totalPaymentApplied.add(application.getBigDecimal("amountApplied"));
> - }
> - // reduce toPaymentId
> - if (application.getString("toPaymentId").equals(payment.getString("paymentId"))) {
> - plInd = payments.indexOf(payment);
> - payment.put("amount",
> - payment.getBigDecimal("amount").
> - subtract(application.getBigDecimal("amountApplied")).doubleValue());
> - payments.remove(plInd);
> - payments.add(plInd,payment);
> - totalPaymentApplied = totalPaymentApplied.add(application.getBigDecimal("amountApplied"));
> - }
> - }
> - }
> - }
> - context.put("historyListPayments",historyList);
> +if (payments) {
> +    pay = payments.iterator();
> +    while (pay.hasNext())   {
> +        payment = (GenericValue) pay.next();
> +        if (payment.statusId.equals("PMNT_CANCELLED")) continue;
> +        applications = payment.getRelated("PaymentApplication", ["paymentId"]);
> +        if (!applications) continue; // none found
> +        Map historyItem = ["paymentId" : payment.paymentId , "effectiveDate" : payment.effectiveDate.toString().substring(0,10)];
> +        BigDecimal amount = payment.getBigDecimal("amount").setScale(2,BigDecimal.ROUND_HALF_UP);
> +        if (payment.partyIdFrom.equals(organizationPartyId)) {
> +            amount = amount.multiply(new BigDecimal("-1"));
> +        }
> +        historyItem.amount = amount.toString();
> +        ap = applications.iterator();
> +        while (ap.hasNext())    {
> +            application = (GenericValue) ap.next();
> +            historyItem = ["toPaymentId" : application.paymentId,
> +                           "applied" : application.amountApplied];
> +            toPayment = application.getRelatedOne("Payment");
> +            historyItem.toEffectiveDate = toPayment.effectiveDate.toString().substring(0,10);
> +            toAmount = toPayment.getBigDecimal("amount").setScale(2,BigDecimal.ROUND_HALF_UP);
> +            if (toPayment.partyIdFrom.equals(organizationPartyId)) toAmount = toAmount.multiply(new BigDecimal("-1"));
> +            //reduce the payment amount in the payment list
> +            pl = payments.iterator();
> +            while (pl.hasNext()) {
> +                payment = (GenericValue) pl.next();
> +                // reduce paymentId
> +                if (application.paymentId.equals(payment.paymentId)) {
> +                    plInd = payments.indexOf(payment);
> +                    payment.amount =
> +                            payment.getBigDecimal("amount").
> +                            subtract(application.getBigDecimal("amountApplied")).doubleValue();
> +                    payments.remove(plInd);
> +                    payments.add(plInd,payment);
> +                    totalPaymentApplied = totalPaymentApplied.add(application.getBigDecimal("amountApplied"));
> +                }
> +                // reduce toPaymentId
> +                if (application.toPaymentId.equals(payment.paymentId)) {
> +                    plInd = payments.indexOf(payment);
> +                    payment.amount =
> +                            payment.getBigDecimal("amount").
> +                            subtract(application.getBigDecimal("amountApplied")).doubleValue();
> +                    payments.remove(plInd);
> +                    payments.add(plInd,payment);
> +                    totalPaymentApplied = totalPaymentApplied.add(application.getBigDecimal("amountApplied"));
> +                }
> +            }
> +        }
> +    }
> +    context.historyListPayments = historyList;
> }
>
> -
> // check if any invoices left not applied
> if (notAppliedInvoices != null && notAppliedInvoices.size() > 0) {
> - context.put("historyListInvoicesN",notAppliedInvoices);
> +    context.historyListInvoicesN = notAppliedInvoices;
> }
> -
> -
> +
> // list payments applied to other companies
> historyList = new LinkedList();
> if (payments != null && payments.size() > 0) {
> - Iterator pm = payments.iterator();
> - while (pm.hasNext()) {
> - payment = pm.next();
> - // check if payment completely applied
> - BigDecimal amount = payment.getBigDecimal("amount").setScale(2,BigDecimal.ROUND_HALF_UP);
> - if (amount.compareTo(new BigDecimal("0.00")) == 0)
> - continue;
> - Debug.logInfo(" other company payments: " + payment.getString("paymentId") + " amount:" + payment.getBigDecimal("amount") + " 
> applied:" + PaymentWorker.getPaymentAppliedBd(payment),"??");
> - List paymentApplications = payment.getRelated("PaymentApplication");
> - Iterator pa = paymentApplications.iterator();
> - while (pa.hasNext()) {
> - GenericValue paymentApplication = pa.next();
> - if (paymentApplication.get("invoiceId") != null) {
> - GenericValue invoice = paymentApplication.getRelatedOne("Invoice");
> - if (!invoice.getString("partyId").equals(partyId)) {
> - historyItem = new HashMap();
> - historyItem.put("paymentId",payment.getString("paymentId"));
> - historyItem.put("invoiceId",paymentApplication.getString("invoiceId"));
> - historyItem.put("invoiceItemSeqId",paymentApplication.getString("invoiceItemSeqId"));
> - historyItem.put("partyId",invoice.getString("partyIdFrom"));
> - historyItem.put("amount",amount.toString());
> - historyItem.put("applied",paymentApplication.getBigDecimal("amountApplied").setScale(2,BigDecimal.ROUND_HALF_UP).toString());
> - historyItem.put("effectiveDate",payment.getString("effectiveDate").substring(0,10));
> - historyList.add(historyItem);
> - }
> - }
> - }
> - }
> - context.put("historyListPaymentsO",historyList);
> +    Iterator pm = payments.iterator();
> +    while (pm.hasNext())    {
> +        payment = (GenericValue) pm.next();
> +        // check if payment completely applied
> +        BigDecimal amount = payment.getBigDecimal("amount").setScale(2,BigDecimal.ROUND_HALF_UP);
> +        if (amount.compareTo(new BigDecimal("0.00")) == 0)
> +            continue;
> +        Debug.logInfo(" other company payments: " + payment.paymentId + " amount:" + payment.getBigDecimal("amount") + " 
> applied:" + PaymentWorker.getPaymentAppliedBd(payment),"??");
> +        List paymentApplications = payment.getRelated("PaymentApplication");
> +        Iterator pa = paymentApplications.iterator();
> +        while (pa.hasNext())    {
> +            paymentApplication = (GenericValue) pa.next();
> +            if (paymentApplication.invoiceId != null) {
> +                invoice = paymentApplication.getRelatedOne("Invoice");
> +                if (!invoice.partyId.equals(partyId)) {
> +                    historyItem = new HashMap();
> +                    Map historyItem = ["paymentId" : payment.paymentId,
> +                                       "invoiceId" : paymentApplication.invoiceId,
> +                                       "invoiceItemSeqId" : paymentApplication.invoiceItemSeqId,
> +                                       "partyId" : invoice.partyIdFrom,
> +                                       "amount" : amount.toString(),
> +                                       "applied" : 
> paymentApplication.getBigDecimal("amountApplied").setScale(2,BigDecimal.ROUND_HALF_UP).toString(),
> +                                       "effectiveDate" : payment.effectiveDate.toString().substring(0,10)];
> +                    historyList.add(historyItem);
> +                }
> +            }
> +        }
> +    }
> +    context.historyListPaymentsO = historyList;
> }
>
> // list not applied payments
> BigDecimal totalPaymentNotApplied = new BigDecimal("0.00").setScale(2,BigDecimal.ROUND_HALF_UP);
> historyList = new LinkedList();
> if (payments != null && payments.size() > 0) {
> - Iterator pm = payments.iterator();
> - while (pm.hasNext()) {
> - payment = pm.next();
> - payment = delegator.findByPrimaryKey("Payment",UtilMisc.toMap("paymentId",payment.getString("paymentId")));
> - notApplied = 
> payment.getBigDecimal("amount").subtract(PaymentWorker.getPaymentAppliedBd(payment)).setScale(2,BigDecimal.ROUND_HALF_UP);
> - // check if payment completely applied
> - Debug.logInfo(" payment: " + payment.getString("paymentId") + " amount:" + payment.getBigDecimal("amount") + " applied:" + 
> PaymentWorker.getPaymentAppliedBd(payment),"??");
> - if (notApplied.compareTo(new BigDecimal("0.00")) == 0)
> - continue;
> - historyItem = new HashMap();
> - historyItem.put("paymentId",payment.getString("paymentId"));
> - BigDecimal amount = payment.getBigDecimal("amount").setScale(2,BigDecimal.ROUND_HALF_UP);
> - totalPaymentNotApplied = totalPaymentNotApplied.add(notApplied);
> - historyItem.put("amount",amount.toString());
> - historyItem.put("notApplied",notApplied.toString());
> - historyItem.put("effectiveDate",payment.getString("effectiveDate").substring(0,10));
> - historyList.add(historyItem);
> - }
> - context.put("historyListPaymentsN",historyList);
> +    Iterator pm = payments.iterator();
> +    while (pm.hasNext())    {
> +        payment = (GenericValue) pm.next();
> +        payment = delegator.findByPrimaryKey("Payment",["paymentId" : payment.paymentId]);
> +        notApplied = 
> payment.getBigDecimal("amount").subtract(PaymentWorker.getPaymentAppliedBd(payment)).setScale(2,BigDecimal.ROUND_HALF_UP);
> +        // check if payment completely applied
> +        Debug.logInfo(" payment: " + payment.paymentId + " amount:" + payment.getBigDecimal("amount") + " applied:" + 
> PaymentWorker.getPaymentAppliedBd(payment),"??");
> +        if (notApplied.compareTo(new BigDecimal("0.00")) == 0)
> +            continue;
> +        Map historyItem = new HashMap();
> +        BigDecimal amount = payment.getBigDecimal("amount").setScale(2,BigDecimal.ROUND_HALF_UP);
> +        totalPaymentNotApplied = totalPaymentNotApplied.add(notApplied);
> +        historyItem = ["paymentId" : payment.paymentId,
> +                       "amount" : amount.toString(),
> +                       "notApplied" : notApplied.toString(),
> +                       "effectiveDate" : payment.effectiveDate.toString().substring(0,10)];
> +        historyList.add(historyItem);
> +    }
> +    context.historyListPaymentsN = historyList;
> }
>
> -
> // create totals
>
> -finanSummary = UtilMisc.toMap(
> - "totalSalesInvoice",totalSalesInvoice.toString(),
> - "totalPurchaseInvoice",totalPurchaseInvoice.toString(),
> - "totalPaymentsIn",totalPaymentsIn.toString(),
> - "totalPaymentsOut",totalPaymentsOut.toString(),
> - "totalInvoiceApplied",totalInvoiceApplied.toString(),
> - "totalInvoiceNotApplied",totalInvoiceNotApplied.toString());
> -finanSummary.put("totalPaymentNotApplied",totalPaymentNotApplied.toString());
> -finanSummary.put("totalPaymentNotApplied",totalPaymentNotApplied.toString());
> +finanSummary = ["totalSalesInvoice" : totalSalesInvoice.toString(),
> +                "totalPurchaseInvoice" : totalPurchaseInvoice.toString(),
> +                "totalPaymentsIn" : totalPaymentsIn.toString(),
> +                "totalPaymentsOut" : totalPaymentsOut.toString(),
> +                "totalInvoiceApplied" : totalInvoiceApplied.toString(),
> +                "totalInvoiceNotApplied" : totalInvoiceNotApplied.toString()];
> +finanSummary = ["totalPaymentNotApplied" : totalPaymentNotApplied.toString(),
> +                "totalPaymentNotApplied" : totalPaymentNotApplied.toString()];
> totalToBePaid = totalSalesInvoice.add(totalPurchaseInvoice).subtract(totalInvoiceApplied).subtract(totalPaymentNotApplied);
> -if (totalToBePaid.compareTo(new BigDecimal("0.00")) < 0 ) finanSummary.put("totalToBePaid",totalToBePaid.toString());
> -else if (totalToBePaid.compareTo(new BigDecimal("0.00")) > 0 ) finanSummary.put("totalToBeReceived",totalToBePaid.toString());
> -else {
> - finanSummary.put("totalToBePaid","0.00");
> - finanSummary.put("totalToBeReceived","0.00");
> +if (totalToBePaid.compareTo(new BigDecimal("0.00")) < 0 ) finanSummary.totalToBePaid = totalToBePaid.toString();
> +else if (totalToBePaid.compareTo(new BigDecimal("0.00")) > 0 ) finanSummary.totalToBeReceived = totalToBePaid.toString();
> +else    {
> +    finanSummary = ["totalToBePaid" : "0.00",
> +                    "totalToBeReceived" : "0.00"];
> }
> - context.put("finanSummary",finanSummary);
> -
> \ No newline at end of file
> + context.finanSummary = finanSummary;
> +
> \ No newline at end of file
>
> Modified: ofbiz/trunk/applications/party/webapp/partymgr/party/PartyForms.xml
> URL: 
> http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/webapp/partymgr/party/PartyForms.xml?rev=698810&r1=698809&r2=698810&view=diff
> ==============================================================================
> --- ofbiz/trunk/applications/party/webapp/partymgr/party/PartyForms.xml (original)
> +++ ofbiz/trunk/applications/party/webapp/partymgr/party/PartyForms.xml Wed Sep 24 21:06:09 2008
> @@ -816,7 +816,7 @@
>         <field name="effectiveDate"><display/></field>
>         <field name="amount" widget-area-style="tabletextright"><display/></field>
>         <field name="applied" widget-area-style="tabletextright"><display/></field>
> -        <field name="toPaymentId"><hyperlink target="paymentOverview?paymentId=${paymentId}" 
> description="${toPaymentId}"/></field>
> +        <field name="toPaymentId"><hyperlink target="/accounting/control/paymentOverview?paymentId=${paymentId}" 
> description="${toPaymentId}" target-type="inter-app"/></field>
>         <field name="toEffectiveDate"><display/></field>
>         <field name="toAmount" widget-area-style="tabletextright"><display/></field>
>     </form>
>
> Modified: ofbiz/trunk/applications/party/widget/partymgr/PartyScreens.xml
> URL: 
> http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/widget/partymgr/PartyScreens.xml?rev=698810&r1=698809&r2=698810&view=diff
> ==============================================================================
> --- ofbiz/trunk/applications/party/widget/partymgr/PartyScreens.xml (original)
> +++ ofbiz/trunk/applications/party/widget/partymgr/PartyScreens.xml Wed Sep 24 21:06:09 2008
> @@ -983,7 +983,7 @@
>                 <decorator-screen name="CommonPartyDecorator" location="${parameters.mainDecoratorLocation}">
>                     <decorator-section name="body">
>                         <container><label style="h1" text="Financial History"/></container>
> -                        <screenlet title="${uiLabelMap.Invoices paid by payments}" navigation-form-name="Invoices">
> +                        <screenlet title="${uiLabelMap.InvoicesPayments}" navigation-form-name="Invoices">
>                             <include-form name="partyFinancialHistoryInvoices" 
> location="component://party/webapp/partymgr/party/PartyForms.xml"/>
>                         </screenlet>
>                         <section>
> @@ -993,8 +993,8 @@
>                                 </not>
>                             </condition>
>                             <widgets>
> -                                <screenlet title="${uiLabelMap.Invoices of other parties paid by payments from }${partyId}" 
> navigation-form-name="PaymentsO">
> -                                <include-form name="partyFinancialHistoryPaymentsO" 
> location="component://party/webapp/partymgr/party/PartyForms.xml"/>
> +                                <screenlet title="${uiLabelMap.InvoicesOtherParties}" 
> navigation-form-name="partyFinancialHistoryPayments">
> +                                    <include-form name="partyFinancialHistoryPaymentsO" 
> location="component://party/webapp/partymgr/party/PartyForms.xml"/>
>                                 </screenlet>
>                             </widgets>
>                         </section>
> @@ -1005,9 +1005,8 @@
>                                 </not>
>                             </condition>
>                             <widgets>
> -                                <screenlet title="${uiLabelMap.Applied payments to payments" navigation-form-name="Payments">
> -                                <container><label style="head1" text="Applied payments to payments"/></container>
> -                                <include-form name="partyFinancialHistoryPayments" 
> location="component://party/webapp/partymgr/party/PartyForms.xml"/>
> +                                <screenlet title="${uiLabelMap.AppliedPayments}" 
> navigation-form-name="partyFinancialHistoryPayments">
> +                                    <include-form name="partyFinancialHistoryPayments" 
> location="component://party/webapp/partymgr/party/PartyForms.xml"/>
>                                 </screenlet>
>                             </widgets>
>                         </section>
> @@ -1018,8 +1017,8 @@
>                                 </not>
>                             </condition>
>                             <widgets>
> -                                <screenlet title="${uiLabelMap.Invoices not yet (fully) applied}" 
> navigation-form-name="InvoicesN">
> -                                <include-form name="partyFinancialHistoryInvoicesN" 
> location="component://party/webapp/partymgr/party/PartyForms.xml"/>
> +                                <screenlet title="${uiLabelMap.InvoicesNotApplied}" 
> navigation-form-name="partyFinancialHistoryInvoicesN">
> +                                    <include-form name="partyFinancialHistoryInvoicesN" 
> location="component://party/webapp/partymgr/party/PartyForms.xml"/>
>                                 </screenlet>
>                             </widgets>
>                         </section>
> @@ -1030,13 +1029,13 @@
>                                 </not>
>                             </condition>
>                             <widgets>
> -                                <screenlet title="${uiLabelMap.Payments not yet (fully) applied}" 
> navigation-form-name="PaymentsN">
> -                                <include-form name="partyFinancialHistoryPaymentsN" 
> location="component://party/webapp/partymgr/party/PartyForms.xml"/>
> +                                <screenlet title="${uiLabelMap.PaymentsNotApplied}" 
> navigation-form-name="partyFinancialHistoryPaymentsN">
> +                                    <include-form name="partyFinancialHistoryPaymentsN" 
> location="component://party/webapp/partymgr/party/PartyForms.xml"/>
>                                 </screenlet>
>                             </widgets>
>                         </section>
> -                        <screenlet title="${uiLabelMap.Totals for Company:}${organizationPartyId}" 
> navigation-form-name="Summary">
> -                        <include-form name="partyFinancialSummary" 
> location="component://party/webapp/partymgr/party/PartyForms.xml"/>
> +                        <screenlet title="${uiLabelMap.PartyFinancialSummary}${organizationPartyId}" 
> navigation-form-name="partyFinancialSummary">
> +                            <include-form name="partyFinancialSummary" 
> location="component://party/webapp/partymgr/party/PartyForms.xml"/>
>                         </screenlet>
>                     </decorator-section>
>                 </decorator-screen>
>
>