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


Python SmsGatewayFee.create_new方法代码示例

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


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

示例1: bootstrap_smsgh_gateway

# 需要导入模块: from corehq.apps.smsbillables.models import SmsGatewayFee [as 别名]
# 或者: from corehq.apps.smsbillables.models.SmsGatewayFee import create_new [as 别名]
def bootstrap_smsgh_gateway(apps=None):
    default_currency, _ = (apps.get_model("accounting", "Currency") if apps else Currency).objects.get_or_create(
        code=settings.DEFAULT_CURRENCY
    )
    sms_gateway_fee_class = apps.get_model("smsbillables", "SmsGatewayFee") if apps else SmsGatewayFee
    sms_gateway_fee_criteria_class = (
        apps.get_model("smsbillables", "SmsGatewayFeeCriteria") if apps else SmsGatewayFeeCriteria
    )

    SmsGatewayFee.create_new(
        SMSGHBackend.get_api_id(),
        INCOMING,
        Decimal("0.0"),
        currency=default_currency,
        fee_class=sms_gateway_fee_class,
        criteria_class=sms_gateway_fee_criteria_class,
    )

    SmsGatewayFee.create_new(
        SMSGHBackend.get_api_id(),
        OUTGOING,
        Decimal("0.0"),
        currency=default_currency,
        fee_class=sms_gateway_fee_class,
        criteria_class=sms_gateway_fee_criteria_class,
    )

    logger.info("Updated SMSGH gateway fees.")
开发者ID:nnestle,项目名称:commcare-hq,代码行数:30,代码来源:bootstrap_smsgh_gateway.py

示例2: update_sislog_vodacom_mozambique_fees

# 需要导入模块: from corehq.apps.smsbillables.models import SmsGatewayFee [as 别名]
# 或者: from corehq.apps.smsbillables.models.SmsGatewayFee import create_new [as 别名]
def update_sislog_vodacom_mozambique_fees(apps, schema_editor):
    mzn, _ = apps.get_model('accounting', 'Currency').objects.get_or_create(code='MZN')
    sms_gateway_fee_class = apps.get_model('smsbillables', 'SmsGatewayFee')
    sms_gateway_fee_criteria_class = apps.get_model('smsbillables', 'SmsGatewayFeeCriteria')

    country_code = 258
    for prefix in ['84', '85']:
        SmsGatewayFee.create_new(
            SQLSislogBackend.get_api_id(),
            INCOMING,
            Decimal('2.0'),
            country_code=country_code,
            prefix=prefix,
            currency=mzn,
            fee_class=sms_gateway_fee_class,
            criteria_class=sms_gateway_fee_criteria_class,
        )

        SmsGatewayFee.create_new(
            SQLSislogBackend.get_api_id(),
            OUTGOING,
            Decimal('0.35'),
            country_code=country_code,
            prefix=prefix,
            currency=mzn,
            fee_class=sms_gateway_fee_class,
            criteria_class=sms_gateway_fee_criteria_class,
        )
开发者ID:dimagi,项目名称:commcare-hq,代码行数:30,代码来源:0020_update_sislog_fees.py

示例3: add_moz_zero_charge

# 需要导入模块: from corehq.apps.smsbillables.models import SmsGatewayFee [as 别名]
# 或者: from corehq.apps.smsbillables.models.SmsGatewayFee import create_new [as 别名]
def add_moz_zero_charge(apps):
    mzn, _ = (apps.get_model('accounting', 'Currency') if apps else Currency).objects.get_or_create(code='MZN')
    sms_gateway_fee_class = apps.get_model('smsbillables', 'SmsGatewayFee') if apps else SmsGatewayFee
    sms_gateway_fee_criteria_class = apps.get_model('smsbillables', 'SmsGatewayFeeCriteria') if apps else SmsGatewayFeeCriteria

    SmsGatewayFee.create_new(
        SQLSislogBackend.get_api_id(),
        INCOMING,
        Decimal('0'),
        country_code=None,
        prefix='',
        currency=mzn,
        fee_class=sms_gateway_fee_class,
        criteria_class=sms_gateway_fee_criteria_class,
    )

    SmsGatewayFee.create_new(
        SQLSislogBackend.get_api_id(),
        OUTGOING,
        Decimal('0'),
        country_code=None,
        prefix='',
        currency=mzn,
        fee_class=sms_gateway_fee_class,
        criteria_class=sms_gateway_fee_criteria_class,
    )

    log_smsbillables_info("Updated Moz gateway default fees.")
