debug: Auftrags-Debug Endpoint + Filter-Fix

This commit is contained in:
2026-06-17 16:36:41 +02:00
parent 29e09f2ed4
commit dd63a8d959

View File

@@ -72,11 +72,13 @@ router.get('/overview', authenticate, (req, res) => {
// - Bezahlte Aufträge: Datum = bezahlt_am (wann wurde Geld erhalten)
// - Offene Aufträge (noch nicht bezahlt): Datum = created_at (wann erstellt)
const filteredOrders = allOrders.filter(o => {
if (!from && !to) return true; // kein Filter → alle
if (o.bezahlt) {
// Bezahlt → nach Bezahldatum filtern
return inRange(o.bezahlt_am || o.created_at);
// Bezahlt → nach bezahlt_am wenn vorhanden, sonst created_at
// Wenn bezahlt_am NULL ist (alte Aufträge vor dem Feature): created_at nutzen
const d = o.bezahlt_am || o.created_at;
return inRange(d);
} else {
// Offen → nach Erstelldatum filtern
return inRange(o.created_at);
}
});
@@ -203,4 +205,11 @@ router.get('/overview', authenticate, (req, res) => {
});
});
// Debug: rohe Auftragsdaten anzeigen
router.get('/debug', authenticate, (req, res) => {
const u = uid(req);
const orders = db.prepare('SELECT id, name, status, bezahlt, bezahlt_am, created_at, custom_price FROM orders WHERE user_id=? ORDER BY created_at DESC LIMIT 20').all(u);
res.json(orders);
});
module.exports = router;