svn commit: r899142 - in /ofbiz/trunk/applications/accounting: script/org/ofbiz/accounting/fixedasset/ servicedef/ webapp/accounting/WEB-INF/ webapp/accounting/fixedasset/ widget/

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

svn commit: r899142 - in /ofbiz/trunk/applications/accounting: script/org/ofbiz/accounting/fixedasset/ servicedef/ webapp/accounting/WEB-INF/ webapp/accounting/fixedasset/ widget/

jacopoc
Author: jacopoc
Date: Thu Jan 14 10:14:46 2010
New Revision: 899142

URL: http://svn.apache.org/viewvc?rev=899142&view=rev
Log:
Refactored fixed asset depreciation screen and improved data preparation service; replaced (poorly implemented) ftl template with a simple form definition.

Removed:
    ofbiz/trunk/applications/accounting/webapp/accounting/fixedasset/DepreciationReport.ftl
Modified:
    ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/fixedasset/FixedAssetServices.xml
    ofbiz/trunk/applications/accounting/servicedef/services_fixedasset.xml
    ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/controller.xml
    ofbiz/trunk/applications/accounting/widget/FixedAssetForms.xml
    ofbiz/trunk/applications/accounting/widget/FixedAssetScreens.xml

Modified: ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/fixedasset/FixedAssetServices.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/fixedasset/FixedAssetServices.xml?rev=899142&r1=899141&r2=899142&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/fixedasset/FixedAssetServices.xml (original)
+++ ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/fixedasset/FixedAssetServices.xml Thu Jan 14 10:14:46 2010
@@ -569,6 +569,7 @@
             </condition>
             <then>
                 <set field="depreciation" value="0.0" type="BigDecimal"/>
+                <set field="depreciationTotal" value="0.0" type="BigDecimal"/>
                 <!--FORMULA :  depreciation = (purchaseCost - salvageValue) / (expectedEndOfLife - dateAcquired) -->
                 <calculate field="depreciation" decimal-scale="2">
                     <calcop operator="divide">
@@ -582,6 +583,7 @@
                         </calcop>
                     </calcop>
                 </calculate>
+                <set field="depreciationYear" from-field="assetAcquiredYear" type="BigDecimal"/>
                 <loop count="${intUsageYears}">
                     <calculate field="purchaseCost">
                         <calcop operator="subtract">
@@ -589,8 +591,26 @@
                             <calcop operator="get" field="depreciation"/>
                         </calcop>
                     </calculate>
+                    <calculate field="depreciationTotal">
+                        <calcop operator="sum">
+                            <calcop operator="get" field="depreciationTotal"/>
+                            <calcop operator="get" field="depreciation"/>
+                        </calcop>
+                    </calculate>
                     <field-to-list list="assetDepreciationTillDate" field="depreciation"/>
                     <field-to-list list="assetNBVAfterDepreciation" field="purchaseCost"/>
+                    <clear-field field="assetDepreciationInfo"/>
+                    <set field="assetDepreciationInfo.year" from-field="depreciationYear"/>
+                    <set field="assetDepreciationInfo.depreciation" from-field="depreciation"/>
+                    <set field="assetDepreciationInfo.depreciationTotal" from-field="depreciationTotal"/>
+                    <set field="assetDepreciationInfo.nbv" from-field="purchaseCost"/>
+                    <field-to-list list="assetDepreciationInfoList" field="assetDepreciationInfo"/>
+                    <calculate field="depreciationYear">
+                        <calcop operator="add">
+                           <calcop operator="get" field="depreciationYear"/>
+                           <number value="1"/>
+                        </calcop>
+                    </calculate>
                 </loop>
             </then>
         </if>
@@ -598,10 +618,16 @@
             <set field="depreciation" value="0.0" type="BigDecimal"/>
             <field-to-list list="assetDepreciationTillDate" field="depreciation"/>
             <field-to-list list="assetNBVAfterDepreciation" field="purchaseCost"/>
+            <set field="assetDepreciationInfo.year" from-field="assetAcquiredYear"/>
+            <set field="assetDepreciationInfo.depreciation" from-field="depreciation"/>
+            <set field="assetDepreciationInfo.depreciationTotal" from-field="depreciationTotal"/>
+            <set field="assetDepreciationInfo.nbv" from-field="purchaseCost"/>
+            <field-to-list list="assetDepreciationInfoList" field="assetDepreciationInfo"/>
         </if-empty>
         <log level="info" message="Using straight line formula depreciation calculated for fixedAsset (${parameters.fixedAssetId}) is ${depreciation}"/>
         <field-to-result field="assetDepreciationTillDate"/>
         <field-to-result field="assetNBVAfterDepreciation"/>
+        <field-to-result field="assetDepreciationInfoList"/>
     </simple-method>
 
     <simple-method method-name="doubleDecliningBalanceDepreciation" short-description="Calculate double declining balance depreciation to Fixed Asset">
