parsers: rogers parser handle cashbacks
probably need something similar for refunds but don't know the format until one happens
This commit is contained in:
parent
0009d98791
commit
a23f2a2619
10
parsers.py
10
parsers.py
@ -49,7 +49,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"
|
||||
r"Attempt of \$([0-9,]+\.\d{2}) was made on ([A-z]{3} \d{1,2}, \d{4})[^<]*at ([^<]+) in ([^<]+)" # noqa: E501
|
||||
)
|
||||
|
||||
def __init__(self, account_id: UUID):
|
||||
@ -72,15 +72,21 @@ class RogersBankParser(TransactionParser):
|
||||
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]
|
||||
|
||||
if "Rebate" == location and "CashBack" in payee:
|
||||
amount = amount * -1
|
||||
|
||||
date = datetime.strptime(date_raw, "%b %d, %Y").date()
|
||||
return Transaction(
|
||||
account=self.account_id,
|
||||
date=date,
|
||||
amount=amount,
|
||||
payee=payee,
|
||||
notes="via email",
|
||||
notes=f"in {location} (via email)",
|
||||
imported_id=msg["Message-ID"],
|
||||
)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user