Problem
Customer needed to trigger itinerary price recalculation from custom Apex code and wanted to know how to detect when the recalculation completes.
What We Found
Kaptio provides two methods for programmatic recalculation: (1) PriceLineFactory global class for recalculating individual itinerary items, and (2) AsyncRequest records for recalculating entire itineraries. There is no Platform Event emitted on completion, but the RecalculationStatus field can be monitored.
Solution
- For ITINERARY ITEMS only: Use the PriceLineFactory global class. Documentation and code samples available at https://docs.kaptioapis.com/kaptio-code-sample/-/price-line-factory. Note: No completion notification mechanism available with this method.
- For FULL ITINERARY recalculation: Create a KaptioTravel__AsyncRequest__c record with these values: (1) KaptioTravel__AsyncType__c = āRecalculate Allā, (2) KaptioTravel__Params__c = serialized itinerary JSON, (3) KaptioTravel__Error__c = false
- Query the itinerary with ALL required fields (see code sample below) and serialize it into the Params field as JSON with key āitineraryā
- To detect completion: Monitor the KaptioTravel__RecalculationStatus__c field on the itinerary. It will be set to āRecalculation Completedā on success or āErrorsā on failure
Notes
- Each AsyncRequest record can only process ONE itinerary. If multiple itineraries need recalculation, create separate AsyncRequest records for each.
- The itinerary query must include many related Channel and Brand fields for the recalculation to work correctly. See the required SOQL query in the code sample.
- Required itinerary fields include: Id, Account, BusinessUnitId, BrandCurrencyIsoCode, BuyConversionRatesJSON, Channel, CommissionTaxProfile, CorporateCurrencyIsoCode, Currency, CurrencyFactor, CurrencyFactorBCY, LockSellPriceMode, OpenAmendment, RecalculationStatus, RecalculationErrors, SellRatesQuoteDateConvert, UseLightningVersion, plus many Channel and Brand relationship fields
Warnings
ā ļø PriceLineFactory can only recalculate itinerary items, NOT entire itineraries ā ļø Kaptio does NOT emit a Platform Event on recalculation completion - you must poll the RecalculationStatus field or use Flow/Apex/CDC to react to field changes
Source: KHELP-12299