diff --git a/schmeckels/serve.py b/schmeckels/serve.py index 34c762b..978ae58 100644 --- a/schmeckels/serve.py +++ b/schmeckels/serve.py @@ -66,8 +66,13 @@ def tags(): def tag(name): tag = session.query(Tag).filter(Tag.name == name).first() transactions = session.query(Transaction).filter(Transaction.tags.any(id=tag.id)).all() + sum_months = session.query(func.sum(Transaction.amount).label("amount"), func.strftime("%Y-%m",Transaction.date).label("month")).filter(Transaction.tags.any(id=tag.id)).group_by("month").all() + months = [] + for m in sum_months: + months.append({'amount' : format_amount(m['amount']), + "month": m['month']}) - return render_template("tag.html", tag=tag, transactions=transactions) + return render_template("tag.html", tag=tag, months=months, transactions=transactions) @app.route("/tag//delete") diff --git a/schmeckels/templates/base.html b/schmeckels/templates/base.html index 2680087..05ae8ec 100644 --- a/schmeckels/templates/base.html +++ b/schmeckels/templates/base.html @@ -6,7 +6,7 @@ Schmeckels - +