Price calculation - DistributedTravels/Documentation GitHub Wiki
Price
Overall price can be calculated according to the formula below:
total_price = (priceReturnedByTransportService * numberPfPeople + priceReturnedByHotelService) * 1.5
priceReturnedByTransportService
and priceReturnedByHotelService
are prices returned by transport and hotel services. Calculation of these prices is described in the next sections.
If user give a discount code during reservation, the total_price
is multiplied by 0.9
.
Transport
Price per single seat and/or person for single flight is calculated based on distance between 2 countries, Source and Destination, one of which always being Poland. The price per person is calculated accordingly:
pricePerPerson = distance/2 + random(0-300)
We've taken the distance approach since we've noticed that's a pretty close approximate to recently checked seat prices for the most commonly used ferrying companies.
Hotels
Total price for staying in hotel can be retrieved from this formula:
totalPrice = totalPricePerDay * numberOfDays * numberOfPeople
Variable numberOfPeople
is correlated with the number of different types of rooms which are reserved. Each type of room can host a certain number of people. Variable mentioned above is the sum of these amounts.
numberOfDays
is a difference between last and first day of reservation - it is the number of full days of reservation
totalPricePerDay
is a basic price per day for one person. Moreover, if the breakfast can be chosen by the reserver and he added this option in his request, the cost of breakfast per day for one person is added to the described variable. Basic price and breakfast price are specific for each hotel.