开发者ID:dimagi,项目名称:commcare-hq,代码行数:30,代码来源:add_moz_zero_charge.py

示例4: bootstrap_yo_gateway

# 需要导入模块: from corehq.apps.smsbillables.models import SmsGatewayFee [as 别名]
# 或者: from corehq.apps.smsbillables.models.SmsGatewayFee import create_new [as 别名]
def bootstrap_yo_gateway(orm):
    ugx, _ = (orm['accounting.Currency'] if orm else Currency).objects.get_or_create(code='UGX')
    sms_gateway_fee_class = orm['smsbillables.SmsGatewayFee'] if orm else SmsGatewayFee
    sms_gateway_fee_criteria_class = orm['smsbillables.SmsGatewayFeeCriteria'] if orm else SmsGatewayFeeCriteria

    SmsGatewayFee.create_new(
        'YO',
        INCOMING,
        Decimal('110.0'),
        currency=ugx,
        fee_class=sms_gateway_fee_class,
        criteria_class=sms_gateway_fee_criteria_class,
    )

    SmsGatewayFee.create_new(
        'HTTP',
        OUTGOING,
        Decimal('55.0'),
        backend_instance='95a4f0929cddb966e292e70a634da716',
        currency=ugx,
        fee_class=sms_gateway_fee_class,
        criteria_class=sms_gateway_fee_criteria_class,
    )

    logger.info("Updated Yo gateway fees.")
开发者ID:LifeCoaching,项目名称:commcare-hq,代码行数:27,代码来源:bootstrap_yo_gateway.py

示例5: add_moz_zero_charge

# 需要导入模块: from corehq.apps.smsbillables.models import SmsGatewayFee [as 别名]
# 或者: from corehq.apps.smsbillables.models.SmsGatewayFee import create_new [as 别名]
def add_moz_zero_charge(apps):
    mzn, _ = (apps.get_model("accounting", "Currency") if apps else Currency).objects.get_or_create(code="MZN")
    sms_gateway_fee_class = apps.get_model("smsbillables", "SmsGatewayFee") if apps else SmsGatewayFee
    sms_gateway_fee_criteria_class = (
        apps.get_model("smsbillables", "SmsGatewayFeeCriteria") if apps else SmsGatewayFeeCriteria
    )

    SmsGatewayFee.create_new(
        SQLSislogBackend.get_api_id(),
        INCOMING,
        Decimal("0"),
        country_code=None,
        prefix="",
        currency=mzn,
        fee_class=sms_gateway_fee_class,
        criteria_class=sms_gateway_fee_criteria_class,
    )

    SmsGatewayFee.create_new(
        SQLSislogBackend.get_api_id(),
        OUTGOING,
        Decimal("0"),
        country_code=None,
        prefix="",
        currency=mzn,
        fee_class=sms_gateway_fee_class,
        criteria_class=sms_gateway_fee_criteria_class,
    )

    logger.info("Updated Moz gateway default fees.")
开发者ID:philipkaare,项目名称:commcare-hq,代码行数:32,代码来源:add_moz_zero_charge.py

示例6: handle

# 需要导入模块: from corehq.apps.smsbillables.models import SmsGatewayFee [as 别名]
# 或者: from corehq.apps.smsbillables.models.SmsGatewayFee import create_new [as 别名]
    def handle(self, *args, **options):
        workbook = xlrd.open_workbook('corehq/apps/smsbillables/management/'
                                      'commands/pricing_data/Syniverse_coverage_list_DIAMONDplus.xls')
        table = workbook.sheet_by_index(0)

        data = {}
        try:
            row = 7
            while True:
                if table.cell_value(row, 6) == 'yes':
                    country_code = int(table.cell_value(row, 0))
                    if not(country_code in data):
                        data[country_code] = []
                    subscribers = table.cell_value(row,10).replace('.', '')
                    try:
                        data[country_code].append(
                            (table.cell_value(row, 9), int(subscribers)))
                    except ValueError:
                        print 'Incomplete data for country code %d' % country_code
                row += 1
        except IndexError:
            pass

        for country_code in data:
            total_subscribers = 0
            weighted_price = 0
            for price, subscribers in data[country_code]:
                total_subscribers += subscribers
                weighted_price += price * subscribers
            weighted_price = weighted_price / total_subscribers
            SmsGatewayFee.create_new(MachBackend.get_api_id(), OUTGOING, weighted_price,
                                     country_code=country_code, currency=Currency.objects.get(code="EUR"))

        print "Updated MACH/Syniverse gateway fees."
