Click here to Skip to main content
Licence CPOL
First Posted 30 Oct 2008
Views 17,213
Bookmarked 20 times

Financial Calculation using .NET:- Depreciation Part-2

By | 30 Oct 2008 | Article
Financial Calculation using .NET:- Depreciation Part-2
Title:       Financial Calculation using .NET:- Depreciation (Part-2)
Author:      Shivprasad Koirala 
Email:       shiv_koirala@yahoo.com
Language:    C#, VB.net, ASP.net.
Level:       Beginner
Description: Financial Calculation using .NET:- Depreciation (Part-2)

Financial Calculation using .NET:-  Depreciation


Introduction

Other Articles of Financial Calculation

Definition of Depreciation

Understanding Single line depreciation

Understanding double declining depreciation

The source code

 

 

 

 

 

Introduction
 

In this article we will look how we can use “Microsoft.VisualBasic” namespace to do single line and double line depreciation calculation.

I have been writing and recording lot of architecture related videos on design patterns, UML, FPA estimation, Enterprise application blocks, C# projects etc you can watch my videos on http://www.questpond.com 

 

Other Articles of Financial Calculation

Future value calculation: -

FinanceCalculation.aspx

 I had really got a bad a very bad rating for this article. I have tried to improve myself in this article.

 

Definition of Depreciation

Any asset we buy for an organization has a finite life time. As time passes by asset looses value. Depreciation helps us to evaluate the wear and tear for fixed assets over a period of time.

 

Understanding Single line depreciation

Straight line depreciation is the simplest and widely used technique. Below figure ‘straight line depreciation’ shows the complete formula for the same. Fixed cost asset is the total cost of the asset. Scrap value is the asset value when it will be finally sold or disposed. For instance let’s say you have bought a computer and you use it for 5 years. Even after five years the computer will still sell for some amount. There is a possibility depending on asset that the scrap value can be zero. Life span of the asset is the total life time of the asset.

To calculate straight line depreciation we need to use the ‘SLN’ formulae. It takes three values the fixed cost which is termed as cost in excel , scrap value also called as salvage value and the life of the asset. This returns us depreciation calculation per month.

So for a asset of fixed cost 15000, scrap value of 2000 and life span of 5 years below is the spread and calculation.

Years

First year

Second

Year

Third

Year

Fourth

Year

Fifth

Year

Depreciation Value

2600

2600

2600

2600

2600

Total Depreciation

13000

Balance

2000

 

Understanding double declining depreciation

Double declining is type of acceleration depreciation method. Accelerated depreciation means it recognizes a higher depreciation at the beginning of the life time of the asset. First let’s understand what declining appreciation is ?. Double declining depreciation value is twice the value of the straight line depreciation. In double declining previous years asset value becomes the input to the next year’s depreciation calculation. Below figure ‘Double declining balance’ shows how calculations are done for every year. The basic formula for calculating depreciation is as below.

Depreciation expense = previous period value * ( Factor / Life of Asset )

From the above formula we will get depreciation expense on a per month basis. Previous period value is the value of the asset after deducting the depreciation of that year. Factor value is two for double declining depreciation. Life of asset is the life of the asset.

So let’s analyze the below calculation for double declining balance. In the below example we have asset of cost around 19000 with scrap value of 2000 and life of the asset is five years. So the first year of calculation is fixed cost multiplied by factor divided by life of asset which comes to around 7600. Now to calculate for the second year we subtract the depreciation of the first year from the fixed cost and multiple by factor divided by life of asset. In the same way we carry forward for third and fourth year. Now for the fifth year we deduct the previous brought forward from the scrap value, because this is the final year of the life of asset. So for the final year the depreciation is 462. Try to follow the way carry forwards are taken from previous year to the next year this will clear your fundamentals in a more appropriate manner.


 

The source code

Now lets see how we can achieve the above two things using the Financial class provided in ‘Microsoft.VisualBasic’ namespace.

