new features
This commit is contained in:
@@ -201,11 +201,13 @@ class BookingService {
|
||||
return rows.length > 0;
|
||||
}
|
||||
|
||||
/** Creates a new booking. Throws if the vehicle has a conflicting booking or is out of service. */
|
||||
async create(data: CreateBuchungData, userId: string): Promise<FahrzeugBuchung> {
|
||||
const outOfService = await this.checkOutOfServiceConflict(data.fahrzeugId, data.beginn, data.ende);
|
||||
if (outOfService) {
|
||||
throw new Error('Fahrzeug ist im gewählten Zeitraum außer Dienst');
|
||||
/** Creates a new booking. Throws if the vehicle has a conflicting booking or is out of service (unless overridden). */
|
||||
async create(data: CreateBuchungData, userId: string, ignoreOutOfService = false): Promise<FahrzeugBuchung> {
|
||||
if (!ignoreOutOfService) {
|
||||
const outOfService = await this.checkOutOfServiceConflict(data.fahrzeugId, data.beginn, data.ende);
|
||||
if (outOfService) {
|
||||
throw new Error('Fahrzeug ist im gewählten Zeitraum außer Dienst');
|
||||
}
|
||||
}
|
||||
|
||||
const hasConflict = await this.checkConflict(
|
||||
@@ -219,9 +221,9 @@ class BookingService {
|
||||
|
||||
const query = `
|
||||
INSERT INTO fahrzeug_buchungen
|
||||
(fahrzeug_id, titel, beschreibung, beginn, ende, buchungs_art, gebucht_von, kontakt_person, kontakt_telefon)
|
||||
(fahrzeug_id, titel, beschreibung, beginn, ende, buchungs_art, gebucht_von, kontakt_person, kontakt_telefon, ganztaegig)
|
||||
VALUES
|
||||
($1, $2, $3, $4, $5, $6::fahrzeug_buchung_art, $7, $8, $9)
|
||||
($1, $2, $3, $4, $5, $6::fahrzeug_buchung_art, $7, $8, $9, $10)
|
||||
RETURNING id
|
||||
`;
|
||||
|
||||
@@ -235,6 +237,7 @@ class BookingService {
|
||||
userId,
|
||||
data.kontaktPerson ?? null,
|
||||
data.kontaktTelefon ?? null,
|
||||
data.ganztaegig ?? false,
|
||||
]);
|
||||
|
||||
const newId: string = rows[0].id;
|
||||
|
||||
Reference in New Issue
Block a user