Skip to content
Collection of algorithms related to price computation in Winding Tree
JavaScript
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Initial commit Dec 12, 2018
docs feat: Removes redundant change property Mar 12, 2019
src chore: fix linter Jul 12, 2019
test
.babelrc fix: Build pipeline for es5 Feb 21, 2019
.eslintrc.js Initial commit Dec 12, 2018
.gitignore Initial commit Dec 12, 2018
.npmignore Initial commit Dec 12, 2018
.nvmrc Initial commit Dec 12, 2018
.travis.yml chore: Moves from trusty to xenial on travis Apr 16, 2019
CONTRIBUTING.md Initial commit Dec 12, 2018
LICENSE Initial commit Dec 12, 2018
README.md chore: Drops greenkeeper Aug 13, 2019
package-lock.json chore: Updates deps Aug 12, 2019
package.json
rollup.config.js breaking: Removes the accidentally introduced named exports in builds Feb 22, 2019

README.md

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
You can’t perform that action at this time.