Dateien nach "backend/src/tools/bestellungen" hochladen

This commit is contained in:
2026-05-26 13:14:03 +02:00
parent 1cc14b74a6
commit 88bf0a57e2

View File

@@ -31,7 +31,8 @@ router.get('/', authenticate, (req, res) => {
COUNT(oi.id) AS item_count,
SUM(COALESCE(oi.qty_fertig,0)) AS qty_fertig_total,
SUM(COALESCE(oi.stueckzahl,0)) AS qty_total,
SUM(COALESCE(oi.custom_price,0) * COALESCE(oi.stueckzahl,0)) AS custom_price_sum
SUM(COALESCE(oi.custom_price,0) * COALESCE(oi.stueckzahl,0)) AS custom_price_sum,
SUM(COALESCE(oi.stunden,0) * COALESCE(oi.stueckzahl,0)) AS stunden_total
FROM orders o
LEFT JOIN order_items oi ON oi.order_id = o.id
WHERE o.user_id = ?
@@ -100,10 +101,10 @@ router.post('/:id/items', authenticate, (req, res) => {
} else {
db.prepare(`INSERT INTO order_items
(order_id,calculation_id,calc_name,preis_freundschaft,preis_normal,preis_auftrag,
stueckzahl,custom_price,status,qty_warteliste,qty_in_arbeit,qty_fertig)
VALUES (?,?,?,?,?,?,?,?,'warteliste',?,0,0)`)
stueckzahl,custom_price,status,qty_warteliste,qty_in_arbeit,qty_fertig,stunden)
VALUES (?,?,?,?,?,?,?,?,'warteliste',?,0,0,?)`)
.run(req.params.id, calc.id, calc.name, calc.preis_freundschaft, calc.preis_normal, calc.preis_auftrag,
stueckzahl, custom_price, stueckzahl);
stueckzahl, custom_price, stueckzahl, calc.stunden || 0);
}
autoUpdateOrderStatus(req.params.id);
res.json(loadOrder(req.params.id, uid(req)));