lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [5054] Move old state determination out of class product_d


From: Greg Chicares
Subject: [lmi-commits] [5054] Move old state determination out of class product_database
Date: Fri, 23 Jul 2010 18:08:15 +0000

Revision: 5054
          http://svn.sv.gnu.org/viewvc/?view=rev&root=lmi&revision=5054
Author:   chicares
Date:     2010-07-23 18:08:15 +0000 (Fri, 23 Jul 2010)
Log Message:
-----------
Move old state determination out of class product_database

Modified Paths:
--------------
    lmi/trunk/ChangeLog
    lmi/trunk/database.cpp
    lmi/trunk/input_xml_io.cpp

Modified: lmi/trunk/ChangeLog
===================================================================
--- lmi/trunk/ChangeLog 2010-07-23 10:29:11 UTC (rev 5053)
+++ lmi/trunk/ChangeLog 2010-07-23 18:08:15 UTC (rev 5054)
@@ -26469,3 +26469,10 @@
   loads_test.cpp
 Move premium-tax database lookup out of class Loads.
 
+20100723T1808Z <address@hidden> [685]
+
+  database.cpp
+  input_xml_io.cpp
+Move old state determination out of class product_database, inducing a
+regression in system testing that must be analyzed.
+

Modified: lmi/trunk/database.cpp
===================================================================
--- lmi/trunk/database.cpp      2010-07-23 10:29:11 UTC (rev 5053)
+++ lmi/trunk/database.cpp      2010-07-23 18:08:15 UTC (rev 5054)
@@ -28,9 +28,7 @@
 
 #include "database.hpp"
 
-#include "alert.hpp"
 #include "assert_lmi.hpp"
-#include "contains.hpp"
 #include "data_directory.hpp"
 #include "dbdict.hpp"
 #include "dbvalue.hpp"
@@ -73,24 +71,7 @@
 
 /// Construct from normal illustration input.
 ///
-/// For the nonce, this ctor determines "state of jurisdiction"
-/// dynamically, and other code uses that state for multiple purposes.
-/// That is a mistake--two states are required:
-///   - FilingApprovalState: the state that must approve a policy-form
-///     filing (whether affirmatively or by deemer) before a contract
-///     can be written; and
-///   - PremiumTaxState: the state to which premium tax must be paid,
-///     which is crucial for products that pass premium tax through as
-///     a load.
-/// Those two states can differ, e.g. on cases with more than five
-/// hundred lives with a common (employer) issue state: the employer's
-/// state approves the policy form, but premium tax follows employee
-/// residence. See:
-///   http://www.naic.org/documents/frs_summit_presentations_03.pdf
-///   
http://www.naic.org/documents/committees_e_app_blanks_adopted_2007-42BWG_Modified.pdf
-///
-/// Soon, both states will be input fields, and these members will be
-/// expunged:
+/// Soon, these members will be expunged:
 ///   GetStateOfJurisdiction()
 ///   Gender
 ///   Class
@@ -98,8 +79,6 @@
 ///   IssueAge
 ///   UWBasis
 ///   State
-/// Database entity DB_PremTaxState will become obsolete, but must be
-/// retained (with a different name) for backward compatibility.
 
 product_database::product_database(yare_input const& input)
 {
@@ -108,7 +87,7 @@
     Smoker      = input.Smoking;
     IssueAge    = input.IssueAge;
     UWBasis     = input.GroupUnderwritingType;
-    State       = mce_s_CT; // Dummy initialization.
+    State       = input.StateOfJurisdiction;
 
     if(is_antediluvian_fork())
         {
@@ -120,44 +99,6 @@
         DBDictionary::instance().Init(AddDataDir(filename));
         }
     initialize();
-
-    // State of jurisdiction must not depend on itself.
-    if(varies_by_state(DB_PremTaxState))
-        {
-        fatal_error()
-            << "Database invalid: circular dependency."
-            << " State of jurisdiction depends on itself."
-            << LMI_FLUSH
-            ;
-        }
-
-    bool swap = contains(input.Comments, "idiosyncrasy_swap_old_tax_state");
-    switch(static_cast<int>(Query(DB_PremTaxState)))
-        {
-        case oe_ee_state:
-            {
-            State = swap ? input.CorporationState : input.State;
-            }
-            break;
-        case oe_er_state:
-            {
-            State = swap ? input.State : input.CorporationState;
-            }
-            break;
-        default:
-            {
-            fatal_error()
-                << "Cannot determine state of jurisdiction."
-                << LMI_FLUSH
-                ;
-            }
-            break;
-        }
-
-    // It may seem excessive to do this when only 'State' has changed,
-    // but it'll become unnecessary when we handle state of jurisdiction
-    // as an input field instead of trying to determine it here.
-    index_ = database_index(Gender, Class, Smoker, IssueAge, UWBasis, State);
 }
 
 product_database::~product_database()

