svn commit: r903321 - in /ofbiz/trunk/applications/accounting: script/org/ofbiz/accounting/fixedasset/FixedAssetServices.xml servicedef/services_fixedasset.xml widget/FixedAssetScreens.xml

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

svn commit: r903321 - in /ofbiz/trunk/applications/accounting: script/org/ofbiz/accounting/fixedasset/FixedAssetServices.xml servicedef/services_fixedasset.xml widget/FixedAssetScreens.xml

jacopoc
Author: jacopoc
Date: Tue Jan 26 16:56:26 2010
New Revision: 903321

URL: http://svn.apache.org/viewvc?rev=903321&view=rev
Log:
Modified depreciation services to compute and return the next depreciation amount based on actual history of depreciations. Added information in the "depreciation" screen of fixed asset about depreciation parameters.

Modified:
    ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/fixedasset/FixedAssetServices.xml
    ofbiz/trunk/applications/accounting/servicedef/services_fixedasset.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=903321&r1=903320&r2=903321&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 Tue Jan 26 16:56:26 2010
@@ -560,6 +560,8 @@
         <set field="purchaseCost" from-field="parameters.purchaseCost"/>
         <set field="salvageValue" from-field="parameters.salvageValue"/>
         <call-object-method obj-field="parameters.usageYears" method-name="intValue" ret-field="intUsageYears"/>
+
+        <!-- Past depreciation based on standard formula -->
         <if>
             <condition>
                 <and>
@@ -628,6 +630,34 @@
         <field-to-result field="assetDepreciationTillDate"/>
         <field-to-result field="assetNBVAfterDepreciation"/>
         <field-to-result field="assetDepreciationInfoList"/>
+
+        <!-- Next depreciation based on actual depreciation history -->
+        <set field="nextDepreciationAmount" value="0.0" type="BigDecimal"/>
+        <if>
+            <condition>
+                <not><if-empty field="parameters.fixedAssetId"/></not>
+            </condition>
+            <then>
+                <entity-one entity-name="FixedAsset" value-field="fixedAsset"/>
+                <!--FORMULA :  depreciation = (purchaseCost - salvageValue - pastDepreciations) / remainingYears -->
+                <calculate field="nextDepreciationAmount" decimal-scale="2">
+                    <calcop operator="divide">
+                        <calcop operator="subtract">
+                            <calcop operator="get" field="fixedAsset.purchaseCost"/>
+                            <calcop operator="get" field="salvageValue"/>
+                            <calcop operator="get" field="fixedAsset.depreciation"/>
+                        </calcop>
+                        <!-- Remaining years -->
+                        <calcop operator="subtract">
+                            <calcop operator="get" field="expEndOfLifeYear"/>
+                            <calcop operator="get" field="assetAcquiredYear"/>
+                            <calcop operator="get" field="intUsageYears"/>
+                        </calcop>
+                    </calcop>
+                </calculate>
+            </then>
+        </if>
+        <field-to-result field="nextDepreciationAmount"/>
     </simple-method>
 
     <simple-method method-name="doubleDecliningBalanceDepreciation" short-description="Calculate double declining balance depreciation to Fixed Asset">
@@ -636,6 +666,38 @@
         <set field="purchaseCost" from-field="parameters.purchaseCost"/>
         <set field="salvageValue" from-field="parameters.salvageValue"/>
         <call-object-method obj-field="parameters.usageYears" method-name="intValue" ret-field="intUsageYears"/>
+        <!-- Next depreciation based on actual depreciation history -->
+        <set field="nextDepreciationAmount" value="0.0" type="BigDecimal"/>
+        <if>
+            <condition>
+                <not><if-empty field="parameters.fixedAssetId"/></not>
+            </condition>
+            <then>
+                <entity-one entity-name="FixedAsset" value-field="fixedAsset"/>
+                <!--FORMULA :  depreciation = 2 * (purchaseCost - salvageValue - pastDepreciations) / remainingYears -->
+                <calculate field="nextDepreciationAmount" decimal-scale="2">
+                    <calcop operator="multiply">
+                        <calcop operator="divide">
+                            <calcop operator="subtract">
+                                <calcop operator="get" field="fixedAsset.purchaseCost"/>
+                                <calcop operator="get" field="salvageValue"/>
+                                <calcop operator="get" field="fixedAsset.depreciation"/>
+                            </calcop>
+                            <!-- Remaining years -->
+                            <calcop operator="subtract">
+                                <calcop operator="get" field="expEndOfLifeYear"/>
+                                <calcop operator="get" field="assetAcquiredYear"/>
+                                <calcop operator="get" field="intUsageYears"/>
+                            </calcop>
+                        </calcop>
+                        <number value="2"/>
+                    </calcop>
+                </calculate>
+            </then>
+        </if>
+        <field-to-result field="nextDepreciationAmount"/>
+
+        <!-- Past depreciation based on standard formula -->
         <if>
             <condition>
                 <and>
