Skip to content

Commit

Permalink
[PBS-84][Anh Dao] fix: update amenity quatity
Browse files Browse the repository at this point in the history
  • Loading branch information
toki-ai committed Oct 31, 2024
1 parent d8b02e4 commit 53b4df0
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@ public void createOrderDetailAmenity(OrderDetailAmenityRequest request) {
}

public void updateAmenityQuantityAfterCreateODA(OrderDetailAmenity orderDetailAmenity) {
Amenity amenity = orderDetailAmenity.getAmenity();
Optional<Amenity> amenityOptional = amenityRepository.findById(orderDetailAmenity.getAmenity().getId());
if(amenityOptional.isEmpty()) {
throw new RuntimeException("Amenity not found");
}
Amenity amenity = amenityOptional.get();
if(amenity.getQuantity() < orderDetailAmenity.getQuantity()) {
throw new RuntimeException("Not enough quantity");
}
Expand Down

0 comments on commit 53b4df0

Please sign in to comment.