diff --git a/account_statement_import_online_paypal/models/online_bank_statement_provider_paypal.py b/account_statement_import_online_paypal/models/online_bank_statement_provider_paypal.py index c320f85fc..303f68014 100644 --- a/account_statement_import_online_paypal/models/online_bank_statement_provider_paypal.py +++ b/account_statement_import_online_paypal/models/online_bank_statement_provider_paypal.py @@ -291,14 +291,17 @@ def _paypal_transaction_to_lines(self, data): transaction_note = transaction.get("transaction_note") invoice = transaction.get("invoice_id") payer_name = payer.get("payer_name", {}) - payer_email = payer_name.get("email_address") + payer_email = payer_name.get("email_address") or payer.get("email_address") + payer_full_name = payer_name.get("full_name") or payer_name.get( + "alternate_full_name" + ) if invoice: invoice = _("Invoice %s") % invoice note = transaction_id if transaction_subject or transaction_note: note = f"{note}: {transaction_subject or transaction_note}" - if payer_email: - note += " (%s)" % payer_email + if payer_email or payer_full_name: + note += f" ({payer_email or payer_full_name})" unique_import_id = f"{transaction_id}-{int(date.timestamp())}" name = ( invoice @@ -315,9 +318,6 @@ def _paypal_transaction_to_lines(self, data): "unique_import_id": unique_import_id, "raw_data": transaction, } - payer_full_name = payer_name.get("full_name") or payer_name.get( - "alternate_full_name" - ) if payer_full_name: line.update({"partner_name": payer_full_name}) lines = [line] diff --git a/account_statement_import_online_paypal/tests/test_account_statement_import_online_paypal.py b/account_statement_import_online_paypal/tests/test_account_statement_import_online_paypal.py index 204725f5f..53151e616 100644 --- a/account_statement_import_online_paypal/tests/test_account_statement_import_online_paypal.py +++ b/account_statement_import_online_paypal/tests/test_account_statement_import_online_paypal.py @@ -560,7 +560,9 @@ def test_pull(self): "date": self.yesterday, "amount": "1000.00", "ref": "Invoice 1", - "payment_ref": "1234567890: Payment for Invoice(s) 1", + "payment_ref": ( + "1234567890: Payment for Invoice(s) 1 (partner@example.com)" + ), "partner_name": "Acme, Inc.", "unique_import_id": f"1234567890-{self.yesterday_timestamp}", }, @@ -572,7 +574,8 @@ def test_pull(self): "amount": "-100.00", "ref": "Fee for Invoice 1", "payment_ref": ( - "Transaction fee for 1234567890: Payment for Invoice(s) 1" + "Transaction fee for 1234567890: Payment for Invoice(s) 1 " + "(partner@example.com)" ), "partner_name": "PayPal", "unique_import_id": f"1234567890-{self.yesterday_timestamp}-FEE", @@ -634,7 +637,9 @@ def test_transaction_parse_1(self): "date": self.today, "amount": "1000.00", "ref": "Invoice 1", - "payment_ref": "1234567890: Payment for Invoice(s) 1", + "payment_ref": ( + "1234567890: Payment for Invoice(s) 1 (partner@example.com)" + ), "partner_name": "Acme, Inc.", "unique_import_id": f"1234567890-{self.today_timestamp}", }, @@ -694,7 +699,9 @@ def test_transaction_parse_2(self): "date": self.today, "amount": "1000.00", "ref": "Invoice 1", - "payment_ref": "1234567890: Payment for Invoice(s) 1", + "payment_ref": ( + "1234567890: Payment for Invoice(s) 1 (partner@example.com)" + ), "partner_name": "Acme, Inc.", "unique_import_id": f"1234567890-{self.today_timestamp}", }, @@ -754,7 +761,9 @@ def test_transaction_parse_3(self): "date": self.today, "amount": "1000.00", "ref": "Invoice 1", - "payment_ref": "1234567890: Payment for Invoice(s) 1", + "payment_ref": ( + "1234567890: Payment for Invoice(s) 1 (partner@example.com)" + ), "partner_name": "Acme, Inc.", "unique_import_id": f"1234567890-{self.today_timestamp}", }, @@ -766,7 +775,8 @@ def test_transaction_parse_3(self): "amount": "-100.00", "ref": "Fee for Invoice 1", "payment_ref": ( - "Transaction fee for 1234567890: Payment for Invoice(s) 1" + "Transaction fee for 1234567890: Payment for Invoice(s) 1 " + "(partner@example.com)" ), "partner_name": "PayPal", "unique_import_id": f"1234567890-{self.today_timestamp}-FEE", @@ -823,7 +833,9 @@ def test_transaction_parse_4(self): "date": self.today, "amount": "1000.00", "ref": "Invoice 1", - "payment_ref": "1234567890: Payment for Invoice(s) 1", + "payment_ref": ( + "1234567890: Payment for Invoice(s) 1 (partner@example.com)" + ), "partner_name": "Acme, Inc.", "unique_import_id": f"1234567890-{self.today_timestamp}", },