mirror of
https://github.com/spiral-project/ihatemoney.git
synced 2025-04-30 18:22:38 +02:00
Merge pull request #5 from FlowingCloudRTL/yiqunz-settle-button
Yiqunz settle button
This commit is contained in:
commit
5fc8b822a1
3 changed files with 40 additions and 1 deletions
|
@ -33,3 +33,6 @@ restful_api.add_resource(BillsHandler, "/projects/<string:project_id>/bills")
|
|||
restful_api.add_resource(
|
||||
BillHandler, "/projects/<string:project_id>/bills/<int:bill_id>"
|
||||
)
|
||||
# restful_api.add_resource(
|
||||
# ProjectHandler, "/<project_id>/settle/<amount>/<ower>/<payer>"
|
||||
# )
|
||||
|
|
|
@ -9,13 +9,20 @@
|
|||
|
||||
{% block content %}
|
||||
<table id="bill_table" class="split_bills table table-striped">
|
||||
<thead><tr><th>{{ _("Who pays?") }}</th><th>{{ _("To whom?") }}</th><th>{{ _("How much?") }}</th></tr></thead>
|
||||
<thead><tr><th>{{ _("Who pays?") }}</th><th>{{ _("To whom?") }}</th><th>{{ _("How much?") }}</th><th>{{ _("Settled?") }}</th></tr></thead>
|
||||
<tbody>
|
||||
{% for bill in bills %}
|
||||
<tr receiver={{bill.receiver.id}}>
|
||||
<td>{{ bill.ower }}</td>
|
||||
<td>{{ bill.receiver }}</td>
|
||||
<td>{{ bill.amount|currency }}</td>
|
||||
<td>
|
||||
<span id="settle-bill" class="ml-auto pb-2">
|
||||
<a href="{{ url_for('.settle', amount = bill.amount, ower_id = bill.ower.id, payer_id = bill.receiver.id) }}" class="btn btn-primary">
|
||||
{{ ("Settle") }}
|
||||
</a>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
|
|
|
@ -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("/<project_id>/settle/<amount>/<int:ower_id>/<int:payer_id>")
|
||||
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("/<project_id>/history")
|
||||
def history():
|
||||
"""Query for the version entries associated with this project."""
|
||||
|
|
Loading…
Reference in a new issue