Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Pricing Engine - Enum Values Reference

Complete reference for all enum fields in the Pricing Engine API.


PricingRule Enums

rule_type

Field: pricing_rule.rule_type
Type: String (required)
Default: "specific_date_time"

ValueDescriptionStatus
specific_date_timeDate & Time based pricing rules✅ Implemented
demand_capacityCapacity-based dynamic pricing🔮 Future
performance_basedPerformance metric based rules🔮 Future
advance_last_minuteBooking window based rules🔮 Future

Example:

{
  "rule_type": "specific_date_time"
}

date_type (PricingRule Level)

Field: pricing_rule.date_type
Type: String (nullable)
Applies to: specific_date_time rules only

ValueDescriptionFields Used
specific_dateOnly date-based validitystart_date, end_date, is_no_end_date
specific_date_timeBoth date and time validitystart_date, end_date, start_time, end_time, is_no_end_date, is_no_end_time, is_anytime

Example:

{
  "rule_type": "specific_date_time",
  "date_type": "specific_date",
  "start_date": "2024-12-15",
  "end_date": "2024-12-31",
  "is_no_end_date": false
}

Example (Ongoing):

{
  "date_type": "specific_date",
  "start_date": "2024-01-01",
  "end_date": null,
  "is_no_end_date": true
}

DateTimeCondition Enums

date_type (Condition Level)

Field: date_time_condition.date_type
Type: String (required)

ValueDescriptionUses condition_itemsUses days_of_weekExample Use Case
everydayApplies every day❌❌All-month promotion
specific_dateSpecific dates only✅ Date fields❌Valentine’s Day, New Year
specific_timeSpecific times daily✅ Time fields❌Happy Hour (daily 5-7pm)
specific_date_timeSpecific dates + times✅ Date + Time❌New Year’s Eve 8pm-midnight
day_of_weekSpecific weekdays❌✅Weekend surge pricing
day_time_of_weekWeekdays + time ranges✅ Time fields✅Friday-Sunday 7-10pm

Examples:

Everyday:

{
  "date_type": "everyday",
  "action_type": "increase",
  "value_type": "percentage",
  "value": 1000  // 10%
}

Weekend Only:

{
  "date_type": "day_of_week",
  "days_of_week": [0, 6],  // Sunday, Saturday
  "action_type": "increase",
  "value_type": "percentage",
  "value": 2000  // 20%
}

Friday Night Special:

{
  "date_type": "day_time_of_week",
  "days_of_week": [5],  // Friday
  "action_type": "decrease",
  "value_type": "percentage",
  "value": 1500,  // 15% off
  "condition_items_attributes": [{
    "start_time": "17:00",
    "end_time": "19:00",
    "is_anytime": false
  }]
}

action_type

Field: date_time_condition.action_type
Type: String (required when value is specified)

ValueDescriptionEffect
increaseRaise the priceAdds to base price
decreaseLower the priceSubtracts from base price

Example:

{
  "action_type": "increase"
}

value_type

Field: date_time_condition.value_type
Type: String (required when value is specified)

ValueDescriptionValue FormatExample
percentagePercentage adjustmentBasis points (100 = 1%)1500 = 15%
fixedFixed amount adjustmentCents50000 = ฿500.00

Examples:

15% increase:

{
  "value_type": "percentage",
  "value": 1500  // 15% = 1500 basis points
}

฿500 increase:

{
  "value_type": "fixed",
  "value": 50000  // ฿500 = 50000 cents
}

period_mode

Field: date_time_condition.period_mode
Type: String (nullable)

ValueDescription
singleSingle occurrence
rangeRange of dates/times

Example:

{
  "period_mode": "range"
}

days_of_week

Field: date_time_condition.days_of_week
Type: Integer Array
Values: 0-6

IntegerDayAbbreviation
0SundaySun
1MondayMon
2TuesdayTue
3WednesdayWed
4ThursdayThu
5FridayFri
6SaturdaySat

Examples:

Weekends:

{
  "days_of_week": [0, 6]  // Sunday and Saturday
}

Weekdays:

{
  "days_of_week": [1, 2, 3, 4, 5]  // Mon-Fri
}

Friday Only:

{
  "days_of_week": [5]
}

Calculation Examples

Base Price: ฿1,000 (100000 cents)

Percentage Adjustments

ActionValueCalculationResult
increase1000 (10%)1000 + (1000 × 0.10)฿1,100
increase1500 (15%)1000 + (1000 × 0.15)฿1,150
increase2500 (25%)1000 + (1000 × 0.25)฿1,250
decrease1000 (10%)1000 - (1000 × 0.10)฿900
decrease2000 (20%)1000 - (1000 × 0.20)฿800

