(xforms, case_db=None)
return StockProcessingResult(
        xform=sorted_forms[0],
        relevant_cases=relevant_cases,
        stock_report_helpers=stock_report_helpers,
    )
process the commtrack xml constructs in an incoming submission
process the commtrack xml constructs in an incoming submission
process the commtrack xml constructs in an incoming submission
def process_stock(xforms, case_db=None):
    """
    process the commtrack xml constructs in an incoming submission
    """
    if not case_db:
        case_db = FormProcessorInterface(xforms[0].domain).casedb_cache(
            domain=xforms[0].domain,
            load_src="process_stock",
        )
    else:
        assert isinstance(case_db, AbstractCaseDbCache)

    stock_report_helpers = []
    case_action_intents = []
    sorted_forms = sorted(xforms, key=lambda f: 1 if f.is_deprecated else 0)
    for xform in sorted_forms:
        try:
            actions_for_form = get_stock_actions(xform)
            stock_report_helpers += actions_for_form.stock_report_helpers
            case_action_intents += actions_for_form.case_action_intents
        except MissingFormXml:
            if not xform.is_deprecated:
                raise

            # in the case where the XML is missing for the deprecated form add a
            # deprecation intent for all cases touched by the primary form
            case_ids = {intent.case_id for intent in case_action_intents}
            case_action_intents += get_ledger_case_action_intents(xform, case_ids)

    # validate the parsed transactions
    for stock_report_helper in stock_report_helpers:
        stock_report_helper.validate()

    relevant_cases = mark_cases_changed(case_action_intents, case_db)
    return StockProcessingResult(
        xform=sorted_forms[0],
        relevant_cases=relevant_cases,
        stock_report_helpers=stock_report_helpers,
    )
def process_stock ( xforms , case_db = None ) : if not case_db : case_db = FormProcessorInterface ( xforms [ 0 ] . domain ) . casedb_cache ( domain = xforms [ 0 ] . domain , load_src = "process_stock" , ) else : assert isinstance ( case_db , AbstractCaseDbCache ) stock_report_helpers = [ ] case_action_intents = [ ] sorted_forms = sorted ( xforms , key = lambda f : 1 if f . is_deprecated else 0 ) for xform in sorted_forms : try : actions_for_form = get_stock_actions ( xform ) stock_report_helpers += actions_for_form . stock_report_helpers case_action_intents += actions_for_form . case_action_intents except MissingFormXml : if not xform . is_deprecated : raise # in the case where the XML is missing for the deprecated form add a # deprecation intent for all cases touched by the primary form case_ids = { intent . case_id for intent in case_action_intents } case_action_intents += get_ledger_case_action_intents ( xform , case_ids ) # validate the parsed transactions for stock_report_helper in stock_report_helpers : stock_report_helper . validate ( ) relevant_cases = mark_cases_changed ( case_action_intents , case_db ) return StockProcessingResult ( xform = sorted_forms [ 0 ] , relevant_cases = relevant_cases , stock_report_helpers = stock_report_helpers , )