- Basics of AngularJS: Part 1
- Microsoft Build 2015 Top Highlights ...
- How to Configure SharePoint Server ...
- How to Create Nodejs Module and Pub ...
- Basics of AngularJS: Part 2
- Learn Simple MVVM and Command Bindi ...
- jQuery Validation Plugin to Validat ...
- Simplify JavaScript Object Oriented ...
- ASP.Net SignalR: Building a Simple ...
- Node.js and AngularJS With SQL Server

# Financial Calculation using .NET: Part II

**Introduction**

In this article we will look how we can use "Microsoft.VisualBasic" namespace to do single line and double line depreciation calculation.**Other Articles of Financial Calculation**

Future value calculation: - Click Here**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.

You can find the source code at the top of this article.

I am 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. You can visit about my organization at www.questpond.com and also en... Read more

- rank47
- 2.3m readers
- GoldMember
- 3 times

## comments