[FIX]pms: allowed late checkin on checkout day

This commit is contained in:
Darío Lodeiros
2021-10-04 15:52:06 +02:00
parent 2be6d2a342
commit 5a80ee15c3
2 changed files with 29 additions and 3 deletions

View File

@@ -652,7 +652,7 @@ class PmsCheckinPartner(models.Model):
for record in self:
if record.reservation_id.checkin > fields.Date.today():
raise ValidationError(_("It is not yet checkin day!"))
if record.reservation_id.checkout <= fields.Date.today():
if record.reservation_id.checkout < fields.Date.today():
raise ValidationError(_("Its too late to checkin"))
if any(

View File

@@ -168,7 +168,7 @@ class TestPmsCheckinPartner(TestPms):
)
@freeze_time("2012-01-14")
def test_late_checkin(self):
def test_premature_checkin(self):
"""
Check that cannot change checkin_partner state to onboard if
it's not yet checkin day
@@ -184,8 +184,34 @@ class TestPmsCheckinPartner(TestPms):
with self.assertRaises(ValidationError, msg="Cannot do checkin onboard"):
self.checkin1.action_on_board()
@freeze_time("2012-01-14")
def test_late_checkin_on_checkout_day(self):
"""
Check that allowed register checkin arrival the next day
even if it is the same day of checkout
"""
# ARRANGE
self.reservation_1.write(
{
"checkin": datetime.date.today() + datetime.timedelta(days=-1),
"checkout": datetime.date.today(),
}
)
# ACT
self.checkin1.action_on_board()
# ASSERT
self.assertEqual(
self.checkin1.arrival,
fields.datetime.now(),
"""The system did not allow to check in the next
day because it was the same day of checkout""",
)
@freeze_time("2012-01-13")
def test_premature_checkin(self):
def test_late_checkin(self):
"""
When host arrives late anad has already passed the checkin day,
the arrival date is updated up to that time.