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


Python BillingAccount.get_or_create_account_by_domain方法代码示例

本文整理汇总了Python中corehq.apps.accounting.models.BillingAccount.get_or_create_account_by_domain方法的典型用法代码示例。如果您正苦于以下问题:Python BillingAccount.get_or_create_account_by_domain方法的具体用法?Python BillingAccount.get_or_create_account_by_domain怎么用?Python BillingAccount.get_or_create_account_by_domain使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在corehq.apps.accounting.models.BillingAccount的用法示例。


在下文中一共展示了BillingAccount.get_or_create_account_by_domain方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setUp

# 需要导入模块: from corehq.apps.accounting.models import BillingAccount [as 别名]
# 或者: from corehq.apps.accounting.models.BillingAccount import get_or_create_account_by_domain [as 别名]
    def setUp(self):
        super(TestNewDomainSubscription, self).setUp()
        self.domain = Domain(
            name="test-domain-sub",
            is_active=True,
        )
        self.domain.save()

        self.domain2 = Domain(
            name="test-domain-sub2",
            is_active=True,
        )
        self.domain2.save()

        self.admin_user = generator.arbitrary_web_user()
        self.admin_user.add_domain_membership(self.domain.name, is_admin=True)
        self.admin_user.save()

        self.account = BillingAccount.get_or_create_account_by_domain(
            self.domain.name, created_by=self.admin_user.username)[0]
        self.account2 = BillingAccount.get_or_create_account_by_domain(
            self.domain2.name, created_by=self.admin_user.username)[0]
        self.standard_plan = DefaultProductPlan.get_default_plan_by_domain(
            self.domain.name, edition=SoftwarePlanEdition.STANDARD)
        self.advanced_plan = DefaultProductPlan.get_default_plan_by_domain(
            self.domain.name, edition=SoftwarePlanEdition.ADVANCED)
开发者ID:SEL-Columbia,项目名称:commcare-hq,代码行数:28,代码来源:test_new_domain_subscription.py

示例2: setUp

# 需要导入模块: from corehq.apps.accounting.models import BillingAccount [as 别名]
# 或者: from corehq.apps.accounting.models.BillingAccount import get_or_create_account_by_domain [as 别名]
    def setUp(self):
        super(TestSubscriptionForm, self).setUp()

        self.domain = Domain(
            name="test-sub-form",
            is_active=True
        )
        self.domain.save()
        self.domain2 = Domain(
            name="test-sub-form-2",
            is_active=True
        )
        self.domain2.save()

        self.web_user = WebUser.create(
            self.domain.name, generator.create_arbitrary_web_user_name(), 'testpwd'
        )

        self.account = BillingAccount.get_or_create_account_by_domain(
            self.domain.name, created_by=self.web_user.username
        )[0]
        self.account.save()
        self.customer_account = BillingAccount.get_or_create_account_by_domain(
            self.domain2.name, created_by=self.web_user.username
        )[0]
        self.customer_account.is_customer_billing_account = True
        self.customer_account.save()

        self.plan = DefaultProductPlan.get_default_plan_version(edition=SoftwarePlanEdition.ADVANCED)
        self.customer_plan = DefaultProductPlan.get_default_plan_version(edition=SoftwarePlanEdition.ADVANCED)
        self.customer_plan.plan.is_customer_software_plan = True
开发者ID:dimagi,项目名称:commcare-hq,代码行数:33,代码来源:test_forms.py

示例3: setUp

# 需要导入模块: from corehq.apps.accounting.models import BillingAccount [as 别名]
# 或者: from corehq.apps.accounting.models.BillingAccount import get_or_create_account_by_domain [as 别名]
    def setUp(self):
        super(OptTestCase, self).setUp()
        self.domain = "opt-test"

        self.domain_obj = Domain(name=self.domain)
        self.domain_obj.save()

        generator.instantiate_accounting_for_tests()
        self.account = BillingAccount.get_or_create_account_by_domain(
            self.domain_obj.name,
            created_by="automated-test",
        )[0]
        plan = DefaultProductPlan.get_default_plan_by_domain(
            self.domain_obj, edition=SoftwarePlanEdition.ADVANCED
        )
        self.subscription = Subscription.new_domain_subscription(
            self.account,
            self.domain_obj.name,
            plan
        )
        self.subscription.is_active = True
        self.subscription.save()

        self.backend = TestSMSBackend(is_global=True)
        self.backend.save()

        self.backend_mapping = BackendMapping(
            is_global=True,
            prefix="*",
            backend_id=self.backend._id,
        )
        self.backend_mapping.save()
