This ia an example of adding a formulaic property to the Biskit of type Booking, which will be called BookingCost and will calculate the cost of the booking depending on the duration of the booking and whether it was cancelled or not.

 

If a booking was Denied, or Cancelled more than 7 days before it was due, then no cost. If it was Cancelled more than 2 but less than 7 days ago, then 20% of cost, if it was Cancelled with less than 2 days to go then 50% of the cost otherwise full cost.

 

The formula used will be:

 

case

 when [status] = 'DENIED' then 0

 when [status] = 'APPROVED' or [status] = 'REQUESTED' then [projectResourceSettings.costPerHour] * [durationInMinutes]/60

 else

   case

     when datediff([dateRange.start], [cancelled]) >= 7 then 0

     when datediff([dateRange.start], [cancelled]) >= 2 then 0.2*[projectResourceSettings.costPerHour] * [durationInMinutes]/60

     else 0.5*[projectResourceSettings.costPerHour] * [durationInMinutes]/60

   end

end

 

[status] will refer to a property called status found on the Booking Biskit.

 

[projectResourceSettings.costPerHour] will refer to a property called costPerHour that is found on the Biskit that is referenced by the projectResourceSettings property of the Booking Biskit. In this case the type of Biskit referenced is Project Resource Settings.

 

[durationInMinutes] will refer to a property called durationInMinutes found on the Booking Biskit.

 

[dateRange.start] will refer to a property called dateRange found on the Booking Biskit. dateRange is of type DateRange, this type has some sub types, one of which is start. start holds the date and time of the start of the date range.

 

[cancelled] will refer to a property called cancelled found on the Booking Biskit.

 

datediff is a MySQL function that returns the difference between two dates as a whole number of days. For more accurate time differences use a combination of timediff() and time_to_sec() ( i.e. time_to_sec(timediff(date1,date2)) returns the number of seconds between the two dates ).

 

We will be using the costPerHour property that can be set up for each resource a project can use. This way individual projects can be set up to pay different amounts for each resource.

 

1.Go to Admin->Bakery,

2.Press the Open All button to open the Biskit Tree

3.Select the Biskit to add properties to (in this case Booking)

4.Press the Edit button to get the Bislkit into edit mode

5.Press the Add New button to add a new property.

6.Update the meta properties of the property. Most of them do not need to be changed but as a minimum

a)Change Type to double.

b)Change Name to BookingCost.

c)Make it not Editable.

d)Make it Formulaic.
 

exp_bakeryExampleFormulaic

 

 

7.Enter the formula required.
 

exp_bakeryExampleFormula

 
 

8.Press the Save button. An error box will appear:

 

exp_bakeryFormulaError
 
Check the error by pressing Show Log. If the error is complaining about a property not being live yet then press the OK button, and then the Save Despite Errors button.

 

9.As this is adding a formulaic property we only need to reload the database configuration.

a)Press Reload Database Configuration, to load the new database into Exprodo DB

   b) Refresh the browser
 

Go and check bookings to see if the Booking Cost is present. In this case if when viewing a booking in the Booking Calendar at the bottom of the Booking will appear the Booking Cost.