lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] odd/string_db ef5db17: Allow product lingo to vary b


From: Greg Chicares
Subject: [lmi-commits] [lmi] odd/string_db ef5db17: Allow product lingo to vary by state, gender, and so on
Date: Mon, 21 Sep 2020 21:30:20 -0400 (EDT)

branch: odd/string_db
commit ef5db171c206579156c8ff80f1a2a4a928b60d96
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>

    Allow product lingo to vary by state, gender, and so on
    
    See the commentary and simple example in 'ledger_invariant_init.cpp'.
    Changed other files slightly to make that example build.
---
 dbdict.cpp                |  2 ++
 dbdict.hpp                |  1 +
 dbnames.hpp               |  4 +++
 dbnames.xpp               |  2 ++
 ledger_invariant_init.cpp | 74 +++++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 83 insertions(+)

diff --git a/dbdict.cpp b/dbdict.cpp
index e8b0a5b..a1d9822 100644
--- a/dbdict.cpp
+++ b/dbdict.cpp
@@ -419,6 +419,7 @@ void DBDictionary::ascribe_members()
     ascribe("PartialMortTable"    , &DBDictionary::PartialMortTable    );
     ascribe("UsePolicyFormAlt"    , &DBDictionary::UsePolicyFormAlt    );
     ascribe("AllowGroupQuote"     , &DBDictionary::AllowGroupQuote     );
+    ascribe("L_PolicyForm"        , &DBDictionary::L_PolicyForm        );
     ascribe("WeightClass"         , &DBDictionary::WeightClass         );
     ascribe("WeightGender"        , &DBDictionary::WeightGender        );
     ascribe("WeightSmoking"       , &DBDictionary::WeightSmoking       );
@@ -927,6 +928,7 @@ sample::sample()
     alt_form[mce_s_KY] = true;
     Add({DB_UsePolicyFormAlt, premium_tax_dimensions, alt_form});
     Add({DB_AllowGroupQuote     , true});
+    Add({DB_L_PolicyForm        , 1});
 }
 
 sample2finra::sample2finra()
diff --git a/dbdict.hpp b/dbdict.hpp
index cb0a885..fce7c28 100644
--- a/dbdict.hpp
+++ b/dbdict.hpp
@@ -403,6 +403,7 @@ class LMI_SO DBDictionary
     database_entity PartialMortTable    ;
     database_entity UsePolicyFormAlt    ;
     database_entity AllowGroupQuote     ;
+    database_entity L_PolicyForm        ;
     database_entity WeightClass         ;
     database_entity WeightGender        ;
     database_entity WeightSmoking       ;
diff --git a/dbnames.hpp b/dbnames.hpp
index f0f0a5a..a6ecef2 100644
--- a/dbnames.hpp
+++ b/dbnames.hpp
@@ -527,6 +527,10 @@ enum e_database_key
         ,DB_UsePolicyFormAlt
         ,DB_AllowGroupQuote
 
+    ,DB_Topic_Lingo
+
+        ,DB_L_PolicyForm
+
     ,DB_Topic_Weights
 
         ,DB_WeightClass
