RahalCorporate
BudgetsConcepts

Consumption Lifecycle

How budget spending flows through pending, spent, and refunded states

Consumption Lifecycle

When users book travel, budget consumption goes through several states. Understanding this lifecycle is essential for accurate budget tracking and management.

Transaction States

Budget transactions move through these states:

StateDescriptionImpact on Available Budget
PendingBudget reserved, booking not confirmedReduces remaining amount
SpentBooking confirmed, budget consumedPermanently consumed
ReleasedReservation cancelled, budget returnedReturns to remaining
RefundedSpent amount partially/fully returnedReturns to remaining

Transaction Types

The system records these transaction types:

Transaction TypeWhen CreatedAmount Impact
BOOKING_PENDINGBooking started, budget reserved+pending, -remaining
BOOKING_COMPLETEDBooking confirmed+spent, -pending
BOOKING_CANCELLEDPending booking cancelled-pending, +remaining
REFUNDCompleted booking refunded-spent, +remaining
ROLLOVER_INAmount received from previous period+rollover
ROLLOVER_OUTAmount transferred to next periodDocuments rollover

Budget Amount Fields

Each budget period tracks several monetary fields:

FieldDescription
Base AmountOriginal allocation for this period
Rollover AmountCarried from previous period
Total AllocatedBase + Rollover
Spent AmountConfirmed transactions
Pending AmountReserved, not yet confirmed
Remaining AmountTotal Allocated - Spent - Pending

The Reservation Flow

Step 1: Budget Reserved (Pending)

When a user starts a booking:

  1. User selects a $500 flight
  2. System checks budget availability ($2,000 remaining)
  3. System reserves $500 (adds to pending, subtracts from remaining)
  4. User proceeds to payment

Before:

FieldAmount
Total Allocated$5,000
Spent$3,000
Pending$0
Remaining$2,000

After Reservation:

FieldAmountChange
Total Allocated$5,000-
Spent$3,000-
Pending$500+$500
Remaining$1,500-$500

Step 2a: Booking Confirmed (Spent)

When payment succeeds:

  1. User completes payment
  2. System processes payment successfully
  3. System confirms the reservation (moves from pending to spent)
  4. User receives booking confirmation

After Confirmation:

FieldAmountChange
Total Allocated$5,000-
Spent$3,500+$500
Pending$0-$500
Remaining$1,500-

Step 2b: Booking Cancelled (Released)

If booking is cancelled before confirmation:

  1. User cancels the booking
  2. System releases the reservation
  3. Pending amount decreases, remaining amount increases
  4. Budget returns to its original state

After Release:

FieldAmountChange
Total Allocated$5,000-
Spent$3,000-
Pending$0-$500
Remaining$2,000+$500

The budget returns to its original state.

Step 3: Refund Processed

If a confirmed booking is refunded:

  1. Supplier processes the refund
  2. System credits the refund to the budget
  3. Spent amount decreases, remaining amount increases
  4. User has more budget available for future bookings

After Refund:

FieldAmountChange
Total Allocated$5,000-
Spent$3,000-$500
Pending$0-
Remaining$2,000+$500

Reservation Timing

The company settings control when budget is reserved:

TimingWhen ReservedTrade-off
On RequestWhen booking request createdPrevents overspending from concurrent requests
On ApprovalWhen request approvedBudget not locked during approval wait
On ConfirmationWhen payment confirmedMost flexible, highest overspending risk

Budget is reserved as soon as the booking request is created.

StageBudget State
Booking StartedBudget reserved (pending)
Approval WaitBudget locked
ApprovedStill pending
PaymentPending → Spent

Pros: Prevents concurrent requests from overspending
Cons: Budget locked during approval wait
Best for: Strict budget control

On Approval

Budget is reserved only when the request is approved.

StageBudget State
Booking StartedNo reservation
Approval WaitBudget NOT locked
ApprovedBudget reserved
PaymentPending → Spent

Pros: Budget only locked when likely to proceed
Cons: Concurrent requests may not see accurate availability
Best for: Longer approval processes

