[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master f8853b9 090/156: Add "contract numbers" fragm
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master f8853b9 090/156: Add "contract numbers" fragment to the header |
Date: |
Tue, 30 Jan 2018 17:22:19 -0500 (EST) |
branch: master
commit f8853b93e3bc1f299ac8c966f1f3a1462e264a4c
Author: Vadim Zeitlin <address@hidden>
Commit: Vadim Zeitlin <address@hidden>
Add "contract numbers" fragment to the header
Defining the entire fragment, containing both fixed text and the
variables, in the code is not ideal, but expressing its logic in an
external template is quite verbose and it's not clear if it's worth
doing it.
---
header.mustache | 3 ++-
ledger_pdf_generator_wx.cpp | 52 +++++++++++++++++++++++++++++++++++++++------
2 files changed, 47 insertions(+), 8 deletions(-)
diff --git a/header.mustache b/header.mustache
index 11cb6b8..50c967d 100644
--- a/header.mustache
+++ b/header.mustache
@@ -52,8 +52,9 @@
<br>
{{^Composite}}
- Initial Death Benefit Option: {{InitDBOpt}}
+ Initial Death Benefit Option: {{InitDBOpt}}<br>
{{/Composite}}
+ {{ContractNumbers}}
</td>
<td width="40%">
Initial {{#HasTerm}}Total{{/HasTerm}}
diff --git a/ledger_pdf_generator_wx.cpp b/ledger_pdf_generator_wx.cpp
index bee5646..abfee9f 100644
--- a/ledger_pdf_generator_wx.cpp
+++ b/ledger_pdf_generator_wx.cpp
@@ -744,14 +744,52 @@ class pdf_illustration : protected html_interpolator
indent += indent;
add_variable("Space64", indent);
- auto const abbreviate_if_necessary = [](std::string s, size_t len)
+ auto const& invar = ledger_.GetLedgerInvariant();
+
+ // Build the combined string containing the master and individual
+ // contract numbers, omitting each of them if it's not specified and
+ // also truncating them to either 15 characters if both are present or
+ // 30 if only one of them is.
+ add_variable
+ ("ContractNumbers"
+ ,[this,invar]() -> std::string
{
- if(s.length() > len)
- {
- s.replace(len - 3, std::string::npos, "...");
- }
- return s;
- };
+ std::ostringstream oss;
+
+ bool const use_master_number
+ = !invar.MasterContractNumber.empty();
+
+ bool const use_policy_number
+ = !invar.ContractNumber.empty()
+ && !ledger_.is_composite()
+ ;
+
+ size_t const full_abbrev_length = 30;
+
+ if(use_master_number)
+ {
+ oss << "Master contract: "
+ << abbreviate_if_necessary
+ (invar.MasterContractNumber
+ ,use_policy_number
+ ? full_abbrev_length / 2
+ : full_abbrev_length
+ );
+ }
+ if(use_policy_number)
+ {
+ oss << "Contract number: "
+ << abbreviate_if_necessary
+ (invar.ContractNumber
+ ,use_master_number
+ ? full_abbrev_length / 2
+ : full_abbrev_length
+ );
+ }
+
+ return oss.str();
+ }()
+ );
}
- [lmi-commits] [lmi] master 234cd39 012/156: Use custom font sizes to be closer to the existing illustrations, (continued)
- [lmi-commits] [lmi] master 234cd39 012/156: Use custom font sizes to be closer to the existing illustrations, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 956fcca 071/156: Change the second narrative summary page to use a template too, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master dbe5955 015/156: Factor out html_interpolator from pdf_illustration, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 9665573 070/156: Change narrative summary page to use an external template, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master a629602 083/156: Use custom <scaled_image> HTML tag for the embedded images, Greg Chicares, 2018/01/30
- [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 <=
- [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, 2018/01/30
- [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