Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
from app.api.helpers.auth import AuthManager
from app.api.helpers.scheduled_jobs import send_after_event_mail, send_event_fee_notification, \
send_event_fee_notification_followup, change_session_state_on_event_completion, \
expire_pending_tickets, send_monthly_event_invoice
expire_pending_tickets, send_monthly_event_invoice, event_invoices_mark_due
from app.models.event import Event
from app.models.role_invite import RoleInvite
from app.views.healthcheck import health_check_celery, health_check_db, health_check_migrations, check_migrations
Expand Down Expand Up @@ -243,6 +243,7 @@ def update_sent_state(sender=None, headers=None, **kwargs):
scheduler.add_job(change_session_state_on_event_completion, 'cron', hour=5, minute=30)
scheduler.add_job(expire_pending_tickets, 'cron', minute=45)
scheduler.add_job(send_monthly_event_invoice, 'cron', day=1, month='1-12')
scheduler.add_job(event_invoices_mark_due, 'cron', hour=5)
scheduler.start()


Expand Down
13 changes: 13 additions & 0 deletions app/api/helpers/scheduled_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,19 @@ def expire_pending_tickets():
db.session.commit()


def event_invoices_mark_due():
from app import current_app as app
with app.app_context():
db.session.query(EventInvoice).\
filter(EventInvoice.status == 'upcoming',
EventInvoice.event.ends_at >= datetime.datetime.now(),
(EventInvoice.created_at + datetime.timedelta(days=30) <=
datetime.datetime.now())).\
update({'status': 'due'})

db.session.commit()


def send_monthly_event_invoice():
from app import current_app as app
with app.app_context():
Expand Down