本文整理汇总了Python中corehq.apps.accounting.models.CreditLine.add_subscription_credit方法的典型用法代码示例。如果您正苦于以下问题:Python CreditLine.add_subscription_credit方法的具体用法?Python CreditLine.add_subscription_credit怎么用?Python CreditLine.add_subscription_credit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类corehq.apps.accounting.models.CreditLine
的用法示例。
在下文中一共展示了CreditLine.add_subscription_credit方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _generate_rate_credits_for_testing
# 需要导入模块: from corehq.apps.accounting.models import CreditLine [as 别名]
# 或者: from corehq.apps.accounting.models.CreditLine import add_subscription_credit [as 别名]
def _generate_rate_credits_for_testing(self, fee, rate_kwarg, generate_invoice_credit=True):
"""
Generates enough line item credit for two invoicing periods.
"""
rate_credit_by_account = CreditLine.add_rate_credit(
fee,
self.account,
**rate_kwarg
)
self.assertEqual(CreditAdjustment.objects.filter(credit_line=rate_credit_by_account).count(), 1)
rate_credit_by_subscription = CreditLine.add_rate_credit(
fee,
self.account,
subscription=self.subscription,
**rate_kwarg
)
self.assertEqual(CreditAdjustment.objects.filter(credit_line=rate_credit_by_subscription).count(), 1)
if generate_invoice_credit:
# this credit should not count toward the line item
subscription_credit = CreditLine.add_subscription_credit(
fee,
self.subscription
)
self.assertEqual(CreditAdjustment.objects.filter(credit_line=subscription_credit).count(), 1)
return rate_credit_by_account, rate_credit_by_subscription
示例2: test_balance_adjustment
# 需要导入模块: from corehq.apps.accounting.models import CreditLine [as 别名]
# 或者: from corehq.apps.accounting.models.CreditLine import add_subscription_credit [as 别名]
def test_balance_adjustment(self):
"""
Makes sure that the balance is added to the same invoice and same line item credit.
"""
product_credit = CreditLine.add_rate_credit(
self.product_rate.monthly_fee,
self.account,
product_rate=self.product_rate,
)
self.assertEqual(CreditAdjustment.objects.filter(credit_line=product_credit).count(), 1)
CreditLine.add_rate_credit(
self.product_rate.monthly_fee,
self.account,
product_rate=self.product_rate,
)
self.assertEqual(CreditAdjustment.objects.filter(credit_line=product_credit).count(), 2)
current_product_credit = CreditLine.objects.get(id=product_credit.id)
self.assertEqual(current_product_credit.balance, self.product_rate.monthly_fee * 2)
subscription_credit = CreditLine.add_subscription_credit(
self.monthly_user_fee,
self.subscription
)
self.assertEqual(CreditAdjustment.objects.filter(credit_line=subscription_credit).count(), 1)
CreditLine.add_subscription_credit(
self.monthly_user_fee,
self.subscription
)
self.assertEqual(CreditAdjustment.objects.filter(credit_line=subscription_credit).count(), 2)
current_subscription_credit = CreditLine.objects.get(id=subscription_credit.id)
self.assertEqual(current_subscription_credit.balance, self.monthly_user_fee * 2)
account_credit = CreditLine.add_account_credit(
self.product_rate.monthly_fee,
self.account
)
self.assertEqual(CreditAdjustment.objects.filter(credit_line=account_credit).count(), 1)
CreditLine.add_account_credit(
self.monthly_user_fee,
self.account
)
self.assertEqual(CreditAdjustment.objects.filter(credit_line=account_credit).count(), 2)
current_account_credit = CreditLine.objects.get(id=account_credit.id)
self.assertEqual(current_account_credit.balance, self.product_rate.monthly_fee + self.monthly_user_fee)
示例3: _generate_subscription_and_account_invoice_credits
# 需要导入模块: from corehq.apps.accounting.models import CreditLine [as 别名]
# 或者: from corehq.apps.accounting.models.CreditLine import add_subscription_credit [as 别名]
def _generate_subscription_and_account_invoice_credits(self, monthly_fee, subscription, account):
subscription_credit = CreditLine.add_subscription_credit(
monthly_fee,
subscription
)
self.assertEqual(CreditAdjustment.objects.filter(credit_line=subscription_credit).count(), 1)
account_credit = CreditLine.add_account_credit(
monthly_fee,
account
)
self.assertEqual(CreditAdjustment.objects.filter(credit_line=account_credit).count(), 1)
return subscription_credit, account_credit
示例4: add_subscription_level
# 需要导入模块: from corehq.apps.accounting.models import CreditLine [as 别名]
# 或者: from corehq.apps.accounting.models.CreditLine import add_subscription_credit [as 别名]
def add_subscription_level():
CreditLine.add_subscription_credit(amount, subscription,
note=note)