Author: apatel
Date: Mon Dec  7 00:34:14 2009
New Revision: 887810

URL: http://svn.apache.org/viewvc?rev=887810&view=rev
Log:
Updated report to show GlAccountBalances by Cost Centers. Now following pattern 
established by Jacopo in other financial reports.

Modified:
    
ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/reports/CostCenters.groovy
    ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/controller.xml
    
ofbiz/trunk/applications/accounting/webapp/accounting/reports/CostCentersReport.fo.ftl
    
ofbiz/trunk/applications/accounting/webapp/accounting/reports/CostCentersReport.ftl
    ofbiz/trunk/applications/accounting/widget/AccountingMenus.xml
    ofbiz/trunk/applications/accounting/widget/ReportFinancialSummaryForms.xml
    ofbiz/trunk/applications/accounting/widget/ReportFinancialSummaryScreens.xml

Modified: 
ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/reports/CostCenters.groovy
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/reports/CostCenters.groovy?rev=887810&r1=887809&r2=887810&view=diff
==============================================================================
--- 
ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/reports/CostCenters.groovy
 (original)
+++ 
ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/reports/CostCenters.groovy
 Mon Dec  7 00:34:14 2009
@@ -16,16 +16,68 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-import org.ofbiz.accounting.util.UtilAccounting;
-import org.ofbiz.entity.util.EntityUtil;
-import org.ofbiz.base.util.Debug;
-import org.ofbiz.base.util.UtilValidate;
+
 import org.ofbiz.base.util.UtilDateTime;
+import org.ofbiz.base.util.UtilMisc;
+import org.ofbiz.base.util.UtilNumber;
 import org.ofbiz.entity.condition.EntityCondition;
+import org.ofbiz.entity.condition.EntityOperator;
+import org.ofbiz.entity.util.EntityUtil;
 
