This commit is contained in:
Matthias Hochmeister
2026-03-16 15:01:09 +01:00
parent 3c72fe627f
commit f3ad989a9e
28 changed files with 794 additions and 52 deletions

View File

@@ -406,6 +406,43 @@ class VehicleService {
}
}
// =========================================================================
// MAINTENANCE WINDOWS (for booking calendar overlay)
// =========================================================================
async getMaintenanceWindows(
from: Date,
to: Date
): Promise<
{
id: string;
bezeichnung: string;
kurzname: string | null;
status: string;
status_bemerkung: string | null;
ausser_dienst_von: string;
ausser_dienst_bis: string;
}[]
> {
try {
const result = await pool.query(
`SELECT id, bezeichnung, kurzname, status, status_bemerkung,
ausser_dienst_von, ausser_dienst_bis
FROM fahrzeuge
WHERE deleted_at IS NULL
AND status IN ('ausser_dienst_wartung', 'ausser_dienst_schaden')
AND ausser_dienst_von IS NOT NULL
AND ausser_dienst_bis IS NOT NULL
AND (ausser_dienst_von, ausser_dienst_bis) OVERLAPS ($1, $2)`,
[from, to]
);
return result.rows;
} catch (error) {
logger.error('VehicleService.getMaintenanceWindows failed', { error });
throw new Error('Failed to fetch maintenance windows');
}
}
// =========================================================================
// DASHBOARD KPI
// =========================================================================