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


Python CreditLine.add_rate_credit方法代码示例

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


在下文中一共展示了CreditLine.add_rate_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_rate_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
开发者ID:dszafranek,项目名称:commcare-hq,代码行数:30,代码来源:test_credit_lines.py

示例2: add_feature_rate

# 需要导入模块: from corehq.apps.accounting.models import CreditLine [as 别名]
# 或者: from corehq.apps.accounting.models.CreditLine import add_rate_credit [as 别名]
 def add_feature_rate():
     CreditLine.add_rate_credit(
         amount,
         get_account_for_rate(),
         feature_rate=FeatureRate.objects.get(id=self.cleaned_data["feature_rate"]),
         subscription=subscription,
         note=note,
     )
开发者ID:pawelreise,项目名称:commcare-hq,代码行数:10,代码来源:forms.py

示例3: add_product_rate

# 需要导入模块: from corehq.apps.accounting.models import CreditLine [as 别名]
# 或者: from corehq.apps.accounting.models.CreditLine import add_rate_credit [as 别名]
 def add_product_rate():
     CreditLine.add_rate_credit(
         amount,
         get_account_for_rate(),
         product_rate=SoftwareProductRate.objects.get(id=self.cleaned_data["product_rate"]),
         subscription=subscription,
         note=note,
     )
开发者ID:pawelreise,项目名称:commcare-hq,代码行数:10,代码来源:forms.py

示例4: test_balance_adjustment

# 需要导入模块: from corehq.apps.accounting.models import CreditLine [as 别名]
# 或者: from corehq.apps.accounting.models.CreditLine import add_rate_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)
开发者ID:dszafranek,项目名称:commcare-hq,代码行数:46,代码来源:test_credit_lines.py


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