本文整理汇总了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),
}
示例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)