mirror of https://github.com/zulip/zulip.git
billing: Show correct info for to be upgraded legacy plan server.
This commit is contained in:
parent
f5a96cba05
commit
ec7fd94782
|
@ -1570,6 +1570,16 @@ class BillingSession(ABC):
|
||||||
return None, None
|
return None, None
|
||||||
return None, last_ledger_entry
|
return None, last_ledger_entry
|
||||||
|
|
||||||
|
def get_next_plan(self, plan: CustomerPlan) -> Optional[CustomerPlan]: # nocoverage
|
||||||
|
if plan.status == CustomerPlan.SWITCH_PLAN_TIER_AT_PLAN_END:
|
||||||
|
assert plan.end_date is not None
|
||||||
|
return CustomerPlan.objects.filter(
|
||||||
|
customer=plan.customer,
|
||||||
|
billing_cycle_anchor=plan.end_date,
|
||||||
|
status=CustomerPlan.NEVER_STARTED,
|
||||||
|
).first()
|
||||||
|
return None
|
||||||
|
|
||||||
def get_billing_context_from_plan(
|
def get_billing_context_from_plan(
|
||||||
self,
|
self,
|
||||||
customer: Customer,
|
customer: Customer,
|
||||||
|
@ -1682,6 +1692,27 @@ class BillingSession(ABC):
|
||||||
plan = new_plan if new_plan is not None else plan
|
plan = new_plan if new_plan is not None else plan
|
||||||
|
|
||||||
context = self.get_billing_context_from_plan(customer, plan, last_ledger_entry, now)
|
context = self.get_billing_context_from_plan(customer, plan, last_ledger_entry, now)
|
||||||
|
|
||||||
|
next_plan = self.get_next_plan(plan)
|
||||||
|
if next_plan is not None: # nocoverage
|
||||||
|
next_plan_context = self.get_billing_context_from_plan(
|
||||||
|
customer, next_plan, last_ledger_entry, now
|
||||||
|
)
|
||||||
|
# Settings we want to display from the next plan instead of the current one.
|
||||||
|
# HACK: Our billing page is not designed to handle two plans, so while this is hacky,
|
||||||
|
# it's the easiest way to get the UI we want without making things too complicated for us.
|
||||||
|
keys = [
|
||||||
|
"renewal_amount",
|
||||||
|
"payment_method",
|
||||||
|
"charge_automatically",
|
||||||
|
"billing_frequency",
|
||||||
|
"fixed_price",
|
||||||
|
"price_per_license",
|
||||||
|
"discount_percent",
|
||||||
|
]
|
||||||
|
|
||||||
|
for key in keys:
|
||||||
|
context[key] = next_plan_context[key]
|
||||||
return context
|
return context
|
||||||
|
|
||||||
def get_initial_upgrade_context(
|
def get_initial_upgrade_context(
|
||||||
|
|
Loading…
Reference in New Issue