Revenue Management API Developer Reference

ffrr.TransactionService

global with sharing class TransactionService implements ITransactionService

Enums

LineAction

Indicates the action to be taken if existing "In Progress" transaction lines are found for the same source object and period in a transaction.

Value Description
Ignore Keep the original transaction line. If there is no matching line on any “In Progress” transaction a new line will be created on this transaction.
Replace Delete the original transaction line and add a new transaction line to the new "In Progress" revenue recognition transaction.

Status

The status of the revenue recognition transaction.

Value Description
Committed The transaction has been committed. Its status is "Committed".
InProgress The transaction has been saved but not committed. Its status is "In Progress".

Methods

retrieve

global static List<ffrr.TransactionService.TransactionLine> retrieve(Id elementId)

Retrieves a list of Committed or In Progress transactions for the specified item (for example, project or milestone). The returned data includes only the high-level details of the transaction (such as transaction status and total recognized) and not the individual transaction lines.

Input Parameters

Name Type Description
elementId Id The specified item to retrieve transactions for.

Return Value

The List of inprogress and committed Transaction Lines related to the recordId.

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.

//Note: This sample demonstrates how to call the retrieve method and therefore relies
//on there being data within the system. While the sample will run without there
//being any data in the system, the output will, naturally, be different.
ID itemID = null;

//Note: At this point the itemID variable needs to be populated with the ID of the
//Revenue Recognition item to be queried. The ID will, naturally, depend on the data
//setup within your system.

//Call the method
List<ffrr.TransactionService.TransactionLine> transactions = ffrr.TransactionService.retrieve(itemID);

//Output the transactions that were retrieved
for (ffrr.TransactionService.TransactionLine transactionLine : transactions)
{
    System.debug('Transaction: ' + transactionLine);
}

save

global static ffrr.TransactionService.StagingSaveResult save(ffrr.TransactionService.StagingSaveContext context, ffrr.TransactionService.StagingSaveOptions options)

Creates Revenue Recognition Transactions (and associated Transaction Lines) of Status "In Progress" using data from the Staging Table Records.

Input Parameters

Name Type Description
context ffrr.TransactionService.StagingSaveContext Specifies the staging records that will be used to create the RR Transcations. Supports various options for selecting leaf/not leaf details, specific versions etc.
options ffrr.TransactionService.StagingSaveOptions Additional information that should be attached to the created RR Transactions and RR Transaction Lines.

Return Value

The StagingSaveResult containing either the Id of the AsyncJob if the process has been executed asynchronously or the created RR Transactions keyed by version.

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.

// Create the StagingSaveContext.
ffrr.TransactionService.StagingSaveContext context = new ffrr.TransactionService.StagingSaveContext();

// Set the versions of the staging data to create RevRec Transactions for.
List<ffrr__StagingVersion__c> versions = [SELECT Id FROM ffrr__StagingVersion__c WHERE ffrr__GroupName__c = 'Project__c' Limit 2];
context.versions = new List<Id>{versions[0].Id};

// Include groupings.
List<ffrr__GroupingSummary__c> groupings = [SELECT Id FROM ffrr__GroupingSummary__c LIMIT 10];
context.Groupings = new List<Id>();
for(ffrr__GroupingSummary__c grouping : groupings)
{
    context.Groupings.add(grouping.Id);
}

// Include summaries from another version.
List<ffrr__StagingSummary__c> summaries = [SELECT Id from ffrr__StagingSummary__c WHERE ffrr__Version__c = :versions[1].Id AND ffrr__AccountName__c = 'FF'];
context.Summaries = new List<Id>();
for(ffrr__StagingSummary__c summary : summaries)
{
    context.Summaries.add(summary.Id);
}

// Exclude a summary from the data of the first version.
ffrr__StagingSummary__c summaryToExclude = [SELECT Id FROM ffrr__StagingSummary__c WHERE ffrr__Version__c = :versions[0].Id AND ffrr__AccountName__c = 'FF'];

// Exclude details from the second version.
List<ffrr__StagingDetail__c> detailsToExclude = [SELECT Id FROM ffrr__StagingDetail__c WHERE ffrr__Version__c = :versions[0].Id AND ffrr__TotalRevenue__c < 100000];
context.Details = new List<Id>();
for(ffrr__StagingDetail__c detail : detailsToExclude)
{
    context.Details.add(detail.Id);
}

