@@ -653,8 +653,7 @@ def backfill_transactions(days=30):
653653 if paymentIntent .invoice :
654654 try :
655655 invoice = stripe .Invoice .retrieve (
656- stripe_account = stripe_connect_account_id ,
657- id = paymentIntent .invoice
656+ stripe_account = stripe_connect_account_id , id = paymentIntent .invoice
658657 )
659658 if invoice .subscription :
660659 subscription_id = invoice .subscription
@@ -677,7 +676,9 @@ def backfill_transactions(days=30):
677676 # Update other fields that may have changed
678677 transaction .amount = paymentIntent .amount
679678 transaction .currency = paymentIntent .currency
680- transaction .payment_status = "paid" if paymentIntent .status == "succeeded" else paymentIntent .status
679+ transaction .payment_status = (
680+ "paid" if paymentIntent .status == "succeeded" else paymentIntent .status
681+ )
681682
682683 database .session .commit ()
683684 updated_count += 1
@@ -689,8 +690,14 @@ def backfill_transactions(days=30):
689690 transaction .external_src = "stripe"
690691 transaction .currency = paymentIntent .currency
691692 transaction .amount = paymentIntent .amount
692- transaction .payment_status = "paid" if paymentIntent .status == "succeeded" else paymentIntent .status
693- transaction .comment = invoice .subscription_details .metadata .get ("donation_comment" ) if invoice and invoice .subscription_details else None
693+ transaction .payment_status = (
694+ "paid" if paymentIntent .status == "succeeded" else paymentIntent .status
695+ )
696+ transaction .comment = (
697+ invoice .subscription_details .metadata .get ("donation_comment" )
698+ if invoice and invoice .subscription_details
699+ else None
700+ )
694701 transaction .created_at = stripe_transaction_created_at
695702
696703 # Try to find subscription in local database
@@ -703,29 +710,45 @@ def backfill_transactions(days=30):
703710 if subscribie_subscription :
704711 transaction .subscription = subscribie_subscription
705712 transaction .person = subscribie_subscription .person
706- log .info (f"Linked transaction to subscription { subscribie_subscription .id } " )
713+ log .info (
714+ f"Linked transaction to subscription { subscribie_subscription .id } "
715+ )
707716 else :
708- log .warning (f"Subscription { subscription_id } not found in local database" )
717+ log .warning (
718+ f"Subscription { subscription_id } not found in local database"
719+ )
709720
710721 # Try to get person from metadata if no subscription found
711722 if transaction .person is None and paymentIntent .invoice :
712- person_uuid = invoice .subscription_details .metadata .get ("person_uuid" ) if invoice and invoice .subscription_details else None
723+ person_uuid = (
724+ invoice .subscription_details .metadata .get ("person_uuid" )
725+ if invoice and invoice .subscription_details
726+ else None
727+ )
713728 if person_uuid :
714729 person = Person .query .filter_by (uuid = person_uuid ).first ()
715730 if person :
716731 transaction .person = person
717- log .info (f"Linked transaction to person { person .id } via metadata" )
732+ log .info (
733+ f"Linked transaction to person { person .id } via metadata"
734+ )
718735
719736 # Check if it's a donation
720- is_donation = invoice .subscription_details .metadata .get ("is_donation" , "False" ) if invoice and invoice .subscription_details else False
737+ is_donation = (
738+ invoice .subscription_details .metadata .get ("is_donation" , "False" )
739+ if invoice and invoice .subscription_details
740+ else False
741+ )
721742 if is_donation == "True" :
722743 transaction .is_donation = True
723744
724745 database .session .add (transaction )
725746 database .session .commit ()
726747 created_count += 1
727748
728- log .info (f"Backfill complete: { created_count } transactions created, { updated_count } updated" )
749+ log .info (
750+ f"Backfill complete: { created_count } transactions created, { updated_count } updated"
751+ )
729752
730753
731754def backfill_subscriptions (days = 30 ):
0 commit comments