mirror of
https://github.com/spiral-project/ihatemoney.git
synced 2025-04-28 17:32:38 +02:00
Settlement: rename variables to make the code more understandable
This commit is contained in:
parent
bd689f931a
commit
9a834c97e3
2 changed files with 43 additions and 37 deletions
|
@ -1,25 +1,31 @@
|
||||||
{% extends "sidebar_table_layout.html" %}
|
{% extends "sidebar_table_layout.html" %} {% block sidebar %}
|
||||||
|
<div id="table_overflow">{{ balance_table(show_weight=False) }}</div>
|
||||||
{% block sidebar %}
|
{% endblock %} {% block content %}
|
||||||
<div id="table_overflow">
|
<table id="bill_table" class="split_bills table table-striped">
|
||||||
{{ balance_table(show_weight=False) }}
|
<thead>
|
||||||
</div>
|
<tr>
|
||||||
{% endblock %}
|
<th>{{ _("Who pays?") }}</th>
|
||||||
|
<th>{{ _("To whom?") }}</th>
|
||||||
|
<th>{{ _("How much?") }}</th>
|
||||||
{% block content %}
|
<th>{{ _("Settled?") }}</th>
|
||||||
<table id="bill_table" class="split_bills table table-striped">
|
</tr>
|
||||||
<thead><tr><th>{{ _("Who pays?") }}</th><th>{{ _("To whom?") }}</th><th>{{ _("How much?") }}</th><th>{{ _("Settled?") }}</th></tr></thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for bill in bills %}
|
{% for transaction in transactions %}
|
||||||
<tr receiver={{bill.receiver.id}}>
|
<tr receiver="{{transaction.receiver.id}}">
|
||||||
<td>{{ bill.ower }}</td>
|
<td>{{ transaction.ower }}</td>
|
||||||
<td>{{ bill.receiver }}</td>
|
<td>{{ transaction.receiver }}</td>
|
||||||
<td>{{ bill.amount|currency }}</td>
|
<td>{{ transaction.amount|currency }}</td>
|
||||||
<td>
|
<td>
|
||||||
<span id="settle-bill" class="ml-auto pb-2">
|
<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">
|
<a
|
||||||
<div data-toggle="tooltip" title='{{ _("Click here to record that the money transfer has been done") }}'>
|
href="{{ url_for('.add_settlement_bill', amount = transaction.amount, sender_id = transaction.ower.id, receiver_id = transaction.receiver.id) }}"
|
||||||
|
class="btn btn-primary"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
data-toggle="tooltip"
|
||||||
|
title='{{ _("Click here to record that the money transfer has been done") }}'
|
||||||
|
>
|
||||||
{{ ("Settle") }}
|
{{ ("Settle") }}
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
|
@ -28,6 +34,6 @@
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -852,24 +852,24 @@ def change_lang(lang):
|
||||||
@main.route("/<project_id>/settle_bills")
|
@main.route("/<project_id>/settle_bills")
|
||||||
def settle_bill():
|
def settle_bill():
|
||||||
"""Compute the sum each one have to pay to each other and display it"""
|
"""Compute the sum each one have to pay to each other and display it"""
|
||||||
bills = g.project.get_transactions_to_settle_bill()
|
transactions = 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", transactions=transactions, current_view="settle_bill")
|
||||||
|
|
||||||
|
|
||||||
@main.route("/<project_id>/settle/<amount>/<int:ower_id>/<int:payer_id>")
|
@main.route("/<project_id>/settle/<amount>/<int:sender_id>/<int:receiver_id>")
|
||||||
def settle(amount, ower_id, payer_id):
|
def add_settlement_bill(amount, sender_id, receiver_id):
|
||||||
new_reinbursement = Bill(
|
settlement = Bill(
|
||||||
amount=float(amount),
|
amount=float(amount),
|
||||||
date=datetime.datetime.today(),
|
date=datetime.datetime.today(),
|
||||||
owers=[Person.query.get(payer_id)],
|
owers=[Person.query.get(receiver_id)],
|
||||||
payer_id=ower_id,
|
payer_id=sender_id,
|
||||||
project_default_currency=g.project.default_currency,
|
project_default_currency=g.project.default_currency,
|
||||||
bill_type=BillType.REIMBURSEMENT,
|
bill_type=BillType.REIMBURSEMENT,
|
||||||
what=_("Settlement"),
|
what=_("Settlement"),
|
||||||
)
|
)
|
||||||
session.update()
|
session.update()
|
||||||
|
|
||||||
db.session.add(new_reinbursement)
|
db.session.add(settlement)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
flash(_("Settlement bill has been successfully added"), category="success")
|
flash(_("Settlement bill has been successfully added"), category="success")
|
||||||
|
|
Loading…
Reference in a new issue