public void CalculateProcessedDepreciation(DepreciationPlanList depreciationPlanList,
                                                   MyDataSet myDataSet)
        {
            foreach (DepreciationPlan depreciationPlan in depreciationPlanList.DepreciationPlans)
            {
                foreach (Asset asset in myDataSet.AssetList)
                {
                    DepreciationType depreciationType = myDataSet.DepreciationTypes[asset.DepreciationTypeId];
                    if (myDataSet.DepreciationCharges.ContainsKey(depreciationPlan.Year.ToString() + depreciationPlan.Month.ToString("00") + asset.Id.ToString()))
                    {
                        DepreciationCharge depreciationCharge = myDataSet.DepreciationCharges[depreciationPlan.Year.ToString() + depreciationPlan.Month.ToString("00") + asset.Id.ToString()];

                        DepreciationItem depr = new DepreciationItem();
                        depr.AssetName          = asset.AssetName;
                        depr.CurrentCharge      = depreciationCharge.CurrentCharge;
                        depr.CumulativelyCharge = depreciationCharge.CumulativelyCharge;
                        depr.RemainingAmount    = depreciationCharge.RemainingAmount;
                        depreciationPlan.Depreciacions.Add(depr);

                        depreciationPlan.CurrentCharge      += depreciationCharge.CurrentCharge;
                        depreciationPlan.CumulativelyCharge += depreciationCharge.CumulativelyCharge;
                        depreciationPlan.RemainingAmount    += depreciationCharge.RemainingAmount;

                        depreciationPlanList.TotalCurrentCharge += depreciationCharge.CurrentCharge;
                    }
                }
                if (depreciationPlan.CumulativelyCharge != 0)
                {
                    depreciationPlanList.TotalCumulativelyCharge = depreciationPlan.CumulativelyCharge;
                    depreciationPlanList.TotalRemainingAmount    = depreciationPlan.RemainingAmount;
                }
            }
        }
示例#2
0
        public ActionResult DeleteConfirmed(int id)
        {
            DepreciationType depreciationType = db.T_DepreciationTypes.Find(id);

            db.T_DepreciationTypes.Remove(depreciationType);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#3
0
 public ActionResult Edit([Bind(Include = "Id,Name,DepreciationRate")] DepreciationType depreciationType)
 {
     if (ModelState.IsValid)
     {
         db.Entry(depreciationType).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(depreciationType));
 }
        public void PrepareViewBagAssetDictionaryDescriptions(Controller controller, ApplicationDbContext db, Asset asset)
        {
            AssetLocation    assetLocation    = db.T_AssetLocations.Find(asset.AssetLocationId);
            AssetType        assetType        = db.T_AssetTypes.Find(asset.AssetTypeId);
            DepreciationType depreciationType = db.T_DepreciationTypes.Find(asset.DepreciationTypeId);

            controller.ViewBag.AssetLocation    = assetLocation.Name;
            controller.ViewBag.AssetType        = assetType.Name;
            controller.ViewBag.DepreciationType = depreciationType.Name;
        }
示例#5
0
        public ActionResult Create([Bind(Include = "Id,Name,DepreciationRate")] DepreciationType depreciationType)
        {
            if (ModelState.IsValid)
            {
                db.T_DepreciationTypes.Add(depreciationType);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(depreciationType));
        }
示例#6
0
        // GET: DepreciationTypes/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            DepreciationType depreciationType = db.T_DepreciationTypes.Find(id);

            if (depreciationType == null)
            {
                return(HttpNotFound());
            }
            return(View(depreciationType));
        }
示例#7
0
        // GET: DepreciationTypes/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            DepreciationType depreciationType = db.T_DepreciationTypes.Find(id);

            if (depreciationType == null)
            {
                return(HttpNotFound());
            }
            if (!DataManipulation.CannDeleteDepreciationType(db, id))
            {
                return(RedirectToAction("CanNotDelete"));
            }
            return(View(depreciationType));
        }
        public void CalculatePlanForAssets(DepreciationPlanList depreciationPlanList,
                                           MyDataSet myDataSet,
                                           bool posting)
        {
            foreach (DepreciationPlan depreciationPlan in depreciationPlanList.DepreciationPlans)
            {
                foreach (Asset asset in myDataSet.AssetList)
                {
                    if (DataManipulation.CanProcessDepretiatin(asset.StartUsingDate, new DateTime(depreciationPlan.Year, depreciationPlan.Month, 1)))
                    {
                        DepreciationType depreciationType = myDataSet.DepreciationTypes[asset.DepreciationTypeId];
                        AssetType        assetType        = myDataSet.AssetTypes.Where(at => at.Id == asset.AssetTypeId).FirstOrDefault();
                        decimal          depreciation     = 0;
                        if (assetType.LowValueAsset)
                        {
                            depreciation = asset.InitialValue;
                        }
                        else
                        {
                            depreciation = decimal.Round(asset.InitialValue * ((depreciationType.DepreciationRate / 100) / 12), 2);
                        }

                        if (!myDataSet.DepreciationCharges.ContainsKey(depreciationPlan.Year.ToString() + depreciationPlan.Month.ToString("00") + asset.Id.ToString()) && depreciation != 0)
                        {
                            if (asset.AmortisedValue + depreciation > asset.InitialValue)
                            {
                                depreciation = asset.InitialValue - asset.AmortisedValue;
                            }
                            asset.AmortisedValue += depreciation;
                            //Księgowanie umożenia
                            if (posting && asset.AmortisedValue <= asset.InitialValue && asset.IsUsed && !asset.Depreciated && depreciation != 0)
                            {
                                DepreciationCharge depreciationCharge = new DepreciationCharge();
                                depreciationCharge.Month              = depreciationPlan.Month;
                                depreciationCharge.Year               = depreciationPlan.Year;
                                depreciationCharge.AssetId            = asset.Id;
                                depreciationCharge.CurrentCharge      = depreciation;
                                depreciationCharge.RemainingAmount    = asset.InitialValue - asset.AmortisedValue;
                                depreciationCharge.CumulativelyCharge = asset.AmortisedValue;
                                depreciationCharge.No = db.T_DepreciationCharges.Where(dc => dc.AssetId == asset.Id).ToList().Count + 1;
                                db.T_DepreciationCharges.Add(depreciationCharge);

                                Asset assetForModfy = db.T_Assets.Find(asset.Id);
                                assetForModfy.AmortisedValue += depreciation;
                                if (assetForModfy.AmortisedValue == assetForModfy.InitialValue)
                                {
                                    assetForModfy.Depreciated = true;
                                }

                                db.SaveChanges();
                            }
                        }
                        DepreciationItem depr = new DepreciationItem();
                        depr.AssetName     = asset.AssetName;
                        depr.CurrentCharge = depreciation;
                        if (depreciation != 0)
                        {
                            depreciationPlan.Depreciacions.Add(depr);
                        }
                        depreciationPlan.CurrentCharge          += depreciation;
                        depreciationPlanList.TotalCurrentCharge += depreciation;
                    }
                }
            }
        }