[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 3e8e257 017/156: Add pdf_illustration_regular
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 3e8e257 017/156: Add pdf_illustration_regular and narrative_summary_page |
Date: |
Tue, 30 Jan 2018 17:21:52 -0500 (EST) |
branch: master
commit 3e8e2575c1c0bcc996b349d5617e3cee7e9adf2b
Author: Vadim Zeitlin <address@hidden>
Commit: Vadim Zeitlin <address@hidden>
Add pdf_illustration_regular and narrative_summary_page
Start writing class combining all pages of a regular illustration and
its second page.
This is still very much work in progress.
---
ledger_pdf_generator_wx.cpp | 147 +++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 145 insertions(+), 2 deletions(-)
diff --git a/ledger_pdf_generator_wx.cpp b/ledger_pdf_generator_wx.cpp
index 6b5fb16..319fcf8 100644
--- a/ledger_pdf_generator_wx.cpp
+++ b/ledger_pdf_generator_wx.cpp
@@ -47,6 +47,15 @@ using namespace html;
namespace
{
+// This function is also provided in <boost/algorithm/string/predicate.hpp>,
+// but it's arguably not worth adding dependency on this Boost library just for
+// this function.
+inline
+bool starts_with(std::string const& s, char const* prefix)
+{
+ return s.compare(0, strlen(prefix), prefix) == 0;
+}
+
// Helper class grouping functions for dealing with interpolating strings
// containing variable references.
class html_interpolator
@@ -430,6 +439,141 @@ affiliated company and sales representatives,
${InsCoAddr}.
}
};
+class narrative_summary_page : public page
+{
+ public:
+ void render
+ (Ledger const& ledger
+ ,pdf_writer_wx& writer
+ ,wxDC& dc
+ ,html_interpolator const& interpolate_html
+ ) override
+ {
+ auto const& invar = ledger.GetLedgerInvariant();
+
+ text summary_html =
+ tag::p[attr::align("center")]
+ (text::from("NARRATIVE SUMMARY")
+ )
+ ;
+
+ std::string description;
+ if(!interpolate_html.test_variable("SinglePremium"))
+ {
+ description = R"(
+${PolicyMktgName} is a ${GroupExperienceRating?group}${GroupCarveout?group}
+flexible premium adjustable life insurance contract.
+${GroupExperienceRating?
+It is a no-load policy and is intended for large case sales.
+It is primarily marketed to financial institutions
+to fund certain corporate liabilities.
+}
+It features accumulating account values, adjustable benefits,
+and flexible premiums.
+)";
+ }
+ else if( interpolate_html.test_variable("ModifiedSinglePremium")
+ || interpolate_html.test_variable("ModifiedSinglePremium0")
+ )
+ {
+ description = R"(
+${PolicyMktgName}
+is a modified single premium adjustable life
+insurance contract. It features accumulating
+account values, adjustable benefits, and single premium.
+)";
+ }
+ else
+ {
+ description = R"(
+${PolicyMktgName}
+is a single premium adjustable life insurance contract.
+It features accumulating account values,
+adjustable benefits, and single premium.
+)";
+ }
+
+ summary_html +=
+ tag::p
+ (tag::font[attr::size("-1")]
+ (interpolate_html(description.c_str())
+ )
+ )
+ ;
+
+ if(!invar.IsInforce)
+ {
+ summary_html +=
+ tag::p
+ (tag::font[attr::size("-1")]
+ (interpolate_html
+ (R"(
+Coverage may be available on a Guaranteed Standard Issue basis.
+All proposals are based on case characteristics and must
+be approved by the ${InsCoShortName}
+Home Office. For details regarding underwriting
+and coverage limitations refer to your offer letter
+or contact your ${InsCoShortName} representative.
+)"
+ )
+ )
+ )
+ ;
+ }
+
+ writer.output_html
+ (writer.get_horz_margin()
+ ,writer.get_vert_margin()
+ ,writer.get_page_width()
+ ,summary_html
+ );
+ }
+};
+
+// Regular illustration.
+class pdf_illustration_regular : public pdf_illustration
+{
+ public:
+ pdf_illustration_regular(Ledger const& ledger
+ ,fs::path const& output
+ )
+ :pdf_illustration(ledger, output)
+ {
+ auto const& invar = ledger.GetLedgerInvariant();
+ auto const& policy_name = invar.PolicyLegalName;
+
+ // Define variables specific to this illustration.
+ add_variable
+ ("ModifiedSinglePremium"
+ ,starts_with(policy_name, "Single") &&
invar.GetStatePostalAbbrev() == "MA"
+ );
+
+ add_variable
+ ("ModifiedSinglePremium0"
+ ,starts_with(policy_name, "Modified")
+ );
+
+ add_variable
+ ("SinglePremium"
+ ,starts_with(policy_name, "Single") || starts_with(policy_name,
"Modified")
+ );
+
+ add_variable
+ ("GroupCarveout"
+ ,policy_name == "Group Flexible Premium Adjustable Life Insurance
Certificate"
+ );
+
+ add_variable
+ ("GroupExperienceRating"
+ ,policy_name == "Group Flexible Premium Adjustable Life Insurance
Policy"
+ );
+
+ // Add all the pages.
+ add<cover_page>();
+ add<narrative_summary_page>();
+ }
+};
+
class ledger_pdf_generator_wx : public ledger_pdf_generator
{
public:
@@ -452,8 +596,7 @@ void ledger_pdf_generator_wx::write
,fs::path const& output
)
{
- pdf_illustration pdf_ill(ledger, output);
- pdf_ill.add<cover_page>();
+ pdf_illustration_regular(ledger, output);
}
volatile bool ensure_setup = ledger_pdf_generator::set_creator
- [lmi-commits] [lmi] master 41ae40d 089/156: Fix wrong "<br>" tag in the header template, (continued)
- [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, 2018/01/30
- [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 <=
- [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
- [lmi-commits] [lmi] master 6a5cd32 079/156: Add "Table Rating" to the header if necessary, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master b01d478 029/156: Resurrect ledger XML IO code as new ledger_evaluator, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 89c676d 009/156: Add pdf_writer_wx::get_page_height() helper, Greg Chicares, 2018/01/30