// Create the StagingTransactionDetails that contain information to.
// be included on the RR Transactions (see ffrr.TransactionService.StagingTransactionDetails)
ffrr__RecognitionPeriod__c period = [Select Id, Name FROM ffrr__RecognitionPeriod__c WHERE ffrr__RecognitionYear__r.Name = '2016' LIMIT 1];
ffrr.TransactionService.StagingTransactionDetails version1Transaction = new ffrr.TransactionService.StagingTransactionDetails();
version1Transaction.Version = versions[0].Id;
version1Transaction.PeriodName = period.Name;
version1Transaction.PeriodId = period.Id;
version1Transaction.Description = 'January Projects Version 1';
version1Transaction.LegislationType = 'ASC 605';
version1Transaction.CommitTransaction = true;
version1Transaction.LineAction = ffrr.TransactionService.LineAction.IGNORE;

ffrr.TransactionService.StagingTransactionDetails version2Transaction = new ffrr.TransactionService.StagingTransactionDetails();
version2Transaction.Version = versions[1].Id;
version2Transaction.PeriodName = period.Name;
version2Transaction.PeriodId = period.Id;
version2Transaction.Description = 'January Projects Version 2';
version2Transaction.LegislationType = 'ASC 605';
version2Transaction.CommitTransaction = true;
version2Transaction.LineAction = ffrr.TransactionService.LineAction.IGNORE;

List<ffrr.TransactionService.StagingTransactionDetails> transactionDetails = new List<ffrr.TransactionService.StagingTransactionDetails>();
transactionDetails.add( version1Transaction );
transactionDetails.add( version2Transaction );

// Add the StagingTransactionDetails to the context.
context.StagingTransactionDetails = transactionDetails;


// Create the StagingSaveOptions object.
ffrr.TransactionService.StagingSaveOptions options = new ffrr.TransactionService.StagingSaveOptions();

// Set the type of the Apex Transactions to be performed.
// If not set the Apex Transaction Type will be defaulted to CommonService.ApexTransactionType.SYNCHRONOUS.
options.TransactionType = ffrr.CommonService.ApexTransactionType.ASYNCHRONOUS;

// Start the save process and get the result.
ffrr.TransactionService.StagingSaveResult result = ffrr.TransactionService.save( context, options );

// Retrieve the Async Job Id from the result.
Id aynchJob = result.AsyncJob;

save

global static Id save(ffrr.TransactionService.HeaderDetails headerDetails)

Saves a revenue recognition transaction (and associated transaction lines) with a status of "In Progress". The single supplied parameter includes both the header details for the transaction and the items that are to be included as part of the transaction.

Input Parameters

Name Type Description
headerDetails ffrr.TransactionService.HeaderDetails Details of the transaction.

Return Value

The Id of the AsyncApexJob.

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.

// Note: This sample demonstrates how to call the save method for two lines in a 
// single transaction, and therefore relies on there being data within the system.
// For the sample to run, Settings, Templates and Recognition Years and Periods
// (covering 2013) should be available.

// If the data isn't available then the results should indicate that the process couldn't
// be completed.

// In the example it is assumed that two records to recognize exist.
// (stored in variables named 'project1' and  'project2')

Account project1 = new Account();
Account project2 = new Account();

// Create the header Details Record for the transaction to be saved.
// See ffrr.TransactionService.HeaderDetails for more details.
ffrr.TransactionService.HeaderDetails headerDetails = new ffrr.TransactionService.HeaderDetails();
headerDetails.description = 'My Transaction';
headerDetails.legislationType = 'ASC 605';
headerDetails.currencyName = 'GBP';
headerDetails.recognitionDate = system.today();
headerDetails.lineAction = ffrr.TransactionService.LineAction.IGNORE;
headerDetails.lineDetailsMap = new Map<Id, ffrr.TransactionService.LineDataToSave>();
headerDetails.groupName = 'Project__c';
headerDetails.period = '2013/008';

