RahalCorporate
BudgetsReference

Transaction Types Reference

Complete reference for budget transaction types

Transaction Types Reference

This reference documents all budget transaction types and their impact on budget amounts.

Transaction Type Values

TypeEnum ValueDescription
Booking PendingBOOKING_PENDINGBudget reserved for in-progress booking
Booking CompletedBOOKING_COMPLETEDBooking confirmed, budget spent
Booking CancelledBOOKING_CANCELLEDPending booking cancelled, budget released
RefundREFUNDConfirmed booking refunded
Rollover InROLLOVER_INAmount received from previous period
Rollover OutROLLOVER_OUTAmount transferred to next period

Type Behaviors

BOOKING_PENDING

Creates a reservation for a booking in progress.

AspectBehavior
When createdUser starts booking process
Amount impact+pending, -remaining
Can be reversedYes (cancelled or completed)
Visible to userYes, as "pending"

Amount changes: Pending increases by $500, remaining decreases by $500.

BOOKING_COMPLETED

Confirms a pending reservation as spent.

AspectBehavior
When createdPayment confirmed
Amount impact+spent, -pending
Can be reversedNo (but can be refunded)
Visible to userYes, as "spent"

Amount changes: Spent increases by $500, pending decreases by $500. Remaining stays the same.

BOOKING_CANCELLED

Releases a pending reservation.

AspectBehavior
When createdUser cancels booking, timeout, rejection
Amount impact-pending, +remaining
ReferenceOriginal booking reference
Visible to userIndirectly (remaining restored)

Amount changes: Pending decreases by $500, remaining increases by $500 (budget restored).

REFUND

Credits back a previously spent amount.

AspectBehavior
When createdRefund processed for completed booking
Amount impact-spent, +remaining
Can be partialYes
Period targetCurrent or original (configurable)

Amount changes: Spent decreases by $300, remaining increases by $300.

ROLLOVER_IN

Records budget amount received from the previous period during rollover.

AspectBehavior
When createdPeriod transition (rollover job)
Amount impactIncreases rollover amount in new period
ReferencePrevious period ID
Visible to userAs "rollover" in period details

ROLLOVER_OUT

Records budget amount transferred to the next period during rollover.

AspectBehavior
When createdPeriod transition (rollover job)
Amount impactDocuments the outgoing rollover
ReferenceNext period ID
Visible to userIn period history

Transaction Record Structure

Each transaction contains:

FieldTypeDescription
idstringUnique transaction ID
budgetPeriodIdstringPeriod this transaction belongs to
userBudgetPeriodIdstring?User period (for PER_USER)
userIdstringUser who made the transaction
transactionTypeenumOne of the types above
amountnumberTransaction amount
currencystringCurrency code
referenceTypestringWhat created this (ORDER, BOOKING_REQUEST)
referenceIdstringID of the reference
bookingRequestIdstring?Related booking request
orderIdstring?Related order
notestring?Optional note
metadataobject?Additional data
createdAtdatetimeWhen created

Transaction Flows

Standard Booking Flow

  1. User starts booking → BOOKING_PENDING created (pending+, remaining-)
  2. User completes payment → BOOKING_COMPLETED created (spent+, pending-)

Cancelled Booking Flow

  1. User starts booking → BOOKING_PENDING created (pending+, remaining-)
  2. User cancels booking → BOOKING_CANCELLED created (pending-, remaining+)

Refund Flow

  1. Supplier processes refund → REFUND created (spent-, remaining+)

Querying Transactions

Transactions can be filtered by:

FilterDescription
Budget PeriodAll transactions in a specific period
UserAll transactions by a specific user
Transaction TypeOnly specific types (e.g., BOOKING_COMPLETED)
Date RangeTransactions within a time range
ReferenceTransactions for a specific order or request

Duplicate Prevention

The system prevents duplicate reservations for the same reference:

  • Before creating a BOOKING_PENDING, it checks for existing pending transactions with the same referenceType and referenceId
  • If found, a ConflictException is thrown: "Budget already reserved for [referenceType]:[referenceId]"
  • This prevents the same booking from consuming budget twice

Transaction Metadata

The metadata field stores additional context. Common metadata fields:

  • originalTransactionId - For confirmations/cancellations, links to the pending transaction
  • originalAmount - For refunds, the original booking amount
  • conversionRate - If currency conversion was applied

On this page