lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [5184] Move free functions


From: Greg Chicares
Subject: [lmi-commits] [5184] Move free functions
Date: Sat, 28 May 2011 13:27:18 +0000

Revision: 5184
          http://svn.sv.gnu.org/viewvc/?view=rev&root=lmi&revision=5184
Author:   chicares
Date:     2011-05-28 13:27:18 +0000 (Sat, 28 May 2011)
Log Message:
-----------
Move free functions

Modified Paths:
--------------
    lmi/trunk/Makefile.am
    lmi/trunk/basic_values.hpp
    lmi/trunk/ihs_basicval.cpp
    lmi/trunk/mec_server.cpp
    lmi/trunk/objects.make
    lmi/trunk/premium_tax.cpp
    lmi/trunk/premium_tax.hpp

Modified: lmi/trunk/Makefile.am
===================================================================
--- lmi/trunk/Makefile.am       2011-05-28 11:29:44 UTC (rev 5183)
+++ lmi/trunk/Makefile.am       2011-05-28 13:27:18 UTC (rev 5184)
@@ -349,6 +349,7 @@
     mec_xml_document.cpp \
     mortality_rates_fetch.cpp \
     preferences_model.cpp \
+    premium_tax.cpp \
     product_data.cpp \
     rounding_rules.cpp \
     stratified_algorithms.cpp \
@@ -655,7 +656,7 @@
   ihs_irc7702a.cpp \
   irc7702a_test.cpp \
   stratified_algorithms.cpp
-test_irc7702a_CXXFLAGS = $(AM_CXXFLAGS)
+test_irc7702a_CXXFLAGS = $(AM_CXXFLAGS) $(XMLWRAPP_CFLAGS)
 test_irc7702a_LDADD = \
   liblmi.la \
   $(BOOST_LIBS) \
@@ -754,14 +755,29 @@
 
 test_premium_tax_SOURCES = \
   $(common_test_objects) \
+  data_directory.cpp \
+  database.cpp \
+  datum_base.cpp \
+  dbdict.cpp \
+  dbnames.cpp \
+  dbvalue.cpp \
+  facets.cpp \
   global_settings.cpp \
+  lmi.cpp \
+  mc_enum.cpp \
+  mc_enum_types.cpp \
+  mc_enum_types_aux.cpp \
   miscellany.cpp \
   path_utility.cpp \
   premium_tax.cpp \
-  premium_tax_test.cpp
-test_premium_tax_CXXFLAGS = $(AM_CXXFLAGS)
+  premium_tax_test.cpp \
+  product_data.cpp \
+  stratified_charges.cpp \
+  xml_lmi.cpp
+test_premium_tax_CXXFLAGS = $(AM_CXXFLAGS) $(XMLWRAPP_CFLAGS)
 test_premium_tax_LDADD = \
-  $(BOOST_LIBS)
+  $(BOOST_LIBS) \
+  $(XMLWRAPP_LIBS)
 
 test_print_matrix_SOURCES = \
   $(common_test_objects) \
@@ -886,7 +902,7 @@
   facets.cpp \
   xml_lmi.cpp \
   xml_serialize_test.cpp
-test_xml_serialize_CXXFLAGS = $(AM_CXXFLAGS)
+test_xml_serialize_CXXFLAGS = $(AM_CXXFLAGS) $(XMLWRAPP_CFLAGS)
 test_xml_serialize_LDADD = \
   $(XMLWRAPP_LIBS)
 

Modified: lmi/trunk/basic_values.hpp
===================================================================
--- lmi/trunk/basic_values.hpp  2011-05-28 11:29:44 UTC (rev 5183)
+++ lmi/trunk/basic_values.hpp  2011-05-28 13:27:18 UTC (rev 5184)
@@ -533,19 +533,6 @@
     return IsSubjectToIllustrationReg_;
 }
 
-bool premium_tax_is_retaliatory
-    (mcenum_state premium_tax_state
-    ,mcenum_state state_of_domicile
-    );
-
-double lowest_premium_tax_load
-    (mcenum_state              premium_tax_state
-    ,mcenum_state              state_of_domicile
-    ,bool                      amortize_premium_load
-    ,product_database   const& db
-    ,stratified_charges const& stratified
-    );
-
 // TODO ?? Use a configuration file instead. These deprecated
 // functions are used only by the antediluvian branch.
 char const* CurrentTableFile();

Modified: lmi/trunk/ihs_basicval.cpp
===================================================================
--- lmi/trunk/ihs_basicval.cpp  2011-05-28 11:29:44 UTC (rev 5183)
+++ lmi/trunk/ihs_basicval.cpp  2011-05-28 13:27:18 UTC (rev 5184)
@@ -52,6 +52,7 @@
 #include "miscellany.hpp"        // ios_out_trunc_binary()
 #include "mortality_rates.hpp"
 #include "outlay.hpp"
