Changeset - 4f223642ed4b
[Not reviewed]
0 5 0
Brett Smith - 4 years ago 2020-08-22 16:33:06
brettcsmith@brettcsmith.org
reports: Refactor total styles to BaseODS.
5 files changed with 17 insertions and 20 deletions:
0 comments (0 inline, 0 general)
conservancy_beancount/reports/balance_sheet.py
Show inline comments
...
 
@@ -249,10 +249,4 @@ class Report(core.BaseODS[Sequence[None], None]):
 
            self.border_style(core.Border.BOTTOM, '1pt'),
 
        )
 
        self.style_subtotline = self.border_style(core.Border.TOP, '1pt')
 
        self.style_totline = self.border_style(core.Border.TOP | core.Border.BOTTOM, '1pt')
 
        self.style_bottomline = self.merge_styles(
 
            self.style_subtotline,
 
            self.border_style(core.Border.BOTTOM, '2pt', 'double'),
 
        )
 

	
 
    def write_all(self) -> None:
...
 
@@ -388,5 +382,5 @@ class Report(core.BaseODS[Sequence[None], None]):
 
        liabilities = self.write_classifications_by_account('Liabilities', balance_kwargs)
 
        self.write_totals_row(
 
            "Total Liabilities", liabilities, stylename=self.style_totline,
 
            "Total Liabilities", liabilities, stylename=self.style_endtotal,
 
        )
 
        self.add_row()
...
 
@@ -404,5 +398,5 @@ class Report(core.BaseODS[Sequence[None], None]):
 
                total_bal += balance
 
        self.write_totals_row(
 
            "Total Net Assets", equity_totals, stylename=self.style_subtotline,
 
            "Total Net Assets", equity_totals, stylename=self.style_total,
 
        )
 
        self.write_totals_row(
...
 
@@ -429,5 +423,5 @@ class Report(core.BaseODS[Sequence[None], None]):
 
        self.add_row()
 
        income_totals = self.write_classifications_by_account('Income', bal_kwargs)
 
        self.write_totals_row("", income_totals, stylename=self.style_subtotline)
 
        self.write_totals_row("", income_totals, stylename=self.style_total)
 
        self.add_row()
 
        self.add_row(
...
 
@@ -446,5 +440,5 @@ class Report(core.BaseODS[Sequence[None], None]):
 
            "Total Support and Revenue",
 
            income_totals, other_totals,
 
            stylename=self.style_totline,
 
            stylename=self.style_endtotal,
 
        )
 

	
...
 
@@ -488,5 +482,5 @@ class Report(core.BaseODS[Sequence[None], None]):
 
            period_bal,
 
            prior_bal,
 
        ], stylename=self.style_totline, leading_rows=0)
 
        ], stylename=self.style_endtotal, leading_rows=0)
 

	
 
        other_totals[0] -= period_bal
...
 
@@ -568,5 +562,5 @@ class Report(core.BaseODS[Sequence[None], None]):
 
            "Net cash provided by operating activities",
 
            period_totals,
 
            stylename=self.style_totline,
 
            stylename=self.style_endtotal,
 
        )
 
        self.write_totals_row("Net Increase in Cash", period_totals)
conservancy_beancount/reports/core.py
Show inline comments
...
 
@@ -1055,4 +1055,11 @@ class BaseODS(BaseSpreadsheet[RT, ST], metaclass=abc.ABCMeta):
 
            setattr(self, f'style_{textalign}text', aligned_style)
 

	
 
        self.style_total = self.border_style(Border.TOP, '1pt')
 
        self.style_endtotal = self.border_style(Border.TOP | Border.BOTTOM, '1pt')
 
        self.style_bottomline = self.merge_styles(
 
            self.style_total,
 
            self.border_style(Border.BOTTOM, '2pt', 'double'),
 
        )
 

	
 
    ### Properties
 

	
conservancy_beancount/reports/fund.py
Show inline comments
...
 
@@ -169,8 +169,5 @@ class ODSReport(core.BaseODS[FundPosts, None]):
 
                for total, bal in zip(totals, balances):
 
                    total += bal
 
        self.write_balances('', totals, self.merge_styles(
 
            self.border_style(core.Border.TOP, '.75pt'),
 
            self.border_style(core.Border.BOTTOM, '1.5pt', 'double'),
 
        ))
 
        self.write_balances('', totals, self.style_bottomline)
 
        self.document.spreadsheet.childNodes.reverse()
 
        self.sheet = start_sheet
conservancy_beancount/reports/ledger.py
Show inline comments
...
 
@@ -179,8 +179,4 @@ class LedgerODS(core.BaseODS[data.Posting, None]):
 
    def init_styles(self) -> None:
 
        super().init_styles()
 
        self.style_bottomline = self.merge_styles(
 
            self.border_style(core.Border.TOP, '1pt'),
 
            self.border_style(core.Border.BOTTOM, '2pt', 'double'),
 
        )
 
        self.amount_column = self.column_style(1.2)
 
        self.default_column = self.column_style(1.5)
tests/test_reports_spreadsheet.py
Show inline comments
...
 
@@ -306,4 +306,7 @@ def test_ods_currency_style_cache_considers_properties(ods_writer):
 
    ('style_endtext', odf.style.ParagraphProperties, 'textalign'),
 
    ('style_starttext', odf.style.ParagraphProperties, 'textalign'),
 
    ('style_total', odf.style.TableCellProperties, 'bordertop'),
 
    ('style_endtotal', odf.style.TableCellProperties, 'borderbottom'),
 
    ('style_bottomline', odf.style.TableCellProperties, 'borderbottom'),
 
])
 
def test_ods_writer_style(ods_writer, attr_name, child_type, checked_attr):
0 comments (0 inline, 0 general)