In order keep configuration simple, please perform the following steps in Salesforce Classic (Booker25 is Lightning-Ready, you may afterwards use the app in Salesforce Lightning as you please)
Use the following procedure to define custom price calculations on resources and services.
1. Create your custom price calculator class
Create a class that implements the interface B25.Util_PluginManager.ReservationPrice. Implementing that interface means the class must have a method with the following signature:
void calculate(B25.Util_PluginManager.ReservationPriceData)
This method will be called whenever a reservation is saved, or whenever the reservation form gets rerendered. You can control when the reservation form gets rerendered, more on that in a bit. The B25.Util_PluginManager.ReservationPriceData object that gets passed along to the calculate method has two properties that will help you to make your own price calculation.
Name | Type | Purpose |
---|---|---|
reservation | B25__Reservation__c | Contains the service costs as shown on the reservation form when you have the setting 'Services have a price' enabled. [link to other doc page] Go here for more information about configuring Booker25's system settings. |
serviceCosts | Decimal | Contains the reservation as it is at the moment the calculate method is called. It will have all the fields populated that are visible on the reservation form. |
In the calculate method you will be able to set any fields on the reservation property record, such as the B25__Subtotal__c field, in order to control the final price of the reservation, or to start an approval process.
Booker25 Global Classes
- Go to Setup
- Search for Apex Classes
- Open the Util_PluginManager class
2. Activate the custom price calculator class
Now, let Booker25 know that it should use your custom class instead of the default price calculation
- Go to Setup
- Search for Custom Settings
- Click Manage next to System Setting
- Click New
- Name the record Reservation Price Calculator Class, and for String Value enter the name of your custom price calculator class
Related articles