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);
            }
        }
Ejemplo n.º 2
0
 private void OnPeFundCollectionAction(PeFundCollectionAction obj)
 {
     if (peFunds == null)
     {
         var task = LoadPefundsAsync();
     }
     if (obj.action == CollectionAction.removed)
     {
         PeFund fund = peFunds.FirstOrDefault(i => i.Id == obj.fund.Id);
         peFunds.Remove(fund);
     }
     else if (obj.action == CollectionAction.added)
     {
         peFunds.Add(obj.fund);
     }
     else if (obj.action == CollectionAction.updated)
     {
         PeFund fund = peFunds.FirstOrDefault(i => i.Id == obj.fund.Id);
         fund.FundHqTrustNumber = obj.fund.FundHqTrustNumber;
         fund.FundName          = obj.fund.FundName;
         fund.FundShortName     = obj.fund.FundShortName;
         fund.FundLegalName     = obj.fund.FundLegalName;
     }
     else if (obj.action == CollectionAction.reload)
     {
         var task = LoadPefundsAsync();
     }
 }
        private bool GetFileData(PeFund peFund)
        {
            DirectoryHelper.CheckDirectory($"TextFiles");
            textFileInfo = DirectoryHelper.GetTextFileName(Fund.Id);
            if (textFileInfo.Exists)
            {
                string fileContent = string.Empty;

                using (StreamReader sr = new StreamReader(textFileInfo.FullName))
                {
                    fileContent = sr.ReadToEnd();
                }


                if (!string.IsNullOrEmpty(fileContent))
                {
                    cashFlowInformation = JsonConvert.DeserializeObject <CashFlowInformation>(fileContent);
                }

                if (cashFlowInformation == null)
                {
                    NotificationRequest.Raise(new Notification()
                    {
                        Title   = ApplicationNames.NotificationTitle,
                        Content = "Die Ausschüttungsdaten konnten nicht gelesen werden"
                    });
                    return(false);
                }
                return(true);
            }
            return(false);
        }
Ejemplo n.º 4
0
        public override bool IsNavigationTarget(NavigationContext navigationContext)
        {
            PeFund newFund = navigationContext.Parameters["Fund"] as PeFund;

            if (newFund.Id == Fund.Id)
            {
                return(true);
            }
            return(false);
        }
        private void AddError(PeFund fund, string v)
        {
            CashFlowErrors error = new CashFlowErrors()
            {
                PeFundId   = fund.Id,
                ErrorText  = v,
                ObjectName = fund.FundShortName
            };

            Errors.Add(error);
        }
 private void InvestorCommitment_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
 {
     if (e.PropertyName == "PeFundId")
     {
         PeFund fund = AvailableFunds.FirstOrDefault(f => f.Id == InvestorCommitment.PeFundId);
         if (fund != null)
         {
             InvestorCommitment.PeFund = fund;
             RaisePropertyChanged("PeFund");
         }
     }
 }
Ejemplo n.º 7
0
        /// <summary>
        /// returns true if more than one Fund uses the same Beteiligungsnummer
        /// (PS Plus makes no difference between legal entities)
        /// </summary>
        /// <param name="fund"></param>
        /// <returns></returns>
        public static bool BeteiligungsNummerExistsMoreThanOnce(PeFund fund)
        {
            bool morethanone = false;

            using (HqTrustData dbContext = new HqTrustData())
            {
                int count = dbContext.PeFunds.Where(p => p.FundHqTrustNumber == fund.FundHqTrustNumber).Count();
                if (count > 1)
                {
                    morethanone = true;
                }
            }
            return(morethanone);
        }
        public override bool IsNavigationTarget(NavigationContext navigationContext)
        {
            if (Fund == null)
            {
                return(true);
            }
            PeFund f = navigationContext.Parameters["Fund"] as PeFund;

            if (f.Id == Fund.Id)
            {
                return(true);
            }
            return(false);
        }
Ejemplo n.º 9
0
        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);
        }
