import { PrismaClient } from '@prisma/client'; import { bookingAutomationService } from '../lib/booking-automation.ts'; const prisma = new PrismaClient(); async function testAutomation() { console.log('๐Ÿงช Teste Booking Automation...\n'); try { // Hole neueste Buchung const latestBooking = await prisma.booking.findFirst({ orderBy: { createdAt: 'desc' }, select: { id: true, bookingNumber: true, customerName: true, eventDate: true, }, }); if (!latestBooking) { console.log('โŒ Keine Buchung gefunden!'); return; } console.log(`๐Ÿ“‹ Buchung: ${latestBooking.bookingNumber} - ${latestBooking.customerName}`); console.log(` Event: ${new Date(latestBooking.eventDate).toLocaleDateString('de-DE')}\n`); console.log('๐Ÿค– Starte automatische Aktionen...\n'); const result = await bookingAutomationService.runPostBookingActions(latestBooking.id); console.log('\n' + 'โ”€'.repeat(60)); console.log('๐Ÿ“Š Ergebnis:'); console.log(` โœ… E-Mail gesendet: ${result.emailSent ? 'Ja' : 'Nein'}`); console.log(` โœ… Kalender synchronisiert: ${result.calendarSynced ? 'Ja' : 'Nein'}`); if (result.errors.length > 0) { console.log(`\nโŒ Fehler (${result.errors.length}):`); result.errors.forEach(err => console.log(` - ${err}`)); } else { console.log('\nโœ… Alle Aktionen erfolgreich!'); } } catch (error: any) { console.error('\nโŒ Fehler:', error.message); throw error; } finally { await prisma.$disconnect(); } } testAutomation();