Skip to content

Commit

Permalink
Fix PayPal payee handling
Browse files Browse the repository at this point in the history
Sometimes data["applicant_name"] can be None.
  • Loading branch information
bahlo committed Oct 1, 2024
1 parent f80ff12 commit 3bb5c7e
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/ing_ynab/ynab.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,14 @@ def transform_transactions(
)

# If this is a PayPal transaction, try to get the Payee from the memo
if PAYPAL_PAYEE_REGEX.match(data["applicant_name"]):
payee = PAYPAL_MEMO_REGEX.match(data["purpose"])
if payee is not None:
payee = payee.group(2)
if payee.endswith(PAYPAL_SUFFIX):
payee = payee[: -len(PAYPAL_SUFFIX)]
data["applicant_name"] = "PAYPAL " + payee
if data["applicant_name"] is not None:
if PAYPAL_PAYEE_REGEX.match(data["applicant_name"]) is not None:
payee = PAYPAL_MEMO_REGEX.match(data["purpose"])
if payee is not None:
payee = payee.group(2)
if payee.endswith(PAYPAL_SUFFIX):
payee = payee[: -len(PAYPAL_SUFFIX)]
data["applicant_name"] = "PAYPAL " + payee

transformed.append(
{
Expand Down

0 comments on commit 3bb5c7e

Please sign in to comment.