@@ -618,6 +644,8 @@
                 </and>
             </condition>
             <then>
+                <set field="depreciationYear" from-field="assetAcquiredYear" type="BigDecimal"/>
+                <set field="depreciationTotal" value="0.0" type="BigDecimal"/>
                 <loop count="${intUsageYears}">
                     <set field="depreciation" value="0.0" type="BigDecimal"/>
                     <!--FORMULA : depreciation = (NBV - salvageValue) * 2 / (expectedEndOfLife - dateAcquired) -->
@@ -648,8 +676,26 @@
                            <calcop operator="get" field="depreciation"/>
                         </calcop>
                     </calculate>
+                    <calculate field="depreciationTotal">
+                        <calcop operator="sum">
+                            <calcop operator="get" field="depreciationTotal"/>
+                            <calcop operator="get" field="depreciation"/>
+                        </calcop>
+                    </calculate>
                     <field-to-list list="assetDepreciationTillDate" field="depreciation"/>
                     <field-to-list list="assetNBVAfterDepreciation" field="purchaseCost"/>
+                    <clear-field field="assetDepreciationInfo"/>
+                    <set field="assetDepreciationInfo.year" from-field="depreciationYear"/>
+                    <set field="assetDepreciationInfo.depreciation" from-field="depreciation"/>
+                    <set field="assetDepreciationInfo.depreciationTotal" from-field="depreciationTotal"/>
+                    <set field="assetDepreciationInfo.nbv" from-field="purchaseCost"/>
+                    <field-to-list list="assetDepreciationInfoList" field="assetDepreciationInfo"/>
+                    <calculate field="depreciationYear">
+                        <calcop operator="add">
+                           <calcop operator="get" field="depreciationYear"/>
+                           <number value="1"/>
+                        </calcop>
+                    </calculate>
                 </loop>
             </then>
         </if>
@@ -657,10 +703,16 @@
             <set field="depreciation" value="0.0" type="BigDecimal"/>
             <field-to-list list="assetDepreciationTillDate" field="depreciation"/>
             <field-to-list list="assetNBVAfterDepreciation" field="purchaseCost"/>
+            <set field="assetDepreciationInfo.year" from-field="assetAcquiredYear"/>
+            <set field="assetDepreciationInfo.depreciation" from-field="depreciation"/>
+            <set field="assetDepreciationInfo.depreciationTotal" from-field="depreciationTotal"/>
+            <set field="assetDepreciationInfo.nbv" from-field="purchaseCost"/>
+            <field-to-list list="assetDepreciationInfoList" field="assetDepreciationInfo"/>
         </if-empty>
         <log level="info" message="Using double decline formula depreciation calculated for fixedAsset (${parameters.fixedAssetId}) is ${assetDepreciationTillDate}"/>
         <field-to-result field="assetDepreciationTillDate"/>
         <field-to-result field="assetNBVAfterDepreciation"/>
+        <field-to-result field="assetDepreciationInfoList"/>
     </simple-method>
 
     <simple-method method-name="calculateFixedAssetDepreciation" short-description="Service to calculate the yearly depreciation from dateAcquired year to current financial year">
@@ -741,11 +793,13 @@
             <call-service service-name="${customMethod.customMethodName}" in-map-name="serviceInMap">
                 <result-to-field result-name="assetDepreciationTillDate"/>
                 <result-to-field result-name="assetNBVAfterDepreciation"/>
+                <result-to-field result-name="assetDepreciationInfoList"/>
             </call-service>
             <log level="info" message="Asset's depreciation calculated till date are ${assetDepreciationTillDate}"/>
             <log level="info" message="Asset's Net Book Values (NBV) from acquired date after deducting depreciation are ${assetNBVAfterDepreciation}"/>
             <field-to-result field="assetDepreciationTillDate"/>
             <field-to-result field="assetNBVAfterDepreciation"/>
+            <field-to-result field="assetDepreciationInfoList"/>
         <else>
             <add-error><fail-property resource="AccountingUiLabels" property="AccountingFixedAssetDepreciationMethodNotFound"/></add-error>
             <check-errors/>

Modified: ofbiz/trunk/applications/accounting/servicedef/services_fixedasset.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/servicedef/services_fixedasset.xml?rev=899142&r1=899141&r2=899142&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/servicedef/services_fixedasset.xml (original)
+++ ofbiz/trunk/applications/accounting/servicedef/services_fixedasset.xml Thu Jan 14 10:14:46 2010
@@ -275,6 +275,7 @@
         <attribute name="usageYears" type="Integer" mode="IN" optional="false"/>
         <attribute name="assetDepreciationTillDate" type="List" mode="OUT" optional="false"/>
         <attribute name="assetNBVAfterDepreciation" type="List" mode="OUT" optional="false"/>
