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


Python LedgerAccessorSQL.get_ledger_value方法代码示例

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


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

示例1: get_models_to_update

# 需要导入模块: from corehq.form_processor.backends.sql.dbaccessors import LedgerAccessorSQL [as 别名]
# 或者: from corehq.form_processor.backends.sql.dbaccessors.LedgerAccessorSQL import get_ledger_value [as 别名]
    def get_models_to_update(self, stock_report_helper, ledger_db=None):
        latest_values = {}
        for stock_trans in stock_report_helper.transactions:
            def _lazy_original_balance():
                # needs to be in closures because it's zero-argument.
                # see compute_ledger_values for more information
                if stock_trans.ledger_reference in latest_values:
                    return latest_values[stock_trans.ledger_reference]
                else:
                    return self.get_current_ledger_value(stock_trans.ledger_reference)

            new_ledger_values = compute_ledger_values(
                _lazy_original_balance, stock_report_helper.report_type, stock_trans.relative_quantity
            )
            latest_values[stock_trans.ledger_reference] = new_ledger_values.balance

        to_save = []
        for touched_ledger_reference, quantity in latest_values.items():
            try:
                ledger_value = LedgerAccessorSQL.get_ledger_value(**touched_ledger_reference._asdict())
            except LedgerValue.DoesNotExist:
                ledger_value = LedgerValue(**touched_ledger_reference._asdict())
            ledger_value.balance = quantity
            to_save.append(ledger_value)
        return StockModelUpdateResult(to_save=to_save)
开发者ID:ansarbek,项目名称:commcare-hq,代码行数:27,代码来源:ledger.py

示例2: hard_rebuild_ledgers

# 需要导入模块: from corehq.form_processor.backends.sql.dbaccessors import LedgerAccessorSQL [as 别名]
# 或者: from corehq.form_processor.backends.sql.dbaccessors.LedgerAccessorSQL import get_ledger_value [as 别名]
 def hard_rebuild_ledgers(case_id, section_id=None, entry_id=None):
     transactions = LedgerAccessorSQL.get_ledger_transactions_for_case(case_id, section_id, entry_id)
     if not transactions:
         LedgerAccessorSQL.delete_ledger_values(case_id, section_id, entry_id)
         return
     ledger_value = LedgerAccessorSQL.get_ledger_value(case_id, section_id, entry_id)
     ledger_value = LedgerProcessorSQL._rebuild_ledger_value_from_transactions(ledger_value, transactions)
     LedgerAccessorSQL.save_ledger_values([ledger_value])
     publish_ledger_v2_saved(ledger_value)
开发者ID:dimagi,项目名称:commcare-hq,代码行数:11,代码来源:ledger.py

示例3: _get_daily_consumption_for_ledger

# 需要导入模块: from corehq.form_processor.backends.sql.dbaccessors import LedgerAccessorSQL [as 别名]
# 或者: from corehq.form_processor.backends.sql.dbaccessors.LedgerAccessorSQL import get_ledger_value [as 别名]
def _get_daily_consumption_for_ledger(ledger):
    from corehq.apps.commtrack.consumption import get_consumption_for_ledger_json
    daily_consumption = get_consumption_for_ledger_json(ledger)
    if should_use_sql_backend(ledger['domain']):
        from corehq.form_processor.backends.sql.dbaccessors import LedgerAccessorSQL
        ledger_value = LedgerAccessorSQL.get_ledger_value(
            ledger['case_id'], ledger['section_id'], ledger['entry_id']
        )
        ledger_value.daily_consumption = daily_consumption
        LedgerAccessorSQL.save_ledger_values([ledger_value])
    else:
        from corehq.apps.commtrack.models import StockState
        StockState.objects.filter(pk=ledger['_id']).update(daily_consumption=daily_consumption)

    return daily_consumption
开发者ID:saketkanth,项目名称:commcare-hq,代码行数:17,代码来源:ledger.py

示例4: get_current_ledger_value

# 需要导入模块: from corehq.form_processor.backends.sql.dbaccessors import LedgerAccessorSQL [as 别名]
# 或者: from corehq.form_processor.backends.sql.dbaccessors.LedgerAccessorSQL import get_ledger_value [as 别名]
 def get_current_ledger_value(self, unique_ledger_reference):
     try:
         return LedgerAccessorSQL.get_ledger_value(**unique_ledger_reference._asdict()).balance
     except LedgerValue.DoesNotExist:
         return 0
开发者ID:ansarbek,项目名称:commcare-hq,代码行数:7,代码来源:ledger.py

示例5: _get_ledger

# 需要导入模块: from corehq.form_processor.backends.sql.dbaccessors import LedgerAccessorSQL [as 别名]
# 或者: from corehq.form_processor.backends.sql.dbaccessors.LedgerAccessorSQL import get_ledger_value [as 别名]
 def _get_ledger(self, unique_ledger_reference):
     try:
         return LedgerAccessorSQL.get_ledger_value(**unique_ledger_reference._asdict())
     except LedgerValueNotFound:
         return None
开发者ID:kkrampa,项目名称:commcare-hq,代码行数:7,代码来源:ledger.py


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