Tag for Release apache-ofbiz-12.04.04

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/tags/REL-12.04.04@1615061 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceWorker.java b/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceWorker.java
index 2d7d40f..2c06e8b 100644
--- a/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceWorker.java
+++ b/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceWorker.java
@@ -517,7 +517,10 @@
             List<GenericValue> acctgTransEntries = invoice.getRelated("AcctgTrans");
             if (UtilValidate.isNotEmpty(acctgTransEntries)) {
                 GenericValue acctgTransEntry = (acctgTransEntries.get(0)).getRelated("AcctgTransEntry").get(0);
-                conversionRate = acctgTransEntry.getBigDecimal("amount").divide(acctgTransEntry.getBigDecimal("origAmount"), new MathContext(100)).setScale(decimals,rounding);
+                BigDecimal origAmount = acctgTransEntry.getBigDecimal("origAmount");
+                if (origAmount.compareTo(ZERO) == 1) {
+                    conversionRate = acctgTransEntry.getBigDecimal("amount").divide(acctgTransEntry.getBigDecimal("origAmount"), new MathContext(100)).setScale(decimals,rounding);
+                }
             }
             // check if a payment is applied and use the currency conversion from there
             if (UtilValidate.isEmpty(conversionRate)) {
diff --git a/applications/content/script/org/ofbiz/content/content/ContentServices.xml b/applications/content/script/org/ofbiz/content/content/ContentServices.xml
index 10ace66..460c372 100644
--- a/applications/content/script/org/ofbiz/content/content/ContentServices.xml
+++ b/applications/content/script/org/ofbiz/content/content/ContentServices.xml
@@ -778,10 +778,10 @@
             <results-to-map map-name="persistOut"/>
         </call-service>
 
-        <set-service-fields service-name="createCommContentDataResource" mode="OUT" map="persistOut" to-map="filteredPersistOut"/>
-        <iterate-map key="key" value="val" map="filteredPersistOut">
+        <iterate-map key="key" value="val" map="persistOut">
             <field-to-result field="val" result-name="${key}"/>
         </iterate-map>
+
         <set field="mapIn.contentId"  from-field="persistOut.contentId"/>
         <!-- <set field="mapIn.fromDate"  from-field="nowTimestamp"/> -->
         <set field="mapIn.communicationEventId"  from-field="parameters.communicationEventId"/>
diff --git a/applications/content/servicedef/secas.xml b/applications/content/servicedef/secas.xml
index 5cd246f..f8b25c1 100644
--- a/applications/content/servicedef/secas.xml
+++ b/applications/content/servicedef/secas.xml
@@ -105,7 +105,7 @@
     </eca>
 
     <!-- electronic text; needs dataResourceId -->
-    <eca service="createElectronicText" event="in-validate">
+    <eca service="createElectronicText" event="invoke">
         <condition field-name="dataResourceId" operator="is-empty"/>
         <set field-name="dataResourceTypeId" value="ELECTRONIC_TEXT"/>
         <action service="createDataResource" mode="sync" result-to-context="true"/>
diff --git a/applications/order/servicedef/secas.xml b/applications/order/servicedef/secas.xml
index adbfcea..50111e0 100644
--- a/applications/order/servicedef/secas.xml
+++ b/applications/order/servicedef/secas.xml
@@ -87,7 +87,7 @@
         <action service="releaseOrderPayments" mode="sync"/>
         <action service="processRefundReturnForReplacement" mode="sync"/>
     </eca>
-    <eca service="changeOrderStatus" event="global-commit" run-on-error="false">
+    <eca service="changeOrderStatus" event="global-commit-post-run" run-on-error="false">
         <condition field-name="statusId" operator="equals" value="ORDER_COMPLETED"/>
         <condition-field field-name="statusId" operator="not-equals" to-field-name="oldStatusId"/>
         <action service="createInvoiceFromOrder" mode="sync"/>
@@ -225,7 +225,7 @@
         <action service="processCreditReturn" mode="sync"/>
         <action service="processRefundOnlyReturn" mode="sync"/>
     </eca>
-    <eca service="updateReturnStatusFromReceipt" event="global-commit">
+    <eca service="updateReturnStatusFromReceipt" event="global-commit-post-run">
         <condition field-name="returnHeaderStatus" operator="equals" value="RETURN_RECEIVED"/>
         <action service="addProductsBackToCategory" mode="sync"/>
         <action service="processWaitReplacementReturn" mode="sync"/>
diff --git a/applications/party/widget/partymgr/PartyForms.xml b/applications/party/widget/partymgr/PartyForms.xml
index 720a315..49d7989 100644
--- a/applications/party/widget/partymgr/PartyForms.xml
+++ b/applications/party/widget/partymgr/PartyForms.xml
@@ -835,8 +835,10 @@
         <field name="partyIdTo" entry-name="parameters.partyId"><display/></field>
         <field name="roleTypeIdTo" title="${uiLabelMap.PartyPartyInTheRoleOf}">
             <drop-down allow-empty="false" no-current-selected-key="_NA_">
-                <entity-options entity-name="RoleType" key-field-name="roleTypeId" description="${description}">
+                <entity-options entity-name="RoleTypeAndParty" key-field-name="roleTypeId" description="${description}">
+                    <entity-constraint name="partyId" value="${partyId}"/>
                     <entity-order-by field-name="description"/>
+                    <entity-order-by field-name="roleTypeId"/>
                 </entity-options>
             </drop-down>
         </field>
diff --git a/applications/product/script/org/ofbiz/product/price/PriceServices.xml b/applications/product/script/org/ofbiz/product/price/PriceServices.xml
index 927837f..9a4463b 100644
--- a/applications/product/script/org/ofbiz/product/price/PriceServices.xml
+++ b/applications/product/script/org/ofbiz/product/price/PriceServices.xml
@@ -21,7 +21,7 @@
 <simple-methods xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/simple-methods-v2.xsd">
     <!-- ProductPrice methods -->
-    <simple-method method-name="createProductPrice" short-description="Create an ProductPrice">
+    <simple-method method-name="createProductPrice" short-description="Create a Product Price">
         <set field="callingMethodName" value="createProductPrice"/>
         <set field="checkAction" value="CREATE"/>
         <call-simple-method method-name="checkProductRelatedPermission" xml-resource="component://product/script/org/ofbiz/product/product/ProductServices.xml"/>
diff --git a/applications/product/servicedef/services.xml b/applications/product/servicedef/services.xml
index d3d8a53..e54a223 100644
--- a/applications/product/servicedef/services.xml
+++ b/applications/product/servicedef/services.xml
@@ -240,12 +240,14 @@
     <service name="createProductPrice" default-entity-name="ProductPrice" engine="simple"
                 location="component://product/script/org/ofbiz/product/price/PriceServices.xml" invoke="createProductPrice" auth="true">
         <description>
-            Create an ProductPrice. 
-            Price is always stored without tax. 
+            Create a Product Price. 
+            
             If taxAuthGeoId and taxAuthPartyId are (or taxAuthCombinedId is) passed in then the price will be considered a price 
             with tax included (the priceWithoutTax, priceWithTax, taxAmount, and taxPercentage fields will also be populated).
-            If the taxInPrice field is 'Y' then the price field will be left with the price included (price will be equal to priceWithTax), 
+            
+            If the taxInPrice field is 'Y' then the price field will be left with the tax included (price will be equal to priceWithTax),            
             otherwise tax will be removed from the passed in price and the price field will be equal to the priceWithoutTax field.
+            
             If taxAuthGeoId or taxAuthPartyId empty, and taxAuthCombinedId is empty, then the taxInPrice field will be ignored.
         </description>
         <auto-attributes include="pk" mode="IN" optional="false"/>
diff --git a/framework/minilang/src/org/ofbiz/minilang/method/envops/Iterate.java b/framework/minilang/src/org/ofbiz/minilang/method/envops/Iterate.java
index 9d68385..bc99a27 100644
--- a/framework/minilang/src/org/ofbiz/minilang/method/envops/Iterate.java
+++ b/framework/minilang/src/org/ofbiz/minilang/method/envops/Iterate.java
@@ -155,8 +155,10 @@
                 }
             }
         } else {
-            if (Debug.verboseOn())
-                Debug.logVerbose("Cannot iterate over a " + objList.getClass().getName() + ", doing nothing: " + this, module);
+            if (Debug.verboseOn()) {
+                Debug.logVerbose("Cannot iterate over a " + objList == null ? "null object" : objList.getClass().getName()
+                        + ", doing nothing: " + this, module);
+            }
             return true;
         }
         entryFma.put(methodContext.getEnvMap(), oldEntryValue);
