Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: PPT-1437 Allow checkin by early_checkin value #325

Merged
merged 1 commit into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions shard.lock
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ shards:

neuroplastic:
git: https://github.com/spider-gazelle/neuroplastic.git
version: 1.13.0
version: 1.13.1

office365:
git: https://github.com/placeos/office365.git
Expand Down Expand Up @@ -159,23 +159,23 @@ shards:

pg-orm:
git: https://github.com/spider-gazelle/pg-orm.git
version: 1.1.0+git.commit.e35e4c535be1ab47b6afb821723ceafb637fa4e8
version: 1.1.0+git.commit.27528d29d0b4e6184d9bc52d9e8ffdf2685ec5d3

place_calendar:
git: https://github.com/placeos/calendar.git
version: 4.22.1

placeos:
git: https://github.com/placeos/crystal-client.git
version: 2.10.0
version: 2.11.0

placeos-log-backend:
git: https://github.com/place-labs/log-backend.git
version: 0.11.0

placeos-models:
git: https://github.com/placeos/models.git
version: 9.48.0
version: 9.52.0

pool:
git: https://github.com/ysbaddaden/pool.git
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 @@ -747,6 +747,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 @@ -727,9 +727,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
Loading