Correctly handle amounts with commas

This commit is contained in:
RunasSudo 2020-05-17 15:15:30 +10:00
parent 56959cda22
commit 4e180f5151
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A

View File

@ -63,12 +63,12 @@ def parse_amount(amount):
if amount_str[0] in list('0123456789-'): if amount_str[0] in list('0123456789-'):
# Commodity follows number # Commodity follows number
bits = amount_str.split() bits = amount_str.split()
amount_num = Decimal(bits[0]) amount_num = Decimal(bits[0].replace(',', ''))
commodity = Commodity(bits[1].strip('"'), False) commodity = Commodity(bits[1].strip('"'), False)
else: else:
# Commodity precedes number # Commodity precedes number
commodity = Commodity(amount_str[0], True) commodity = Commodity(amount_str[0], True)
amount_num = Decimal(amount_str[1:]) amount_num = Decimal(amount_str[1:].replace(',', ''))
if price_str: if price_str:
commodity.price = parse_amount(price_str) commodity.price = parse_amount(price_str)