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.

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@903321 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jacopo Cappellato
2010-01-26 16:56:26 +00:00
parent 0eb5a20261
commit d9283fecf6
3 changed files with 75 additions and 1 deletions
@@ -560,6 +560,8 @@ under the License.
<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 @@ under the License.
<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 @@ under the License.
<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 @@ under the License.
<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/>
@@ -282,6 +282,7 @@ under the License.
<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 @@ under the License.
<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">
@@ -527,6 +527,14 @@ under the License.
<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 @@ under the License.
</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>