-if (organizationPartyId) {
-    resultFromPartyAcctgPref = 
dispatcher.runSync("getPartyAccountingPreferences", [organizationPartyId : 
organizationPartyId, userLogin : request.getAttribute("userLogin")]);
-    partyAcctgPreference = resultFromPartyAcctgPref.partyAccountingPreference;
-    context.currencyUomId = partyAcctgPreference.baseCurrencyUomId;
-    context.glAccountCategories = delegator.findList("GlAccountCategory", 
EntityCondition.makeCondition([glAccountCategoryTypeId : "COST_CENTER"]), null, 
["glAccountCategoryId"], null, false);
+import javolution.util.FastList;
+import javolution.util.FastMap;
+
+if (!fromDate) {
+    return;
+}
+if (!thruDate) {
+    thruDate = UtilDateTime.nowTimestamp();
 }
+if (!parameters.glFiscalTypeId) {
+    parameters.glFiscalTypeId = "ACTUAL";
+}
+
+// POSTED
+// Posted transactions totals and grand totals
+postedTotalDebit = BigDecimal.ZERO;
+postedTotalCredit = BigDecimal.ZERO;
+andExprs = FastList.newInstance();
+andExprs.add(EntityCondition.makeCondition("organizationPartyId", 
EntityOperator.IN, partyIds));
+andExprs.add(EntityCondition.makeCondition("isPosted", EntityOperator.EQUALS, 
"Y"));
+andExprs.add(EntityCondition.makeCondition("glFiscalTypeId", 
EntityOperator.EQUALS, parameters.glFiscalTypeId));
+andExprs.add(EntityCondition.makeCondition("transactionDate", 
EntityOperator.GREATER_THAN_EQUAL_TO, fromDate));
+andExprs.add(EntityCondition.makeCondition("transactionDate", 
EntityOperator.LESS_THAN_EQUAL_TO, thruDate));
+andCond = EntityCondition.makeCondition(andExprs, EntityOperator.AND);
+List postedTransactionTotals = delegator.findList("AcctgTransEntrySums", 
andCond, UtilMisc.toSet("glAccountId", "accountName", "accountCode", 
"debitCreditFlag", "amount"), UtilMisc.toList("glAccountId"), null, false);
+if (postedTransactionTotals) {
+    glAccountCategories = delegator.findByAnd("GlAccountCategory", 
[glAccountCategoryTypeId : 'COST_CENTER'], ['glAccountCategoryId']);
+    context.glAccountCategories = glAccountCategories;
+    Map postedTransactionTotalsMap = [:]
+    postedTransactionTotals.each { postedTransactionTotal ->
+        Map accountMap = 
(Map)postedTransactionTotalsMap.get(postedTransactionTotal.glAccountId);
+        if (!accountMap) {
+            accountMap = UtilMisc.makeMapWritable(postedTransactionTotal);
+            accountMap.put("D", BigDecimal.ZERO);
+            accountMap.put("C", BigDecimal.ZERO);
+        }
+        UtilMisc.addToBigDecimalInMap(accountMap, 
postedTransactionTotal.debitCreditFlag, postedTransactionTotal.amount);
+        postedTransactionTotalsMap.put(postedTransactionTotal.glAccountId, 
accountMap);
+        BigDecimal debitAmount = (BigDecimal)accountMap.get("D");
+        BigDecimal creditAmount = (BigDecimal)accountMap.get("C");
+        BigDecimal balance = debitAmount.subtract(creditAmount);
+        accountMap.put("balance", balance);
+        glAccountCategories.each { glAccountCategory ->
+            glAccountCategoryMember = 
EntityUtil.getFirst(EntityUtil.filterByDate(delegator.findByAnd("GlAccountCategoryMember",
 [glAccountCategoryId : glAccountCategory.glAccountCategoryId, glAccountId: 
postedTransactionTotal.glAccountId], ['glAccountCategoryId'])));
+            if (glAccountCategoryMember) {
+                BigDecimal glAccountCategorySharePercentage = 
glAccountCategoryMember.amountPercentage;
+                if (glAccountCategorySharePercentage && 
glAccountCategorySharePercentage != BigDecimal.ZERO ) {
+                    glAccountCategoryShareFraction = 
glAccountCategorySharePercentage.divide(new BigDecimal("100.00"));
+                    BigDecimal glAccountCategoryShare = 
balance.multiply(glAccountCategoryShareFraction);
+                    
accountMap.put(glAccountCategory.glAccountCategoryId,glAccountCategoryShare);
+                }
+            }
+        }
+    }
+    context.glAcctBalancesByCostCenter = 
postedTransactionTotalsMap.values().asList()
+}
+

Modified: 
ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/controller.xml
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/controller.xml?rev=887810&r1=887809&r2=887810&view=diff
==============================================================================
--- 
ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/controller.xml 
(original)
+++ 
ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/controller.xml 
Mon Dec  7 00:34:14 2009
@@ -2445,29 +2445,21 @@
         <response name="success" type="view" value="CostCenters"/>
     </request-map>
 
-    <request-map uri="CostCenterReport">
-        <security https="true" auth="true"/>
-        <response name="success" type="view" value="CostCenterReport"/>
-    </request-map>
-
-    <request-map uri="getGlAcctgOrgWithPostedBalanceSplit">
-        <security https="true" auth="true"/>
-        <event type="service" invoke="getGlAcctgOrgWithPostedBalanceSplit"/>
-        <response name="success" type="view" value="CostCenterReport"/>
-        <response name="error" type="view" value="CostCenterReport"/>
-    </request-map>
-
-    <request-map uri="CostCentersReport.pdf">
-        <security auth="true" https="true"/>
-        <response name="success" type="view" value="CostCentersReportPdf"/>
-    </request-map>
-
     <request-map uri="createUpdateCostCenter">
         <security auth="true" https="true"/>
         <event type="jsonservice-multi"  invoke="createUpdateCostCenter"/>
         <response name="success" type="none"/>
         <response name="error" type="none"/>
     </request-map>
+
+    <request-map uri="GlAccountBalanceByCostCenter">
+        <security https="true" auth="true"/>
+        <response name="success" type="view" 
value="GlAccountBalanceByCostCenter"/>
+    </request-map>
+    <request-map uri="GlAccountBalanceByCostCenter.pdf">
+        <security auth="true" https="true"/>
+        <response name="success" type="view" 
value="GlAccountBalanceByCostCenterPdf"/>
+    </request-map>
     <!-- end of request mappings -->
 
     <!-- View Mappings -->
@@ -2765,8 +2757,8 @@
     <view-map name="FindGlAccountCategory" type="screen" 
page="component://accounting/widget/GlSetupScreens.xml#FindGlAccountCategory"/>
     <view-map name="EditGlAccountCategoryMember" type="screen" 
page="component://accounting/widget/GlSetupScreens.xml#EditGlAccountCategoryMember"/>
     <view-map name="CostCenters" type="screen" 
page="component://accounting/widget/GlobalGlAccountsScreens.xml#CostCenters"/>
-    <view-map name="CostCenterReport" type="screen" 
page="component://accounting/widget/ReportFinancialSummaryScreens.xml#CostCenterReport"/>
-    <view-map name="CostCentersReportPdf" type="screenfop" 
page="component://accounting/widget/ReportFinancialSummaryScreens.xml#CostCentersReportPdf"
 content-type="application/pdf" encoding="none"/>
+    <view-map name="GlAccountBalanceByCostCenter" type="screen" 
page="component://accounting/widget/ReportFinancialSummaryScreens.xml#GlAccountBalanceByCostCenter"/>
+    <view-map name="GlAccountBalanceByCostCenterPdf" type="screenfop" 
page="component://accounting/widget/ReportFinancialSummaryScreens.xml#GlAccountBalanceByCostCenterPdf"
 content-type="application/pdf" encoding="none"/>
     <view-map name="ComparativeIncomeStatementsPdf" type="screenfop" 
page="component://accounting/widget/ReportFinancialSummaryScreens.xml#ComparativeIncomeStatementsPdf"
 content-type="application/pdf" encoding="none"/>
     <view-map name="ComparativeIncomeStatementsCsv" type="screencsv" 
page="component://accounting/widget/ReportFinancialSummaryScreens.xml#ComparativeIncomeStatementsCsv"
 content-type="text/csv" encoding="none"/>
     <!-- end of view mappings -->

Modified: 
ofbiz/trunk/applications/accounting/webapp/accounting/reports/CostCentersReport.fo.ftl
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/webapp/accounting/reports/CostCentersReport.fo.ftl?rev=887810&r1=887809&r2=887810&view=diff
==============================================================================
--- 
ofbiz/trunk/applications/accounting/webapp/accounting/reports/CostCentersReport.fo.ftl
 (original)
+++ 
ofbiz/trunk/applications/accounting/webapp/accounting/reports/CostCentersReport.fo.ftl
 Mon Dec  7 00:34:14 2009
@@ -17,7 +17,7 @@
 under the License.
 -->
 <#escape x as x?xml>
-    <#if glAcctgOrgAndCostCenterList?has_content && 
glAccountCategories?has_content>
+    <#if glAcctBalancesByCostCenter?has_content && 
glAccountCategories?has_content>
         <fo:table border="1pt solid" border-width=".1mm" width="19cm">
             <fo:table-header>
                 <fo:table-cell border="1pt solid" border-width=".1mm">
@@ -39,24 +39,24 @@
                 </#list>
             </fo:table-header>
             <fo:table-body>
-                <#list glAcctgOrgAndCostCenterList as glAcctgOrgAndCostCenter>
+                <#list glAcctBalancesByCostCenter as glAcctBalanceByCostCenter>
                     <#if glAcctgOrgAndCostCenter?has_content>
                         <fo:table-row>
                             <fo:table-cell border="1pt solid" 
border-width=".1mm">
-                                <fo:block 
text-align="center">${glAcctgOrgAndCostCenter.glAccountId?if_exists}</fo:block>
+                                <fo:block 
text-align="center">${glAcctBalanceByCostCenter.glAccountId?if_exists}</fo:block>
                             </fo:table-cell>
                             <fo:table-cell border="1pt solid" 
border-width=".1mm">
-                                <fo:block 
text-align="center">${glAcctgOrgAndCostCenter.accountCode?if_exists}</fo:block>
+                                <fo:block 
text-align="center">${glAcctBalanceByCostCenter.accountCode?if_exists}</fo:block>
                             </fo:table-cell>
                             <fo:table-cell border="1pt solid" 
border-width=".1mm">
-                                <fo:block 
text-align="center">${glAcctgOrgAndCostCenter.accountName?if_exists}</fo:block>
+                                <fo:block 
text-align="center">${glAcctBalanceByCostCenter.accountName?if_exists}</fo:block>
                             </fo:table-cell>
                             <fo:table-cell border="1pt solid" 
border-width=".1mm">
-                                <fo:block 
text-align="center">${glAcctgOrgAndCostCenter.postedBalance?if_exists!}</fo:block>
+                                <fo:block 
text-align="center">${glAcctBalanceByCostCenter.balance?if_exists!}</fo:block>
                             </fo:table-cell>
                             <#list glAccountCategories as glAccountCategory>
                                 <fo:table-cell border="1pt solid" 
border-width=".1mm">
-                                    <fo:block 
text-align="center">${(glAcctgOrgAndCostCenter[glAccountCategory.glAccountCategoryId?if_exists]?if_exists)}</fo:block>
+                                    <fo:block 
text-align="center">${(glAcctBalanceByCostCenter[glAccountCategory.glAccountCategoryId?if_exists]?if_exists)}</fo:block>
                                 </fo:table-cell>
                             </#list>
                         </fo:table-row>

Modified: 
ofbiz/trunk/applications/accounting/webapp/accounting/reports/CostCentersReport.ftl
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/webapp/accounting/reports/CostCentersReport.ftl?rev=887810&r1=887809&r2=887810&view=diff
==============================================================================
--- 
ofbiz/trunk/applications/accounting/webapp/accounting/reports/CostCentersReport.ftl
 (original)
+++ 
ofbiz/trunk/applications/accounting/webapp/accounting/reports/CostCentersReport.ftl
 Mon Dec  7 00:34:14 2009
@@ -17,13 +17,7 @@
 specific language governing permissions and limitations
 under the License.
 -->
-<#if glAcctgOrgAndCostCenterList?has_content && 
glAccountCategories?has_content>
-  <form name="costCentersReportPdfForm" method="post" 
action="<@ofbizUrl>CostCentersReport.pdf</@ofbizUrl>">
-    <input type="hidden" name="organizationPartyId" 
value="${parameters.organizationPartyId}"/>
-    <input type="hidden" name="fromDate" value="${parameters.fromDate}"/>
-    <input type="hidden" name="thruDate" value="${parameters.thruDate}"/>
-    <a href="javascript:document.costCentersReportPdfForm.submit();" 
class="buttontext">${uiLabelMap.AccountingExportAsPdf}</a>
-  </form>
+<#if glAcctBalancesByCostCenter?has_content && glAccountCategories?has_content>
   <table class="basic-table hover-bar" cellspacing="0">
     <tr class="header-row">
       <th>${uiLabelMap.FormFieldTitle_glAccountId}</th>
@@ -34,18 +28,18 @@
         <th>${glAccountCategory.description!} - (${currencyUomId})</th>
       </#list>
     </tr>
-    <#list glAcctgOrgAndCostCenterList as glAcctgOrgAndCostCenter>
-      <#if glAcctgOrgAndCostCenter?has_content>
-        <tr>
-          <td>${glAcctgOrgAndCostCenter.glAccountId?if_exists}</td>
-          <td>${glAcctgOrgAndCostCenter.accountCode?if_exists}</td>
-          <td>${glAcctgOrgAndCostCenter.accountName?if_exists}</td>
-          <td>${glAcctgOrgAndCostCenter.postedBalance?if_exists}</td>
+    <#assign alt_row = false>
+    <#list glAcctBalancesByCostCenter as glAcctBalanceByCostCenter>
+        <tr <#if alt_row> class="alternate-row"</#if>>
+          <td>${glAcctBalanceByCostCenter.glAccountId?if_exists}</td>
+          <td>${glAcctBalanceByCostCenter.accountCode?if_exists}</td>
+          <td>${glAcctBalanceByCostCenter.accountName?if_exists}</td>
+          <td>${glAcctBalanceByCostCenter.balance?if_exists}</td>
           <#list glAccountCategories as glAccountCategory>
-            
<td>${(glAcctgOrgAndCostCenter[glAccountCategory.glAccountCategoryId?if_exists]?if_exists)}</td>
+            
<td>${(glAcctBalanceByCostCenter[glAccountCategory.glAccountCategoryId?if_exists]?if_exists)}</td>
           </#list>
+          <#assign alt_row = !alt_row>
         </tr>
-      </#if>
     </#list>
   </table>
 <#else>

Modified: ofbiz/trunk/applications/accounting/widget/AccountingMenus.xml
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/widget/AccountingMenus.xml?rev=887810&r1=887809&r2=887810&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/widget/AccountingMenus.xml (original)
+++ ofbiz/trunk/applications/accounting/widget/AccountingMenus.xml Mon Dec  7 
00:34:14 2009
@@ -827,8 +827,8 @@
                 <parameter param-name="organizationPartyId"/>
             </link>
         </menu-item>
-        <menu-item name="CostCenterReport" 
title="${uiLabelMap.FormFieldTitle_costCenters}">
-            <link target="CostCenterReport">
+        <menu-item name="GlAccountBalanceByCostCenter" 
title="${uiLabelMap.FormFieldTitle_costCenters}">
+            <link target="GlAccountBalanceByCostCenter">
                 <parameter param-name="organizationPartyId"/>
             </link>
         </menu-item>

Modified: 
ofbiz/trunk/applications/accounting/widget/ReportFinancialSummaryForms.xml
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/widget/ReportFinancialSummaryForms.xml?rev=887810&r1=887809&r2=887810&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/widget/ReportFinancialSummaryForms.xml 
(original)
+++ ofbiz/trunk/applications/accounting/widget/ReportFinancialSummaryForms.xml 
Mon Dec  7 00:34:14 2009
@@ -333,6 +333,19 @@
         <field name="balance2" title="Period2" 
widget-style="tabletextright"><display type="currency" 
currency="${currencyUomId}"/></field>
     </form>
 
+    <form name="SelectAcctReportPeriod" type="single" title="Select period for 
report">
+        <field name="fromDate"><date-time/></field>
+        <field name="thruDate"><date-time/></field>
+        <field name="glFiscalTypeId" 
title="${uiLabelMap.FormFieldTitle_glFiscalType}">
+            <drop-down>
+                <entity-options entity-name="GlFiscalType" 
description="${description}">
+                    <entity-order-by field-name="glFiscalTypeId"/>
+                </entity-options>
+            </drop-down>
+        </field>
+        <field name="submitButton" widget-style="smallSubmit"><submit 
button-type="button"/></field>
+    </form>
+
     <form name="FindTransactionTotals" type="single" 
target="TransactionTotals" title="Find list of transaction totals"
         header-row-style="header-row" default-table-style="basic-table">
         <field name="organizationPartyId"><hidden/></field>
@@ -528,13 +541,6 @@
         <field name="isPosted" 
field-name="parameters.isPosted"><hidden/></field>
     </form>
 
-    <form name="CostCenter" type="single" header-row-style="header-row" 
target="getGlAcctgOrgWithPostedBalanceSplit" default-table-style="basic-table">
-        <field name="organizationPartyId"><hidden/></field>
-        <field name="fromDate" required-field="false"><date-time 
type="timestamp"/></field>
-        <field name="thruDate" required-field="false"><date-time 
type="timestamp"/></field>
-        <field name="submitButton" title="${uiLabelMap.CommonSubmit}" 
widget-style="smallSubmit" tooltip="Please enter From and Thru date or select 
financial time period in fields above"><submit button-type="button"/></field>
-    </form>
-
     <form name="InventoryValuation" type="single" target="InventoryValuation" 
header-row-style="header-row" default-table-style="basic-table">
         <field name="facilityId" position="1">
             <drop-down allow-empty="true">

Modified: 
ofbiz/trunk/applications/accounting/widget/ReportFinancialSummaryScreens.xml
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/widget/ReportFinancialSummaryScreens.xml?rev=887810&r1=887809&r2=887810&view=diff
==============================================================================
--- 
ofbiz/trunk/applications/accounting/widget/ReportFinancialSummaryScreens.xml 
(original)
+++ 
ofbiz/trunk/applications/accounting/widget/ReportFinancialSummaryScreens.xml 
Mon Dec  7 00:34:14 2009
@@ -1323,40 +1323,48 @@
         </section>
     </screen>
 
-    <screen name="CostCenterReport">
+    <screen name="GlAccountBalanceByCostCenter">
         <section>
             <actions>
-                <property-map resource="CommonUiLabels" map-name="uiLabelMap" 
global="true"/>
-                <property-map resource="AccountingUiLabels" 
map-name="uiLabelMap" global="true"/>
+                <set field="viewSize" value="99999"/>
                 <set field="titleProperty" value="FormFieldTitle_costCenters"/>
                 <set field="labelTitleProperty" 
value="FormFieldTitle_costCenters"/>
                 <set field="tabButtonItem" 
value="OrganizationAccountingReports"/>
-                <set field="tabButtonItem2" value="CostCenterReport"/>
-                <set field="organizationPartyId" 
from-field="parameters.organizationPartyId" type="String"/>
+                <set field="tabButtonItem2" 
value="GlAccountBalanceByCostCenter"/>
+                <set field="organizationPartyId" 
from-field="parameters.organizationPartyId"/>
+                <set field="partyIds" 
value="${groovy:org.ofbiz.party.party.PartyWorker.getAssociatedPartyIdsByRelationshipType(delegator,
 organizationPartyId, 'GROUP_ROLLUP')}" type="List"/>
