Allow rate plan code per room type
All checks were successful
build-and-deploy / build-deploy (push) Successful in 35s
All checks were successful
build-and-deploy / build-deploy (push) Successful in 35s
This commit is contained in:
@@ -50,14 +50,14 @@ class RatePlans(
|
||||
@RequestBody request: RatePlanCreateRequest
|
||||
): RatePlanResponse {
|
||||
requireRole(propertyAccess, propertyId, principal, Role.ADMIN, Role.MANAGER)
|
||||
if (ratePlanRepo.existsByPropertyIdAndCode(propertyId, request.code.trim())) {
|
||||
throw ResponseStatusException(HttpStatus.CONFLICT, "Rate plan code already exists")
|
||||
}
|
||||
val property = propertyRepo.findById(propertyId).orElseThrow {
|
||||
ResponseStatusException(HttpStatus.NOT_FOUND, "Property not found")
|
||||
}
|
||||
val roomType = roomTypeRepo.findByPropertyIdAndCodeIgnoreCase(propertyId, request.roomTypeCode)
|
||||
?: throw ResponseStatusException(HttpStatus.NOT_FOUND, "Room type not found")
|
||||
if (ratePlanRepo.existsByPropertyIdAndRoomTypeIdAndCode(propertyId, roomType.id!!, request.code.trim())) {
|
||||
throw ResponseStatusException(HttpStatus.CONFLICT, "Rate plan code already exists for room type")
|
||||
}
|
||||
|
||||
val plan = RatePlan(
|
||||
property = property,
|
||||
|
||||
Reference in New Issue
Block a user