Move django-based uncloud to top-level
This commit is contained in:
parent
0560063326
commit
95d43f002f
265 changed files with 0 additions and 0 deletions
35
uncloud_pay/management/commands/generate-bills.py
Normal file
35
uncloud_pay/management/commands/generate-bills.py
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
import logging
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
from uncloud_auth.models import User
|
||||
from uncloud_pay.models import Order, Bill
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
|
||||
from datetime import timedelta, date
|
||||
from django.utils import timezone
|
||||
from uncloud_pay.models import Bill
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = 'Generate bills and charge customers if necessary.'
|
||||
|
||||
def add_arguments(self, parser):
|
||||
pass
|
||||
|
||||
# TODO: use logger.*
|
||||
def handle(self, *args, **options):
|
||||
# Iterate over all 'active' users.
|
||||
# TODO: filter out inactive users.
|
||||
users = User.objects.all()
|
||||
print("Processing {} users.".format(users.count()))
|
||||
|
||||
for user in users:
|
||||
now = timezone.now()
|
||||
Bill.generate_for(
|
||||
year=now.year,
|
||||
month=now.month,
|
||||
user=user)
|
||||
|
||||
# We're done for this round :-)
|
||||
print("=> Done.")
|
||||
Loading…
Add table
Add a link
Reference in a new issue