コード例 #1
0
def get_wrapped_ledger_values(domain, case_ids, section_id, entry_ids=None):
    # todo: figure out why this causes circular import
    from corehq.apps.reports.commtrack.util import StockLedgerValueWrapper
    query = LedgerES().domain(domain).section(section_id).case(case_ids)
    if entry_ids:
        query = query.entry(entry_ids)

    return [StockLedgerValueWrapper.wrap(row) for row in query.run().hits]
コード例 #2
0
ファイル: esaccessors.py プロジェクト: dimagi/commcare-hq
def get_wrapped_ledger_values(domain, case_ids, section_id, entry_ids=None):
    # todo: figure out why this causes circular import
    from corehq.apps.reports.commtrack.util import StockLedgerValueWrapper

    query = LedgerES().domain(domain).section(section_id).case(case_ids)
    if entry_ids:
        query = query.entry(entry_ids)

    return [StockLedgerValueWrapper.wrap(row) for row in query.run().hits]
コード例 #3
0
ファイル: esaccessors.py プロジェクト: dimagi/commcare-hq
def get_aggregated_ledger_values(domain, case_ids, section_id, entry_ids=None):
    # todo: figure out why this causes circular import
    query = LedgerES().domain(domain).section(section_id).case(case_ids)
    if entry_ids:
        query = query.entry(entry_ids)

    terms = [AggregationTerm("entry_id", "entry_id")]
    return NestedTermAggregationsHelper(
        base_query=query, terms=terms, inner_most_aggregation=SumAggregation("balance", "balance")
    ).get_data()
コード例 #4
0
def get_aggregated_ledger_values(domain, case_ids, section_id, entry_ids=None):
    # todo: figure out why this causes circular import
    query = LedgerES().domain(domain).section(section_id).case(case_ids)
    if entry_ids:
        query = query.entry(entry_ids)

    terms = [
        AggregationTerm('entry_id', 'entry_id'),
    ]
    return NestedTermAggregationsHelper(
        base_query=query,
        terms=terms,
        inner_most_aggregation=SumAggregation('balance', 'balance'),
    ).get_data()
コード例 #5
0
def products_with_ledgers(domain, case_ids, section_id, entry_ids=None):
    # returns entry ids/product ids that have associated ledgers
    query = LedgerES().domain(domain).section(section_id).case(case_ids)
    if entry_ids:
        query = query.entry(entry_ids)
    return set(query.values_list('entry_id', flat=True))
コード例 #6
0
ファイル: esaccessors.py プロジェクト: dimagi/commcare-hq
def products_with_ledgers(domain, case_ids, section_id, entry_ids=None):
    # returns entry ids/product ids that have associated ledgers
    query = LedgerES().domain(domain).section(section_id).case(case_ids)
    if entry_ids:
        query = query.entry(entry_ids)
    return set(query.values_list('entry_id', flat=True))
コード例 #7
0
def get_total_records(domain, case_ids, section_id, entry_ids=None):
    query = LedgerES().domain(domain).section(section_id).case(case_ids)
    if entry_ids:
        query = query.entry(entry_ids)
    return query.count()