+                <set field="partyIds[]" from-field="organizationPartyId"/>
+                <service service-name="getPartyAccountingPreferences" 
result-map="result" auto-field-map="true"/>
+                <set field="partyAcctgPreference" 
from-field="result.partyAccountingPreference"/>
+                <set field="currencyUomId" 
from-field="partyAcctgPreference.baseCurrencyUomId"/>
                 <!-- Get a default fromDate -->
                 <service service-name="findLastClosedDate" 
result-map="findLastClosedDateOutMap">
                     <field-map field-name="organizationPartyId" 
from-field="organizationPartyId"/>
                 </service>
                 <set field="fromDate" from-field="parameters.fromDate" 
type="Timestamp" default-value="${findLastClosedDateOutMap.lastClosedDate}"/>
                 <set field="thruDate" from-field="parameters.thruDate" 
type="Timestamp" default-value="${nowTimestamp}"/>
-
-                <set field="glAcctgOrgAndCostCenterList" 
from-field="parameters.glAcctgOrgAndCostCenterList" type="List"/>
                 <script 
location="component://accounting/webapp/accounting/WEB-INF/actions/reports/CostCenters.groovy"/>
             </actions>
             <widgets>
-               <decorator-screen 
name="CommonOrganizationAccountingReportsDecorator" 
location="${parameters.mainDecoratorLocation}">
+                <decorator-screen 
name="CommonOrganizationAccountingReportsDecorator" 
location="${parameters.mainDecoratorLocation}">
                     <decorator-section name="body">
                         <screenlet 
