Functional Weave
Code in Python

hospitality.occupancy-adr-revpar@1.0.0

README.md

1,507 bytes · view raw

# hospitality.occupancy-adr-revpar

The three headline hotel figures for a period, from three totals:

- **Occupancy** = room-nights sold / room-nights available, in basis points
  (7500 is 75%).
- **ADR** (average daily rate) = room revenue / room-nights sold. It is `null`
  when nothing was sold, because the average of no sales is undefined, not 0.
- **RevPAR** (revenue per available room) = room revenue / room-nights
  available.

## Why it is shaped this way

Each figure is divided out of the raw totals and rounded half-up once, to the
minor unit or the basis point. RevPAR is *not* worked out as ADR x occupancy:
both of those are already rounded, and multiplying rounded figures can land a
penny away from the true value. ADR x occupancy is the identity to explain
RevPAR with, not the way to compute it.

Room-nights, not rooms: a 100-room hotel over 30 nights has 3,000 room-nights
available.

## What the caller decides

The industry definitions (STR's glossary, for example) leave choices to the
operator, and this function takes the totals as given:

- whether out-of-order rooms come off the rooms available;
- whether complimentary and house-use rooms count as sold (they add nights but
  no revenue, pulling ADR down);
- what counts as room revenue. Use it net of VAT, and without breakfast,
  packages' food element or other extras, so figures compare across hotels.

## Errors

At least one room-night must be available; sold must be from 0 to available;
revenue must not be negative.