CFLib.org – Common Function Library Project

getDepreciatedValue(acq_cost, act_date, numberOfYears)

Last updated June 4, 2008
Download UDF

author

Steve Walker                                      Steve Walker

Version: 1 | Requires: ColdFusion MX | Library: FinancialLib

 
Rated 0 time(s). Average Rating: 0

Description:
This function outputs the current value of an item based on straight line depreciation.

Return Values:
Returns a number.

Example:

<cfoutput>
Current Value as of Today: #LSCurrencyFormat((getDepreciatedValue(125000,'9/1/2006', 8)))#
</cfoutput>

Parameters:

Name Description Required
acq_cost Cost of item. Yes
act_date Date item acquired. Yes
numberOfYears Number of years to depreciate the item. Yes

Full UDF Source:

<!---
This function outputs the current value of an item based on straight line depreciation.

@param acq_cost      Cost of item. (Required)
@param act_date      Date item acquired. (Required)
@param numberOfYears      Number of years to depreciate the item. (Required)
@return Returns a number.
@author Steve Walker (sneakyllama@gmail.com)
@version 1, June 4, 2008
--->

<cffunction name="getDepreciatedValue" output="no" returntype="numeric" hint="Calculates the current straight line depreciated value">
    <cfargument name="acq_cost" required="yes" type="numeric" hint="The acquistion cost or value of an item">
    <cfargument name="acq_date" type="date" required="yes" hint="the acquisition date of the item">
    <cfargument name="numberofYears" type="numeric" default="5" required="yes" hint="the number of years to depreciate the item.">
    <cfset var DV = "">
    <cfset var cost = arguments.acq_cost>
    <cfset var days = arguments.numberofYears * 365>
    <cfset var age = dateDiff('d', DateFormat(arguments.acq_date,'mm/dd/yyyy'), DateFormat(Now(),'mm/dd/yyyy'))>
    
    <cfif age gte days>
        <cfset age = days>
    </cfif>
    
    <cfset DV = (cost*((age/days)-1)*-1)>
    
    <cfreturn DV>
</cffunction>

Search CFLib.org


Latest Additions

John Bartlett John Bartlett added
browserDetect
4 day(s) ago

Rob Brooks-Bilson Rob Brooks-Bilson added
listCompare
7 day(s) ago

Stephen Withington Stephen Withington added
formToNameValueP...
15 day(s) ago

anthony petruzzi anthony petruzzi added
parseExcel
20 day(s) ago

Pablo Varando Pablo Varando added
returnRandomHEXC...
21 day(s) ago

Top Rated

Nathan Dintenfass                                 QueryStringChang...
Rated 5.0, 10 time(s)

Stephen Withington formToNameValueP...
Rated 5.0, 5 time(s)

Gyrus                                             HTMLSafe
Rated 5.0, 4 time(s)

Shlomy Gantz                                      viewCSS
Rated 5.0, 4 time(s)

Michael Sharman generateRandomKe...
Rated 5.0, 3 time(s)

Created by Raymond Camden / Design by Justin Johnson