@windingtree/wt-pricing-algorithms
v0.6.2
Published
Javascript libraries to compute prices from Winding Tree data model
Downloads
15
Readme
Winding Tree Pricing algorithms
Javascript implementation of pricing algorithms based on data stored in Winding Tree platform.
Installation and usage
npm install @windingtree/wt-pricing-algorithms
import {
prices, availability, cancellationFees
} from '@windingtree/wt-pricing-algorithms';
<script type="text/javascript" src="https://unpkg.com/@windingtree/wt-pricing-algorithms"></script>
<script type="text/javascript">
// Price
const pc = new window.wtPricingAlgorithms.prices.PriceComputer(
hotelDataFromApi.roomTypes,
hotelDataFromApi.ratePlans,
hotelDataFromApi.currency
);
// You can use different pricing strategies, see the generated documentation for that
resultingPrice = pc.getBestPrice(
new Date(), // Booking date
arrival,
departure,
guests,
hotelDataFromApi.currency,
roomType
);
// Availability
const indexedAvailability = window.wtPricingAlgorithms.availability.indexAvailability(
hotelDataFromApi.availability.roomTypes
);
const roomAvailability = window.wtPricingAlgorithms.availability.computeAvailability(
arrival,
departure,
guests.length,
hotelDataFromApi.roomTypes,
indexedAvailability
);
// Cancellation fees
const cancellationFees = window.wtPricingAlgorithms.cancellationFees.computeCancellationFees(
new Date(),
dayjs(arrivalDateInput.value),
hotelDataFromApi.cancellationPolicies,
hotelDataFromApi.defaultCancellationAmount
);
</script>
Development
git clone https://github.com/windingtree/wt-pricing-algorithms
nvm install
npm install
npm test