本文整理汇总了Python中corehq.apps.accounting.models.BillingAccount类的典型用法代码示例。如果您正苦于以下问题:Python BillingAccount类的具体用法?Python BillingAccount怎么用?Python BillingAccount使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BillingAccount类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
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)
示例2: setUp
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
示例3: create_account
def create_account(self):
name = self.cleaned_data['name']
salesforce_account_id = self.cleaned_data['salesforce_account_id']
currency, _ = Currency.objects.get_or_create(code=self.cleaned_data['currency'])
account = BillingAccount(name=name,
salesforce_account_id=salesforce_account_id,
currency=currency)
account.save()
return account
示例4: billing_account
def billing_account(web_user_creator, web_user_contact, currency=None, save=True):
account_name = data_gen.arbitrary_unique_name(prefix="BA")[:40]
currency = currency or Currency.objects.get(code=settings.DEFAULT_CURRENCY)
billing_account = BillingAccount(name=account_name, created_by=web_user_creator.username, currency=currency)
if save:
billing_account.save()
billing_contact = arbitrary_contact_info(billing_account, web_user_contact)
billing_contact.save()
return billing_account
示例5: create_account
def create_account(self):
name = self.cleaned_data["name"]
salesforce_account_id = self.cleaned_data["salesforce_account_id"]
currency, _ = Currency.objects.get_or_create(code=self.cleaned_data["currency"])
account = BillingAccount(name=name, salesforce_account_id=salesforce_account_id, currency=currency)
account.save()
contact_info, _ = BillingContactInfo.objects.get_or_create(account=account)
contact_info.emails = self.cleaned_data["contact_emails"]
contact_info.save()
return account
示例6: handle
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
示例7: setUp
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()
示例8: update_credits
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,
)
示例9: setUp
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]
示例10: email_enterprise_report
def email_enterprise_report(domain, slug, couch_user):
account = BillingAccount.get_account_by_domain(domain)
report = EnterpriseReport.create(slug, account.id, couch_user)
# Generate file
csv_file = io.StringIO()
writer = csv.writer(csv_file)
writer.writerow(report.headers)
writer.writerows(report.rows)
# Store file in redis
hash_id = uuid.uuid4().hex
redis = get_redis_client()
redis.set(hash_id, csv_file.getvalue())
redis.expire(hash_id, 60 * 60 * 24)
csv_file.close()
# Send email
url = absolute_reverse("enterprise_dashboard_download", args=[domain, report.slug, str(hash_id)])
link = "<a href='{}'>{}</a>".format(url, url)
subject = _("Enterprise Dashboard: {}").format(report.title)
body = "The enterprise report you requested for the account {} is ready.<br>" \
"You can download the data at the following link: {}<br><br>" \
"Please remember that this link will only be active for 24 hours.".format(account.name, link)
send_html_email_async(subject, couch_user.username, body)
示例11: assign_explicit_community_subscription
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,
)
示例12: account
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
示例13: setUp
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()
示例14: setUp
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()
示例15: setUp
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',
)