title="${uiLabelMap.FormFieldTitle_costCenters}">
-                            <include-form name="CostCenter" 
location="component://accounting/widget/ReportFinancialSummaryForms.xml"/>
+                            <include-form name="SelectAcctReportPeriod" 
location="component://accounting/widget/ReportFinancialSummaryForms.xml"/>
                         </screenlet>
                         <section>
                             <condition>
-                                <or>
-                                    <not><if-empty 
field="parameters.fromDate"/></not>
-                                    <not><if-empty 
field="glAcctgOrgAndCostCenterMapList"/></not>
-                                </or>
+                                <and>
+                                    <not><if-empty field="fromDate"/></not>
+                                    <not><if-empty field="thruDate"/></not>
+                                    <not><if-empty 
field="organizationPartyId"/></not>
+                                </and>
                             </condition>
                             <widgets>
+                                <link 
text="${uiLabelMap.AccountingExportAsPdf}" style="button" 
target="GlAccountBalanceByCostCenter.pdf">
+                                    <parameter 
param-name="organizationPartyId" from-field="parameters.organizationPartyId"/>
+                                    <parameter param-name="fromDate" 
from-field="parameters.fromDate"/>
+                                    <parameter param-name="thruDate" 
from-field="parameters.thruDate"/>
+                                </link>
                                 <screenlet 
