Ejemplo n.º 1
0
 public ParentViewModel()
 {
     Jct_Asset_Dep_Unit                = new Jct_Asset_Dep_Unit();
     Jct_Asset_Dep_Company             = new Jct_Asset_Dep_Company();
     Jct_Asset_Dep_SubUnit             = new Jct_Asset_Dep_SubUnit();
     Jct_Asset_Dep_Book                = new Jct_Asset_Dep_Book();
     Jct_Asset_Dep_Group               = new Jct_Asset_Dep_Group();
     Jct_Asset_Dep_SubGroup            = new Jct_Asset_Dep_SubGroup();
     Jct_Asset_Dep_CompanyActRate      = new Jct_Asset_Dep_CompanyActRate();
     Jct_Asset_Dep_Bill_Info           = new Jct_Asset_Dep_Bill_Info();
     Jct_Asset_Dep_Asset               = new Jct_Asset_Dep_Asset();
     Jct_Asset_Dep_Book_AccountingYear = new Jct_Asset_Dep_Book_AccountingYear();
     Jct_Asset_Dep_Section             = new Jct_Asset_Dep_Section();
     FinancialYearMasterModel          = new FinancialYearMasterModel();
     Jct_Asset_Dep_Method              = new Jct_Asset_Dep_Method();
     Jct_Asset_Dep_Insurance           = new Jct_Asset_Dep_Insurance();
     Jct_Asset_Dep_Sub_Asset           = new Jct_Asset_Dep_Sub_Asset();
     Jct_Asset_Dep_Shift               = new Jct_Asset_Dep_Shift();
     SLMProspectiveCalculatorModel     = new SLMProspectiveCalculatorModel();
     DropDownViewModel = new DropDownViewModel();
     ReportViewModel   = new ReportViewModel();
 }
        public JsonResult SLMCalculation(SLMProspectiveCalculatorModel data)
        {
            if (!ModelState.Equals(null))
            {
                int count = 0;
                SLMProspectiveCalculatorModel        model = new SLMProspectiveCalculatorModel();
                List <SLMProspectiveCalculatorModel> list  = new List <SLMProspectiveCalculatorModel>();
                decimal monthUsed = 0;
                model.AccumulatedDepreciation = 0;
                model.AssetLife_Months        = data.AssetLife_Months;
                decimal Put_In_Use_Month = data.Put_In_Use.Month;
                model.AnnualDepreciationExpense = Math.Round(Convert.ToDecimal((data.AssetCost - data.SalvageValue) / data.AssetLife), 2);
                for (int i = 0; i <= data.AssetLife; i++)
                {
                    if (Put_In_Use_Month < 4)
                    {
                        monthUsed = 4 - Put_In_Use_Month;
                        model.DepreciationExpense      = Math.Round((monthUsed / 12) * Convert.ToDecimal(model.AnnualDepreciationExpense), 2);
                        model.AccumulatedDepreciation += model.DepreciationExpense;
                        list.Add(new SLMProspectiveCalculatorModel {
                            AnnualDepreciationExpense = model.AnnualDepreciationExpense, DepreciationExpense = model.DepreciationExpense, currentYear = i, AccumulatedDepreciation = model.AccumulatedDepreciation
                        });
                        Put_In_Use_Month = 5;
                    }
                    else
                    {
                        if (Put_In_Use_Month > 4)
                        {
                            int moon = Convert.ToInt16(Put_In_Use_Month);
                            switch (moon)
                            {
                            case 5:
                                monthUsed = 11;

                                break;

                            case 6:
                                monthUsed = 10;
                                break;

                            case 7:
                                monthUsed = 9;
                                break;

                            case 8:
                                monthUsed = 8;
                                break;

                            case 9:
                                monthUsed = 7;
                                break;

                            case 10:
                                monthUsed = 6;
                                break;

                            case 11:
                                monthUsed = 5;
                                break;

                            case 12:
                                monthUsed = 4;
                                break;

                            default:
                                break;
                            }

                            model.DepreciationExpense      = Math.Round((monthUsed / 12) * Convert.ToDecimal(model.AnnualDepreciationExpense), 2);
                            model.AccumulatedDepreciation += model.DepreciationExpense;
                            list.Add(new SLMProspectiveCalculatorModel {
                                AnnualDepreciationExpense = model.AnnualDepreciationExpense, DepreciationExpense = model.DepreciationExpense, currentYear = i, AccumulatedDepreciation = model.AccumulatedDepreciation
                            });
                            Put_In_Use_Month = 4;
                        }

                        else if (model.AssetLife_Months - monthUsed > 12)
                        {
                            model.DepreciationExpense      = Math.Round(Convert.ToDecimal(model.AnnualDepreciationExpense), 2);
                            model.AccumulatedDepreciation += model.DepreciationExpense;
                            monthUsed += 12;
                            list.Add(new SLMProspectiveCalculatorModel {
                                AnnualDepreciationExpense = model.AnnualDepreciationExpense, DepreciationExpense = model.DepreciationExpense, currentYear = i, AccumulatedDepreciation = model.AccumulatedDepreciation
                            });
                        }
                        else
                        {
                            decimal lifeleft = model.AssetLife_Months - monthUsed;
                            model.DepreciationExpense      = Math.Round((lifeleft / 12) * Convert.ToDecimal(model.AnnualDepreciationExpense), 2);
                            model.AccumulatedDepreciation += model.DepreciationExpense;
                            monthUsed += lifeleft;
                            list.Add(new SLMProspectiveCalculatorModel {
                                AnnualDepreciationExpense = model.AnnualDepreciationExpense, DepreciationExpense = model.DepreciationExpense, currentYear = i, AccumulatedDepreciation = model.AccumulatedDepreciation
                            });
                        }
                    }
                }
                decimal tempqq = monthUsed;
                var     temp   = list.Count;
                return(Json(new { Result = "OK", Records = list, TotalRecordCount = temp }, JsonRequestBehavior.AllowGet));
            }
            return(Json(new { }));
        }