0 2 0
Brett Smith - 3 months ago 2020-05-19 19:22:00
brettcsmith@brettcsmith.org
historical: Beancount can handle commas in amounts. And having it looks nicer, is more consistent with our historical books, is less code for me, and is no more trouble for the user.
2 files changed with 3 insertions and 4 deletions:
↑ Collapse Diff ↑
...
 
@@ -176,13 +176,13 @@ class BeancountFormatter(LedgerFormatter):
176 176
 
    COST_FMT = '{{{}}}'
177 177
 

	
178 178
 
    def __init__(self, cost_rates, price_rates=None,
179
 
                 signed_currencies=(), base_fmt='###0.###',
179
 
                 signed_currencies=(), base_fmt='#,##0.###',
180 180
 
                 rate_precision=5, denomination=None):
181 181
 
        super().__init__(
182 182
 
            cost_rates,
183 183
 
            price_rates,
184 184
 
            (),
185
 
            base_fmt.replace(',', ''),
185
 
            base_fmt,
186 186
 
            rate_precision,
187 187
 
            denomination,
188 188
 
        )
...
 
@@ -95,7 +95,6 @@ def check_fx_amount(config, lines, amount, cost, fx_code, fx_sign=None, price=No
95 95
 
        cost_re = '{{={}}}'.format(rate_fmt.format(cost))
96 96
 
        price_re = ' @ {}'.format(rate_fmt.format(price))
97 97
 
    else:
98
 
        amount = amount.replace(',', '')
99 98
 
        cost_re = '{{{}}}'.format(rate_fmt.format(cost))
100 99
 
        if config.args.from_date is None:
101 100
 
            price_re = ''
...
 
@@ -115,7 +114,7 @@ def check_nonfx_amount(config, lines, amount, code=None, sign=None):
115 114
 
        else:
116 115
 
            expected = f'{amount} {code}\n'
117 116
 
    else:
118
 
        expected = f'{amount.replace(",", "")} {code or "USD"}\n'
117
 
        expected = f'{amount} {code or "USD"}\n'
119 118
 
    assert next(lines, "<EOF>") == expected
120 119
 

	
121 120
 
def test_rate_list(single_responder, output, any_date):
0 comments (0 inline, 0 general)