add cancellationReason

This commit is contained in:
2026-06-13 13:42:52 +03:30
parent 1d685b3338
commit 9ec1a476a0
5 changed files with 51 additions and 2 deletions
+14 -1
View File
@@ -324,9 +324,22 @@ export class BookingsService {
return this.repo.save(row);
}
async cancel(id: string, actor?: AuthUser): Promise<BookingEntity> {
async cancel(
id: string,
actor?: AuthUser,
payload?: { cancellationReason?: string },
): Promise<BookingEntity> {
const row = await this.findOne(id);
this.assertCanCancelBooking(row, actor);
const reason = payload?.cancellationReason?.trim() ?? '';
if (actor?.role === UserRole.BUSINESS_OWNER && !reason) {
throw new BadRequestException('Cancellation reason is required');
}
if (reason) {
row.cancellationReason = reason;
}
this.applyStatusTransition(row, BookingStatus.CANCELLED, actor);
return this.repo.save(row);
}