Skip to content

Commit

Permalink
Merge branch 'master' into add-recurring-bookings
Browse files Browse the repository at this point in the history
  • Loading branch information
stakach authored Jul 12, 2024
2 parents 1bca98b + c7105ba commit 7bd6efc
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

### Feat

- PPT-1437 Allow checkin by early_checkin value ([#325](https://github.com/PlaceOS/staff-api/pull/325))
- PPT-1326 Add endpoint to provide a list of booking ids ([#323](https://github.com/PlaceOS/staff-api/pull/323))
- **events**: preference metadata and system selection ([#322](https://github.com/PlaceOS/staff-api/pull/322))
- **bookings**: #index filter on permission field ([#320](https://github.com/PlaceOS/staff-api/pull/320))
Expand Down
7 changes: 7 additions & 0 deletions spec/controllers/bookings_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,13 @@ describe Bookings do

check_in_early = client.post("#{BOOKINGS_BASE}/#{booking.id}/check_in", headers: headers).status_code
check_in_early.should eq(405)

# allow early checkin by 1.5 hours
tenant.early_checkin = (1.5 * 60 * 60).to_i64
tenant.save!

check_in_early = client.post("#{BOOKINGS_BASE}/#{booking.id}/check_in", headers: headers).status_code
check_in_early.should eq(200)
end

it "cannot check in early when another booking is present" do
Expand Down
4 changes: 2 additions & 2 deletions src/controllers/bookings.cr
Original file line number Diff line number Diff line change
Expand Up @@ -771,9 +771,9 @@ class Bookings < Application

# Can't checkin after the booking end time
raise Error::NotAllowed.new("The booking has ended") if booking.booking_end <= time_now

early_checkin = booking.tenant!.early_checkin
# Check if we can check into a booking early (on the same day)
raise Error::NotAllowed.new("Can only check in an hour before the booking start") if (booking.booking_start - time_now) > 3600
raise Error::NotAllowed.new("Can only check in an #{early_checkin.seconds.total_hours} hour before the booking start") if (booking.booking_start - time_now) > early_checkin

# Check if there are any booking between now and booking start time
if booking.booking_start > time_now
Expand Down

0 comments on commit 7bd6efc

Please sign in to comment.