开发者ID:modonnell729,项目名称:commcare-hq,代码行数:36,代码来源:bootstrap_mach_gateway.py

示例7: bootstrap_mach_gateway

# 需要导入模块: from corehq.apps.smsbillables.models import SmsGatewayFee [as 别名]
# 或者: from corehq.apps.smsbillables.models.SmsGatewayFee import create_new [as 别名]
def bootstrap_mach_gateway(apps):
    currency_class = apps.get_model("accounting", "Currency") if apps else Currency
    sms_gateway_fee_class = apps.get_model("smsbillables", "SmsGatewayFee") if apps else SmsGatewayFee
    sms_gateway_fee_criteria_class = (
        apps.get_model("smsbillables", "SmsGatewayFeeCriteria") if apps else SmsGatewayFeeCriteria
    )

    workbook = xlrd.open_workbook(
        "corehq/apps/smsbillables/management/" "commands/pricing_data/Syniverse_coverage_list_DIAMONDplus.xls"
    )
    table = workbook.sheet_by_index(0)

    data = {}
    try:
        row = 7
        while True:
            if table.cell_value(row, 6) == "yes":
                country_code = int(table.cell_value(row, 0))
                if not (country_code in data):
                    data[country_code] = []
                subscribers = table.cell_value(row, 10).replace(".", "")
                try:
                    data[country_code].append((table.cell_value(row, 9), int(subscribers)))
                except ValueError:
                    logger.info("Incomplete data for country code %d" % country_code)
            row += 1
    except IndexError:
        pass

    for country_code in data:
        total_subscribers = 0
        weighted_price = 0
        for price, subscribers in data[country_code]:
            total_subscribers += subscribers
            weighted_price += price * subscribers
        weighted_price = weighted_price / total_subscribers
        SmsGatewayFee.create_new(
            MachBackend.get_api_id(),
            OUTGOING,
            weighted_price,
            country_code=country_code,
            currency=currency_class.objects.get(code="EUR"),
            fee_class=sms_gateway_fee_class,
            criteria_class=sms_gateway_fee_criteria_class,
        )

    # Fee for invalid phonenumber
    SmsGatewayFee.create_new(
        MachBackend.get_api_id(),
        OUTGOING,
        0.0225,
        country_code=None,
        currency=currency_class.objects.get(code="EUR"),
        fee_class=sms_gateway_fee_class,
        criteria_class=sms_gateway_fee_criteria_class,
    )

    logger.info("Updated MACH/Syniverse gateway fees.")
开发者ID:nnestle,项目名称:commcare-hq,代码行数:60,代码来源:bootstrap_mach_gateway.py

示例8: bootstrap_unicel_gateway

# 需要导入模块: from corehq.apps.smsbillables.models import SmsGatewayFee [as 别名]
# 或者: from corehq.apps.smsbillables.models.SmsGatewayFee import create_new [as 别名]
def bootstrap_unicel_gateway(apps):
    currency = (apps.get_model('accounting.Currency') if apps else Currency).objects.get(code="INR")
    sms_gateway_fee_class = apps.get_model('smsbillables.SmsGatewayFee') if apps else SmsGatewayFee
    sms_gateway_fee_criteria_class = apps.get_model('smsbillables.SmsGatewayFeeCriteria') if apps else SmsGatewayFeeCriteria

    SmsGatewayFee.create_new(SQLUnicelBackend.get_api_id(), INCOMING, 0.50,
                             currency=currency,
                             fee_class=sms_gateway_fee_class,
                             criteria_class=sms_gateway_fee_criteria_class)
    SmsGatewayFee.create_new(SQLUnicelBackend.get_api_id(), OUTGOING, 0.50,
                             currency=currency,
                             fee_class=sms_gateway_fee_class,
                             criteria_class=sms_gateway_fee_criteria_class)
    logger.info("Updated Unicel gateway fees.")
