當前位置: 首頁>>代碼示例>>Python>>正文


Python SmsBillable.save方法代碼示例

本文整理匯總了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
開發者ID:saketkanth,項目名稱:commcare-hq,代碼行數:28,代碼來源:generator.py

示例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
開發者ID:saketkanth,項目名稱:commcare-hq,代碼行數:16,代碼來源:retrobill_india_unicel_03012016.py

示例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()
開發者ID:amonkeykong81,項目名稱:commcare-hq,代碼行數:23,代碼來源:generator.py


注:本文中的corehq.apps.smsbillables.models.SmsBillable.save方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。