[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master ca6e17c 031/156: Add function generating a st
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master ca6e17c 031/156: Add function generating a standard header and use it |
Date: |
Tue, 30 Jan 2018 17:22:01 -0500 (EST) |
branch: master
commit ca6e17cffe70d0a14dcbea52c484674b7a192e7d
Author: Vadim Zeitlin <address@hidden>
Commit: Vadim Zeitlin <address@hidden>
Add function generating a standard header and use it
Add header to the "Narrative Summary" page and prepare for reusing it
on the other pages too.
---
ledger_pdf_generator_wx.cpp | 270 ++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 260 insertions(+), 10 deletions(-)
diff --git a/ledger_pdf_generator_wx.cpp b/ledger_pdf_generator_wx.cpp
index c7bf5f3..373dfdb 100644
--- a/ledger_pdf_generator_wx.cpp
+++ b/ledger_pdf_generator_wx.cpp
@@ -277,6 +277,37 @@ class pdf_illustration : protected html_interpolator
+ text::from(", ")
+ text::from(evaluate("PrepYear"))
);
+
+ auto indent = text::nbsp();
+ add_variable("Space1", indent);
+
+ indent += indent;
+ add_variable("Space2", indent);
+
+ indent += indent;
+ add_variable("Space4", indent);
+
+ indent += indent;
+ add_variable("Space8", indent);
+
+ auto const abbreviate_if_necessary = [](std::string s, size_t len)
+ {
+ if(s.length() > len)
+ {
+ s.replace(len - 3, std::string::npos, "...");
+ }
+ return s;
+ };
+
+ add_variable
+ ("CorpNameAbbrev50"
+ ,abbreviate_if_necessary(evaluate("CorpName"), 50)
+ );
+
+ add_variable
+ ("Insured1Abbrev50"
+ ,abbreviate_if_necessary(evaluate("Insured1"), 50)
+ );
}
// Use non-default font sizes to make it simpler to replicate the existing
@@ -611,6 +642,217 @@ class numbered_page : public page_with_footer
int numbered_page::last_page_number_ = 0;
+// Wrap the given HTML in a paragraph tag using (smaller) body font size.
+text add_body_paragraph_html(text const& t)
+{
+ return tag::p(tag::font[attr::size("-1")](t));
+}
+
+// Return HTML with the standard page header.
+text get_header_html
+ (LedgerInvariant const& invar
+ ,html_interpolator const& interpolate_html
+ )
+{
+ // Some convenient helpers for performing common operations.
+ auto const add_line = [=](char const* s) -> text
+ {
+ return tag::br + interpolate_html(s);
+ };
+
+ text header_html = interpolate_html
+ (R"(
+{{#IsInforce}}
+LIFE INSURANCE IN FORCE BASIC ILLUSTRATION
+{{/IsInforce}}
+{{^IsInforce}}
+LIFE INSURANCE BASIC ILLUSTRATION
+{{/IsInforce}}
+)"
+ );
+
+ header_html += add_line("{{InsCoName}}");
+
+ if(invar.ProducerName != "0")
+ {
+ header_html += add_line("Presented by: {{ProducerName}}");
+ }
+
+ if(invar.ProducerStreet != "0")
+ {
+ header_html += add_line("{{ProducerStreet}}");
+ }
+
+ if(invar.ProducerCity != "0")
+ {
+ header_html += add_line("{{ProducerCity}}");
+ }
+
+ // Construct the left-hand side of the summary table.
+ text lhs_html = text::from("Prepared for:");
+
+ lhs_html += add_line("{{Space8}}Group Name:{{CorpNameAbbrev50}}");
+
+ lhs_html += add_line
+ (R"(
+{{#Composite}}
+Composite Illustration
+{{/Composite}}
+{{^Composite}}
+{{Space8}}Insured:{{Insured1Abbrev50}}
+{{/Composite}}
+)"
+ );
+
+ if(!interpolate_html.test_variable("Composite"))
+ {
+ lhs_html += add_line("{{Space8}}Age: {{Age}}");
+ }
+
+ lhs_html += add_line
+ (R"(
+Product: {{PolicyForm}}{{Space1}}{{PolicyMktgName}}
+)"
+ );
+
+ lhs_html += add_line
+ (R"(
+{{#ModifiedSinglePremium}}
+Modified Single Premium Adjustable Life Insurance Policy
+{{/ModifiedSinglePremium}}
+{{^ModifiedSinglePremium}}
+{{PolicyLegalName}}
+{{/ModifiedSinglePremium}}
+)"
+ );
+
+ if(!interpolate_html.test_variable("IsInforce"))
+ {
+ lhs_html += add_line
+ (R"(
+{{^SinglePremium}}
+Initial Premium:
+{{/SinglePremium}}
+{{#SinglePremium}}
+Single Premium:
+{{/SinglePremium}}
+{{Space1}}${{InitPrem}}
+)"
+ );
+ }
+
+ if(!interpolate_html.test_variable("Composite"))
+ {
+ lhs_html += add_line
+ ("Initial Death Benefit Option: {{InitDBOpt}}"
+ );
+ }
+
+ // Now the right-hand side.
+ auto rhs_html = interpolate_html
+ (R"(
+Initial {{#HasTerm}}Total{{/HasTerm}}
+Selected Face Amount: ${{InitTotalSA}}
+)"
+ );
+
+ if(interpolate_html.test_variable("HasTerm"))
+ {
+ rhs_html += add_line
+ ("Initial Base Face Amount: ${{InitBaseSpecAmt}}"
+ );
+
+ rhs_html += add_line
+ ("Initial Term Face Amount: ${{InitTermSpecAmt}}"
+ );
+ }
+
+ rhs_html += add_line
+ ("Guaranteed Crediting Rate: {{InitAnnGenAcctInt_Guaranteed}}"
+ );
+
+ rhs_html += add_line
+ (R"(
+Current Illustrated Crediting Rate:
+{{#InforceYear}}
+{{UltimateInterestRate}}
+{{/InforceYear}}
+{{^InforceYear}}
+{{InitAnnGenAcctInt_Current}}
+{{/InforceYear}}
+)"
+ );
+
+ if
+ ( interpolate_html.test_variable("SinglePremium")
+ && invar.InforceYear <= 4
+ )
+ {
+ rhs_html += add_line
+ (R"(
+Ultimate Illustrated Crediting Rate:
+{{#ModifiedSinglePremium0}}
+{{AnnGAIntRate_Current[11]}}
+{{/ModifiedSinglePremium0}}
+{{^ModifiedSinglePremium0}}
+{{AnnGAIntRate_Current[6]}}
+{{/ModifiedSinglePremium0}}
+)"
+ );
+ }
+
+ if(!interpolate_html.test_variable("Composite"))
+ {
+ rhs_html += add_line
+ (R"(
+Underwriting Type:
+{{#UWTypeIsMedical}}
+Fully underwritten
+{{/UWTypeIsMedical}}
+{{^UWTypeIsMedical}}
+{{UWType}}
+{{/UWTypeIsMedical}}
+)"
+ );
+
+ rhs_html += add_line
+ (R"(
+Rate Classification: {{UWClass}}, {{Smoker}}, {{Gender}}
+)"
+ );
+
+ if(invar.UWClass == "Rated")
+ {
+ rhs_html += add_line
+ ("{{Space2}}{{Space1}}Table Rating: {{SubstandardTable}}"
+ );
+ }
+ }
+
+ // Put everything together.
+ return
+ tag::font[attr::size("-1")]
+ (tag::p[attr::align("center")]
+ (header_html
+ )
+ )
+ (tag::p
+ (text::nbsp()
+ )
+ )
+ (tag::table
+ [attr::width("100%")]
+ [attr::cellspacing("0")]
+ [attr::cellpadding("0")]
+ [attr::valign("top")]
+ (tag::tr
+ (tag::td(lhs_html))
+ (tag::td(rhs_html))
+ )
+ )
+ ;
+}
+
class narrative_summary_page : public numbered_page
{
public:
@@ -623,18 +865,16 @@ class narrative_summary_page : public numbered_page
{
numbered_page::render(ledger, writer, dc, interpolate_html);
- text summary_html =
- tag::p[attr::align("center")]
- (text::from("NARRATIVE SUMMARY")
- )
- ;
+ text summary_html = get_header_html
+ (ledger.GetLedgerInvariant()
+ ,interpolate_html
+ );
- // Just a helper performing a common operation.
- auto const add_body_paragraph_html = [](text const& t) -> text
- {
- return tag::p(tag::font[attr::size("-1")](t));
- };
+ summary_html += tag::p[attr::align("center")]
+ (text::from("NARRATIVE SUMMARY")
+ );
+ // Just a convenient helper performing a common operation.
auto const add_body_paragraph = [=](std::string const& s) -> text
{
return add_body_paragraph_html(interpolate_html(s));
@@ -934,6 +1174,16 @@ class pdf_illustration_regular : public pdf_illustration
,invar.GetStatePostalAbbrev() == "TX"
);
+ add_variable
+ ("UWTypeIsMedical"
+ ,invar.UWType == "Medical"
+ );
+
+ add_variable
+ ("UltimateInterestRate"
+ ,evaluate("AnnGAIntRate_Current", invar.InforceYear + 1)
+ );
+
// Add all the pages.
add<cover_page>();
add<narrative_summary_page>();
- [lmi-commits] [lmi] master 5e2fc70 007/156: Make HTML generation utilities more type-safe, (continued)
- [lmi-commits] [lmi] master 5e2fc70 007/156: Make HTML generation utilities more type-safe, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 7ed2bbf 027/156: Simplify footer generation code by moving font tag outside, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master d7244c1 043/156: Change the colour used for lines and borders, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 41ae40d 089/156: Fix wrong "<br>" tag in the header template, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master acb7aae 049/156: Add numbered_page::get_extra_pages_needed() hook, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master c0d68e1 122/156: Add rate of return pages of the individual placement illustration, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 875ca7d 039/156: Rename StateIsTX ledger variable to StateIsTexas, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 31048c8 047/156: Make wx_table_generator even more customizable, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 10dd0a9 051/156: Factor enum_output_mode into a separate header to allow its reuse, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 8fa972e 052/156: Add "Tabular Detail, continued" page to the PDF illustration, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master ca6e17c 031/156: Add function generating a standard header and use it,
Greg Chicares <=
- [lmi-commits] [lmi] master c378bc5 064/156: Remove unnecessary value_cast inclusion, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 41de2e2 140/156: Add helper expand_template() method, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 3e8e257 017/156: Add pdf_illustration_regular and narrative_summary_page, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 614fb47 135/156: Add supplemental reports pages to private placement illustrations, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 49cc809 072/156: Remove HTML construction helpers not needed any more, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master efc01fa 046/156: Allow disabling separator lines in wx_table_generator, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master e20544f 018/156: Add check for the ledger type, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master a0a167e 144/156: Rename "compliance_tracking_number" template to "imprimatur", Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 982c9f0 149/156: Remove consecutive blank lines from a Mustache template, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master ec73905 058/156: Add extra pair of braces to std::array<> initializer for clang, Greg Chicares, 2018/01/30