+ total_expenditures = meta.Session.query(model.Expenditure).\
+ add_column(sqlalchemy.func.sum(model.Expenditure.amount).label('total_spend')).\
+ group_by(model.Expenditure.spender_id)
+ for expenditure, total_spend in total_expenditures:
+ debts_dict[expenditure.spender] -= total_spend