Skip to content

Commit

Permalink
fix: sales dashboard subscription metadata shows wrong data after sta…
Browse files Browse the repository at this point in the history
…rting trial (#2962)
  • Loading branch information
matthewelwell authored Nov 13, 2023
1 parent b18e4a6 commit 9a49f7d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
19 changes: 8 additions & 11 deletions api/organisations/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,12 +228,12 @@ def get_portal_url(self, redirect_url):

def get_subscription_metadata(self) -> BaseSubscriptionMetadata:
metadata = None

if self.is_in_trial():
metadata = BaseSubscriptionMetadata(
seats=self.max_seats, api_calls=self.max_api_calls
)

if self.payment_method == CHARGEBEE and self.subscription_id:
elif self.payment_method == CHARGEBEE and self.subscription_id:
if self.organisation.has_subscription_information_cache():
# Getting the data from the subscription information cache because
# data is guaranteed to be up to date by using a Chargebee webhook.
Expand All @@ -247,17 +247,14 @@ def get_subscription_metadata(self) -> BaseSubscriptionMetadata:
metadata = get_subscription_metadata_from_id(self.subscription_id)
elif self.payment_method == XERO and self.subscription_id:
metadata = XeroSubscriptionMetadata(
seats=self.max_seats, api_calls=self.max_api_calls, projects=None
)

if not metadata:
metadata = BaseSubscriptionMetadata(
seats=self.max_seats,
api_calls=self.max_api_calls,
projects=MAX_PROJECTS_IN_FREE_PLAN,
seats=self.max_seats, api_calls=self.max_api_calls
)

return metadata
return metadata or BaseSubscriptionMetadata(
seats=self.max_seats,
api_calls=self.max_api_calls,
projects=MAX_PROJECTS_IN_FREE_PLAN,
)

def add_single_seat(self):
if not self.can_auto_upgrade_seats:
Expand Down
5 changes: 1 addition & 4 deletions api/sales_dashboard/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@
Organisation,
OrganisationSubscriptionInformationCache,
)
from organisations.subscriptions.subscription_service import (
get_subscription_metadata,
)
from organisations.tasks import (
update_organisation_subscription_information_cache,
update_organisation_subscription_information_influx_cache,
Expand Down Expand Up @@ -123,7 +120,7 @@ def organisation_info(request, organisation_id):
Organisation.objects.select_related("subscription"), pk=organisation_id
)
template = loader.get_template("sales_dashboard/organisation.html")
subscription_metadata = get_subscription_metadata(organisation)
subscription_metadata = organisation.subscription.get_subscription_metadata()

identity_count_dict = {}
identity_migration_status_dict = {}
Expand Down

0 comments on commit 9a49f7d

Please sign in to comment.