// Note: Although we have specified 'period' in the header structure above, your Org may be
// configured so that Period Validation is enabled.
// In this case the periodId field must be set to contain the Id of the period that
// the transaction is to be recorded against.
// e.g. headerDetails.periodId = myRecognitionPeriod.Id;

// Note: To append lines to an existing InProgress transaction the
// headerDetails.transactionId field should be filled.
//
// For example:
// ffrr.RevenueRecognitionTransaction__c transactionToAppend = [ Select Id from ffrr.RevenueRecognitionTransaction__c where Status__c = 'in Progress' Limit 1 ];
// headerDetails.transactionId = transactionToAppend.Id;

// Create the two Line Data records ( one for each of the two projects )
// and add them to the transaction Header Details record.
// See ffrr.TransactionService.LineDataToSave for more details

// Line Data for Project1
ffrr.TransactionService.LineDataToSave sampleLineData1 = new ffrr.TransactionService.LineDataToSave();
sampleLineData1.recordIdList = new List<Id>{project1.Id};
sampleLineData1.templateId = project1.ffrrTemplate__c;
sampleLineData1.toRecognizeThisPeriod = 100.00;

// Add the line to the Header Details.
headerDetails.lineDetailsMap.put(project1.Id, sampleLineData1);

// Line Data for Project 2
ffrr.TransactionService.LineDataToSave sampleLineData2 = new ffrr.TransactionService.LineDataToSave();
sampleLineData2.recordIdList = new List<Id>{project2.Id};
sampleLineData2.templateId = project2.ffrrTemplate__c;
sampleLineData2.toRecognizeThisPeriod = 100.00;

// Add the line to the Header Details.
headerDetails.lineDetailsMap.put(project2.Id, sampleLineData2);

// Call the save method that will start an asynchronous process
// to create the InProgress RR Transaction.
Id saveBatchId = ffrr.TransactionService.save( headerDetails );

bulkSave

global static ffrr.TransactionService.SaveResult bulkSave(List<ffrr.TransactionService.HeaderDetails> headerDetails)

Creates Transactions and TransactionLines using the provided HeaderDetails and LineDataToSave. Same as the save(HeaderDetails headerDetails) method except this will not start an asynchronous process.

Input Parameters

Name Type Description
headerDetails List<ffrr.TransactionService.HeaderDetails> The Transaction Header details used to create Transactions and TransactionLines.

Return Value

A SaveResult containing the List of Transaction Ids for the created Transactions.

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.

// Note: This sample demonstrates how to call the save method for two lines in a
// single transaction, and therefore relies on there being data within the system.
// For the sample to run, Settings, Templates and Recognition Years and Periods
// (covering 2013) should be available.

// If the data isn't available then the results should indicate that the process couldn't
// be completed.

// In the example it is assumed that two records to recognize exist.
// (stored in variables named 'project1' and  'project2')

Account project1 = new Account();
Account project2 = new Account();

// Create the header Details Record for the transaction to be saved.
// See ffrr.TransactionService.HeaderDetails for more details.
ffrr.TransactionService.HeaderDetails headerDetails = new ffrr.TransactionService.HeaderDetails();
headerDetails.description = 'My Transaction';
headerDetails.legislationType = 'ASC 605';
headerDetails.currencyName = 'GBP';
headerDetails.recognitionDate = system.today();
headerDetails.lineAction = ffrr.TransactionService.LineAction.IGNORE;
headerDetails.lineDetailsMap = new Map<Id, ffrr.TransactionService.LineDataToSave>();
headerDetails.groupName = 'Project__c';
headerDetails.period = '2013/008';

List<ffrr.TransactionService.HeaderDetails> headers = new List<ffrr.TransactionService.HeaderDetails>{headerDetails};

// Note: Although we have specified 'period' in the header structure above, your Org may be
// configured so that Period Validation is enabled.
// In this case the periodId field must be set to contain the Id of the period that
// the transaction is to be recorded against.
// e.g. headerDetails.periodId = myRecognitionPeriod.Id;

// Note: To append lines to an existing InProgress transaction the
// headerDetails.transactionId field should be filled.
//
// For example:
// ffrr.RevenueRecognitionTransaction__c transactionToAppend = [ Select Id from ffrr.RevenueRecognitionTransaction__c where Status__c = 'in Progress' Limit 1 ];
// headerDetails.transactionId = transactionToAppend.Id;

