mirror of
https://github.com/almet/copanier.git
synced 2025-04-28 19:42:37 +02:00
Display names in the debts repartition table.
Because multiple referents can exist in the same group, one is picked and considerd as the one who's paying for the group. Closes #18.
This commit is contained in:
parent
2550030bb6
commit
89e4664c21
6 changed files with 60 additions and 42 deletions
|
@ -358,7 +358,7 @@ async def edit_producer(request, response, delivery_id, producer_id):
|
|||
if request.method == "POST":
|
||||
form = request.form
|
||||
producer.referent = form.get("referent")
|
||||
producer.tel_referent = form.get("tel_referent")
|
||||
producer.referent_tel = form.get("referent_tel")
|
||||
producer.description = form.get("description")
|
||||
producer.contact = form.get("contact")
|
||||
delivery.producers[producer_id] = producer
|
||||
|
@ -733,12 +733,21 @@ async def delivery_balance(request, response, id):
|
|||
for group_id, order in delivery.orders.items():
|
||||
balance.append((group_id, order.total(delivery.products) * -1))
|
||||
|
||||
producer_groups = {}
|
||||
|
||||
for producer in delivery.producers.values():
|
||||
group = groups.get_user_group(producer.referent)
|
||||
# When a group contains multiple producer contacts,
|
||||
# the first one is elected to receive the money,
|
||||
# and all the other ones are separated in the table.
|
||||
group_id = None
|
||||
if hasattr(group, "id"):
|
||||
if group.id not in producer_groups or producer_groups[group.id] == producer.referent_name:
|
||||
producer_groups[group.id] = producer.referent_name
|
||||
group_id = group.id
|
||||
else:
|
||||
group_id = group
|
||||
if not group_id:
|
||||
group_id = producer.referent_name
|
||||
|
||||
amount = delivery.total_for_producer(producer.id)
|
||||
if amount:
|
||||
balance.append((group_id, amount))
|
||||
|
@ -759,7 +768,8 @@ async def delivery_balance(request, response, id):
|
|||
"debiters": debiters,
|
||||
"crediters": crediters,
|
||||
"results": results_dict,
|
||||
"groups": groups.groups,
|
||||
"debiters_groups": groups.groups,
|
||||
"crediters_groups": producer_groups,
|
||||
},
|
||||
)
|
||||
|
||||
|
|
|
@ -164,7 +164,8 @@ class Groups(PersistedBase):
|
|||
class Producer(Base):
|
||||
id: str
|
||||
referent: str = ""
|
||||
tel_referent: str = ""
|
||||
referent_tel: str = ""
|
||||
referent_name: str = ""
|
||||
contact: str = ""
|
||||
description: str = ""
|
||||
|
||||
|
|
|
@ -561,3 +561,40 @@ details summary {
|
|||
.email-template {
|
||||
height: 400px;
|
||||
}
|
||||
|
||||
code {
|
||||
font-family: monospace;
|
||||
padding: .2em .4em;
|
||||
margin: 0;
|
||||
font-size: 85%;
|
||||
background-color: rgba(27,31,35,.05);
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
table.paiements {
|
||||
font-family:Arial, Helvetica, sans-serif;
|
||||
color:#666;
|
||||
font-size:12px;
|
||||
text-shadow: 1px 1px 0px #fff;
|
||||
background:#eaebec;
|
||||
box-shadow: 0 1px 2px #d1d1d1;
|
||||
}
|
||||
table.paiements tr {
|
||||
text-align: center;
|
||||
padding-left:20px;
|
||||
}
|
||||
table.paiements td:first-child {
|
||||
text-align: left;
|
||||
padding-left:20px;
|
||||
border-left: 0;
|
||||
}
|
||||
table.paiements td {
|
||||
padding:5px;
|
||||
border-top: 1px solid #ffffff;
|
||||
border-bottom:1px solid #e0e0e0;
|
||||
border-left: 1px solid #e0e0e0;
|
||||
background: #fafafa;
|
||||
}
|
||||
table.paiements tr:hover td {
|
||||
background: #f2f2f2;
|
||||
}
|
|
@ -1,45 +1,15 @@
|
|||
{% extends "base.html" %}
|
||||
{% block head %}
|
||||
<style media="screen">
|
||||
table {
|
||||
font-family:Arial, Helvetica, sans-serif;
|
||||
color:#666;
|
||||
font-size:12px;
|
||||
text-shadow: 1px 1px 0px #fff;
|
||||
background:#eaebec;
|
||||
box-shadow: 0 1px 2px #d1d1d1;
|
||||
}
|
||||
table tr {
|
||||
text-align: center;
|
||||
padding-left:20px;
|
||||
}
|
||||
table td:first-child {
|
||||
text-align: left;
|
||||
padding-left:20px;
|
||||
border-left: 0;
|
||||
}
|
||||
table td {
|
||||
padding:5px;
|
||||
border-top: 1px solid #ffffff;
|
||||
border-bottom:1px solid #e0e0e0;
|
||||
border-left: 1px solid #e0e0e0;
|
||||
background: #fafafa;
|
||||
}
|
||||
table tr:hover td {
|
||||
background: #f2f2f2;
|
||||
}
|
||||
</style>
|
||||
{% endblock head %}
|
||||
{% block body %}
|
||||
<h1><i class="icon-lightbulb"></i> Répartition des paiements</h1>
|
||||
<table>
|
||||
<p class="info">Les personnes indiquées avec un <code>*</code> à côté de leur nom sont celles qui ont payé cette commande pour leur groupe.</p>
|
||||
<table class="paiements">
|
||||
<tr>
|
||||
<td></td>
|
||||
{% for crediter in crediters %}<td>{% if crediter[0] in groups %} {{ groups[crediter[0]].name }}{% else %}{{ crediter[0] }}{% endif %} (+{{ crediter[1] | round(2) }})</td>{% endfor %}
|
||||
{% for crediter in crediters %}<td>{% if crediter[0] in crediters_groups %} {{ crediters_groups[crediter[0]] }}*{% else %}{{ crediter[0] }}{% endif %} (+{{ crediter[1] | round(2) }})</td>{% endfor %}
|
||||
</tr>
|
||||
{% for debiter in debiters %}
|
||||
<tr>
|
||||
<td>{% if debiter[0] in groups %} {{ groups[debiter[0]].name }}{% else %}{{ debiter[0] }}{% endif %} ({{ debiter[1] | round(2) }})</td>
|
||||
<td>{% if debiter[0] in debiters_groups %} {{ debiters_groups[debiter[0]].name }}{% else %}{{ debiter[0] }}{% endif %} ({{ debiter[1] | round(2) }})</td>
|
||||
{% for crediter in crediters %}
|
||||
{% set due_amount = results[debiter[0]][crediter[0]] | round(2) %}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
</label>
|
||||
<label>
|
||||
<p>Téléphone de la personne référente</p>
|
||||
<input type="tel" name="tel_referent" value="{{ producer.tel_referent or '' }}" required>
|
||||
<input type="tel" name="referent_tel" value="{{ producer.referent_tel or '' }}" required>
|
||||
</label>
|
||||
<label>
|
||||
<h5>Contact du⋅la product⋅eur⋅rice</h5>
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
{% endif %}
|
||||
{% endif %}
|
||||
</h2>
|
||||
<h5>{% if delivery.producers[producer].description %}{{ delivery.producers[producer].description }}{% endif %}. Référent⋅e : {{ delivery.producers[producer].referent }} / {{ delivery.producers[producer].tel_referent }}</h5>
|
||||
<h5>{% if delivery.producers[producer].description %}{{ delivery.producers[producer].description }}{% endif %}. Référent⋅e : {{ delivery.producers[producer].referent }} / {{ delivery.producers[producer].referent_tel }}</h5>
|
||||
<table class="delivery">
|
||||
<thead>
|
||||
<tr>
|
||||
|
|
Loading…
Reference in a new issue