private void OnInvokeEditInvestorCommitment(InvokeEditInvestorCommitment parameter) { if (InvestorCommitment != null) { InvestorCommitment.PropertyChanged -= InvestorCommitment_PropertyChanged; } InvestorCommitment = parameter.investorCommitment; InvestorCommitment.PropertyChanged += InvestorCommitment_PropertyChanged; // create a copy // will be used when user cancels input copyOfInvestorCommitment = new InvestorCommitment(InvestorCommitment); AvailableFunds = new ObservableCollection <PeFund>(); AvailableFunds = parameter.availableFunds; BankAccounts = parameter.bankAccounts; InvestorCommitmentDetails = new ObservableCollection <InvestorCommitmentDetail>(InvestorCommitment.InvestorCommitmentDetails); // Select first record if available if (InvestorCommitmentDetails.Count == 0) { InvestorCommitmentDetails.Add(new InvestorCommitmentDetail() { CommitmentDate = DateTime.Now }); } SelectedInvestorCommitmentDetail = InvestorCommitmentDetails[0]; SelectedInvestorCommitmentDetail.PropertyChanged += SelectedInvestorCommitmentDetail_PropertyChanged; AddDisplayNameToBankAccounts(); RaisePropertyChanged("AvailableFunds"); RaisePropertyChanged("InvestorCommitment"); RaisePropertyChanged("BankAccounts"); }
public void DeleteInvestorCommitment(InvestorCommitment commitment) { using (HqTrustData dbContext = new HqTrustData()) { InvestorCommitment old = dbContext.InvestorCommitmnents. FirstOrDefault(c => c.Id == commitment.Id); if (old == null) { throw new Exception($"Das Commitment mit der Id {commitment.Id} für den Investor {commitment.InvestorId} wurde nicht in der Datenbank gefunden"); } dbContext.InvestorCommitmnents.Remove(old); foreach (InvestorCommitmentDetail detail in commitment.InvestorCommitmentDetails) { InvestorCommitmentDetail icDetail = dbContext.InvestorCommitmentDetails.FirstOrDefault(d => d.Id == detail.Id); if (icDetail == null) { throw new Exception($"Das CommitmentDetail mit der Id {icDetail.Id} für das Commitment {old.Id} wurde nicht in der Datenbank gefunden"); } dbContext.InvestorCommitmentDetails.Remove(icDetail); } try { dbContext.SaveChanges(); } catch (Exception ex) { throw new Exception("Das Commitment konnte in der Datenbank nicht gelöscht werden" + Environment.NewLine + ex.InnerException.Message); } } }
/// <summary> /// returns investorpcap for a commitmnet prior to a date /// returns null if not available /// </summary> /// <param name="c"></param> /// <param name="selectedQuarter"></param> /// <returns></returns> public static InvestorPcap GetLastPCap(InvestorCommitment c, DateTime selectedQuarter) { using (HqTrustData dbContext = new HqTrustData()) { return(dbContext.InvestorPcaps.OrderByDescending(p => p.AsOfDate). Where(p => p.InvestorCommitmentId == c.Id && p.AsOfDate < selectedQuarter).FirstOrDefault()); } }
private void OnCancelButton() { InvestorCommitment = new InvestorCommitment(copyOfInvestorCommitment); EditInvestorCommitmentResponse response = new EditInvestorCommitmentResponse() { ActionType = "Cancel", editedCommitment = null }; eventAggregator.GetEvent <EditInvestorCommitmentResponseEvent>().Publish(response); }
private void OnInvestorRowSelected(object obj) { if (obj != null) { selectedInvestorCommitment = obj as InvestorCommitment; CanShowInvestor = true; } else { selectedInvestorCommitment = null; CanShowInvestor = false; } }
public override bool IsNavigationTarget(NavigationContext navigationContext) { InvestorCommitment newInvestorCommitment = navigationContext.Parameters["Commitment"] as InvestorCommitment; if (InvestorCommitment == null) { return(true); } if (newInvestorCommitment.Id == InvestorCommitment.Id) { return(true); } return(false); }
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)); }
public PeFundResults(InvestorCommitment myCommitment, DateTime?mydateFrom, DateTime?mydateTo) { commitments.Clear(); if (mydateFrom != null) { this.dateFrom = (DateTime)mydateFrom; } if (mydateTo != null) { this.dateTo = (DateTime)mydateTo; } else { this.dateTo = dateFunctions.PreviousQuarter(DateTime.Now); } commitments.Add(myCommitment); CalculateResults(); }
private void OnSelectInvestorCommitment() { if (NewInvestorCommitments.CurrentItem == null) { return; } ShowInvestorCommitments = WindowState.Closed; foreach (CashFlowDetail detail in CashFlowInformation.InvestorDetails) { if (detail.InvestorId != newInvestorId) { continue; } InvestorCommitment commitment = NewInvestorCommitments.CurrentItem as InvestorCommitment; detail.InvestorCommitmentId = commitment.Id; break; } }
private void OnNewCommitment() { if (SelectedCommitment == null) { SelectedCommitment = new InvestorCommitment() { InvestorId = Investor.Id }; } InvokeEditInvestorCommitment parameter = new InvokeEditInvestorCommitment(); parameter.investorCommitment = new InvestorCommitment() { InvestorId = SelectedCommitment.InvestorId }; parameter.availableFunds = availableFunds; parameter.bankAccounts = new ObservableCollection <BankAccount>(Investor.BankAccounts); eventAggregator.GetEvent <InvokeEditInvestorCommitmentEvent>().Publish(parameter); EditCommitmentWindowState = WindowState.Open; }
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; }
public InvestorCommitment UpdateInvestorCommitments(InvestorCommitment commitment) { if (commitment.Id == 0) { // add new commitment using (HqTrustData dbContext = new HqTrustData()) { InvestorCommitment newCommitment = new InvestorCommitment(commitment); newCommitment.PeFund = null; dbContext.InvestorCommitmnents.Add(newCommitment); try { dbContext.SaveChanges(); return(newCommitment); } catch (Exception ex) { throw new Exception("Das Commitment konnte nicht in der Datenbank gespeichert werden" + Environment.NewLine + ex.InnerException.Message); } } } else { // update commitments using (HqTrustData dbContext = new HqTrustData()) { InvestorCommitment old = dbContext.InvestorCommitmnents. Include("InvestorCommitmentDetails"). FirstOrDefault(c => c.Id == commitment.Id); if (old == null) { throw new Exception($"Das Commitment mit der Id {commitment.Id} für den Investor {commitment.InvestorId} wurde nicht in der Datenbank gefunden"); } old.BankAccountId = commitment.BankAccountId; old.CommitmentAmount = commitment.CommitmentAmount; old.CommitmentPlannedAmount = commitment.CommitmentPlannedAmount; old.DateCommitmentAccepted = commitment.DateCommitmentAccepted; old.PeFundReference = commitment.PeFundReference; try { dbContext.SaveChanges(); } catch (Exception ex) { throw new Exception("Das Commitment konnte in der Datenbank nicht geändert werden" + Environment.NewLine + ex.InnerException.Message); } //foreach(InvestorCommitmentDetail detail in old.InvestorCommitmentDetails) for (int i = 0; i < old.InvestorCommitmentDetails.Count; i++) { InvestorCommitmentDetail detail = old.InvestorCommitmentDetails.ElementAt(i); InvestorCommitmentDetail oldDetail = dbContext.InvestorCommitmentDetails.FirstOrDefault(d => d.Id == detail.Id); if (oldDetail == null) { throw new Exception($"Das CommitmentDetail mit der Id {detail.Id} für das Commitment {old.Id} wurde nicht in der Datenbank gefunden"); } InvestorCommitmentDetail newDetail = commitment.InvestorCommitmentDetails.FirstOrDefault(n => n.Id == detail.Id); if (newDetail == null) { // record has been delete by the user: dbContext.InvestorCommitmentDetails.Remove(oldDetail); dbContext.SaveChanges(); } else { oldDetail.CommitmentAmount = newDetail.CommitmentAmount; oldDetail.CommitmentDate = newDetail.CommitmentDate; oldDetail.SecondaryCallsAfterCutOff = newDetail.SecondaryCallsAfterCutOff; oldDetail.SecondaryCutOffDate = newDetail.SecondaryCutOffDate; oldDetail.SecondaryDistributionsAfterCutOff = newDetail.SecondaryDistributionsAfterCutOff; oldDetail.SecondaryOpenCommitment = newDetail.SecondaryOpenCommitment; oldDetail.SecondaryPurchaseAmount = newDetail.SecondaryPurchaseAmount; dbContext.SaveChanges(); } } foreach (InvestorCommitmentDetail detail in commitment.InvestorCommitmentDetails) { if (detail.Id > 0) { continue; } dbContext.InvestorCommitmentDetails.Add(detail); } try { dbContext.SaveChanges(); return(commitment); } catch (Exception ex) { throw new Exception("Das Commitment konnte in der Datenbank nicht geändert werden" + Environment.NewLine + ex.InnerException.Message); } } } }