Index: remit/finance_core/reporting.py
===================================================================
--- remit/finance_core/reporting.py	(revision 18149fdd97151a9464bc192719677cb556b56b63)
+++ remit/finance_core/reporting.py	(revision d1692e80e5a311571d00881ece31a5966043ff79)
@@ -3,27 +3,5 @@
 import finance_core.models
 
-def build_table_annotate(line_items, main_lineitem_limit_primary, primary_axis, primary_axis_objs, secondary_axis, ):
-    # Setup
-    arcprimary = {}
-    table = []
-    zero = Decimal('0.00')
-    for num, (pk, label, qobj, objrel_qobj) in enumerate(primary_axis):
-        arcprimary[pk] = num
-        table.append([zero]*len(secondary_axis))
-
-    def lineitem_total(obj):
-        if obj.lineitem__amount__sum is None: return zero
-        else: return obj.lineitem__amount__sum
-
-    # Do the real work
-    for num, (pk, label, qobj_lineitem, qobj_primary) in enumerate(secondary_axis):
-        secondary_results = (primary_axis_objs.filter(main_lineitem_limit_primary, qobj_primary, ).annotate(Sum('lineitem__amount')))
-        for cell in secondary_results:
-            #print cell, cell.pk, arcprimary[cell.pk], num, table[arcprimary[cell.pk]]
-            table[arcprimary[cell.pk]][num] = lineitem_total(cell)
-
-    return table
-
-def build_table_valannotate(line_items, primary_field, secondary_field, primary_axis, secondary_axis, ):
+def build_table_annotate(line_items, primary_field, secondary_field, primary_axis, secondary_axis, ):
     # Setup
     arcprimary = {}
@@ -31,8 +9,8 @@
     table = []
     zero = Decimal('0.00')
-    for num, (pk, label, qobj, objrel_qobj) in enumerate(primary_axis):
+    for num, (pk, label, qobj, ) in enumerate(primary_axis):
         arcprimary[pk] = num
         table.append([zero]*len(secondary_axis))
-    for num, (pk, label, qobj, objrel_qobj) in enumerate(secondary_axis):
+    for num, (pk, label, qobj, ) in enumerate(secondary_axis):
         arcsecondary[pk] = num
 
@@ -44,18 +22,13 @@
     results = line_items.values(primary_field, secondary_field,).annotate(Sum('amount'))
     for result in results:
-        print result
-        table[arcprimary[result[primary_field]]][arcsecondary[result[secondary_field]]] = lineitem_total(result)
-    #for num, (pk, label, qobj_lineitem, qobj_primary) in enumerate(secondary_axis):
-    #    secondary_results = (primary_axis_objs.filter(main_lineitem_limit_primary, qobj_primary, ).annotate(Sum('lineitem__amount')))
-    #    for cell in secondary_results:
-    #        #print cell, cell.pk, arcprimary[cell.pk], num, table[arcprimary[cell.pk]]
-    #        table[arcprimary[cell.pk]][num] = lineitem_total(cell)
+        pkey = arcprimary[result[primary_field]]
+        skey = arcsecondary[result[secondary_field]]
+        assert table[pkey][skey] == zero
+        table[pkey][skey] = lineitem_total(result)
 
     return table
 
-def build_table_aggregate(line_items, main_lineitem_limit_primary, primary_axis, primary_axis_objs, secondary_axis):
+def build_table_aggregate(line_items, primary_field, secondary_field, primary_axis, secondary_axis):
     # This uses a simpler but probably slower method
-    # In theory, if we grow unit tests, comparing this method with
-    # the one above using annotate would be a good idea
     zero = Decimal('0.00')
     def total_amount(queryset):
@@ -72,10 +45,9 @@
 
 build_table = build_table_annotate
-build_table = build_table_aggregate
 
 
 def get_primary_axis(slug, base_area, term, ):
     if slug in axes and axes[slug][3]:
-        return axes[slug][0:2] + axes[slug][2](base_area, term, )
+        return axes[slug][0:2] + (axes[slug][2](base_area, term, ), )
     else:
         raise NotImplementedError
