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:
73
scripts/sync-nextcloud-bookings.ts
Normal file
73
scripts/sync-nextcloud-bookings.ts
Normal file
@@ -0,0 +1,73 @@
|
||||
import { config } from 'dotenv';
|
||||
config(); // Load .env file
|
||||
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
import { nextcloudCalendar } from '../lib/nextcloud-calendar.ts';
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
async function syncExistingBookings() {
|
||||
console.log('🔄 Synchronisiere bestehende Buchungen mit Nextcloud...\n');
|
||||
|
||||
try {
|
||||
// Hole alle bestätigten Buchungen
|
||||
const bookings = await prisma.booking.findMany({
|
||||
where: {
|
||||
status: {
|
||||
in: ['RESERVED', 'CONFIRMED'],
|
||||
},
|
||||
},
|
||||
include: {
|
||||
location: true,
|
||||
photobox: true,
|
||||
},
|
||||
orderBy: {
|
||||
eventDate: 'asc',
|
||||
},
|
||||
});
|
||||
|
||||
console.log(`📊 Gefunden: ${bookings.length} Buchungen\n`);
|
||||
|
||||
if (bookings.length === 0) {
|
||||
console.log('ℹ️ Keine Buchungen zum Synchronisieren gefunden.');
|
||||
return;
|
||||
}
|
||||
|
||||
let synced = 0;
|
||||
let failed = 0;
|
||||
|
||||
for (const booking of bookings) {
|
||||
try {
|
||||
console.log(`📅 Synchronisiere: ${booking.bookingNumber} - ${booking.customerName}`);
|
||||
console.log(` Event: ${new Date(booking.eventDate).toLocaleDateString('de-DE')}`);
|
||||
console.log(` Standort: ${booking.location?.name || 'Unbekannt'}`);
|
||||
|
||||
await nextcloudCalendar.syncBookingToCalendar(booking);
|
||||
synced++;
|
||||
console.log(` ✅ Erfolgreich!\n`);
|
||||
} catch (error: any) {
|
||||
failed++;
|
||||
console.error(` ❌ Fehler: ${error.message}\n`);
|
||||
}
|
||||
}
|
||||
|
||||
console.log('─'.repeat(50));
|
||||
console.log(`✅ Erfolgreich synchronisiert: ${synced}`);
|
||||
console.log(`❌ Fehlgeschlagen: ${failed}`);
|
||||
console.log(`📊 Gesamt: ${bookings.length}`);
|
||||
console.log('\n🎉 Synchronisation abgeschlossen!');
|
||||
console.log(' Prüfen Sie Nextcloud → Kalender "Buchungen (Dennis Forte)"');
|
||||
|
||||
} catch (error: any) {
|
||||
console.error('❌ Fehler beim Synchronisieren:', error);
|
||||
throw error;
|
||||
} finally {
|
||||
await prisma.$disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
syncExistingBookings()
|
||||
.catch((error) => {
|
||||
console.error('Fatal error:', error);
|
||||
process.exit(1);
|
||||
});
|
||||
Reference in New Issue
Block a user