Changeset - 72f58d80d735
[Not reviewed]
0 2 0
Brett Smith - 4 years ago 2020-06-15 18:09:42
brettcsmith@brettcsmith.org
reports: BaseODS.currency_cell() sets default style.

It'll be rare we don't want this.
2 files changed with 15 insertions and 0 deletions:
0 comments (0 inline, 0 general)
conservancy_beancount/reports/core.py
Show inline comments
...
 
@@ -922,6 +922,8 @@ class BaseODS(BaseSpreadsheet[RT, ST], metaclass=abc.ABCMeta):
 
            return self.multiline_cell(lines, **attrs)
 

	
 
    def currency_cell(self, amount: data.Amount, **attrs: Any) -> odf.table.TableCell:
 
        if 'stylename' not in attrs:
 
            attrs['stylename'] = self.currency_style(amount.currency)
 
        number, currency = amount
 
        cell = odf.table.TableCell(valuetype='currency', value=number, **attrs)
 
        cell.addElement(odf.text.P(text=babel.numbers.format_currency(
tests/test_reports_spreadsheet.py
Show inline comments
...
 
@@ -470,6 +470,19 @@ def test_ods_writer_currency_cell(ods_writer, cell_source, style_name):
 
    )
 
    assert get_text(cell) == expected
 

	
 
@pytest.mark.parametrize('currency', [
 
    'EUR',
 
    'CHF',
 
    'GBP',
 
])
 
def test_ods_writer_currency_cell_default_style(ods_writer, currency):
 
    amount = testutil.Amount(1000, currency)
 
    expected_stylename = ods_writer.currency_style(currency).getAttribute('name')
 
    cell = ods_writer.currency_cell(amount)
 
    assert cell.getAttribute('valuetype') == 'currency'
 
    assert cell.getAttribute('value') == '1000'
 
    assert cell.getAttribute('stylename') == expected_stylename
 

	
 
@pytest.mark.parametrize('date,style_name', testutil.combine_values(
 
    [datetime.date(1980, 2, 5), datetime.date(2030, 10, 30)],
 
    XML_NAMES_LIST,
0 comments (0 inline, 0 general)