// Create the two Line Data records ( one for each of the two projects )
// and add them to the transaction Header Details record.
// See ffrr.TransactionService.LineDataToSave for more details

// Line Data for Project1
ffrr.TransactionService.LineDataToSave sampleLineData1 = new ffrr.TransactionService.LineDataToSave();
sampleLineData1.recordIdList = new List<Id>{project1.Id};
sampleLineData1.templateId = project1.ffrrTemplate__c;
sampleLineData1.toRecognizeThisPeriod = 100.00;

// Add the line to the Header Details.
headerDetails.lineDetailsMap.put(project1.Id, sampleLineData1);

// Line Data for Project 2
ffrr.TransactionService.LineDataToSave sampleLineData2 = new ffrr.TransactionService.LineDataToSave();
sampleLineData2.recordIdList = new List<Id>{project2.Id};
sampleLineData2.templateId = project2.ffrrTemplate__c;
sampleLineData2.toRecognizeThisPeriod = 100.00;

// Add the line to the Header Details.
headerDetails.lineDetailsMap.put(project2.Id, sampleLineData2);

// Call the save method that will start a synchronous process
// to create the InProgress RR Transaction.
ffrr.TransactionService.SaveResult result = ffrr.TransactionService.bulkSave( headers );

commitTransactions

global static Id commitTransactions(List<Id> transactionList)

Commits the transactions provided. This method starts an asynchronous process. Will update the source record fields if those fields are filled in on the corresponding setting record.

Input Parameters

Name Type Description
transactionList List<Id> The Ids of the transactions to be committed.

Return Value

The Id of the AsyncApexJob.

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.

// Note: This sample demonstrates how to call the commit method for a previously
// saved transaction, and therefore relies on there being data within the system.

// For the sample to run Settings, Templates and Recognition Years and Periods
// should be available, and a transaction should have been correctly
// saved so that it is marked as 'In Progress'.

// If the data isn't available then the results should indicate
// that the process couldn't be completed.

// Extract any saved transactions that are currently marked as being 'In Progress'
List<ffrr__RevenueRecognitionTransaction__c> savedTransactions = [Select Id FROM ffrr__RevenueRecognitionTransaction__c WHERE ffrr__status__c = 'In Progress'];

// Build the list of transaction Ids candidates to be committed.
List<Id> transactionIds = new List<Id>();
for (ffrr__RevenueRecognitionTransaction__c savedTransaction : savedTransactions)
{
    transactionIds.add(savedTransaction.Id);
}

// Call the commit method that will start an asynchronous process
// to commit the In Progress RR Transactions.
Id commitBatchId = ffrr.TransactionService.commitTransactions( transactionIds );

bulkCommit

global static ffrr.TransactionService.CommitResult bulkCommit(List<Id> transactions)

Commits the transactions provided. Will update the source record fields if those fields are filled in on the corresponding setting record.

Input Parameters

Name Type Description
transactions List<Id> The Ids of the transactions to be committed.

Return Value

A CommitResult containing a list of the committed transactions. Note: This list is not in the order the transactions were provided.

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.

// Note: This sample demonstrates how to call the commit method for a previously
// saved transaction, and therefore relies on there being data within the system.

// For the sample to run Settings, Templates and Recognition Years and Periods
// should be available, and a transaction should have been correctly
// saved so that it is marked as 'In Progress'.

// If the data isn't available then the results should indicate
// that the process couldn't be completed.

// Extract any saved transactions that are currently marked as being 'In Progress'
List<ffrr__RevenueRecognitionTransaction__c> savedTransactions = [Select Id FROM ffrr__RevenueRecognitionTransaction__c WHERE ffrr__status__c = 'In Progress'];

// Build the list of transaction Ids candidates to be committed.
List<Id> transactionIds = new List<Id>();
for (ffrr__RevenueRecognitionTransaction__c savedTransaction : savedTransactions)
{
    transactionIds.add(savedTransaction.Id);
}

// Call the commit method that will start a synchronous process
// to commit the In Progress RR Transactions.
ffrr.TransactionService.CommitResult result = ffrr.TransactionService.bulkCommit( transactionIds );