Modified: lmi/trunk/input_xml_io.cpp
===================================================================
--- lmi/trunk/input_xml_io.cpp  2010-07-23 10:29:11 UTC (rev 5053)
+++ lmi/trunk/input_xml_io.cpp  2010-07-23 18:08:15 UTC (rev 5054)
@@ -32,9 +32,11 @@
 #include "alert.hpp"
 #include "calendar_date.hpp"
 #include "contains.hpp"
+#include "database.hpp"
 #include "global_settings.hpp"
 #include "map_lookup.hpp"
 #include "miscellany.hpp" // lmi_array_size()
+#include "oecumenic_enumerations.hpp"
 
 #include <algorithm>      // std::min()
 #include <stdexcept>
@@ -90,6 +92,13 @@
     return s;
 }
 
+/// See this function's general documentation in the base class.
+///
+/// No xml file written by lmi ever contained 'FilingApprovalState'.
+/// It appears only in certain admin-system extracts, as an alias for
+/// 'StateOfJurisdiction'. That alias was chosen to favor unambiguity
+/// over clarity.
+
 bool Input::is_detritus(std::string const& s) const
 {
     static std::string const a[] =
@@ -101,6 +110,7 @@
         ,"CorporationPremiumTableNumber" // Never implemented.
         ,"CorporationTaxpayerId"         // Would violate privacy.
         ,"CurrentCoiGrading"             // Withdrawn.
+        ,"FilingApprovalState"           // Alias for 'StateOfJurisdiction'.
         ,"FirstName"                     // Single name instead.
         ,"InforceDcvDeathBenefit"        // Misbegotten.
         ,"InforceExperienceReserve"      // Renamed before implementation.
@@ -368,10 +378,79 @@
             );
         }
 
+    // One state governs everything except premium tax, which may be
+    // paid to a different state, e.g. on cases with more than five
+    // hundred lives with a common (employer) issue state; see:
+    //   http://www.naic.org/documents/frs_summit_presentations_03.pdf
+    //   
http://www.naic.org/documents/committees_e_app_blanks_adopted_2007-42BWG_Modified.pdf
+    // Prior to version 6, a single state was used for all purposes,
+    // and it was determined as either employee or employer state,
+    // depending on the value of DB_PremTaxState. The determination is
+    // complex (what if a case was issued with 498 lives and then
+    // grew to 502?), and starting with version 6 both states are
+    // input fields.
+    //
+    // 'FilingApprovalState' and 'PremiumTaxState' were unknown before
+    // version 6, and would not ordinarily occur in older versions.
+    // However, certain admin-system extracts that are always marked
+    // as version 5 have been modified to add these two fields.
     if(file_version < 6)
         {
-        LMI_ASSERT(contains(residuary_names, "PremiumTaxState"));
-        PremiumTaxState = StateOfJurisdiction;
+        bool const b0 = contains(detritus_map, "FilingApprovalState");
+        bool const b1 = !contains(residuary_names, "PremiumTaxState");
+        if(b0 || b1)
+            {
+            LMI_ASSERT(b0 && b1 && 5 == file_version);
+            StateOfJurisdiction = map_lookup(detritus_map, 
"FilingApprovalState");
+            }
+        else
+            {
+            product_database db
+                (ProductName          .value()
+                ,Gender               .value()
+                ,UnderwritingClass    .value()
+                ,Smoking              .value()
+                ,IssueAge             .value()
+                ,GroupUnderwritingType.value()
+                ,mce_s_CT // Dummy initialization.
+                );
+
+            // Deemed state must not depend on itself.
+            if(db.varies_by_state(DB_PremTaxState))
+                {
+                fatal_error()
+                    << "Database invalid: circular dependency."
+                    << " State of jurisdiction depends on itself."
+                    << LMI_FLUSH
+                    ;
+                }
+
+            bool swap = contains(Comments.value(), 
"idiosyncrasy_swap_old_tax_state");
+            mce_state state;
+            switch(static_cast<int>(db.Query(DB_PremTaxState)))
+                {
+                case oe_ee_state:
+                    {
+                    state = swap ? CorporationState : State;
+                    }
+                    break;
+                case oe_er_state:
+                    {
+                    state = swap ? State : CorporationState;
+                    }
+                    break;
+                default:
+                    {
+                    fatal_error()
+                        << "Cannot determine state of jurisdiction."
+                        << LMI_FLUSH
+                        ;
+                    }
+                    break;
+                }
+            StateOfJurisdiction = state;
+            PremiumTaxState     = state;
+            }
         }
 }
 




reply via email to

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