Пример #1
0
        public CreateClientLetterTelerik(string sourcePath, string saveAsFile, CashFlowInformation information, CashFlowDetail detail)
        {
            this.sourcePath  = sourcePath;
            SaveAsFile       = saveAsFile;
            this.information = information;
            this.detail      = detail;

            FillStrings(detail);
            RadFlowDocument wordDocument = new RadFlowDocument();

            provider = new DocxFormatProvider();

            try
            {
                using (Stream input = File.OpenRead(sourcePath))
                {
                    wordDocument = provider.Import(input);
                }
            }
            catch (Exception ex)
            {
                throw new Exception($"Das Word-Template konnte nicht geöffnet werden. {ex.Message}");
            }

            editor = new RadFlowDocumentEditor(wordDocument);
            ReplacePlaceholder(detail);

            int    pos      = saveAsFile.LastIndexOf(".");
            string fileName = saveAsFile.Substring(0, pos) + ".docx";

            using (Stream output = File.OpenWrite(fileName))
            {
                provider.Export(editor.Document, output);
            }



            string pdfFile = fileName.Replace(".docx", ".pdf");

            // cpmversion of a flowdocument to a fixeddocument

            PdfFormatProvider pdfProvider   = new PdfFormatProvider();
            RadFixedDocument  fixedDocument = pdfProvider.ExportToFixedDocument(editor.Document);

            // write the fixeddocuement to file
            Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.PdfFormatProvider fixedProvider = new Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.PdfFormatProvider();


            using (Stream output = File.OpenWrite(pdfFile))
            {
                fixedProvider.Export(fixedDocument, output);
            }
        }