On Confirmation

Budget is reserved and spent immediately upon payment.

StageBudget State
Booking StartedNo reservation
ApprovalNo reservation
PaymentBudget reserved AND spent immediately

Pros: Maximum flexibility
Cons: Highest risk of overspending
Best for: Trust-based environments

Pending Reservations and Timeouts

Pending reservations don't last forever. The system has a timeout mechanism:

How Timeouts Work

  1. When a reservation is created, it's timestamped
  2. A background job runs periodically
  3. Reservations older than the timeout (default: 72 hours) are released
  4. Released amount returns to remaining budget

Configuring Timeout

In company settings:

SettingDescriptionDefault
Pending Reservation TimeoutHours before releasing72 hours

Timeout Example

Friday 10:00 AM: User starts booking, $500 reserved
Friday 10:00 AM: User abandons checkout
...
Monday 10:00 AM: Timeout job runs (72 hours elapsed)
Monday 10:00 AM: $500 released back to budget

The timeout prevents abandoned bookings from permanently blocking budget. Users who return after timeout will need to re-reserve.

Include Pending in Availability

The company settings control whether pending reservations count against availability:

SettingAvailable AmountUse Case
Include Pending: YesTotal - Spent - PendingAccurate real-time balance
Include Pending: NoTotal - SpentOptimistic balance, may overspend

With Include Pending = Yes (Default)

Total Allocated: $5,000
Spent: $3,000
Pending: $500

Available to book: $1,500 (includes pending)

With Include Pending = No

Total Allocated: $5,000
Spent: $3,000
Pending: $500

Available to book: $2,000 (ignores pending)

Setting "Include Pending: No" can lead to overspending if multiple users book concurrently. Only use this if you trust users to manage their own spending.

Refund Crediting

When refunds are processed, the system can credit them back to the budget:

Credit to Current Period

Refund goes to the current active period, even if the booking was in a previous period.

Booking: January (Period 1, now closed)
Refund: March (Period 3, active)

Refund credited to: Period 3

Pros: Increases current available budget Cons: Distorts period-over-period reporting

Credit to Original Period

Refund goes back to the period where the booking was made.

Booking: January (Period 1, now closed)
Refund: March (Period 3, active)

Refund credited to: Period 1

Pros: Accurate historical reporting Cons: Closed period can't be spent

Most companies use "Current Period" for practical reasons - refunds become available immediately.

Transaction History

Every budget maintains a complete transaction history:

TimestampTypeAmountReferenceBalance After
Jan 15 10:00BOOKING_PENDING$500ORD-001$4,500 remaining
Jan 15 10:30BOOKING_COMPLETED$500ORD-001$4,500 remaining
Jan 20 14:00BOOKING_PENDING$1,200ORD-002$3,300 remaining
Jan 20 14:15BOOKING_CANCELLED$1,200ORD-002$4,500 remaining
Jan 25 09:00BOOKING_PENDING$800ORD-003$3,700 remaining
Jan 25 09:30BOOKING_COMPLETED$800ORD-003$3,700 remaining
Feb 10 16:00REFUND$300ORD-001$4,000 remaining

This provides a complete audit trail for finance and compliance.

Per User vs Shared Pool

The consumption lifecycle works differently based on allocation type:

Per User

  • Each user has their own UserBudgetPeriod with separate tracking
  • User A's pending reservations don't affect User B's availability
  • Transactions are recorded per user

Shared Pool

  • Single BudgetPeriod tracks the entire pool
  • User A's pending reservation reduces availability for all users
  • Transactions show which user made them but affect the shared pool

Handling Errors

If a transaction fails mid-process (e.g., database error), the system uses database transactions to ensure consistency:

  • Reservation fails: No pending amount recorded, user can retry
  • Confirmation fails: Pending remains, can retry confirmation
  • Release fails: Pending remains, timeout job will eventually clean up

All budget amount updates happen within database transactions to prevent partial updates that could corrupt budget state.

On this page