reports: Balance.format(None) uses accounting formats.

This commit is contained in:
Brett Smith 2020-06-21 11:39:31 -04:00
parent 5e9e11923e
commit 42d2002fda
2 changed files with 7 additions and 5 deletions

View file

@ -231,8 +231,9 @@ class Balance(Mapping[str, data.Amount]):
amounts = list(balance.values())
amounts.sort(key=lambda amt: (-abs(amt.number), amt.currency))
return sep.join(
babel.numbers.format_currency(amt.number, amt.currency, fmt)
for amt in amounts
babel.numbers.format_currency(
amt.number, amt.currency, fmt, format_type='accounting',
) for amt in amounts
)

View file

@ -419,10 +419,11 @@ def test_format_sep(sep):
balance = core.Balance(amounts_from_map(mapping))
assert balance.format(sep=sep) == expected
def test_format_none():
args = (65000, 'BRL')
@pytest.mark.parametrize('number', [65000, -77000])
def test_format_none(number):
args = (number, 'BRL')
balance = core.Balance([testutil.Amount(*args)])
expected = babel.numbers.format_currency(*args)
expected = babel.numbers.format_currency(*args, format_type='accounting')
assert balance.format(None) == expected
@pytest.mark.parametrize('empty', [