You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ap...@apache.org on 2009/08/08 05:47:51 UTC

svn commit: r802295 - in /ofbiz/trunk/applications/accounting: script/org/ofbiz/accounting/ledger/ servicedef/ webapp/accounting/WEB-INF/ webapp/accounting/WEB-INF/actions/reports/ webapp/accounting/reports/ widget/

Author: apatel
Date: Sat Aug  8 03:47:50 2009
New Revision: 802295

URL: http://svn.apache.org/viewvc?rev=802295&view=rev
Log:
First pass of Cost Center report Gl Report. Patch from OFBIZ-2811. Thanks Brajesh for working on it.

Added:
    ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/reports/CostCenters.groovy
    ofbiz/trunk/applications/accounting/webapp/accounting/reports/CostCentersReport.ftl   (with props)
Modified:
    ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/ledger/GeneralLedgerServices.xml
    ofbiz/trunk/applications/accounting/servicedef/services_ledger.xml
    ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/controller.xml
    ofbiz/trunk/applications/accounting/widget/Menus.xml
    ofbiz/trunk/applications/accounting/widget/ReportFinancialSummaryForms.xml
    ofbiz/trunk/applications/accounting/widget/ReportFinancialSummaryScreens.xml

Modified: ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/ledger/GeneralLedgerServices.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/ledger/GeneralLedgerServices.xml?rev=802295&r1=802294&r2=802295&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/ledger/GeneralLedgerServices.xml (original)
+++ ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/ledger/GeneralLedgerServices.xml Sat Aug  8 03:47:50 2009
@@ -2488,4 +2488,81 @@
             </if-compare-field>
         </if-not-empty>
     </simple-method>