开发者ID:LifeCoaching,项目名称:commcare-hq,代码行数:34,代码来源:opt_tests.py

示例4: update_credits

# 需要导入模块: from corehq.apps.accounting.models import BillingAccount [as 别名]
# 或者: from corehq.apps.accounting.models.BillingAccount import get_or_create_account_by_domain [as 别名]
 def update_credits(self, payment_record):
     amount = payment_record.amount
     for invoice in self.invoices:
         deduct_amount = min(amount, invoice.balance)
         amount -= deduct_amount
         if deduct_amount > 0:
             if self.account and self.account.is_customer_billing_account:
                 customer_invoice = invoice
                 subscription_invoice = None
                 account = self.account
             else:
                 customer_invoice = None
                 subscription_invoice = invoice
                 account = invoice.subscription.account
             # TODO - refactor duplicated functionality
             CreditLine.add_credit(
                 deduct_amount,
                 account=account,
                 payment_record=payment_record,
             )
             CreditLine.add_credit(
                 -deduct_amount,
                 account=account,
                 invoice=subscription_invoice,
                 customer_invoice=customer_invoice
             )
             invoice.update_balance()
             invoice.save()
     if amount:
         account = BillingAccount.get_or_create_account_by_domain(self.domain)[0]
         CreditLine.add_credit(
             amount, account=account,
             payment_record=payment_record,
         )
开发者ID:dimagi,项目名称:commcare-hq,代码行数:36,代码来源:payment_handlers.py

示例5: setUp

# 需要导入模块: from corehq.apps.accounting.models import BillingAccount [as 别名]
# 或者: from corehq.apps.accounting.models.BillingAccount import get_or_create_account_by_domain [as 别名]
 def setUp(self):
     super(TestCreditTransfers, self).setUp()
     self.product_credit_amt = Decimal("500.00")
     self.feature_credit_amt = Decimal("200.00")
     self.subscription_credit_amt = Decimal("600.00")
     self.domain = generator.arbitrary_domain()
     self.account = BillingAccount.get_or_create_account_by_domain(self.domain, created_by="[email protected]")[0]
开发者ID:bazuzi,项目名称:commcare-hq,代码行数:9,代码来源:test_credit_lines.py

示例6: assign_explicit_community_subscription

# 需要导入模块: from corehq.apps.accounting.models import BillingAccount [as 别名]
# 或者: from corehq.apps.accounting.models.BillingAccount import get_or_create_account_by_domain [as 别名]
def assign_explicit_community_subscription(domain_name, start_date, method, account=None, web_user=None):
    future_subscriptions = Subscription.visible_objects.filter(
        date_start__gt=start_date,
        subscriber__domain=domain_name,
    )
    if future_subscriptions.exists():
        end_date = future_subscriptions.earliest('date_start').date_start
    else:
        end_date = None

    if account is None:
        account = BillingAccount.get_or_create_account_by_domain(
            domain_name,
            created_by='assign_explicit_community_subscriptions',
            entry_point=EntryPoint.SELF_STARTED,
        )[0]

    return Subscription.new_domain_subscription(
        account=account,
        domain=domain_name,
        plan_version=DefaultProductPlan.get_default_plan_version(),
        date_start=start_date,
        date_end=end_date,
        skip_invoicing_if_no_feature_charges=True,
        adjustment_method=method,
        internal_change=True,
        service_type=SubscriptionType.PRODUCT,
        web_user=web_user,
    )
开发者ID:kkrampa,项目名称:commcare-hq,代码行数:31,代码来源:tasks.py

示例7: account

# 需要导入模块: from corehq.apps.accounting.models import BillingAccount [as 别名]
# 或者: from corehq.apps.accounting.models.BillingAccount import get_or_create_account_by_domain [as 别名]
 def account(self):
     """
     First try to grab the account used for the last subscription.
     If an account is not found, create it.
     """
     account, _ = BillingAccount.get_or_create_account_by_domain(self.domain.name, self.__class__.__name__)
     return account