diff --git a/dbnames.xpp b/dbnames.xpp
index aa113ab..c5e5092 100644
--- a/dbnames.xpp
+++ b/dbnames.xpp
@@ -356,6 +356,8 @@
 {DB_PartialMortTable,DB_Topic_Miscellanea,"PartialMortTable","Partial 
mortality table (index in mortality table database)",}, \
 {DB_UsePolicyFormAlt,DB_Topic_Miscellanea,"UsePolicyFormAlt","Use alternative 
policy-form name: 0=no, 1=yes",}, \
 {DB_AllowGroupQuote,DB_Topic_Miscellanea,"AllowGroupQuote","Allow group 
premium quotes: 0=no, 1=yes",}, \
+{DB_Topic_Lingo,DB_FIRST,"Lingo","Substitutable text strings for report 
generation",}, \
+{DB_L_PolicyForm,DB_Topic_Lingo,"L_PolicyForm","Policy form: string index",}, \
 {DB_Topic_Weights,DB_FIRST,"Weights","Weights for profit analysis cells [not 
yet implemented]",}, \
 {DB_WeightClass,DB_Topic_Weights,"WeightClass","Weight by underwriting class 
[not yet implemented]",}, \
 {DB_WeightGender,DB_Topic_Weights,"WeightGender","Weight by gender [not yet 
implemented]",}, \
diff --git a/ledger_invariant_init.cpp b/ledger_invariant_init.cpp
index a174184..e1fbb98 100644
--- a/ledger_invariant_init.cpp
+++ b/ledger_invariant_init.cpp
@@ -324,6 +324,80 @@ void LedgerInvariant::Init(BasicValues const* b)
 
         // Strings.
 
+// The next couple hundred "p.datum" lines will be replaced.
+//
+// Old way: store strings in class product_data. That works, but
+// strings are one-dimensional--not like the (up to) seven-dimensional
+// class database_entity used by class DBDictionary. A database_entity
+// is a 0- to 7-dimensional scalar of type 'double' (which might hold
+// actual floating point values, or integral values).
+//
+// Alternative not considered: devise a "string_database_entity" that
+// can hold a 0- to 7-dimensional string; then radically redesign
+// class product_data to hold that new type instead of plain strings.
+// Too much labor. Too much duplication.
+//
+// Crucial insight: Actuarial tables are non-dimensional per se, but
+// lmi treats them as multidimensional by storing their table numbers
+// in objects of class database_entity, e.g.:
+//
+//  // 1983 GAM; unisex=male because no unisex table was published.
+//  double T83Gam[3] = {825, 826, 826,}; // f, m, u
+//  Add({DB_PartialMortTable, e_number_of_axes, dims311, T83Gam});
+//
+// Something very similar can certainly be done for strings.
+//
+// New way: establish a compendium of product-specific strings, and
+// store indexes into that compendium in database_entity objects.
+// The only question is what form that compendium should take.
+// Below is an expedient answer; what would be better? And is there
+// a good way to give each string a descriptive name? E.g., some
+// products use this (no proprietiary content)...
+//
+// [proprietary 'my_prod.cpp']
+// static std::string const S_GroupQuoteStateVariations =
+//   "Product may not be available in all states. State variations may apply."
+//   ;
+// item("GroupQuoteStateVariations")  = S_GroupQuoteStateVariations;
+//
+// ...where each product-file entity already has a name, and its
+// string values are named with an "S_" prefix, and if necessary
+// a suffix indicating specialization--so a special disclaimer in
+// TX might use a string 'S_GroupQuoteStateVariations_TX'. Is there
+// really any better way to do that than the way shown below, i.e.,
+// a map of strings looked up by enumerators, where an enumerator
+// like 'e_group_quote_state_variations_TX' would take the place of
+// the "S_"-prefixed string above?
+
+// Tiny example:
+// 'sample' products have this in 'product_data.cpp':
+//  item("PolicyForm")                 = glossed_string("UL32768-NY");
+//  item("PolicyFormAlternative")      = glossed_string("UL32768-X");
+// and this in 'dbdict.cpp':
+//  // Use alternative policy form name in states beginning with "K".
+//  std::vector<double> alt_form(e_max_dim_state);
+//  alt_form[mce_s_KS] = true;
+//  alt_form[mce_s_KY] = true;
+//  Add({DB_UsePolicyFormAlt, premium_tax_dimensions, alt_form});
+// That's the old way:
+//   - '.policy': contains every unique string (two in this case)
+//   - '.database': indicates which of those strings to choose
+//
+// Here's the new way:
+
+        enum e_xyzzy
+            {e_policy_form
+            ,e_policy_form_KS_KY
+            };
+        static std::map<e_xyzzy,std::string> xyzzy
+            {{e_policy_form, "UL32768-NY"}
+            ,{e_policy_form_KS_KY, "UL32768-X"}
+            };
+        auto policy_form = b->database().query<e_xyzzy>(DB_L_PolicyForm);
+        PolicyForm = xyzzy[policy_form];
+// ...and that can replace the "p.datum" line immediately following,
+// as well as the assignment of local 'alt_form' above.
+
         PolicyForm = p.datum(alt_form ? "PolicyFormAlternative" : 
"PolicyForm");
         PolicyMktgName             = p.datum("PolicyMktgName"                 
);
         PolicyLegalName            = p.datum("PolicyLegalName"                
);



reply via email to

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