You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

37 lines
1.3 KiB

# coding=utf-8
from celery.task import periodic_task
from datetime import timedelta, datetime
from finance.models import Price, Bill, ServiceRequest
from courses.models import CourseMap
@periodic_task(run_every=timedelta(minutes=1))
def price_map_migrator():
for price in Price.objects.filter(included=None).exclude(course=None):
if not price.included.exists():
inc_type = []
if price.m_type == 'B':
inc_type = ['B']
elif price.m_type == 'E':
inc_type = ['B', 'E']
elif price.m_type == 'P':
inc_type = ['B', 'E', 'P']
for m in CourseMap.objects.filter(course=price.course):
if m.get_obj().theme.price_type in inc_type:
price.included.add(m)
@periodic_task(run_every=timedelta(hours=1))
def price_map_migrator():
for price in Price.objects.exclude(by_time=None):
for bill in Bill.objects.filter(service=price, fire_date__lt=datetime.now()):
bill.status = 'H'
bill.save()
@periodic_task(run_every=timedelta(minutes=1))
def sent_service_request_to_amo():
sr = ServiceRequest.objects.filter(send=False, send_date__lt=datetime.now()).exclude(name='TEST').first()
if sr:
sr.sent_to_amo()