ffrr.TransactionService.HeaderDetails

global class HeaderDetails

Contains the header and line data to be used for revenue recognition.

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.

// Given the following record structure:
// Project 1 <- Milestone 1 <- Time Card 1
// the example demonstrates the creation of a Header
// detail record containing a line data to save for
// Time Card 1 record.

// First the Line Data record for the source record to be recognised should be created
ffrr.TransactionService.LineDataToSave sampleLineData = new ffrr.TransactionService.LineDataToSave();

// The recordIdList should contain the source record Ids
// from the parent record to the record to be recognised.
sampleLineData.recordIdList = new List<Id>();
sampleLineData.recordIdList.add('a0sa00000011op1');    //Add the Project 1 Id
sampleLineData.recordIdList.add('a0ga00000026abx');    //Add the Milestone 1 Id
sampleLineData.recordIdList.add('a0va00000059tb8');    //Add the Time Card 1 Id

// Add the temlate Id of the record to be recognised ( in this example for Time Card 1 )
sampleLineData.templateId = 'a0ba00000512cc6';

// Add the value to be recognised.
sampleLineData.toRecognizeThisPeriod = 112.06;

// Second create the Header Details record
ffrr.TransactionService.HeaderDetails sampleHeaderDetails = new ffrr.TransactionService.HeaderDetails();

// Specify that we want to save and commit the RR Transaction (rather than just save)
sampleHeaderDetails.commitTransaction = true;

//Specify the currency that the transaction will be recognised.
sampleHeaderDetails.currencyName = 'USD';

// Specify the group. This should be the Object type of the top Parent record.
// In this example the Project's object type.
sampleHeaderDetails.groupName = 'Project__c';

// Specify the RR Transaction's description
sampleHeaderDetails.description= 'February Time Cards';

// Specify the RR Transactions's Legislation Type (Optional)
sampleHeaderDetails.legislationType = 'ASC 605';

// Specify what we want to do with existing transaction lines
// In this example if there is an existing transaction line for this record
// in an InProgress RR Transaction a new one will not be created.
sampleHeaderDetails.lineAction = ffrr.TransactionService.LineAction.IGNORE;

// Specify the period and the period's Id that we're recognising against and the date of the recognition.
sampleHeaderDetails.period = '02/2013';
sampleHeaderDetails.periodId = 'a0ta00000001gq2';
sampleHeaderDetails.recognitionDate = date.newInstance(2013, 3, 2);

// Create a map containing our line data
sampleHeaderDetails.lineDetailsMap = new Map<Id, ffrr.TransactionService.LineDataToSave>();

// Add our line data to the map. The key should be the Id of the source record that will be recognised.
// In this example the Time Card's Id.
// Note: We can add as many lines here as we want
sampleHeaderDetails.lineDetailsMap.put('a0va00000059tb8', sampleLineData);

Properties

Name Type Description
transactionId Id The Id of the "In Progress" transaction that the lines defined on this header details should be appended to.
periodId Id Id of the period.
period String Name of the period.
lineAction ffrr.TransactionService.LineAction Action to be taken if existing "In Progress" transaction lines are found for the same source object and period.
description String Description of the transaction.
currencyName String Name of the currency.
groupName String Name of the recognition group. The group is the Schema.SObjectType defined in the ffrr__Object__c field on the root primary ffrr__Settings__c record. This ffrr.TransactionService.HeaderDetails can only contain ffrr.TransactionService.LineDataToSave that relate to settings where the root primary Setting has the same Schema.SObjectType as defined in this ffrr.TransactionService.HeaderDetails.
recognitionDate Date Date on which to base the revenue calculation.
commitTransaction boolean True = Save and Commit. False = Save only.
legislationType String The Revenue Recognition Transaction's Legislation Type.
originatingProcess String The process that is to be recorded as creating this transaction. This will be set on the OriginatingProcess__c field. This will only be set if this is a new transaction, it will be ignored if transactionId is set.
lineDetailsMap Map<Id, ffrr.TransactionService.LineDataToSave> The lines to save on the transaction.

Methods

HeaderDetails

global HeaderDetails()

