Compare commits

...

3 commits

Author SHA1 Message Date
zorun
39f4348379
Merge f62ca85ace into cf77b4c346 2024-11-16 11:55:10 +01:00
MediMilk
cf77b4c346
Corrected typo Administation > Administration (#1332)
Some checks failed
Check doc / test_doc (push) Has been cancelled
Docker build / test (push) Has been cancelled
Lint & unit tests / lint (push) Has been cancelled
Docker build / build_upload (push) Has been cancelled
Lint & unit tests / test (mariadb, minimal, 3.11) (push) Has been cancelled
Lint & unit tests / test (mariadb, normal, 3.11) (push) Has been cancelled
Lint & unit tests / test (mariadb, normal, 3.9) (push) Has been cancelled
Lint & unit tests / test (postgresql, minimal, 3.11) (push) Has been cancelled
Lint & unit tests / test (postgresql, normal, 3.11) (push) Has been cancelled
Lint & unit tests / test (postgresql, normal, 3.9) (push) Has been cancelled
Lint & unit tests / test (sqlite, minimal, 3.10) (push) Has been cancelled
Lint & unit tests / test (sqlite, minimal, 3.11) (push) Has been cancelled
Lint & unit tests / test (sqlite, minimal, 3.12) (push) Has been cancelled
Lint & unit tests / test (sqlite, minimal, 3.7) (push) Has been cancelled
Lint & unit tests / test (sqlite, minimal, 3.9) (push) Has been cancelled
Lint & unit tests / test (sqlite, normal, 3.10) (push) Has been cancelled
Lint & unit tests / test (sqlite, normal, 3.11) (push) Has been cancelled
Lint & unit tests / test (sqlite, normal, 3.12) (push) Has been cancelled
Lint & unit tests / test (sqlite, normal, 3.7) (push) Has been cancelled
Lint & unit tests / test (sqlite, normal, 3.8) (push) Has been cancelled
Lint & unit tests / test (sqlite, normal, 3.9) (push) Has been cancelled
Co-authored-by: MediMilk <chadricksoup@gmail.com>
2024-11-16 11:55:04 +01:00
Baptiste Jonglez
f62ca85ace Add transferred/received amounts in statistics page 2024-03-29 15:22:54 +01:00
40 changed files with 81 additions and 62 deletions

View file

@ -759,7 +759,7 @@ msgstr ""
msgid "Documentation"
msgstr ""
msgid "Administation Dashboard"
msgid "Administration Dashboard"
msgstr ""
msgid "Legal information"

View file

@ -113,42 +113,57 @@ class Project(db.Model):
@property
def full_balance(self):
"""Returns a triple of dicts:
"""Returns a tuple of dicts:
- dict mapping each member to its balance
- dict mapping each member to its overall balance
- dict mapping each member to how much he/she should pay others
(i.e. how much he/she benefited from bills)
- dict mapping each member to its expenses (i.e. how much he/she
benefited from all bills, whoever actually paid)
- dict mapping each member to how much he/she should be paid by
others (i.e. how much he/she has paid for bills)
- dict mapping each member to how much he/she has paid for bills
- dict mapping each member to how much he/she has transferred
money to other members
- dict mapping each member to how much he/she has received money
from other members
balance, spent, paid, transferred, received
balance spent paid
"""
balances, should_pay, should_receive = (defaultdict(int) for time in (1, 2, 3))
balances, spent, paid, transferred, received = (
defaultdict(float) for _ in range(5)
)
for bill in self.get_bills_unordered().all():
total_weight = sum(ower.weight for ower in bill.owers)
if bill.bill_type == BillType.EXPENSE:
should_receive[bill.payer.id] += bill.converted_amount
paid[bill.payer.id] += bill.converted_amount
for ower in bill.owers:
should_pay[ower.id] += (
spent[ower.id] += ower.weight * bill.converted_amount / total_weight
if bill.bill_type == BillType.REIMBURSEMENT:
transferred[bill.payer.id] += bill.converted_amount
for ower in bill.owers:
received[ower.id] += (
ower.weight * bill.converted_amount / total_weight
)
if bill.bill_type == BillType.REIMBURSEMENT:
should_receive[bill.payer.id] += bill.converted_amount
for ower in bill.owers:
should_receive[ower.id] -= bill.converted_amount
for person in self.members:
balance = should_receive[person.id] - should_pay[person.id]
balance = (
paid[person.id]
- spent[person.id]
+ transferred[person.id]
- received[person.id]
)
balances[person.id] = balance
return (
balances,
should_pay,
should_receive,
spent,
paid,
transferred,
received,
)
@property
@ -157,17 +172,19 @@ class Project(db.Model):
@property
def members_stats(self):
"""Compute what each participant has paid
"""Compute what each participant has spent, paid, transferred and received
:return: one stat dict per participant
:rtype list:
"""
balance, spent, paid = self.full_balance
balance, spent, paid, transferred, received = self.full_balance
return [
{
"member": member,
"spent": -1.0 * spent[member.id],
"paid": paid[member.id],
"spent": spent[member.id],
"transferred": transferred[member.id],
"received": -1.0 * received[member.id],
"balance": balance[member.id],
}
for member in self.active_members

View file

@ -168,7 +168,7 @@
<i class="icon book">{{ static_include("images/book.svg") | safe }}</i>
</a>
{% if g.show_admin_dashboard_link %}
<a target="_blank" rel="noopener" data-toggle="tooltip" data-placement="top" title="{{ _('Administation Dashboard') }}" href="{{ url_for('main.dashboard') }}">
<a target="_blank" rel="noopener" data-toggle="tooltip" data-placement="top" title="{{ _('Administration Dashboard') }}" href="{{ url_for('main.dashboard') }}">
<i class="icon admin">{{ static_include("images/cog.svg") | safe }}</i>
</a>
{% endif %}

View file

@ -10,20 +10,22 @@
{% block content %}
<div class="d-flex flex-column">
<table id="bill_table" class="split_bills table table-striped ml-md-n3">
<thead><tr><th class="d-md-none">{{ _("Who?") }}</th><th>{{ _("Paid") }}</th><th>{{ _("Spent") }}</th></tr></thead>
<thead><tr><th class="d-md-none">{{ _("Who?") }}</th><th>{{ _("Paid") }}</th><th>{{ _("Expenses") }}</th><th>{{ _("Transferred") }}</th><th>{{ _("Received") }}</th></tr></thead>
<tbody>
{% for stat in members_stats|sort(attribute='member.name') %}
<tr>
<td class="d-md-none">{{ stat.member.name }}</td>
<td>{{ stat.paid|currency }}</td>
<td>{{ stat.spent|currency }}</td>
<td>{{ stat.transferred|currency }}</td>
<td>{{ stat.received|currency }}</td>
</tr>
{% endfor %}
</tbody>
</table>
<h2>{{ _("Expenses by Month") }}</h2>
<h2>{{ _("Expenses by month") }}</h2>
<table id="monthly_stats" class="table table-striped">
<thead><tr><th>{{ _("Period") }}</th><th>{{ _("Spent") }}</th></tr></thead>
<thead><tr><th>{{ _("Period") }}</th><th>{{ _("Expenses") }}</th></tr></thead>
<tbody>
{% for month in months %}
<tr>

View file

@ -782,7 +782,7 @@ msgstr ""
msgid "Documentation"
msgstr ""
msgid "Administation Dashboard"
msgid "Administration Dashboard"
msgstr ""
msgid "Legal information"

View file

@ -785,7 +785,7 @@ msgstr ""
msgid "Documentation"
msgstr ""
msgid "Administation Dashboard"
msgid "Administration Dashboard"
msgstr ""
msgid "Legal information"

View file

@ -826,7 +826,7 @@ msgstr "Aplicació mòbil"
msgid "Documentation"
msgstr "Documentació"
msgid "Administation Dashboard"
msgid "Administration Dashboard"
msgstr "Panell d'administració"
msgid "Legal information"

View file

@ -800,7 +800,7 @@ msgstr "Mobilní aplikace"
msgid "Documentation"
msgstr "Dokumentace"
msgid "Administation Dashboard"
msgid "Administration Dashboard"
msgstr "Správcovský panel"
msgid "Legal information"

View file

@ -824,7 +824,7 @@ msgstr "Handy-Applikation"
msgid "Documentation"
msgstr "Dokumentation"
msgid "Administation Dashboard"
msgid "Administration Dashboard"
msgstr "Dashboard Administration"
msgid "Legal information"

View file

@ -811,7 +811,7 @@ msgstr ""
msgid "Documentation"
msgstr ""
msgid "Administation Dashboard"
msgid "Administration Dashboard"
msgstr ""
#, fuzzy

View file

@ -821,7 +821,7 @@ msgstr "Poŝaparata programo"
msgid "Documentation"
msgstr "Dokumentaro"
msgid "Administation Dashboard"
msgid "Administration Dashboard"
msgstr "Administra panelo"
#, fuzzy

View file

@ -818,7 +818,7 @@ msgstr "Aplicación móvil"
msgid "Documentation"
msgstr "Documentación"
msgid "Administation Dashboard"
msgid "Administration Dashboard"
msgstr "Panel de administración"
msgid "Legal information"

View file

@ -815,7 +815,7 @@ msgstr "Aplicación móvil"
msgid "Documentation"
msgstr "Documentación"
msgid "Administation Dashboard"
msgid "Administration Dashboard"
msgstr "Panel de administración"
msgid "Legal information"

View file

@ -782,7 +782,7 @@ msgstr ""
msgid "Documentation"
msgstr ""
msgid "Administation Dashboard"
msgid "Administration Dashboard"
msgstr ""
msgid "Legal information"

View file

@ -824,7 +824,7 @@ msgstr "Application mobile"
msgid "Documentation"
msgstr "Documentation"
msgid "Administation Dashboard"
msgid "Administration Dashboard"
msgstr "Panneau d'administration"
msgid "Legal information"

View file

@ -788,7 +788,7 @@ msgstr "יישום לנייד"
msgid "Documentation"
msgstr "דוקומנטציה"
msgid "Administation Dashboard"
msgid "Administration Dashboard"
msgstr ""
msgid "Legal information"

View file

@ -829,7 +829,7 @@ msgstr "मोबाइल एप्लीकेशन"
msgid "Documentation"
msgstr "प्रलेखन"
msgid "Administation Dashboard"
msgid "Administration Dashboard"
msgstr "व्यवस्थापन डैशबोर्ड"
#, fuzzy

View file

@ -817,7 +817,7 @@ msgstr "Mobil alkalmazás"
msgid "Documentation"
msgstr "Dokumentáció"
msgid "Administation Dashboard"
msgid "Administration Dashboard"
msgstr "Adminisztrátori vezérlőpult"
msgid "Legal information"

View file

@ -812,7 +812,7 @@ msgstr "Aplikasi Gawai"
msgid "Documentation"
msgstr "Dokumentasi"
msgid "Administation Dashboard"
msgid "Administration Dashboard"
msgstr "Dasbor Administrasi"
msgid "Legal information"

View file

@ -817,7 +817,7 @@ msgstr "Applicazione mobile"
msgid "Documentation"
msgstr "Documentazione"
msgid "Administation Dashboard"
msgid "Administration Dashboard"
msgstr "Cruscotto Amministrazione"
msgid "Legal information"

View file

@ -797,7 +797,7 @@ msgstr "携帯アプリ"
msgid "Documentation"
msgstr "書類"
msgid "Administation Dashboard"
msgid "Administration Dashboard"
msgstr "管理ダッシュボード"
#, fuzzy

View file

@ -793,7 +793,7 @@ msgstr ""
msgid "Documentation"
msgstr ""
msgid "Administation Dashboard"
msgid "Administration Dashboard"
msgstr ""
msgid "Legal information"

View file

@ -793,7 +793,7 @@ msgstr ""
msgid "Documentation"
msgstr ""
msgid "Administation Dashboard"
msgid "Administration Dashboard"
msgstr ""
msgid "Legal information"

View file

@ -855,7 +855,7 @@ msgstr "Mobilprogram"
msgid "Documentation"
msgstr "Dokumentasjon"
msgid "Administation Dashboard"
msgid "Administration Dashboard"
msgstr "Administrasjonsoversiktspanel"
#, fuzzy

View file

@ -814,7 +814,7 @@ msgstr "Mobiele app"
msgid "Documentation"
msgstr "Documentatie"
msgid "Administation Dashboard"
msgid "Administration Dashboard"
msgstr "Administratie-overzicht"
#, fuzzy

View file

@ -777,7 +777,7 @@ msgstr ""
msgid "Documentation"
msgstr "Documentacion"
msgid "Administation Dashboard"
msgid "Administration Dashboard"
msgstr "Panèl dadministracion"
msgid "Legal information"

View file

@ -812,7 +812,7 @@ msgstr "Aplikacja mobilna"
msgid "Documentation"
msgstr "Dokumentacja"
msgid "Administation Dashboard"
msgid "Administration Dashboard"
msgstr "Kokpit administracyjny"
msgid "Legal information"

View file

@ -823,7 +823,7 @@ msgstr "Aplicação Mobile"
msgid "Documentation"
msgstr "Documentação"
msgid "Administation Dashboard"
msgid "Administration Dashboard"
msgstr "Painel de Administração"
msgid "Legal information"

View file

@ -809,7 +809,7 @@ msgstr "Aplicativo"
msgid "Documentation"
msgstr "Documentação"
msgid "Administation Dashboard"
msgid "Administration Dashboard"
msgstr "Painel de Administração"
msgid "Legal information"

View file

@ -816,7 +816,7 @@ msgstr "Мобильное приложение"
msgid "Documentation"
msgstr "Документация"
msgid "Administation Dashboard"
msgid "Administration Dashboard"
msgstr "Панель инструментов администратора"
msgid "Legal information"

View file

@ -783,7 +783,7 @@ msgstr "Mobilna Aplikacija"
msgid "Documentation"
msgstr "Dokumentacija"
msgid "Administation Dashboard"
msgid "Administration Dashboard"
msgstr ""
msgid "Legal information"

View file

@ -818,7 +818,7 @@ msgstr "Mobilapplikation"
msgid "Documentation"
msgstr "Dokumentation"
msgid "Administation Dashboard"
msgid "Administration Dashboard"
msgstr "Översiktspanel för administration"
msgid "Legal information"

View file

@ -809,7 +809,7 @@ msgstr ""
msgid "Documentation"
msgstr ""
msgid "Administation Dashboard"
msgid "Administration Dashboard"
msgstr ""
msgid "Legal information"

View file

@ -817,7 +817,7 @@ msgstr ""
msgid "Documentation"
msgstr ""
msgid "Administation Dashboard"
msgid "Administration Dashboard"
msgstr ""
msgid "Legal information"

View file

@ -778,7 +778,7 @@ msgstr ""
msgid "Documentation"
msgstr ""
msgid "Administation Dashboard"
msgid "Administration Dashboard"
msgstr ""
msgid "Legal information"

View file

@ -811,7 +811,7 @@ msgstr "Telefon Uygulaması"
msgid "Documentation"
msgstr "Belgelendirme"
msgid "Administation Dashboard"
msgid "Administration Dashboard"
msgstr "Yönetici Gösterge Paneli"
msgid "Legal information"

View file

@ -791,7 +791,7 @@ msgstr ""
msgid "Documentation"
msgstr ""
msgid "Administation Dashboard"
msgid "Administration Dashboard"
msgstr ""
msgid "Legal information"

View file

@ -776,7 +776,7 @@ msgstr ""
msgid "Documentation"
msgstr ""
msgid "Administation Dashboard"
msgid "Administration Dashboard"
msgstr ""
msgid "Legal information"

View file

@ -775,7 +775,7 @@ msgstr ""
msgid "Documentation"
msgstr ""
msgid "Administation Dashboard"
msgid "Administration Dashboard"
msgstr ""
msgid "Legal information"

View file

@ -779,7 +779,7 @@ msgstr "手机软件"
msgid "Documentation"
msgstr "文件"
msgid "Administation Dashboard"
msgid "Administration Dashboard"
msgstr "管理面板"
msgid "Legal information"