plugins development
This commit is contained in:
@@ -34,4 +34,22 @@ async def get_reservations(hotel_id, start_date=None, end_date=None):
|
||||
query = query.filter(check_in__gte=start_date)
|
||||
if end_date:
|
||||
query = query.filter(check_out__lte=end_date)
|
||||
return await sync_to_async(list)(query.prefetch_related('guests'))
|
||||
return await sync_to_async(list)(query.prefetch_related('guests'))
|
||||
|
||||
def save_reservations(data):
|
||||
"""
|
||||
Сохранение данных бронирований в базу данных.
|
||||
:param data: Список бронирований.
|
||||
"""
|
||||
for booking in data:
|
||||
Reservation.objects.update_or_create(
|
||||
external_id=booking['id'],
|
||||
defaults={
|
||||
'check_in': booking['begin_date'],
|
||||
'check_out': booking['end_date'],
|
||||
'amount': booking['amount'],
|
||||
'notes': booking.get('notes', ''),
|
||||
'guest_name': booking['client']['fio'],
|
||||
'guest_phone': booking['client']['phone'],
|
||||
},
|
||||
)
|
||||
Reference in New Issue
Block a user