@@ -794,12 +856,14 @@
                 <result-to-field result-name="assetDepreciationTillDate"/>
                 <result-to-field result-name="assetNBVAfterDepreciation"/>
                 <result-to-field result-name="assetDepreciationInfoList"/>
+                <result-to-field result-name="nextDepreciationAmount"/>
             </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"/>
+            <field-to-result field="nextDepreciationAmount"/>
         <else>
             <property-to-field resource="AccountingUiLabels" property="AccountingFixedAssetDepreciationMethodNotFound" field="successMessageList[]"/>
             <return/>

Modified: ofbiz/trunk/applications/accounting/servicedef/services_fixedasset.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/servicedef/services_fixedasset.xml?rev=903321&r1=903320&r2=903321&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/servicedef/services_fixedasset.xml (original)
+++ ofbiz/trunk/applications/accounting/servicedef/services_fixedasset.xml Tue Jan 26 16:56:26 2010
@@ -282,6 +282,7 @@
         <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"/>
+        <attribute name="nextDepreciationAmount" type="BigDecimal" 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">
@@ -302,6 +303,7 @@
         <attribute name="assetDepreciationTillDate" type="List" mode="OUT" optional="true"/>
         <attribute name="assetNBVAfterDepreciation" type="List" mode="OUT" optional="true"/>
         <attribute name="assetDepreciationInfoList" type="List" mode="OUT" optional="true"/>
+        <attribute name="nextDepreciationAmount" type="BigDecimal" mode="OUT" optional="true"/>
     </service>
     <service name="createFixedAssetTypeGlAccount" engine="simple" default-entity-name="FixedAssetTypeGlAccount"
                 location="component://accounting/script/org/ofbiz/accounting/fixedasset/FixedAssetServices.xml" invoke="createFixedAssetTypeGlAccount" auth="true">

Modified: ofbiz/trunk/applications/accounting/widget/FixedAssetScreens.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/widget/FixedAssetScreens.xml?rev=903321&r1=903320&r2=903321&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/widget/FixedAssetScreens.xml (original)
+++ ofbiz/trunk/applications/accounting/widget/FixedAssetScreens.xml Tue Jan 26 16:56:26 2010
@@ -527,6 +527,14 @@
                     <decorator-section name="body">
                         <section>
                             <widgets>
+                                <screenlet title="${uiLabelMap.PageTitleFixedAssetDepreciationHistory}">
+                                    <label style="h3">${uiLabelMap.FixedAssetPurchaseCost}: ${fixedAsset.purchaseCost}</label>
+                                    <label style="h3">${uiLabelMap.FixedAssetDepreciation}: ${fixedAsset.depreciation}</label>
+                                    <label style="h3">${uiLabelMap.FixedAssetSalvageValue}: ${fixedAsset.salvageValue}</label>
+                                    <label style="h3">${uiLabelMap.FixedAssetDateAcquired}: ${fixedAsset.dateAcquired}</label>
+                                    <label style="h3">${uiLabelMap.FixedAssetExpectedEndOfLife}: ${fixedAsset.expectedEndOfLife}</label>
+                                    <label style="h3">${uiLabelMap.FixedAssetNextDepreciationAmount}: ${assetDepreciationResultMap.nextDepreciationAmount}</label>
+                                </screenlet>
                                 <screenlet title="${uiLabelMap.PageTitleFixedAssetDepreciationMethod}">
                                     <include-form name="AddFixedAssetDepMethod" location="component://accounting/widget/FixedAssetForms.xml"/>
                                     <include-form name="ListFixedAssetDepMethods" location="component://accounting/widget/FixedAssetForms.xml"/>
@@ -537,7 +545,7 @@
                                     </condition>
                                     <widgets>
                                         <screenlet title="${uiLabelMap.PageTitleFixedAssetDepreciationReport}">
-                                        <include-form name="ListFixedAssetDepreciations" location="component://accounting/widget/FixedAssetForms.xml"/>
+                                            <include-form name="ListFixedAssetDepreciations" location="component://accounting/widget/FixedAssetForms.xml"/>
                                         </screenlet>
                                     </widgets>
                                     <fail-widgets>