[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master d5d8185 057/156: Add tabular_details page
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master d5d8185 057/156: Add tabular_details page |
Date: |
Tue, 30 Jan 2018 17:22:09 -0500 (EST) |
branch: master
commit d5d818557110f076019f4fbf901cdaa69ea92036
Author: Vadim Zeitlin <address@hidden>
Commit: Vadim Zeitlin <address@hidden>
Add tabular_details page
This is simple after the refactorings in the previous commits as this
class reuses the logic in the base page_with_tabular_report class.
The only new difficulty is that a hack to support dummy separator
columns is required to reproduce the gap between the guaranteed and
non-guaranteed values in the existing illustrations.
---
ledger_pdf_generator_wx.cpp | 114 +++++++++++++++++++++++++++++++++++++++++++-
tabular_details.mustache | 14 ++++++
2 files changed, 127 insertions(+), 1 deletion(-)
diff --git a/ledger_pdf_generator_wx.cpp b/ledger_pdf_generator_wx.cpp
index aab0021..5dbb642 100644
--- a/ledger_pdf_generator_wx.cpp
+++ b/ledger_pdf_generator_wx.cpp
@@ -1747,7 +1747,14 @@ class page_with_tabular_report : public numbered_page
for(std::size_t col = 0; col < columns.size(); ++col)
{
std::string const variable_name =
columns[col].variable_name;
- values[col] = interpolate_html.evaluate(variable_name,
year);
+
+ // Special hack for the dummy columns used in some reports,
+ // whose value is always empty as it's used only as
+ // separator.
+ values[col] = variable_name.empty()
+ ? std::string{}
+ : interpolate_html.evaluate(variable_name, year)
+ ;
}
if(table.output_and_check_for_page_break(year, &pos_y,
values.data()))
@@ -1840,6 +1847,110 @@ class page_with_tabular_report : public numbered_page
}
};
+class tabular_detail_page : public page_with_tabular_report
+{
+ private:
+ enum
+ {column_policy_year
+ ,column_end_of_year_age
+ ,column_premium_outlay
+ ,column_guar_account_value
+ ,column_guar_cash_surr_value
+ ,column_guar_death_benefit
+ ,column_dummy_separator
+ ,column_cur_account_value
+ ,column_cur_cash_surr_value
+ ,column_cur_death_benefit
+ ,column_max
+ };
+
+ int render_or_measure_fixed_page_part
+ (illustration_table_generator& table
+ ,pdf_writer_wx& writer
+ ,wxDC& dc
+ ,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("{{>tabular_details}}")
+ ,output_mode
+ );
+
+ // Decrease the font size for the table to match the main page
+ // body text size.
+ dc.SetFont(dc.GetFont().Smaller());
+ dc.SetPen(HIGHLIGHT_COL);
+
+ // Make a copy because we want the real pos_y to be modified only once,
+ // not twice, by both output_super_header() calls.
+ auto pos_y_copy = pos_y;
+ table.output_super_header
+ ("Guaranteed Values"
+ ,column_guar_account_value
+ ,column_dummy_separator
+ ,&pos_y_copy
+ ,output_mode
+ );
+ table.output_super_header
+ ("Non-Guaranteed Values"
+ ,column_cur_account_value
+ ,column_max
+ ,&pos_y
+ ,output_mode
+ );
+
+ pos_y += table.get_separator_line_height();
+ table.output_horz_separator
+ (column_guar_account_value
+ ,column_dummy_separator
+ ,pos_y
+ ,output_mode
+ );
+ table.output_horz_separator
+ (column_cur_account_value
+ ,column_max
+ ,pos_y
+ ,output_mode
+ );
+
+ 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;
+ }
+
+ columns const& get_report_columns() const override
+ {
+ static columns const columns =
+ {{ "PolicyYear" , "Policy\nYear" , "999" }
+ ,{ "AttainedAge" , "End of\nYear Age" , "999" }
+ ,{ "GrossPmt" , "Premium\nOutlay" , "999,999" }
+ ,{ "AcctVal_Guaranteed" , "Account\nValue" , "999,999" }
+ ,{ "CSVNet_Guaranteed" , "Cash Surr\nValue" , "999,999" }
+ ,{ "EOYDeathBft_Guaranteed" , "Death\nBenefit" , "9,999,999" }
+ ,{ "" , " " , "----" }
+ ,{ "AcctVal_Current" , "Account\nValue" , "999,999" }
+ ,{ "CSVNet_Current" , "Cash Surr\nValue" , "999,999" }
+ ,{ "EOYDeathBft_Current" , "Death\nBenefit" , "9,999,999" }
+ };
+
+ return columns;
+ }
+};
+
class tabular_detail2_page : public page_with_tabular_report
{
private:
@@ -2062,6 +2173,7 @@ class pdf_illustration_regular : public pdf_illustration
{
add<numeric_summary_page>();
}
+ add<tabular_detail_page>();
add<tabular_detail2_page>();
}
};
diff --git a/tabular_details.mustache b/tabular_details.mustache
new file mode 100644
index 0000000..fef605c
--- /dev/null
+++ b/tabular_details.mustache
@@ -0,0 +1,14 @@
+{{>header}}
+
+<p align="center">Tabular Detail</p>
+
+<p align="center"><font size="-1">
+Values shown are in
+{{#HasScaleUnit}}
+{{ScaleUnit}}s of
+{{/HasScaleUnit}}
+dollars
+</font></p>
+
+<br></br>
+<br></br>
- [lmi-commits] [lmi] master updated (70fb246 -> 408ba18), Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master cfdf224 016/156: Use raw multiline string instead of concatenating several strings, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 1d99e76 008/156: Make pdf_writer_wx::output_html() type safe by taking html::text, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master e43a485 005/156: Further improve wxPdfDocument API encapsulation and reuse, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 7d278ef 011/156: Add footer to the cover page, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master d5d8185 057/156: Add tabular_details page,
Greg Chicares <=
- [lmi-commits] [lmi] master bb64784 013/156: Add a helper allowing to interpolate variables in strings, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master b72ced6 014/156: Replace ad hoc illustration properties with HTML interpolator, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master e7d763d 066/156: Add company logo display to the PDF illustration header, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master f575c94 003/156: Refactor more group_quote_pdf_gen_wx code to allow its reuse, Greg Chicares, 2018/01/30
- [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