Add view to get categories with their expenses and revenues.
This commit is contained in:
parent
f9acff50d1
commit
68ef144474
@ -130,5 +130,22 @@ class EntryResource(Resource):
|
||||
return entry
|
||||
|
||||
|
||||
category_resource_fields = {
|
||||
'category': fields.String,
|
||||
'expenses': fields.Float,
|
||||
'revenues': fields.Float
|
||||
}
|
||||
|
||||
|
||||
class CategoriesResource(Resource):
|
||||
@session_aware
|
||||
@marshal_with_field(fields.List(Object(category_resource_fields)))
|
||||
def get(self, session):
|
||||
kwargs = range_parser.parse_args()
|
||||
|
||||
return Operation.get_categories_for_range(session, **kwargs)
|
||||
|
||||
|
||||
api_api.add_resource(EntryListResource, "/entries")
|
||||
api_api.add_resource(EntryResource, "/entries/<int:entry_id>")
|
||||
api_api.add_resource(CategoriesResource, "/categories")
|
||||
|
Loading…
Reference in New Issue
Block a user