private void OnErrorSelected() { if (SelectedError == null) { return; } // if PeFundId <>0 start PeFundDetail // if InvestorId <>0 start InvestorDetail if (SelectedError.InvestorId != 0) { Investor investor = investorAccess.GetInvestorById(SelectedError.InvestorId); NavigationParameters parameters = new NavigationParameters(); parameters.Add("Investor", investor); regionManager.RequestNavigate(RegionNames.TabControlRegion, ViewNames.InvestorDetails, parameters); } if (SelectedError.PeFundId != 0) { PeFund fund = PefundAccess.GetPeFundById(SelectedError.PeFundId); NavigationParameters parameters = new NavigationParameters(); parameters.Add("Fund", fund); regionManager.RequestNavigate(RegionNames.TabControlRegion, ViewNames.PeFundDetail, parameters); } }
private async Task AddInvestorCashFlowsAsync() { CashFlowsLoading = true; cashFlows = new ObservableCollection <PsPlusCashFlow>(); List <PeFund> funds = PefundAccess.GetFundListForBeteiligungsnumer(fund.FundHqTrustNumber); StringBuilder builder = new StringBuilder(fund.FundHqTrustNumber + ": "); bool firstItem = true; foreach (PeFund f in funds) { // // add FundName to FundNames // if (string.IsNullOrEmpty(f.FundLegalName)) { f.FundLegalName = f.FundName; } if (firstItem) { builder.Append(f.FundName); } else { builder.Append(", " + f.FundName); } firstItem = false; // // read commitments for each fund // var commitments = await PefundAccess.GetCommitmentsForPeFundIncludingCashFlowsAsync(f.Id); // // read cashflows for each commitment and add properties to be displayed in the gridview // foreach (InvestorCommitment commitment in commitments) { // nur HQT Kunden verarbeiten if (commitment.Investor.IsHqtClient == false) { continue; } foreach (InvestorCashFlow cf in commitment.InvestorCashFlows) { PsPlusCashFlow psPlusCf = new PsPlusCashFlow() { InvestorCashFlow = cf, InvestorHqTrustAccount = commitment.Investor.InvestorHqTrustAccount, InvestorId = (int)commitment.InvestorId, InvestorReference = commitment.Investor.InvestorReference }; cashFlows.Add(psPlusCf); } } } FundNames = builder.ToString(); CashFlowsLoading = false; }
private async Task LoadCommitmentssAsync() { DataLoading = true; Commitments = new ObservableCollection <InvestorCommitment>(await PefundAccess.GetCommitmentsForPeFundAsync(Fund.Id)); DataLoading = false; RaisePropertyChanged("Commitments"); RaisePropertyChanged("Fund"); }
private void CreatePcapList() { pcaps.Clear(); isNavCalculating = true; NewPcap = 0; totalCommitments = 0; ContainsCalculatedItems = false; foreach (InvestorCommitment c in commitments) { InvestorPcap pcap = PefundAccess.GetPcapForCommitmentAndDate(c.Id, selectedQuarter); if (pcap == null) { // if there is no record --> create a new record // this record may be inserted into the database when saving changes pcap = new InvestorPcap() { AsOfDate = selectedQuarter, DateOfFinalPcap = DateTime.Now, InvestorCommitmentId = c.Id }; pcap.EstimatedPcapAmount = CalculatePcap(c, selectedQuarter); pcap.FinalPcapAmount = pcap.EstimatedPcapAmount; pcap.IsCalculated = true; ContainsCalculatedItems = true; } // Add InvestorReference and InvestorHqTrustAccount to display properties in the list pcap.InvestorReference = c.Investor.InvestorReference; pcap.InvestorHqTrustAccount = c.Investor.InvestorHqTrustAccount; pcap.CommitmentAmount = c.CommitmentAmount; pcaps.Add(pcap); NewPcap += Math.Round(pcap.FinalPcapAmount, 2); totalCommitments += c.CommitmentAmount; } //if (Pcaps != null) Pcaps.CurrentChanged -= Pcaps_CurrentChanged; Pcaps = CollectionViewSource.GetDefaultView(pcaps); //Pcaps.CurrentChanged += Pcaps_CurrentChanged; Pcaps.MoveCurrentToFirst(); RaisePropertyChanged("Pcaps"); if (Pcaps.CurrentItem == null) { return; } // calculate sum of Pcaps and compare with NewPcap // display difference if any PcapDifference = NewPcap; foreach (InvestorPcap pcap in pcaps) { PcapDifference -= Math.Round(pcap.FinalPcapAmount, 2); } PcapDifference = Math.Round(PcapDifference, 2); isNavCalculating = false; }
private void OnGridMouseDoubleClick() { if (SelectedCommitment == null) { return; } PeFund entirePeFund = PefundAccess.GetPeFundById(SelectedCommitment.PeFundId); NavigationParameters parameter = new NavigationParameters(); parameter.Add("Fund", entirePeFund); regionManager.RequestNavigate(RegionNames.TabControlRegion, ViewNames.PeFundDetail, parameter); }
private double CalculatePcap(InvestorCommitment c, DateTime selectedQuarter) { InvestorPcap lastPcap = PefundAccess.GetLastPCap(c, selectedQuarter); if (lastPcap == null) { lastPcap = new InvestorPcap() { InvestorCommitmentId = c.Id, AsOfDate = DateTime.MinValue, FinalPcapAmount = 0 }; } return(PefundAccess.NavCalculation(lastPcap, selectedQuarter)); }
private void OnSaveChanges() { try { PefundAccess.UpdateOrInsertPcaps(new List <InvestorPcap>(pcaps)); } catch (Exception ex) { NotificationRequest.Raise(new Notification() { Title = ApplicationNames.NotificationTitle, Content = $"Beim Ändern der Datenbank ist ein Fehler aufgetreten. {ex.Message}" }); } }
private async Task LoadPefundsAsync() { availableFunds = new ObservableCollection <PeFund>(await PefundAccess.GetAllPefundsAsync()); // remove all funds where the investor is already invested in from available funds // this ensures that a new commitment can't be made for an already existing fund if (Commitments != null && Commitments.Count > 0) { foreach (InvestorCommitment commitment in Commitments) { availableFunds.Remove(commitment.PeFund); } } }
private void OnRemoveItem() { try { PefundAccess.RemoveInitiator(Initiator); eventAggregator.GetEvent <InitiatorUpdatedEvent>().Publish("Changed"); } catch (Exception ex) { NotificationRequest.Raise(new Notification() { Title = ApplicationNames.NotificationTitle, Content = $"{ex.Message}" }); } }
private async Task LoadInitiatorsAsync() { InitiatorsLoading = true; initiators = new ObservableCollection <Initiator>(await PefundAccess.GetAllInitiatorsAsync()); InitiatorList = CollectionViewSource.GetDefaultView(initiators); SortDescription sortDescription = new SortDescription() { Direction = ListSortDirection.Ascending, PropertyName = "InitiatorName" }; InitiatorList.SortDescriptions.Add(sortDescription); InitiatorsLoading = false; }
public override void OnNavigatedTo(NavigationContext navigationContext) { Fund = navigationContext.Parameters["Fund"] as PeFund; TabTitle = Fund.FundShortName + " CashFlows"; if (UniqueCashFlows != null) { UniqueCashFlows.CurrentChanged -= UniqueCashFlows_CurrentChanged; } uniqueNumbers = new ObservableCollection <UniqueCashFlowNumber>(PefundAccess.GetCashFlowsForFund(Fund.Id)); UniqueCashFlows = CollectionViewSource.GetDefaultView(uniqueNumbers); UniqueCashFlows.CurrentChanged += UniqueCashFlows_CurrentChanged; RaisePropertyChanged("UniqueCashFlows"); var task = AddInvestorCashFlowsAsync(); }
public override void OnNavigatedTo(NavigationContext navigationContext) { SelectedFund = navigationContext.Parameters["Fund"] as PeFund; // remove fund from List of feeder funds if (SelectedFund.Id != 0 && FeederFunds != null) { FeederFunds.Remove(SelectedFund); } if (string.IsNullOrEmpty(SelectedFund.FundHqTrustNumber)) { TabTitle = SelectedFund.FundShortName; } else { TabTitle = SelectedFund.FundHqTrustNumber; } RaisePropertyChanged("SelectedPeFund"); // check whether cashFlowInformation exists DirectoryHelper.CheckDirectory($"TextFiles"); FileInfo textFileInfo = DirectoryHelper.GetTextFileName(SelectedFund.Id); if (textFileInfo.Exists) { CashFlowInformationExists = true; } if (SelectedFund.CurrencyId == null) { SelectedFund.CurrencyId = ComboboxLists.GetEuroCurrency().Id; } if (SelectedFund.Initiator != null) { if (!string.IsNullOrEmpty(SelectedFund.Initiator.InitiatorAddress.Street)) { HasHeadQuarter = true; } } // Fund can be removed if the fund has no commitments if (!PefundAccess.FundHasCommitments(SelectedFund)) { CanRemoveFund = true; } // CanShowPsPlusCashFlows = (PefundAccess.BeteiligungsNummerExistsMoreThanOnce(SelectedFund)); }
private void OnEditInitiator() { Initiator initiator = new Initiator(); if (SelectedFund.InitiatorId != null) { initiator = PefundAccess.GetInitiatorById((int)SelectedFund.InitiatorId); } if (SelectedFund.Initiator == null || SelectedFund.InitiatorId == 0) { initiator = new Initiator(); } NavigationParameters parameters = new NavigationParameters(); parameters.Add("Initiator", initiator); regionManager.RequestNavigate(RegionNames.TabControlRegion, ViewNames.InitiatorDetail, parameters); initiatorToken = eventAggregator.GetEvent <InitiatorUpdatedEvent>().Subscribe(OnInitiatorUpdated); }
private async Task LoadPefundsAsync() { PeFundsLoading = true; peFunds = new ObservableCollection <PeFund>(await PefundAccess.GetAllPefundsAsync()); PeFundList = CollectionViewSource.GetDefaultView(peFunds); SortDescription sortDescription = new SortDescription() { Direction = ListSortDirection.Ascending, PropertyName = "FundName" }; PeFundList.SortDescriptions.Add(sortDescription); PeFundsLoading = false; RaisePropertyChanged("PeFundList"); }
private void OnConfirmationResponse(IConfirmation obj) { if (!obj.Confirmed) { return; } // Fund wird gelöscht try { PefundAccess.RemovePeFund(SelectedFund); } catch (Exception ex) { NotificationRequest.Raise(new Notification() { Title = ApplicationNames.NotificationTitle, Content = ex.Message }); return; } // InvestorSelection wird informiert PeFundCollectionAction parameter = new PeFundCollectionAction() { action = CollectionAction.removed, fund = SelectedFund }; eventAggregator.GetEvent <PeFundCollectionActionEvent>().Publish(parameter); // Unsubscribe Event(s) eventAggregator.GetEvent <AccountCollectionEvent>().Unsubscribe(accountListToken); // get the current active view (myself) and remove that view from tabcontrol var view = regionManager.Regions[RegionNames.TabControlRegion].ActiveViews.ElementAt(0); regionManager.Regions[RegionNames.TabControlRegion].Remove(view); }
private void UpdateOrInsertPeFund() { try { if (SelectedFund.Id == 0) { PefundAccess.InsertPeFund(SelectedFund); //PeFundSelection will be informed about a new PeFund to add the new investor to its list PeFundCollectionAction parameter = new PeFundCollectionAction() { action = CollectionAction.added, fund = SelectedFund }; eventAggregator.GetEvent <PeFundCollectionActionEvent>().Publish(parameter); eventAggregator.GetEvent <StatusBarEvent>().Publish($"Der PeFund {SelectedFund.FundShortName} wurde in die Datenbank eingetragen"); } else { // update investor PefundAccess.UpdatePeFund(SelectedFund); //InvestorSelection will be informed about changes of an Investor to show the new information PeFundCollectionAction parameter = new PeFundCollectionAction() { action = CollectionAction.updated, fund = SelectedFund }; eventAggregator.GetEvent <PeFundCollectionActionEvent>().Publish(parameter); eventAggregator.GetEvent <StatusBarEvent>().Publish($"Der Fund {SelectedFund.FundShortName} wurde in der Datenbank geändert"); } } catch (Exception ex) { NotificationRequest.Raise(new Notification() { Title = ApplicationNames.NotificationTitle, Content = ex.Message }); } }
private void ReloadCashFlowInformation() { CashFlowInformation.Fund = PefundAccess.GetPeFundById(CashFlowInformation.Fund.Id); CashFlowInformation.LastUpdated = DateTime.Now.Date; List <InvestorCommitment> ListOfCommitments = PefundAccess.GetCommitmentsForPeFund(CashFlowInformation.Fund.Id); CashFlowDetail totalDetail = CashFlowInformation.DetailSummary; totalDetail.CommitmentAmount = 0; // will be calculated while reading the investorcommitments CashFlowInformation.InvestorDetails = new List <CashFlowDetail>(); if (CashFlowInformation.Fund.BankAccounts.Count == 0) { totalDetail.BankAccount = null; } else { totalDetail.BankAccount = CashFlowInformation.Fund.BankAccounts.ElementAt(0); } foreach (InvestorCommitment commitment in ListOfCommitments) { CashFlowDetail investorDetail = new CashFlowDetail() { Investor = commitment.Investor, Reference = commitment.Investor.InvestorReference, BankAccount = commitment.BankAccount, CommitmentAmount = commitment.CommitmentAmount, InvestorCommitmentId = commitment.Id }; if (!string.IsNullOrEmpty(commitment.PeFundReference)) { investorDetail.Reference = commitment.PeFundReference; } totalDetail.CommitmentAmount += commitment.CommitmentAmount; CashFlowInformation.InvestorDetails.Add(investorDetail); } CashFlowInformation.DetailSummary = totalDetail; }
private void OnGotoNextStep() { // check cashflows whether another cashflow for the same fund has already been entered // checkFlowexists returns true if a cashflow exists for date and fund if (PefundAccess.CashFlowExists(CashFlowInformation.EffectiveDate, CashFlowInformation.Fund.Id) == false) { CashFlowInformation.CashFlowDataEntered = true; PrepareCashFlow prepareCashFlow = new PrepareCashFlow() { cfInfo = cashFlowInformation }; eventAggregator.GetEvent <PrepareCashFlowEvent>().Publish(prepareCashFlow); } else { ConfirmationRequest.Raise(new Confirmation() { Title = ApplicationNames.NotificationTitle, Content = "Für dieses Datum wurde bereits ein Cashflow erfasst. Wollen Sie einen weiteren CashFlow erfassen?" }, OnFurtherCashflow); } }
public override void OnNavigatedTo(NavigationContext navigationContext) { pcaps = new ObservableCollection <InvestorPcap>(); Fund = navigationContext.Parameters["Fund"] as PeFund; commitments = PefundAccess.GetCommitmentsForPeFund(Fund.Id); if (selectedQuarter != DateTime.MinValue) { CreatePcapList(); } Pcaps = CollectionViewSource.GetDefaultView(pcaps); Pcaps.CurrentChanged += Pcaps_CurrentChanged; // set tabtitle if (string.IsNullOrEmpty(Fund.FundHqTrustNumber)) { TabTitle = Fund.FundName + " (NAVs)"; } else { TabTitle = Fund.FundHqTrustNumber + " (NAVs)"; } }
public override void OnNavigatedTo(NavigationContext navigationContext) { Initiator = navigationContext.Parameters["Initiator"] as Initiator; // It is only possible to remove a Initiator if it is not related to a fund if (Initiator.Id != 0) { if (PefundAccess.IsInitiatorUsed(Initiator.Id)) { CanUserDeleteInitiator = false; } else { CanUserDeleteInitiator = true; } } else { CanUserDeleteInitiator = false; } copyOfInitiator = new Initiator(Initiator); TabTitle = Initiator.InitiatorName; }
private void CalculateResults() { ClearFields(); foreach (InvestorCommitment commitment in commitments) { if (commitment.InvestorCashFlows.Count == 0) { continue; } try { PeFundPerformance performance = new PeFundPerformance(commitment, dateFrom, dateTo); // the individual Performance of each PeFund is added to a collection performance.InvestorCommitmentId = commitment.Id; fundPerformances.Add(performance); } catch (Exception) { continue; } foreach (InvestorCashFlow cashFlow in commitment.InvestorCashFlows) { if (cashFlow.EffectiveDate > dateTo) { continue; } if (cashFlow.EffectiveDate < dateFrom) { continue; } cfCollection.Add(new CashFlowLight() { CDate = cashFlow.EffectiveDate, CAmount = cashFlow.CashFlowAmount, CAmountInvestorCurrency = cashFlow.CashFlowAmountInInvestorCurrency } ); if (cashFlow.CashFlowType == "Capital Call") { amountCalled += cashFlow.CashFlowAmount; amountCalledInvestorCurrency += cashFlow.CashFlowAmountInInvestorCurrency; } else if (cashFlow.CashFlowType == "Distribution") { amountDistributed += cashFlow.CashFlowAmount; amountDistributedInvestorCurrency += cashFlow.CashFlowAmountInInvestorCurrency; if (cashFlow.RecallableAmount != 0) { amountDistributed -= cashFlow.RecallableAmount; amountDistributedInvestorCurrency -= Math.Round(cashFlow.RecallableAmount / cashFlow.CashFlowAmount * cashFlow.CashFlowAmountInInvestorCurrency, 2); amountCalled -= cashFlow.RecallableAmount; amountCalledInvestorCurrency -= Math.Round(cashFlow.RecallableAmount / cashFlow.CashFlowAmount * cashFlow.CashFlowAmountInInvestorCurrency, 2); } } } // use market value (of DateTo) als last distribution InvestorPcap pcap = PefundAccess.GetLastPCap(commitment, dateTo); if (pcap == null) { pcap = new InvestorPcap() { InvestorCommitmentId = commitment.Id, AsOfDate = DateTime.MinValue, FinalPcapAmount = 0 }; } pcap.FinalPcapAmount = PefundAccess.NavCalculation(pcap, dateTo); //InvestorPcap pcap = commitment.InvestorPcaps.Find(p => p.AsOfDate == dateTo); //if (pcap == null) //{ // //throw new Exception($"der NAV für Fund {commitment.PeFund.FundName} und Datum {dateTo:d} ist nicht vorhanden"); // pcap = commitment.InvestorPcaps.Find(p => p.AsOfDate > dateTo); // if (pcap == null) // { // pcap = commitment.InvestorPcaps.Find(p => p.AsOfDate < dateTo); // if (pcap == null) // { // throw new Exception($"der NAV für Fund {commitment.PeFund.FundName} und Datum {dateTo:d} ist nicht vorhanden"); // } // } //} cfCollection.Add(new CashFlowLight() { CDate = dateTo, CAmount = pcap.FinalPcapAmount, CAmountInvestorCurrency = pcap.FinalPcapAmountInInvestorCurrency } ); valuationFundCurrency += pcap.FinalPcapAmount; valuationInvestorCurrency += pcap.FinalPcapAmountInInvestorCurrency; commitmentAmount += commitment.CommitmentAmount; openCommitment = commitmentAmount + amountCalled; amountCalledInPercentOfCommitment = Math.Abs(Math.Round(amountCalled / commitmentAmount, 4)); } tvpi = Math.Round((amountDistributed + valuationFundCurrency) / amountCalled, 2); dpi = Math.Round(amountDistributed / amountCalled, 2); rvpi = Math.Round(valuationFundCurrency / amountCalled, 2); tvpi = Math.Abs(tvpi); rvpi = Math.Abs(rvpi); dpi = Math.Abs(dpi); totalValue = Math.Round(amountDistributed + valuationFundCurrency, 2); Comparer.CashFlowLightComparer cashFlowLightComparer = new Comparer.CashFlowLightComparer(); cfCollection.Sort(cashFlowLightComparer); foreach (CashFlowLight light in cfCollection) { cfDates.Add(light.CDate); cfAmounts.Add(light.CAmount); cfAmountsInvestorCurrency.Add(light.CAmountInvestorCurrency); } if (cfCollection.Count > 1) { try { irr = Financial.XIrr(cfAmounts, cfDates) * 100; irrInvestorCurrency = Financial.XIrr(cfAmountsInvestorCurrency, cfDates) * 100; } catch (Exception) { irr = 0; irrInvestorCurrency = 0; } } else { irr = 0; irrInvestorCurrency = 0; } }
private void OnUndoChanges() { SelectedFund = PefundAccess.GetPeFundById(SelectedFund.Id); }
private async Task LoadPefundsAsync() { FeederFunds = new List <PeFund>(await PefundAccess.GetAllPefundsAsync()); }
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; } }
private void OnAddMissingItems() { CanAddMissingItems = false; foreach (ImportCommitment item in iCommitments) { if (item.PeFundId == 0 || item.InvestorId == 0) { if (item.PeFundId == 0) { string found = fundList.FirstOrDefault(p => p == item.PeFundNumber); if (string.IsNullOrEmpty(found)) { fundList.Add(item.PeFundNumber); // Fund hinzufügen PeFund newFund = new PeFund() { FundHqTrustNumber = item.PeFundNumber, FundName = item.PeFundName, CurrencyId = item.PeFundCurrencyId }; try { PefundAccess.InsertPeFund(newFund); } catch (Exception ex) { NotificationRequest.Raise(new Notification() { Title = ApplicationNames.NotificationTitle, Content = $"Fehler beim Einfügen eines Funds. {ex.Message}" }); } } } if (item.InvestorId == 0) { string found = investorList.FirstOrDefault(p => p == item.InvestorNumber); if (string.IsNullOrEmpty(found)) { investorList.Add(item.InvestorNumber); Investor newInvestor = new Investor() { InvestorHqTrustAccount = item.InvestorNumber, InvestorReference = "Hinzugefügt " + item.InvestorNumber, CurrencyId = item.InvestorCurrencyId }; try { investorAccess.InsertInvestor(newInvestor); } catch (Exception ex) { NotificationRequest.Raise(new Notification() { Title = ApplicationNames.NotificationTitle, Content = $"Fehler beim Einfügen eines Investors. {ex.Message}" }); } } } } } CanStartImport = true; eventAggregator.GetEvent <InvestorCollectionActionEvent>().Publish(new InvestorCollectionAction() { action = CollectionAction.reload, investor = null }); eventAggregator.GetEvent <PeFundCollectionActionEvent>().Publish(new PeFundCollectionAction() { action = CollectionAction.reload, fund = null }); }
private void GetCommitmentRow(int row) { ImportCommitment commitment = new ImportCommitment(); commitment.PeFundNumber = sheetFunctions.GetText(row, 0); commitment.PeFundCurrency = sheetFunctions.GetText(row, 1); commitment.PeFundCurrencyId = FindCurrencyId(commitment.PeFundCurrency); commitment.PeFundName = sheetFunctions.GetText(row, 2); commitment.InvestorNumber = sheetFunctions.GetText(row, 3); commitment.InvestorCurrency = sheetFunctions.GetText(row, 4); commitment.InvestorCurrencyId = FindCurrencyId(commitment.InvestorCurrency); commitment.AsOfDate = sheetFunctions.GetDate(row, 5); try { commitment.Commitment = sheetFunctions.GetAmount(row, 6); } catch (Exception) { commitment.Commitment = 0; } if (!int.TryParse(commitment.InvestorNumber.Substring(0, 3), out int test)) { // lines with other content than 3 numerical digits will ignored // these lines are for institutional investors return; } ImportCommitment found = ICommitments. Where(c => c.PeFundNumber == commitment.PeFundNumber && c.InvestorNumber == commitment.InvestorNumber).FirstOrDefault(); if (found != null) { found.FoundInPsPlus = true; if (found.Commitment == commitment.Commitment) { return; } found.ErrorInformation = $"Abweichende Kapitalzusage zwischen PsPlus ({commitment.Commitment:N0}) und HQT Private Equity ({found.Commitment:N0}) "; found.HqpeCommitment = found.Commitment; CanShowDifferentCommitments = true; return; } // there is a commitment in PS-Plus with no matching commitment in HQPE // add a new importCommitment to the importCommitmentCollection // add a InvestorCommitment to the database if PeFund and Investor are found ImportCommitment import = new ImportCommitment() { AsOfDate = commitment.AsOfDate, PeFundName = commitment.PeFundName, PeFundNumber = commitment.PeFundNumber, InvestorNumber = commitment.InvestorNumber, InvestorCurrency = commitment.InvestorCurrency, InvestorCurrencyId = commitment.InvestorCurrencyId, PeFundCurrency = commitment.PeFundCurrency, PeFundCurrencyId = commitment.PeFundCurrencyId, Commitment = commitment.Commitment, FoundInPsPlus = true, ErrorInformation = "Es wurde kein Commitment in HQT Private Equity gefunden;" }; // try to find Investor using InvestorNumber; set InvestorId if found // try to find PEFund using Beteiligungsnumber; set PeFundId if found Investor investor = investorAccess.GetInvestorByHqTrustNumber(import.InvestorNumber); if (investor == null) { import.ErrorInformation += " kein Investor gefunden;"; import.InvestorId = 0; CanShowMissingInvestors = true; CanAddMissingItems = true; } if (investor != null) { import.InvestorId = investor.Id; } PeFund peFund = PefundAccess.GetPeFundByBeteiligungsnummer(import.PeFundNumber); if (peFund == null) { import.ErrorInformation += " kein Fund gefunden;"; import.PeFundId = 0; CanShowMissingFunds = true; CanAddMissingItems = true; } if (peFund != null) { import.PeFundId = peFund.Id; } // if investor and fund are found insert investorcommitment if (import.PeFundId > 0 && import.InvestorId > 0) { // Find Commitment using FundId and InvestorId // if found set InvestorCommitmentId and add ImportCommitment // if not add InvestorCommitment InvestorCommitment newCommitment = new InvestorCommitment() { CommitmentAmount = import.Commitment, InvestorId = import.InvestorId, PeFundId = import.PeFundId }; try { newCommitment = investorAccess.UpdateInvestorCommitments(newCommitment); import.ErrorInformation = "Das Commitment wurde in die Datenbank eingefügt."; import.InvestorCommitmentId = newCommitment.Id; import.CommitmentsAdded = true; CanShowAddedCommitments = true; } catch (Exception ex) { NotificationRequest.Raise(new Notification() { Title = ApplicationNames.NotificationTitle, Content = ex.Message }); CloseThisTab(); } } ICommitments.Add(import); return; }