diff --git a/conservancy_beancount/reports/core.py b/conservancy_beancount/reports/core.py index 48ba9c4e158ee7ac4462e0611d7e52a020602f1a..59d0bc516dd2eacd2b002bf048e7381d0f9550ce 100644 --- a/conservancy_beancount/reports/core.py +++ b/conservancy_beancount/reports/core.py @@ -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( diff --git a/tests/test_reports_spreadsheet.py b/tests/test_reports_spreadsheet.py index 97780bc69a417f97c528f0607a700e2e34799033..d27ee3c608939a79fb5e9fbbce448aae496fe5fe 100644 --- a/tests/test_reports_spreadsheet.py +++ b/tests/test_reports_spreadsheet.py @@ -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,