RahalCorporate
OrdersConcepts

Events (Audit Trail)

Understanding the event sourcing system for order tracking and auditing

Events (Audit Trail)

Rahal uses an event sourcing pattern to maintain a complete, immutable audit trail of everything that happens to an order. This provides transparency, debugging capabilities, and compliance support.

What Are Events?

Events are immutable records that capture significant actions or state changes in an order's lifecycle. Each event contains:

FieldDescription
IDUnique event identifier
Entity IDThe order ID this event belongs to
Entity TypeAlways ORDER for booking events
VersionEvent version number
Event TypeType of event (see catalog below)
Event DataDetails specific to the event type
Created AtTimestamp when event occurred

Why Event Sourcing?

Event sourcing provides several benefits:

1. Complete Audit Trail

Every action is recorded. You can trace exactly what happened and when.

2. Debugging

When something goes wrong, the event log shows the exact sequence of operations.

3. Compliance

For corporate travel, auditors can verify the complete booking history.

4. Reconciliation

Events help reconcile internal records with external systems (payment providers, travel suppliers).

Event Catalog

Order Creation Events

Event TypeDescriptionData Includes
Order CreatedOrder was createdFlight route, dates, cabin class

Payment Events

Event TypeDescriptionData Includes
Payment VerifiedPayment confirmed by provider-
BNPL ConfirmedBuy Now Pay Later payment confirmedInstallment plan details

Reservation Events

Event TypeDescriptionData Includes
Reservation CreatedBooking created with supplierExternal reservation ID
Ticket IssuedFlight ticket issuedReservation ID
Reservation CancelledReservation cancelledReservation ID, reason
Switched to CreditHotel payment method changedBooking details
Resolved Outside AppManual resolution recordedResolution notes
Updated Outside AppExternal update recordedUpdate details

Status Change Events

Event TypeDescriptionData Includes
Status Manually ChangedAdmin changed order statusPrevious status, new status, reason
Manually ResolvedAdmin resolved an issueResolution details

Error Events

Event TypeDescriptionData Includes
Encountered ErrorError during processingError message, context
Cancelled Due to No ActivityOrder cancelled after 24h unpaid-

Refund Events

Event TypeDescriptionData Includes
Order RefundedOrder was refundedRefund amount, reason

Event Flow Example

A typical successful order produces this event sequence:

StepEventDescription
1Order CreatedUser initiates booking
2Payment VerifiedPayment confirmed
3Reservation CreatedBooking confirmed with supplier
4Ticket IssuedE-ticket generated (flights only)
5Status → FinalizedOrder complete

Viewing Events

Events are accessible in the dashboard:

  1. Navigate to Orders
  2. Click Details on an order
  3. Select the Events tab

Each event shows:

  • Timestamp (with time)
  • Event type
  • Action to view full event data

Error events (ORDER_ENCOUNTERED_ERROR) are visually distinguished for quick identification during troubleshooting.

Event Data Structure

Event data is stored as a JSON string. When viewing an event, the data is parsed and displayed in a readable format.

Common Event Data Fields

FieldDescription
reservationIdExternal reservation reference
messageHuman-readable description
flightReservationInformationFlight booking details
reservationInformationError context for failed reservations

Best Practices for Event Analysis

Troubleshooting Failed Orders

  1. Find the first ORDER_ENCOUNTERED_ERROR event
  2. Check the message and reservationInformation fields
  3. Look at subsequent events for recovery attempts
  4. Verify if the order was manually resolved

Verifying Successful Orders

  1. Confirm ORDER_CREATED exists
  2. Verify ORDER_PAYMENT_VERIFIED_TO_BE_PAID follows
  3. Check for ORDER_RESERVATION_CREATED (one per reservation)
  4. For flights: verify ORDER_RESERVATION_TICKET_ISSUED
  5. Confirm order status is FINALIZED

Auditing Corporate Orders

For corporate direct orders, also verify:

  1. Policy evaluation (logged separately in policy violations)
  2. Budget reservation (logged in budget transactions)
  3. Budget confirmation on finalization

On this page