Skip to content

Conversation

@diebas
Copy link
Collaborator

@diebas diebas commented Dec 3, 2025

Notes

Fix daily booking validation to properly enforce minimum and maximum reservation days. Previously, when creating a reservation for a daily booking instrument, the system only checked max_reserve_mins and min_reserve_mins (which are nil for daily bookings), allowing users to create reservations that exceeded the configured max_reserve_days limit.

NUOPEN-296 | Issue related with Daily booking

Additional Context

Root Cause

The validation methods satisfies_minimum_length? and satisfies_maximum_length? in app/support/reservations/validations.rb were only checking minute-based fields:

# Before fix - always returned true for daily bookings because max_reserve_mins is nil
def satisfies_maximum_length?
  return true if product.max_reserve_mins.to_i == 0  # nil.to_i == 0, so always true
  # ... rest of validation never executed for daily bookings
end

@diebas diebas marked this pull request as ready for review December 3, 2025 18:11
@diebas diebas changed the title Fix daily booking issue [NUOPEN-296] Fix daily booking issue Dec 3, 2025
@diebas diebas force-pushed the nuopen-296/fix-daily-booking-issue branch from d01a4ab to 48abe75 Compare December 3, 2025 18:42
Copy link
Collaborator

@LeticiaErrandonea LeticiaErrandonea left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

duration_days >= product.min_reserve_days
else
diff = reserve_end_at - reserve_start_at # in seconds
true if product.min_reserve_mins.nil? || product.min_reserve_mins == 0 || diff / 60 >= product.min_reserve_mins
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this make sense?

Suggested change
true if product.min_reserve_mins.nil? || product.min_reserve_mins == 0 || diff / 60 >= product.min_reserve_mins
product.min_reserve_mins.nil? || product.min_reserve_mins == 0 || diff / 60 >= product.min_reserve_mins

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants