def create_30_day_advanced_trial(domain_obj):
    # Create a 30 Day Trial subscription to the Advanced Plan
    advanced_plan_version = DefaultProductPlan.get_default_plan_by_domain(
        domain_obj, edition=SoftwarePlanEdition.ADVANCED, is_trial=True
    )
    expiration_date = date.today() + timedelta(days=30)
    trial_account = BillingAccount.objects.get_or_create(
        name="Trial Account for %s" % domain_obj.name,
        currency=Currency.get_default(),
        created_by_domain=domain_obj.name,
        account_type=BillingAccountType.TRIAL,
        pre_or_post_pay=PreOrPostPay.POSTPAY,
    )[0]
    trial_subscription = Subscription.new_domain_subscription(
        trial_account, domain_obj.name, advanced_plan_version,
        date_end=expiration_date,
        adjustment_method=SubscriptionAdjustmentMethod.TRIAL,
        is_trial=True,
        service_type=SubscriptionType.TRIAL
    )
    trial_subscription.is_active = True
    trial_subscription.save()
dataset/ETHPy150Open dimagi/commcare-hq/corehq/apps/registration/utils.py/create_30_day_advanced_trial/original