From 9a834c97e336e8e4f8b7e1d5516f0b7a91e551ee Mon Sep 17 00:00:00 2001 From: Baptiste Jonglez Date: Fri, 29 Mar 2024 17:27:15 +0100 Subject: [PATCH] Settlement: rename variables to make the code more understandable --- ihatemoney/templates/settle_bills.html | 64 ++++++++++++++------------ ihatemoney/web.py | 16 +++---- 2 files changed, 43 insertions(+), 37 deletions(-) diff --git a/ihatemoney/templates/settle_bills.html b/ihatemoney/templates/settle_bills.html index 67aac337..f4043621 100644 --- a/ihatemoney/templates/settle_bills.html +++ b/ihatemoney/templates/settle_bills.html @@ -1,33 +1,39 @@ -{% extends "sidebar_table_layout.html" %} - -{% block sidebar %} -
- {{ balance_table(show_weight=False) }} -
-{% endblock %} - - -{% block content %} - - - - {% for bill in bills %} - - - - - +{% extends "sidebar_table_layout.html" %} {% block sidebar %} +
{{ balance_table(show_weight=False) }}
+{% endblock %} {% block content %} +
{{ _("Who pays?") }}{{ _("To whom?") }}{{ _("How much?") }}{{ _("Settled?") }}
{{ bill.ower }}{{ bill.receiver }}{{ bill.amount|currency }} - - -
- {{ ("Settle") }} -
-
-
-
+ + + + + + + + + + {% for transaction in transactions %} + + + + + {% endfor %} - -
{{ _("Who pays?") }}{{ _("To whom?") }}{{ _("How much?") }}{{ _("Settled?") }}
{{ transaction.ower }}{{ transaction.receiver }}{{ transaction.amount|currency }} + + +
+ {{ ("Settle") }} +
+
+
+
+ + {% endblock %} diff --git a/ihatemoney/web.py b/ihatemoney/web.py index 43b04c21..cb1bea56 100644 --- a/ihatemoney/web.py +++ b/ihatemoney/web.py @@ -852,24 +852,24 @@ def change_lang(lang): @main.route("//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("//settle///") -def settle(amount, ower_id, payer_id): - new_reinbursement = Bill( +@main.route("//settle///") +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")