getOccupancyReport
Generates a comprehensive occupancy report for a specific date, including total rooms, occupied/available breakdown, and statistics by room type.Function Signature
Parameters
The hotel object to generate the report for
The date to check occupancy for in ISO format (e.g., ‘2026-03-22’). Can be past, present, or future.
How It Works
- Combines Data: Creates a clone of both active reservations and historical reservations (main.js:242-245)
- Filters by Date: Uses
isDateInRange()to find all reservations where the specified date falls within check-in and check-out dates (main.js:250, validation.js:32-40) - Gets Room Details: Maps reservation room numbers to full room objects (main.js:251)
- Calculates Metrics: Computes total, occupied, available counts and percentage
- Breaks Down by Type: Groups statistics by room type (single, double, suite)
Return Value
Detailed occupancy report object
Example
Expected Output
The report includes both active reservations and historical data, making it accurate for past, present, and future dates.
Related Functions
isDateInRange()- Checks if date falls within reservation dates (validation.js:32-40)getRoomByNumber()- Gets room details (utils.js:18-21)getRoomsByType()- Filters rooms by type (utils.js:33-35)
getRevenueReport
Calculates total revenue for a date range, including room charges and extras, with reservation count.Function Signature
Parameters
The hotel object to generate the revenue report for
Start date of the reporting period in ISO format (e.g., ‘2026-01-01’)
End date of the reporting period in ISO format (e.g., ‘2026-03-22’)
How Revenue is Calculated
- Combines Data: Gets all reservations + history using
getReservationsPlusHistory()(main.js:283, utils.js:207-209) - Filters by Range: Uses
isRangeInRange()to find reservations where BOTH check-in and check-out fall within the specified date range (main.js:288-290, validation.js:42-51) - Excludes Cancelled: Filters out reservations with status
'cancelled'(main.js:294) - Calculates Extras: Sums all extras using
getExtrasPrice()for each reservation (main.js:306-308, utils.js:122-127) - Calculates Total: Sums all
totalPricevalues from valid reservations (main.js:309-311)
Return Value
Revenue report with financial breakdown
Example
Expected Output
Revenue Breakdown Example
The
total field in the report represents the sum of all reservation totalPrice values, which already include extras. The separate extras field shows extras revenue for analytical purposes.Related Functions
getReservationsPlusHistory()- Combines active and historical reservations (utils.js:207-209)isRangeInRange()- Validates date ranges overlap (validation.js:42-51)getExtrasPrice()- Calculates extras total (utils.js:122-127)
getGuestHistory
Retrieves complete reservation history and spending summary for a specific guest by email.Function Signature
Parameters
The hotel object to search within
The email address of the guest (used as unique identifier)
How It Works
- Get All Reservations: Retrieves combined reservations and history (main.js:320)
- Filter by Email: Finds all reservations matching
guest.email(main.js:322-324) - Extract Guest Data: Gets guest info from the first matching reservation (main.js:326-328)
- Calculate Total Spent: Sums all
totalPricevalues (main.js:330-332) - Calculate Total Extras: Sums all extras charges separately (main.js:334-336)
- Map Reservations: Creates simplified reservation list (main.js:343-350)
Return Value
Complete guest profile with reservation history
Example
Expected Output
Total Spent Calculation
- The function searches across both active reservations and historical data
- All reservation statuses are included (confirmed, checked_in, checked_out, cancelled)
- Guest data (name, phone, dni) is extracted from the reservation records
Use Cases
- Guest Loyalty Programs: Track total spending for rewards
- Customer Service: View complete reservation history
- Analytics: Identify repeat customers and their preferences
- Billing Inquiries: Verify past charges and reservations
Related Functions
getReservationsPlusHistory()- Combines all reservation data (utils.js:207-209)getExtrasPrice()- Calculates extras total (utils.js:122-127)