+
+    <simple-method method-name="getGlAcctgOrgWithPostedBalanceSplit" short-description="Posted amounts split by cost center from GlAccountOrganization">
+        <!-- retrieve ledger rounding properties -->
+        <property-to-field resource="arithmetic" property="ledger.decimals" field="ledgerDecimals"/>
+        <property-to-field resource="arithmetic" property="ledger.rounding" field="roundingMode"/>
+        <set field="glAcctgOrgAndCostCenterMapList" type="List" value="null"/>
+        <now-timestamp field="nowThruDate"/>
+        <set field="fromDate" from-field="parameters.fromDate" type="Timestamp"/>
+        <set field="thruDate" from-field="parameters.thruDate" type="Timestamp" default-value="${nowThruDate}"/>
+
+        <if-empty field="fromDate">
+            <entity-one entity-name="CustomTimePeriod" value-field="customTimePeriod" auto-field-map="false">
+                <field-map field-name="customTimePeriodId" from-field="parameters.timePeriod"/>
+            </entity-one>
+            <set field="fromDate" from-field="customTimePeriod.fromDate" type="Timestamp"/>
+            <set field="thruDate" from-field="customTimePeriod.thruDate" type="Timestamp"/>
+        </if-empty>
+
+        <entity-condition entity-name="GlAccountOrganization" list="glAccountOrganizations" use-cache="true">
+            <condition-list>
+                <condition-expr field-name="organizationPartyId" from-field="parameters.organizationPartyId"/>
+                <condition-expr field-name="postedBalance" operator="not-equals" value=""/>
+                <condition-list combine="or">
+                    <condition-expr field-name="fromDate" operator="greater-equals" from-field="fromDate"/>
+                    <condition-expr field-name="thruDate" operator="less" from-field="thruDate"/>
+                </condition-list>
+            </condition-list>
+            <order-by field-name="glAccountId"/>
+        </entity-condition>
+        <if-not-empty field="glAccountOrganizations">
+            <entity-condition entity-name="GlAccountCategory" list="glAccountCategories">
+                <condition-expr field-name="glAccountCategoryTypeId" operator="equals" value="COST_CENTER"/>
+                <order-by field-name="glAccountCategoryId"/>
+            </entity-condition>
+            <iterate list="glAccountOrganizations" entry="glAccountOrganization">
+            
+                <clear-field field="glAcctgOrgAndCostCenterMap"/>
+                <set field="glAcctgOrgAndCostCenterMap.glAccountId" from-field="glAccountOrganization.glAccountId"/>
+                
+                <set field="postedBalance" from-field="glAccountOrganization.postedBalance" type="BigDecimal"/>
+                <if-compare field="postedBalance" operator="less" value="0" type="BigDecimal">
+                    <set field="postedBalance" value="${postedBalance * -1}" type="BigDecimal"/>
+                </if-compare>
+                <set field="glAcctgOrgAndCostCenterMap.postedBalance" from-field="postedBalance"/>
+                <entity-one entity-name="GlAccount" value-field="glAccount" auto-field-map="false">
+                    <field-map field-name="glAccountId" from-field="glAccountOrganization.glAccountId"/>
+                </entity-one>
+                <set field="glAcctgOrgAndCostCenterMap.accountCode" from-field="glAccount.accountCode"/>
+                <set field="glAcctgOrgAndCostCenterMap.accountName" from-field="glAccount.accountName"/>
+
+                <if-not-empty field="glAccountCategories">
+
+                    <iterate list="glAccountCategories" entry="glAccountCategory">
+                        <entity-condition entity-name="GlAccountCategoryMember" list="glAccountCategoryMembers" filter-by-date="true">
+                            <condition-list>
+                                <condition-expr field-name="glAccountId" from-field="glAccountOrganization.glAccountId"/>
+                                <condition-expr field-name="glAccountCategoryId" from-field="glAccountCategory.glAccountCategoryId"/>
+                            </condition-list>
+                        </entity-condition>
+                        <if-not-empty field="glAccountCategoryMembers">
+                            <first-from-list list="glAccountCategoryMembers" entry="glAccountCategoryMember"/>
+                            <if-not-empty field="glAccountCategoryMember">
+                                <set field="splitAmount" value="${postedBalance * glAccountCategoryMember.amountPercentage / 100}" type="BigDecimal"/>
+                                <calculate field="splitAmount" decimal-scale="${ledgerDecimals}" rounding-mode="${roundingMode}" type="BigDecimal">
+                                    <calcop operator="get" field="splitAmount"/>
+                                </calculate>
+                                <set field="glAcctgOrgAndCostCenterMap[glAccountCategory.glAccountCategoryId]" from-field="splitAmount" type="BigDecimal"/>
+                            </if-not-empty>
+                        </if-not-empty>
+                    </iterate>
+
+                    <field-to-list field="glAcctgOrgAndCostCenterMap" list="glAcctgOrgAndCostCenterMapList"/>
+                </if-not-empty>
+            </iterate>
+            <field-to-result field="glAcctgOrgAndCostCenterMapList" result-name="glAcctgOrgAndCostCenterMapList"/>
+        </if-not-empty>
+    </simple-method>
 </simple-methods>

Modified: ofbiz/trunk/applications/accounting/servicedef/services_ledger.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/servicedef/services_ledger.xml?rev=802295&r1=802294&r2=802295&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/servicedef/services_ledger.xml (original)
+++ ofbiz/trunk/applications/accounting/servicedef/services_ledger.xml Sat Aug  8 03:47:50 2009
@@ -644,4 +644,14 @@
         <attribute name="glAccountCategoryId" mode="IN" type="String"/>
         <attribute name="amountPercentage" mode="IN" type="BigDecimal" optional="true"/>
     </service>
+
+    <service name="getGlAcctgOrgWithPostedBalanceSplit" engine="simple" default-entity-name="GlAccountOrganization"
+        location="component://accounting/script/org/ofbiz/accounting/ledger/GeneralLedgerServices.xml" invoke="getGlAcctgOrgWithPostedBalanceSplit" auth="true">
+        <description>Posted amounts split by cost center from GlAccountOrganization</description>
+        <attribute name="organizationPartyId" type="String" mode="IN"/>
+        <attribute name="fromDate" type="Timestamp" mode="IN" optional="true"/>
+        <attribute name="thruDate" type="Timestamp" mode="IN" optional="true"/>
+        <attribute name="timePeriod" type="String" mode="IN" optional="true"/>
+        <attribute name="glAcctgOrgAndCostCenterMapList" mode="OUT"  type="List" optional="true"/>
+    </service>
 </services>