First lets create a class which has the year and the value of the depreciation , below is the code for the same.

public class clsYearValue
    {
        private int _intYear;
        private double _dblCalculated;
        public int Year
        {
            set
            {
                _intYear = value;
            }
            get
            {
                return _intYear;
            }
        }
        public double CalculatedAmount
        {
            set
            {
                _dblCalculated = value;
            }
            get
            {
                return _dblCalculated;
            }
        }
    }

 

Definitely when we talk about depreciation it will have collection of values with year. So let’s create a strongly typed class called ‘clsYearValues’ which holds a collection of ‘clsYearValue’ class.

public class clsYearValue
    public class clsYearValues : CollectionBase
    {
        public void Add(clsYearValue obj)
        {
            List.Add(obj);
        }
    }

 

We will create a function which will take in number of years, salvage value and fixed cost. So first let’s create object of year class and year’s class which is a collection.

clsYearValues objYearValues = new clsYearValues();
clsYearValue objYear = new clsYearValue();

 

Depending on the number of years we will loop and get the single line depreciation value using the SLN function of the static ‘Financial’ class. Once the value is calculated we add the object to the collection.

for (int itemp = 1; itemp <= NumberOfYears; itemp++)
{
    objYear = new clsYearValue();
    objYear.Year = itemp;
    objYear.CalculatedAmount = Financial.SLN(FixedCost, ScrapValue, NumberOfYears);
    objYearValues.Add(objYear);
}

 

To calculate double declining we again loop and use the DBB function of the ‘Financial’ static class. Once we get the value we add the value in to the collection.

for (int itemp = 1; itemp <= NumberOfYears; itemp++)
{
    objYear = new clsYearValue();
    objYear.Year = itemp;
    objYear.CalculatedAmount = Financial.DDB(FixedCost, ScrapValue, NumberOfYears, itemp, 2);
    objYearValues.Add(objYear);
}

 

The function also takes which type of calculation to perform. If we pass 1 in the function it will calculate single line depreciation and for 2 it will calculate double line depreciation.

Finally we create the object of the financial class and calculate single line and double line depreciation. We first pass 1 to calculate the single line depreciation and 2 for double line. We have created to data grid one which binds the single line depreciation calculation and second for double line depreciation calculations.

protected void btnCalculate_Click(object sender, EventArgs e)
    {
    clsFinancial objFinancial = new clsFinancial();
    DataGrid1.DataSource = objFinancial.Calculate(Convert.ToDouble(txtValueofAsset.Text),
                            Convert.ToDouble(txtScrapValue.Text),
                            Convert.ToInt16(txtLifeofAsset.Text), 1);
    DataGrid1.DataBind();
    DataGrid2.DataSource = objFinancial.Calculate(Convert.ToDouble(txtValueofAsset.Text),
                            Convert.ToDouble(txtScrapValue.Text),
                            Convert.ToInt16(txtLifeofAsset.Text), 2);
    DataGrid2.DataBind();
    }

Below is the screen shot which shows single line and double line depreciation for 20 years with a scrap value of 1000 and asset value of 50000.
To download the source code, Click here


 

 

 

 

 


 

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Shivprasad koirala

Architect
http://www.questpond.com
India India

Member

I am a Microsoft MVP for ASP/ASP.NET and currently a CEO of a small
E-learning company in India. We are very much active in making training videos ,
writing books and corporate trainings. Do visit my site for 
.NET, C# , design pattern , WCF , Silverlight
, LINQ , ASP.NET , ADO.NET , Sharepoint , UML , SQL Server  training 
and Interview questions and answers



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralGood one PinmemberSrikantgklNbo0:22 31 Oct '08  
GeneralRe: Good one PinmemberShivprasad koirala0:29 31 Oct '08  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web01 | 2.5.120517.1 | Last Updated 31 Oct 2008
Article Copyright 2008 by Shivprasad koirala
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid