mirror of
https://github.com/spiral-project/ihatemoney.git
synced 2025-05-04 12:11:50 +02:00
Compare commits
3 commits
9c78e80a0d
...
39f4348379
Author | SHA1 | Date | |
---|---|---|---|
![]() |
39f4348379 | ||
![]() |
cf77b4c346 | ||
![]() |
f62ca85ace |
40 changed files with 81 additions and 62 deletions
|
@ -759,7 +759,7 @@ msgstr ""
|
|||
msgid "Documentation"
|
||||
msgstr ""
|
||||
|
||||
msgid "Administation Dashboard"
|
||||
msgid "Administration Dashboard"
|
||||
msgstr ""
|
||||
|
||||
msgid "Legal information"
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 %}
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -782,7 +782,7 @@ msgstr ""
|
|||
msgid "Documentation"
|
||||
msgstr ""
|
||||
|
||||
msgid "Administation Dashboard"
|
||||
msgid "Administration Dashboard"
|
||||
msgstr ""
|
||||
|
||||
msgid "Legal information"
|
||||
|
|
|
@ -785,7 +785,7 @@ msgstr ""
|
|||
msgid "Documentation"
|
||||
msgstr ""
|
||||
|
||||
msgid "Administation Dashboard"
|
||||
msgid "Administration Dashboard"
|
||||
msgstr ""
|
||||
|
||||
msgid "Legal information"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -800,7 +800,7 @@ msgstr "Mobilní aplikace"
|
|||
msgid "Documentation"
|
||||
msgstr "Dokumentace"
|
||||
|
||||
msgid "Administation Dashboard"
|
||||
msgid "Administration Dashboard"
|
||||
msgstr "Správcovský panel"
|
||||
|
||||
msgid "Legal information"
|
||||
|
|
|
@ -824,7 +824,7 @@ msgstr "Handy-Applikation"
|
|||
msgid "Documentation"
|
||||
msgstr "Dokumentation"
|
||||
|
||||
msgid "Administation Dashboard"
|
||||
msgid "Administration Dashboard"
|
||||
msgstr "Dashboard Administration"
|
||||
|
||||
msgid "Legal information"
|
||||
|
|
|
@ -811,7 +811,7 @@ msgstr ""
|
|||
msgid "Documentation"
|
||||
msgstr ""
|
||||
|
||||
msgid "Administation Dashboard"
|
||||
msgid "Administration Dashboard"
|
||||
msgstr ""
|
||||
|
||||
#, fuzzy
|
||||
|
|
|
@ -821,7 +821,7 @@ msgstr "Poŝaparata programo"
|
|||
msgid "Documentation"
|
||||
msgstr "Dokumentaro"
|
||||
|
||||
msgid "Administation Dashboard"
|
||||
msgid "Administration Dashboard"
|
||||
msgstr "Administra panelo"
|
||||
|
||||
#, fuzzy
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -782,7 +782,7 @@ msgstr ""
|
|||
msgid "Documentation"
|
||||
msgstr ""
|
||||
|
||||
msgid "Administation Dashboard"
|
||||
msgid "Administration Dashboard"
|
||||
msgstr ""
|
||||
|
||||
msgid "Legal information"
|
||||
|
|
|
@ -824,7 +824,7 @@ msgstr "Application mobile"
|
|||
msgid "Documentation"
|
||||
msgstr "Documentation"
|
||||
|
||||
msgid "Administation Dashboard"
|
||||
msgid "Administration Dashboard"
|
||||
msgstr "Panneau d'administration"
|
||||
|
||||
msgid "Legal information"
|
||||
|
|
|
@ -788,7 +788,7 @@ msgstr "יישום לנייד"
|
|||
msgid "Documentation"
|
||||
msgstr "דוקומנטציה"
|
||||
|
||||
msgid "Administation Dashboard"
|
||||
msgid "Administration Dashboard"
|
||||
msgstr ""
|
||||
|
||||
msgid "Legal information"
|
||||
|
|
|
@ -829,7 +829,7 @@ msgstr "मोबाइल एप्लीकेशन"
|
|||
msgid "Documentation"
|
||||
msgstr "प्रलेखन"
|
||||
|
||||
msgid "Administation Dashboard"
|
||||
msgid "Administration Dashboard"
|
||||
msgstr "व्यवस्थापन डैशबोर्ड"
|
||||
|
||||
#, fuzzy
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -812,7 +812,7 @@ msgstr "Aplikasi Gawai"
|
|||
msgid "Documentation"
|
||||
msgstr "Dokumentasi"
|
||||
|
||||
msgid "Administation Dashboard"
|
||||
msgid "Administration Dashboard"
|
||||
msgstr "Dasbor Administrasi"
|
||||
|
||||
msgid "Legal information"
|
||||
|
|
|
@ -817,7 +817,7 @@ msgstr "Applicazione mobile"
|
|||
msgid "Documentation"
|
||||
msgstr "Documentazione"
|
||||
|
||||
msgid "Administation Dashboard"
|
||||
msgid "Administration Dashboard"
|
||||
msgstr "Cruscotto Amministrazione"
|
||||
|
||||
msgid "Legal information"
|
||||
|
|
|
@ -797,7 +797,7 @@ msgstr "携帯アプリ"
|
|||
msgid "Documentation"
|
||||
msgstr "書類"
|
||||
|
||||
msgid "Administation Dashboard"
|
||||
msgid "Administration Dashboard"
|
||||
msgstr "管理ダッシュボード"
|
||||
|
||||
#, fuzzy
|
||||
|
|
|
@ -793,7 +793,7 @@ msgstr ""
|
|||
msgid "Documentation"
|
||||
msgstr ""
|
||||
|
||||
msgid "Administation Dashboard"
|
||||
msgid "Administration Dashboard"
|
||||
msgstr ""
|
||||
|
||||
msgid "Legal information"
|
||||
|
|
|
@ -793,7 +793,7 @@ msgstr ""
|
|||
msgid "Documentation"
|
||||
msgstr ""
|
||||
|
||||
msgid "Administation Dashboard"
|
||||
msgid "Administration Dashboard"
|
||||
msgstr ""
|
||||
|
||||
msgid "Legal information"
|
||||
|
|
|
@ -855,7 +855,7 @@ msgstr "Mobilprogram"
|
|||
msgid "Documentation"
|
||||
msgstr "Dokumentasjon"
|
||||
|
||||
msgid "Administation Dashboard"
|
||||
msgid "Administration Dashboard"
|
||||
msgstr "Administrasjonsoversiktspanel"
|
||||
|
||||
#, fuzzy
|
||||
|
|
|
@ -814,7 +814,7 @@ msgstr "Mobiele app"
|
|||
msgid "Documentation"
|
||||
msgstr "Documentatie"
|
||||
|
||||
msgid "Administation Dashboard"
|
||||
msgid "Administration Dashboard"
|
||||
msgstr "Administratie-overzicht"
|
||||
|
||||
#, fuzzy
|
||||
|
|
|
@ -777,7 +777,7 @@ msgstr ""
|
|||
msgid "Documentation"
|
||||
msgstr "Documentacion"
|
||||
|
||||
msgid "Administation Dashboard"
|
||||
msgid "Administration Dashboard"
|
||||
msgstr "Panèl d’administracion"
|
||||
|
||||
msgid "Legal information"
|
||||
|
|
|
@ -812,7 +812,7 @@ msgstr "Aplikacja mobilna"
|
|||
msgid "Documentation"
|
||||
msgstr "Dokumentacja"
|
||||
|
||||
msgid "Administation Dashboard"
|
||||
msgid "Administration Dashboard"
|
||||
msgstr "Kokpit administracyjny"
|
||||
|
||||
msgid "Legal information"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -816,7 +816,7 @@ msgstr "Мобильное приложение"
|
|||
msgid "Documentation"
|
||||
msgstr "Документация"
|
||||
|
||||
msgid "Administation Dashboard"
|
||||
msgid "Administration Dashboard"
|
||||
msgstr "Панель инструментов администратора"
|
||||
|
||||
msgid "Legal information"
|
||||
|
|
|
@ -783,7 +783,7 @@ msgstr "Mobilna Aplikacija"
|
|||
msgid "Documentation"
|
||||
msgstr "Dokumentacija"
|
||||
|
||||
msgid "Administation Dashboard"
|
||||
msgid "Administration Dashboard"
|
||||
msgstr ""
|
||||
|
||||
msgid "Legal information"
|
||||
|
|
|
@ -818,7 +818,7 @@ msgstr "Mobilapplikation"
|
|||
msgid "Documentation"
|
||||
msgstr "Dokumentation"
|
||||
|
||||
msgid "Administation Dashboard"
|
||||
msgid "Administration Dashboard"
|
||||
msgstr "Översiktspanel för administration"
|
||||
|
||||
msgid "Legal information"
|
||||
|
|
|
@ -809,7 +809,7 @@ msgstr ""
|
|||
msgid "Documentation"
|
||||
msgstr ""
|
||||
|
||||
msgid "Administation Dashboard"
|
||||
msgid "Administration Dashboard"
|
||||
msgstr ""
|
||||
|
||||
msgid "Legal information"
|
||||
|
|
|
@ -817,7 +817,7 @@ msgstr ""
|
|||
msgid "Documentation"
|
||||
msgstr ""
|
||||
|
||||
msgid "Administation Dashboard"
|
||||
msgid "Administration Dashboard"
|
||||
msgstr ""
|
||||
|
||||
msgid "Legal information"
|
||||
|
|
|
@ -778,7 +778,7 @@ msgstr ""
|
|||
msgid "Documentation"
|
||||
msgstr ""
|
||||
|
||||
msgid "Administation Dashboard"
|
||||
msgid "Administration Dashboard"
|
||||
msgstr ""
|
||||
|
||||
msgid "Legal information"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -791,7 +791,7 @@ msgstr ""
|
|||
msgid "Documentation"
|
||||
msgstr ""
|
||||
|
||||
msgid "Administation Dashboard"
|
||||
msgid "Administration Dashboard"
|
||||
msgstr ""
|
||||
|
||||
msgid "Legal information"
|
||||
|
|
|
@ -776,7 +776,7 @@ msgstr ""
|
|||
msgid "Documentation"
|
||||
msgstr ""
|
||||
|
||||
msgid "Administation Dashboard"
|
||||
msgid "Administration Dashboard"
|
||||
msgstr ""
|
||||
|
||||
msgid "Legal information"
|
||||
|
|
|
@ -775,7 +775,7 @@ msgstr ""
|
|||
msgid "Documentation"
|
||||
msgstr ""
|
||||
|
||||
msgid "Administation Dashboard"
|
||||
msgid "Administration Dashboard"
|
||||
msgstr ""
|
||||
|
||||
msgid "Legal information"
|
||||
|
|
|
@ -779,7 +779,7 @@ msgstr "手机软件"
|
|||
msgid "Documentation"
|
||||
msgstr "文件"
|
||||
|
||||
msgid "Administation Dashboard"
|
||||
msgid "Administration Dashboard"
|
||||
msgstr "管理面板"
|
||||
|
||||
msgid "Legal information"
|
||||
|
|
Loading…
Reference in a new issue