title="${uiLabelMap.FormFieldTitle_costCenters}">
                                     <platform-specific>
                                         <html>
@@ -1372,7 +1380,7 @@
         </section>
     </screen>
 
-    <screen name="CostCentersReportPdf">
+    <screen name="GlAccountBalanceByCostCenterPdf">
         <section>
             <actions>
                 <property-map resource="CommonUiLabels" map-name="uiLabelMap" 
global="true"/>
@@ -1380,11 +1388,12 @@
                 <service service-name="getPartyAccountingPreferences" 
result-map="result" auto-field-map="true"/>
                 <set field="partyAcctgPreference" 
from-field="result.partyAccountingPreference"/>
                 <set field="currencyUomId" 
from-field="partyAcctgPreference.baseCurrencyUomId"/>
-                <entity-condition entity-name="GlAccountCategory" 
list="glAccountCategories">
-                    <condition-expr field-name="glAccountCategoryTypeId" 
operator="equals" value="COST_CENTER"/>
-                </entity-condition>
-                <service service-name="getGlAcctgOrgWithPostedBalanceSplit" 
result-map="result" auto-field-map="true"/>
-                <set field="glAcctgOrgAndCostCenterList" 
from-field="result.glAcctgOrgAndCostCenterList" type="List"/>
+                <set field="organizationPartyId" 
from-field="parameters.organizationPartyId"/>
+                <set field="partyIds" 
value="${groovy:org.ofbiz.party.party.PartyWorker.getAssociatedPartyIdsByRelationshipType(delegator,
 organizationPartyId, 'GROUP_ROLLUP')}" type="List"/>
+                <set field="partyIds[]" from-field="organizationPartyId"/>
+                <set field="fromDate" from-field="parameters.fromDate" 
type="Timestamp" default-value="${findLastClosedDateOutMap.lastClosedDate}"/>
+                <set field="thruDate" from-field="parameters.thruDate" 
type="Timestamp" default-value="${nowTimestamp}"/>
+                <script 
location="component://accounting/webapp/accounting/WEB-INF/actions/reports/CostCenters.groovy"/>
             </actions>
             <widgets>
                 <decorator-screen name="SimpleDecorator" 
location="component://common/widget/CommonScreens.xml">


Reply via email to