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(
|
restful_api.add_resource(
|
||||||
BillHandler, "/projects/<string:project_id>/bills/<int:bill_id>"
|
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))
|
default_currency = db.Column(db.String(3))
|
||||||
bill_types = [
|
bill_types = [
|
||||||
("Expense", "Expense"),
|
("Expense", "Expense"),
|
||||||
("Reimbursment", "Reimbursment"),
|
("Reimbursement", "Reimbursement"),
|
||||||
("Transfer", "Transfer"),
|
("Transfer", "Transfer"),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -9,13 +9,20 @@
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<table id="bill_table" class="split_bills table table-striped">
|
<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>
|
<tbody>
|
||||||
{% for bill in bills %}
|
{% for bill in bills %}
|
||||||
<tr receiver={{bill.receiver.id}}>
|
<tr receiver={{bill.receiver.id}}>
|
||||||
<td>{{ bill.ower }}</td>
|
<td>{{ bill.ower }}</td>
|
||||||
<td>{{ bill.receiver }}</td>
|
<td>{{ bill.receiver }}</td>
|
||||||
<td>{{ bill.amount|currency }}</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>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
|
@ -301,7 +301,7 @@ class CommonTestCase(object):
|
||||||
{
|
{
|
||||||
"date": "2017-01-01",
|
"date": "2017-01-01",
|
||||||
"what": "refund",
|
"what": "refund",
|
||||||
"bill_type": "Refund",
|
"bill_type": "Reimbursement",
|
||||||
"payer_name": "tata",
|
"payer_name": "tata",
|
||||||
"payer_weight": 1.0,
|
"payer_weight": 1.0,
|
||||||
"owers": ["fred"],
|
"owers": ["fred"],
|
||||||
|
@ -353,7 +353,7 @@ class ExportTestCase(IhatemoneyTestCase):
|
||||||
"/raclette/add",
|
"/raclette/add",
|
||||||
data={
|
data={
|
||||||
"date": "2017-01-01",
|
"date": "2017-01-01",
|
||||||
"bill_type": "Refund",
|
"bill_type": "Reimbursement",
|
||||||
"what": "refund",
|
"what": "refund",
|
||||||
"payer": 3,
|
"payer": 3,
|
||||||
"payed_for": [2],
|
"payed_for": [2],
|
||||||
|
@ -366,7 +366,7 @@ class ExportTestCase(IhatemoneyTestCase):
|
||||||
expected = [
|
expected = [
|
||||||
{
|
{
|
||||||
"date": "2017-01-01",
|
"date": "2017-01-01",
|
||||||
"bill_type": "Refund",
|
"bill_type": "Reimbursement",
|
||||||
"what": "refund",
|
"what": "refund",
|
||||||
"amount": 13.33,
|
"amount": 13.33,
|
||||||
"currency": "XXX",
|
"currency": "XXX",
|
||||||
|
@ -493,7 +493,7 @@ class ExportTestCase(IhatemoneyTestCase):
|
||||||
data={
|
data={
|
||||||
"date": "2017-01-01",
|
"date": "2017-01-01",
|
||||||
"what": "refund",
|
"what": "refund",
|
||||||
"bill_type": "Refund",
|
"bill_type": "Reimbursement",
|
||||||
"payer": 3,
|
"payer": 3,
|
||||||
"payed_for": [2],
|
"payed_for": [2],
|
||||||
"amount": "13.33",
|
"amount": "13.33",
|
||||||
|
@ -507,7 +507,7 @@ class ExportTestCase(IhatemoneyTestCase):
|
||||||
{
|
{
|
||||||
"date": "2017-01-01",
|
"date": "2017-01-01",
|
||||||
"what": "refund",
|
"what": "refund",
|
||||||
"bill_type": "Refund",
|
"bill_type": "Reimbursement",
|
||||||
"amount": 13.33,
|
"amount": 13.33,
|
||||||
"currency": "EUR",
|
"currency": "EUR",
|
||||||
"payer_name": "tata",
|
"payer_name": "tata",
|
||||||
|
|
|
@ -12,6 +12,7 @@ from functools import wraps
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
from urllib.parse import urlparse, urlunparse
|
from urllib.parse import urlparse, urlunparse
|
||||||
|
import datetime
|
||||||
|
|
||||||
from flask import (
|
from flask import (
|
||||||
Blueprint,
|
Blueprint,
|
||||||
|
@ -809,6 +810,32 @@ def settle_bill():
|
||||||
bills = g.project.get_transactions_to_settle_bill()
|
bills = g.project.get_transactions_to_settle_bill()
|
||||||
return render_template("settle_bills.html", bills=bills, current_view="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")
|
@main.route("/<project_id>/history")
|
||||||
def history():
|
def history():
|
||||||
|
|
Loading…
Reference in a new issue