From 4e180f515111eeabd061814c44a10250403c4c96 Mon Sep 17 00:00:00 2001 From: RunasSudo Date: Sun, 17 May 2020 15:15:30 +1000 Subject: [PATCH] Correctly handle amounts with commas --- ledger_pyreport/ledger.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ledger_pyreport/ledger.py b/ledger_pyreport/ledger.py index b452ce4..805c417 100644 --- a/ledger_pyreport/ledger.py +++ b/ledger_pyreport/ledger.py @@ -63,12 +63,12 @@ def parse_amount(amount): if amount_str[0] in list('0123456789-'): # Commodity follows number bits = amount_str.split() - amount_num = Decimal(bits[0]) + amount_num = Decimal(bits[0].replace(',', '')) commodity = Commodity(bits[1].strip('"'), False) else: # Commodity precedes number commodity = Commodity(amount_str[0], True) - amount_num = Decimal(amount_str[1:]) + amount_num = Decimal(amount_str[1:].replace(',', '')) if price_str: commodity.price = parse_amount(price_str)