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
entityIdThe order ID this event belongs to
entityTypeAlways ORDER for booking events
versionEvent version (for schema evolution)
eventTypeType of event (see catalog below)
eventDataJSON payload with event-specific details
createdAtTimestamp 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 TypeDescriptionEvent Data
ORDER_CREATEDOrder was createdFlight reservation information

Example Event Data:

{
  "flightReservationInformation": {
    "origin": "BGW",
    "destination": "DXB",
    "departureDate": "2024-06-15",
    "returnDate": "2024-06-20"
  }
}

Payment Events

Event TypeDescriptionEvent Data
ORDER_PAYMENT_VERIFIED_TO_BE_PAIDPayment confirmed-
ORDER_FINALIZED_BY_CONFIRMING_BNPL_TRANSACTIONBNPL payment confirmedBNPL details

Reservation Events

Event TypeDescriptionEvent Data
ORDER_RESERVATION_CREATEDReservation created with supplierreservationId
ORDER_RESERVATION_TICKET_ISSUEDFlight ticket issuedreservationId
ORDER_RESERVATION_CANCELEDReservation cancelledreservationId, reason
ORDER_RESERVATION_SWITCHED_TO_CREDITHotel payment switched to creditBooking details
ORDER_RESERVATION_RESOLVED_OUTSIDE_APPManual resolution recordedResolution details
ORDER_RESERVATION_UPDATED_OUTSIDE_APPExternal update recordedUpdate details

Example Reservation Created:

{
  "reservationId": "12345678"
}

Status Change Events

Event TypeDescriptionEvent Data
ORDER_STATUS_MANUALLY_CHANGEDAdmin changed order statusPrevious status, new status, reason
ORDER_MANUALLY_RESOLVEDAdmin manually resolved an issueResolution details

Example Status Change:

{
  "previousStatus": "FAILED",
  "newStatus": "FINALIZED",
  "reason": "Ticket issued manually via supplier portal"
}

Error Events

Event TypeDescriptionEvent Data
ORDER_ENCOUNTERED_ERRORError occurred during processingError message, context
ORDER_CANCELED_DUE_TO_NO_ACTIVITYOrder cancelled (unpaid 24h+)-

Example Error Event:

{
  "message": "Creating reservation for order failed.",
  "reservationInformation": {
    "searchResultKey": "abc123",
    "supplier": "IRIX"
  }
}

Refund Events

Event TypeDescriptionEvent Data
ORDER_REFUNDEDOrder was refundedRefund amount, reason

Event Flow Example

Here's a typical successful order event sequence:

Viewing Events

Events are accessible in the Travel Zone Dashboard:

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

Each event shows:

  • Timestamp (with time)
  • Event type (color-coded: green for success, red for errors)
  • Action to view full event data

Error events (ORDER_ENCOUNTERED_ERROR) are highlighted in red 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