lmi
[Top][All Lists]
Advanced

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

Re: [lmi] Group quotes, part deux


From: Greg Chicares
Subject: Re: [lmi] Group quotes, part deux
Date: Fri, 20 May 2016 01:34:22 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Icedove/38.6.0

On 2016-05-20 00:54, Greg Chicares wrote:
> On 2016-05-20 00:18, Vadim Zeitlin wrote:
[...]
> In a different case, I'm seeing "$inf". I don't yet know why it's an
> infinity rather than a NaN, though I'll look into that.

1.0 / 0.0 is inf
0.0 / 0.0 is NaN

> In this
> particular test case, "additional" premium is present, but there is
> no "supplemental" specified amount, and--as a special exception--the
> "average" here should be "additional" premium divided by "basic"
> specified amount.

Here's something that works well enough to share for discussion
(but I won't rush to commit it). In a comment, I pose a question
addressed to you:

Index: group_quote_pdf_gen_wx.cpp
===================================================================
--- group_quote_pdf_gen_wx.cpp(revision 6609)
+++ group_quote_pdf_gen_wx.cpp(working copy)
@@ -1347,18 +1347,41 @@
         // Only premium columns have averages, but we must output something for
         // all cells to ensure that we use homogeneous background.
         std::string average_text;
+        double dividend = 0.0;
+        double divisor = 0.0;
         switch(col)
             {
             case e_col_basic_premium:
-            case e_col_additional_premium:
+                {
+                dividend = totals_.total(e_col_basic_premium);
+                divisor  = totals_.total(e_col_basic_face_amount);
+                }
+                break;
             case e_col_total_premium:
-                // We can rely on the face amount column corresponding to this
-                // premium just preceding it because the way we display the
-                // averages wouldn't make sense otherwise.
-                double const average = 
1000*totals_.total(col)/totals_.total(col - 1);
-                average_text = '$' + ledger_format(average, f);
+                {
+                dividend = totals_.total(e_col_total_premium);
+                divisor  = totals_.total(e_col_total_face_amount);
+                }
                 break;
+            case e_col_additional_premium:
+                {
+                dividend = totals_.total(e_col_additional_premium);
+                divisor  = totals_.total(e_col_supplemental_face_amount);
+                if(0.0 == divisor)
+                    {
+                    divisor = totals_.total(e_col_basic_face_amount);
+                    }
+                }
+                break;
             }
+        if(0.0 != divisor)
+            {
+            double const average = 1000.0 * dividend / divisor;
+            average_text = '$' + ledger_format(average, f);
+            }
+        // Vadim--Suppose (0.0 != divisor). Then average_text is an
+        // empty string. Does that satisfy "we must output something"
+        // above?

         table_gen.output_highlighted_cell(col, y_next, average_text);
         }




reply via email to

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