+#include "premium_tax.hpp"
 #include "product_data.hpp"
 #include "rounding_rules.hpp"
 #include "stratified_charges.hpp"
@@ -862,122 +863,6 @@
     TestPremiumTaxLoadConsistency();
 }
 
-/// Determine whether premium tax is retaliatory.
-///
-/// Here's a general discussion:
-///   
http://leg2.state.va.us/dls/h&sdocs.nsf/fc86c2b17a1cf388852570f9006f1299/461afa310d4d3d528525646500562282/$FILE/HD78_1997.pdf
-///
-/// Premium tax is retaliatory in most states. Exceptions:
-///   - MA, MN, NY, and RI are mutually nonretaliatory.
-///   - HI never retaliates; neither does fictitious state XX.
-///   - AK and SD retaliate only on the bottom tier; this is best
-///     implemented by adjusting that tier's rate and treating them
-///     as otherwise nonretaliatory.
-
-bool premium_tax_is_retaliatory
-    (mcenum_state premium_tax_state
-    ,mcenum_state state_of_domicile
-    )
-{
-    static int const n = 4;
-    static mcenum_state const d[n] = {mce_s_MA, mce_s_MN, mce_s_NY, mce_s_RI};
-    static std::vector<mcenum_state> const reciprocal_nonretaliation_states(d, 
d + n);
-    bool const reciprocally_nonretaliatory =
-            contains(reciprocal_nonretaliation_states, state_of_domicile)
-        &&  contains(reciprocal_nonretaliation_states, premium_tax_state)
-        ;
-    bool const nonretaliatory =
-            reciprocally_nonretaliatory
-        ||  mce_s_HI == premium_tax_state
-        ||  mce_s_XX == premium_tax_state
-        ||  mce_s_AK == premium_tax_state
-        ||  mce_s_SD == premium_tax_state
-        ;
-    return !nonretaliatory;
-}
-
-/// Lowest premium-tax load, for 7702 and 7702A purposes.
-
-double lowest_premium_tax_load
-    (mcenum_state              premium_tax_state
-    ,mcenum_state              state_of_domicile
-    ,bool                      amortize_premium_load
-    ,product_database   const& db
-    ,stratified_charges const& stratified
-    )
-{
-    // TRICKY !! Here, we use 'DB_PremTaxLoad', not 'DB_PremTaxRate',
-    // to determine the lowest premium-tax load. Premium-tax loads
-    // (charged by the insurer to the contract) and rates (charged by
-    // the state to the insurer) really shouldn't be mixed. The
-    // intention is to support products that pass actual premium tax
-    // through as a load, taking into account retaliation and tiered
-    // premium-tax rates.
-    //
-    // While a more complicated model would be more aesthetically
-    // satisfying, this gives the right answer in practice for the
-    // two cases we believe will arise in practice. In the first case,
-    // premium-tax load doesn't vary by state--perhaps a flat load
-    // such as two percent might be used, or maybe zero percent with
-    // premium-tax expense covered elsewhere in pricing--and tiering
-    // is ignored, so this implementation just returns the flat load.
-    // In the second case, the exact premium tax is passed through,
-    // so the tax rate equals the tax load.
-
-    double z = 0.0;
-    if(amortize_premium_load)
-        {
-        return z;
-        }
-
-    database_index index = db.index().state(premium_tax_state);
-    z = db.Query(DB_PremTaxLoad, index);
-
-    if(premium_tax_is_retaliatory(premium_tax_state, state_of_domicile))
-        {
-        index = db.index().state(state_of_domicile);
-        z = std::max(z, db.Query(DB_PremTaxLoad, index));
-        }
-
-    if(!db.varies_by_state(DB_PremTaxLoad))
-        {
-        return z;
-        }
-
-    // If premium-tax load varies by state, we're assuming that
-    // it equals premium-tax rate--i.e. that premium tax is passed
-    // through exactly--and that therefore tiered tax rates determine
-    // loads where applicable and implemented.
-    if(!db.are_equivalent(DB_PremTaxLoad, DB_PremTaxRate))
-        {
-        fatal_error()
-            << "Premium-tax load varies by state, but differs"
-            << " from premium-tax rates. Probably the database"
-            << " is incorrect.\n"
-            << LMI_FLUSH
-            ;
-        }
-
-    if(stratified.premium_tax_is_tiered(premium_tax_state))
-        {
-        if(0.0 != z)
-            {
-            fatal_error()
-                << "Premium-tax load is tiered in state "
-                << mc_str(premium_tax_state)
-                << ", but the product database specifies a scalar load of "
-                << z
-                << " instead of zero as expected. Probably the database"
-                << " is incorrect."
-                << LMI_FLUSH
-                ;
-            }
-        z = stratified.minimum_tiered_premium_tax_rate(premium_tax_state);
-        }
-
-    return z;
-}
-
 /// Test consistency of premium-tax loads.
 ///
 /// In particular, if the tiered premium-tax load isn't zero, then the

