/// <summary> /// This routine calculates capital calls, distribution and other performance numbers and adds information to Commitments /// </summary> private void AddPeResults() { PeFundResults results; InvestorCashFlowComparer cashFlowComparer = new InvestorCashFlowComparer(); foreach (InvestorCommitment commitment in Commitments) { InvestorCashFlowComparer comparer = new InvestorCashFlowComparer(); commitment.InvestorCashFlows.Sort(comparer); try { results = new PeFundResults(commitment, null, null); commitment.Dpi = results.Dpi; commitment.Irr = results.Irr; commitment.OpenCommitment = results.OpenCommitment; commitment.TotalCapitalCalls = results.AmountCalled; commitment.TotalDistributions = results.AmountDistributed; commitment.Tvpi = results.Tvpi; commitment.LastNav = results.ValuationFundCurrency; } catch (Exception ex) { Notification notification = new Notification { Title = ApplicationNames.NotificationTitle, Content = ex.Message }; NotificationRequest.Raise(notification); } } }
public override void OnNavigatedTo(NavigationContext navigationContext) { Commitment = navigationContext.Parameters["Commitment"] as InvestorCommitment; // add additionalInformation about Investor and Fund Commitment = investorAccess.GetFullyLoadedInvestorCommitment(commitment.Id); if (Commitment != null) { cashflows = new ObservableCollection <InvestorCashFlow>(investorAccess.GetCashFlowsForCommitment(Commitment.Id)); Cashflows = CollectionViewSource.GetDefaultView(cashflows); FundResults = new PeFundResults(Commitment, null, null); RaisePropertyChanged("Cashflows"); // Set tabtitle if (string.IsNullOrEmpty(Commitment.Investor.InvestorHqTrustAccount)) { TabTitle = Commitment.Investor.InvestorReference + " (Cashflows)"; } else { TabTitle = Commitment.Investor.InvestorHqTrustAccount + " (Cashflows)"; } // set headline StringBuilder builder = new StringBuilder(Commitment.PeFund.FundName + " "); builder.Append(" Commitment: "); builder.Append(Commitment.PeFund.Currency.CurrencyShortName); builder.Append($" {Commitment.CommitmentAmount:n0}"); Headline = builder.ToString(); if (cashflows.Count == 0) { builder.Append(" Es sind keine Cashflows gespeichert."); Headline = builder.ToString(); } } }
private void CreateDataForCharts() { pcaps = new List <ExtendedPcap>(); if (AnalyzingParameter.Period == AnalyzingParameterPeriod.Auto) { int quarters = timeFunctions.Quarters(AnalyzingParameter.StartDate, AnalyzingParameter.EndDate); // bis 5 Jahre => Quartal // bis 10 Jahre => Halbjahr // bis 20 Jahre => Jahr // bis 40 Jahre => 2 Jahre // >40 Jahre => 5 Jahre if (quarters <= 20) { AnalyzingParameter.Period = AnalyzingParameterPeriod.Quarter; } else if (quarters <= 40) { AnalyzingParameter.Period = AnalyzingParameterPeriod.SixMonth; } else if (quarters <= 80) { AnalyzingParameter.Period = AnalyzingParameterPeriod.Year; } else if (quarters <= 160) { AnalyzingParameter.Period = AnalyzingParameterPeriod.TwoYear; } else { AnalyzingParameter.Period = AnalyzingParameterPeriod.FiveYear; } } switch (AnalyzingParameter.Period) { case AnalyzingParameterPeriod.Quarter: { DateTime currentDate = AnalyzingParameter.StartDate; do { ExtendedPcap newPcap = new ExtendedPcap() { AsOfDate = currentDate }; pcaps.Add(newPcap); currentDate = timeFunctions.NextQuarter(currentDate); } while (currentDate <= AnalyzingParameter.EndDate); break; } case AnalyzingParameterPeriod.SixMonth: { DateTime currentDate = AnalyzingParameter.StartDate; if (currentDate.Month != 6 && currentDate.Month != 12) { currentDate = timeFunctions.NextHalfYear(currentDate); } ExtendedPcap newPcap = new ExtendedPcap() { AsOfDate = currentDate }; pcaps.Add(newPcap); do { currentDate = timeFunctions.NextHalfYear(currentDate); newPcap = new ExtendedPcap() { AsOfDate = currentDate }; pcaps.Add(newPcap); } while (currentDate <= AnalyzingParameter.EndDate); pcaps.ElementAt(pcaps.Count - 1).AsOfDate = AnalyzingParameter.EndDate; break; } case AnalyzingParameterPeriod.Year: { DateTime currentDate = AnalyzingParameter.StartDate; if (currentDate.Month != 12) { currentDate = timeFunctions.NextYearEnd(currentDate); } ExtendedPcap newPcap = new ExtendedPcap() { AsOfDate = currentDate }; pcaps.Add(newPcap); do { currentDate = currentDate.AddYears(1); newPcap = new ExtendedPcap() { AsOfDate = currentDate }; pcaps.Add(newPcap); } while (currentDate <= AnalyzingParameter.EndDate); pcaps.ElementAt(pcaps.Count - 1).AsOfDate = AnalyzingParameter.EndDate; break; } case AnalyzingParameterPeriod.TwoYear: { DateTime currentDate = AnalyzingParameter.StartDate; if (currentDate.Month != 12) { currentDate = timeFunctions.NextYearEnd(currentDate); } ExtendedPcap newPcap = new ExtendedPcap() { AsOfDate = currentDate }; pcaps.Add(newPcap); do { currentDate = currentDate.AddYears(2); newPcap = new ExtendedPcap() { AsOfDate = currentDate }; pcaps.Add(newPcap); } while (currentDate <= AnalyzingParameter.EndDate); pcaps.ElementAt(pcaps.Count - 1).AsOfDate = AnalyzingParameter.EndDate; break; } case AnalyzingParameterPeriod.FiveYear: { DateTime currentDate = AnalyzingParameter.StartDate; if (currentDate.Month != 12) { currentDate = timeFunctions.NextYearEnd(currentDate); } ExtendedPcap newPcap = new ExtendedPcap() { AsOfDate = currentDate }; pcaps.Add(newPcap); do { currentDate = currentDate.AddYears(5); newPcap = new ExtendedPcap() { AsOfDate = currentDate }; pcaps.Add(newPcap); } while (currentDate <= AnalyzingParameter.EndDate); pcaps.ElementAt(pcaps.Count - 1).AsOfDate = AnalyzingParameter.EndDate; break; } default: { break; } } // fill pcaps with amounts using cashflows and NAVs of the commitments CashflowComparer cashflowComparer = new CashflowComparer(); PcapComparer pcapComparer = new PcapComparer(); foreach (ExtendedCommitment commitment in AnalyzingParameter.Commitments) { // sort cashflows by effectivedate ascending and pcaps by asofDate commitment.Commitment.InvestorCashFlows.Sort(cashflowComparer); commitment.Commitment.InvestorPcaps.Sort(pcapComparer); foreach (InvestorCashFlow cashflow in commitment.Commitment.InvestorCashFlows) { ExtendedPcap pcap1 = FindPcap(cashflow.EffectiveDate); // pcap can be null if cashflow date is after endDate if (pcap1 == null) { continue; } if (cashflow.CashFlowType == "Capital Call") { pcap1.CallsInPeriod += cashflow.CashFlowAmount; } if (cashflow.CashFlowType == "Distribution") { pcap1.DistributionsInPeriod += (cashflow.CashFlowAmount + cashflow.RecallableAmount); pcap1.CallsInPeriod -= cashflow.RecallableAmount; } } // add NAVs foreach (InvestorPcap nav in commitment.Commitment.InvestorPcaps) { ExtendedPcap pcap2 = pcaps.FirstOrDefault(p => p.AsOfDate.Date == nav.AsOfDate.Date); // pcap is null depending on period if (pcap2 == null) { continue; } pcap2.NavAmount += nav.FinalPcapAmount; } } // calculate cumulated cashflows ExtendedPcap pcap = pcaps.ElementAt(0); double totalCalls = 0; double totalDistributions = 0; foreach (ExtendedPcap p in pcaps) { p.CallsSinceInception = totalCalls + p.CallsInPeriod; p.DistributionsSinceInception = totalDistributions + p.DistributionsInPeriod; totalCalls = p.CallsSinceInception; totalDistributions = p.DistributionsSinceInception; } // calculate results for portfolio List <InvestorCommitment> commitmentList = new List <InvestorCommitment>(); foreach (ExtendedCommitment c in AnalyzingParameter.Commitments) { commitmentList.Add(c.Commitment); } PeFundResults = new PeFundResults(commitmentList, AnalyzingParameter.StartDate, AnalyzingParameter.EndDate); // Create Dictionaries for PieCharts // Fire an Event of type AnalyzePortfolioEvent; Views listen to this event AnalyzePortfolio analyzePortfolio = new AnalyzePortfolio() { AnalyzingParameter = AnalyzingParameter, Pcaps = pcaps, PeFundResults = PeFundResults }; eventAggregator.GetEvent <AnalyzePortfolioEvent>().Publish(analyzePortfolio); }
private void CreateCashFlowInformation(CashFlowInformation info) { info.Fund = Fund; info.LastUpdated = DateTime.Now.Date; if (info.EffectiveDate == DateTime.MinValue) { info.EffectiveDate = DateTime.Now.Date; } List <InvestorCommitment> ListOfCommitments = PefundAccess.GetCommitmentsForPeFund(Fund.Id); CashFlowDetail totalDetail = new CashFlowDetail() { Investor = null }; if (Fund.BankAccounts.Count == 0) { totalDetail.BankAccount = null; } else { totalDetail.BankAccount = Fund.BankAccounts.ElementAt(0); } info.InvestorDetails = new List <CashFlowDetail>(); foreach (InvestorCommitment commitment in ListOfCommitments) { PeFundResults results = new PeFundResults(commitment, DateTime.MinValue, DateTime.Now); CashFlowDetail investorDetail = new CashFlowDetail() { Investor = commitment.Investor, Reference = commitment.Investor.InvestorReference, BankAccount = commitment.BankAccount, CommitmentAmount = commitment.CommitmentAmount, OpenCommitment = results.OpenCommitment, TotalCalls = results.AmountCalled, TotalDistributions = results.AmountDistributed, InvestorCommitmentId = commitment.Id }; if (!string.IsNullOrEmpty(commitment.PeFundReference)) { investorDetail.Reference = commitment.PeFundReference; } totalDetail.CommitmentAmount += commitment.CommitmentAmount; info.InvestorDetails.Add(investorDetail); } info.DetailSummary = totalDetail; WriteInformationToTextFile(); SetProgressStatus(); if (info.OtherWorkDone) { return; //CashFlow has been processed; no further action required } if (info.LettersPrinted) { // start OtherWork return; } if (info.InvestorDetailsEntered) { // start Print Letters return; } if (info.CashFlowDataEntered) { // start Enter CashFlowData for investors NavigationParameters parameter = new NavigationParameters(); parameter.Add("Info", info); regionManager.RequestNavigate(RegionNames.CashFlowRegion, ViewNames.EditInvestorSplit, parameter); return; } if (info.InvestorsChecked) { // start Enter CashFlowData NavigationParameters parameter = new NavigationParameters(); parameter.Add("Info", info); regionManager.RequestNavigate(RegionNames.CashFlowRegion, ViewNames.EditCashFlowData, parameter); return; } }