Example #1
0
        public ProdCostPerOreMinedDetails ComputeProdCostPerOReMined(CostKPI value)
        {
            if (value == null)
            {
                return(null);
            }

            List <CostSetting> costSetting = _cmcOmtSqlDb.CostSettings.ToList();
            int     curMonth = System.DateTime.Now.Month - 1;
            decimal prodCost = costSetting[curMonth].ProductionCost;

            ProdCostPerOreMinedDetails finalValues = new ProdCostPerOreMinedDetails();

            finalValues.TotalOreMined             = value.TotalLimoWMT + value.TotalSaproWMT;
            finalValues.ProductionCost            = prodCost;
            finalValues.ProductionCostPerOreMined = prodCost / (value.TotalLimoWMT + value.TotalSaproWMT);

            finalValues.JanuaryProdCost   = costSetting[0].ProductionCost;
            finalValues.FebruaryProdCost  = costSetting[1].ProductionCost;
            finalValues.MarchProdCost     = costSetting[2].ProductionCost;
            finalValues.MayProdCost       = costSetting[3].ProductionCost;
            finalValues.AprilProdCost     = costSetting[4].ProductionCost;
            finalValues.JuneProdCost      = costSetting[5].ProductionCost;
            finalValues.JulyProdCost      = costSetting[6].ProductionCost;
            finalValues.AugustProdCost    = costSetting[7].ProductionCost;
            finalValues.SeptemberProdCost = costSetting[8].ProductionCost;
            finalValues.OctoberProdCost   = costSetting[9].ProductionCost;
            finalValues.NovemberProdCost  = costSetting[10].ProductionCost;
            finalValues.DecemberProdCost  = costSetting[11].ProductionCost;

            finalValues.JanuaryOreMined   = value.JanuaryLimoWMT + value.JanuarySaproWMT;
            finalValues.FebruaryOreMined  = value.FebruaryLimoWMT + value.FebruarySaproWMT;
            finalValues.MarchOreMined     = value.MarchLimoWMT + value.MarchSaproWMT;
            finalValues.MayOreMined       = value.AprilLimoWMT + value.AprilSaproWMT;
            finalValues.AprilOreMined     = value.MayLimoWMT + value.MaySaproWMT;
            finalValues.JuneOreMined      = value.JuneLimoWMT + value.JuneSaproWMT;
            finalValues.JulyOreMined      = value.JulyLimoWMT + value.JulySaproWMT;
            finalValues.AugustOreMined    = value.AugustLimoWMT + value.AugustSaproWMT;
            finalValues.SeptemberOreMined = value.SeptemberLimoWMT + value.SeptemberSaproWMT;
            finalValues.OctoberOreMined   = value.OctoberLimoWMT + value.OctoberSaproWMT;
            finalValues.NovemberOreMined  = value.NovemberLimoWMT + value.NovemberSaproWMT;
            finalValues.DecemberOreMined  = value.DecemberLimoWMT + value.DecemberSaproWMT;

            finalValues.JanuaryTotalCost   = ComputeTotalCost(costSetting[0].ProductionCost, (value.JanuaryLimoWMT + value.JanuarySaproWMT));
            finalValues.FebruaryTotalCost  = ComputeTotalCost(costSetting[1].ProductionCost, (value.FebruaryLimoWMT + value.FebruarySaproWMT));
            finalValues.MarchTotalCost     = ComputeTotalCost(costSetting[2].ProductionCost, (value.MarchLimoWMT + value.MarchSaproWMT));
            finalValues.MayTotalCost       = ComputeTotalCost(costSetting[3].ProductionCost, (value.AprilLimoWMT + value.AprilSaproWMT));
            finalValues.AprilTotalCost     = ComputeTotalCost(costSetting[4].ProductionCost, (value.MayLimoWMT + value.MaySaproWMT));
            finalValues.JuneTotalCost      = ComputeTotalCost(costSetting[5].ProductionCost, (value.JuneLimoWMT + value.JuneSaproWMT));
            finalValues.JulyTotalCost      = ComputeTotalCost(costSetting[6].ProductionCost, (value.JulyLimoWMT + value.JulySaproWMT));
            finalValues.AugustTotalCost    = ComputeTotalCost(costSetting[7].ProductionCost, (value.AugustLimoWMT + value.AugustSaproWMT));
            finalValues.SeptemberTotalCost = ComputeTotalCost(costSetting[8].ProductionCost, (value.SeptemberLimoWMT + value.SeptemberSaproWMT));
            finalValues.OctoberTotalCost   = ComputeTotalCost(costSetting[9].ProductionCost, (value.OctoberLimoWMT + value.OctoberSaproWMT));
            finalValues.NovemberTotalCost  = ComputeTotalCost(costSetting[10].ProductionCost, (value.NovemberLimoWMT + value.NovemberSaproWMT));
            finalValues.DecemberTotalCost  = ComputeTotalCost(costSetting[11].ProductionCost, (value.DecemberLimoWMT + value.DecemberSaproWMT));

            return(finalValues);
        }
        public ActionResult CostPerKPI()
        {
            if (Session["user"] == null)
            {
                Response.Redirect("/Reports/Login", true);
            }

            finalDEURList = (List <TonnageByActivity>)Session["DEURList"];
            if (finalDEURList == null)
            {
                finalDEURList = GenerateDEURList(1);
            }

            CostKPI costKPIVariables = new CostKPI();

            costKPIVariables = ComputeCostVariables(finalDEURList);

            ProdCostPerOreMinedDetails costDetails = new ProdCostPerOreMinedDetails();

            costDetails = ComputeProdCostPerOReMined(costKPIVariables);
            Session["ProdCostPerOreMined"] = costDetails;

            return(View(costDetails));
        }
