from django.core.management.base import BaseCommand from uncloud_auth.models import User from uncloud_pay.models import Bill from datetime import timedelta from django.utils import timezone class Command(BaseCommand): help = 'Take action on overdue bills.' def add_arguments(self, parser): pass def handle(self, *args, **options): users = User.objects.all() print("Processing {} users.".format(users.count())) for user in users: for bill in Bill.get_overdue_for(user): print("/!\ Overdue bill for {}, {} with amount {}" .format(user.username, bill.uuid, bill.amount)) # TODO: take action? print("=> Done.")