mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[ADD] 14.0 pms real avail compute (#60)
* [ADD]pms: avail real * [ADD] Wizards adaptation multiproperty & new real avail model * [ADD] Tests Wizard avail
This commit is contained in:
@@ -271,7 +271,6 @@ class TestPmsReservations(TestHotel):
|
||||
}
|
||||
)
|
||||
r_test.flush()
|
||||
|
||||
# ASSERT
|
||||
self.assertEqual(
|
||||
expected_num_changes,
|
||||
|
||||
@@ -262,6 +262,7 @@ class TestPmsRoomTypeAvailabilityRules(TestHotel):
|
||||
"room_type_id": self.test_room_type_double.id,
|
||||
"date": (fields.datetime.today() + datetime.timedelta(days=2)).date(),
|
||||
"closed": True, # <- (1/2)
|
||||
"pms_property_id": self.test_property.id,
|
||||
}
|
||||
)
|
||||
# ACT
|
||||
@@ -269,7 +270,7 @@ class TestPmsRoomTypeAvailabilityRules(TestHotel):
|
||||
checkin=fields.date.today(),
|
||||
checkout=(fields.datetime.today() + datetime.timedelta(days=4)).date(),
|
||||
# room_type_id=False, # <- (2/2)
|
||||
pricelist=self.test_pricelist1.id,
|
||||
pricelist_id=self.test_pricelist1.id,
|
||||
)
|
||||
# ASSERT
|
||||
self.assertNotIn(
|
||||
@@ -295,6 +296,7 @@ class TestPmsRoomTypeAvailabilityRules(TestHotel):
|
||||
"availability_plan_id": self.test_room_type_availability1.id,
|
||||
"room_type_id": self.test_room_type_double.id,
|
||||
"date": (fields.datetime.today() + datetime.timedelta(days=0)).date(),
|
||||
"pms_property_id": self.test_property.id,
|
||||
}
|
||||
)
|
||||
|
||||
@@ -410,7 +412,7 @@ class TestPmsRoomTypeAvailabilityRules(TestHotel):
|
||||
checkin=checkin,
|
||||
checkout=checkout,
|
||||
room_type_id=self.test_room_type_double.id,
|
||||
pricelist=self.test_pricelist1.id,
|
||||
pricelist_id=self.test_pricelist1.id,
|
||||
)
|
||||
|
||||
# ASSERT
|
||||
@@ -437,6 +439,7 @@ class TestPmsRoomTypeAvailabilityRules(TestHotel):
|
||||
"room_type_id": self.test_room_type_double.id,
|
||||
"date": (fields.datetime.today() + datetime.timedelta(days=2)).date(),
|
||||
"closed": True,
|
||||
"pms_property_id": self.test_property.id,
|
||||
}
|
||||
)
|
||||
checkin = datetime.datetime.now()
|
||||
@@ -475,6 +478,7 @@ class TestPmsRoomTypeAvailabilityRules(TestHotel):
|
||||
"room_type_id": self.test_room_type_double.id,
|
||||
"date": (fields.datetime.today() + datetime.timedelta(days=2)).date(),
|
||||
"closed": True,
|
||||
"pms_property_id": self.test_property.id,
|
||||
}
|
||||
)
|
||||
|
||||
@@ -537,6 +541,7 @@ class TestPmsRoomTypeAvailabilityRules(TestHotel):
|
||||
"room_type_id": self.test_room_type_double.id,
|
||||
"date": datetime.date.today(),
|
||||
"quota": 1,
|
||||
"pms_property_id": self.test_property.id,
|
||||
}
|
||||
)
|
||||
r1 = self.env["pms.reservation"].create(
|
||||
@@ -587,6 +592,7 @@ class TestPmsRoomTypeAvailabilityRules(TestHotel):
|
||||
"room_type_id": self.test_room_type_double.id,
|
||||
"date": datetime.date.today(),
|
||||
"quota": test_quota,
|
||||
"pms_property_id": self.test_property.id,
|
||||
}
|
||||
)
|
||||
reservation = self.env["pms.reservation"].create(
|
||||
@@ -687,7 +693,7 @@ class TestPmsRoomTypeAvailabilityRules(TestHotel):
|
||||
fields.datetime.today() + datetime.timedelta(days=2)
|
||||
).date(),
|
||||
room_type_id=self.test_room_type_special.id,
|
||||
pricelist=self.test_pricelist1.id,
|
||||
pricelist_id=self.test_pricelist1.id,
|
||||
pms_property_id=p["property"],
|
||||
)
|
||||
# ASSERT
|
||||
@@ -730,6 +736,7 @@ class TestPmsRoomTypeAvailabilityRules(TestHotel):
|
||||
"room_type_id": self.test_room_type_special.id,
|
||||
"date": (fields.datetime.today() + datetime.timedelta(days=2)).date(),
|
||||
"closed": True,
|
||||
"pms_property_id": self.test_property1.id,
|
||||
}
|
||||
)
|
||||
# Test cases when creating a availability_rule
|
||||
@@ -794,6 +801,7 @@ class TestPmsRoomTypeAvailabilityRules(TestHotel):
|
||||
"room_type_id": self.test_room_type_special.id,
|
||||
"date": (fields.datetime.today() + datetime.timedelta(days=2)).date(),
|
||||
"closed": True,
|
||||
"pms_property_id": self.test_property1.id,
|
||||
}
|
||||
)
|
||||
|
||||
@@ -802,6 +810,3 @@ class TestPmsRoomTypeAvailabilityRules(TestHotel):
|
||||
self.availability_rule1.allowed_property_ids.mapped("id"),
|
||||
"error",
|
||||
)
|
||||
|
||||
# plan 1 property 01 | rule property: False
|
||||
# plan 1 property 02 | rule property: False
|
||||
|
||||
@@ -150,7 +150,6 @@ class TestPmsWizardMassiveChanges(TestHotel):
|
||||
# Set values for the wizard and the total price is correct
|
||||
# Also check the discount is correctly applied to get
|
||||
# the total folio price
|
||||
# (no pricelist applied)
|
||||
|
||||
# ARRANGE
|
||||
# common scenario
|
||||
@@ -183,6 +182,8 @@ class TestPmsWizardMassiveChanges(TestHotel):
|
||||
"start_date": checkin,
|
||||
"end_date": checkout,
|
||||
"partner_id": self.partner_id.id,
|
||||
"pms_property_id": self.test_property.id,
|
||||
"pricelist_id": self.test_pricelist.id,
|
||||
}
|
||||
)
|
||||
|
||||
@@ -206,7 +207,6 @@ class TestPmsWizardMassiveChanges(TestHotel):
|
||||
)
|
||||
|
||||
lines_availability_test[0].num_rooms_selected = value
|
||||
|
||||
for discount in discounts:
|
||||
with self.subTest(k=discount):
|
||||
# ACT
|
||||
@@ -265,6 +265,7 @@ class TestPmsWizardMassiveChanges(TestHotel):
|
||||
"end_date": checkout,
|
||||
"partner_id": self.partner_id.id,
|
||||
"pricelist_id": self.test_pricelist.id,
|
||||
"pms_property_id": self.test_property.id,
|
||||
}
|
||||
)
|
||||
wizard_folio.flush()
|
||||
@@ -395,6 +396,7 @@ class TestPmsWizardMassiveChanges(TestHotel):
|
||||
"end_date": checkout,
|
||||
"partner_id": self.partner_id.id,
|
||||
"pricelist_id": self.test_pricelist.id,
|
||||
"pms_property_id": self.test_property.id,
|
||||
}
|
||||
)
|
||||
wizard_folio.flush()
|
||||
@@ -444,6 +446,7 @@ class TestPmsWizardMassiveChanges(TestHotel):
|
||||
"end_date": checkout,
|
||||
"partner_id": self.partner_id.id,
|
||||
"pricelist_id": self.test_pricelist.id,
|
||||
"pms_property_id": self.test_property.id,
|
||||
}
|
||||
)
|
||||
wizard_folio.flush()
|
||||
@@ -495,6 +498,7 @@ class TestPmsWizardMassiveChanges(TestHotel):
|
||||
"end_date": checkout,
|
||||
"partner_id": self.partner_id.id,
|
||||
"pricelist_id": self.test_pricelist.id,
|
||||
"pms_property_id": self.test_property.id,
|
||||
}
|
||||
)
|
||||
wizard_folio.flush()
|
||||
@@ -552,6 +556,7 @@ class TestPmsWizardMassiveChanges(TestHotel):
|
||||
"end_date": checkout,
|
||||
"partner_id": self.partner_id.id,
|
||||
"pricelist_id": self.test_pricelist.id,
|
||||
"pms_property_id": self.test_property.id,
|
||||
}
|
||||
)
|
||||
wizard_folio.flush()
|
||||
@@ -585,6 +590,7 @@ class TestPmsWizardMassiveChanges(TestHotel):
|
||||
"room_type_id": self.test_room_type_double,
|
||||
"partner_id": self.partner_id.id,
|
||||
"pricelist_id": folio.pricelist_id.id,
|
||||
"pms_property_id": self.test_property.id,
|
||||
}
|
||||
|
||||
# ASSERT
|
||||
@@ -593,7 +599,8 @@ class TestPmsWizardMassiveChanges(TestHotel):
|
||||
with self.subTest(k=key):
|
||||
self.assertEqual(
|
||||
reservation[key].id
|
||||
if key in ["folio_id", "partner_id", "pricelist_id"]
|
||||
if key
|
||||
in ["folio_id", "partner_id", "pricelist_id", "pms_property_id"]
|
||||
else reservation[key],
|
||||
vals[key],
|
||||
"The value of " + key + " is not correctly established",
|
||||
@@ -620,6 +627,7 @@ class TestPmsWizardMassiveChanges(TestHotel):
|
||||
"partner_id": self.partner_id.id,
|
||||
"pricelist_id": self.test_pricelist.id,
|
||||
"discount": discount,
|
||||
"pms_property_id": self.test_property.id,
|
||||
}
|
||||
)
|
||||
wizard_folio.flush()
|
||||
@@ -655,3 +663,87 @@ class TestPmsWizardMassiveChanges(TestHotel):
|
||||
discount * 100,
|
||||
"The discount is not correctly established",
|
||||
)
|
||||
|
||||
def test_check_quota_avail(self):
|
||||
# TEST CASE
|
||||
# Check avail on room type with quota
|
||||
|
||||
# ARRANGE
|
||||
# common scenario
|
||||
self.create_common_scenario()
|
||||
|
||||
# checkin & checkout
|
||||
checkin = fields.date.today()
|
||||
checkout = fields.date.today() + datetime.timedelta(days=1)
|
||||
|
||||
self.env["pms.room.type.availability.rule"].create(
|
||||
{
|
||||
"quota": 1,
|
||||
"room_type_id": self.test_room_type_double.id,
|
||||
"availability_plan_id": self.test_availability_plan.id,
|
||||
"date": fields.date.today(),
|
||||
"pms_property_id": self.test_property.id,
|
||||
}
|
||||
)
|
||||
|
||||
# create folio wizard with partner id => pricelist & start-end dates
|
||||
wizard_folio = self.env["pms.folio.wizard"].create(
|
||||
{
|
||||
"start_date": checkin,
|
||||
"end_date": checkout,
|
||||
"partner_id": self.partner_id.id,
|
||||
"pricelist_id": self.test_pricelist.id,
|
||||
"pms_property_id": self.test_property.id,
|
||||
}
|
||||
)
|
||||
wizard_folio.flush()
|
||||
|
||||
room_type_plan_avail = wizard_folio.availability_results.filtered(
|
||||
lambda r: r.room_type_id.id == self.test_room_type_double.id
|
||||
).num_rooms_available
|
||||
|
||||
# ASSERT
|
||||
|
||||
self.assertEqual(room_type_plan_avail, 1, "Quota not applied in Wizard Folio")
|
||||
|
||||
def test_check_min_stay_avail(self):
|
||||
# TEST CASE
|
||||
# Check avail on room type with quota
|
||||
|
||||
# ARRANGE
|
||||
# common scenario
|
||||
self.create_common_scenario()
|
||||
|
||||
# checkin & checkout
|
||||
checkin = fields.date.today()
|
||||
checkout = fields.date.today() + datetime.timedelta(days=1)
|
||||
|
||||
self.env["pms.room.type.availability.rule"].create(
|
||||
{
|
||||
"min_stay": 3,
|
||||
"room_type_id": self.test_room_type_double.id,
|
||||
"availability_plan_id": self.test_availability_plan.id,
|
||||
"date": fields.date.today(),
|
||||
"pms_property_id": self.test_property.id,
|
||||
}
|
||||
)
|
||||
|
||||
# create folio wizard with partner id => pricelist & start-end dates
|
||||
wizard_folio = self.env["pms.folio.wizard"].create(
|
||||
{
|
||||
"start_date": checkin,
|
||||
"end_date": checkout,
|
||||
"partner_id": self.partner_id.id,
|
||||
"pricelist_id": self.test_pricelist.id,
|
||||
"pms_property_id": self.test_property.id,
|
||||
}
|
||||
)
|
||||
wizard_folio.flush()
|
||||
|
||||
room_type_plan_avail = wizard_folio.availability_results.filtered(
|
||||
lambda r: r.room_type_id.id == self.test_room_type_double.id
|
||||
).num_rooms_available
|
||||
|
||||
# ASSERT
|
||||
|
||||
self.assertEqual(room_type_plan_avail, 0, "Quota not applied in Wizard Folio")
|
||||
|
||||
@@ -78,6 +78,7 @@ class TestPmsWizardMassiveChanges(TestHotel):
|
||||
"start_date": fields.date.today(),
|
||||
"end_date": fields.date.today() + datetime.timedelta(days=days),
|
||||
"room_type_id": self.test_room_type_double.id,
|
||||
"pms_property_ids": [self.test_property.id],
|
||||
}
|
||||
).apply_massive_changes()
|
||||
|
||||
@@ -98,7 +99,13 @@ class TestPmsWizardMassiveChanges(TestHotel):
|
||||
date_from = fields.date.today()
|
||||
date_to = fields.date.today() + datetime.timedelta(days=3)
|
||||
|
||||
num_room_types = self.env["pms.room.type"].search_count([])
|
||||
num_room_types = self.env["pms.room.type"].search_count(
|
||||
[
|
||||
"|",
|
||||
("pms_property_ids", "=", False),
|
||||
("pms_property_ids", "in", self.test_property.id),
|
||||
]
|
||||
)
|
||||
num_exp_rules_to_create = ((date_to - date_from).days + 1) * num_room_types
|
||||
|
||||
# ACT
|
||||
@@ -108,6 +115,7 @@ class TestPmsWizardMassiveChanges(TestHotel):
|
||||
"availability_plan_id": self.test_availability_plan.id,
|
||||
"start_date": date_from,
|
||||
"end_date": date_to,
|
||||
"pms_property_ids": [self.test_property.id],
|
||||
}
|
||||
).apply_massive_changes()
|
||||
|
||||
@@ -144,6 +152,7 @@ class TestPmsWizardMassiveChanges(TestHotel):
|
||||
"closed": True,
|
||||
"closed_arrival": True,
|
||||
"closed_departure": True,
|
||||
"pms_property_ids": [self.test_property.id],
|
||||
}
|
||||
|
||||
# ACT
|
||||
@@ -155,6 +164,7 @@ class TestPmsWizardMassiveChanges(TestHotel):
|
||||
del vals["start_date"]
|
||||
del vals["end_date"]
|
||||
del vals["room_type_id"]
|
||||
del vals["pms_property_ids"]
|
||||
for key in vals:
|
||||
with self.subTest(k=key):
|
||||
self.assertEqual(
|
||||
@@ -190,6 +200,7 @@ class TestPmsWizardMassiveChanges(TestHotel):
|
||||
"room_type_id": self.test_room_type_double.id,
|
||||
"start_date": date_from,
|
||||
"end_date": date_to,
|
||||
"pms_property_ids": [self.test_property.id],
|
||||
}
|
||||
)
|
||||
|
||||
@@ -243,6 +254,7 @@ class TestPmsWizardMassiveChanges(TestHotel):
|
||||
"start_date": fields.date.today(),
|
||||
"end_date": fields.date.today() + datetime.timedelta(days=days),
|
||||
"room_type_id": self.test_room_type_double.id,
|
||||
"pms_property_ids": [self.test_property.id],
|
||||
}
|
||||
).apply_massive_changes()
|
||||
# ASSERT
|
||||
@@ -266,7 +278,13 @@ class TestPmsWizardMassiveChanges(TestHotel):
|
||||
self.create_common_scenario()
|
||||
date_from = fields.date.today()
|
||||
date_to = fields.date.today() + datetime.timedelta(days=3)
|
||||
num_room_types = self.env["pms.room.type"].search_count([])
|
||||
num_room_types = self.env["pms.room.type"].search_count(
|
||||
[
|
||||
"|",
|
||||
("pms_property_ids", "=", False),
|
||||
("pms_property_ids", "in", self.test_property.id),
|
||||
]
|
||||
)
|
||||
num_exp_items_to_create = ((date_to - date_from).days + 1) * num_room_types
|
||||
|
||||
# ACT
|
||||
@@ -276,6 +294,7 @@ class TestPmsWizardMassiveChanges(TestHotel):
|
||||
"pricelist_id": self.test_pricelist.id,
|
||||
"start_date": date_from,
|
||||
"end_date": date_to,
|
||||
"pms_property_ids": [self.test_property.id],
|
||||
}
|
||||
).apply_massive_changes()
|
||||
|
||||
@@ -305,8 +324,8 @@ class TestPmsWizardMassiveChanges(TestHotel):
|
||||
"date_start": date_from,
|
||||
"date_end": date_to,
|
||||
"compute_price": "fixed",
|
||||
"applied_on": "1_product",
|
||||
"product_tmpl_id": self.test_room_type_double.product_id.product_tmpl_id,
|
||||
"applied_on": "0_product_variant",
|
||||
"product_id": self.test_room_type_double.product_id,
|
||||
"fixed_price": price,
|
||||
"min_quantity": min_quantity,
|
||||
}
|
||||
@@ -321,6 +340,7 @@ class TestPmsWizardMassiveChanges(TestHotel):
|
||||
"room_type_id": self.test_room_type_double.id,
|
||||
"price": price,
|
||||
"min_quantity": min_quantity,
|
||||
"pms_property_ids": [self.test_property.id],
|
||||
}
|
||||
).apply_massive_changes()
|
||||
vals["date_start_overnight"] = date_from
|
||||
@@ -362,6 +382,7 @@ class TestPmsWizardMassiveChanges(TestHotel):
|
||||
"room_type_id": self.test_room_type_double.id,
|
||||
"start_date": date_from,
|
||||
"end_date": date_to,
|
||||
"pms_property_ids": [self.test_property.id],
|
||||
}
|
||||
)
|
||||
for index, test_case in enumerate(test_case_week_days):
|
||||
|
||||
Reference in New Issue
Block a user