Documentation

Rate Script Tutorial

Rate scripts determine the rate for a single resource in a reservation. You can use them to dynamically adjust the rate for different situations. To begin making rate scripts, first add a rate to a resource by navigating to the resource edit page, then selecting "Add Rate" in the Reservations -> Rates panel.

create_a_rate.png

Now that your resource has a rate, we can create a rate script and begin testing it with this resource and rate. To create a rate script, go to the Resources -> Scripts page of the administrative section, select the "Rates" tab, and then select "Create Rate Script" in the top right corner.

create_rate_script.png

After creating the rate script, you will be presented with the script editing IDE. This is similar to the script IDE for reservations, except in order to test your script you will need to first select the resource and rate you wish to test.

rate_script_editor.png

Another key difference with rate scripts is that there is no concept of exceptions that block the reservation -- rate scripts must return a dictionary containing at minimum a rate, rate_unit, and rate_basis. Refer to this documentation for more information about the structure expected for the return value of rate scripts. Rate scripts not returning this information or throwing exceptions will crash.

Another difference in rate scripts is that the original rate that the reservation was attached to is accessible to the user in script['rate']. To be helpful, the information in script['rate'] is provided to you when testing after you have selected a resource and a rate.

rate_object_in_dict_while_testing.png

As in reservation scripts, all the details about the reservation itself are available within the reservation dictionary.

When updating the rate and rate description, the rate description in the UI itself will also dynamically update.

Once you are happy with your script, you can add it to your rate by returning to the resource editing page and clicking the "Add Script" button on the rate.

add_rate_script_to_rate.png

Now your rate script will execute whenever a reservation is made and dynamically set the rate for your resource.