Пример #2
0
        private void ReplacePlaceholder(CashFlowDetail detail)
        {
            string currencyName = information.Fund.Currency.CurrencyShortName;

            editor.ReplaceText("[Beteiligungsgesellschaft]", information.Fund.FundLegalName);
            if (information.Fund.Initiator != null)
            {
                editor.ReplaceText("[Absender Zeile 1]", information.Fund.Initiator.SenderInformation);
                editor.ReplaceText("[Absender Zeile 2]", information.Fund.Initiator.SenderInformationLine2);
                editor.ReplaceText("[Fusszeile 1]", information.Fund.Initiator.FooterLine1);
                editor.ReplaceText("[Fusszeile 2]", information.Fund.Initiator.FooterLine2);
                editor.ReplaceText("[Fusszeile 3]", information.Fund.Initiator.FooterLine3);
            }
            editor.ReplaceText("[Vertraulich]", confidential);
            editor.ReplaceText("[Firma]", firma);
            editor.ReplaceText("[AdressAnrede]", adressAnrede);
            editor.ReplaceText("[Straße]", strasse);
            editor.ReplaceText("[PLZ Ort]", plzOrt);
            editor.ReplaceText("[Land]", land);
            editor.ReplaceText("[Text oben]", information.ComponentText);
            editor.ReplaceText("[Investor Referenz]", detail.Reference);
            editor.ReplaceText("[Betreff]", information.Fund.SubjectForLetter);

            editor.ReplaceText("[Anrede]", anrede);
            editor.ReplaceText("[Zeichnungsbetrag]", $"{detail.CommitmentAmount:n0}");
            editor.ReplaceText("[Whg]", currencyName);
            editor.ReplaceText("[Kapitalabruf]", information.CashFlowDescription);
            editor.ReplaceText("[Tagesdatum]", $"{information.LetterDate:dd. MMMM yyyy}");
            editor.ReplaceText("[CF Amount]", cfAmount);
            editor.ReplaceText("[CF Amount Percent]", cfAmountPercent);
            editor.ReplaceText("[CF Expenses Percent]", cfExpensesPercent);
            editor.ReplaceText("[CF Expenses]", cfExpenses);
            editor.ReplaceText("[CF Lookback]", cfLookback);
            editor.ReplaceText("[CF Lookback Percent]", cfLookbackPercent);
            editor.ReplaceText("[Cashflow Betrag]", cashflowBetrag);
            editor.ReplaceText("[Cashflow Prozent]", cashFlowPercent);
            editor.ReplaceText("[Valutatag]", valuta);
            editor.ReplaceText("[BankName]", bankName);
            editor.ReplaceText("[SwiftAdresse]", swift);
            editor.ReplaceText("[Kontoinhaber]", empfaenger);
            editor.ReplaceText("[IBAN]", iban);
            editor.ReplaceText("[BIC", bic);
            editor.ReplaceText("[BankAdresse]", bankAddress);
            editor.ReplaceText("[ZusatzInfo]", additionalInformation);
            editor.ReplaceText("[FFCKontoInhaber]", ffcHolder);
            editor.ReplaceText("[FFCKontoNummer]", ffcAccountNumber);
            editor.ReplaceText("[BankNummer]", bankNumber);
            editor.ReplaceText("[OpenCommitment]", openCommitment);
            editor.ReplaceText("[TotalCalledPercent]", totalCalledPercent);
            editor.ReplaceText("[TotalDistributed]", totalDistributed);
            editor.ReplaceText("[TotalDistributedPercent]", totalDistributedPercent);
            editor.ReplaceText("[CF ReturnOfCapital]", cfReturnOfCapital);
            editor.ReplaceText("[CF CapitalGain]", cfCapitalGain);
            editor.ReplaceText("[CF Dividends]", cfDividends);
            editor.ReplaceText("[CF Recallable]", cfRecallable);
            editor.ReplaceText("[CF WithholdingTax]", cfWithholdingTax);
            editor.ReplaceText("[SitzStrasse]", sitzStrasse1);
            editor.ReplaceText("[SitzStrasse2]", sitzStrasse2);
            editor.ReplaceText("[Sitz PLZ Ort]", sitzPlzOrt);
            editor.ReplaceText("[GesamtAbruf]", fundCalled);
            editor.ReplaceText("[GesamtAusschuettung]", fundDistributed);
            editor.ReplaceText("[offenePosition]", openPosition);


            // Absenderangaben

            var tables = editor.Document.EnumerateChildrenOfType <Table>();

            if (detail.CashFlowAmountCall != 0)
            {
                foreach (Table table in tables)
                {
                    if (table.Rows.Count < 3)
                    {
                        continue;
                    }
                    TableRow  row       = table.Rows[0];
                    TableCell cell      = row.Cells[0];
                    Paragraph paragraph = cell.Blocks[0] as Paragraph;
                    if (paragraph == null)
                    {
                        continue;
                    }
                    if (paragraph.Inlines.Count == 0)
                    {
                        continue;
                    }
                    if (paragraph.Inlines[0].ToString() == "Art")
                    {
                        // remove table rows if amounts are '0'
                        // if expenses are '0' remove row 2
                        // if lookback is '0' remove row 4
                        // start removing with the last rows!

                        if (detail.LookbackInterests == 0)
                        {
                            table.Rows.RemoveAt(3);
                        }
                        if (detail.PartnershipExpenses == 0)
                        {
                            table.Rows.RemoveAt(2);
                        }
                    }
                }
            }
        }
