mirror of
https://github.com/spiral-project/ihatemoney.git
synced 2025-04-30 18:22:38 +02:00
button added
This commit is contained in:
parent
e13f9152e5
commit
536a2e08dc
5 changed files with 44 additions and 7 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>"
|
||||
# )
|
||||
|
|
|
@ -76,7 +76,7 @@ class Project(db.Model):
|
|||
default_currency = db.Column(db.String(3))
|
||||
bill_types = [
|
||||
("Expense", "Expense"),
|
||||
("Reimbursment", "Reimbursment"),
|
||||
("Reimbursement", "Reimbursement"),
|
||||
("Transfer", "Transfer"),
|
||||
]
|
||||
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -301,7 +301,7 @@ class CommonTestCase(object):
|
|||
{
|
||||
"date": "2017-01-01",
|
||||
"what": "refund",
|
||||
"bill_type": "Refund",
|
||||
"bill_type": "Reimbursement",
|
||||
"payer_name": "tata",
|
||||
"payer_weight": 1.0,
|
||||
"owers": ["fred"],
|
||||
|
@ -353,7 +353,7 @@ class ExportTestCase(IhatemoneyTestCase):
|
|||
"/raclette/add",
|
||||
data={
|
||||
"date": "2017-01-01",
|
||||
"bill_type": "Refund",
|
||||
"bill_type": "Reimbursement",
|
||||
"what": "refund",
|
||||
"payer": 3,
|
||||
"payed_for": [2],
|
||||
|
@ -366,7 +366,7 @@ class ExportTestCase(IhatemoneyTestCase):
|
|||
expected = [
|
||||
{
|
||||
"date": "2017-01-01",
|
||||
"bill_type": "Refund",
|
||||
"bill_type": "Reimbursement",
|
||||
"what": "refund",
|
||||
"amount": 13.33,
|
||||
"currency": "XXX",
|
||||
|
@ -493,7 +493,7 @@ class ExportTestCase(IhatemoneyTestCase):
|
|||
data={
|
||||
"date": "2017-01-01",
|
||||
"what": "refund",
|
||||
"bill_type": "Refund",
|
||||
"bill_type": "Reimbursement",
|
||||
"payer": 3,
|
||||
"payed_for": [2],
|
||||
"amount": "13.33",
|
||||
|
@ -507,7 +507,7 @@ class ExportTestCase(IhatemoneyTestCase):
|
|||
{
|
||||
"date": "2017-01-01",
|
||||
"what": "refund",
|
||||
"bill_type": "Refund",
|
||||
"bill_type": "Reimbursement",
|
||||
"amount": 13.33,
|
||||
"currency": "EUR",
|
||||
"payer_name": "tata",
|
||||
|
|
|
@ -12,6 +12,7 @@ from functools import wraps
|
|||
import json
|
||||
import os
|
||||
from urllib.parse import urlparse, urlunparse
|
||||
import datetime
|
||||
|
||||
from flask import (
|
||||
Blueprint,
|
||||
|
@ -809,6 +810,32 @@ def settle_bill():
|
|||
bills = g.project.get_transactions_to_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():
|
||||
|
|
Loading…
Reference in a new issue