lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master 031070b 132/156: Implement supplemental repor


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 031070b 132/156: Implement supplemental report page for the regular illustrations
Date: Tue, 30 Jan 2018 17:22:31 -0500 (EST)

branch: master
commit 031070b4707607c6e96db2e85412567bddaf5fcb
Author: Vadim Zeitlin <address@hidden>
Commit: Vadim Zeitlin <address@hidden>

    Implement supplemental report page for the regular illustrations
    
    The columns vector is constructed dynamically using the supplemental
    report columns defined in the ledger itself for this report.
---
 ledger_pdf_generator_wx.cpp  | 53 ++++++++++++++++++++++++++++++++++++++++++++
 supplemental_report.mustache |  7 ++++++
 2 files changed, 60 insertions(+)

diff --git a/ledger_pdf_generator_wx.cpp b/ledger_pdf_generator_wx.cpp
index b72ad06..0898470 100644
--- a/ledger_pdf_generator_wx.cpp
+++ b/ledger_pdf_generator_wx.cpp
@@ -763,6 +763,9 @@ class pdf_illustration : protected html_interpolator
     virtual std::string get_lower_footer_template_name() const = 0;
 
   protected:
+    // Explicitly retrieve the base class.
+    html_interpolator const& get_interpolator() const {return *this;}
+
     // Helper for abbreviating a string to at most the given length (in bytes).
     static std::string abbreviate_if_necessary(std::string s, size_t len)
     {
@@ -1835,6 +1838,52 @@ class tabular_detail2_page : public 
page_with_tabular_report
     }
 };
 
+class supplemental_report : public page_with_tabular_report
+{
+  public:
+    explicit supplemental_report(html_interpolator const& interpolate_html)
+    {
+        constexpr std::size_t max_columns = 12;
+        std::string const empty_column_name("[none]");
+
+        for(std::size_t i = 0; i < max_columns; ++i)
+            {
+            auto name = 
interpolate_html.evaluate("SupplementalReportColumnsNames", i);
+            if(name != empty_column_name)
+                {
+                // We currently don't have the field width information for
+                // arbitrary fields, so use fixed width that should be
+                // sufficient for almost all of them.
+                columns_.emplace_back
+                    (illustration_table_column
+                        {std::move(name)
+                        
,interpolate_html.evaluate("SupplementalReportColumnsTitles", i)
+                        ,"999,999"
+                        }
+                    );
+                }
+            }
+    }
+
+  private:
+    std::string get_fixed_page_contents() const override
+    {
+        return "{{>supplemental_report}}";
+    }
+
+    std::string get_upper_footer_template_name() const override
+    {
+        return "footer_disclaimer";
+    }
+
+    illustration_table_columns const& get_table_columns() const override
+    {
+        return columns_;
+    }
+
+    illustration_table_columns columns_;
+};
+
 // Regular illustration.
 class pdf_illustration_regular : public pdf_illustration
 {
@@ -1973,6 +2022,10 @@ class pdf_illustration_regular : public pdf_illustration
             }
         add<tabular_detail_page>();
         add<tabular_detail2_page>();
+        if(invar.SupplementalReport)
+            {
+            add<supplemental_report>(get_interpolator());
+            }
         if(!invar.IsInforce)
             {
             add<numeric_summary_or_attachment_page<true>>();
diff --git a/supplemental_report.mustache b/supplemental_report.mustache
new file mode 100644
index 0000000..5743626
--- /dev/null
+++ b/supplemental_report.mustache
@@ -0,0 +1,7 @@
+{{>header}}
+
+<p align="center">{{SupplementalReportTitle}}</p>
+
+{{>dollar_units}}
+
+{{! The supplemental report table itself is generated from C++ code }}



reply via email to

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