diff --git a/ihatemoney/api/v1/resources.py b/ihatemoney/api/v1/resources.py index 6c46e4f9..d824ff85 100644 --- a/ihatemoney/api/v1/resources.py +++ b/ihatemoney/api/v1/resources.py @@ -33,3 +33,6 @@ restful_api.add_resource(BillsHandler, "/projects//bills") restful_api.add_resource( BillHandler, "/projects//bills/" ) +# restful_api.add_resource( +# ProjectHandler, "//settle///" +# ) diff --git a/ihatemoney/templates/settle_bills.html b/ihatemoney/templates/settle_bills.html index 601156c6..d23f9c06 100644 --- a/ihatemoney/templates/settle_bills.html +++ b/ihatemoney/templates/settle_bills.html @@ -9,13 +9,20 @@ {% block content %} - + {% for bill in bills %} + {% endfor %} diff --git a/ihatemoney/web.py b/ihatemoney/web.py index f5cd01d5..1b70cb1b 100644 --- a/ihatemoney/web.py +++ b/ihatemoney/web.py @@ -8,6 +8,7 @@ Basically, this blueprint takes care of the authentication and provides some shortcuts to make your life better when coding (see `pull_project` and `add_project_id` for a quick overview) """ +import datetime from functools import wraps import json import os @@ -810,6 +811,34 @@ def settle_bill(): return render_template("settle_bills.html", bills=bills, current_view="settle_bill") +@main.route("//settle///") +def settle(amount, ower_id, payer_id): + # FIXME: Test this bill belongs to this project ! + # form = get_billform_for(g.project, set_default=False) + # form.bill_type = ("Refund", "Refund") + # form.amount = amount + # form.payer = ower + # form.payedfor = payer + + new_reinbursement = Bill( + amount=float(amount), + date=datetime.datetime.today(), + owers=[Person.query.get(payer_id)], + payer_id=ower_id, + project_default_currency=g.project.default_currency, + bill_type="Reimbursement", + what="settlement" + ) + session.update() + + db.session.add(new_reinbursement) + db.session.commit() + + # db.session.add(form.export(g.project)) + # db.session.commit() + return redirect(url_for(".settle_bill")) + + @main.route("//history") def history(): """Query for the version entries associated with this project."""
{{ _("Who pays?") }}{{ _("To whom?") }}{{ _("How much?") }}
{{ _("Who pays?") }}{{ _("To whom?") }}{{ _("How much?") }}{{ _("Settled?") }}
{{ bill.ower }} {{ bill.receiver }} {{ bill.amount|currency }} + + + {{ ("Settle") }} + + +