Added: 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=802295&view=auto
==============================================================================
--- ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/reports/CostCenters.groovy (added)
+++ ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/reports/CostCenters.groovy Sat Aug  8 03:47:50 2009
@@ -0,0 +1,43 @@
+/*
+ * 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 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.entity.condition.EntityCondition;
+
+if (organizationPartyId) {
+
+    customTimePeriods = delegator.findByAnd("CustomTimePeriod", [organizationPartyId : organizationPartyId, periodTypeId : "FISCAL_YEAR"]);
+    if (UtilValidate.isNotEmpty(customTimePeriods)) {
+        context.customTimePeriods = customTimePeriods;
+    }
+    onlyIncludePeriodTypeIdList = [];
+    onlyIncludePeriodTypeIdList.add("FISCAL_YEAR");
+    customTimePeriodResults = dispatcher.runSync("findCustomTimePeriods", [findDate : UtilDateTime.nowTimestamp(), organizationPartyId : organizationPartyId, onlyIncludePeriodTypeIdList : onlyIncludePeriodTypeIdList, userLogin : userLogin]);
+    customTimePeriodList = customTimePeriodResults.customTimePeriodList;
+    if (UtilValidate.isNotEmpty(customTimePeriodList)) {
+        context.timePeriod = (EntityUtil.getFirst(customTimePeriodList)).customTimePeriodId;
+    }
+    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);
+}

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=802295&r1=802294&r2=802295&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/controller.xml (original)
+++ ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/controller.xml Sat Aug  8 03:47:50 2009
@@ -2379,6 +2379,17 @@
         <response name="error" 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>
     <!-- end of request mappings -->
 
     <!-- View Mappings -->
@@ -2668,5 +2679,6 @@
     <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"/>
     <!-- end of view mappings -->
 </site-conf>

Added: 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=802295&view=auto
==============================================================================
--- ofbiz/trunk/applications/accounting/webapp/accounting/reports/CostCentersReport.ftl (added)
+++ ofbiz/trunk/applications/accounting/webapp/accounting/reports/CostCentersReport.ftl Sat Aug  8 03:47:50 2009
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<#if glAcctgOrgAndCostCenterMapList?has_content && glAccountCategories?has_content>
+  <table class="basic-table hover-bar" cellspacing="0">
+    <tr class="header-row">
+      <th>${uiLabelMap.FormFieldTitle_glAccountId}</th>
+      <th>${uiLabelMap.FormFieldTitle_accountCode}</th>
+      <th>${uiLabelMap.FormFieldTitle_accountName}</th>
+      <th>${uiLabelMap.FormFieldTitle_postedBalance} - (${currencyUomId})</th>
+      <#list glAccountCategories as glAccountCategory>
+        <th>${glAccountCategory.description!} - (${currencyUomId})</th>
+      </#list>
+    </tr>
+    <#list glAcctgOrgAndCostCenterMapList as glAcctgOrgAndCostCenterMap>
+      <#if glAcctgOrgAndCostCenterMap?has_content>
+        <tr>
+          <td>${glAcctgOrgAndCostCenterMap.glAccountId?if_exists}</td>
+          <td>${glAcctgOrgAndCostCenterMap.accountCode?if_exists}</td>
+          <td>${glAcctgOrgAndCostCenterMap.accountName?if_exists}</td>
+          <td>${glAcctgOrgAndCostCenterMap.postedBalance?if_exists}</td>
+          <#list glAccountCategories as glAccountCategory>
+            <td>${(glAcctgOrgAndCostCenterMap[glAccountCategory.glAccountCategoryId?if_exists]?if_exists)}</td>
+          </#list>
+        </tr>
+      </#if>
+    </#list>
+  </table>
+<#else>
+  <label>${uiLabelMap.AccountingNoRecordFound}</label>
+</#if>

Propchange: ofbiz/trunk/applications/accounting/webapp/accounting/reports/CostCentersReport.ftl
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/trunk/applications/accounting/webapp/accounting/reports/CostCentersReport.ftl
------------------------------------------------------------------------------
    svn:keywords = Date Rev Author URL Id

Propchange: ofbiz/trunk/applications/accounting/webapp/accounting/reports/CostCentersReport.ftl
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: ofbiz/trunk/applications/accounting/widget/Menus.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/widget/Menus.xml?rev=802295&r1=802294&r2=802295&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/widget/Menus.xml (original)
+++ ofbiz/trunk/applications/accounting/widget/Menus.xml Sat Aug  8 03:47:50 2009
@@ -768,6 +768,11 @@
                 <parameter param-name="organizationPartyId"/>
             </link>
         </menu-item>
+        <menu-item name="CostCenterReport" title="${uiLabelMap.FormFieldTitle_costCenters}">
+            <link target="CostCenterReport">
+                <parameter param-name="organizationPartyId"/>
+            </link>
+        </menu-item>
     </menu>
     <menu name="PartyAdminTabBar" extends="CommonTabBarMenu" extends-resource="component://common/widget/CommonMenus.xml"
           default-menu-item-name="PartyAcctgPreference">

Modified: ofbiz/trunk/applications/accounting/widget/ReportFinancialSummaryForms.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/widget/ReportFinancialSummaryForms.xml?rev=802295&r1=802294&r2=802295&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/widget/ReportFinancialSummaryForms.xml (original)
+++ ofbiz/trunk/applications/accounting/widget/ReportFinancialSummaryForms.xml Sat Aug  8 03:47:50 2009
@@ -513,4 +513,16 @@
             extends="MonthlyPostedTransactionList" extends-resource="component://accounting/widget/ReportFinancialSummaryForms.xml">
         <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="timePeriod" required-field="false">
+            <drop-down>
+                <list-options list-name="customTimePeriods" key-name="customTimePeriodId" description="${fromDate} - ${thruDate}"/>
+            </drop-down>
+        </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>
 </forms>

Modified: ofbiz/trunk/applications/accounting/widget/ReportFinancialSummaryScreens.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/widget/ReportFinancialSummaryScreens.xml?rev=802295&r1=802294&r2=802295&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/widget/ReportFinancialSummaryScreens.xml (original)
+++ ofbiz/trunk/applications/accounting/widget/ReportFinancialSummaryScreens.xml Sat Aug  8 03:47:50 2009
@@ -1041,4 +1041,45 @@
             </widgets>
         </section>
     </screen>
+
+    <screen name="CostCenterReport">
+        <section>
+            <actions>
+                <property-map resource="CommonUiLabels" map-name="uiLabelMap" global="true"/>
+                <property-map resource="AccountingUiLabels" map-name="uiLabelMap" global="true"/>
+                <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="glAcctgOrgAndCostCenterMapList" from-field="parameters.glAcctgOrgAndCostCenterMapList" type="List"/>
+                <script location="component://accounting/webapp/accounting/WEB-INF/actions/reports/CostCenters.groovy"/>
+            </actions>
+            <widgets>
+               <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"/>
+                        </screenlet>
+                        <section>
+                            <condition>
+                                <or>
+                                    <not><if-empty field="parameters.timePeriod"/></not>
+                                    <not><if-empty field="parameters.fromDate"/></not>
+                                    <not><if-empty field="glAcctgOrgAndCostCenterMapList"/></not>
+                                </or>
+                            </condition>
+                            <widgets>
+                                <platform-specific>
+                                    <html>
+                                        <html-template location="component://accounting/webapp/accounting/reports/CostCentersReport.ftl"/>
+                                    </html>
+                                </platform-specific>
+                            </widgets>
+                        </section>
+                    </decorator-section>
+                </decorator-screen>
+            </widgets>
+        </section>
+    </screen>
 </screens>