lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [6353] Verify census consistency before running a group qu


From: Greg Chicares
Subject: [lmi-commits] [6353] Verify census consistency before running a group quote
Date: Thu, 15 Oct 2015 14:01:40 +0000

Revision: 6353
          http://svn.sv.gnu.org/viewvc/?view=rev&root=lmi&revision=6353
Author:   chicares
Date:     2015-10-15 14:01:39 +0000 (Thu, 15 Oct 2015)
Log Message:
-----------
Verify census consistency before running a group quote

Modified Paths:
--------------
    lmi/trunk/census_view.cpp
    lmi/trunk/group_quote_pdf_gen_wx.cpp
    lmi/trunk/illustrator.cpp
    lmi/trunk/illustrator.hpp

Modified: lmi/trunk/census_view.cpp
===================================================================
--- lmi/trunk/census_view.cpp   2015-10-11 22:19:24 UTC (rev 6352)
+++ lmi/trunk/census_view.cpp   2015-10-15 14:01:39 UTC (rev 6353)
@@ -1423,7 +1423,7 @@
 
 bool CensusView::DoAllCells(mcenum_emission emission)
 {
-    assert_consistent_run_order(case_parms()[0], cell_parms());
+    test_census_consensus(emission, case_parms()[0], cell_parms());
 
     illustrator z(emission);
     if(!z(base_filename(), cell_parms()))

Modified: lmi/trunk/group_quote_pdf_gen_wx.cpp
===================================================================
--- lmi/trunk/group_quote_pdf_gen_wx.cpp        2015-10-11 22:19:24 UTC (rev 
6352)
+++ lmi/trunk/group_quote_pdf_gen_wx.cpp        2015-10-15 14:01:39 UTC (rev 
6353)
@@ -526,6 +526,23 @@
 {
 }
 
+namespace
+{
+void assert_nonblank(std::string const& value, std::string const& name)
+{
+    if(std::string::npos == value.find_first_not_of(" \f\n\r\t\v"))
+        {
+        fatal_error() << name << " must not be blank." << LMI_FLUSH;
+        }
+}
+} // Unnamed namespace.
+
+/// Copy global report data from ledger.
+///
+/// All ledger data used here must be checked for consistency upstream
+/// by assert_okay_to_run_group_quote(); therefore, any changes in the
+/// set of data used here should be reflected there.
+
 void group_quote_pdf_generator_wx::global_report_data::fill_global_report_data
     (LedgerInvariant const& ledger
     )
@@ -539,6 +556,7 @@
     contract_state_   = ledger.GetStatePostalAbbrev();
     jdn_t eff_date    = jdn_t(static_cast<int>(ledger.EffDateJdn));
     effective_date_   = ConvertDateToWx(eff_date).FormatDate().ToStdString();
+    // SOMEDAY !! Suppress <br> elements preceding blank strings.
     footer_           =
                           escape_for_html_elem(ledger.GroupQuoteIsNotAnOffer   
)
         + "<br><br>"    + escape_for_html_elem(ledger.GroupQuoteRidersFooter   
)
@@ -550,6 +568,23 @@
         + "<br><br>"    + escape_for_html_elem(ledger.GroupQuoteBrokerDealer   
)
         ;
 
+    assert_nonblank(company_         , "Sponsor");
+    assert_nonblank(prepared_by_     , "Agent");
+    assert_nonblank(product_         , "Product name");
+    assert_nonblank(short_product_   , "Product ID");
+    assert_nonblank(available_riders_, "Available riders"); // If none, should 
say "none".
+    assert_nonblank(premium_mode_    , "Mode");
+    assert_nonblank(contract_state_  , "State");
+    assert_nonblank(effective_date_  , "Effective date");
+
+    assert_nonblank(ledger.GroupQuoteIsNotAnOffer   , "First footnote");
+    assert_nonblank(ledger.GroupQuoteRidersFooter   , "Second footnote");
+    assert_nonblank(ledger.GroupQuotePolicyFormId   , "Third footnote");
+    assert_nonblank(ledger.GroupQuoteStateVariations, "Fourth footnote");
+    assert_nonblank(ledger.MarketingNameFootnote    , "Fifth footnote");
+    // The other footnotes may be blank for non-variable products.
+    // In principle this could be discerned by Ledger::ledger_type().
+
     extra_fields_     = parse_extra_report_fields(ledger.Comments);
 }
 