Пример #3
0
 private void FillStrings(CashFlowDetail detail)
 {
     if (detail.Investor.ConfidentialLetter == true)
     {
         confidential = "Persönlich / Vertraulich";
     }
     anrede       = detail.Investor.ClientAdvisor.AdvisorName.Salutation;
     firma        = detail.Investor.ClientAdvisor.CompanyName;
     adressAnrede = detail.Investor.ClientAdvisor.AdvisorName.AddressName;
     strasse      = detail.Investor.ClientAdvisor.Address.Street;
     plzOrt       = detail.Investor.ClientAdvisor.Address.ZipCode + " " + detail.Investor.ClientAdvisor.Address.City;
     land         = detail.Investor.ClientAdvisor.Address.Country;
     if (detail.CashFlowAmountCall != 0)
     {
         cfAmount = $"{detail.CashFlowAmountCall:n2}";
     }
     else
     {
         cfAmount = $"{detail.CashFlowAmountDistribution:n2}";
     }
     cfExpenses              = $"{detail.PartnershipExpenses:n2}";
     cfLookback              = $"{detail.LookbackInterests:n2}";
     cfAmountPercent         = $"{Math.Round(detail.CashFlowAmountCall / detail.CommitmentAmount * 100,1):n1} %";
     cfExpensesPercent       = $"{Math.Round(detail.PartnershipExpenses / detail.CommitmentAmount * 100, 1):n1} %";
     cfLookbackPercent       = $"{Math.Round(detail.LookbackInterests / detail.CommitmentAmount * 100, 1):n1} %";
     cashflowBetrag          = $"{detail.CashFlowAmountCall + detail.PartnershipExpenses + detail.LookbackInterests+ detail.OpenPosition:n2}";
     cashFlowPercent         = $"{Math.Round((detail.CashFlowAmountCall + detail.PartnershipExpenses + detail.LookbackInterests+ detail.OpenPosition) / detail.CommitmentAmount * 100, 1):n1} %";
     openCommitment          = $"{detail.CommitmentAmount - Math.Abs(detail.TotalCalls + detail.CashFlowAmountCall - detail.RecallableAmount):n2}";
     totalCalledPercent      = $"{Math.Round((Math.Abs(detail.TotalCalls+detail.CashFlowAmountCall-detail.RecallableAmount)/detail.CommitmentAmount*100),1):n1} %";
     totalCalled             = $"{Math.Abs(detail.TotalCalls + detail.CashFlowAmountCall - detail.RecallableAmount):n2}";
     totalDistributed        = $"{detail.TotalDistributions + detail.CashFlowAmountDistribution-detail.RecallableAmount:n2}";
     totalDistributedPercent = $"{Math.Round((detail.TotalDistributions + detail.CashFlowAmountDistribution - detail.RecallableAmount) / detail.CommitmentAmount * 100, 1):n1} %";
     fundCalled              = $"{Math.Abs(information.DetailSummary.CashFlowAmountCall):n2}";
     fundDistributed         = $"{information.DetailSummary.CashFlowAmountDistribution:n2}";
     valuta     = $"{information.EffectiveDate:dd. MMMM yyyy}";
     bankName   = information.Fund.BankAccounts[0].BankName;
     swift      = information.Fund.BankAccounts[0].SwiftAddress;
     empfaenger = information.Fund.BankAccounts[0].AccountHolder;
     if (string.IsNullOrEmpty(empfaenger))
     {
         empfaenger = information.Fund.FundLegalName;
     }
     iban = information.Fund.BankAccounts[0].Iban;
     bic  = information.Fund.BankAccounts[0].Bic;
     cfReturnOfCapital = $"{detail.ReturnOfCapital:n2}";
     cfCapitalGain     = $"{detail.CapitalGain:n2}";
     cfDividends       = $"{detail.Dividends:n2}";
     cfRecallable      = $"{detail.RecallableAmount:n2}";
     cfWithholdingTax  = $"{detail.WithholdingTax:n2}";
     openPosition      = $"{detail.OpenPosition:n2}";
     if (information.Fund.Initiator != null)
     {
         sitzStrasse1 = information.Fund.Initiator.HeadQuarterAddress.Street;
         sitzStrasse2 = information.Fund.Initiator.HeadQuarterAddress.Street2;
         sitzPlzOrt   = information.Fund.Initiator.HeadQuarterAddress.ZipCode + " " + information.Fund.Initiator.HeadQuarterAddress.City;
     }
     bankAddress           = information.Fund.BankAccounts[0].BankAddress;
     bankNumber            = information.Fund.BankAccounts[0].BankNumberBlz;
     additionalInformation = information.Fund.BankAccounts[0].AdditionalInstructions;
     ffcHolder             = information.Fund.BankAccounts[0].FfcAccountHolderName;
     ffcAccountNumber      = information.Fund.BankAccounts[0].FfcAccountNumber;
 }