'Calculate totals for all kits and bundles with this item'

@staticmethod
def budget_item_onaccept(form):

    db = current.db
    s3db = current.s3db
    try:
        item_id = form.vars.id
    except:
        return
    linktable = s3db.budget_kit_item
    kit_id = linktable.kit_id
    rows = db((linktable.item_id == item_id)).select(kit_id, groupby=kit_id)
    kit_ids = set()
    for row in rows:
        kit_id = row.kit_id
        budget_kit_totals(kit_id)
        kit_ids.add(kit_id)
    if kit_ids:
        linktable = s3db.budget_bundle_kit
        bundle_id = linktable.bundle_id
        rows = db(linktable.kit_id.belongs(kit_ids)).select(bundle_id, groupby=bundle_id)
        already_updated = [row.bundle_id for row in rows]
    else:
        already_updated = None
    linktable = s3db.budget_bundle_item
    bundle_id = linktable.bundle_id
    query = (linktable.item_id == item_id)
    if already_updated:
        query &= (~ linktable.bundle_id.belongs(already_updated))
    rows = db(query).select(bundle_id, groupby=bundle_id)
    for row in rows:
        budget_bundle_totals(kit_id)
    return
