public virtual void CopyTotalGeneralCapital1StockProperties(
     GeneralCapital1Stock calculator)
 {
     this.TotalEnergyUseHr      = calculator.TotalEnergyUseHr;
     this.TotalEnergyEffTypical = calculator.TotalEnergyEffTypical;
     this.TotalRandMPercent     = calculator.TotalRandMPercent;
 }
        public static bool AddMachineryInputToStock(GeneralCapital1Stock machStock, double multiplier,
                                                    GeneralCapital1Input machinput, string currentNodeName, bool adjustTotals)
        {
            bool bHasCalculations = false;

            //inheriting classes usually run this class, but adjust their own totals
            if (adjustTotals)
            {
                //multipliers (input.times, out.compositionamount, oc.amount, tp.amount)
                //don't change per hour machinery costs, only total costs
                if (currentNodeName.EndsWith(Input.INPUT_PRICE_TYPES.input.ToString()))
                {
                    //i.e. machinput.cost = machinput.cost * multiplier * input.ocamount
                    //multiplier = input.times * oc.amount * tp.amount
                    ChangeMachineryInputByInputMultipliers(machinput, multiplier);
                }
                else
                {
                    //i.e. machinput.cost = machinput.cost * multiplier (1 in stock analyzers)
                    ChangeMachineryInputByMultiplier(machinput, multiplier);
                }
            }
            machStock.TotalMarketValue               += (machinput.MarketValue);
            machStock.TotalSalvageValue              += (machinput.SalvageValue);
            machStock.TotalFuelAmount                += (machinput.FuelAmount);
            machStock.TotalFuelPrice                 += AgBudgetingRules.GetFuelPrice(machinput);
            machStock.TotalFuelCost                  += (machinput.FuelCost);
            machStock.TotalEnergyUseHr               += (machinput.EnergyUseHr);
            machStock.TotalEnergyEffTypical          += (machinput.EnergyEffTypical);
            machStock.TotalRandMPercent              += (machinput.Capital1Constant.RandMPercent);
            machStock.TotalRepairCost                += (machinput.RepairCost);
            machStock.TotalLaborAmount               += (machinput.LaborAmount);
            machStock.TotalLaborPrice                += AgBudgetingRules.GetLaborPrice(machinput);
            machStock.TotalLaborCost                 += (machinput.LaborCost);
            machStock.TotalCapitalRecoveryCost       += (machinput.CapitalRecoveryCost);
            machStock.TotalTaxesHousingInsuranceCost += (machinput.TaxesHousingInsuranceCost);
            machStock.TotalPriceGas                  += (machinput.Constants.PriceGas);
            machStock.TotalPriceDiesel               += (machinput.Constants.PriceDiesel);
            machStock.TotalPriceLP              += (machinput.Constants.PriceLP);
            machStock.TotalPriceElectric        += (machinput.Constants.PriceElectric);
            machStock.TotalPriceNG              += (machinput.Constants.PriceNG);
            machStock.TotalPriceOil             += (machinput.Constants.PriceOil);
            machStock.TotalPriceRegularLabor    += (machinput.Constants.PriceRegularLabor);
            machStock.TotalPriceMachineryLabor  += (machinput.Constants.PriceMachineryLabor);
            machStock.TotalPriceSupervisorLabor += (machinput.Constants.PriceSupervisorLabor);
            machStock.TotalStartingHrs          += (machinput.Constants.StartingHrs);
            machStock.TotalPlannedUseHrs        += (machinput.Constants.PlannedUseHrs);
            machStock.TotalUsefulLifeHrs        += (machinput.Constants.UsefulLifeHrs);
            machStock.TotalHousingPercent       += (machinput.Constants.HousingPercent);
            machStock.TotalTaxPercent           += (machinput.Constants.TaxPercent);
            machStock.TotalInsurePercent        += (machinput.Constants.InsurePercent);
            bHasCalculations = true;
            return(bHasCalculations);
        }
 public static void AddMachineryStockTotals(GeneralCapital1Stock mach1Stock,
                                            ref XElement machStockCalcElement)
 {
     //these have already been adjusted by input multipliers (ocamount, times)
     mach1Stock.TotalOC = mach1Stock.TotalFuelCost + mach1Stock.TotalLaborCost
                          + mach1Stock.TotalRepairCost;
     mach1Stock.TotalAOH = mach1Stock.TotalCapitalRecoveryCost
                           + mach1Stock.TotalTaxesHousingInsuranceCost;
     CalculatorHelpers.SetAttributeDoubleF2(machStockCalcElement,
                                            CostBenefitCalculator.TOC, mach1Stock.TotalOC);
     CalculatorHelpers.SetAttributeDoubleF2(machStockCalcElement,
                                            CostBenefitCalculator.TAOH, mach1Stock.TotalAOH);
 }
        //add a GeneralCapital1Input to the baseStat.GenCapitalStocks dictionary
        public static bool AddGeneralCapital1StocksToDictionary(
            this GeneralCapital1Stock baseStat,
            int filePosition, int nodePosition, GeneralCapital1Input calculator)
        {
            bool bIsAdded = false;

            if (filePosition < 0 || nodePosition < 0)
            {
                baseStat.ErrorMessage
                    = Errors.MakeStandardErrorMsg("ANALYSES_INDEX_OUTOFBOUNDS");
                return(false);
            }
            if (baseStat.GenCapitalStocks == null)
            {
                baseStat.GenCapitalStocks
                    = new Dictionary <int, List <GeneralCapital1Input> >();
            }
            if (baseStat.GenCapitalStocks.ContainsKey(filePosition))
            {
                if (baseStat.GenCapitalStocks[filePosition] != null)
                {
                    for (int i = 0; i <= nodePosition; i++)
                    {
                        if (baseStat.GenCapitalStocks[filePosition].Count <= i)
                        {
                            baseStat.GenCapitalStocks[filePosition]
                            .Add(new GeneralCapital1Input());
                        }
                    }
                    baseStat.GenCapitalStocks[filePosition][nodePosition]
                             = calculator;
                    bIsAdded = true;
                }
            }
            else
            {
                //add the missing dictionary entry
                List <GeneralCapital1Input> baseStats
                    = new List <GeneralCapital1Input>();
                KeyValuePair <int, List <GeneralCapital1Input> > newStat
                    = new KeyValuePair <int, List <GeneralCapital1Input> >(
                          filePosition, baseStats);
                baseStat.GenCapitalStocks.Add(newStat);
                bIsAdded = AddGeneralCapital1StocksToDictionary(baseStat,
                                                                filePosition, nodePosition, calculator);
            }
            return(bIsAdded);
        }
        public static int GetNodePositionCount(this GeneralCapital1Stock baseStat,
                                               int filePosition, GeneralCapital1Input calculator)
        {
            int iNodeCount = 0;

            if (baseStat.GenCapitalStocks == null)
            {
                return(iNodeCount);
            }
            if (baseStat.GenCapitalStocks.ContainsKey(filePosition))
            {
                if (baseStat.GenCapitalStocks[filePosition] != null)
                {
                    iNodeCount = baseStat.GenCapitalStocks[filePosition].Count;
                }
            }
            return(iNodeCount);
        }
 //copy constructor
 public GeneralCapital1Stock(GeneralCapital1Stock calculator)
     : base(calculator)
 {
     CopyTotalGeneralCapital1StockProperties(calculator);
 }