Fixed Amount Adjustments

ActionValue (cents)CalculationResult
increase50000 (฿500)1000 + 500฿1,500
increase20000 (฿200)1000 + 200฿1,200
decrease10000 (฿100)1000 - 100฿900
decrease50000 (฿500)1000 - 500฿500

Value Conversion Reference

Percentage (Basis Points)

DisplayBasis PointsDecimal
1%1000.01
5%5000.05
10%10000.10
15%15000.15
20%20000.20
25%25000.25
50%50000.50

Formula:
basis_points = percentage × 100
percentage = basis_points / 100

Fixed Amount (Cents)

DisplayCents
฿1.00100
฿10.001000
฿50.005000
฿100.0010000
฿500.0050000
฿1000.00100000

Formula:
cents = baht × 100
baht = cents / 100


Common Patterns

Weekend Surge (20% increase)

{
  "pricing_rule": {
    "name": "Weekend Surge",
    "rule_type": "specific_date_time",
    "date_type": "specific_date",
    "start_date": "2024-01-01",
    "is_no_end_date": true,
    "requires_approval": false,
    "date_time_conditions_attributes": [{
      "date_type": "day_of_week",
      "days_of_week": [0, 6],
      "action_type": "increase",
      "value_type": "percentage",
      "value": 2000
    }]
  }
}

Happy Hour (15% discount, Mon-Fri 5-7pm)

{
  "pricing_rule": {
    "name": "Happy Hour",
    "rule_type": "specific_date_time",
    "date_type": "specific_date",
    "start_date": "2024-01-01",
    "is_no_end_date": true,
    "date_time_conditions_attributes": [{
      "date_type": "day_time_of_week",
      "days_of_week": [1, 2, 3, 4, 5],
      "action_type": "decrease",
      "value_type": "percentage",
      "value": 1500,
      "condition_items_attributes": [{
        "start_time": "17:00",
        "end_time": "19:00"
      }]
    }]
  }
}

Holiday Special (New Year’s Eve)

{
  "pricing_rule": {
    "name": "New Year's Eve Special",
    "rule_type": "specific_date_time",
    "date_type": "specific_date_time",
    "start_date": "2024-12-31",
    "end_date": "2024-12-31",
    "start_time": "20:00",
    "end_time": "23:59",
    "requires_approval": true,
    "date_time_conditions_attributes": [{
      "date_type": "specific_date_time",
      "action_type": "increase",
      "value_type": "fixed",
      "value": 100000,  // ฿1000
      "condition_items_attributes": [{
        "start_date": "2024-12-31",
        "end_date": "2024-12-31",
        "start_time": "20:00",
        "end_time": "23:59"
      }]
    }]
  }
}

Validation Rules

Required Fields

PricingRule:

  • name (string)
  • rule_type (enum)
  • priority (integer, 0-1000)

DateTimeCondition:

  • date_type (enum)
  • action_type (enum) - when value specified
  • value_type (enum) - when value specified
  • value (integer) - when action specified

Conditional Requirements

If date_type is day_of_week or day_time_of_week:

  • days_of_week array is required

If date_type is specific_date, specific_time, specific_date_time, or day_time_of_week:

  • At least one condition_item is required

If end_date is provided:

  • Must be >= start_date
  • If is_no_end_date is true, end_date is ignored

If end_time is provided:

  • Must be >= start_time
  • If is_no_end_time or is_anytime is true, times are ignored

API Response Format

{
  "data": {
    "id": 123,
    "restaurant_id": "rest_abc123",
    "name": "Weekend Surge",
    "rule_type": "specific_date_time",
    "priority": 100,
    "active": true,
    "requires_approval": false,
    "date_type": "specific_date",
    "start_date": "2024-01-01",
    "end_date": null,
    "start_time": null,
    "end_time": null,
    "is_no_end_date": true,
    "is_no_end_time": false,
    "is_anytime": false,
    "ongoing": true,
    "apply_to_all_packages": true,
    "package_ids": [],
    "date_time_conditions": [
      {
        "id": 456,
        "date_type": "day_of_week",
        "period_mode": "range",
        "action_type": "increase",
        "value_type": "percentage",
        "value": 2000,
        "days_of_week": [0, 6],
        "condition_items": []
      }
    ],
    "created_at": "2024-01-01T00:00:00Z",
    "updated_at": "2024-01-01T00:00:00Z"
  }
}