1 # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
2 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
4 from datetime import timedelta
6 from django.core.management.base import BaseCommand, CommandError
7 from django.utils.timezone import now
8 from club.models import PayUOrder
9 from funding.models import Funding
10 from paypal.models import BillingAgreement
13 class Command(BaseCommand):
14 def add_arguments(self, parser):
16 'year', type=int, metavar='YEAR',
17 help='Send receipts for the year.')
20 help='Send only to these emails.')
22 def handle(self, *args, **options):
23 year = options['year']
25 PayUOrder.objects.filter(
26 completed_at__year=year
27 ).order_by('schedule__email').values_list(
28 'schedule__email', flat=True
32 BillingAgreement.objects.all().order_by(
33 'schedule__email').values_list(
34 'schedule__email', flat=True
38 Funding.objects.exclude(email='').filter(
40 ).order_by('email').values_list(
46 emails = options['emails'].split(',')
51 PayUOrder.send_receipt(email, year)