diff --git a/parsers.py b/parsers.py index 6a9274d..d81e0fa 100644 --- a/parsers.py +++ b/parsers.py @@ -49,7 +49,7 @@ class TransactionParsingFailed(Exception): class RogersBankParser(TransactionParser): EXTRACT_RE = re.compile( - r"Attempt of \$(\d+\.\d{2}) was made on ([A-z]{3} \d{1,2}, \d{4})[^<]*at ([^<]+) in" + r"Attempt of \$([0-9,]+\.\d{2}) was made on ([A-z]{3} \d{1,2}, \d{4})[^<]*at ([^<]+) in" ) def __init__(self, account_id: UUID): @@ -71,7 +71,7 @@ class RogersBankParser(TransactionParser): matches = self.EXTRACT_RE.search(content) if matches is None: raise TransactionParsingFailed("No matches for extraction RE") - amount = Decimal(matches[1]) + amount = Decimal(matches[1].replace(",", "")) date_raw = matches[2] payee = matches[3] date = datetime.strptime(date_raw, "%b %d, %Y").date() @@ -87,7 +87,7 @@ class RogersBankParser(TransactionParser): class MBNAParser(TransactionParser): EXTRACT_RE = re.compile( - r"A purchase of \$(\d+\.\d{2}) from ([^<]+) was made at (\d{1,2}:\d{2} (AM|PM)) UTC on (\d{4}-\d{2}-\d{2})" # noqa: E501 + r"A purchase of \$([0-9,]+\.\d{2}) from ([^<]+) was made at (\d{1,2}:\d{2} (AM|PM)) UTC on (\d{4}-\d{2}-\d{2})" # noqa: E501 ) def __init__(self, account_id: UUID): @@ -109,7 +109,7 @@ class MBNAParser(TransactionParser): matches = self.EXTRACT_RE.search(content) if matches is None: raise TransactionParsingFailed("No matches for extraction RE") - amount = Decimal(matches[1]) + amount = Decimal(matches[1].replace(",", "")) payee = matches[2] date_raw = matches[5] return Transaction(