@windingtree/wt-pricing-algorithms

0.6.2 • Public • Published

Winding Tree Pricing algorithms

Greenkeeper badge

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

Readme

Keywords

Package Sidebar

Install

npm i @windingtree/wt-pricing-algorithms

Weekly Downloads

1

Version

0.6.2

License

Apache-2.0

Unpacked Size

250 kB

Total Files

15

Last publish

Collaborators

  • kostysh
  • kvakes
  • tomashq