当前位置: 首页>>代码示例>>Python>>正文


Python BillingAccount.create_account_for_domain方法代码示例

本文整理汇总了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,
    )
开发者ID:kkrampa,项目名称:commcare-hq,代码行数:34,代码来源:tasks.py


注:本文中的corehq.apps.accounting.models.BillingAccount.create_account_for_domain方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。