Example #3
0
        public CostKPI ComputeCostVariables(List <TonnageByActivity> DEURList)
        {
            if (DEURList.Count == 0)
            {
                return(null);
            }

            CostKPI finalValues = new CostKPI();
            List <TonnageByActivity> tonnageList      = new List <TonnageByActivity>();
            List <TonnageByActivity> tempTonnageList  = new List <TonnageByActivity>();
            List <TonnageByActivity> limoTonnageList  = new List <TonnageByActivity>();
            List <TonnageByActivity> saproTonnageList = new List <TonnageByActivity>();

            tonnageList = DEURList.Where(s => s.TonnageAmount > 0).OrderByDescending(s => s.MaterialDateOfEntry).ToList();
            if (tonnageList.Count == 0)
            {
                return(null);
            }
            DateTime?latestDate = tonnageList[0].MaterialDateOfEntry;

            string yearlyDate = "";

            //get year-to-date tonnage from January 1 - to the latest date of the latest year available
            tempTonnageList = tonnageList.Where(s => s.MaterialDateOfEntry.Value.Year == latestDate.Value.Year).ToList();
            limoTonnageList = tonnageList.Where(s => s.MaterialDateOfEntry.Value.Year == latestDate.Value.Year &&
                                                (s.MaterialName.ToUpper() == "LIMONITE" || s.MaterialName.ToUpper() == "LIMO" || s.MaterialName.ToUpper() == "SHIPPABLE LIMO")).ToList();
            saproTonnageList = tonnageList.Where(s => s.MaterialDateOfEntry.Value.Year == latestDate.Value.Year &&
                                                 (s.MaterialName.ToUpper() == "SAPROLITE" || s.MaterialName.ToUpper() == "SAPRO" || s.MaterialName.ToUpper() == "SHIPPABLE SAPRO")).ToList();
            if (tempTonnageList.Count() > 0)
            {
                yearlyDate = tempTonnageList[0].MaterialDateOfEntry.Value.Year.ToString();
                finalValues.TotalLimoWMT    = limoTonnageList.Select(s => s.TonnageAmount).Sum();
                finalValues.TotalSaproWMT   = saproTonnageList.Select(s => s.TonnageAmount).Sum();
                finalValues.TotalManHour    = Convert.ToDecimal((limoTonnageList.Select(s => s.TotalMinutes).Sum() / 60) + (saproTonnageList.Select(s => s.TotalMinutes).Sum() / 60));
                finalValues.AverageDistance = Convert.ToDecimal((limoTonnageList.Select(s => s.Distance).Sum() +
                                                                 saproTonnageList.Select(s => s.Distance).Sum()) /
                                                                (limoTonnageList.Count() + saproTonnageList.Count()));

                finalValues.TotalBargeLimoWMT  = limoTonnageList.Where(s => s.GeneralActivity.ToUpper() == "BARGELOADING/SHIPLOADING").Select(s => s.TonnageAmount).Sum();
                finalValues.TotalBargeSaproWMT = saproTonnageList.Where(s => s.GeneralActivity.ToUpper() == "BARGELOADING/SHIPLOADING").Select(s => s.TonnageAmount).Sum();

                finalValues.JanuarySaproWMT   = saproTonnageList.Where(s => s.MaterialDateOfEntry.Value.Month == 1).Select(s => s.TonnageAmount).Sum();
                finalValues.FebruarySaproWMT  = saproTonnageList.Where(s => s.MaterialDateOfEntry.Value.Month == 2).Select(s => s.TonnageAmount).Sum();
                finalValues.MarchSaproWMT     = saproTonnageList.Where(s => s.MaterialDateOfEntry.Value.Month == 3).Select(s => s.TonnageAmount).Sum();
                finalValues.MaySaproWMT       = saproTonnageList.Where(s => s.MaterialDateOfEntry.Value.Month == 4).Select(s => s.TonnageAmount).Sum();
                finalValues.AprilSaproWMT     = saproTonnageList.Where(s => s.MaterialDateOfEntry.Value.Month == 5).Select(s => s.TonnageAmount).Sum();
                finalValues.JuneSaproWMT      = saproTonnageList.Where(s => s.MaterialDateOfEntry.Value.Month == 6).Select(s => s.TonnageAmount).Sum();
                finalValues.JulySaproWMT      = saproTonnageList.Where(s => s.MaterialDateOfEntry.Value.Month == 7).Select(s => s.TonnageAmount).Sum();
                finalValues.AugustSaproWMT    = saproTonnageList.Where(s => s.MaterialDateOfEntry.Value.Month == 8).Select(s => s.TonnageAmount).Sum();
                finalValues.SeptemberSaproWMT = saproTonnageList.Where(s => s.MaterialDateOfEntry.Value.Month == 9).Select(s => s.TonnageAmount).Sum();
                finalValues.OctoberSaproWMT   = saproTonnageList.Where(s => s.MaterialDateOfEntry.Value.Month == 10).Select(s => s.TonnageAmount).Sum();
                finalValues.NovemberSaproWMT  = saproTonnageList.Where(s => s.MaterialDateOfEntry.Value.Month == 11).Select(s => s.TonnageAmount).Sum();
                finalValues.DecemberSaproWMT  = saproTonnageList.Where(s => s.MaterialDateOfEntry.Value.Month == 12).Select(s => s.TonnageAmount).Sum();

                finalValues.JanuaryLimoWMT   = limoTonnageList.Where(s => s.MaterialDateOfEntry.Value.Month == 1).Select(s => s.TonnageAmount).Sum();
                finalValues.FebruaryLimoWMT  = limoTonnageList.Where(s => s.MaterialDateOfEntry.Value.Month == 2).Select(s => s.TonnageAmount).Sum();
                finalValues.MarchLimoWMT     = limoTonnageList.Where(s => s.MaterialDateOfEntry.Value.Month == 3).Select(s => s.TonnageAmount).Sum();
                finalValues.MayLimoWMT       = limoTonnageList.Where(s => s.MaterialDateOfEntry.Value.Month == 4).Select(s => s.TonnageAmount).Sum();
                finalValues.AprilLimoWMT     = limoTonnageList.Where(s => s.MaterialDateOfEntry.Value.Month == 5).Select(s => s.TonnageAmount).Sum();
                finalValues.JuneLimoWMT      = limoTonnageList.Where(s => s.MaterialDateOfEntry.Value.Month == 6).Select(s => s.TonnageAmount).Sum();
                finalValues.JulyLimoWMT      = limoTonnageList.Where(s => s.MaterialDateOfEntry.Value.Month == 7).Select(s => s.TonnageAmount).Sum();
                finalValues.AugustLimoWMT    = limoTonnageList.Where(s => s.MaterialDateOfEntry.Value.Month == 8).Select(s => s.TonnageAmount).Sum();
                finalValues.SeptemberLimoWMT = limoTonnageList.Where(s => s.MaterialDateOfEntry.Value.Month == 9).Select(s => s.TonnageAmount).Sum();
                finalValues.OctoberLimoWMT   = limoTonnageList.Where(s => s.MaterialDateOfEntry.Value.Month == 10).Select(s => s.TonnageAmount).Sum();
                finalValues.NovemberLimoWMT  = limoTonnageList.Where(s => s.MaterialDateOfEntry.Value.Month == 11).Select(s => s.TonnageAmount).Sum();
                finalValues.DecemberLimoWMT  = limoTonnageList.Where(s => s.MaterialDateOfEntry.Value.Month == 12).Select(s => s.TonnageAmount).Sum();
            }

            return(finalValues);
        }