villafleurie/rental/pricing.py
2019-12-03 13:39:43 +01:00

18 lines
539 B
Python

def get_reservation_price(place, start, end):
"""
Compute booking price as a function of place and dates
"""
nights = (end - start).days
return place.price * nights
if __name__ == '__main__':
from rental.models import Place
from datetime import *
from django.shortcuts import get_object_or_404
place_name = 'T2'
place = get_object_or_404(Place, name=place_name)
start = datetime(2019, 11, 14)
end = datetime(2019, 11, 20)
x = get_reservation_price(place_name, start, end)
print(x)