- 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
54 lines
1.6 KiB
TypeScript
54 lines
1.6 KiB
TypeScript
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();
|