Fix: iOS Modal scrollIntoView bei Tastatur; CSV Stornierte mit 0€ + Stornonummer (SW by-v975)

This commit is contained in:
rene 2026-05-15 13:15:49 +02:00
parent 2bbf3bc3f6
commit cabb2fd6f7
6 changed files with 38 additions and 19 deletions

View file

@ -413,14 +413,17 @@ def get_quarterly(year: int, q: int, admin=Depends(require_admin)):
period = f"Q{q} {year} ({labels[q]} {ends[q]})"
with db() as conn:
# Alle Rechnungen außer Entwürfe — Stornierte bleiben mit 0€ für lückenlose Nummerierung
rows = conn.execute(
"SELECT * FROM invoices WHERE status IN ('paid','sent') AND created_at >= ? AND created_at <= ? ORDER BY id",
"SELECT * FROM invoices WHERE status != 'draft' AND created_at >= ? AND created_at <= ? ORDER BY id",
(from_date, to_date + "T23:59:59Z")
).fetchall()
total_net = sum(r["amount_net"] for r in rows)
total_tax = sum(r["tax_amount"] for r in rows)
total_gross = sum(r["amount_gross"] for r in rows)
# Summen nur für paid/sent (Stornierte zählen nicht zum Umsatz)
active = [r for r in rows if r["status"] in ("paid", "sent")]
total_net = sum(r["amount_net"] for r in active)
total_tax = sum(r["tax_amount"] for r in active)
total_gross = sum(r["amount_gross"] for r in active)
return {
"period": period,