+        <attribute name="assetDepreciationInfoList" type="List" mode="OUT" optional="false"/>
     </service>
     <service name="straightLineDepreciation" engine="simple" default-entity-name="FixedAsset"
                 location="component://accounting/script/org/ofbiz/accounting/fixedasset/FixedAssetServices.xml" invoke="straightLineDepreciation" auth="true">
@@ -294,6 +295,7 @@
         <attribute name="fixedAssetId" type="String" mode="IN"/>
         <attribute name="assetDepreciationTillDate" type="List" mode="OUT" optional="false"/>
         <attribute name="assetNBVAfterDepreciation" type="List" mode="OUT" optional="false"/>
+        <attribute name="assetDepreciationInfoList" type="List" mode="OUT" optional="false"/>
     </service>
 
     <!-- FixedAssetGeoPoint services -->

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=899142&r1=899141&r2=899142&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/controller.xml (original)
+++ ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/controller.xml Thu Jan 14 10:14:46 2010
@@ -2303,7 +2303,6 @@
     <!-- ================ Depreciation Calculation Report requests ================ -->
     <request-map uri="showFixedAssetDepreciation">
         <security https="true" auth="true"/>
-        <event type="service" invoke="calculateFixedAssetDepreciation"/>
         <response name="success" type="view" value="ShowFixedAssetDepreciation"/>
         <response name="error" type="view" value="ShowFixedAssetDepreciation"/>
     </request-map>

Modified: ofbiz/trunk/applications/accounting/widget/FixedAssetForms.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/widget/FixedAssetForms.xml?rev=899142&r1=899141&r2=899142&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/widget/FixedAssetForms.xml (original)
+++ ofbiz/trunk/applications/accounting/widget/FixedAssetForms.xml Thu Jan 14 10:14:46 2010
@@ -611,4 +611,17 @@
             </hyperlink>
         </field>
     </form>
+    <form name="ListFixedAssetDepreciations" type="list" list-name="assetDepreciationInfoList" default-map-name="assetDepreciationInfo"
+        odd-row-style="alternate-row" header-row-style="header-row-2" default-table-style="basic-table hover-bar">
+        <actions>
+            <service service-name="calculateFixedAssetDepreciation" result-map-list="assetDepreciationInfoList">
+                <field-map field-name="fixedAssetId" from-field="parameters.fixedAssetId"/>
+            </service>
+        </actions>
+        <field name="index"><display description="${itemIndex + 1}"/></field>
+        <field name="year"><display/></field>
+        <field name="depreciation"><display type="currency" currency="${fixedAsset.purchaseCostUomId}"/></field>
+        <field name="depreciationTotal"><display type="currency" currency="${fixedAsset.purchaseCostUomId}"/></field>
+        <field name="nbv" title="Net Book Value"><display type="currency" currency="${fixedAsset.purchaseCostUomId}"/></field>
+    </form>
 </forms>

Modified: ofbiz/trunk/applications/accounting/widget/FixedAssetScreens.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/widget/FixedAssetScreens.xml?rev=899142&r1=899141&r2=899142&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/widget/FixedAssetScreens.xml (original)
+++ ofbiz/trunk/applications/accounting/widget/FixedAssetScreens.xml Thu Jan 14 10:14:46 2010
@@ -513,8 +513,7 @@
                 <set field="tabButtonItem" value="FixedAssetDepreciation"/>
                 <set field="labelTitleProperty" value="PageTitleFixedAssetDepreciationReport"/>
                 <set field="fixedAssetId" from-field="parameters.fixedAssetId"/>
-                <set field="assetDepreciationTillDate" from-field="parameters.assetDepreciationTillDate"/>
-                <set field="assetNBVAfterDepreciation" from-field="parameters.assetNBVAfterDepreciation"/>
+                <entity-one entity-name="FixedAsset" value-field="fixedAsset" auto-field-map="true"/>
             </actions>
             <widgets>
                 <decorator-screen name="CommonFixedAssetDecorator" location="${parameters.fixedAssetDecoratorLocation}">
@@ -524,9 +523,7 @@
                                 <screenlet title="${uiLabelMap.PageTitleFixedAssetDepreciationReport}">
                                     <include-form name="AddFixedAssetDepMethod" location="component://accounting/widget/FixedAssetForms.xml"/>
                                     <include-form name="ListFixedAssetDepMethods" location="component://accounting/widget/FixedAssetForms.xml"/>
-                                    <platform-specific>
-                                        <html><html-template location="component://accounting/webapp/accounting/fixedasset/DepreciationReport.ftl"/></html>
-                                    </platform-specific>
+                                    <include-form name="ListFixedAssetDepreciations" location="component://accounting/widget/FixedAssetForms.xml"/>
                                 </screenlet>
                             </widgets>
                         </section>