public ActionResult Depreciation(int startMonth, int startYear, int endMonth, int endYear) { Depreciation depreciation = new Depreciation(); MyDataSet myDataSet = new MyDataSet(db); DepreciationPlanList depreciationPlanList = depreciation.CalculatePlan(startMonth, startYear, endMonth, endYear, myDataSet.MonthNames); depreciation.CalculatePlanForAssets(depreciationPlanList, myDataSet, true); return(View(depreciationPlanList)); }
public void TestMethodDepretiatinPlanCalculation() { Depreciation depreciation = new Depreciation(); Dictionary <int, string> monthNames = MocForMonths(); int startMonth = 2, startYear = 2017, endMonth = 5, endYear = 2030; DepreciationPlanList depreciationPlanList = depreciation.CalculatePlan(startMonth, startYear, endMonth, endYear, monthNames); List <AssetType> assetTypes = new List <AssetType>(); assetTypes.Add(new AssetType() { Id = 3, LowValueAsset = false, Name = "Zestaw komputerowy" }); assetTypes.Add(new AssetType() { Id = 4, LowValueAsset = false, Name = "Drukarka" }); assetTypes.Add(new AssetType() { Id = 5, LowValueAsset = false, Name = "Serwer" }); assetTypes.Add(new AssetType() { Id = 6, LowValueAsset = true, Name = "Biurko" }); assetTypes.Add(new AssetType() { Id = 7, LowValueAsset = true, Name = "Krzeslo" }); assetTypes.Add(new AssetType() { Id = 8, LowValueAsset = false, Name = "Projektor" }); assetTypes.Add(new AssetType() { Id = 9, LowValueAsset = false, Name = "UPS" }); assetTypes.Add(new AssetType() { Id = 10, LowValueAsset = false, Name = "Macierz dyskowa" }); assetTypes.Add(new AssetType() { Id = 11, LowValueAsset = false, Name = "Super biurko prezesowej" }); List <Asset> assetList = new List <Asset>(); assetList.Add(new Asset() { Id = 2, AssetName = "Serwer HP", StartUsingDate = new DateTime(2017, 12, 8), InitialValue = (decimal)1000.21, AmortisedValue = 0, DepreciationTypeId = 1, AssetTypeId = 5, IsUsed = true, Depreciated = false }); assetList.Add(new Asset() { Id = 3, AssetName = "Macierz dyskowa 50TB", StartUsingDate = new DateTime(2017, 12, 21), InitialValue = (decimal)25000, AmortisedValue = 0, DepreciationTypeId = 1, AssetTypeId = 10, IsUsed = true, Depreciated = false }); assetList.Add(new Asset() { Id = 6, AssetName = "Biurko prezesowej", StartUsingDate = new DateTime(2017, 12, 8), InitialValue = (decimal)10000.00, AmortisedValue = 0, DepreciationTypeId = 1, AssetTypeId = 11, IsUsed = true, Depreciated = false }); assetList.Add(new Asset() { Id = 9, AssetName = "Biurko pracownika", StartUsingDate = new DateTime(2017, 10, 15), InitialValue = (decimal)500.00, AmortisedValue = 0, DepreciationTypeId = 2, AssetTypeId = 6, IsUsed = true, Depreciated = false }); Dictionary <int, DepreciationType> depreciationTypes = new Dictionary <int, DepreciationType>(); depreciationTypes.Add(1, new DepreciationType() { Id = 1, Name = "Liniowa 30%", DepreciationRate = (decimal)30 }); depreciationTypes.Add(2, new DepreciationType() { Id = 2, Name = "Jednorazowa", DepreciationRate = (decimal)100 }); Dictionary <string, DepreciationCharge> depreciationCharges = new Dictionary <string, DepreciationCharge>(); MyDataSet myDataSet = new MyDataSet(); myDataSet.AssetList = assetList; myDataSet.DepreciationTypes = depreciationTypes; myDataSet.DepreciationCharges = depreciationCharges; myDataSet.AssetTypes = assetTypes; depreciation.CalculatePlanForAssets(depreciationPlanList, myDataSet, false); decimal total = 0; foreach (DepreciationPlan dep in depreciationPlanList.DepreciationPlans) { total += dep.CurrentCharge; } Assert.AreEqual(total, (decimal)(10000.00 + 25000.00 + 1000.21 + 500)); }