Use the following procedure to define custom price calculations on resources and services.
1. Create your custom price calculator class
...
This method will be called when the calendar loads, to determine which fields trigger a calculation. To let Booker25 know about the existence of the class, create a new custom setting just as in step 2, except this time name the new record Reservation Price Fields Class. For String Value enter the name of the class you created.
Sample Code
The sample code below adds the account field as one of the fields triggering calculation, besides all the default fields.
Then, in the actual calculation method, it sets the price to zero if the linked account is an Installation Partner.
Code Block | ||
---|---|---|
| ||
global class MyCalculation implements B25.Util_PluginManager.ReservationPrice, B25.Util_PluginManager.ReservationPriceFields { public Set<String> getDependantFieldNames(B25.Util_PluginManager.ReservationPriceData data) { return new Set<String>{ 'B25__Account__c', 'B25__StartLocal__c', 'B25__EndLocal__c', 'B25__Base_Price__c', 'B25__Quantity__c', 'B25__Calculation_Method__c' }; } public void calculate(B25.Util_PluginManager.ReservationPriceData data) { if (data.reservation.B25__Account__c == null) { return; } Account linkedAccount = [ SELECT Type FROM Account WHERE Id = :data.reservation.B25__Account__c ]; if (linkedAccount.Type == 'Installation Partner') { data.reservation.B25__Subtotal__c = 0; } } } |
Related articles
Filter by label (Content by label) | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
...