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":
|
if request.method == "POST":
|
||||||
form = request.form
|
form = request.form
|
||||||
producer.referent = form.get("referent")
|
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.description = form.get("description")
|
||||||
producer.contact = form.get("contact")
|
producer.contact = form.get("contact")
|
||||||
delivery.producers[producer_id] = producer
|
delivery.producers[producer_id] = producer
|
||||||
|
@ -733,12 +733,21 @@ async def delivery_balance(request, response, id):
|
||||||
for group_id, order in delivery.orders.items():
|
for group_id, order in delivery.orders.items():
|
||||||
balance.append((group_id, order.total(delivery.products) * -1))
|
balance.append((group_id, order.total(delivery.products) * -1))
|
||||||
|
|
||||||
|
producer_groups = {}
|
||||||
|
|
||||||
for producer in delivery.producers.values():
|
for producer in delivery.producers.values():
|
||||||
group = groups.get_user_group(producer.referent)
|
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 hasattr(group, "id"):
|
||||||
group_id = group.id
|
if group.id not in producer_groups or producer_groups[group.id] == producer.referent_name:
|
||||||
else:
|
producer_groups[group.id] = producer.referent_name
|
||||||
group_id = group
|
group_id = group.id
|
||||||
|
if not group_id:
|
||||||
|
group_id = producer.referent_name
|
||||||
|
|
||||||
amount = delivery.total_for_producer(producer.id)
|
amount = delivery.total_for_producer(producer.id)
|
||||||
if amount:
|
if amount:
|
||||||
balance.append((group_id, amount))
|
balance.append((group_id, amount))
|
||||||
|
@ -759,7 +768,8 @@ async def delivery_balance(request, response, id):
|
||||||
"debiters": debiters,
|
"debiters": debiters,
|
||||||
"crediters": crediters,
|
"crediters": crediters,
|
||||||
"results": results_dict,
|
"results": results_dict,
|
||||||
"groups": groups.groups,
|
"debiters_groups": groups.groups,
|
||||||
|
"crediters_groups": producer_groups,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -164,7 +164,8 @@ class Groups(PersistedBase):
|
||||||
class Producer(Base):
|
class Producer(Base):
|
||||||
id: str
|
id: str
|
||||||
referent: str = ""
|
referent: str = ""
|
||||||
tel_referent: str = ""
|
referent_tel: str = ""
|
||||||
|
referent_name: str = ""
|
||||||
contact: str = ""
|
contact: str = ""
|
||||||
description: str = ""
|
description: str = ""
|
||||||
|
|
||||||
|
|
|
@ -561,3 +561,40 @@ details summary {
|
||||||
.email-template {
|
.email-template {
|
||||||
height: 400px;
|
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" %}
|
{% 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 %}
|
{% block body %}
|
||||||
<h1><i class="icon-lightbulb"></i> Répartition des paiements</h1>
|
<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>
|
<tr>
|
||||||
<td></td>
|
<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>
|
</tr>
|
||||||
{% for debiter in debiters %}
|
{% for debiter in debiters %}
|
||||||
<tr>
|
<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 %}
|
{% for crediter in crediters %}
|
||||||
{% set due_amount = results[debiter[0]][crediter[0]] | round(2) %}
|
{% set due_amount = results[debiter[0]][crediter[0]] | round(2) %}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
</label>
|
</label>
|
||||||
<label>
|
<label>
|
||||||
<p>Téléphone de la personne référente</p>
|
<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>
|
||||||
<label>
|
<label>
|
||||||
<h5>Contact du⋅la product⋅eur⋅rice</h5>
|
<h5>Contact du⋅la product⋅eur⋅rice</h5>
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</h2>
|
</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">
|
<table class="delivery">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
|
Loading…
Reference in a new issue