Skip to content

Commit

Permalink
fix: Set billing starts at to reasonable default for API usage notifi…
Browse files Browse the repository at this point in the history
…cations (#4054)
  • Loading branch information
zachaysan authored May 30, 2024
1 parent 84c0835 commit 515b34c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions api/organisations/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from __future__ import unicode_literals

import logging
from datetime import timedelta

from app_analytics.influxdb_wrapper import (
get_events_for_organisation,
Expand Down Expand Up @@ -324,6 +325,10 @@ def get_queryset(self):
billing_starts_at = subscription_cache.current_billing_term_starts_at
now = timezone.now()

# Handle case where billing dates are not set by
# defaulting to something as a reasonable default.
billing_starts_at = billing_starts_at or now - timedelta(days=30)

month_delta = relativedelta(now, billing_starts_at).months
period_starts_at = relativedelta(months=month_delta) + billing_starts_at

Expand Down

0 comments on commit 515b34c

Please sign in to comment.