本文整理汇总了Python中corehq.apps.accounting.models.BillingAccount.create_account_for_domain方法的典型用法代码示例。如果您正苦于以下问题:Python BillingAccount.create_account_for_domain方法的具体用法?Python BillingAccount.create_account_for_domain怎么用?Python BillingAccount.create_account_for_domain使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类corehq.apps.accounting.models.BillingAccount
的用法示例。
在下文中一共展示了BillingAccount.create_account_for_domain方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _deactivate_subscription
# 需要导入模块: from corehq.apps.accounting.models import BillingAccount [as 别名]
# 或者: from corehq.apps.accounting.models.BillingAccount import create_account_for_domain [as 别名]
def _deactivate_subscription(subscription):
subscription.is_active = False
subscription.save()
next_subscription = subscription.next_subscription
activate_next_subscription = next_subscription and next_subscription.date_start == subscription.date_end
if activate_next_subscription:
new_plan_version = next_subscription.plan_version
next_subscription.is_active = True
next_subscription.save()
else:
domain = subscription.subscriber.domain
if not subscription.account.is_customer_billing_account:
account = subscription.account
else:
account = BillingAccount.create_account_for_domain(
domain, created_by='default_community_after_customer_level'
)
next_subscription = assign_explicit_community_subscription(
domain, subscription.date_end, SubscriptionAdjustmentMethod.DEFAULT_COMMUNITY, account=account
)
new_plan_version = next_subscription.plan_version
_, downgraded_privs, upgraded_privs = get_change_status(subscription.plan_version, new_plan_version)
if subscription.account == next_subscription.account:
subscription.transfer_credits(subscription=next_subscription)
else:
subscription.transfer_credits()
subscription.subscriber.deactivate_subscription(
downgraded_privileges=downgraded_privs,
upgraded_privileges=upgraded_privs,
old_subscription=subscription,
new_subscription=next_subscription if activate_next_subscription else None,
)