开发者ID:dszafranek,项目名称:commcare-hq,代码行数:9,代码来源:invoicing.py

示例8: handle

# 需要导入模块: from corehq.apps.accounting.models import BillingAccount [as 别名]
# 或者: from corehq.apps.accounting.models.BillingAccount import get_or_create_account_by_domain [as 别名]
 def handle(self, *args, **options):
     if len(args) != 1:
         print "Invalid arguments: %s" % str(args)
         return
     domain = Domain.get_by_name(args[0])
     if not domain:
         print "Invalid domain name: %s" % args[0]
         return
     account, _ = BillingAccount.get_or_create_account_by_domain(
         domain.name,
         account_type=BillingAccountType.CONTRACT,
         created_by="management command",
     )
     enterprise_plan_version = SoftwarePlanVersion.objects.filter(
         plan__edition=SoftwarePlanEdition.ENTERPRISE
     )[0]
     try:
         subscription = Subscription.new_domain_subscription(
             account,
             domain.name,
             enterprise_plan_version
         )
     except NewSubscriptionError as e:
         print e.message
         return
     subscription.is_active = True
     subscription.save()
     print 'Domain %s has been upgraded to enterprise level.' % domain.name
开发者ID:LifeCoaching,项目名称:commcare-hq,代码行数:30,代码来源:make_domain_enterprise_level.py

示例9: setUp

# 需要导入模块: from corehq.apps.accounting.models import BillingAccount [as 别名]
# 或者: from corehq.apps.accounting.models.BillingAccount import get_or_create_account_by_domain [as 别名]
    def setUp(self):
        super(TestRenewSubscriptions, self).setUp()
        self.domain = Domain(
            name="test-domain-sub",
            is_active=True,
        )
        self.domain.save()

        self.admin_user = generator.arbitrary_web_user()
        self.admin_user.add_domain_membership(self.domain.name, is_admin=True)
        self.admin_user.save()

        self.account = BillingAccount.get_or_create_account_by_domain(
            self.domain.name, created_by=self.admin_user.username)[0]

        self.standard_plan = DefaultProductPlan.get_default_plan_by_domain(
            self.domain.name, edition=SoftwarePlanEdition.STANDARD)

        today = datetime.date.today()
        yesterday = today + datetime.timedelta(days=-1)
        tomorrow = today + datetime.timedelta(days=1)

        self.subscription = Subscription.new_domain_subscription(
            self.account,
            self.domain.name,
            self.standard_plan,
            web_user=self.admin_user.username,
            date_start=yesterday,
            date_end=tomorrow,
        )

        self.subscription.save()
开发者ID:tlwakwella,项目名称:commcare-hq,代码行数:34,代码来源:test_renew_subscription.py

示例10: setUp

# 需要导入模块: from corehq.apps.accounting.models import BillingAccount [as 别名]
# 或者: from corehq.apps.accounting.models.BillingAccount import get_or_create_account_by_domain [as 别名]
    def setUp(self):
        super(BaseReminderTestCase, self).setUp()
        self.domain_obj = Domain(name="test")
        self.domain_obj.save()
        # Prevent resource conflict
        self.domain_obj = Domain.get(self.domain_obj._id)

        self.account, _ = BillingAccount.get_or_create_account_by_domain(
            self.domain_obj.name,
            created_by="tests"
        )
        advanced_plan_version = DefaultProductPlan.get_default_plan_by_domain(
            self.domain_obj, edition=SoftwarePlanEdition.ADVANCED)
        self.subscription = Subscription.new_domain_subscription(
            self.account,
            self.domain_obj.name,
            advanced_plan_version
        )
        self.subscription.is_active = True
        self.subscription.save()

        self.sms_backend = TestSMSBackend(named="MOBILE_BACKEND_TEST", is_global=True)
        self.sms_backend.save()

        self.sms_backend_mapping = BackendMapping(is_global=True,prefix="*",backend_id=self.sms_backend._id)
        self.sms_backend_mapping.save()
开发者ID:puttarajubr,项目名称:commcare-hq,代码行数:28,代码来源:__init__.py

