uncloud-mravi/uncloud_django_based/uncloud/uncloud_pay/management/commands/handle-overdue-bills.py

24 lines
732 B
Python
Raw Normal View History

2020-02-28 09:18:24 +00:00
from django.core.management.base import BaseCommand
from uncloud_auth.models import User
from uncloud_pay.models import Bill
2020-02-28 09:18:24 +00:00
from datetime import timedelta
from django.utils import timezone
class Command(BaseCommand):
help = 'Take action on overdue bills.'
2020-02-28 09:18:24 +00:00
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?
2020-02-28 09:18:24 +00:00
print("=> Done.")