List both the 'paypal_reference_id' and 'transaction_id' for likely one-off donations
This commit is contained in:
parent
8fd968c6f9
commit
621e130f7f
1 changed files with 20 additions and 7 deletions
|
@ -231,13 +231,26 @@ def report_on_unique_profiles(transactions, verbose=False):
|
|||
records = {}
|
||||
for t in transactions:
|
||||
transaction_info = t['transaction_info']
|
||||
if 'paypal_reference_id' in transaction_info:
|
||||
records[
|
||||
(
|
||||
transaction_info['paypal_reference_id'],
|
||||
transaction_info.get('transaction_subject', 'NO TRANSACTION SUBJECT'),
|
||||
)
|
||||
] = t
|
||||
try:
|
||||
item_details = t['cart_info']['item_details'][0]
|
||||
except KeyError:
|
||||
item_details = None
|
||||
|
||||
if 'paypal_reference_id' in transaction_info and 'transaction_subject' in transaction_info:
|
||||
# A typical recurring payment
|
||||
records[(transaction_info['paypal_reference_id'], transaction_info['transaction_subject'])] = t
|
||||
elif 'paypal_reference_id' in transaction_info and item_details:
|
||||
# A typical one-off payment
|
||||
#
|
||||
# List separate entries for the paypal_reference_id and
|
||||
# transaction_id since they no longer match.
|
||||
label = f'LIKELY NOT RECURRING: {item_details["item_description"]} - {item_details["item_name"]}'
|
||||
records[(transaction_info['paypal_reference_id'], label)] = t
|
||||
records[(transaction_info['transaction_id'], label)] = t
|
||||
elif 'paypal_reference_id' in transaction_info:
|
||||
# Something else, possibly a payout.
|
||||
label = 'NO TRANSACTION SUBJECT'
|
||||
records[(transaction_info['paypal_reference_id'], label)] = t
|
||||
else:
|
||||
print(
|
||||
f'Skipping transaction {transaction_info["transaction_id"]} with no PayPal Reference ID.',
|
||||
|
|
Loading…
Add table
Reference in a new issue