Rules
A Feature rule-based system that allows dynamic pricing or other adjustments based on predefined conditions.
Here’s a breakdown of how your system might work based on the Rules, Conditions, and Periods tables:
Database

Rules
This table defines the rules that will be applied based on certain conditions. Each rule represents a specific pricing or occupancy strategy or period .
| Column Name | Data Type | Description |
|---|---|---|
| id | AI PK | Auto-incremented primary key, uniquely identifies each rule. |
| property_id | INT(7) | Links the rule to a specific property (hotel, rental, etc.). |
| rule_name | VARCHAR(100) | The name of the rule (e.g., "Peak Season Pricing"). |
| rule_type | INT(1) | Defines the type of rule (e.g., 1 = Occupancy-Based, 2 = Period-Based, etc.). |
| status | INT(1) | Indicates whether the rule is active (1 = Active, 0 = Inactive). |
| created_at | TIMESTAMP | Timestamp of when the rule was created. |
| updated_at | TIMESTAMP (on update) | Automatically updates whenever the record is modified. |
Conditions
This table stores the conditions that trigger a rule. Each rule can have one or more conditions.
| Column Name | Data Type | Description |
|---|---|---|
| id | AI PK | Auto-incremented primary key, uniquely identifies each condition. |
| rule_id | INT (FK to rules.id) | Foreign key linking the condition to a specific rule. |
| custom_name | VARCHAR(150) DEFAULT NULL | Optional custom name for the condition. |
| condition | ENUM('increase', 'decrease') DEFAULT NULL | Defines if the rule increases or decreases the value. |
| value_type | ENUM('amount', 'percentage') DEFAULT NULL | Determines if the value is a fixed amount or a percentage. |
| value | DOUBLE(10,2) DEFAULT NULL | The numeric value applied to the condition. |
| pax | INT(2) DEFAULT 0 | Specifies the number of guests (pax) the condition applies to. |
| created_at | TIMESTAMP DEFAULT CURRENT_TIMESTAMP | Timestamp of when the condition was created. |
| updated_at | TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP | Automatically updates on modification. |
Periods
This table defines different time periods (seasons) that can be referenced in the rules.
| Column Name | Data Type | Description |
|---|---|---|
id | AI PK | Auto-incremented primary key, uniquely identifies each period. |
condition_id | INT (FK to conditions.id) | Foreign key linking the period to a specific condition. |
start_date | DATE | The start date of the period. |
end_date | DATE | The end date of the period. |
days | DEFAULT '1,2,3,4,5,6,7' | Specifies the applicable days (1 = Monday, 7 = Sunday). |
created_at | TIMESTAMP DEFAULT CURRENT_TIMESTAMP | Timestamp of when the period was created. |
updated_at | TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP | Automatically updates on modification. |
Query
Get rule by General
content
Get rule by property
content