If set to true when replacing lines any amount on the old line will be transfered to the new one. This is used in a temporary fix for the transfer previously recognized process on POLIs. When we refactor this service should be removed and there should be a proper update process on existing RRTs/RRTLs

ffrr.TransactionService.LineDataToSave

global class LineDataToSave

Contains a single set of line data to be saved as part of a revenue recognition transaction.

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.

// Given the following record structure:
// Project 1 <- Milestone 1 <- Time Card 1
// the example demonstrates the creation of
// a line data to save for the Time Card 1 record.

// Create the Line Data record
ffrr.TransactionService.LineDataToSave sampleLineData = new ffrr.TransactionService.LineDataToSave();

// Fill the recordIdList with all the source record Ids
// from the top parent to the one that will be recognised
sampleLineData.recordIdList = new List<Id>();
sampleLineData.recordIdList.add('a0sa00000011op1');    //Add the Project 1 Id
sampleLineData.recordIdList.add('a0ga00000026abx');    //Add the Milestone 1 Id
sampleLineData.recordIdList.add('a0va00000059tb8');    //Add the Time Card 1 Id

// Fill the template Id. This should be the template specified on the record to be recognised.
// In this example the template on the Time Card 1 record.
sampleLineData.templateId = 'a0ba00000512cc6';

// Specify the amount to be recognised.
sampleLineData.toRecognizeThisPeriod = 112.06;

Properties

Name Type Description
recordIdList List<Id> The full list of Ids from the parent record to the record to be recognised. The primary record should be the first element in the list and the record to be recognised should be the last.
templateID Id The template Id related to the record to be recognized.
toAmortizeThisPeriod Decimal Amount to amortize this period.
toRecognizeThisPeriod Decimal Amount to recognize this period.

Methods

LineDataToSave

global LineDataToSave()

ffrr.TransactionService.TransactionLine

global class TransactionLine extends ViewService.Reference

Contains the details of a revenue recognition transaction.

This class extends ffrr.ViewService.Reference

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.

//Create the TransactionLine
ffrr.TransactionService.TransactionLine tlSample = new ffrr.TransactionService.TransactionLine();

//Populate the fields inherited from ffrr.ViewService.Reference
tlSample.id = 'a0va00000059tb8';
tlSample.name = 'Customer Order Deposit 1762991';

//Populate the fields specific to ffrr.TransactionService.TransactionLine
tlSample.amount = 500.00;
tlSample.recognitionCurrency = 'USD';
tlSample.recognitionDate = date.newInstance(2013, 3, 31);
tlSample.status = ffrr.TransactionService.Status.COMMITTED;

Properties

Name Type Description
recognitionDate Date Date on which the revenue calculation was based.
status ffrr.TransactionService.Status Status of the transaction.
recognitionCurrency String The currency of the recognition line.
amountAmortized Decimal The amount amortized.
amount Decimal The amount recognized.

ffrr.TransactionService.SaveResult

global class SaveResult

Contains the list of transactions created by the TransactionService.bulkSave method.

Properties

Name Type Description
transactions List<Id> The ids of the transactions that were created. A transaction should only ever have the status "Error" or "In Progress".

ffrr.TransactionService.CommitResult

global class CommitResult

Contains the list of transactions committed by the TransactionService.bulkCommit method. Note: This list is not in the order the transaction ids were provided to the service call.

Properties

Name Type Description
Transactions List<Id> The ids of the transactions that were committed. Any transactions that failed to be committed are not in this list.

ffrr.TransactionService.StagingSaveContext

global class StagingSaveContext

Contains details required to create Revenue Recognition Transactions and TransactionLines from the staging 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.

// Create the StagingSaveContext.
ffrr.TransactionService.StagingSaveContext context = new ffrr.TransactionService.StagingSaveContext();

// Set the versions of the staging data to create RevRec Transactions for.
List<ffrr__StagingVersion__c> versions = [SELECT Id FROM ffrr__StagingVersion__c WHERE ffrr__GroupName__c = 'Project__c' Limit 2];
context.versions = new List<Id>{versions[0].Id};