Modified: lmi/trunk/mec_server.cpp
===================================================================
--- lmi/trunk/mec_server.cpp    2011-05-28 11:29:44 UTC (rev 5183)
+++ lmi/trunk/mec_server.cpp    2011-05-28 13:27:18 UTC (rev 5184)
@@ -31,7 +31,6 @@
 #include "actuarial_table.hpp"
 #include "alert.hpp"
 #include "assert_lmi.hpp"
-#include "basic_values.hpp"          // lowest_premium_tax_load()
 #include "commutation_functions.hpp"
 #include "configurable_settings.hpp"
 #include "contains.hpp"
@@ -48,6 +47,7 @@
 #include "miscellany.hpp"            // ios_out_trunc_binary()
 #include "oecumenic_enumerations.hpp"
 #include "path_utility.hpp"          // fs::path inserter
+#include "premium_tax.hpp"           // lowest_premium_tax_load()
 #include "product_data.hpp"
 #include "round_to.hpp"
 #include "stratified_algorithms.hpp" // TieredGrossToNet()

Modified: lmi/trunk/objects.make
===================================================================
--- lmi/trunk/objects.make      2011-05-28 11:29:44 UTC (rev 5183)
+++ lmi/trunk/objects.make      2011-05-28 13:27:18 UTC (rev 5184)
@@ -288,6 +288,7 @@
   mec_xml_document.o \
   mortality_rates_fetch.o \
   preferences_model.o \
+  premium_tax.o \
   product_data.o \
   rounding_rules.o \
   stratified_algorithms.o \
@@ -410,6 +411,7 @@
   null_stream.o \
   outlay.o \
   path_utility.o \
+  premium_tax.o \
   product_data.o \
   product_names.o \
   rounding_rules.o \
@@ -795,11 +797,26 @@
 premium_tax_test$(EXEEXT): \
   $(boost_filesystem_objects) \
   $(common_test_objects) \
+  $(xmlwrapp_objects) \
+  data_directory.o \
+  database.o \
+  datum_base.o \
+  dbdict.o \
+  dbnames.o \
+  dbvalue.o \
+  facets.o \
   global_settings.o \
+  lmi.o \
+  mc_enum.o \
+  mc_enum_types.o \
+  mc_enum_types_aux.o \
   miscellany.o \
   path_utility.o \
   premium_tax.o \
   premium_tax_test.o \
+  product_data.o \
+  stratified_charges.o \
+  xml_lmi.o \
 
 print_matrix_test$(EXEEXT): \
   $(common_test_objects) \

Modified: lmi/trunk/premium_tax.cpp
===================================================================
--- lmi/trunk/premium_tax.cpp   2011-05-28 11:29:44 UTC (rev 5183)
+++ lmi/trunk/premium_tax.cpp   2011-05-28 13:27:18 UTC (rev 5184)
@@ -28,6 +28,12 @@
 
 #include "premium_tax.hpp"
 
