Skip to content

Commit 202e05f

Browse files
authored
Merge pull request #169 from bahlo/more-paypal-fixes
More paypal fixes
2 parents ced4e8a + 0315de9 commit 202e05f

File tree

2 files changed

+38
-3
lines changed

2 files changed

+38
-3
lines changed

ing_ynab/ynab.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
YNAB_BASE_URL = "https://api.youneedabudget.com/v1"
1212
PAYPAL_PAYEE_REGEX = re.compile(r"^PayPal\s?\(Europe\)")
13-
PAYPAL_MEMO_REGEX = re.compile(r".*, Ihr Einkauf bei (.*)$")
13+
PAYPAL_MEMO_REGEX = re.compile(r".*, Ihr Einkauf be\n?i\s?(.*)$")
1414

1515

1616
class YNABError(Exception):

tests/test_ynab.py

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ def test_paypal_extraction(self):
9494

9595
tests = [
9696
{
97+
"name": "no pp",
9798
"transaction": Transaction(
9899
[],
99100
data={
@@ -109,6 +110,7 @@ def test_paypal_extraction(self):
109110
},
110111
},
111112
{
113+
"name": "pp",
112114
"transaction": Transaction(
113115
[],
114116
data={
@@ -123,12 +125,46 @@ def test_paypal_extraction(self):
123125
"memo": "PP.0000.PP . GITHUB INC, Ihr Einkauf bei GITHUB INC",
124126
},
125127
},
128+
{
129+
"name": "linebreak",
130+
"transaction": Transaction(
131+
[],
132+
data={
133+
"date": date.fromisoformat("2020-08-18"),
134+
"applicant_name": "PayPal (Europe) S.a.r.l. et Cie., S.C.A.",
135+
"purpose": "PP.0000.PP . GITHUB INC, Ihr Einkauf be\ni GITHUB INC",
136+
"amount": Amount("4.99", "D"),
137+
},
138+
),
139+
"expected": {
140+
"payee_name": "PAYPAL GITHUB INC",
141+
"memo": "PP.0000.PP . GITHUB INC, Ihr Einkauf be\ni GITHUB INC",
142+
},
143+
},
144+
{
145+
"name": "missing space",
146+
"transaction": Transaction(
147+
[],
148+
data={
149+
"date": date.fromisoformat("2020-08-18"),
150+
"applicant_name": "PayPal (Europe) S.a.r.l. et Cie., S.C.A.",
151+
"purpose": "PP.0000.PP . GITHUB INC, Ihr Einkauf beiGITHUB INC",
152+
"amount": Amount("4.99", "D"),
153+
},
154+
),
155+
"expected": {
156+
"payee_name": "PAYPAL GITHUB INC",
157+
"memo": "PP.0000.PP . GITHUB INC, Ihr Einkauf beiGITHUB INC",
158+
},
159+
},
126160
]
127161

128162
for test in tests:
129163
transformed = ynab_client.transform_transactions([test["transaction"]])
130164
for key in test["expected"]:
131-
self.assertEqual(test["expected"][key], transformed[0][key])
165+
self.assertEqual(
166+
test["expected"][key], transformed[0][key], test["name"]
167+
)
132168

133169
def test_paypal_applicant_names(self):
134170
ynab_client = YNABClient("", "foo", "")
@@ -156,4 +192,3 @@ def test_paypal_applicant_names(self):
156192
]
157193
)
158194
self.assertEqual("PAYPAL GITHUB INC", transformed[0]["payee_name"])
159-

0 commit comments

Comments
 (0)