mirror of
https://github.com/almet/copanier.git
synced 2025-04-28 19:42:37 +02:00
Fix a few bugs in the reports
This commit is contained in:
parent
911f327106
commit
c89f1d9466
10 changed files with 48 additions and 36 deletions
|
@ -192,7 +192,11 @@ async def home(request, response):
|
|||
if not request['user'].group_id:
|
||||
response.redirect = "/groupes"
|
||||
return
|
||||
response.html("home.html", incoming=Delivery.incoming(), former=Delivery.former())
|
||||
response.html(
|
||||
"home.html",
|
||||
incoming=Delivery.incoming(),
|
||||
former=Delivery.former(),
|
||||
archives=list(Delivery.all(is_archived=True)))
|
||||
|
||||
|
||||
@app.route("/groupes", methods=["GET"])
|
||||
|
@ -516,13 +520,15 @@ async def import_multiple_commands(request, response, id):
|
|||
@app.route("/livraison/{id}/bon-de-commande.xlsx", methods=["GET"])
|
||||
async def xls_report(request, response, id):
|
||||
delivery = Delivery.load(id)
|
||||
response.xlsx(reports.summary(delivery))
|
||||
date = delivery.to_date.strftime("%Y-%m-%d")
|
||||
response.xlsx(reports.summary(delivery), filename=f"{config.SITE_NAME}-{date}-bon-de-commande.xlsx")
|
||||
|
||||
|
||||
@app.route("/livraison/{id}/rapport-complet.xlsx", methods=["GET"])
|
||||
async def xls_full_report(request, response, id):
|
||||
delivery = Delivery.load(id)
|
||||
response.xlsx(reports.full(delivery))
|
||||
date = delivery.to_date.strftime("%Y-%m-%d")
|
||||
response.xlsx(reports.full(delivery), filename=f"{config.SITE_NAME}-{date}-rapport-complet.xlsx")
|
||||
|
||||
|
||||
@app.route("/livraison/{id}/ajuster/{ref}", methods=["GET", "POST"])
|
||||
|
|
|
@ -38,6 +38,7 @@ def send_order(request, env, person, delivery, order):
|
|||
"order_summary",
|
||||
person.email,
|
||||
f"{config.SITE_NAME} : résumé de la commande {delivery.name}",
|
||||
display_prices=True,
|
||||
order=order,
|
||||
delivery=delivery,
|
||||
request=request
|
||||
|
|
|
@ -39,17 +39,14 @@ def summary_for_products(wb, title, delivery, total=None, products=None):
|
|||
def summary(delivery):
|
||||
wb = Workbook()
|
||||
wb.remove(wb.active)
|
||||
if delivery.has_multiple_producers:
|
||||
for producer in delivery.producers:
|
||||
summary_for_products(
|
||||
wb,
|
||||
producer,
|
||||
delivery,
|
||||
total=delivery.total_for_producer(producer),
|
||||
products=delivery.get_products_by(producer)
|
||||
)
|
||||
else:
|
||||
summary_for_products(wb, f"{delivery.name} {delivery.from_date.date()}", delivery)
|
||||
for producer in delivery.producers:
|
||||
summary_for_products(
|
||||
wb,
|
||||
producer,
|
||||
delivery,
|
||||
total=delivery.total_for_producer(producer),
|
||||
products=delivery.get_products_by(producer)
|
||||
)
|
||||
|
||||
return save_virtual_workbook(wb)
|
||||
|
||||
|
@ -59,13 +56,11 @@ def full(delivery):
|
|||
ws = wb.active
|
||||
ws.title = f"{delivery.name} {delivery.from_date.date()}"
|
||||
headers = ["ref", "produit", "prix"] + [e for e in delivery.orders] + ["total"]
|
||||
if delivery.has_multiple_producers:
|
||||
headers.insert(1, "producer")
|
||||
headers.insert(1, "producer")
|
||||
ws.append(headers)
|
||||
for product in delivery.products:
|
||||
row = [product.ref, str(product), product.price]
|
||||
if delivery.has_multiple_producers:
|
||||
row.insert(1, product.producer)
|
||||
row.insert(1, product.producer)
|
||||
for order in delivery.orders.values():
|
||||
wanted = order.products.get(product.ref)
|
||||
row.append(wanted.quantity if wanted else 0)
|
||||
|
@ -76,8 +71,7 @@ def full(delivery):
|
|||
+ [round(o.total(delivery.products),2) for o in delivery.orders.values()]
|
||||
+ [round(delivery.total, 2)]
|
||||
)
|
||||
if delivery.has_multiple_producers:
|
||||
footer.insert(1, "")
|
||||
footer.insert(1, "")
|
||||
|
||||
ws.append(footer)
|
||||
return save_virtual_workbook(wb)
|
||||
|
|
|
@ -4,7 +4,7 @@ Voici le résumé de votre commande «{{ delivery.name }}» pour « {{ request['
|
|||
|
||||
Produit | Prix unitaire | Quantité
|
||||
|
||||
{% for product in delivery.products %}{% if order[product].quantity %}{{ product.name }} | {{ product.price }} € | {{ order[product].quantity }}
|
||||
{% for product in delivery.products %}{% if order[product].quantity %}{{ product.name }} | {{ product.price }} € | {{ order[product].quantity }} x {{ product.unit }}
|
||||
{% endif %}{% endfor %}
|
||||
|
||||
Total: {{ order.total(delivery.products) if order else 0 }} €
|
||||
|
|
|
@ -4,12 +4,16 @@
|
|||
{% with deliveries=incoming %}
|
||||
{% include "includes/delivery_list.html" %}
|
||||
{% endwith %}
|
||||
{% if former %}
|
||||
<h2>Livraisons passées</h2>
|
||||
{% with deliveries=former %}
|
||||
{% include "includes/delivery_list.html" %}
|
||||
{% endwith %}
|
||||
{% endif %}
|
||||
{% if archives %}
|
||||
<a href="/archives">Voir les livraisons archivées</a>
|
||||
<hr>
|
||||
{% endif %}
|
||||
<ul class="toolbox">
|
||||
<li>
|
||||
<a href="/groupes" class="button"><i class="icon-globe"></i> Gérer les groupes</a>
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
{% if delivery.description %}<li><i class="icon-basket"></i> <strong>Produits</strong> {{ delivery.description }}</li>{% endif %}
|
||||
<li><i class="icon-streetsign"></i> <strong>Lieu</strong> {{ delivery.where }}</li>
|
||||
<li><i class="icon-strategy"></i> <strong>Référent⋅e</strong> <a href="mailto:{{ delivery.contact }}">{{ delivery.contact }}</a></li>
|
||||
<li><i class="icon-clock"></i> <strong>Date de livraison</strong> <time datetime="{{ delivery.from_date }}">{{ delivery.from_date|date }} de {{ delivery.from_date|time }} à {{ delivery.to_date|time }}</time></li>
|
||||
<li><i class="icon-hourglass"></i> {% if delivery.status == delivery.OPEN %}<strong>Date limite de commande</strong> <time datetime="{{ delivery.order_before.date() }}">{{ delivery.order_before|date }}</time>{% elif delivery.status == delivery.ADJUSTMENT %}<strong>Ajustement en cours</strong>{% elif delivery.status == delivery.CLOSED %}<strong>Fermée</strong>{% else %}<strong>Archivée</strong>{% endif %}</li>
|
||||
<li><i class="icon-clock"></i> <strong>Date de livraison</strong> <time datetime="{{ delivery.from_date }}">{{ delivery.from_date|date|capitalize }} de {{ delivery.from_date|time }} à {{ delivery.to_date|time }}</time></li>
|
||||
<li><i class="icon-hourglass"></i> {% if delivery.status == delivery.OPEN %}<strong>Date limite de commande</strong> <time datetime="{{ delivery.order_before.date() }}">{{ delivery.order_before|date|capitalize }}</time>{% elif delivery.status == delivery.ADJUSTMENT %}<strong>Ajustement en cours</strong>{% elif delivery.status == delivery.CLOSED %}<strong>Fermée</strong>{% else %}<strong>Archivée</strong>{% endif %}</li>
|
||||
{% if delivery.instructions %}<li><i class="icon-lightbulb"></i> <strong>À savoir</strong> {{ delivery.instructions }}</li>{% endif %}
|
||||
{% if delivery.infos_url %}<li><i class="icon-global"></i><strong>Plus d'infos</strong> <a href="{{ delivery.infos_url }}" title="{{ delivery.infos_url }}">{{ delivery.infos_url|truncate(20)}}</a></li>{% endif %}
|
||||
</ul>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{% for producer in delivery.producers %}
|
||||
<h2>{{ producer }}</h2>
|
||||
<h4>Référent⋅e : {{ delivery.producers[producer].referent }} / {{ delivery.producers[producer].tel_referent }}</h4>
|
||||
<table class="delivery">
|
||||
<thead>
|
||||
<tr>
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
<table class="order">
|
||||
<tr><th class="product">Produit</th><th class="price">Prix unitaire</th><th class="amount">Quantité</th></tr>
|
||||
<tr><th class="product">Produit</th>{% if display_prices %}<th class="price">Prix unitaire</th>{% endif %}<th class="amount">Quantité</th></tr>
|
||||
{% for product in delivery.products %}
|
||||
{% if order[product].quantity %}
|
||||
<tr>
|
||||
<th class="product" style="text-align: left;">{{ product }}</th>
|
||||
<td>{{ product.price | round(2) }} €</td><td>{{ order[product].quantity }}</td>
|
||||
{% if display_prices %}<td>{{ product.price | round(2) }} €</td>{% endif %}<td>{{ order[product].quantity }} x {{ product.unit }}</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
</th>
|
||||
<td>{{ product.price | round(2) }} €</td>
|
||||
{% if delivery.has_packing %}
|
||||
<td {% if delivery.status == delivery.ADJUSTMENT and delivery.product_missing(product) %} class="missing" title="Les commandes individuelles ne correspondent pas aux conditionnements"{% endif %}>{{ product.packing or "—" }}{% if delivery.status == delivery.ADJUSTMENT and delivery.product_missing(product) %} (−{{ delivery.product_missing(product) }}){% endif %}</td>
|
||||
<td {% if delivery.status == delivery.ADJUSTMENT and delivery.product_missing(product) %} class="missing" title="Les commandes individuelles ne correspondent pas aux conditionnements"{% endif %}>{{ product.packing or "—" }}{% if delivery.status == delivery.ADJUSTMENT and delivery.product_missing(product) %} (manque {{ delivery.product_missing(product) }}){% endif %}</td>
|
||||
{% endif %}
|
||||
<td class="with-input"><input {% if delivery.status != delivery.OPEN %}type="text" readonly{% else%}type="number"{% endif%} min=0 name="wanted:{{ product.ref }}" value="{{ order[product].wanted }}"> x {{ product.unit }}</td>
|
||||
{% if delivery.status == delivery.ADJUSTMENT or order.has_adjustments %}
|
||||
|
|
|
@ -1,10 +1,16 @@
|
|||
<title>{% if title %}{{ title }} - {% endif %}{{ config.SITE_NAME }}</title>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<h2>{{ delivery.name }} {{ delivery.from_date.date() }} - liste d'émargement</h2>
|
||||
{% for email, order in delivery.orders.items() %}
|
||||
<h3>{{ email }}</h3>
|
||||
{% include "includes/order_summary.html" %}
|
||||
<hr>
|
||||
{% endfor %}
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>{% if title %}{{ title }} - {% endif %}{{ config.SITE_NAME }}</title>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" type="text/css" href="/static/signing-sheet.css">
|
||||
</head>
|
||||
<body>
|
||||
<h2>{{ delivery.name }} {{ delivery.from_date.date() }} - liste d'émargement</h2>
|
||||
{% for email, order in delivery.orders.items() %}
|
||||
<h3>{{ email }}</h3>
|
||||
{% include "includes/order_summary.html" %}
|
||||
<hr>
|
||||
{% endfor %}
|
||||
</body>
|
Loading…
Reference in a new issue