public void AddGoalPlanning(GoalPlanning goalPlanning)
 {
     if (goalPlanning != null)
     {
         _goalPlannings.Add(goalPlanning);
     }
 }
        private void setLIFOPlanning()
        {
            double futureInvestmentRequireValueForGoal = _futureValueOfGoal - (_futureValueOfMappedInstruments +
                                                                               _futureValueOfMappedNonFinancialAssets + getLoanAmount());
            double investmentAmount = futureInvestmentRequireValueForGoal;

            for (int calculationYear = int.Parse(_goal.StartYear); calculationYear >= _planner.StartDate.Year;
                 calculationYear--)
            {
                GoalPlanning goalPlanning = new GoalPlanning(_goal);
                goalPlanning.Year                  = calculationYear;
                goalPlanning.GoalFutureValue       = futureInvestmentRequireValueForGoal;
                goalPlanning.ActualFreshInvestment = (investmentAmount * 100) / (100 + (double)GetGrowthPercentage(goalPlanning.Year));
                goalPlanning.GoalId                = _goal.Id;
                goalPlanning.GrowthPercentage      = GetGrowthPercentage(goalPlanning.Year);
                _LIFO_GoalPlannings.Add(goalPlanning);
                investmentAmount = goalPlanning.ActualFreshInvestment;
            }
        }