// Include groupings.
List<ffrr__GroupingSummary__c> groupings = [SELECT Id FROM ffrr__GroupingSummary__c LIMIT 10];
context.Groupings = new List<Id>();
for(ffrr__GroupingSummary__c grouping : groupings)
{
    context.Groupings.add(grouping.Id);
}

// Include summaries from another version.
List<ffrr__StagingSummary__c> summaries = [SELECT Id from ffrr__StagingSummary__c WHERE ffrr__Version__c = :versions[1].Id AND ffrr__AccountName__c = 'FF'];
context.Summaries = new List<Id>();
for(ffrr__StagingSummary__c summary : summaries)
{
    context.Summaries.add(summary.Id);
}

// Exclude a summary from the data of the first version.
ffrr__StagingSummary__c summaryToExclude = [SELECT Id FROM ffrr__StagingSummary__c WHERE ffrr__Version__c = :versions[0].Id AND ffrr__AccountName__c = 'FF'];

// Exclude details from the second version.
List<ffrr__StagingDetail__c> detailsToExclude = [SELECT Id FROM ffrr__StagingDetail__c WHERE ffrr__Version__c = :versions[0].Id AND ffrr__TotalRevenue__c < 100000];
context.Details = new List<Id>();
for(ffrr__StagingDetail__c detail : detailsToExclude)
{
    context.Details.add(detail.Id);
}

// Create the StagingTransactionDetails that contain information to.
// be included on the RR Transactions (see ffrr.TransactionService.StagingTransactionDetails)
ffrr__RecognitionPeriod__c period = [Select Id, Name FROM ffrr__RecognitionPeriod__c WHERE ffrr__RecognitionYear__r.Name = '2016' LIMIT 1];
ffrr.TransactionService.StagingTransactionDetails version1Transaction = new ffrr.TransactionService.StagingTransactionDetails();
version1Transaction.Version = versions[0].Id;
version1Transaction.PeriodName = period.Name;
version1Transaction.PeriodId = period.Id;
version1Transaction.Description = 'January Projects Version 1';
version1Transaction.CommitTransaction = true;
version1Transaction.LineAction = ffrr.TransactionService.LineAction.IGNORE;

ffrr.TransactionService.StagingTransactionDetails version2Transaction = new ffrr.TransactionService.StagingTransactionDetails();
version2Transaction.Version = versions[1].Id;
version2Transaction.PeriodName = period.Name;
version2Transaction.PeriodId = period.Id;
version2Transaction.Description = 'January Projects Version 2';
version2Transaction.CommitTransaction = true;
version2Transaction.LineAction = ffrr.TransactionService.LineAction.IGNORE;

List<ffrr.TransactionService.StagingTransactionDetails> transactionDetails = new List<ffrr.TransactionService.StagingTransactionDetails>();
transactionDetails.add( version1Transaction );
transactionDetails.add( version2Transaction );

// Add the StagingTransactionDetails to the context.
context.StagingTransactionDetails = transactionDetails;

Properties

Name Type Description
Versions List<Id> All the leaf staging detail records under the specified versions will be used to create Revenue Recognition Transactions. (Optional)
Groupings List<Id> All the leaf staging detail records under the specified groupings will be used to create Revenue Recognition Transactions. (Optional)
Summaries List<Id> All the leaf staging detail records under the specified summaries will be used to create Revenue Recognition Transactions. (Optional)
Details List<Id> All the staging detail records specified will be used to create Revenue Recognition Transactions. (Optional)
ExcludedSummaries List<Id> All the detail records under the specified summaries will be excluded from the process, even if they are included in one of the lists above. (Optional)
ExcludedDetails List<Id> All the detail records specified will be excluded from the process, even if they are included in one of the lists above. (Optional)
StagingTransactionDetails List<ffrr.TransactionService.StagingTransactionDetails> Contains information that will be included on the Revenue Recognition Transaction record and additional options on how the save opration will be performed.

Methods

StagingSaveContext

global StagingSaveContext()

ffrr.TransactionService.StagingTransactionDetails

global class StagingTransactionDetails

Contains information that will be included on the Revenue Recognition Transaction record and additional options on how the save opration will be performed

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.

// Create the StagingTransactionDetails object
ffrr.TransactionService.StagingTransactionDetails details = new ffrr.TransactionService.StagingTransactionDetails();