开发者ID:ansarbek,项目名称:commcare-hq,代码行数:16,代码来源:bootstrap_unicel_gateway.py

示例9: create_prefix_gateway_fees

# 需要导入模块: from corehq.apps.smsbillables.models import SmsGatewayFee [as 别名]
# 或者: from corehq.apps.smsbillables.models.SmsGatewayFee import create_new [as 别名]
 def create_prefix_gateway_fees(self):
     for direction, backend in self.prefix_fees.items():
         for backend_api_id, country in backend.items():
             for country_code, prfx in country.items():
                 for prefix, backend_instance_and_amount in prfx.items():
                     for backend_instance, amount in backend_instance_and_amount.items():
                         SmsGatewayFee.create_new(
                             backend_api_id,
                             direction,
                             amount,
                             country_code=country_code,
                             prefix=prefix,
                             backend_instance=backend_instance,
                         )
开发者ID:ansarbek,项目名称:commcare-hq,代码行数:16,代码来源:test_gateway_fees.py

示例10: handle

# 需要导入模块: from corehq.apps.smsbillables.models import SmsGatewayFee [as 别名]
# 或者: from corehq.apps.smsbillables.models.SmsGatewayFee import create_new [as 别名]
    def handle(self, *args, **options):
        SmsGatewayFee.create_new(TropoBackend.get_api_id(), INCOMING, 0.01)

        rates_csv = open('corehq/apps/smsbillables/management/'
                         'pricing_data/tropo_international_rates_2013-12-19.csv', 'r')
        for line in rates_csv.readlines():
            data = line.split(',')
            if data[1] == 'Fixed Line' and data[4] != '\n':
                SmsGatewayFee.create_new(TropoBackend.get_api_id(),
                                         OUTGOING,
                                         float(data[4].rstrip()),
                                         country_code=int(data[2]))
        rates_csv.close()

        print "Updated Tropo gateway fees."
开发者ID:modonnell729,项目名称:commcare-hq,代码行数:17,代码来源:bootstrap_tropo_gateway.py

示例11: arbitrary_sms_billables_for_domain

# 需要导入模块: from corehq.apps.smsbillables.models import SmsGatewayFee [as 别名]
# 或者: from corehq.apps.smsbillables.models.SmsGatewayFee import create_new [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

示例12: bootstrap_twilio_gateway_incoming

# 需要导入模块: from corehq.apps.smsbillables.models import SmsGatewayFee [as 别名]
# 或者: from corehq.apps.smsbillables.models.SmsGatewayFee import create_new [as 别名]
def bootstrap_twilio_gateway_incoming(orm):
    currency_class = orm['accounting.Currency'] if orm else Currency
    sms_gateway_fee_class = orm['smsbillables.SmsGatewayFee'] if orm else SmsGatewayFee
    sms_gateway_fee_criteria_class = orm['smsbillables.SmsGatewayFeeCriteria'] if orm else SmsGatewayFeeCriteria

    # https://www.twilio.com/sms/pricing/us
    SmsGatewayFee.create_new(
        TwilioBackend.get_api_id(),
        INCOMING,
        0.0075,
        country_code=None,
        currency=currency_class.objects.get(code="USD"),
        fee_class=sms_gateway_fee_class,
        criteria_class=sms_gateway_fee_criteria_class,
    )

    logger.info("Updated INCOMING Twilio gateway fees.")
开发者ID:LifeCoaching,项目名称:commcare-hq,代码行数:19,代码来源:bootstrap_twilio_gateway_incoming.py

示例13: bootstrap_twilio_gateway_incoming

# 需要导入模块: from corehq.apps.smsbillables.models import SmsGatewayFee [as 别名]
# 或者: from corehq.apps.smsbillables.models.SmsGatewayFee import create_new [as 别名]
def bootstrap_twilio_gateway_incoming(apps):
    currency_class = apps.get_model('accounting', 'Currency') if apps else Currency
    sms_gateway_fee_class = apps.get_model('smsbillables', 'SmsGatewayFee') if apps else SmsGatewayFee
    sms_gateway_fee_criteria_class = apps.get_model('smsbillables', 'SmsGatewayFeeCriteria') if apps else SmsGatewayFeeCriteria

    # https://www.twilio.com/sms/pricing/us
    SmsGatewayFee.create_new(
        SQLTwilioBackend.get_api_id(),
        INCOMING,
        0.0075,
        country_code=None,
        currency=currency_class.objects.get(code="USD"),
        fee_class=sms_gateway_fee_class,
        criteria_class=sms_gateway_fee_criteria_class,
    )

    log_smsbillables_info("Updated INCOMING Twilio gateway fees.")
