diff --git a/R/exportInsuranceContract_xlsx.R b/R/exportInsuranceContract_xlsx.R index 2b30850bd0a1325c2dba461c3de99dd0039eeef1..5bfbe850f6771ed6f2a2bbcff0ad648bc6f28d96 100644 --- a/R/exportInsuranceContract_xlsx.R +++ b/R/exportInsuranceContract_xlsx.R @@ -62,8 +62,8 @@ writeValuesTable = function(wb, sheet, values, caption = NULL, crow = 1, ccol = writePremiumCoefficients = function(wb, sheet, values, tarif = NULL, type = "benefits", crow = crow, ccol = ccol) { writeData(wb, sheet, matrix(c( - "Nettopr\\u00e4mie", "", "Zillmerpr\\u00e4mie", "", "Bruttopr\\u00e4mie", "", - "rel. zu VS", "rel. zu Pr\\u00e4mie", "rel. zu VS", "rel. zu Pr\\u00e4mie", "rel. zu VS", "rel. zu Pr\\u00e4mie"), 6, 2 + "Nettopr\u00e4mie", "", "Zillmerpr\u00e4mie", "", "Bruttopr\u00e4mie", "", + "rel. zu VS", "rel. zu Pr\u00e4mie", "rel. zu VS", "rel. zu Pr\u00e4mie", "rel. zu VS", "rel. zu Pr\u00e4mie"), 6, 2 ), startCol = ccol, startRow = crow, colNames = FALSE, borders = "rows", borderColour = "gray5", borderStyle = "thin"); mergeCells(wb, sheet, cols = ccol, rows = crow:(crow + 1)); mergeCells(wb, sheet, cols = ccol, rows = (crow + 2):(crow + 3)); @@ -110,7 +110,7 @@ labelsReplace = function(labels) { labels[labels == "unit.gross"] = "Brutto"; labels[labels == "written_yearly"] = "Verrechnet"; labels[labels == "written"] = "netto"; - labels[labels == "unitcost"] = "St?ckkosten"; + labels[labels == "unitcost"] = "St\u00fcckkosten"; labels[labels == "written_beforetax"] = "vor Steuer"; # Kosten @@ -129,15 +129,15 @@ labelsReplace = function(labels) { labels[labels == "Constant"] = ""; # Cash Flows - labels[labels == "premiums_advance"] = "Pr\\u00e4m. vorsch."; - labels[labels == "premiums_arrears"] = "Pr\\u00e4m. nachsch."; + labels[labels == "premiums_advance"] = "Pr\u00e4m. vorsch."; + labels[labels == "premiums_arrears"] = "Pr\u00e4m. nachsch."; labels[labels == "guaranteed_advance"] = "Gar. vorsch."; labels[labels == "guaranteed_arrears"] = "Gar. nachsch."; labels[labels == "survival_advance"] = "Erl. vorsch."; labels[labels == "survival_arrears"] = "Erl. nachsch."; # Barwerte - labels[labels == "premiums"] = "Pr\\u00e4m."; + labels[labels == "premiums"] = "Pr\u00e4m."; labels[labels == "guaranteed"] = "Gar."; labels[labels == "survival"] = "Erl."; labels[labels == "death_SumInsured"] = "Abl. VS"; @@ -156,27 +156,27 @@ labelsReplace = function(labels) { labels[labels == "PremiumFree"] = "Pr.Fr." labels[labels == "PolicyPeriod"] = "LZ" - # R\\u00fcckstellungen + # R\u00fcckstellungen labels[labels == "adequate"] = "ausr."; labels[labels == "contractual"] = "vertragl."; labels[labels == "conversion"] = "Umrechn."; - labels[labels == "alphaRefund"] = "\u03b1-R\\u00fccktrag"; - labels[labels == "reduction"] = "Sparpr.f\\u00fcr DK"; + labels[labels == "alphaRefund"] = "\u03b1-R\u00fccktrag"; + labels[labels == "reduction"] = "Sparpr.f\u00fcr DK"; labels[labels == "PremiumsPaid"] = "Pr.Summe"; - labels[labels == "Surrender"] = "R\\u00fcckkauf"; + labels[labels == "Surrender"] = "R\u00fcckkauf"; labels[labels == "PremiumFreeSumInsured"] = "Prf.VS"; labels[labels == "Balance Sheet Reserve"] = "Bilanzreserve" - # Pr\\u00e4mienzerlegung + # Pr\u00e4mienzerlegung labels[labels == "charged"] = "verrechnet" labels[labels == "tax"] = "VSt." labels[labels == "loading.frequency"] = "UJZ" - labels[labels == "rebate.premium"] = "Pr\\u00e4m.Rab." + labels[labels == "rebate.premium"] = "Pr\u00e4m.Rab." labels[labels == "rebate.partner"] = "Partn.Rab." labels[labels == "unitcosts"] = "StkK" labels[labels == "profit.advance"] = "Vw.GB" labels[labels == "rebate.sum"] = "Summenrab." - labels[labels == "charge.noMedicalExam"] = "o.\\u00e4rztl.U." + labels[labels == "charge.noMedicalExam"] = "o.\u00e4rztl.U." labels[labels == "gross"] = "Brutto" labels[labels == "alpha.noZillmer"] = "\u03b1 (ungez.)"; labels[labels == "alpha.Zillmer"] = "\u03b1 (gezill.)"; @@ -186,20 +186,20 @@ labelsReplace = function(labels) { labels[labels == "Zillmer.risk"] = "gez.Risikopr."; labels[labels == "Zillmer.savings"] = "gez.Sparpr."; labels[labels == "Zillmer.amortization"] = "gez.AK-Tilgung"; - labels[labels == "Zillmer.savings.real"] = "Sparpr.f\\u00fcr DK"; + labels[labels == "Zillmer.savings.real"] = "Sparpr.f\u00fcr DK"; # Vertragseigenschaften labels[labels == "InterestRate"] = "i"; labels[labels == "PolicyDuration"] = "LZ"; - labels[labels == "PremiumPayment"] = "Pr\\u00e4mienzhlg."; - labels[labels == "Premiums"] = "Pr\\u00e4mien"; + labels[labels == "PremiumPayment"] = "Pr\u00e4mienzhlg."; + labels[labels == "Premiums"] = "Pr\u00e4mien"; labels[labels == "age"] = "Alter"; labels[labels == "Sum insured"] = "Vers.summe"; labels[labels == "Mortality table"] = "Sterbetafel"; labels[labels == "i"] = "Garantiezins"; labels[labels == "Age"] = "Alter"; labels[labels == "Policy duration"] = "Laufzeit"; - labels[labels == "Premium period"] = "Pr?mienzahlung"; + labels[labels == "Premium period"] = "Pr\u00e4mienzahlung"; labels[labels == "Deferral period"] = "Aufschub"; labels[labels == "Guaranteed payments"] = "Garantiezeit"; @@ -332,7 +332,7 @@ exportContractDataTable = function(wb, sheet, contract, ccol = 1, crow = 1, styl tmp = contractPremiums %>% select(Vertragsteil = .data$ID, .data$unit.net, .data$unit.Zillmer, .data$unit.gross) writeValuesTable(wb, sheet, values = setInsuranceValuesLabels(tmp), - caption = "Pr\\u00e4miens\\u00e4tze (auf VS 1)", crow = crow, ccol = 1, + caption = "Pr\u00e4miens\u00e4tze (auf VS 1)", crow = crow, ccol = 1, tableName = "UnitPremiums", styles = styles, valueStyle = styles$unitpremiums) crow = crow + NROW(tmp) + 2 + 2 # 2 rows for caption/table header, 2 rows padding @@ -340,7 +340,7 @@ exportContractDataTable = function(wb, sheet, contract, ccol = 1, crow = 1, styl tmp = contractPremiums %>% select(Vertragsteil = .data$ID, .data$net, .data$Zillmer, .data$gross, .data$written_yearly) writeValuesTable(wb, sheet, values = setInsuranceValuesLabels(tmp), - caption = "Jahrespr\\u00e4mien", crow = crow, ccol = 1, + caption = "Jahrespr\u00e4mien", crow = crow, ccol = 1, tableName = "YearlyPremiums", styles = styles, valueStyle = styles$currency0) crow = crow + NROW(tmp) + 2 + 2 # 2 rows for caption/table header, 2 rows padding @@ -348,7 +348,7 @@ exportContractDataTable = function(wb, sheet, contract, ccol = 1, crow = 1, styl tmp = contractPremiums %>% select(Vertragsteil = .data$ID, .data$written, .data$unitcost, .data$written_beforetax, .data$tax) writeValuesTable(wb, sheet, values = setInsuranceValuesLabels(tmp), - caption = "Pr\\u00e4mien (pro Zahlungsweise)", crow = crow, ccol = 1, + caption = "Pr\u00e4mien (pro Zahlungsweise)", crow = crow, ccol = 1, tableName = "WrittenPremiums", styles = styles, valueStyle = styles$currency0) crow = crow + NROW(tmp) + 2 + 2 # 2 rows for caption/table header, 2 rows padding @@ -513,10 +513,10 @@ exportProfitParticipationTable = function(wb, sheet, contract, ccol = 1, crow = # Add table headers for the various sections: if (length(baseCols) > 0) { - writeTableCaption(wb, sheet, "Basisgr\\u00f6\\u00dfen", rows = crow, cols = baseCols + ccol.table, style = styles$header); + writeTableCaption(wb, sheet, "Basisgr\u00f6\u00dfen", rows = crow, cols = baseCols + ccol.table, style = styles$header); } if (length(rateCols) > 0) { - writeTableCaption(wb, sheet, "Gewinnbeteiligungss\\u00e4tze", rows = crow, cols = rateCols + ccol.table, style = styles$header); + writeTableCaption(wb, sheet, "Gewinnbeteiligungss\u00e4tze", rows = crow, cols = rateCols + ccol.table, style = styles$header); } if (length(profitCols) > 0) { writeTableCaption(wb, sheet, "GB Zuweisungen", rows = crow, cols = profitCols + ccol.table, style = styles$header); @@ -532,10 +532,10 @@ exportProfitParticipationTable = function(wb, sheet, contract, ccol = 1, crow = } if (length(surrenderCols) > 0) { - writeTableCaption(wb, sheet, "R\\u00fcckkauf", rows = crow, cols = surrenderCols + ccol.table, style = styles$header); + writeTableCaption(wb, sheet, "R\u00fcckkauf", rows = crow, cols = surrenderCols + ccol.table, style = styles$header); } if (length(premiumWaiverCols) > 0) { - writeTableCaption(wb, sheet, "Pr\\u00e4mienfreistellung", rows = crow, cols = premiumWaiverCols + ccol.table, style = styles$header); + writeTableCaption(wb, sheet, "Pr\u00e4mienfreistellung", rows = crow, cols = premiumWaiverCols + ccol.table, style = styles$header); } exportBlockID(wb, sheet, id = id, rows = blockid.row, cols = ccol:cl, styles = styles) @@ -567,7 +567,7 @@ exportPremiumCompositionTable = function(wb, sheet, contract, ccol = 1, crow = 1 cl = cl + writeValuesTable( wb, sheet, as.data.frame(setInsuranceValuesLabels(contract$Values$premiumComposition)), crow = crow, ccol = cl, tableName = tableName("Premium_Decomposition_", id), styles = styles, - caption = "Pr\\u00e4mienzerlegung", valueStyle = styles$currency0) + 1; + caption = "Pr\u00e4mienzerlegung", valueStyle = styles$currency0) + 1; crow = crow + nrrow + 4; @@ -576,7 +576,7 @@ exportPremiumCompositionTable = function(wb, sheet, contract, ccol = 1, crow = 1 cl = cl + writeValuesTable( wb, sheet, as.data.frame(setInsuranceValuesLabels(contract$Values$premiumCompositionSums)), crow = crow, ccol = cl, tableName = tableName("Premium_DecompositionSums_", id), styles = styles, - caption = "Pr\\u00e4mienzerlegung (Summe zuk\\u00fcnftiger Pr\\u00e4mien)", valueStyle = styles$currency0) + 1; + caption = "Pr\u00e4mienzerlegung (Summe zuk\u00fcnftiger Pr\u00e4mien)", valueStyle = styles$currency0) + 1; crow = crow + nrrow + 4; @@ -585,7 +585,7 @@ exportPremiumCompositionTable = function(wb, sheet, contract, ccol = 1, crow = 1 cl = cl + writeValuesTable( wb, sheet, as.data.frame(setInsuranceValuesLabels(contract$Values$premiumCompositionPV)), crow = crow, ccol = cl, tableName = tableName("Premium_DecompositionPV_", id), styles = styles, - caption = "Pr\\u00e4mienzerlegung(Barwerte zuk\\u00fcnftiger Pr\\u00e4mien)", valueStyle = styles$currency0) + 1; + caption = "Pr\u00e4mienzerlegung(Barwerte zuk\u00fcnftiger Pr\u00e4mien)", valueStyle = styles$currency0) + 1; endrow = (crow + 1 + nrrow) @@ -703,7 +703,7 @@ exportPVTable = function(wb, sheet, contract, ccol = 1, crow = 1, styles = c(), caption = "Kostenbarwerte", valueStyle = styles$cost0) + 1; # Now print out the formulas for premium calculation into the columns 2 and 3: - writeData(wb, sheet, as.data.frame(c("Nettopr\\u00e4mie", contract$Values$premiums[["net"]],"Zillmerpr\\u00e4mie", contract$Values$premiums[["Zillmer"]], "Bruttopr\\u00e4mie", contract$Values$premiums[["gross"]])), startCol = ccol, startRow = crow, colNames = FALSE, borders = "rows"); + writeData(wb, sheet, as.data.frame(c("Nettopr\u00e4mie", contract$Values$premiums[["net"]],"Zillmerpr\u00e4mie", contract$Values$premiums[["Zillmer"]], "Bruttopr\u00e4mie", contract$Values$premiums[["gross"]])), startCol = ccol, startRow = crow, colNames = FALSE, borders = "rows"); for (i in 0:5) { writeFormula(wb, sheet, paste0("SUMPRODUCT(", sprintf(area.premiumcoeff, crow + i, crow + i), ", ", area.premiumvals, ") + SUMPRODUCT(", sprintf(area.costcoeff, crow + i, crow + i), ", ", area.costvals, ")"), startCol = ccol + 2, startRow = crow + i); addStyle(wb, sheet, style = styles$pv0, rows = crow + i, cols = ccol + 2, stack = TRUE); @@ -832,7 +832,7 @@ exportInsuranceContract.xlsx = function(contract, filename) { fgFill = "#E0E0E0", halign = "center", valign = "center", textDecoration = "bold"), hide0 = createStyle(numFmt = "General; General; \"\""), - currency0 = createStyle(numFmt = "[$\u20ac C07] #,##0.00;[red]-[$\u20ac-C07] #,##0.00;\"\""), + currency0 = createStyle(numFmt = "[$\u20ac-C07] #,##0.00;[red]-[$\u20ac-C07] #,##0.00;\"\""), cost0 = createStyle(numFmt = "0.0##%; 0.0##%; \"\""), pv0 = createStyle(numFmt = "0.00000;-0.00000;\"\""), qx = createStyle(numFmt = "0.000000"), @@ -901,7 +901,7 @@ exportInsuranceContract.xlsx = function(contract, filename) { # Print out premium decomposition #### ############################################### # - sheet = "Pr\\u00e4mienzerlegung"; + sheet = "Pr\u00e4mienzerlegung"; addValuesWorksheet(wb, sheet); exportPremiumCompositionTable( wb = wb, sheet = sheet, contract = contract, diff --git a/R/showVmGlgExamples.R b/R/showVmGlgExamples.R index 0049d11576e4e9f45a636471ce0dff1bfb7231b6..c98fa06620bd15beaa16f13e44d0f2dc58ffe2a4 100644 --- a/R/showVmGlgExamples.R +++ b/R/showVmGlgExamples.R @@ -55,7 +55,7 @@ showVmGlgExamples = function(contract, prf = 10, t = 10, t_prf = 12, file = "", contract$tarif$desc, sprintf("Typ: %s", contract$tarif$tariffType), sprintf("VS: %.2f", contract$Parameters$ContractData$sumInsured), - sprintf("Alter: %d, LZ: %d, Pr\\u00e4mienzahlung: %d, Aufschubzeit: %d, Garantiezeit: %d", + sprintf("Alter: %d, LZ: %d, Pr\u00e4mienzahlung: %d, Aufschubzeit: %d, Garantiezeit: %d", contract$Parameters$ContractData$age, contract$Parameters$ContractData$policyPeriod, contract$Parameters$ContractData$premiumPeriod, @@ -67,21 +67,21 @@ showVmGlgExamples = function(contract, prf = 10, t = 10, t_prf = 12, file = "", contract$Parameters$ActuarialBases$mortalityTable@name), "", - "Pr\\u00e4mien:", + "Pr\u00e4mien:", "========", - sprintf("Nettopr\\u00e4mie: %8.2f", contract$Values$premiums["net"]), - sprintf("Zillmerpr\\u00e4mie: %8.2f", contract$Values$premiums["Zillmer"]), - sprintf("Bruttopr\\u00e4mie: %8.2f", contract$Values$premiums["gross"]), + sprintf("Nettopr\u00e4mie: %8.2f", contract$Values$premiums["net"]), + sprintf("Zillmerpr\u00e4mie: %8.2f", contract$Values$premiums["Zillmer"]), + sprintf("Bruttopr\u00e4mie: %8.2f", contract$Values$premiums["gross"]), sprintf("Vorgeschr.Pr.: %8.2f", contract$Values$premiums["written"]), "", - sprintf("Sparpr\\u00e4mie (t=%d): %8.2f", t, contract$Values$premiumComposition[t + 1, "Zillmer.savings"]), - sprintf("Risikopr\\u00e4mie (t=%d): %8.2f", t, contract$Values$premiumComposition[t + 1, "Zillmer.risk"]), + sprintf("Sparpr\u00e4mie (t=%d): %8.2f", t, contract$Values$premiumComposition[t + 1, "Zillmer.savings"]), + sprintf("Risikopr\u00e4mie (t=%d): %8.2f", t, contract$Values$premiumComposition[t + 1, "Zillmer.risk"]), "", "Reserven:", "=========", - sprintf("Pr\\u00e4mienpflichtig (t=%d): %8.2f", t, contract$Values$reserves[t + 1, "Zillmer"]), + sprintf("Pr\u00e4mienpflichtig (t=%d): %8.2f", t, contract$Values$reserves[t + 1, "Zillmer"]), ifelse(has.prf, sprintf("Pr.Frei (mangels Zahlung) (tprf=%d): %8.2f", t_prf, contract.prf$Values$reserves[t_prf + 1, "Zillmer"]), ""), sprintf("VwKostenreserve (t=%d): %8.2f", t, contract$Values$reserves[t + 1, "gamma"]), ifelse(has.prf, sprintf("VwKostenreserve (Pr.Frei) (tprf=%d): %8.2f", t_prf, contract.prf$Values$reserves[t_prf + 1, "gamma"]), ""), @@ -90,23 +90,23 @@ showVmGlgExamples = function(contract, prf = 10, t = 10, t_prf = 12, file = "", sprintf("Bilanzreserve (t=%.2f): %8.2f", contract$Values$reservesBalanceSheet[t + 1, "time"], contract$Values$reservesBalanceSheet[t + 1, "Balance Sheet Reserve"]), - sprintf("Pr\\u00e4mien\\u00fcbertrag (BM=%2d): %8.2f", month(contract$Parameters$ContractData$contractClosing), contract$Values$reservesBalanceSheet[t + 1, "unearned Premiums"]), + sprintf("Pr\u00e4mien\u00fcbertrag (BM=%2d): %8.2f", month(contract$Parameters$ContractData$contractClosing), contract$Values$reservesBalanceSheet[t + 1, "unearned Premiums"]), "", - "R\\u00fcckkauf und Pr\\u00e4mienfreistellung:", + "R\u00fcckkauf und Pr\u00e4mienfreistellung:", "=================================", - sprintf("R\\u00fcckkaufsreserve (t=%d): %8.2f", t, contract$Values$reserves[t + 1, "reduction"]), - sprintf("R\\u00fcckkaufswert (t=%d): %8.2f", t, contract$Values$reserves[t + 1, "Surrender"]), - sprintf("Abschlusskostenr\\u00fccktrag (t=%d): %8.2f", t, contract$Values$reserves[t + 1, "alphaRefund"]), + sprintf("R\u00fcckkaufsreserve (t=%d): %8.2f", t, contract$Values$reserves[t + 1, "reduction"]), + sprintf("R\u00fcckkaufswert (t=%d): %8.2f", t, contract$Values$reserves[t + 1, "Surrender"]), + sprintf("Abschlusskostenr\u00fccktrag (t=%d): %8.2f", t, contract$Values$reserves[t + 1, "alphaRefund"]), "", - ifelse(has.prf, sprintf("R\\u00fcckkaufswert (Prf.) (t=%d): %8.2f (VS: %.2f)", + ifelse(has.prf, sprintf("R\u00fcckkaufswert (Prf.) (t=%d): %8.2f (VS: %.2f)", t_prf, contract.prf$Values$reserves[t_prf + 1, "Surrender"], contract.prf$Values$reserves[t_prf + 1, "PremiumFreeSumInsured"]), ""), "", - ifelse(has.prf, sprintf("Pr\\u00e4mienfreie VS (t=%d): %8.2f", + ifelse(has.prf, sprintf("Pr\u00e4mienfreie VS (t=%d): %8.2f", t, contract$Values$reserves[t + 1, "PremiumFreeSumInsured"]), "") ); cat(paste(output, collapse = '\r\n'), file = file)