mirror of
https://github.com/spiral-project/ihatemoney.git
synced 2025-04-28 09:22: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,33 +1,39 @@
|
|||
{% extends "sidebar_table_layout.html" %}
|
||||
|
||||
{% block sidebar %}
|
||||
<div id="table_overflow">
|
||||
{{ balance_table(show_weight=False) }}
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
|
||||
{% 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><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">
|
||||
<div data-toggle="tooltip" title='{{ _("Click here to record that the money transfer has been done") }}'>
|
||||
{{ ("Settle") }}
|
||||
</div>
|
||||
</a>
|
||||
</span>
|
||||
</td>
|
||||
{% extends "sidebar_table_layout.html" %} {% block sidebar %}
|
||||
<div id="table_overflow">{{ balance_table(show_weight=False) }}</div>
|
||||
{% endblock %} {% 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>
|
||||
<th>{{ _("Settled?") }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for transaction in transactions %}
|
||||
<tr receiver="{{transaction.receiver.id}}">
|
||||
<td>{{ transaction.ower }}</td>
|
||||
<td>{{ transaction.receiver }}</td>
|
||||
<td>{{ transaction.amount|currency }}</td>
|
||||
<td>
|
||||
<span id="settle-bill" class="ml-auto pb-2">
|
||||
<a
|
||||
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") }}
|
||||
</div>
|
||||
</a>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
{% endblock %}
|
||||
|
|
|
@ -852,24 +852,24 @@ def change_lang(lang):
|
|||
@main.route("/<project_id>/settle_bills")
|
||||
def settle_bill():
|
||||
"""Compute the sum each one have to pay to each other and display it"""
|
||||
bills = g.project.get_transactions_to_settle_bill()
|
||||
return render_template("settle_bills.html", bills=bills, current_view="settle_bill")
|
||||
transactions = g.project.get_transactions_to_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>")
|
||||
def settle(amount, ower_id, payer_id):
|
||||
new_reinbursement = Bill(
|
||||
@main.route("/<project_id>/settle/<amount>/<int:sender_id>/<int:receiver_id>")
|
||||
def add_settlement_bill(amount, sender_id, receiver_id):
|
||||
settlement = Bill(
|
||||
amount=float(amount),
|
||||
date=datetime.datetime.today(),
|
||||
owers=[Person.query.get(payer_id)],
|
||||
payer_id=ower_id,
|
||||
owers=[Person.query.get(receiver_id)],
|
||||
payer_id=sender_id,
|
||||
project_default_currency=g.project.default_currency,
|
||||
bill_type=BillType.REIMBURSEMENT,
|
||||
what=_("Settlement"),
|
||||
)
|
||||
session.update()
|
||||
|
||||
db.session.add(new_reinbursement)
|
||||
db.session.add(settlement)
|
||||
db.session.commit()
|
||||
|
||||
flash(_("Settlement bill has been successfully added"), category="success")
|
||||
|
|
Loading…
Reference in a new issue