add cancellationReason
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user