示例11: setUp

# 需要导入模块: from corehq.apps.accounting.models import BillingAccount [as 别名]
# 或者: from corehq.apps.accounting.models.BillingAccount import get_or_create_account_by_domain [as 别名]
    def setUp(self):
        super(TestUserRoleSubscriptionChanges, self).setUp()
        self.domain = generator.arbitrary_domain()
        UserRole.init_domain_with_presets(self.domain.name)
        self.user_roles = UserRole.by_domain(self.domain.name)
        self.custom_role = UserRole.get_or_create_with_permissions(
            self.domain.name,
            Permissions(edit_apps=True, edit_web_users=True),
            "Custom Role"
        )
        self.custom_role.save()
        self.read_only_role = UserRole.get_read_only_role_by_domain(self.domain.name)

        self.admin_user = generator.arbitrary_web_user()
        self.admin_user.add_domain_membership(self.domain.name, is_admin=True)
        self.admin_user.save()

        self.web_users = []
        self.commcare_users = []
        for role in [self.custom_role] + self.user_roles:
            web_user = generator.arbitrary_web_user()
            web_user.add_domain_membership(self.domain.name, role_id=role.get_id)
            web_user.save()
            self.web_users.append(web_user)

            commcare_user = generator.arbitrary_commcare_user(
                domain=self.domain.name)
            commcare_user.set_role(self.domain.name, role.get_qualified_id())
            commcare_user.save()
            self.commcare_users.append(commcare_user)

        self.account = BillingAccount.get_or_create_account_by_domain(
            self.domain.name,created_by=self.admin_user.username)[0]
        self.advanced_plan = DefaultProductPlan.get_default_plan_by_domain(
            self.domain.name,edition=SoftwarePlanEdition.ADVANCED)
开发者ID:pawelreise,项目名称:commcare-hq,代码行数:37,代码来源:test_subscription_changes.py

示例12: create_domain

# 需要导入模块: from corehq.apps.accounting.models import BillingAccount [as 别名]
# 或者: from corehq.apps.accounting.models.BillingAccount import get_or_create_account_by_domain [as 别名]
    def create_domain(self, domain):
        domain_obj = Domain(name=domain)
        domain_obj.use_default_sms_response = True
        domain_obj.default_sms_response = "Default SMS Response"
        domain_obj.save()

        # I tried making this class inherit from BaseSMSTest, but somehow
        # the multiple inheritance was causing the postgres connection to
        # get in a weird state where it wasn't commiting any changes. So
        # for now, keeping this subscription setup code as is.
        generator.instantiate_accounting_for_tests()
        self.account = BillingAccount.get_or_create_account_by_domain(
            domain_obj.name,
            created_by="automated-test",
        )[0]
        plan = DefaultProductPlan.get_default_plan_by_domain(
            domain_obj, edition=SoftwarePlanEdition.ADVANCED
        )
        self.subscription = Subscription.new_domain_subscription(
            self.account,
            domain_obj.name,
            plan
        )
        self.subscription.is_active = True
        self.subscription.save()
        return domain_obj
开发者ID:johan--,项目名称:commcare-hq,代码行数:28,代码来源:util.py

示例13: create_wire_credits_invoice

# 需要导入模块: from corehq.apps.accounting.models import BillingAccount [as 别名]
# 或者: from corehq.apps.accounting.models.BillingAccount import get_or_create_account_by_domain [as 别名]
def create_wire_credits_invoice(domain_name,
                                account_created_by,
                                account_entry_point,
                                amount,
                                invoice_items,
                                contact_emails):
    account = BillingAccount.get_or_create_account_by_domain(
        domain_name,
        created_by=account_created_by,
        created_by_invoicing=True,
        entry_point=account_entry_point
    )[0]
    wire_invoice = WirePrepaymentInvoice.objects.create(
        domain=domain_name,
        date_start=datetime.datetime.utcnow(),
        date_end=datetime.datetime.utcnow(),
        date_due=None,
        balance=amount,
        account=account,
    )
    wire_invoice.items = invoice_items

    record = WirePrepaymentBillingRecord.generate_record(wire_invoice)
    try:
        record.send_email(contact_emails=contact_emails)
    except Exception as e:
        logger.error("[BILLING] %s" % e)
