feat: Equipment-System, Buchungsbearbeitung, Kundenadresse, LexOffice-Fix

- Vintage Modell hinzugefuegt
- Equipment Multi-Select (Neue Buchung + Bearbeitung)
- Kundenadresse in Formularen
- Bearbeiten-Seite fuer Buchungen
- Abbau-Zeiten in Formularen und Uebersicht
- Vertrag PDF nur bei Privatkunden
- LexOffice Kontakt-Erstellung Fix (BUSINESS)
- Zurueck-Pfeil auf Touren-Seite
This commit is contained in:
Julia Wehden
2026-03-19 16:21:55 +01:00
parent 0b6e429329
commit a2c95c70e7
79 changed files with 7396 additions and 538 deletions

View File

@@ -106,6 +106,7 @@ export async function POST(request: NextRequest) {
},
data: {
tourId: tour.id,
status: 'ASSIGNED',
},
});
@@ -145,6 +146,13 @@ export async function POST(request: NextRequest) {
},
});
// Create TourStops for each booking
const fullBookings = await prisma.booking.findMany({
where: { id: { in: bookingIds } },
include: { setupWindows: true },
orderBy: { setupTimeStart: 'asc' },
});
try {
// For route optimization, use the selected setup window time if available
const stopsWithSetupTimes = bookings.map((booking: any) => {
@@ -182,8 +190,38 @@ export async function POST(request: NextRequest) {
estimatedDuration: routeData.totalDuration,
},
});
// Create TourStops based on optimized order
const optimizedOrder = routeData.optimizedOrder || fullBookings.map((_, i) => i);
for (let i = 0; i < optimizedOrder.length; i++) {
const orderIndex = optimizedOrder[i];
const booking = fullBookings[orderIndex];
await prisma.tourStop.create({
data: {
tourId: tour.id,
bookingId: booking.id,
stopOrder: i + 1,
stopType: 'DELIVERY',
status: 'PENDING',
},
});
}
} catch (routeError) {
console.error('Route optimization error:', routeError);
// If route optimization fails, create TourStops in simple order
for (let i = 0; i < fullBookings.length; i++) {
await prisma.tourStop.create({
data: {
tourId: tour.id,
bookingId: fullBookings[i].id,
stopOrder: i + 1,
stopType: 'DELIVERY',
status: 'PENDING',
},
});
}
}
}