diff --git a/facturier/management/commands/cleanup_transactionevents.py b/facturier/management/commands/cleanup_transactionevents.py index a862b61..f338088 100644 --- a/facturier/management/commands/cleanup_transactionevents.py +++ b/facturier/management/commands/cleanup_transactionevents.py @@ -9,7 +9,7 @@ class Command(BaseCommand): def handle(self, *args, **options): delta = timezone.now() - timezone.timedelta(minutes=10) for event in TransactionEvent.objects.filter(status='CREATED', date__lte=delta): - if not TransactionEvent.objects.filter(invoice_id=event.invoice_id, + if not TransactionEvent.objects.filter(invoice_id=event.invoice_id, date__gt=event.date, status__in=['CANCELED', 'ERROR', 'PAID', 'DENIED']).exists(): TransactionEvent.objects.create(transaction_id=event.transaction_id, status='CANCELED',