From 9fc6fe9e50a3e8d027f4e6754194fb7d4058bcf6 Mon Sep 17 00:00:00 2001 From: Koert van der Veer Date: Tue, 17 Sep 2024 12:59:22 +0200 Subject: [PATCH] Make name and email acquisition more reliable --- .../models/online_bank_statement_provider_paypal.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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]