From 097128c290d7fc50790361d04545ef817b2b5be9 Mon Sep 17 00:00:00 2001 From: Keenan Tims Date: Sat, 9 May 2026 00:08:32 -0700 Subject: [PATCH] fix rogers parser for new format --- actual_imap_poll/parsers.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/actual_imap_poll/parsers.py b/actual_imap_poll/parsers.py index 8c4d293..28f3fbb 100644 --- a/actual_imap_poll/parsers.py +++ b/actual_imap_poll/parsers.py @@ -77,7 +77,7 @@ class TransactionParsingFailed(Exception): class RogersBankParser(TransactionParser): EXTRACT_RE = re.compile( - r"Attempt of \$([0-9,]+\.\d{2}) was made on ([A-z]{3} \d{1,2}, \d{4})[^<]*at ([^<]+) in ([^<]+)." # noqa: E501 + r"\$([0-9,]+\.\d{2}) on ((Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) [0-9]{2}, [0-9]{4}) on your credit card ending in ([0-9]{4}). Details: ([^.]+)" # noqa: E501 ) def __init__(self, account_id: UUID): @@ -90,17 +90,16 @@ class RogersBankParser(TransactionParser): ) def extract(self, msg: EmailMessage) -> Optional[Transaction]: - content = self.get_content(msg) + content = self.strip_html(msg) matches = self.EXTRACT_RE.search(content) if matches is None: raise TransactionParsingFailed("No matches for extraction RE") amount = Decimal(matches[1].replace(",", "")) * -1 date_raw = matches[2] - payee = matches[3] - location = matches[4] + payee = matches[5] - if "Rebate" == location and "CashBack" in payee: + if "CashBack" in payee: amount = amount * -1 date = datetime.strptime(date_raw, "%b %d, %Y").date() @@ -109,7 +108,7 @@ class RogersBankParser(TransactionParser): date=date, amount=amount, payee=payee, - notes=f"in {location} (via email)", + notes="(via email)", imported_id=msg["Message-ID"], )