diff options
| author | 0livd <github@destras.fr> | 2017-08-21 23:51:32 +0200 |
|---|---|---|
| committer | Alexis Metaireau <alexis@notmyidea.org> | 2017-08-21 23:51:32 +0200 |
| commit | 2ec4fb589fdc0fa14297263fd9357c796689dee9 (patch) | |
| tree | 33357717c20a5781cbff4b783dc3db1517dda533 /ihatemoney/web.py | |
| parent | ec4a099f182629d86a7421af7d4899a655be684e (diff) | |
| download | ihatemoney-mirror-2ec4fb589fdc0fa14297263fd9357c796689dee9.zip ihatemoney-mirror-2ec4fb589fdc0fa14297263fd9357c796689dee9.tar.gz ihatemoney-mirror-2ec4fb589fdc0fa14297263fd9357c796689dee9.tar.bz2 | |
Add a statistics tab (#257)
Diffstat (limited to 'ihatemoney/web.py')
| -rw-r--r-- | ihatemoney/web.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/ihatemoney/web.py b/ihatemoney/web.py index cc2eeac..82e1591 100644 --- a/ihatemoney/web.py +++ b/ihatemoney/web.py @@ -507,6 +507,28 @@ def settle_bill(): ) +@main.route("/<project_id>/statistics") +def statistics(): + """Compute what each member has paid and spent and display it""" + members = g.project.active_members + balance = g.project.balance + paid = {} + spent = {} + for member in members: + paid[member.id] = sum([bill.amount + for bill in g.project.get_member_bills(member.id).all()]) + spent[member.id] = sum([bill.pay_each() * member.weight + for bill in g.project.get_bills().all() if member in bill.owers]) + return render_template( + "statistics.html", + members=members, + balance=balance, + paid=paid, + spent=spent, + current_view='statistics', + ) + + @main.route("/dashboard") def dashboard(): return render_template("dashboard.html", projects=Project.query.all()) |