开发者ID:saketkanth,项目名称:commcare-hq,代码行数:19,代码来源:bootstrap_twilio_gateway_incoming.py

示例14: add_moz_zero_charge

# 需要导入模块: from corehq.apps.smsbillables.models import SmsGatewayFee [as 别名]
# 或者: from corehq.apps.smsbillables.models.SmsGatewayFee import create_new [as 别名]
def add_moz_zero_charge(apps):
    mzn, _ = (apps.get_model("accounting", "Currency") if apps else Currency).objects.get_or_create(code="MZN")
    sms_gateway_fee_class = apps.get_model("smsbillables", "SmsGatewayFee") if apps else SmsGatewayFee
    sms_gateway_fee_criteria_class = (
        apps.get_model("smsbillables", "SmsGatewayFeeCriteria") if apps else SmsGatewayFeeCriteria
    )

    SmsGatewayFee.create_new(
        "SISLOG",
        INCOMING,
        Decimal("0"),
        country_code=None,
        prefix="",
        currency=mzn,
        fee_class=sms_gateway_fee_class,
        criteria_class=sms_gateway_fee_criteria_class,
    )

    backend_id = "7ddf3301c093b793c6020ebf755adb6f"
    try:
        backend = HttpBackend.get(backend_id)

        SmsGatewayFee.create_new(
            backend.get_api_id(),
            OUTGOING,
            Decimal("0"),
            backend_instance=backend._id,
            country_code=None,
            prefix="",
            currency=mzn,
            fee_class=sms_gateway_fee_class,
            criteria_class=sms_gateway_fee_criteria_class,
        )

        logger.info("Updated Moz gateway default fees.")
    except ResourceNotFound:
        logger.error(
            "[SMS-BILLING] Could not find HttpBackend %s - did not create outgoing Moz gateway default fees."
            " Please look into if this is on production, otherwise ignore." % backend_id
        )
开发者ID:nnestle,项目名称:commcare-hq,代码行数:42,代码来源:add_moz_zero_charge.py

示例15: bootstrap_grapevine_gateway

# 需要导入模块: from corehq.apps.smsbillables.models import SmsGatewayFee [as 别名]
# 或者: from corehq.apps.smsbillables.models.SmsGatewayFee import create_new [as 别名]
def bootstrap_grapevine_gateway(orm):
    currency_class = orm['accounting.Currency'] if orm else Currency
    sms_gateway_fee_class = orm['smsbillables.SmsGatewayFee'] if orm else SmsGatewayFee
    sms_gateway_fee_criteria_class = orm['smsbillables.SmsGatewayFeeCriteria'] if orm else SmsGatewayFeeCriteria

    relevant_backends = get_global_backends_by_class(GrapevineBackend)
    currency = currency_class.objects.get_or_create(code="ZAR")[0]

    # any incoming message
    SmsGatewayFee.create_new(
        GrapevineBackend.get_api_id(), INCOMING, Decimal('0.10'),
        currency=currency,
        fee_class=sms_gateway_fee_class,
        criteria_class=sms_gateway_fee_criteria_class,
    )
    logger.info("Updated Global Grapevine gateway fees.")

    # messages relevant to our Grapevine Backends
    for backend in relevant_backends:
        SmsGatewayFee.create_new(
            GrapevineBackend.get_api_id(), INCOMING, Decimal('0.10'),
            currency=currency, backend_instance=backend.get_id,
            fee_class=sms_gateway_fee_class,
            criteria_class=sms_gateway_fee_criteria_class,
        )
        SmsGatewayFee.create_new(
            GrapevineBackend.get_api_id(), OUTGOING, Decimal('0.22'),
            currency=currency, backend_instance=backend.get_id,
            fee_class=sms_gateway_fee_class,
            criteria_class=sms_gateway_fee_criteria_class,
        )

        logger.info("Updated Grapevine fees for backend %s" % backend.name)
开发者ID:LifeCoaching,项目名称:commcare-hq,代码行数:35,代码来源:bootstrap_grapevine_gateway.py


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