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


Python SmsGatewayFee.get_by_criteria方法代码示例

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


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

示例1: get_rate_response

# 需要导入模块: from corehq.apps.smsbillables.models import SmsGatewayFee [as 别名]
# 或者: from corehq.apps.smsbillables.models.SmsGatewayFee import get_by_criteria [as 别名]
    def get_rate_response(self):
        gateway = self.data.get('gateway')
        try:
            backend_api_id = SQLMobileBackend.get_backend_api_id(gateway, is_couch_id=True)
        except Exception as e:
            log_smsbillables_error(
                "Failed to get backend for calculating an sms rate due to: %s"
                % e
            )
            raise SMSRateCalculatorError("Could not obtain connection information.")

        country_code = self.data.get('country_code')
        if country_code == NONMATCHING_COUNTRY:
            country_code = None
        direction = self.data.get('direction')

        gateway_fee = SmsGatewayFee.get_by_criteria(
            backend_api_id, direction, backend_instance=gateway,
            country_code=country_code,
        )
        usage_fee = SmsUsageFee.get_by_criteria(direction, self.request.domain)
        usd_gateway_fee = gateway_fee.amount / gateway_fee.currency.rate_to_default
        usd_total = usage_fee.amount + usd_gateway_fee

        return {
            'rate': _("%s per 160 character SMS") % fmt_dollar_amount(usd_total),
        }
开发者ID:tlwakwella,项目名称:commcare-hq,代码行数:29,代码来源:async_handlers.py

示例2: _directed_fee

# 需要导入模块: from corehq.apps.smsbillables.models import SmsGatewayFee [as 别名]
# 或者: from corehq.apps.smsbillables.models.SmsGatewayFee import get_by_criteria [as 别名]
 def _directed_fee(direction, backend_api_id, backend_instance_id):
     gateway_fee = SmsGatewayFee.get_by_criteria(
         backend_api_id, direction, backend_instance=backend_instance_id, country_code=country_code
     )
     if not gateway_fee or gateway_fee.amount is None:
         return None
     usd_gateway_fee = gateway_fee.amount / gateway_fee.currency.rate_to_default
     usage_fee = SmsUsageFee.get_by_criteria(direction)
     return fmt_dollar_amount(usage_fee.amount + usd_gateway_fee)
开发者ID:dimagi,项目名称:commcare-hq,代码行数:11,代码来源:async_handlers.py


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