public GoalCalculationManager(Planner planner, RiskProfileInfo riskProfileInfo, int riskProfileId) { _planner = planner; _planId = _planner.ID; _riskProfileInfo = riskProfileInfo; _riskProfileId = riskProfileId; }
public CashFlowCalculation GetCashFlowData(int clientId, int planId, int riskProfileId) { _clientId = clientId; _planId = planId; _riskProfileId = riskProfileId; ClientPersonalInfo clientPersonalInfo = new ClientPersonalInfo(); PersonalInformation personalInfo = clientPersonalInfo.Get(clientId); fillPersonalData(personalInfo); _riskProfileInfo = new RiskProfileInfo(); PlannerAssumption plannerAssumption = new PlannerAssumptionInfo().GetAll(_planId); if (plannerAssumption != null) { fillCashFlowFromPlannerAssumption(plannerAssumption); } IList <Income> incomes = new IncomeInfo().GetAll(_planId); IList <Expenses> expenses = new ExpensesInfo().GetAll(_planId); IList <Loan> loans = new LoanInfo().GetAll(_planId); IList <Goals> goals = new GoalsInfo().GetAll(_planId); fillCashFlowFromIncomes(incomes); fillCashFlowFromExpenses(expenses); fillCashFlowFromLoans(loans); fillCashFlowFromGoals(goals); return(_cashFlow); }
private void dtGridCurrentStatusGoals_CellValueChanged(object sender, DataGridViewCellEventArgs e) { try { if (e.ColumnIndex == 3) { double excessFund = 0; if (e.RowIndex > 0 && double.Parse(dtGridCurrentStatusGoals.Rows[e.RowIndex - 1].Cells[4].Value.ToString()) > 0) { excessFund = double.Parse(dtGridCurrentStatusGoals.Rows[e.RowIndex - 1].Cells[4].Value.ToString()) - (double.Parse(dtGridCurrentStatusGoals.Rows[e.RowIndex].Cells[2].Value.ToString()) + double.Parse(dtGridCurrentStatusGoals.Rows[e.RowIndex].Cells[3].Value.ToString())); if (excessFund > 0) { if (dtGridCurrentStatusGoals.Rows[e.RowIndex].Cells[0].Value.ToString() != "0") { Goals goal = _goals.First(i => i.Id == int.Parse(dtGridCurrentStatusGoals.Rows[e.RowIndex].Cells[0].Value.ToString())); var drs = _dtPlan.Select("ID = " + _planeId); Planner planner = convertToPlanner(drs[0]); RiskProfileInfo _riskProfileInfo = new RiskProfileInfo(); dtGridCurrentStatusGoals.Rows[e.RowIndex].Cells[4].Value = excessFund; if (_goalCalculationInfo == null) { _goalCalculationInfo = new GoalsCalculationInfo(goal, planner, _riskProfileInfo, _riskProfileId, int.Parse(cmbPlanOption.Tag.ToString())); _goalCalculationInfo.GoalCalManager = cashFlowService.GoalCalculationMgr; } _goalCalculationInfo.SetGoalProfilevalue(double.Parse(dtGridCurrentStatusGoals.Rows[e.RowIndex].Cells[3].Value.ToString())); for (int i = e.RowIndex + 1; i <= dtGridCurrentStatusGoals.Rows.Count; i++) { excessFund = double.Parse(dtGridCurrentStatusGoals.Rows[i - 1].Cells[4].Value.ToString()) - (double.Parse(dtGridCurrentStatusGoals.Rows[i].Cells[2].Value.ToString()) + (string.IsNullOrEmpty(dtGridCurrentStatusGoals.Rows[i].Cells[3].Value.ToString()) ? 0 : double.Parse(dtGridCurrentStatusGoals.Rows[i].Cells[3].Value.ToString()))); dtGridCurrentStatusGoals.Rows[i].Cells[4].Value = excessFund; if (excessFund < 0) { MessageBox.Show("Fund allocation should not be allowed more then excess fund.", "Fund Allocation", MessageBoxButtons.OK, MessageBoxIcon.Stop); dtGridCurrentStatusGoals.Rows[i].Cells[3].Value = 0; } } } } else { MessageBox.Show("Fund allocation should not be allowed more then excess fund.", "Fund Allocation", MessageBoxButtons.OK, MessageBoxIcon.Stop); dtGridCurrentStatusGoals.Rows[e.RowIndex].Cells[3].Value = 0; } } } } catch (Exception ex) { } }
public GoalsCalculationInfo(Goals goal, Planner planner, RiskProfileInfo riskProfileInfo, int riskProfileId, int optionId) { this._goal = goal; this.planner = planner; this._plannerId = planner.ID; this._riskProfileInfo = riskProfileInfo; _riskprofileId = riskProfileId; this._optionId = optionId; }
public GoalsValueCalculationInfo(Goals goal, Planner planner, RiskProfileInfo riskProfileInfo, int riskprorfileId) { _goal = goal; _planner = planner; _planStartYear = _planner.StartDate.Year; _riskProfileInfo = riskProfileInfo; _riskProfileId = riskprorfileId; growthPercentage = _riskProfileInfo.GetRiskProfileReturnRatio(_riskProfileId, getRemainingYearsFromPlanStartYear()); _futureValueOfGoal = getGoalFutureValue(); _currentValueOfGoal = getGoalCurrentValue(); _futureValueOfMappedInstruments = getTotalMappedInstrumentValue(); _futureValueOfMappedNonFinancialAssets = getFutureValueOfMappedNonFinancialAsset(); setLIFOPlanning(); }
public DataTable GenerateCashFlow(int clientId, int planId, int riskProfileId) { _dtCashFlow = new DataTable(); var plannerInfo = new PlannerInfo.PlannerInfo(); _planId = planId; _planner = plannerInfo.GetPlanDataById(planId); _riskProfileInfo = new RiskProfileInfo(); GoalCalculationMgr = new GoalCalculationManager(_planner, _riskProfileInfo, riskProfileId); CashFlowCalculation cashFlow = GetCashFlowData(clientId, planId, riskProfileId); if (cashFlow != null) { createTableCashFlowStructure(); generateCashFlowData(); } return(_dtCashFlow); }
private void cmbGoals_SelectedIndexChanged(object sender, EventArgs e) { setGoalId(); if (cmbGoals.Tag == "0") { dtGridGoalValue.DataSource = null; dtGridGoalCal.DataSource = null; } else { Goals goal = _goals.First(i => i.Id == int.Parse(cmbGoals.Tag.ToString())); var drs = _dtPlan.Select("ID = " + _planeId); Planner planner = convertToPlanner(drs[0]); RiskProfileInfo _riskProfileInfo = new RiskProfileInfo(); //decimal growthPercentage = _riskProfileInfo.GetRiskProfileReturnRatio(_riskProfileId, int.Parse(goal.StartYear) - planner.StartDate.Year); if (_goalCalculationInfo == null) { _goalCalculationInfo = new GoalsCalculationInfo(goal, planner, _riskProfileInfo, _riskProfileId, int.Parse(cmbPlanOption.Tag.ToString())); _goalCalculationInfo.GoalCalManager = cashFlowService.GoalCalculationMgr; } // _goalCalculationInfo.SetInvestmentInGoal(_investmentToGoal); _dtGoalValue = _goalCalculationInfo.GetGoalValue(int.Parse(cmbGoals.Tag.ToString()), _planeId, int.Parse(lblRiskProfileVal.Tag.ToString())); if (_dtGoalValue != null && _dtGoalValue.Rows.Count > 0) { lblGoalPeriodValue.Text = _dtGoalValue.Rows[0]["GoalYear"].ToString(); txtPorfolioValue.Text = _goalCalculationInfo.GetProfileValue().ToString(); setGoalValueGrid(); _dtGoalCal = _goalCalculationInfo.GetGoalCalculation(); dtGridGoalCal.DataSource = _dtGoalCal; setGoalCalGrid(); int goalComplitionPercentage = getGoalComplitionPercentage(); progGoalComplition.Value = (goalComplitionPercentage > 100) ? 100 : goalComplitionPercentage; lblGoalComplition.Text = progGoalComplition.Value.ToString() + "%"; } } }
private void addFirstRowData(int rowId) { DataRow dr = _dtCashFlow.NewRow(); dr["ID"] = rowId; dr["StartYear"] = _planner.StartDate.Year; #region "Add Incomes" double totalIncome = 0; double totalpostTaxIncome = 0; double totalTaxAmt = 0; foreach (Income income in _cashFlow.LstIncomes) { dr["(" + income.IncomeBy + ") " + income.Source] = income.Amount; totalIncome = totalIncome + income.Amount; dr["(" + income.IncomeBy + ") " + income.Source + " - Income Tax"] = income.IncomeTax; double taxAmt = (income.Amount * income.IncomeTax) / 100; totalTaxAmt = totalTaxAmt + taxAmt; dr["(" + income.IncomeBy + ") " + income.Source + " - Post Tax"] = income.Amount - taxAmt; totalpostTaxIncome = totalpostTaxIncome + (income.Amount - taxAmt); } dr["Total Income"] = totalIncome; dr["Total Tax Deduction"] = totalTaxAmt; dr["Total Post Tax Income"] = totalpostTaxIncome; #endregion #region "Add Expenses" double totalExpenses = 0; foreach (Expenses exp in _cashFlow.LstExpenses) { double expAmt = (exp.OccuranceType == ExpenseType.Monthly) ? exp.Amount * 12 : exp.Amount; dr[exp.Item] = expAmt; totalExpenses = totalExpenses + expAmt; } dr["Total Annual Expenses"] = totalExpenses; #endregion #region "Add Loans" double totalLoan = 0; foreach (Loan loan in _cashFlow.LstLoans) { double loanAmt = loan.Emis * 12; dr[loan.TypeOfLoan] = loanAmt; totalLoan = totalLoan + loanAmt; } dr["Total Annual Loans"] = totalLoan; #endregion #region "Add Goals" double totalLoanEmi = 0; double surplusCashFund = (totalpostTaxIncome - (totalExpenses + totalLoan + totalLoanEmi)); foreach (Goals goal in _cashFlow.LstGoals) { //1 Loan for Goal double loanForGoalValue = 0; double emi = 0; if (goal.LoanForGoal != null) { loanForGoalValue = goal.LoanForGoal.LoanAmount; if (_planner.StartDate.Year >= goal.LoanForGoal.StratYear) { dr[string.Format("(Loan EMI - {0})", goal.Name)] = goal.LoanForGoal.EMI; totalLoanEmi = totalLoanEmi + goal.LoanForGoal.EMI; emi = goal.LoanForGoal.EMI; } } //2 Cash Flow and fund allocation to goal if (surplusCashFund > 0) { _riskProfileInfo = new RiskProfileInfo(); GoalsValueCalculationInfo goalValCalInfo = new GoalsValueCalculationInfo(goal, _planner, _riskProfileInfo, _riskProfileId); GoalsCalculationInfo goalcalInfo = new GoalsCalculationInfo(goal, _planner, _riskProfileInfo, _riskProfileId, _optionId); goalValCalInfo.SetPortfolioValue(goalcalInfo.GetProfileValue()); GoalCalculationMgr.AddGoalValueCalculation(goalValCalInfo); double surplusAmountAfterInvestment = goalValCalInfo.SetInvestmentToAchiveGoal(_planner.StartDate.Year, surplusCashFund); dr[string.Format("{0} - {1}", goal.Priority, goal.Name)] = surplusCashFund - surplusAmountAfterInvestment; surplusCashFund = surplusAmountAfterInvestment; } else { _riskProfileInfo = new RiskProfileInfo(); GoalsValueCalculationInfo goalValCalInfo = new GoalsValueCalculationInfo(goal, _planner, _riskProfileInfo, _riskProfileId); GoalsCalculationInfo goalcalInfo = new GoalsCalculationInfo(goal, _planner, _riskProfileInfo, _riskProfileId, _optionId); goalValCalInfo.SetPortfolioValue(goalcalInfo.GetProfileValue()); GoalCalculationMgr.AddGoalValueCalculation(goalValCalInfo); } } #endregion dr["Surplus Amount"] = totalpostTaxIncome - (totalExpenses + totalLoan + totalLoanEmi); _dtCashFlow.Rows.Add(dr); }
private void loadRiskProfileReturnDetails() { RiskProfileInfo _defaultRiskProfile = new RiskProfileInfo(); _dtRiskProfileDet = _defaultRiskProfile.GetRiskProfileReturnById(_riskprofileId); }