// Specify the "In Progress" RR Transaction that the new lines will be attached to.
// If left empty a new RR Transaction will be created.
details.TransactionId = [SELECT Id FROM ffrr__RevenueRecognitionTransaction__c WHERE ffrr__Status__c = 'In Progress' LIMIT 1][0].Id;

// Specify the Version of the staging records that this transaction is for.
// The period is used from the service to retrieve information about the currency,
// the group name and the recognition date that will be recorded on the RR Transaction.
details.Version = [SELECT Id FROM ffrr__StagingVersion__c WHERE ffrr__GroupName__c = 'Project__c' LIMIT 1][0].Id;

// Set the period information
ffrr__RecognitionPeriod__c period = [Select Id, Name FROM ffrr__RecognitionPeriod__c WHERE ffrr__RecognitionYear__r.Name = '2016' LIMIT 1];
details.PeriodName = period.Name;
details.PeriodId = period.Id;

// Set the description
details.Description = 'February Time Cards';

// Set the Legislation Type (Optional)
details.legislationType = 'ASC 605';

// Set whether or not to commit the RR Transaction after creating it.
// If not set will be defaulted to FALSE.
details.CommitTransaction = true;

// Set whether or not RRT lines for the same records on existing RR Transactions
// should replace the existing RRT lines.
// When set to REPLACE the existing RRT lines are removed and the new lines are created,
// when set to IGNORE the existing RRT lines are created and the new ones are ignored.
// If not set it will be defaulted to ffrr.TransactionService.LineAction.REPLACE.
details.LineAction = ffrr.TransactionService.LineAction.IGNORE;

Properties

Name Type Description
TransactionId Id Specify the Revenue Recognition Transaction to append to
Version Id Used by the process to group the staging detail records by version. A new Revenue Recognition Transaction (RRT) is created for each version specified. Also used to retrieve additional information that will be added on the RRT, such as Currency Name, Group Name and Recognition Date.
PeriodName String The period name to set on the transaction. Only required if the period validation is disabled. @see RecognitionPeriod__c, RevenueRecognitionSettings__c.DisablePeriodValidation__c, CustomSettings.isPeriodValidationDisabled()
PeriodId Id The id of the period the transaction belongs to. Only required if period validation is enabled. @see RecognitionPeriod__c, RevenueRecognitionSettings__c.DisablePeriodValidation__c, CustomSettings.isPeriodValidationDisabled()
Description String Description of the transaction.
CommitTransaction Boolean Whether or not to commit the Revenue Recognition Transaction after creating it
LineAction ffrr.TransactionService.LineAction Whether to remove lines for the same record from other transactions or ignore this line if a duplicate on another transaction exists and dont create it on the new transaction. @see TransactionService.LineAction
LegislationType String The Revenue Recognition Transaction's Legislation Type.

Methods

StagingTransactionDetails

global StagingTransactionDetails()

ffrr.TransactionService.StagingSaveOptions

global class StagingSaveOptions

Options to specify how the save operation will be performed.

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.

// Create the StagingSaveOptions object
ffrr.TransactionService.StagingSaveOptions options = new ffrr.TransactionService.StagingSaveOptions();

// Set the type of the Apex Transactions to be performed.
// If not set the Apex Transaction Type will be defaulted to CommonService.ApexTransactionType.SYNCHRONOUS
options.TransactionType = ffrr.CommonService.ApexTransactionType.ASYNCHRONOUS;

Properties

Name Type Description
TransactionType CommonService.ApexTransactionType The type of the Apex Transaction that will be performed.

Methods

StagingSaveOptions

global StagingSaveOptions()

ffrr.TransactionService.StagingSaveResult

global class StagingSaveResult

The data resulting from the Save operation

Properties

Name Type Description
AsyncJob Id The Id of the Async Job if an Asynchronous Apex transaction was executed
CreatedTransactionsByVersion Map<Id, List<Id>> The Ids of the created Revenue Recognition Transactions keyed by the version (see StagingTransactionDetails)

Methods

StagingSaveResult

global StagingSaveResult()

© Copyright 2009–2018 FinancialForce.com, inc. Confidential – all rights reserved. Various trademarks held by their respective owners.