feat: dashboard web FastAPI Sprint 4
Ajout d'un dashboard lecture seule par-dessus la DB SQLite existante. Fichiers créés : - tickettracker/web/queries.py : 7 fonctions SQL (stats, compare, historique...) - tickettracker/web/api.py : router /api/* JSON (FastAPI) - tickettracker/web/app.py : routes HTML + Jinja2 + point d'entrée uvicorn - tickettracker/web/templates/ : base.html, index.html, compare.html, product.html, receipt.html - tickettracker/web/static/style.css : personnalisations Pico CSS - tests/test_web.py : 19 tests (96 passent, 1 xfail OCR) Fichiers modifiés : - requirements.txt : +fastapi, uvicorn[standard], jinja2, python-multipart, httpx - config.py : +DB_PATH (lu depuis TICKETTRACKER_DB_PATH) Lancement : python -m tickettracker.web.app Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
89
tickettracker/web/templates/receipt.html
Normal file
89
tickettracker/web/templates/receipt.html
Normal file
@@ -0,0 +1,89 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}{% if data %}Ticket #{{ data.id }}{% else %}Ticket introuvable{% endif %}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
{% if data is none %}
|
||||
<article>
|
||||
<h2>Ticket introuvable</h2>
|
||||
<p>Le ticket #{{ receipt_id }} n'existe pas dans la base.</p>
|
||||
<a href="/">← Retour à l'accueil</a>
|
||||
</article>
|
||||
{% else %}
|
||||
|
||||
<!-- En-tête ticket -->
|
||||
<hgroup>
|
||||
<h1>Ticket #{{ data.id }}</h1>
|
||||
<p>{{ data.store | capitalize }} — {{ data.date }}</p>
|
||||
</hgroup>
|
||||
|
||||
<!-- Champs du ticket -->
|
||||
<article>
|
||||
<dl>
|
||||
<dt>Enseigne</dt>
|
||||
<dd>{{ data.store }}</dd>
|
||||
|
||||
<dt>Date</dt>
|
||||
<dd>{{ data.date }}</dd>
|
||||
|
||||
<dt>Total</dt>
|
||||
<dd><strong>{{ "%.2f"|format(data.total) }} €</strong></dd>
|
||||
|
||||
{% if data.delivery_fee is not none %}
|
||||
<dt>Frais de livraison</dt>
|
||||
<dd>{{ "%.2f"|format(data.delivery_fee) }} €</dd>
|
||||
{% endif %}
|
||||
|
||||
{% if data.order_id %}
|
||||
<dt>Référence commande</dt>
|
||||
<dd><code>{{ data.order_id }}</code></dd>
|
||||
{% endif %}
|
||||
</dl>
|
||||
</article>
|
||||
|
||||
<!-- Articles -->
|
||||
<article>
|
||||
<h2>Articles ({{ data['items'] | length }})</h2>
|
||||
<div class="overflow-auto">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Nom brut</th>
|
||||
<th>Nom normalisé</th>
|
||||
<th>Catégorie</th>
|
||||
<th>Qté</th>
|
||||
<th>Unité</th>
|
||||
<th>Prix unit.</th>
|
||||
<th>Total</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for item in data['items'] %}
|
||||
<tr>
|
||||
<td>{{ item.name_raw }}</td>
|
||||
<td>
|
||||
{% if item.name_normalized %}
|
||||
<a href="/product/{{ item.name_normalized | urlquote }}">
|
||||
{{ item.name_normalized }}
|
||||
</a>
|
||||
{% else %}
|
||||
<em>—</em>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>{{ item.category or "—" }}</td>
|
||||
<td>{{ item.quantity }}</td>
|
||||
<td>{{ item.unit }}</td>
|
||||
<td>{{ "%.2f"|format(item.unit_price) }} €</td>
|
||||
<td>{{ "%.2f"|format(item.total_price) }} €</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</article>
|
||||
|
||||
<a href="/">← Retour à l'accueil</a>
|
||||
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user