Boarding, ticketing, class fare edit updates

This commit is contained in:
Stephanos A
2026-07-02 16:20:15 +03:00
parent b511da2821
commit 9494d57343
15 changed files with 370 additions and 325 deletions

View File

@@ -19,21 +19,31 @@ export class SeatClassesService {
return sc;
}
async updateSeatClass(id: string, dto: any) {
const sc = await this.prisma.seatClass.findUnique({ where: { id } });
if (!sc) throw new NotFoundException('SeatClass not found');
const { basePrice, ...rest } = dto;
const data = {
...rest,
...(basePrice !== undefined && { baseFareMinor: basePrice }),
};
return this.prisma.seatClass.update({ where: { id }, data });
}
async createSeatClass(dto: any) {
try {
return await this.prisma.seatClass.create({ data: dto });
const { basePrice, ...rest } = dto;
const data = {
...rest,
...(basePrice !== undefined && { baseFareMinor: basePrice }),
};
return await this.prisma.seatClass.create({ data });
} catch (e: any) {
if (e.code === 'P2002') throw new ConflictException(`Seat class "${dto.name}" already exists`);
throw e;
}
}
async updateSeatClass(id: string, dto: any) {
const sc = await this.prisma.seatClass.findUnique({ where: { id } });
if (!sc) throw new NotFoundException('SeatClass not found');
return this.prisma.seatClass.update({ where: { id }, data: dto });
}
async deleteSeatClass(id: string) {
const sc = await this.prisma.seatClass.findUnique({ where: { id } });
if (!sc) throw new NotFoundException('SeatClass not found');