@@ -557,11 +592,10 @@
 {
     LedgerInvariant const& Invar = ledger.GetLedgerInvariant();
 
-    // Header and footer data must be the same for all ledgers.
-    // FIXME This needs to be asserted. And leaving "Company"
-    // empty is a plausible user error that should be protected
-    // against by an assertion.
-    if(report_data_.company_.empty())
+    // Initialize 'report_data_' the first time this function is
+    // called: i.e., iff its 'contract_state_' field is empty, because
+    // the state postal abbreviation in a ledger can never be empty.
+    if(report_data_.contract_state_.empty())
         {
         report_data_.fill_global_report_data(Invar);
         }

Modified: lmi/trunk/illustrator.cpp
===================================================================
--- lmi/trunk/illustrator.cpp   2015-10-11 22:19:24 UTC (rev 6352)
+++ lmi/trunk/illustrator.cpp   2015-10-15 14:01:39 UTC (rev 6353)
@@ -38,6 +38,7 @@
 #include "handle_exceptions.hpp"
 #include "input.hpp"
 #include "ledgervalues.hpp"
+#include "miscellany.hpp"               // lmi_array_size()
 #include "multiple_cell_document.hpp"
 #include "path_utility.hpp"             // fs::path inserter
 #include "platform_dependent.hpp"       // access()
@@ -69,7 +70,7 @@
         {
         Timer timer;
         multiple_cell_document doc(file_path.string());
-        assert_consistent_run_order(doc.case_parms()[0], doc.cell_parms());
+        test_census_consensus(emission_, doc.case_parms()[0], 
doc.cell_parms());
         seconds_for_input_ = timer.stop().elapsed_seconds();
         return operator()(file_path, doc.cell_parms());
         }
@@ -236,6 +237,8 @@
     return user_default;
 }
 
+namespace
+{
 /// Throw if run order for any cell does not match case default.
 ///
 /// If lmi had case-only input fields, run order would be one of them.
@@ -264,3 +267,67 @@
         }
 }
 
+void assert_okay_to_run_group_quote
+    (Input              const& case_default
+    ,std::vector<Input> const& cells
+    )
+{
+    // There is a surjective mapping of the input fields listed here
+    // onto the members of class LedgerInvariant that are used by
+    // fill_global_report_data() in the group quote code. Whenever
+    // that function changes, this list must be maintained to conserve
+    // this relation.
+    //
+    // The "ProductName" field uniquely determines all ledger values
+    // taken from class product_data, so it maps onto them.
+    static char const*const fields[] =
+        {"ProductName"
+        ,"CorporationName"
+        ,"AgentName"
+        ,"CorporationPaymentMode"
+        ,"StateOfJurisdiction"
+        ,"EffectiveDate"
+        ,"Comments"
+        };
+    static std::size_t const n = lmi_array_size(fields);
+
+    typedef std::vector<Input>::size_type svst;
+    for(svst i = 0; i != cells.size(); ++i)
+        {
+        Input const& cell = cells[i];
+        for(std::size_t j = 0; j != n; ++j)
+            {
+            char const*const field = fields[j];
+            if(case_default[field] != cell[field])
+                {
+                fatal_error()
+                    << "Input field '"
+                    << field
+                    << "': value in cell number "
+                    << 1 + i
+                    << " ("
+                    << cell[field]
+                    << ") differs from case default ("
+                    << case_default[field]
+                    << "). Make them the same before running a group quote."
+                    << LMI_FLUSH
+                    ;
+                }
+            }
+        }
+}
+} // Unnamed namespace.
+
+void test_census_consensus
+    (mcenum_emission           emission
+    ,Input              const& case_default
+    ,std::vector<Input> const& cells
+    )
+{
+    assert_consistent_run_order(case_default, cells);
+    if(emission & mce_emit_group_quote)
+        {
+        assert_okay_to_run_group_quote(case_default, cells);
+        }
+}
+

Modified: lmi/trunk/illustrator.hpp
===================================================================
--- lmi/trunk/illustrator.hpp   2015-10-11 22:19:24 UTC (rev 6352)
+++ lmi/trunk/illustrator.hpp   2015-10-15 14:01:39 UTC (rev 6353)
@@ -26,7 +26,7 @@
 
 #include "config.hpp"
 
-#include "mc_enum_type_enums.hpp" // enum mcenum_emission
+#include "mc_enum_type_enums.hpp"       // enum mcenum_emission
 #include "obstruct_slicing.hpp"
 #include "so_attributes.hpp"
 
@@ -73,8 +73,11 @@
 
 Input const& LMI_SO default_cell();
 
-void LMI_SO assert_consistent_run_order
-    (Input              const& case_default
+/// Test whether census is consistent wrt emission type; throw if not.
+
+void LMI_SO test_census_consensus
+    (mcenum_emission           emission
+    ,Input              const& case_default
     ,std::vector<Input> const& cells
     );
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]