@@ -83,5 +55,5 @@
 def get_secondary_axis(slug, base_area, term, ):
     if slug in axes and axes[slug][4]:
-        return axes[slug][0:2] + axes[slug][2](base_area, term, )
+        return axes[slug][0:2] + (axes[slug][2](base_area, term, ), )
     else:
         raise NotImplementedError
@@ -97,10 +69,8 @@
             area.indented_name(base_area_depth),
             Q(budget_area=area),
-            Q(lineitem__budget_area=area),
         )
         for area in areas
     ]
-    axis_objs = areas
-    return axis, axis_objs,
+    return axis
 
 def get_budget_terms(base_area, term, ):
@@ -114,9 +84,8 @@
             term.name,
             Q(budget_term=term),
-            Q(lineitem__budget_term=term),
         )
         for term in terms
     ]
-    return axis, terms
+    return axis
 
 def get_layers(base_area, term, ):
@@ -126,14 +95,13 @@
             finance_core.models.layer_name(layer),
             Q(layer=finance_core.models.layer_num(layer)),
-            Q(lineitem__layer=finance_core.models.layer_num(layer)),
         )
         for layer in finance_core.models.layers
     ]
-    return axis, None,
+    return axis
 
 axes = {
     'budget-areas': ('Budget Areas', 'budget_area', get_budget_areas, True,  True,  ),
     'budget-terms': ('Budget Terms', 'budget_term', get_budget_terms, True,  True,  ),
-    'layers':       ('Layers',       'layer',       get_layers,       False, True,  ),
+    'layers':       ('Layers',       'layer',       get_layers,       True,  True,  ),
 }
 
Index: remit/finance_core/reporting_tests.sh
===================================================================
--- remit/finance_core/reporting_tests.sh	(revision 18149fdd97151a9464bc192719677cb556b56b63)
+++ remit/finance_core/reporting_tests.sh	(revision d1692e80e5a311571d00881ece31a5966043ff79)
@@ -1,5 +1,5 @@
 #!/bin/bash
 
-methods="annotate aggregate valannotate"
+methods="annotate aggregate"
 baseurl=${1:-http://localhost:8001/finance_core/reporting/?a=b}
 baseurls="$baseurl&term=2010-spring $baseurl&area=13 $baseurl&layer=30"
@@ -8,5 +8,5 @@
     dirname=$(mktemp -d /tmp/remit.XXXXXX)
     cd $dirname
-    wget -O default.html "$baseurl"
+    wget -q -O default.html "$baseurl"
     for method in $methods; do
         wget -q -O $method.html  "$baseurl&compute_method=$method"
Index: remit/finance_core/views.py
===================================================================
--- remit/finance_core/views.py	(revision 18149fdd97151a9464bc192719677cb556b56b63)
+++ remit/finance_core/views.py	(revision d1692e80e5a311571d00881ece31a5966043ff79)
@@ -22,6 +22,4 @@
     ###############################
     line_items = finance_core.models.LineItem.objects.all()
-    # Main limit to lineitems, relative to primary axis
-    main_lineitem_limits_primary = []
 
     # Term
@@ -30,5 +28,4 @@
         term_name = term_obj.name
         line_items = line_items.filter(budget_term=term_obj)
-        main_lineitem_limits_primary.append(Q(lineitem__budget_term=term_obj))
     else:
         term_obj = None
@@ -41,6 +38,7 @@
         base_area_obj = finance_core.models.BudgetArea.get_by_path(['Accounts'])
     all_relevant_areas = base_area_obj.get_descendants()
+    if term_obj:
+        all_relevant_areas = all_relevant_areas.filter(Q(always=True) | Q(budget_term=term_obj))
     line_items = line_items.filter(budget_area__in=all_relevant_areas)
-    main_lineitem_limits_primary.append(Q(lineitem__budget_area__in=all_relevant_areas))
 
     # Layer
@@ -52,8 +50,6 @@
             raise Http404("Invalid layer %s request" % request.REQUEST['layer'])
         line_items = line_items.filter(layer=layer_id)
-        main_lineitem_limits_primary.append(Q(lineitem__layer=layer_id))
     else:
         layer = 'all'
-    main_lineitem_limit_primary = Q(*main_lineitem_limits_primary)
 
     #######################
@@ -66,5 +62,5 @@
         primary_slug = 'budget-areas'
     try:
-        primary_name, primary_field, primary_axis, primary_axis_objs = finance_core.reporting.get_primary_axis(primary_slug, base_area_obj, term_obj, )
+        primary_name, primary_field, primary_axis = finance_core.reporting.get_primary_axis(primary_slug, base_area_obj, term_obj, )
     except NotImplementedError:
         raise Http404("Primary axis %s is not implemented" % primary_slug)
@@ -76,5 +72,5 @@
         secondary_slug = 'layers'
     try:
-        secondary_name, secondary_field, secondary_axis, secondary_axis_obj = finance_core.reporting.get_secondary_axis(secondary_slug, base_area_obj, term_obj, )
+        secondary_name, secondary_field, secondary_axis = finance_core.reporting.get_secondary_axis(secondary_slug, base_area_obj, term_obj, )
     except NotImplementedError:
         raise Http404("Secondary axis %s is not implemented" % secondary_slug)
@@ -82,5 +78,5 @@
 
     primary_labels = [ ]
-    for num, (pk, label, qobj, objrel_qobj, ) in enumerate(primary_axis):
+    for num, (pk, label, qobj, ) in enumerate(primary_axis):
         primary_labels.append(label)
     secondary_labels = [ secondary[1] for secondary in secondary_axis ]
@@ -94,13 +90,11 @@
         'annotate':  finance_core.reporting.build_table_annotate,
     }
