# Complete Booking Flow Documentation
## Overview
This document provides a comprehensive overview of the entire booking flow implemented in the Zapazime PMS system, covering the complete lifecycle from booking creation to post-stay management.
## Table of Contents
1. [Booking Lifecycle](#booking-lifecycle)
2. [Core Models](#core-models)
3. [Services](#services)
4. [Controllers](#controllers)
5. [Workflow Stages](#workflow-stages)
6. [Data Integrity Features](#data-integrity-features)
7. [Notification System](#notification-system)
8. [Document Generation](#document-generation)
---
## Booking Lifecycle
```
BOOKING CREATION → PRE-ARRIVAL → CHECK-IN VALIDATION → CHECK-IN → ACTIVE STAY → CHECK-OUT → POST-STAY
```
### 1. Booking Creation
- User creates booking via frontend or admin panel
- System validates availability and pricing
- Booking record created with status 'confirmed'
- Invoice may be generated (proforma or final)
- Payment processed based on payment mode
### 2. Pre-Arrival
- Automated reminders sent 1 day before check-in
- Pre-check-in link generated for guests
- Guests can complete pre-check-in online
- ETA tracking and special requests collected
### 3. Check-In Validation
- System validates booking status
- Checks payment requirements
- Validates room availability
- Verifies guest information completeness
### 4. Check-In
- Booking status updated to 'checked'
- Stay record created
- Booking guests converted to stay guests
- Room assignment created
- Active folio created
- Audit log entry created
### 5. Active Stay
- Room changes supported
- Guest additions/removals
- Stay extensions/shortenings
- Services and charges added
- Folio updates and payments
### 6. Check-Out
- Stay status updated to 'completed'
- Booking status updated to 'checkout'
- Folio reviewed and finalized
- Final payment processed
- Documents generated (invoice, receipt)
### 7. Post-Stay
- Room status updated (occupied → dirty → cleaning → inspected → available)
- Thank-you messages sent
- Review requests sent
- Loyalty points calculated
---
## Core Models
### Booking Model (`app/Models/Booking.php`)
**Purpose:** Represents a booking/reservation in the system.
**Key Fields:**
- `booking_number` - Unique booking identifier
- `status` - confirmed, checked, checkout, cancelled, no_show
- `check_in`, `check_out` - Booking dates
- `total_amount`, `deposit_amount` - Financial amounts
- `payment_status` - Payment tracking
- `payment_mode` - full_electronic, deposit_platform_remainder_onsite, payment_guarantee, onsite_payment
**Key Methods:**
- `checkIn()` - Process check-in with idempotency
- `checkOut()` - Process check-out
- `markAsNoShow()` - Handle no-show workflow
- `canCheckIn()` - Validation check
- `cancel()` - Cancel booking with reason
**Relationships:**
- `bookingGuests` - Guests on the booking
- `venueObjects` - Rooms/units booked
- `venueSpots` - Additional spots (beach, parking)
- `venueServices` - Additional services
- `venuePackages` - Packages included
- `client` - Client who made booking
- `company`, `workspace` - Ownership
- `stays` - Associated stay records
### Stay Model (`app/Models/Stay.php`)
**Purpose:** Represents the actual stay when guest is on property.
**Key Fields:**
- `stay_number` - Unique stay identifier
- `status` - pending, active, completed, cancelled
- `expected_check_in`, `expected_check_out`, `expected_nights` - Original booking dates
- `actual_check_in`, `actual_check_out`, `actual_nights` - Actual stay dates
- `actual_amount`, `deposit_amount`, `additional_charges` - Financial tracking
- `guests_snapshot` - Guest information at check-in
- `metadata` - Guest tracking, custom data
**Key Methods:**
- `checkIn()` - Activate stay
- `checkOut()` - Complete stay
- `activeFolio()` - Get current folio
- `currentRoomAssignment()` - Get current room
**Relationships:**
- `booking` - Original booking
- `stayGuests` - Guests on stay
- `stayRoomAssignments` - Room history
- `folios` - Associated folios
### StayGuest Model (`app/Models/StayGuest.php`)
**Purpose:** Represents guests during their actual stay.
**Key Fields:**
- `stay_id` - Associated stay
- `guest_id` - Guest profile
- `is_primary` - Primary guest flag
- `guest_type` - adult, child, infant
- `room_assignment` - Room assignment
- `checked_in_at`, `checked_out_at` - Timestamps
- `notes` - Additional notes
### StayRoomAssignment Model (`app/Models/StayRoomAssignment.php`)
**Purpose:** Tracks room assignments and history during stay.
**Key Fields:**
- `stay_id` - Associated stay
- `venue_object_id` - Assigned room
- `assigned_by`, `assigned_at` - Assignment details
- `checked_in_at`, `checked_out_at` - Guest usage
- `released_at`, `released_by` - Room change tracking
- `assignment_reason` - initial, upgrade, downgrade, maintenance, guest_request, overbooking, other
- `notes` - Additional notes
**Assignment Reasons:**
- `REASON_INITIAL` - First room assignment
- `REASON_UPGRADE` - Room upgrade
- `REASON_DOWNGRADE` - Room downgrade
- `REASON_MAINTENANCE` - Maintenance required
- `REASON_GUEST_REQUEST` - Guest requested change
- `REASON_OVERBOOKING` - Overbooking resolution
- `REASON_OTHER` - Other reason
### Folio Model (`app/Models/Folio.php`)
**Purpose:** Represents a guest folio for charges and payments.
**Key Fields:**
- `folio_number` - Unique folio identifier
- `stay_id` - Associated stay
- `status` - open, closed, cancelled
- `is_locked` - Locking flag
- `subtotal`, `tax_amount`, `total` - Financial totals
- `paid_amount` - Amount paid
**Key Methods:**
- `isLocked()` - Check if folio is locked
- `canEdit()` - Check if folio can be edited
- `lock()` - Lock folio
- `unlock()` - Unlock folio
- `addCharge()` - Add charge to folio
- `addPayment()` - Add payment to folio
- `recalculateTotals()` - Update totals
**Relationships:**
- `folioCharges` - Charges on folio
- `folioPayments` - Payments on folio
- `stay` - Associated stay
### Invoice Model (`app/Models/Invoice.php`)
**Purpose:** Represents invoices for billing purposes.
**Key Fields:**
- `invoice_number` - Unique invoice identifier
- `invoice_type` - proforma, final, credit_note
- `status` - draft, pending, sent, paid, cancelled
- `payment_status` - unpaid, partially_paid, paid
- `date`, `due_date` - Date tracking
- `subtotal`, `tax_amount`, `total` - Financial totals
- `paid` - Amount paid
**Key Methods:**
- `generateInvoiceNumber()` - Generate unique number
- `isPaid()`, `isUnpaid()`, `isPartiallyPaid()` - Status checks
- `isOverdue()` - Check if overdue
- `markAsPaid()` - Mark as paid
- `addPayment()` - Add payment
- `cancel()` - Cancel invoice
- `markAsOverdue()` - Mark as overdue and notify
- `recalculateTotals()` - Calculate from items
**Relationships:**
- `invoiceItems` - Line items
- `booking` - Associated booking
- `client` - Client billed
- `creditInvoices` - Credit notes
- `originalInvoice` - Original invoice (for credit notes)
### FiscalReceipt Model (`app/Models/FiscalReceipt.php`)
**Purpose:** Represents fiscal receipts for tax compliance.
**Key Fields:**
- `receipt_number` - Unique receipt identifier
- `invoice_id` - Associated invoice
- `payment_id` - Associated payment
- `status` - pending, sent, failed
- `fiscal_data` - Fiscal device data
- `sent_at`, `failed_at` - Timestamps
---
## Services
### BookingToStayGuestService (`app/Services/BookingToStayGuestService.php`)
**Purpose:** Convert booking guests to stay guests with tracking.
**Key Methods:**
- `convertBookingGuestsToStayGuests()` - Convert guests with data overrides
- `updateStayGuestTracking()` - Update guest tracking in metadata
- `getGuestTracking()` - Get expected vs actual guest comparison
- `getOrCreateGuest()` - Find or create guest profile
**Features:**
- DB transaction with rollback
- Expected vs actual guest tracking
- Guest profile management
- Idempotency on guest check-in
### RoomChangeManagementService (`app/Services/RoomChangeManagementService.php`)
**Purpose:** Manage room assignments and changes during stay.
**Key Methods:**
- `createInitialAssignment()` - Create first room assignment
- `changeRoom()` - Change room with reason
- `checkInRoom()` - Mark room as checked in
- `checkOutRoom()` - Mark room as checked out
- `releaseRoom()` - Release room for changes
- `isRoomAvailable()` - Check availability with concurrency
**Features:**
- Concurrency control with `lockForUpdate()`
- DB transaction with rollback
- Audit logging
- Room availability validation
- Released_at tracking for proper history
### StayModificationService (`app/Services/StayModificationService.php`)
**Purpose:** Handle stay modifications during active stay.
**Key Methods:**
- `extendStay()` - Extend stay with charge calculation
- `shortenStay()` - Shorten stay with credit note
- `addGuest()` - Add guest to stay
- `removeGuest()` - Remove guest from stay
- `addService()` - Add service to stay
- `removeService()` - Remove service from stay
**Features:**
- Folio locking validation
- DB transaction with rollback
- Audit logging
- Automatic charge calculation
- Guest tracking updates
### PreArrivalService (`app/Services/PreArrivalService.php`)
**Purpose:** Manage pre-arrival communication and pre-check-in.
**Key Methods:**
- `sendPreArrivalReminder()` - Send reminder notification
- `sendUpcomingReminders()` - Send to all upcoming bookings
- `generatePreCheckInLink()` - Generate secure pre-check-in link
- `validatePreCheckInToken()` - Validate pre-check-in token
- `submitPreCheckIn()` - Process pre-check-in data
- `getPreCheckInStatus()` - Get pre-check-in completion status
- `generateCheckInQR()` - Generate QR code for check-in
- `validateCheckInQR()` - Validate QR code for check-in
**Features:**
- Email and SMS notifications
- Secure token-based links
- ETA tracking
- Guest information updates
- Special requests collection
### CheckInValidationService (`app/Services/CheckInValidationService.php`)
**Purpose:** Validate booking before check-in.
**Key Methods:**
- `validateForCheckIn()` - Comprehensive validation
- `checkPaymentRequirements()` - Verify payment status
- `checkRoomAvailability()` - Verify room availability
- `checkGuestInformation()` - Verify guest data completeness
### InvoiceService (`app/Services/InvoiceService.php`)
**Purpose:** Create and manage invoices.
**Key Methods:**
- `createFromBooking()` - Create invoice from booking
- `createProformaFromBooking()` - Create proforma invoice
- `convertProformaToFinal()` - Convert to final invoice
- `createCreditNote()` - Create credit note from invoice
- `addProductToInvoice()` - Add product to existing invoice
- `addCustomFee()` - Add custom fee
- `addDiscount()` - Add discount
- `applyPercentageDiscount()` - Apply percentage discount
**Features:**
- Automatic item population (accommodations, spots, services, packages)
- Tax rate calculation
- Total recalculation
- Credit note generation
### CheckOutFolioReviewService (`app/Services/CheckOutFolioReviewService.php`)
**Purpose:** Review and finalize folio at check-out.
**Key Methods:**
- `getFolioSummary()` - Get folio summary for review
- `checkDiscrepancies()` - Check for discrepancies
- `validateBalance()` - Validate folio balance
- `approveAndFinalize()` - Approve and finalize folio
### PostStayService (`app/Services/PostStayService.php`)
**Purpose:** Handle post-stay communications and operations.
**Key Methods:**
- `sendThankYouMessage()` - Send thank-you message
- `sendReviewRequest()` - Request guest review
- `calculateLoyaltyPoints()` - Calculate loyalty points
- `collectFeedback()` - Collect guest feedback
### RoomStatusWorkflowService (`app/Services/RoomStatusWorkflowService.php`)
**Purpose:** Manage room status workflow after check-out.
**Key Methods:**
- `transitionToDirty()` - Mark room as dirty
- `transitionToCleaning()` - Mark room as cleaning
- `transitionToInspected()` - Mark room as inspected
- `transitionToAvailable()` - Mark room as available
- `validateTransition()` - Validate status transition
- `getStatusHistory()` - Get status history
**Status Flow:**
```
available → occupied → dirty → cleaning → inspected → available
```
### AuditLogService (`app/Services/AuditLogService.php`)
**Purpose:** Log critical actions for audit trail.
**Key Methods:**
- `log()` - Generic log method
- `logCheckIn()` - Log check-in action
- `logCheckOut()` - Log check-out action
- `logRoomChange()` - Log room change
- `logGuestRemoved()` - Log guest removal
- `logStayExtension()` - Log stay extension
- `logFolioAdjustment()` - Log folio adjustment
- `logBookingCancellation()` - Log booking cancellation
- `logBookingNoShow()` - Log booking no-show
**Action Types:**
- `ACTION_CHECK_IN`, `ACTION_CHECK_OUT`
- `ACTION_ROOM_CHANGE`, `ACTION_ROOM_ASSIGNMENT`, `ACTION_ROOM_RELEASE`
- `ACTION_GUEST_ADDED`, `ACTION_GUEST_REMOVED`
- `ACTION_STAY_EXTENSION`, `ACTION_STAY_SHORTENING`
- `ACTION_FOLIO_ADJUSTMENT`, `ACTION_FOLIO_CHARGE`, `ACTION_FOLIO_PAYMENT`, `ACTION_FOLIO_FINALIZED`
- `ACTION_BOOKING_CANCELLED`, `ACTION_BOOKING_NO_SHOW`, `ACTION_BOOKING_MODIFIED`
---
## Controllers
### BookingController (`app/Http/Controllers/BookingController.php`)
**Purpose:** Manage booking CRUD operations.
**Key Methods:**
- `index()` - List bookings
- `show()` - Show booking details
- `store()` - Create booking
- `update()` - Update booking
- `destroy()` - Delete booking
- `checkIn()` - Process check-in
- `checkOut()` - Process check-out
- `generatePdf()` - Generate booking confirmation PDF
### PreCheckInController (`app/Http/Controllers/PreCheckInController.php`)
**Purpose:** Handle pre-check-in functionality.
**Key Methods:**
- `show()` - Show pre-check-in form
- `submit()` - Submit pre-check-in data
- `validateToken()` - Validate pre-check-in token
### StayController (`app/Http/Controllers/StayController.php`)
**Purpose:** Manage stay operations.
**Key Methods:**
- `index()` - List stays
- `show()` - Show stay details
- `update()` - Update stay
- `checkIn()` - Activate stay
- `checkOut()` - Complete stay
### CheckOutFolioReviewController (`app/Http/Controllers/CheckOutFolioReviewController.php`)
**Purpose:** Handle folio review at check-out.
**Key Methods:**
- `show()` - Show folio review
- `approve()` - Approve and finalize folio
- `reject()` - Reject folio with corrections
### InvoicePDFController (`app/Http/Controllers/InvoicePDFController.php`)
**Purpose:** Generate invoice PDFs.
**Key Methods:**
- `generatePDF()` - Generate invoice PDF
---
## Workflow Stages
### 1. Booking Creation
**Process:**
1. User selects dates, room, and additional services
2. System validates availability
3. Pricing calculated automatically
4. Booking created with status 'confirmed'
5. Invoice generated (proforma or final based on settings)
6. Payment processed based on payment mode:
- `full_electronic` - Full payment online
- `deposit_platform_remainder_onsite` - Deposit online, remainder at check-in
- `payment_guarantee` - Card on file, charged at check-in
- `onsite_payment` - Pay entirely at check-in
**Key Files:**
- `BookingController.php` - Booking CRUD
- `InvoiceService.php` - Invoice creation
### 2. Pre-Arrival
**Process:**
1. Scheduled task runs daily at 10:00 AM
2. Identifies bookings checking in within 1 day
3. Sends pre-arrival reminder (email + SMS)
4. Includes pre-check-in link
5. Guest can complete pre-check-in online:
- Update guest information
- Provide ETA
- Add special requests
6. Pre-check-in data saved to booking
**Key Files:**
- `PreArrivalService.php` - Pre-arrival logic
- `PreArrivalReminderNotification.php` - Notification
- `SendPreArrivalReminders.php` - Console command
- `Kernel.php` - Scheduling
### 3. Check-In Validation
**Process:**
1. Receptionist initiates check-in
2. System validates:
- Booking status (must be 'confirmed')
- Payment requirements met
- Room availability
- Guest information completeness
3. Validation errors displayed if any
4. If valid, proceed to check-in
**Key Files:**
- `CheckInValidationService.php` - Validation logic
### 4. Check-In
**Process:**
1. Receptionist confirms check-in
2. System performs idempotency check:
- If already checked in, return success
- If stay already active, return success
3. Booking status updated to 'checked'
4. Stay record created:
- Populated with booking data
- Expected dates from booking
- Actual check-in timestamp
- Status set to 'active'
5. Active folio created
6. Booking guests converted to stay guests:
- Guest profiles found or created
- Stay guests created with check-in timestamps
- Guest tracking updated in metadata
7. Initial room assignment created
8. Audit log entry created
9. All operations in DB transaction with rollback
**Key Files:**
- `Booking.php::checkIn()` - Check-in logic
- `BookingToStayGuestService.php` - Guest conversion
- `RoomChangeManagementService.php` - Room assignment
- `AuditLogService.php` - Audit logging
### 5. Active Stay Management
#### Room Changes
**Process:**
1. Receptionist initiates room change
2. System validates:
- New room availability (with concurrency check)
- Valid reason for change
3. Current room released:
- `released_at` timestamp set
- `released_by` user recorded
4. New room assigned:
- New assignment created
- Reason recorded
5. Stay's venue_object_id updated
6. Audit log entry created
7. All operations in DB transaction with rollback
**Key Files:**
- `RoomChangeManagementService.php::changeRoom()`
#### Guest Changes
**Adding Guest:**
1. Receptionist adds guest
2. Guest profile found or created
3. Stay guest created
4. Guest tracking updated
**Removing Guest:**
1. Receptionist removes guest
2. Stay guest checked out
3. Stay notes updated
4. Audit log entry created
**Key Files:**
- `StayModificationService.php::addGuest()`, `removeGuest()`
#### Stay Extension
**Process:**
1. Receptionist requests stay extension
2. System validates:
- Folio not locked
- New dates valid
3. Stay check-out date updated
4. Additional nights calculated
5. Extension charge added to folio
6. Audit log entry created
7. All operations in DB transaction with rollback
**Key Files:**
- `StayModificationService.php::extendStay()`
#### Stay Shortening
**Process:**
1. Receptionist requests stay shortening
2. System validates folio status
3. Stay check-out date updated
4. Credit note generated for unused nights
5. Audit log entry created
**Key Files:**
- `StayModificationService.php::shortenStay()`
#### Services and Charges
**Process:**
1. Receptionist adds service
2. System validates folio not locked
3. Charge added to folio
4. Folio totals recalculated
5. Audit log entry created
**Key Files:**
- `StayModificationService.php::addService()`
### 6. Check-Out Folio Review
**Process:**
1. Receptionist initiates check-out
2. System displays folio summary:
- All charges
- All payments
- Current balance
3. System checks for discrepancies
4. Receptionist reviews and approves
5. Folio locked and finalized
6. Balance validated
**Key Files:**
- `CheckOutFolioReviewService.php`
- `CheckOutFolioReviewController.php`
### 7. Check-Out
**Process:**
1. Final payment processed
2. Stay status updated to 'completed'
3. Actual check-out timestamp set
4. Booking status updated to 'checkout'
5. Documents generated:
- Final invoice
- Payment receipt
6. Audit log entry created (ready to add)
**Key Files:**
- `Stay.php::checkOut()`
- `Booking.php::checkOut()`
- `InvoicePDFController.php`
### 8. Post-Stay
**Room Status Workflow:**
1. Room status automatically updated to 'dirty'
2. Housekeeping assigned
3. Status updated to 'cleaning'
4. Status updated to 'inspected' after inspection
5. Status updated to 'available' when ready
**Guest Communications:**
1. Thank-you message sent
2. Review request sent
3. Loyalty points calculated and credited
**Key Files:**
- `RoomStatusWorkflowService.php`
- `PostStayService.php`
### 9. No-Show and Cancellation Workflows
**Cancellation:**
1. Booking cancelled with reason
2. Status updated to 'cancelled'
3. Cancellation timestamp recorded
4. Audit log entry created
5. Credit note may be generated for payments made
**No-Show:**
1. Booking marked as no-show
2. Status updated to 'no_show'
3. No-show timestamp and reason recorded
4. Cannot be checked in after no-show
5. Audit log entry created
**Key Files:**
- `Booking.php::cancel()`, `markAsNoShow()`
- `AuditLogService.php`
---
## Data Integrity Features
### Idempotency
- **Check-in:** Prevents duplicate check-ins
- **Stay activation:** Prevents duplicate stay creation
- **Guest check-in:** Prevents duplicate guest check-in
- **Guest check-out:** Prevents duplicate guest check-out
- **Room release:** Prevents duplicate room release
### Transactions
All critical operations wrapped in DB transactions with rollback:
- BookingToStayGuestService operations
- RoomChangeManagementService operations
- StayModificationService operations
- InvoiceService operations
### Concurrency Control
- Room assignments use `lockForUpdate()` to prevent double booking
- Room availability re-validated within transaction
- Prevents race conditions during concurrent check-ins
### Folio Locking
- Folios can be locked after finalization
- Prevents editing locked folios
- Validated before modifications:
- Stay extensions
- Service additions
- Charge modifications
### Booking vs Stay Dates
- Stay model tracks both expected and actual dates
- Expected dates from original booking preserved
- Actual dates reflect real stay duration
- Useful for analytics and discrepancy tracking
### Expected vs Actual Guests
- Guest tracking in Stay metadata
- Tracks expected guest count vs actual
- Tracks difference and timestamp
- Available via `getGuestTracking()` method
### Room Assignment History
- Proper tracking of room changes
- `released_at` distinguishes room changes from guest departures
- Complete assignment history preserved
- Assignment reasons tracked
### No-Show/Cancellation Separation
- Separate workflows from normal stay lifecycle
- Cannot check-in cancelled/no-show bookings
- Prevents accidental stay creation
- Clear status tracking
### Audit Logging
- Comprehensive audit trail for critical actions
- Tracks who, when, what for each action
- Stores old/new values for changes
- IP address and user agent tracking
- Queryable by action type, entity, user, date range
---
## Notification System
### Pre-Arrival Notifications
- **Trigger:** Daily at 10:00 AM
- **Recipients:** Guests with bookings in next 24 hours
- **Channels:** Email (always), SMS (if phone available)
- **Content:**
- Booking details (number, dates, venue, guest count)
- Pre-check-in link
- Welcome message
- **Implementation:**
- `PreArrivalReminderNotification` class
- Laravel Notification system
- Queued for performance
### Invoice Notifications
- **Invoice Overdue:** Sent when invoice becomes overdue
- **Invoice Created:** Sent when invoice is created
- **Payment Received:** Sent when payment is recorded
### Booking Notifications
- **Booking Confirmed:** Sent when booking is confirmed
- **Booking Cancelled:** Sent when booking is cancelled
---
## Document Generation
### Supported Documents
- Invoices (proforma and final)
- Credit Notes
- Fiscal Receipts
- Payment Receipts
- Booking Confirmations
- Calendar Exports
- Statistics Reports
### PDF Generation
- **Library:** barryvdh/laravel-dompdf
- **Implementation:** Distributed across controllers
- **Views:** Blade templates for each document type
- **Storage:** PDFs can be cached for re-use
### Key Controllers
- `InvoicePDFController` - Invoice PDFs
- `CompanyAdminController` - Various PDFs (invoice, fiscal receipt, payment receipt)
- `BookingController` - Booking confirmation PDFs
- `PaymentTransactionController` - Payment receipt PDFs
### Document Types
1. **Invoice:** Formal billing document
2. **Proforma Invoice:** Preliminary invoice for deposit
3. **Credit Note:** Refund document
4. **Fiscal Receipt:** Tax-compliant receipt
5. **Payment Receipt:** Payment acknowledgment
6. **Booking Confirmation:** Booking details summary
---
## Routes
### Booking Routes
- `GET /bookings` - List bookings
- `GET /bookings/{booking}` - Show booking
- `POST /bookings` - Create booking
- `PUT /bookings/{booking}` - Update booking
- `DELETE /bookings/{booking}` - Delete booking
- `POST /bookings/{booking}/check-in` - Check-in
- `POST /bookings/{booking}/check-out` - Check-out
- `GET /bookings/{booking}/pdf` - Download PDF
### Pre-Check-In Routes
- `GET /public/pre-check-in/{token}` - Pre-check-in form
- `POST /public/pre-check-in/{token}` - Submit pre-check-in
### Stay Routes
- `GET /stays` - List stays
- `GET /stays/{stay}` - Show stay
- `PUT /stays/{stay}` - Update stay
- `POST /stays/{stay}/check-in` - Activate stay
- `POST /stays/{stay}/check-out` - Complete stay
### Folio Routes
- `GET /folios/{folio}` - Show folio
- `POST /folios/{folio}/lock` - Lock folio
- `POST /folios/{folio}/unlock` - Unlock folio
### Check-Out Routes
- `GET /check-out-folio-review/{stay}` - Folio review
- `POST /check-out-folio-review/{stay}/approve` - Approve folio
- `POST /check-out-folio-review/{stay}/reject` - Reject folio
### Invoice Routes
- `GET /invoice/{invoice}/pdf` - Download invoice PDF
---
## Console Commands
### Pre-Arrival Reminders
```bash
php artisan pms:send-pre-arrival-reminders
```
- Sends pre-arrival reminders to guests
- Scheduled to run daily at 10:00 AM
### Other Scheduled Commands
```bash
php artisan bookings:send-reminders # Hourly booking reminders
php artisan invoices:check-overdue --notify # Daily at 09:00
```
---
## Database Tables
### Core Tables
- `bookings` - Booking records
- `stays` - Stay records
- `booking_guests` - Booking guests
- `stay_guests` - Stay guests
- `stay_room_assignments` - Room assignments
- `folios` - Folios
- `folio_charges` - Folio charges
- `folio_payments` - Folio payments
- `invoices` - Invoices
- `invoice_items` - Invoice line items
- `fiscal_receipts` - Fiscal receipts
- `payments` - Payment transactions
- `guests` - Guest profiles
- `clients` - Client records
### Audit Tables
- `audit_logs` - Audit trail
---
## Recent Enhancements (2026-08-13)
### Workflow Consistency Improvements
1. **Idempotency Checks** - Prevents duplicate operations
2. **DB Transactions** - All critical operations in transactions
3. **Concurrency Control** - Room assignments with locking
4. **Folio Locking** - Prevents editing after finalization
5. **Booking vs Stay Dates** - Separate expected and actual dates
6. **Expected vs Actual Guests** - Guest tracking in metadata
7. **Room History** - Released_at for proper history
8. **No-Show/Cancellation Workflows** - Separate from normal lifecycle
9. **Audit Logging** - Comprehensive audit trail
10. **Automated Pre-Arrival Notifications** - Email/SMS reminders
### New Migrations
- `add_expected_dates_to_stays_table` - Expected date fields
- `add_released_at_to_stay_room_assignments_table` - Room history
- `create_audit_logs_table` - Audit trail
### New Services
- `AuditLogService` - Audit logging
### New Notifications
- `PreArrivalReminderNotification` - Pre-arrival reminders
### New Console Commands
- `SendPreArrivalReminders` - Automated reminder sending
---
## Summary
The Zapazime PMS system implements a comprehensive booking flow with:
- **Complete Lifecycle:** From booking creation to post-stay management
- **Data Integrity:** Idempotency, transactions, concurrency control, audit logging
- **Workflow Separation:** Clear separation of booking vs stay data, no-show/cancellation workflows
- **Room Management:** Full room assignment history with proper change tracking
- **Guest Management:** Expected vs actual guest tracking, profile management
- **Financial Management:** Invoices, folios, payments, fiscal receipts
- **Communication:** Automated pre-arrival reminders, notifications
- **Documentation:** PDF generation for all document types
- **Audit Trail:** Comprehensive logging of all critical actions
The system is production-ready with robust error handling, data validation, and workflow consistency features.