From fce50bb4a07d9fa60b365702c2dd6be352c84391 Mon Sep 17 00:00:00 2001 From: Prakhar Pratyush Date: Wed, 31 Jan 2024 12:50:26 +0530 Subject: [PATCH] populate_billing_realms: Add legacy remote realm. --- .../commands/populate_billing_realms.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/zilencer/management/commands/populate_billing_realms.py b/zilencer/management/commands/populate_billing_realms.py index 2ab02ff2d9..d7ad80d8d7 100644 --- a/zilencer/management/commands/populate_billing_realms.py +++ b/zilencer/management/commands/populate_billing_realms.py @@ -198,6 +198,11 @@ class Command(BaseCommand): is_sponsored=True, is_remote_server=True, ), + CustomerProfile( + unique_id="legacy-remote-realm", + tier=CustomerPlan.TIER_SELF_HOSTED_LEGACY, + is_remote_realm=True, + ), CustomerProfile( unique_id="free-tier-remote-realm", is_remote_realm=True, @@ -553,7 +558,15 @@ def populate_remote_realms(customer_profile: CustomerProfile) -> Dict[str, str]: else: customer = billing_session.update_or_create_customer() add_card_to_customer(customer) - if customer_profile.tier is not None: + if customer_profile.tier == CustomerPlan.TIER_SELF_HOSTED_LEGACY: + renewal_date = datetime.strptime(customer_profile.renewal_date, TIMESTAMP_FORMAT).replace( + tzinfo=timezone.utc + ) + end_date = datetime.strptime(customer_profile.end_date, TIMESTAMP_FORMAT).replace( + tzinfo=timezone.utc + ) + billing_session.migrate_customer_to_legacy_plan(renewal_date, end_date) + elif customer_profile.tier is not None: billing_session.do_change_plan_type( tier=customer_profile.tier, is_sponsored=customer_profile.is_sponsored )