[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master b5fe850 102/156: Add NASD basic illustration
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master b5fe850 102/156: Add NASD basic illustration page |
Date: |
Tue, 30 Jan 2018 17:22:22 -0500 (EST) |
branch: master
commit b5fe850dd4d924659b0fde06e663b371402d8490
Author: Vadim Zeitlin <address@hidden>
Commit: Vadim Zeitlin <address@hidden>
Add NASD basic illustration page
This is a relatively straightforward reimplementation of the
corresponding part of nasd.xsl.
Implementation reuses the existing page_with_tabular_report class and
the only difference with the other existing tables is that the labels of
the columns of this one are dynamic, i.e. depend themselves on the
illustration values, so need to be generated using HTML interpolator.
---
ledger_pdf_generator_wx.cpp | 217 ++++++++++++++++++++++++++++++++++++++++++++
nasd_basic.mustache | 14 +++
2 files changed, 231 insertions(+)
diff --git a/ledger_pdf_generator_wx.cpp b/ledger_pdf_generator_wx.cpp
index a80b111..e7f1ab3 100644
--- a/ledger_pdf_generator_wx.cpp
+++ b/ledger_pdf_generator_wx.cpp
@@ -1897,6 +1897,220 @@ class pdf_illustration_regular : public pdf_illustration
std::string get_lower_footer_template_name() const override { return
"footer"; }
};
+class nasd_basic : public page_with_tabular_report
+{
+ private:
+ enum
+ {column_policy_year
+ ,column_end_of_year_age
+ ,column_premium_outlay
+ ,column_guar0_cash_surr_value
+ ,column_guar0_death_benefit
+ ,column_separator_guar0_guar
+ ,column_guar_cash_surr_value
+ ,column_guar_death_benefit
+ ,column_separator_guar_cur0
+ ,column_cur0_cash_surr_value
+ ,column_cur0_death_benefit
+ ,column_separator_cur0_cur
+ ,column_cur_cash_surr_value
+ ,column_cur_death_benefit
+ ,column_max
+ };
+
+ illustration_table_columns const& get_table_columns() const override
+ {
+ static illustration_table_columns const columns =
+ {{ "PolicyYear" , "Policy\nYear" , "999"
}
+ ,{ "AttainedAge" , "End of\nYear Age" , "999"
}
+ ,{ "GrossPmt" , "Premium\nOutlay" , "999,999"
}
+ ,{ "CSVNet_GuaranteedZero" , "Cash Surr\nValue" , "999,999"
}
+ ,{ "EOYDeathBft_GuaranteedZero" , "Death\nBenefit" , "9,999,999"
}
+ ,{ "" , " " , "-"
}
+ ,{ "CSVNet_Guaranteed" , "Cash Surr\nValue" , "999,999"
}
+ ,{ "EOYDeathBft_Guaranteed" , "Death\nBenefit" , "9,999,999"
}
+ ,{ "" , " " , "-"
}
+ ,{ "CSVNet_CurrentZero" , "Cash Surr\nValue" , "999,999"
}
+ ,{ "EOYDeathBft_CurrentZero" , "Death\nBenefit" , "9,999,999"
}
+ ,{ "" , " " , "-"
}
+ ,{ "CSVNet_Current" , "Cash Surr\nValue" , "999,999"
}
+ ,{ "EOYDeathBft_Current" , "Death\nBenefit" , "9,999,999"
}
+ };
+
+ return columns;
+ }
+
+ bool should_show_column(Ledger const& ledger, int column) const override
+ {
+ // One column should be hidden for composite ledgers.
+ return column != column_end_of_year_age || !ledger.is_composite();
+ }
+
+ int render_or_measure_fixed_page_part
+ (illustration_table_generator& table
+ ,pdf_writer_wx& writer
+ ,html_interpolator const& interpolate_html
+ ,enum_output_mode output_mode
+ ) const override
+ {
+ int pos_y = writer.get_vert_margin();
+
+ pos_y += writer.output_html
+ (writer.get_horz_margin()
+ ,pos_y
+ ,writer.get_page_width()
+ ,interpolate_html("{{>nasd_basic}}")
+ ,output_mode
+ );
+
+ // Output the first super header row.
+
+ auto pos_y_copy = pos_y;
+ table.output_super_header
+ ("Using guaranteed charges"
+ ,column_guar0_cash_surr_value
+ ,column_separator_guar_cur0
+ ,&pos_y
+ ,output_mode
+ );
+
+ pos_y = pos_y_copy;
+ table.output_super_header
+ ("Using current charges"
+ ,column_cur0_cash_surr_value
+ ,column_max
+ ,&pos_y
+ ,output_mode
+ );
+
+ pos_y += table.get_separator_line_height();
+ table.output_horz_separator
+ (column_guar0_cash_surr_value
+ ,column_separator_guar_cur0
+ ,pos_y
+ ,output_mode
+ );
+ table.output_horz_separator
+ (column_cur0_cash_surr_value
+ ,column_max
+ ,pos_y
+ ,output_mode
+ );
+
+ // Output the second super header row which is composed of three
+ // physical lines.
+
+ enum class base
+ {guaranteed
+ ,current
+ };
+
+ enum class interest_rate
+ {zero
+ ,non_zero
+ };
+
+ // This function outputs all lines of a single header, corresponding to
+ // the "Guaranteed" or "Current", "Zero" or not, column and returns the
+ // vertical position below the header.
+ auto const output_two_column_super_header = [=,&table]
+ (base guar_or_cur
+ ,interest_rate zero_or_not
+ ,std::size_t begin_column
+ ) -> int
+ {
+ std::size_t end_column = begin_column + 2;
+ LMI_ASSERT(end_column <= column_max);
+
+ auto y = pos_y;
+
+ std::string const suffix_short = [=]()
+ {
+ switch(guar_or_cur)
+ {
+ case base::guaranteed: return "Guaranteed";
+ case base::current: return "Current" ;
+ }
+ throw "Unreachable--unknown base value";
+ }()
+ ;
+
+ std::string const suffix_full = suffix_short + [=]()
+ {
+ switch(zero_or_not)
+ {
+ case interest_rate::zero: return "Zero";
+ case interest_rate::non_zero: return "" ;
+ }
+ throw "Unreachable--unknown interest_rate value";
+ }()
+ ;
+
+
+ std::array<std::string, 3> const header_lines =
+ {
+ {"{{InitAnnSepAcctGrossInt_" + suffix_full + "}} Assumed
Sep Acct"
+ ,"Gross Rate* ({{InitAnnSepAcctNetInt_" + suffix_full +
"}} net)"
+ ,"{{InitAnnGenAcctInt_" + suffix_short + "}} GPA rate"
+ }
+ };
+
+ for(auto const& line : header_lines)
+ {
+ table.output_super_header
+ (interpolate_html(line).as_html()
+ ,begin_column
+ ,end_column
+ ,&y
+ ,output_mode
+ );
+ }
+
+ y += table.get_separator_line_height();
+ table.output_horz_separator
+ (begin_column
+ ,end_column
+ ,y
+ ,output_mode
+ );
+
+ return y;
+ };
+
+ output_two_column_super_header
+ (base::guaranteed
+ ,interest_rate::zero
+ ,column_guar0_cash_surr_value
+ );
+
+ output_two_column_super_header
+ (base::guaranteed
+ ,interest_rate::non_zero
+ ,column_guar_cash_surr_value
+ );
+
+ output_two_column_super_header
+ (base::current
+ ,interest_rate::zero
+ ,column_cur0_cash_surr_value
+ );
+
+ pos_y = output_two_column_super_header
+ (base::current
+ ,interest_rate::non_zero
+ ,column_cur_cash_surr_value
+ );
+
+ // Finally output the standard header.
+ table.output_header(&pos_y, output_mode);
+
+ pos_y += table.get_separator_line_height();
+ table.output_horz_separator(0, column_max, pos_y, output_mode);
+
+ return pos_y;
+ }
+};
+
// NASD illustration.
class pdf_illustration_nasd : public pdf_illustration
{
@@ -1909,6 +2123,7 @@ class pdf_illustration_nasd : public pdf_illustration
{
auto const& invar = ledger.GetLedgerInvariant();
+ // Define variables specific to this illustration.
add_abbreviated_variable("CorpName", 60);
add_abbreviated_variable("Insured1", 30);
@@ -1934,7 +2149,9 @@ class pdf_illustration_nasd : public pdf_illustration
,test_variable("HasTerm") || test_variable("HasSupplSpecAmt")
);
+ // Add all the pages.
add<cover_page>();
+ add<nasd_basic>();
add<standard_page>("nasd_column_headings");
}
diff --git a/nasd_basic.mustache b/nasd_basic.mustache
new file mode 100644
index 0000000..43c139c
--- /dev/null
+++ b/nasd_basic.mustache
@@ -0,0 +1,14 @@
+{{>nasd_header_upper}}
+{{#IsInforce}}
+ <p align="center">
+ In Force Illustration
+ </p>
+{{/IsInforce}}
+{{>nasd_header_lower}}
+
+{{>dollar_units}}
+
+<br></br>
+<br></br>
+
+{{! Basic illustration table is created from C++ code }}
- [lmi-commits] [lmi] master b425030 082/156: Factor out html_cell_for_pdf_output from numeric_summary_table_cell, (continued)
- [lmi-commits] [lmi] master b425030 082/156: Factor out html_cell_for_pdf_output from numeric_summary_table_cell, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master d99576a 069/156: Change cover page to use an external template, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 416ab02 030/156: Add support for vector variables to PDF generating code, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master d4dfaa9 075/156: Also use data directory for image files referenced from HTML, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 4f98db5 081/156: Don't show "Age 70" row in numeric summary for composites, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master f8853b9 090/156: Add "contract numbers" fragment to the header, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 61430d2 092/156: Move some variable definitions to the base illustration class, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 7ccd207 087/156: Rename "footer_contents" to more precise "page_number", Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 3a64b87 094/156: Correct misleading comment for page class dtor, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 4e76bba 098/156: Add support for comments to the string interpolation function, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master b5fe850 102/156: Add NASD basic illustration page,
Greg Chicares <=
- [lmi-commits] [lmi] master 4250de9 104/156: Add first variant of NASD supplemental page, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 7a1e1e8 025/156: Include the missing <cstring> header, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 8bfb896 109/156: Add NASD illustration first explanatory notes page, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master ea20a31 095/156: Make pdf_illustration dtor virtual, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 61fae89 091/156: Reimplement the contract numbers fragment as an external template, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 0c55621 085/156: Replace trivial PDF page classes with single standard_page one, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master ea2564b 099/156: Split the NASD header template in the upper and lower parts, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master c1bf4a8 032/156: Adjust position of the right hand side of the header manually, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 89b4674 120/156: Add automatic support for multiline super-headers, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 0f885a2 116/156: Define CorpNameAbbrev60 and Insured1Abbrev30 in common code, Greg Chicares, 2018/01/30