Ejemplo n.º 10
0
        private static void UpdateDocumentAndLettersForPeFund(PeFund fund)
        {
            using (HqTrustData dbContext = new HqTrustData())
            {
                var existingDocs = dbContext.DocumentAndLetters.Where(b => b.PeFundId == fund.Id).ToList();

                // foreach account in existingAccounts try to find a record in investor.BankAccounts
                // if found --> update properties
                // if not found --> record was deleted by user --> remove account

                foreach (DocumentAndLetter document in existingDocs)
                {
                    DocumentAndLetter newDoc = fund.DocumentAndLetters.FirstOrDefault(b => b.Id == document.Id);
                    if (newDoc == null)
                    {
                        // not found --> remove
                        dbContext.DocumentAndLetters.Remove(document);
                    }
                    else
                    {
                        // found --> update properties
                        document.DocumentDate        = newDoc.DocumentDate;
                        document.DocumentDescription = newDoc.DocumentDescription;
                        document.DocumentFileName    = newDoc.DocumentFileName;
                        document.DocumentType        = newDoc.DocumentType;
                    }
                }


                foreach (DocumentAndLetter document in fund.DocumentAndLetters)
                {
                    if (document.Id != 0)
                    {
                        continue;
                    }
                    document.PeFundId   = fund.Id;
                    document.InvestorId = null;
                    dbContext.DocumentAndLetters.Add(document);
                }
                try
                {
                    dbContext.SaveChanges();
                }
                catch (Exception ex)
                {
                    throw new Exception($"Fehler beim Einfügen eines neuen Private Equity Funds (Tabelle: DocumentAndLetters) Fehler: {ex.InnerException.Message}");
                }
            }
        }
