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);
        }
Exemple #2
0
        public override void OnNavigatedTo(NavigationContext navigationContext)
        {
            CashFlowInformation = navigationContext.Parameters["Info"] as CashFlowInformation;
            RaisePropertyChanged("CashFlowInformation");

            OnAutomaticSplit();
            GetInvestors();
        }
 private void OnConfirmNewCashFlow(IConfirmation obj)
 {
     if (obj.Confirmed)
     {
         cashFlowInformation = new CashFlowInformation();
         CreateCashFlowInformation(cashFlowInformation);
     }
 }
        private void OnPrepareCashFlow(PrepareCashFlow obj)
        {
            cashFlowInformation = obj.cfInfo;
            WriteInformationToTextFile();
            SetProgressStatus();
            // the next step will be automatically started

            if (cashFlowInformation.OtherWorkDone)
            {
                return;                                     //CashFlow has been processed; no further action required
            }
            if (cashFlowInformation.LettersPrinted)
            {
                // start OtherWork
                return;
            }
            if (cashFlowInformation.InvestorDetailsEntered)
            {
                // start Print Letters
                NavigationParameters parameter = new NavigationParameters();
                parameter.Add("Info", cashFlowInformation);
                regionManager.RequestNavigate(RegionNames.CashFlowRegion, ViewNames.CheckLetters, parameter);
                return;
            }
            if (cashFlowInformation.CashFlowDataEntered)
            {
                // start Enter CashFlowData for investors
                NavigationParameters parameter = new NavigationParameters();
                parameter.Add("Info", cashFlowInformation);
                regionManager.RequestNavigate(RegionNames.CashFlowRegion, ViewNames.EditInvestorSplit, parameter);
                return;
            }
            if (cashFlowInformation.InvestorsChecked)
            {
                // start Enter CashFlowData
                NavigationParameters parameter = new NavigationParameters();
                parameter.Add("Info", cashFlowInformation);
                regionManager.RequestNavigate(RegionNames.CashFlowRegion, ViewNames.EditCashFlowData, parameter);
                return;
            }
        }
        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;
            }
        }
        public override void OnNavigatedTo(NavigationContext navigationContext)
        {
            Fund        = navigationContext.Parameters["Fund"] as PeFund;
            newCashFlow = (bool?)navigationContext.Parameters["Status"];
            if (newCashFlow == null)
            {
                return;
            }

            TabTitle = "Cash Flow";

            if (GetFileData(Fund) == false)
            {
                cashFlowInformation = new CashFlowInformation();
                CreateCashFlowInformation(cashFlowInformation);
                return;
            }

            if ((bool)newCashFlow)
            {
                // get confirmation that existing cashflowinformation was finalized
                // if not confirmed show existing cashflowinformation
                // if confirmed set new confirmation and write info to disk
                //          and return function
                if (cashFlowInformation.OtherWorkDone == false)
                {
                    ConfirmationRequest.Raise(new Confirmation()
                    {
                        Title   = ApplicationNames.NotificationTitle,
                        Content = "Der existierende CashFlow wurde noch nicht abgeschlossen. Wollen Sie einen neuen CashFlow erfassen? "
                    }, OnConfirmNewCashFlow);
                }
                cashFlowInformation = new CashFlowInformation();
                CreateCashFlowInformation(cashFlowInformation);
                cashFlowInformation.FileName = textFileInfo.FullName;
                return;
            }
            else
            {
                SetProgressStatus();
                cashFlowInformation.FileName = textFileInfo.FullName;

                if (cashFlowInformation.OtherWorkDone)
                {
                    return;                                     //CashFlow has been processed; no further action required
                }
                if (cashFlowInformation.LettersPrinted)
                {
                    // start OtherWork
                    return;
                }
                if (cashFlowInformation.InvestorDetailsEntered)
                {
                    // start Print Letters
                    NavigationParameters parameter = new NavigationParameters();
                    parameter.Add("Info", cashFlowInformation);
                    regionManager.RequestNavigate(RegionNames.CashFlowRegion, ViewNames.CheckLetters, parameter);
                    return;
                }
                if (cashFlowInformation.CashFlowDataEntered)
                {
                    // start Enter CashFlowData for investors
                    NavigationParameters parameter = new NavigationParameters();
                    parameter.Add("Info", cashFlowInformation);
                    regionManager.RequestNavigate(RegionNames.CashFlowRegion, ViewNames.EditInvestorSplit, parameter);
                    return;
                }
                if (cashFlowInformation.InvestorsChecked)
                {
                    // start Enter CashFlowData
                    NavigationParameters parameter = new NavigationParameters();
                    parameter.Add("Info", cashFlowInformation);
                    regionManager.RequestNavigate(RegionNames.CashFlowRegion, ViewNames.EditCashFlowData, parameter);
                    return;
                }
                // start check InvestorData
                NavigationParameters parameter1 = new NavigationParameters();
                parameter1.Add("Info", cashFlowInformation);
                regionManager.RequestNavigate(RegionNames.CashFlowRegion, ViewNames.CheckInvestorData, parameter1);
                return;

                return;
            }
            // set status
        }