add linking between internal and external orders

This commit is contained in:
Matthias Hochmeister
2026-03-27 11:18:06 +01:00
parent 75e533c1fc
commit 90f691d607
8 changed files with 573 additions and 49 deletions

View File

@@ -507,6 +507,30 @@ class AusruestungsanfrageController {
}
}
async createOrders(req: Request, res: Response): Promise<void> {
try {
const anfrageId = Number(req.params.id);
const { orders } = req.body as {
orders: Array<{
lieferant_id: number;
bezeichnung: string;
positionen: Array<{ position_id: number; bezeichnung: string; menge: number; einheit?: string; notizen?: string }>;
}>;
};
if (!orders || orders.length === 0) {
res.status(400).json({ success: false, message: 'Mindestens eine Bestellung ist erforderlich' });
return;
}
const created = await ausruestungsanfrageService.createOrdersFromRequest(anfrageId, orders, req.user!.id);
res.status(201).json({ success: true, data: { created_bestellungen: created } });
} catch (error) {
logger.error('AusruestungsanfrageController.createOrders error', { error });
res.status(500).json({ success: false, message: 'Bestellungen konnten nicht erstellt werden' });
}
}
// -------------------------------------------------------------------------
// Widget overview (lightweight, for dashboard widget)
// -------------------------------------------------------------------------