Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: sales dashboard subscription metadata shows wrong data after starting trial #2962

Merged
merged 1 commit into from
Nov 13, 2023
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
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