Example #3
0
        private void addRowsInGoalCalculation()
        {
            int     goalYear    = int.Parse(_goal.StartYear);
            decimal returnRatio = getRiskProfileReturnRatio(goalYear - _planner.StartDate.Year);

            GoalsValueCalculationInfo goalsValueCal = GoalCalManager.GetGoalValueCalculation(_goal);

            goalsValueCal.SetPortfolioValue(GetProfileValue());

            for (int currentYear = _planner.StartDate.Year; currentYear <= goalYear; currentYear++)
            {
                GoalPlanning goalPlanning = goalsValueCal.GetGoalPlanning(currentYear);
                if (goalPlanning == null)
                {
                    goalPlanning                       = new GoalPlanning(_goal);
                    goalPlanning.Year                  = currentYear;
                    goalPlanning.GrowthPercentage      = _riskProfileInfo.GetRiskProfileReturnRatio(_riskprofileId, goalPlanning.YearLeft);
                    goalPlanning.ActualFreshInvestment = 0;
                }
                DataRow dr = _dtGoalCalculation.NewRow();
                returnRatio           = goalPlanning.GrowthPercentage;
                dr["Year Left"]       = goalPlanning.YearLeft;
                dr["Loan Instrument"] = 0;
                double freshInvestment = goalPlanning.ActualFreshInvestment;

                dr["Fresh Investment"] = Math.Round(freshInvestment);
                if (currentYear == goalYear)
                {
                    dr["Assets Mapping"]    = goalsValueCal.FutureValueOfMappedNonFinancialAssets;
                    dr["Instrument Mapped"] = goalsValueCal.FutureValueOfMappedInstruments;
                }
                dr["Portfolio Value"] =
                    calculatePortfoliioValue(freshInvestment, returnRatio);
                dr["Cash outflow Goal Year"] = (currentYear == goalYear) ? goalsValueCal.FutureValueOfGoal : 0;
                dr["Portfolio Return"]       = returnRatio;
                _dtGoalCalculation.Rows.Add(dr);
            }
        }
        public double GetCurrentPortfolioValue()
        {
            double totalCashInvestmentUptoNow = 0;
            double currentPortFoliovalue      = _portfolioValue;

            for (int currentYear = _planner.StartDate.Year; currentYear <= int.Parse(_goal.StartYear); currentYear++)
            {
                GoalPlanning goalPlanning = GetGoalPlanning(currentYear);
                //GoalPlanning previousYearGoalPlanning = GetGoalPlanning(currentYear-1);
                GoalPlanning lifoGoalPlanningObj = GetLIFOGoalPlanning(currentYear);
                if (goalPlanning != null)
                {
                    //currentPortFoliovalue = currentPortFoliovalue + goalPlanning.ActualFreshInvestment;
                    double interestRate = (lifoGoalPlanningObj.GrowthPercentage != null) ?
                                          (double)lifoGoalPlanningObj.GrowthPercentage : 0;

                    currentPortFoliovalue = currentPortFoliovalue +
                                            ((currentPortFoliovalue * interestRate) / 100) +
                                            goalPlanning.ActualFreshInvestment;
                }
                else
                {
                    double interestRate = (lifoGoalPlanningObj.GrowthPercentage != null) ?
                                          (double)lifoGoalPlanningObj.GrowthPercentage : 0;

                    currentPortFoliovalue = currentPortFoliovalue +
                                            ((currentPortFoliovalue * interestRate) / 100);
                    if (_goalPlannings.Count > 0 && (currentYear > _goalPlannings[0].Year))
                    {
                        break;
                    }
                }
            }
            _currentPortfolioValue = currentPortFoliovalue;
            return(_currentPortfolioValue);
        }
        public double SetInvestmentToAchiveGoal(int investmentYear, double investmentAmount)
        {
            double futureInvestmentRequireValueForGoal = _futureValueOfGoal - (_futureValueOfMappedInstruments +
                                                                               _futureValueOfMappedNonFinancialAssets + getLoanAmount());

            GoalPlanning lifoGoalPlanningObj = GetLIFOGoalPlanning(investmentYear + 1);
            double       currentProfileValue = GetCurrentPortfolioValue();

            if (Math.Round(currentProfileValue) == Math.Round(lifoGoalPlanningObj.ActualFreshInvestment))
            {
                GoalPlanning goalPlanning = new GoalPlanning(_goal);
                goalPlanning.GoalId                = _goal.Id;
                goalPlanning.Year                  = investmentYear;
                goalPlanning.GoalFutureValue       = _futureValueOfGoal;
                goalPlanning.ActualFreshInvestment = 0;
                goalPlanning.GrowthPercentage      = GetGrowthPercentage(investmentYear);

                AddGoalPlanning(goalPlanning);
                return(investmentAmount - goalPlanning.ActualFreshInvestment);
            }

            double profileValue = (currentProfileValue + investmentAmount);

            if (profileValue < lifoGoalPlanningObj.ActualFreshInvestment)
            {
                GoalPlanning goalPlanning = new GoalPlanning(_goal);
                goalPlanning.GoalId                = _goal.Id;
                goalPlanning.Year                  = investmentYear;
                goalPlanning.GoalFutureValue       = _futureValueOfGoal;
                goalPlanning.ActualFreshInvestment = investmentAmount;
                goalPlanning.GrowthPercentage      = GetGrowthPercentage(investmentYear);

                AddGoalPlanning(goalPlanning);
                return(investmentAmount - goalPlanning.ActualFreshInvestment);
            }
            else
            {
                double currentInvestmentRequire = (lifoGoalPlanningObj.ActualFreshInvestment - currentProfileValue);
                if (System.Math.Round(currentInvestmentRequire) > 0 && ((currentProfileValue + currentInvestmentRequire) <= lifoGoalPlanningObj.ActualFreshInvestment))
                {
                    GoalPlanning goalPlanning = new GoalPlanning(_goal);
                    goalPlanning.GoalId                = _goal.Id;
                    goalPlanning.Year                  = investmentYear;
                    goalPlanning.GoalFutureValue       = _futureValueOfGoal;
                    goalPlanning.ActualFreshInvestment = currentInvestmentRequire;
                    goalPlanning.GrowthPercentage      = GetGrowthPercentage(investmentYear);

                    AddGoalPlanning(goalPlanning);
                    return(investmentAmount - goalPlanning.ActualFreshInvestment);
                }
                else
                {
                    GoalPlanning goalPlanning = new GoalPlanning(_goal);
                    goalPlanning.GoalId                = _goal.Id;
                    goalPlanning.Year                  = investmentYear;
                    goalPlanning.GoalFutureValue       = _futureValueOfGoal;
                    goalPlanning.ActualFreshInvestment = 0;
                    goalPlanning.GrowthPercentage      = GetGrowthPercentage(investmentYear);

                    AddGoalPlanning(goalPlanning);
                    return(investmentAmount - goalPlanning.ActualFreshInvestment);
                }
            }
            //double investmentReturnValueOnGoalYear = getInvestmentReturnValueAtGoalYear(investmentYear, investmentAmount);
            //if (futureInvestmentRequireValueForGoal >= investmentReturnValueOnGoalYear)
            //{
            //    GoalPlanning goalPlanning = new GoalPlanning(_goal);
            //    goalPlanning.GoalId = _goal.Id;
            //    goalPlanning.Year = investmentYear;
            //    goalPlanning.GoalFutureValue = _futureValueOfGoal;
            //    goalPlanning.ActualFreshInvestment = investmentAmount;
            //    goalPlanning.GrowthPercentage = GetGrowthPercentage(investmentYear - 1);
            //    AddGoalPlanning(goalPlanning);
            //    return investmentAmount - goalPlanning.ActualFreshInvestment;
            //}
            //else   // Case: Investment Amount return will cross goal future value and over access fund get allocated.
            //{
            //    GoalPlanning lifoGoalPlanningObj = GetLIFOGoalPlanning(investmentYear + 1);
            //    double currentProfileValue = GetCurrentPortfolioValue();

            //    double estimatedDiffAmount = (lifoGoalPlanningObj.ActualFreshInvestment  - currentProfileValue);

            //    estimatedDiffAmount = estimatedDiffAmount +
            //        ((estimatedDiffAmount * (double)GetGrowthPercentage(investmentYear)) / 100);

            //    if (estimatedDiffAmount < investmentAmount)
            //    {
            //        GoalPlanning goalPlanning = new GoalPlanning(_goal);
            //        goalPlanning.GoalId = _goal.Id;
            //        goalPlanning.Year = investmentYear;
            //        goalPlanning.GoalFutureValue = _futureValueOfGoal;
            //        goalPlanning.ActualFreshInvestment = (estimatedDiffAmount > 0) ? estimatedDiffAmount : 0;
            //        goalPlanning.GrowthPercentage = GetGrowthPercentage(investmentYear -1);

            //        AddGoalPlanning(goalPlanning);
            //        return investmentAmount - goalPlanning.ActualFreshInvestment;
            //    }
            //    else
            //    {
            //        GoalPlanning goalPlanning = new GoalPlanning(_goal);
            //        goalPlanning.GoalId = _goal.Id;
            //        goalPlanning.Year = investmentYear;
            //        goalPlanning.GoalFutureValue = _futureValueOfGoal;
            //        goalPlanning.ActualFreshInvestment = investmentAmount;
            //        goalPlanning.GrowthPercentage = GetGrowthPercentage(investmentYear - 1);

            //        AddGoalPlanning(goalPlanning);
            //        return investmentAmount - investmentAmount;
            //    }
            //}
        }