import json, sys
from collections import defaultdict
source = json.load(open(sys.argv[1], encoding='utf-8'))
allocated = defaultdict(float)
for row in source['usage']:
    allocated[row.get('team') or 'unallocated'] += row['billableUnits']
total = sum(allocated.values())
print(json.dumps({'unitsByTeam': dict(allocated), 'allocatedUnits': total,
    'providerUnits': source['providerUnits'],
    'unreconciledUnits': source['providerUnits'] - total}))