diff --git a/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ServiceArtifactInfo.java b/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ServiceArtifactInfo.java
index d6696d8..12e305a 100644
--- a/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ServiceArtifactInfo.java
+++ b/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ServiceArtifactInfo.java
@@ -122,7 +122,7 @@
     }
     protected void populateEntitiesFromNameSet(Set<String> allEntityNameSet) throws GeneralException {
         for (String entityName: allEntityNameSet) {
-            if (UtilValidate.isEmail(entityName) || entityName.contains("${")) {
+            if (UtilValidate.isEmpty(entityName) || entityName.contains("${")) {
                 continue;
             }
             // attempt to convert relation names to entity names
diff --git a/tools/rc.ofbiz.for.debian b/tools/rc.ofbiz.for.debian
index c315aff..125214b 100644
--- a/tools/rc.ofbiz.for.debian
+++ b/tools/rc.ofbiz.for.debian
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 #####################################################################
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
@@ -23,6 +23,15 @@
 #
 # chkconfig: - 80 10
 # description: OFBiz server
+### BEGIN INIT INFO
+# Provides:          OFBiz ERP software
+# Required-Start:    $remote_fs $syslog
+# Required-Stop:     $remote_fs $syslog
+# Default-Start:     2 3 4 5
+# Default-Stop:      0 1 6
+# Short-Description: Apache-OFBiz
+# Description:       OFBiz ERP Software
+### END INIT INFO
 
 # Paths - Edit for your locations
 JAVA_BINARY=/usr/java/j2sdk1.4.2/bin/java