Ejemplo n.º 11
0
        public static bool FundHasCommitments(PeFund fund)
        {
            int numberOfCommitments = 0;

            using (HqTrustData dbContext = new HqTrustData())
            {
                numberOfCommitments = dbContext.InvestorCommitmnents.Where(c => c.PeFundId == fund.Id).Count();
            }
            if (numberOfCommitments > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public override async void OnNavigatedTo(NavigationContext navigationContext)
        {
            fund     = navigationContext.Parameters["Fund"] as PeFund;
            TabTitle = $"PsPlus CashFlows ({fund.FundHqTrustNumber})";
            if (PsPlusCashFlows != null)
            {
                PsPlusCashFlows.CurrentChanged -= PsPlusCashFlows_CurrentChanged;
            }

            // fill collection of cashflows:
            await Task.Run(() => AddInvestorCashFlowsAsync());

            PsPlusCashFlows = CollectionViewSource.GetDefaultView(cashFlows);
            PsPlusCashFlows.CurrentChanged += PsPlusCashFlows_CurrentChanged;
            RaisePropertyChanged("PsPlusCashFlows");

            //
            // add sort criteria to CollectionViewSource
            // sort by HQTrustaccount and then by Date
            //

            PsPlusCashFlows.SortDescriptions.Clear();

            SortDescription sortDescription = new SortDescription()
            {
                Direction    = ListSortDirection.Ascending,
                PropertyName = "InvestorHqTrustAccount"
            };

            PsPlusCashFlows.SortDescriptions.Add(sortDescription);

            sortDescription = new SortDescription()
            {
                Direction    = ListSortDirection.Ascending,
                PropertyName = "InvestorCashFlow.EffectiveDate"
            };
            PsPlusCashFlows.SortDescriptions.Add(sortDescription);


            //
            // groupdescription to CollectoinViewSource
            // the information is grouped by HqTrustAccount
            // grouping is defined in the xaml
            //
        }
Ejemplo n.º 13
0
        private bool FilterInvestor(object obj)
        {
            PeFund fund = obj as PeFund;

            if (fund.FundName != null && fund.FundName.ToLower().Contains(FilterText.ToLower()))
            {
                return(true);
            }
            if (fund.FundLegalName != null && fund.FundLegalName.ToLower().Contains(FilterText.ToLower()))
            {
                return(true);
            }
            if (fund.FundHqTrustNumber != null && fund.FundHqTrustNumber.ToLower().Contains(FilterText.ToLower()))
            {
                return(true);
            }
            return(false);
        }
Ejemplo n.º 14
0
        public static void RemovePeFund(PeFund fund)
        {
            using (HqTrustData dbContext = new HqTrustData())
            {
                PeFund removefund = dbContext.PeFunds.FirstOrDefault(i => i.Id == fund.Id);
                if (removefund == null)
                {
                    throw new Exception($"Der Fund mit der Id {fund.Id} wurde in der Datenbank nicht gefunden.");
                }
                dbContext.PeFunds.Remove(removefund);

                try
                {
                    // remove related BankAccounts
                    var results = dbContext.BankAccounts.Where(b => b.PefundId == fund.Id).ToList();
                    if (results.Count > 0)
                    {
                        dbContext.BankAccounts.RemoveRange(results);
                    }

                    // remove related Documents and LetterInformation
                    var docs = dbContext.DocumentAndLetters.Where(e => e.PeFundId == fund.Id).ToList();
                    if (docs.Count > 0)
                    {
                        dbContext.DocumentAndLetters.RemoveRange(docs);
                    }
                }

                catch (Exception ex)
                {
                    throw new Exception($"Fehler beim Löschen von abhängigen Tabellen: {ex.InnerException.Message}");
                }
                // save changes
                try
                {
                    dbContext.SaveChanges();
                }
                catch (Exception ex)
                {
                    throw new Exception($"Fehler beim Löschen des Funds. Ursache: {ex.InnerException.Message}");
                }
            }
        }
Ejemplo n.º 15
0
 public static void UpdatePeFund(PeFund fund)
 {
     using (HqTrustData dbContext = new HqTrustData())
     {
         PeFund updatePeFund = dbContext.PeFunds.FirstOrDefault(i => i.Id == fund.Id);
         if (updatePeFund == null)
         {
             throw new Exception($"Der Fund mit der Id {fund.Id} wurde nicht in der Datenbank gefunden");
         }
         dbContext.Entry(updatePeFund).CurrentValues.SetValues(fund);
         try
         {
             dbContext.SaveChanges();
         }
         catch (Exception ex)
         {
             throw new Exception($"Fehler beim Ändern eines PeFunds: {ex.InnerException.Message}");
         }
     }
     UpdateBankAccountsForPeFund(fund);
     UpdateDocumentAndLettersForPeFund(fund);
 }
Ejemplo n.º 16
0
        public static void InsertPeFund(PeFund fund)
        {
            PeFund newFund = fund.Copy(fund);

            newFund.BankAccounts       = new System.Collections.ObjectModel.ObservableCollection <BankAccount>();
            newFund.DocumentAndLetters = new System.Collections.ObjectModel.ObservableCollection <DocumentAndLetter>();

            using (HqTrustData dbContext = new HqTrustData())
            {
                dbContext.PeFunds.Add(newFund);
                try
                {
                    dbContext.SaveChanges();
                    fund.Id = newFund.Id;
                }
                catch (Exception ex)
                {
                    throw new Exception($"Fehler beim Einfügen eines neuen Private Equity Funds: {ex.InnerException.Message}");
                }
            }
            UpdateBankAccountsForPeFund(fund);
            UpdateDocumentAndLettersForPeFund(fund);
        }
        private void OnShowPeFundDiagram(ShowPeFundDiagram obj)
        {
            if (this.fund != null)
            {
                return;
            }
            if (obj == null)
            {
                return;
            }
            if (obj.hirarchy == null)
            {
                return;
            }

            Hirarchies = obj.hirarchy;
            this.fund  = obj.fund;
            CreateDiagram();
            if (border != null)
            {
                border.Child = diagram;
            }
            //eventAggregator.GetEvent<ShowPeFundDiagramEvent>().Unsubscribe(token);
        }
Ejemplo n.º 18
0
        private static void UpdateBankAccountsForPeFund(PeFund fund)
        {
            using (HqTrustData dbContext = new HqTrustData())
            {
                var existingAccounts = dbContext.BankAccounts.Where(b => b.PefundId == fund.Id).ToList();

                // foreach account in existingAccounts try to find a record in investor.BankAccounts
                // if found --> update properties
                // if not found --> record was deleted by user --> remove account

                foreach (BankAccount account in existingAccounts)
                {
                    BankAccount newAccount = fund.BankAccounts.FirstOrDefault(b => b.Id == account.Id);
                    if (newAccount == null)
                    {
                        // not found --> remove
                        dbContext.BankAccounts.Remove(account);
                    }
                    else
                    {
                        // found --> update properties
                        account.AccountHolder          = newAccount.AccountHolder;
                        account.AccountNumber          = newAccount.AccountNumber;
                        account.AdditionalInstructions = newAccount.AdditionalInstructions;
                        account.BankAddress            = newAccount.BankAddress;
                        account.BankContactId          = newAccount.BankContactId;
                        account.BankName             = newAccount.BankName;
                        account.BankNumberBlz        = newAccount.BankNumberBlz;
                        account.BeneficiaryBank      = newAccount.BeneficiaryBank;
                        account.CurrencyId           = newAccount.CurrencyId;
                        account.FfcAccountHolderName = newAccount.FfcAccountHolderName;
                        account.FfcAccountNumber     = newAccount.FfcAccountNumber;
                        account.Iban         = newAccount.Iban;
                        account.InvestorId   = null;
                        account.PefundId     = fund.Id;
                        account.Signature1   = newAccount.Signature1;
                        account.Signature2   = newAccount.Signature2;
                        account.SwiftAddress = newAccount.SwiftAddress;
                    }
                }


                foreach (BankAccount account in fund.BankAccounts)
                {
                    if (account.Id != 0)
                    {
                        continue;
                    }
                    account.PefundId   = fund.Id;
                    account.InvestorId = null;
                    dbContext.BankAccounts.Add(account);
                }
                try
                {
                    dbContext.SaveChanges();
                }
                catch (Exception ex)
                {
                    throw new Exception($"Fehler beim Einfügen eines neuen Private Equity Funds (Tabelle: BankAccounts) Fehler: {ex.InnerException.Message}");
                }
            }
        }
Ejemplo n.º 19
0
        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;
        }
Ejemplo n.º 20
0
        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
            });
        }