Skip to content

Commit

Permalink
Implement cron job to mark invoice as due
Browse files Browse the repository at this point in the history
Hound issues resolution
  • Loading branch information
mrsaicharan1 committed Jul 10, 2019
1 parent f6b900a commit d81e0cf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
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(send_monthly_event_invoice, 'cron', day=1, month='1-12')
scheduler.start()


Expand Down
12 changes: 12 additions & 0 deletions app/api/helpers/scheduled_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,18 @@ 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

0 comments on commit d81e0cf

Please sign in to comment.