+#include "alert.hpp"
+#include "contains.hpp"
+#include "database.hpp"
+#include "mc_enum_types_aux.hpp" // mc_str()
+#include "stratified_charges.hpp"
+
 premium_tax::premium_tax
     (mcenum_state              premium_tax_state
     ,mcenum_state              state_of_domicile
@@ -46,3 +52,119 @@
 premium_tax::~premium_tax()
 {}
 
+/// Determine whether premium tax is retaliatory.
+///
+/// Here's a general discussion:
+///   
http://leg2.state.va.us/dls/h&sdocs.nsf/fc86c2b17a1cf388852570f9006f1299/461afa310d4d3d528525646500562282/$FILE/HD78_1997.pdf
+///
+/// Premium tax is retaliatory in most states. Exceptions:
+///   - MA, MN, NY, and RI are mutually nonretaliatory.
+///   - HI never retaliates; neither does fictitious state XX.
+///   - AK and SD retaliate only on the bottom tier; this is best
+///     implemented by adjusting that tier's rate and treating them
+///     as otherwise nonretaliatory.
+
+bool premium_tax_is_retaliatory
+    (mcenum_state premium_tax_state
+    ,mcenum_state state_of_domicile
+    )
+{
+    static int const n = 4;
+    static mcenum_state const d[n] = {mce_s_MA, mce_s_MN, mce_s_NY, mce_s_RI};
+    static std::vector<mcenum_state> const reciprocal_nonretaliation_states(d, 
d + n);
+    bool const reciprocally_nonretaliatory =
+            contains(reciprocal_nonretaliation_states, state_of_domicile)
+        &&  contains(reciprocal_nonretaliation_states, premium_tax_state)
+        ;
+    bool const nonretaliatory =
+            reciprocally_nonretaliatory
+        ||  mce_s_HI == premium_tax_state
+        ||  mce_s_XX == premium_tax_state
+        ||  mce_s_AK == premium_tax_state
+        ||  mce_s_SD == premium_tax_state
+        ;
+    return !nonretaliatory;
+}
+
+/// Lowest premium-tax load, for 7702 and 7702A purposes.
+
+double lowest_premium_tax_load
+    (mcenum_state              premium_tax_state
+    ,mcenum_state              state_of_domicile
+    ,bool                      amortize_premium_load
+    ,product_database   const& db
+    ,stratified_charges const& stratified
+    )
+{
+    // TRICKY !! Here, we use 'DB_PremTaxLoad', not 'DB_PremTaxRate',
+    // to determine the lowest premium-tax load. Premium-tax loads
+    // (charged by the insurer to the contract) and rates (charged by
+    // the state to the insurer) really shouldn't be mixed. The
+    // intention is to support products that pass actual premium tax
+    // through as a load, taking into account retaliation and tiered
+    // premium-tax rates.
+    //
+    // While a more complicated model would be more aesthetically
+    // satisfying, this gives the right answer in practice for the
+    // two cases we believe will arise in practice. In the first case,
+    // premium-tax load doesn't vary by state--perhaps a flat load
+    // such as two percent might be used, or maybe zero percent with
+    // premium-tax expense covered elsewhere in pricing--and tiering
+    // is ignored, so this implementation just returns the flat load.
+    // In the second case, the exact premium tax is passed through,
+    // so the tax rate equals the tax load.
+
+    double z = 0.0;
+    if(amortize_premium_load)
+        {
+        return z;
+        }
+
+    database_index index = db.index().state(premium_tax_state);
+    z = db.Query(DB_PremTaxLoad, index);
+
+    if(premium_tax_is_retaliatory(premium_tax_state, state_of_domicile))
+        {
+        index = db.index().state(state_of_domicile);
+        z = std::max(z, db.Query(DB_PremTaxLoad, index));
+        }
+
+    if(!db.varies_by_state(DB_PremTaxLoad))
+        {
+        return z;
+        }
+
+    // If premium-tax load varies by state, we're assuming that
+    // it equals premium-tax rate--i.e. that premium tax is passed
+    // through exactly--and that therefore tiered tax rates determine
+    // loads where applicable and implemented.
+    if(!db.are_equivalent(DB_PremTaxLoad, DB_PremTaxRate))
+        {
+        fatal_error()
+            << "Premium-tax load varies by state, but differs"
+            << " from premium-tax rates. Probably the database"
+            << " is incorrect.\n"
+            << LMI_FLUSH
+            ;
+        }
+
+    if(stratified.premium_tax_is_tiered(premium_tax_state))
+        {
+        if(0.0 != z)
+            {
+            fatal_error()
+                << "Premium-tax load is tiered in state "
+                << mc_str(premium_tax_state)
+                << ", but the product database specifies a scalar load of "
+                << z
+                << " instead of zero as expected. Probably the database"
+                << " is incorrect."
+                << LMI_FLUSH
+                ;
+            }
+        z = stratified.minimum_tiered_premium_tax_rate(premium_tax_state);
+        }
+
+    return z;
+}
+

Modified: lmi/trunk/premium_tax.hpp
===================================================================
--- lmi/trunk/premium_tax.hpp   2011-05-28 11:29:44 UTC (rev 5183)
+++ lmi/trunk/premium_tax.hpp   2011-05-28 13:27:18 UTC (rev 5184)
@@ -50,5 +50,18 @@
   private:
 };
 
+bool premium_tax_is_retaliatory
+    (mcenum_state premium_tax_state
+    ,mcenum_state state_of_domicile
+    );
+
+double lowest_premium_tax_load
+    (mcenum_state              premium_tax_state
+    ,mcenum_state              state_of_domicile
+    ,bool                      amortize_premium_load
+    ,product_database   const& db
+    ,stratified_charges const& stratified
+    );
+
 #endif // premium_tax_hpp
 




reply via email to

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