parsers: Support commas in numbers for other parsers
This commit is contained in:
		@@ -49,7 +49,7 @@ class TransactionParsingFailed(Exception):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
class RogersBankParser(TransactionParser):
 | 
					class RogersBankParser(TransactionParser):
 | 
				
			||||||
    EXTRACT_RE = re.compile(
 | 
					    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):
 | 
					    def __init__(self, account_id: UUID):
 | 
				
			||||||
@@ -71,7 +71,7 @@ class RogersBankParser(TransactionParser):
 | 
				
			|||||||
        matches = self.EXTRACT_RE.search(content)
 | 
					        matches = self.EXTRACT_RE.search(content)
 | 
				
			||||||
        if matches is None:
 | 
					        if matches is None:
 | 
				
			||||||
            raise TransactionParsingFailed("No matches for extraction RE")
 | 
					            raise TransactionParsingFailed("No matches for extraction RE")
 | 
				
			||||||
        amount = Decimal(matches[1])
 | 
					        amount = Decimal(matches[1].replace(",", ""))
 | 
				
			||||||
        date_raw = matches[2]
 | 
					        date_raw = matches[2]
 | 
				
			||||||
        payee = matches[3]
 | 
					        payee = matches[3]
 | 
				
			||||||
        date = datetime.strptime(date_raw, "%b %d, %Y").date()
 | 
					        date = datetime.strptime(date_raw, "%b %d, %Y").date()
 | 
				
			||||||
@@ -87,7 +87,7 @@ class RogersBankParser(TransactionParser):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
class MBNAParser(TransactionParser):
 | 
					class MBNAParser(TransactionParser):
 | 
				
			||||||
    EXTRACT_RE = re.compile(
 | 
					    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):
 | 
					    def __init__(self, account_id: UUID):
 | 
				
			||||||
@@ -109,7 +109,7 @@ class MBNAParser(TransactionParser):
 | 
				
			|||||||
        matches = self.EXTRACT_RE.search(content)
 | 
					        matches = self.EXTRACT_RE.search(content)
 | 
				
			||||||
        if matches is None:
 | 
					        if matches is None:
 | 
				
			||||||
            raise TransactionParsingFailed("No matches for extraction RE")
 | 
					            raise TransactionParsingFailed("No matches for extraction RE")
 | 
				
			||||||
        amount = Decimal(matches[1])
 | 
					        amount = Decimal(matches[1].replace(",", ""))
 | 
				
			||||||
        payee = matches[2]
 | 
					        payee = matches[2]
 | 
				
			||||||
        date_raw = matches[5]
 | 
					        date_raw = matches[5]
 | 
				
			||||||
        return Transaction(
 | 
					        return Transaction(
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user