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

Use cases and examples

We’ll look at the earlier examples of business rules to determine discount on tickets and implement them with the tools we have under our belt.

The following factset with part persons: \(FS_{persons}\) is used again.

namehairweightagegendermember
Homershort25036malefalse
Margelong15035femalefalse
Bartshort9010malefalse
Lisamiddle788femalefalse
Maggiemiddle201femalefalse
Abeshort17070malefalse
Selmalong16041femaletrue
Ottolong18038malefalse
Krustymiddle20045maletrue

warning

TODO

Example: Personal Discount Ticket

  • Rule: If a person is a member and the total is over $100, give 10% off.

The engine checks if both conditions are true, and if so, applies the discount.

members = getpart("persons") ; filter (member == true)
discount = returnif( getpart("members"), const({factor: 0.15})) ; const({factor: 0.0})
  

Example: Family Discount Ticket

  • Rule: If the group consists of more than 2 members, all persons younger than 12 years get 50% off.

The engine checks the group of people, finds the kids if there are any, and and if so, applies the discount.

Example: Combined Discount

  • Rule: If there is Family Discount use that, otherwise consider the personal discount. If both don’t hold, give 5% discount on week days.