本文整理汇总了Python中corehq.apps.smsbillables.models.SmsBillable.save方法的典型用法代码示例。如果您正苦于以下问题:Python SmsBillable.save方法的具体用法?Python SmsBillable.save怎么用?Python SmsBillable.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类corehq.apps.smsbillables.models.SmsBillable
的用法示例。
在下文中一共展示了SmsBillable.save方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: arbitrary_sms_billables_for_domain
# 需要导入模块: from corehq.apps.smsbillables.models import SmsBillable [as 别名]
# 或者: from corehq.apps.smsbillables.models.SmsBillable import save [as 别名]
def arbitrary_sms_billables_for_domain(domain, message_month_date, num_sms, direction=None, multipart_count=1):
from corehq.apps.smsbillables.models import SmsBillable, SmsGatewayFee, SmsUsageFee
direction = direction or random.choice(DIRECTIONS)
gateway_fee = SmsGatewayFee.create_new('MACH', direction, Decimal(0.5))
usage_fee = SmsUsageFee.create_new(direction, Decimal(0.25))
_, last_day_message = calendar.monthrange(message_month_date.year, message_month_date.month)
billables = []
for _ in range(0, num_sms):
sms_billable = SmsBillable(
gateway_fee=gateway_fee,
usage_fee=usage_fee,
log_id=data_gen.arbitrary_unique_name()[:50],
phone_number=data_gen.random_phonenumber(),
domain=domain,
direction=direction,
date_sent=datetime.date(message_month_date.year, message_month_date.month,
random.randint(1, last_day_message)),
multipart_count=multipart_count,
)
sms_billable.save()
billables.append(sms_billable)
return billables
示例2: _get_updated_billable
# 需要导入模块: from corehq.apps.smsbillables.models import SmsBillable [as 别名]
# 或者: from corehq.apps.smsbillables.models.SmsBillable import save [as 别名]
def _get_updated_billable(self, old_billable, updated_currency):
new_billable = SmsBillable(
log_id=old_billable.log_id,
phone_number=old_billable.phone_number,
direction=old_billable.direction,
date_sent=old_billable.date_sent,
domain=old_billable.domain,
multipart_count=old_billable.multipart_count
)
new_billable.gateway_fee = old_billable.gateway_fee
new_billable.gateway_fee_conversion_rate = updated_currency.rate_to_default
new_billable.usage_fee = old_billable.usage_fee
new_billable.save()
return new_billable
示例3: arbitrary_sms_billables_for_domain
# 需要导入模块: from corehq.apps.smsbillables.models import SmsBillable [as 别名]
# 或者: from corehq.apps.smsbillables.models.SmsBillable import save [as 别名]
def arbitrary_sms_billables_for_domain(domain, direction, message_month_date, num_sms):
from corehq.apps.smsbillables.models import SmsBillable, SmsGatewayFee, SmsUsageFee
from corehq.apps.smsbillables import generator as sms_gen
gateway_fee = SmsGatewayFee.create_new('MACH', direction, sms_gen.arbitrary_fee())
usage_fee = SmsUsageFee.create_new(direction, sms_gen.arbitrary_fee())
_, last_day_message = calendar.monthrange(message_month_date.year, message_month_date.month)
for _ in range(0, num_sms):
sms_billable = SmsBillable(
gateway_fee=gateway_fee,
usage_fee=usage_fee,
log_id=data_gen.arbitrary_unique_name()[:50],
phone_number=data_gen.random_phonenumber(),
domain=domain,
direction=direction,
date_sent=datetime.date(message_month_date.year, message_month_date.month,
random.randint(1, last_day_message)),
)
sms_billable.save()