Skip to main content

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

databse

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 NameData TypeDescription
idAI PKAuto-incremented primary key, uniquely identifies each rule.
property_idINT(7)Links the rule to a specific property (hotel, rental, etc.).
rule_nameVARCHAR(100)The name of the rule (e.g., "Peak Season Pricing").
rule_typeINT(1)Defines the type of rule (e.g., 1 = Occupancy-Based, 2 = Period-Based, etc.).
statusINT(1)Indicates whether the rule is active (1 = Active, 0 = Inactive).
created_atTIMESTAMPTimestamp of when the rule was created.
updated_atTIMESTAMP (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 NameData TypeDescription
idAI PKAuto-incremented primary key, uniquely identifies each condition.
rule_idINT (FK to rules.id)Foreign key linking the condition to a specific rule.
custom_nameVARCHAR(150) DEFAULT NULLOptional custom name for the condition.
conditionENUM('increase', 'decrease') DEFAULT NULLDefines if the rule increases or decreases the value.
value_typeENUM('amount', 'percentage') DEFAULT NULLDetermines if the value is a fixed amount or a percentage.
valueDOUBLE(10,2) DEFAULT NULLThe numeric value applied to the condition.
paxINT(2) DEFAULT 0Specifies the number of guests (pax) the condition applies to.
created_atTIMESTAMP DEFAULT CURRENT_TIMESTAMPTimestamp of when the condition was created.
updated_atTIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMPAutomatically updates on modification.

Periods

This table defines different time periods (seasons) that can be referenced in the rules.

Column NameData TypeDescription
idAI PKAuto-incremented primary key, uniquely identifies each period.
condition_idINT (FK to conditions.id)Foreign key linking the period to a specific condition.
start_dateDATEThe start date of the period.
end_dateDATEThe end date of the period.
daysDEFAULT '1,2,3,4,5,6,7'Specifies the applicable days (1 = Monday, 7 = Sunday).
created_atTIMESTAMP DEFAULT CURRENT_TIMESTAMPTimestamp of when the period was created.
updated_atTIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMPAutomatically updates on modification.

Query

Get rule by General

content

Get rule by property

content