ffrr.RevenueScheduleServiceglobal with sharing class RevenueScheduleService contains methods for revenue schedule operations. Methods
generateglobal static List<Id> generate(Set<Id> sourceRecordIds) Takes a set of input source recordIds and generates and inserts multiple ffrr__RevenueRecognitionSchedule__c and multiple associated ffrr__RevenueRecognitionScheduleLine__c. The schedules and lines are populated with information from the source records, as defined by the associated ffrr__Settings__c, using the calculation type from the associated ffrr__Template__c. Input Parameters
Return ValueThe Ids of the created ffrr__RevenueSchedule__c records Sample Code
//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.
// In this example the Revenue Schedule Service is used to create a Revenue Schedule for each
// source record Id passed in to the service method, and return a list of associated Revenue Schedule Ids
// If any of the sources are not set up for revenue recognition then no schedules will be generated.
// Retrieve the Ids of the Performance Obligations that will be used as the source Ids from which to generate Revenue Schedules
List<ffrr__PerformanceObligation__c> sourceRecords = [SELECT Id FROM ffrr__PerformanceObligation__c WHERE ffrr__AccountName__c = 'FF'];
Set<Id> sourceRecordIds = new Set<Id>();
for( ffrr__PerformanceObligation__c sourceRecord : sourceRecords )
{
sourceRecordIds.add(sourceRecord.Id);
}
// Get the List of Revenue Schedule Ids that have been generated by this service
List<Id> revenueScheduleIds = ffrr.RevenueScheduleService.generate(sourceRecordIds);
generateglobal static Map<Id, ffrr.RevenueScheduleService.GenerateResult> generate(Set<Id> sourceRecordIds, ffrr.RevenueScheduleService.GenerateConfig config) Takes a set of input source recordIds and a configuration and generates and inserts multiple ffrr__RevenueRecognitionSchedule__c and multiple associated ffrr__RevenueRecognitionScheduleLine__c. The schedules and lines are populated with information from the source records, as defined by the associated ffrr__Settings__c, using the calculation type from the associated ffrr__Template__c. Input Parameters
Return ValueThe Ids of the created ffrr__RevenueSchedule__c records Sample Code
//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.
// In this example the Revenue Schedule Service is used to create a Revenue Schedule for each
// source record Id passed in to the service method, and return a map of source Ids to associated results.
// The generate method is called with a GenerateConfig object that sets the all or none parameter to false.
// If a source is not set up for revenue recognition then no schedules will be generated for it.
// If a source is set up for revenue recognition then a schedule will be generated for it.
// Retrieve the Ids of the Performance Obligations that will be used as the source Ids from which to generate Revenue Schedules
List<ffrr__PerformanceObligation__c> sourceRecords = [SELECT Id FROM ffrr__PerformanceObligation__c WHERE ffrr__AccountName__c = 'FF'];
Set<Id> sourceRecordIds = new Set<Id>();
for( ffrr__PerformanceObligation__c sourceRecord : sourceRecords )
{
sourceRecordIds.add(sourceRecord.Id);
}
ffrr.RevenueScheduleService.GenerateConfig config = new ffrr.RevenueScheduleService.GenerateConfig();
config.allOrNone = false;
// Get the results that have been generated by this service
Map<Id, ffrr.RevenueScheduleService.GenerateResult> results = ffrr.RevenueScheduleService.generate(sourceRecordIds, config);
for(Id sourceId : results.keySet()) {
ffrr.RevenueScheduleService.GenerateResult result = results.get(sourceId);
// Log the Id of the source record for which this result is associated with
System.debug('Source Record Id ' + result.sourceRecordId);
// Log the Id of the schedule that was generated
System.debug('Schedule Id ' + result.scheduleId);
// Log the status of the generate for this source record Id
System.debug('Success ' + result.success);
// Log any errors that were thrown
for(String e : result.errors) {
System.debug('error: ' + e);
}
}
generateAsyncglobal static Id generateAsync() Generates and inserts multiple ffrr__RevenueRecognitionSchedule__c and multiple associated ffrr__RevenueRecognitionScheduleLine__c asynchronously for all the valid objects available in the Org. The schedules and lines are populated with information from the source records, as defined by the associated ffrr__Settings__c, using the calculation type from the associated ffrr__Template__c. Return ValueThe Id of the executing Batch Job Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. // In this example the Revenue Schedule Service is used to asynchronously create a Revenue Schedule for each // available source record in the org, and return the Async Apex Job Id. // If a source is not set up for revenue recognition then no schedules will be generated for it. // If a source is set up for revenue recognition then a schedule will be generated for it. // Get the Id of Async Apex Job generating the Revenue Schedules Id batchJobId = ffrr.RevenueScheduleService.generateAsync(); // Get AsyncApexJob status List<AsyncApexJob> batchJob = [SELECT Id, Status FROM AsyncApexJob WHERE Id = :batchJobId]; generateAsyncglobal static Id generateAsync(Set<Id> sourceRecordIds) Takes a set of input source recordIds and generates and inserts multiple ffrr__RevenueRecognitionSchedule__c and multiple associated ffrr__RevenueRecognitionScheduleLine__c asynchronously. The schedules and lines are populated with information from the source records, as defined by the associated ffrr__Settings__c, using the calculation type from the associated ffrr__Template__c. Input Parameters
Return ValueThe Id of the executing Batch Job Sample Code
//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.
// In this example the Revenue Schedule Service is used to asynchronously create a Revenue Schedule for each
// source record Id passed in to the service method, and return the Async Apex Job Id.
// If a source is not set up for revenue recognition then no schedules will be generated for it.
// If a source is set up for revenue recognition then a schedule will be generated for it.
// Retrieve the Ids of the Performance Obligations that will be used as the source Ids from which to generate Revenue Schedules
List<ffrr__PerformanceObligation__c> sourceRecords = [SELECT Id FROM ffrr__PerformanceObligation__c WHERE ffrr__AccountName__c = 'FF'];
Set<Id> sourceRecordIds = new Set<Id>();
for( ffrr__PerformanceObligation__c sourceRecord : sourceRecords )
{
sourceRecordIds.add(sourceRecord.Id);
}
// Get the Id of Async Apex Job generating the Revenue Schedules
Id batchJobId = ffrr.RevenueScheduleService.generateAsync(sourceRecordIds);
// Get AsyncApexJob status
List<AsyncApexJob> batchJob = [SELECT Id, Status FROM AsyncApexJob WHERE Id = :batchJobId];
ffrr.RevenueScheduleService.GenerateConfigglobal class GenerateConfig class that contains the configuration to be used for generating schedules Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. // Configure the way generate revenue schedules should be performed ffrr.RevenueScheduleService.GenerateConfig config = new ffrr.RevenueScheduleService.GenerateConfig(); // Set the allOrNone configuration to false to continue with schedule generation process even if one or more of the schedules could not be created config.allOrNone = false; Properties
MethodsGenerateConfigglobal GenerateConfig() ffrr.RevenueScheduleService.GenerateResultglobal class GenerateResult class that contains the results given back from the generate method. Properties
|