开发者ID:sheelio,项目名称:commcare-hq,代码行数:29,代码来源:tasks.py

示例14: setUp

# 需要导入模块: from corehq.apps.accounting.models import BillingAccount [as 别名]
# 或者: from corehq.apps.accounting.models.BillingAccount import get_or_create_account_by_domain [as 别名]
    def setUp(self):
        super(TestDeleteDomain, self).setUp()
        self.domain = Domain(name="test", is_active=True)
        self.domain.save()
        self.domain.convert_to_commtrack()
        self.current_subscription = Subscription.new_domain_subscription(
            BillingAccount.get_or_create_account_by_domain(self.domain.name, created_by='tests')[0],
            self.domain.name,
            DefaultProductPlan.get_default_plan_version(SoftwarePlanEdition.ADVANCED),
            date_start=date.today() - relativedelta(days=1),
        )

        self.domain2 = Domain(name="test2", is_active=True)
        self.domain2.save()
        self.domain2.convert_to_commtrack()

        LocationType.objects.create(
            domain='test',
            name='facility',
        )
        LocationType.objects.create(
            domain='test2',
            name='facility',
        )
        LocationType.objects.create(
            domain='test',
            name='facility2',
        )
        LocationType.objects.create(
            domain='test2',
            name='facility2',
        )
开发者ID:kkrampa,项目名称:commcare-hq,代码行数:34,代码来源:test_delete_domain.py

示例15: ensure_full_coverage

# 需要导入模块: from corehq.apps.accounting.models import BillingAccount [as 别名]
# 或者: from corehq.apps.accounting.models.BillingAccount import get_or_create_account_by_domain [as 别名]
 def ensure_full_coverage(self, subscriptions):
     plan_version = DefaultProductPlan.get_default_plan_by_domain(
         self.domain, edition=SoftwarePlanEdition.COMMUNITY
     ).plan.get_version()
     if not plan_version.feature_charges_exist_for_domain(self.domain):
         return
     community_ranges = self.get_community_ranges(subscriptions)
     if not community_ranges:
         return
     do_not_invoice = any([s.do_not_invoice for s in subscriptions])
     account = BillingAccount.get_or_create_account_by_domain(
         self.domain.name, created_by=self.__class__.__name__,
         created_by_invoicing=True)[0]
     if account.date_confirmed_extra_charges is None:
         if self.domain.is_active:
             subject = "[%s] Invoice Generation Issue" % self.domain.name
             email_content = render_to_string(
                 'accounting/invoice_error_email.html', {
                     'project': self.domain.name,
                     'error_msg': "This project is incurring charges on their "
                                  "Community subscription, but they haven't "
                                  "agreed to the charges yet. Someone should "
                                  "follow up with this project to see if everything "
                                  "is configured correctly or if communication "
                                  "needs to happen between Dimagi and the project's"
                                  "admins. For now, the invoices generated are "
                                  "marked as Do Not Invoice.",
                 }
             )
             send_HTML_email(
                 subject, settings.BILLING_EMAIL, email_content,
                 email_from="Dimagi Billing Bot <%s>" % settings.DEFAULT_FROM_EMAIL
             )
         do_not_invoice = True
     if not BillingContactInfo.objects.filter(account=account).exists():
         # No contact information exists for this account.
         # This shouldn't happen, but if it does, we can't continue
         # with the invoice generation.
         raise BillingContactInfoError(
             "Project %s has incurred charges, but does not have their "
             "Billing Contact Info filled out. Someone should follow up "
             "on this." % self.domain.name
         )
     # First check to make sure none of the existing subscriptions is set
     # to do not invoice. Let's be on the safe side and not send a
     # community invoice out, if that's the case.
     for c in community_ranges:
         # create a new community subscription for each
         # date range that the domain did not have a subscription
         community_subscription = Subscription(
             account=account,
             plan_version=plan_version,
             subscriber=self.subscriber,
             date_start=c[0],
             date_end=c[1],
             do_not_invoice=do_not_invoice,
         )
         community_subscription.save()
         subscriptions.append(community_subscription)
开发者ID:SEL-Columbia,项目名称:commcare-hq,代码行数:61,代码来源:invoicing.py


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