Skip to content

Commit

Permalink
fix: Set billing term starts at 30 days for null values (#4053)
Browse files Browse the repository at this point in the history
  • Loading branch information
zachaysan authored May 30, 2024
1 parent a9c3110 commit 84c0835
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions api/app_analytics/analytics_db_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ def get_usage_data(
if not getattr(organisation, "subscription_information_cache", None):
return []
sub_cache = organisation.subscription_information_cache
starts_at = sub_cache.current_billing_term_starts_at
starts_at = sub_cache.current_billing_term_starts_at or now - timedelta(
days=30
)
month_delta = relativedelta(now, starts_at).months
period_starts_at = relativedelta(months=month_delta) + starts_at
period_ends_at = now
Expand All @@ -54,7 +56,9 @@ def get_usage_data(
if not getattr(organisation, "subscription_information_cache", None):
return []
sub_cache = organisation.subscription_information_cache
starts_at = sub_cache.current_billing_term_starts_at
starts_at = sub_cache.current_billing_term_starts_at or now - timedelta(
days=30
)
month_delta = relativedelta(now, starts_at).months - 1
month_delta += relativedelta(now, starts_at).years * 12
period_starts_at = relativedelta(months=month_delta) + starts_at
Expand Down

0 comments on commit 84c0835

Please sign in to comment.