Beispiel #1
0
        private bool RunOutputCalculations(OutputDiscounted outputDiscounted,
                                           CalculatorParameters calcParameters)
        {
            //this calculator does not do cumulative totals
            bool bHasCalculations = false;

            //outputs are discounted using the BudgetsandInvestments calculator
            //that calculator relies on 'ancestor' objects (ancestor xml nodes)
            //for some calculation parameters
            calcParameters.ParentBudgetInvestment                     = new BudgetInvestment();
            calcParameters.ParentBudgetInvestment.Local               = new Local();
            calcParameters.ParentBudgetInvestment.Local.NominalRate   = outputDiscounted.Local.NominalRate;
            calcParameters.ParentBudgetInvestment.Local.InflationRate = outputDiscounted.Local.InflationRate;
            calcParameters.ParentBudgetInvestment.Local.RealRate      = outputDiscounted.Local.RealRate;
            calcParameters.ParentBudgetInvestment.InitEOPDate         = outputDiscounted.EndOfPeriodDate;
            calcParameters.ParentBudgetInvestment.PreProdPeriods      = 0;
            calcParameters.ParentBudgetInvestment.ProdPeriods         = 1;
            calcParameters.ParentTimePeriod = new TimePeriod();
            calcParameters.ParentTimePeriod.IsDiscounted = outputDiscounted.IsDiscounted;
            calcParameters.ParentTimePeriod.Date         = outputDiscounted.EndOfPeriodDate;
            //convert discountedoutput to an Output object that can be used to run calcs
            Output       output = OutputDiscounted.ConvertDiscountedOutput(calcParameters, outputDiscounted);
            XElement     oCurrentCalculationElement = null;
            BICalculator biCalculator = new BICalculator();

            bHasCalculations = biCalculator.SetOutputCalculations(
                calcParameters, output, oCurrentCalculationElement);
            //transfer the new calculations back to outputDiscounted (via its base output object)
            outputDiscounted.SetOutputProperties(calcParameters, output);
            return(bHasCalculations);
        }
Beispiel #2
0
        //conversion method
        public static Output ConvertDiscountedOutput(CalculatorParameters calcParameters,
                                                     OutputDiscounted outputDiscounted)
        {
            Output output = new Output();

            output.SetOutputProperties(calcParameters, outputDiscounted);
            //only the calcs in the base output.total1 ... are needed in outputDiscounted
            return(output);
        }
Beispiel #3
0
 //copy constructor
 public void SetOutputDiscountedProperties(CalculatorParameters calcParameters,
                                           OutputDiscounted outputDiscounted)
 {
     //set the base output properties
     this.SetOutputProperties(calcParameters, outputDiscounted);
     //set this properties
     this.IsDiscounted    = outputDiscounted.IsDiscounted;
     this.EndOfPeriodDate = outputDiscounted.EndOfPeriodDate;
 }
Beispiel #4
0
        public bool SetInputOutputCalculations(
            CalculatorHelpers.CALCULATOR_TYPES calculatorType,
            CalculatorParameters calcParameters, XElement currentCalculationsElement,
            XElement currentElement, IDictionary <string, string> updates)
        {
            bool bHasCalculations = false;

            switch (calculatorType)
            {
            case CalculatorHelpers.CALCULATOR_TYPES.input:
                InputDiscounted inputDiscounted = new InputDiscounted();
                //deserialize xml to object
                inputDiscounted.SetInputDiscountedProperties(
                    calcParameters, currentCalculationsElement, currentElement);
                //set up and run and the calculations
                bHasCalculations = RunInputCalculations(inputDiscounted,
                                                        calcParameters);
                //serialize object back to xml
                inputDiscounted.SetInputDiscountedAttributes(
                    calcParameters, currentCalculationsElement,
                    currentElement, updates);
                break;

            case CalculatorHelpers.CALCULATOR_TYPES.output:
                OutputDiscounted outputDiscounted = new OutputDiscounted();
                //deserialize xml to object
                outputDiscounted.SetOutputDiscountedProperties(
                    calcParameters, currentCalculationsElement, currentElement);
                //set up and run and the calculations
                bHasCalculations = RunOutputCalculations(outputDiscounted,
                                                         calcParameters);
                //serialize object back to xml
                outputDiscounted.SetOutputDiscountedAttributes(
                    calcParameters, currentCalculationsElement,
                    currentElement, updates);
                break;

            default:
                break;
            }
            return(bHasCalculations);
        }