Пример #1
0
        public ActionResult DepreciationView(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.CalculateProcessedDepreciation(depreciationPlanList, myDataSet);

            return(View(depreciationPlanList));
        }
Пример #2
0
        public void TestMethodDepretiatinProccessedView()
        {
            Depreciation             depreciation = new Depreciation();
            Dictionary <int, string> monthNames   = MocForMonths();

            int startMonth = 1, startYear = 2018, endMonth = 2, endYear = 2018;

            DepreciationPlanList depreciationPlanList = depreciation.CalculatePlan(startMonth, startYear, endMonth, endYear, monthNames);

            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
            });
            assetList.Add(new Asset()
            {
                Id = 3, AssetName = "Macierz dyskowa 50TB", StartUsingDate = new DateTime(2017, 12, 21), InitialValue = (decimal)25000, AmortisedValue = 0, DepreciationTypeId = 1
            });
            assetList.Add(new Asset()
            {
                Id = 6, AssetName = "Biurko prezesowej", StartUsingDate = new DateTime(2017, 12, 8), InitialValue = (decimal)10000.00, AmortisedValue = 0, DepreciationTypeId = 1
            });

            Dictionary <int, DepreciationType> depreciationTypes = new Dictionary <int, DepreciationType>();

            depreciationTypes.Add(1, new DepreciationType()
            {
                Id = 1, Name = "Liniowa 30%", DepreciationRate = (decimal)30
            });

            Dictionary <string, DepreciationCharge> depreciationCharges = new Dictionary <string, DepreciationCharge>();

            depreciationCharges.Add("2018012", new DepreciationCharge()
            {
                Id = 10, No = 1, Month = 1, Year = 2018, CurrentCharge = (decimal)25.01, CumulativelyCharge = (decimal)25.01, RemainingAmount = (decimal)975.20, AssetId = 2
            });
            depreciationCharges.Add("2018013", new DepreciationCharge()
            {
                Id = 11, No = 1, Month = 1, Year = 2018, CurrentCharge = (decimal)625.00, CumulativelyCharge = (decimal)25.01, RemainingAmount = (decimal)24375.00, AssetId = 3
            });
            depreciationCharges.Add("2018016", new DepreciationCharge()
            {
                Id = 12, No = 1, Month = 1, Year = 2018, CurrentCharge = (decimal)250.00, CumulativelyCharge = (decimal)25.01, RemainingAmount = (decimal)9750.00, AssetId = 6
            });
            depreciationCharges.Add("2018022", new DepreciationCharge()
            {
                Id = 13, No = 2, Month = 2, Year = 2018, CurrentCharge = (decimal)25.01, CumulativelyCharge = (decimal)50.02, RemainingAmount = (decimal)950.19, AssetId = 2
            });
            depreciationCharges.Add("2018023", new DepreciationCharge()
            {
                Id = 14, No = 2, Month = 2, Year = 2018, CurrentCharge = (decimal)625.00, CumulativelyCharge = (decimal)1250.00, RemainingAmount = (decimal)23750.00, AssetId = 3
            });
            depreciationCharges.Add("2018026", new DepreciationCharge()
            {
                Id = 15, No = 2, Month = 2, Year = 2018, CurrentCharge = (decimal)250.00, CumulativelyCharge = (decimal)500.00, RemainingAmount = (decimal)9500.00, AssetId = 6
            });

            MyDataSet myDataSet = new MyDataSet();

            myDataSet.AssetList           = assetList;
            myDataSet.DepreciationTypes   = depreciationTypes;
            myDataSet.DepreciationCharges = depreciationCharges;

            depreciation.CalculateProcessedDepreciation(depreciationPlanList, myDataSet);

            decimal total11 = 0;
            decimal total12 = 0;
            decimal total13 = 0;

            decimal total21 = 0;
            decimal total22 = 0;
            decimal total23 = 0;

            decimal total31 = 0;
            decimal total32 = 0;
            decimal total33 = 0;

            foreach (DepreciationPlan dep in depreciationPlanList.DepreciationPlans)
            {
                foreach (DepreciationItem d in dep.Depreciacions)
                {
                    total11 += d.CurrentCharge;
                    total12 += d.CumulativelyCharge;
                    total13 += d.RemainingAmount;
                }

                total21 += dep.CurrentCharge;
                total22  = dep.CumulativelyCharge;
                total23  = dep.RemainingAmount;
            }

            total31 = depreciationPlanList.TotalCurrentCharge;
            total32 = depreciationPlanList.TotalCumulativelyCharge;
            total33 = depreciationPlanList.TotalRemainingAmount;


            Assert.AreEqual(total11, total21);
            Assert.AreEqual(total31, total21);
            Assert.AreEqual(total22, total32);
            Assert.AreEqual(total23, total33);
        }