-    if compute_method == 'valannotate':
-        table = finance_core.reporting.build_table_valannotate(line_items, primary_field, secondary_field, primary_axis, secondary_axis, )
+    if compute_method in compute_methods:
+        build_table = compute_methods[compute_method]
     else:
-        if compute_method in compute_methods:
-            build_table = compute_methods[compute_method]
-        else:
-            raise Http404("Unknown compute_method selected")
-        table = build_table(line_items, main_lineitem_limit_primary, primary_axis, primary_axis_objs, secondary_axis, )
+        raise Http404("Unknown compute_method selected")
+    table = build_table(line_items, primary_field, secondary_field, primary_axis, secondary_axis, )
 
+    debug = True
     debug = False
     if debug:
Index: remit/remit_templates/finance_core/reporting.html
===================================================================
--- remit/remit_templates/finance_core/reporting.html	(revision 193dfcd83752041362fc5611f67a2277fe4bd03d)
+++ remit/remit_templates/finance_core/reporting.html	(revision d1692e80e5a311571d00881ece31a5966043ff79)
@@ -40,5 +40,5 @@
     <th>Primary Axis</th>
     <td><select name='primary'>
-    {% for slug, content in axes.items %}{% if content.2 %}<option {% ifequal primary_name content.0 %}selected {% endifequal %}value='{{slug}}'>{{content.0}}</option>{% endif %}{% endfor %}
+    {% for slug, content in axes.items %}{% if content.3 %}<option {% ifequal primary_name content.0 %}selected {% endifequal %}value='{{slug}}'>{{content.0}}</option>{% endif %}{% endfor %}
     </select></td>
 </tr>
@@ -46,5 +46,5 @@
     <th>Secondary Axis</th>
     <td><select name='secondary'>
-    {% for slug, content in axes.items %}{% if content.3 %}<option {% ifequal secondary_name content.0 %}selected {% endifequal %}value='{{slug}}'>{{content.0}}</option>{% endif %}{% endfor %}
+    {% for slug, content in axes.items %}{% if content.4 %}<option {% ifequal secondary_name content.0 %}selected {% endifequal %}value='{{slug}}'>{{content.0}}</option>{% endif %}{% endfor %}
     </select></td>
 </tr>
