示例#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
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
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
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()