Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def print_failed_transactions():
- from datetime import date
- print('#, Failed Transaction ID, New Transaction ID, New Transaction Status, Identity ID, Employee, Email, Amount, Needs Recreation')
- start_date = date(2025,2,28)
- failed_transactions = AptPayTransaction.objects.filter(
- transaction_type='Apt Send',
- movement_type='Employee payout',
- created__date__gte=start_date,
- internal_status='Failed'
- ).order_by('created')
- for i, transaction in enumerate(failed_transactions, 1):
- created = transaction.created
- identity_id = transaction.identity_id
- amount = transaction.amount
- needs_recreation = True
- new_transaction_id = '-'
- new_status = '-'
- new_transaction = AptPayTransaction.objects.filter(
- identity_id=identity_id,
- amount=amount,
- transaction_type='Apt Send',
- movement_type='Employee payout',
- created__gt=created,
- ).first()
- if new_transaction:
- new_transaction_id = new_transaction.apt_pay_id
- new_status = new_transaction.status
- if new_transaction.internal_status != 'Failed':
- needs_recreation = False
- employee = transaction.employee_name
- user_profile = ADTUserProfile.objects.filter(identity_id=identity_id).first()
- if not user_profile:
- user_profile = ADTUserProfile.objects.filter(
- previous_identity_ids__contains=[identity_id]
- ).first()
- email = '-'
- if user_profile:
- email = user_profile.user.email
- print(f'{i}, {transaction.apt_pay_id}, {new_transaction_id}, {new_status}, {identity_id}, {employee}, {email},'
- f' {amount}, {needs_recreation}')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement