Revenue Management API Developer Reference

ffrr.TransactionService

global with sharing class TransactionService

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" recognition transaction.

Status

The status of the 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

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 Recognition Settings, Recognition 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 Recognition Transactions.
ffrr.TransactionService.CommitResult result = ffrr.TransactionService.bulkCommit( transactionIds );

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 Recognition Settings, Recognition 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 Recognition Transactions.
Id commitBatchId = ffrr.TransactionService.commitTransactions( transactionIds );

discard

global static void discard(Set<Id> transactionIds)

Discards one or more Recognition Transactions.

Input Parameters

Name Type Description
transactionIds Set<Id> A Set of "Committed" transaction Ids, passing anything else including empty or null values will throw an exception.

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 discard method for previously
// committed transactions, and therefore relies on there being data within the system.

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

//Query the database and retrieve all committed transactions.
List<ffrr__RevenueRecognitionTransaction__c> transactionList = [SELECT Id FROM ffrr__RevenueRecognitionTransaction__c WHERE ffrr__Status__c = 'Committed'];

//Create a set of Ids to be used for storing committed transaction Ids.
Set<Id> committedTransactionIds = new Set<Id>();

//Pass in the transaction Ids from the List to the Set
for (ffrr__RevenueRecognitionTransaction__c rrt : transactionList)
{
    committedTransactionIds.add(rrt.Id);
}

//Call the method passing in the committed transaction Ids
ffrr.TransactionService.discard(committedTransactionIds);

discardAsync

global static Id discardAsync(Set<Id> transactionIds)

Discards one or more Recognition Transactions using an asynchronous process.

Input Parameters

Name Type Description
transactionIds Set<Id> A Set of "Committed" transaction Ids, passing anything else including empty or null values will throw an exception.

Return Value

Id of the executing ffrr__RevenueManagementBackgroundProcess__c record.

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 discard method for previously
// committed transactions, and therefore relies on there being data within the system.

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

// Query the database and retrieve all committed transactions.
List<ffrr__RevenueRecognitionTransaction__c> transactionList = [SELECT Id FROM ffrr__RevenueRecognitionTransaction__c WHERE ffrr__Status__c = 'Committed'];

// Create a set of Ids to be used for storing committed transaction Ids.
Set<Id> committedTransactionIds = new Set<Id>();

// Pass in the transaction Ids from the List to the Set
for (ffrr__RevenueRecognitionTransaction__c rrt : transactionList)
{
    committedTransactionIds.add(rrt.Id);
}

// Call the method passing in the committed transaction Ids
// Get the Id of the executing ffrr__RevenueManagementBackgroundProcess__c discarding the committed transactions
Id processRunId = ffrr.TransactionService.discardAsync(committedTransactionIds);

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 Id save(ffrr.TransactionService.HeaderDetails headerDetails)

Saves a 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, Recognition Settings, Recognition 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.GroupingValue = 'North America';
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.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.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 Recognition Transaction.
Id saveBatchId = ffrr.TransactionService.save( headerDetails );

save

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

Creates 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 Recognition Transactions. 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 Recognition Transactions and Recognition Transaction Lines.

Return Value

The StagingSaveResult containing either the Id of the AsyncJob if the process has been executed asynchronously or the created Recognition 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 Recognition 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 Recognition 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;
version1Transaction.CreateGroupedTransactions = true;

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;
version1Transaction.CreateGroupedTransactions = false;

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 asyncJob = result.AsyncJob;

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, Recognition Settings, Recognition 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.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.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 Recognition Transaction.
ffrr.TransactionService.SaveResult result = ffrr.TransactionService.bulkSave( headers );

summarize

global static void summarize(Set<Id> transactionIds)

Summarizes Recognition Transaction Lines into Recognition Transaction Summary records. Revenue and cost amounts are summarized by GLA Type, GLA Revenue or GLA Cost, and any fields included in the Summarization Fields field set on the Recognition Transaction Line object. If a transaction has both revenue and cost amounts, at least 4 summary records will be created (2 Income Statement and 2 Balance Sheet). NOTE: All fields included in the RTL Summarization Fields field set must exist on the Recognition Transaction Summary.

Input Parameters

Name Type Description
transactionIds Set<Id> A Set of "Committed" transaction Ids, passing anything else including empty or null values will throw an exception.

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 summarize method for previously
// committed transactions, and therefore relies on there being data within the system.

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

// Query the database and retrieve all committed transactions.
List<ffrr__RevenueRecognitionTransaction__c> transactionList = [SELECT Id FROM ffrr__RevenueRecognitionTransaction__c WHERE ffrr__Status__c = 'Committed'];

// Create a set of Ids to be used for storing committed transaction Ids.
Set<Id> committedTransactionIds = new Map<Id, SObject>(transactionList).keySet();

// Call the method passing in the committed transaction Ids
ffrr.TransactionService.summarize(committedTransactionIds);

summarizeAsync

global static Id summarizeAsync(Set<Id> transactionIds)

Summarizes Recognition Transaction Lines into Recognition Transaction Summary records. Revenue and cost amounts are summarized by GLA Type, GLA Revenue or GLA Cost, and any fields included in the Summarization Fields field set on the Recognition Transaction Line object. If a transaction has both revenue and cost amounts, at least 4 summary records will be created (2 Income Statement and 2 Balance Sheet). NOTE: All fields included in the RTL Summarization Fields field set must exist on the Recognition Transaction Summary. The total number of Recognition Transaction Lines must not exceed 50000 per batch, and a maximum of 10000 summary lines can be created per batch.

Input Parameters

Name Type Description
transactionIds Set<Id> A Set of "Committed" transaction Ids, passing anything else including empty or null values will throw an exception.

Return Value

Returns the ID of the Batch Apex 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.

// Note: This sample demonstrates how to call the summarize method for previously
// committed transactions, and therefore relies on there being data within the system.

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

// Query the database and retrieve all committed transactions.
List<ffrr__RevenueRecognitionTransaction__c> transactionList = [SELECT Id FROM ffrr__RevenueRecognitionTransaction__c WHERE ffrr__Status__c = 'Committed'];

// Create a set of Ids to be used for storing committed transaction Ids.
Set<Id> committedTransactionIds = new Map<Id, SObject>(transactionList).keySet();

// Call the method passing in the committed transaction Ids
ffrr.TransactionService.summarizeAsync(committedTransactionIds);

ffrr.TransactionService.CommitResult

global with sharing 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.HeaderDetails

global with sharing 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>{'a0va00000059tb8'}; //Add the Time Card 1 Id

// 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 Recognition 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 Recognition Transaction's description
sampleHeaderDetails.description= 'February Time Cards';

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

// Specify the value that this Recognition Transaction was grouped by.
sampleHeaderDetails.GroupingValue = 'North America';

// 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 Recognition 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.
description String A description to add to the transaction.
commitTransaction Boolean Whether to also commit the transaction after creating it.
currencyName String The currency for the transaction.
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 recognition settings where the root primary recognition setting has the same Schema.SObjectType as defined in this ffrr.TransactionService.HeaderDetails.
GroupingValue String The value to put into the ffrr__GroupedBy__c field.
legislationType String The Recognition Transaction's Legislation Type.
lineAction ffrr.TransactionService.LineAction Action to be taken if existing "In Progress" transaction lines are found for the same source object and period.
lineDetailsMap Map<Id, ffrr.TransactionService.LineDataToSave> The lines to be created and added to this transaction. The key in this map should be the id of the record being recognised.
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.
periodId Id The Id of the ffrr__RecognitionPeriod__c. Only required if period validation is enabled.
period String The period name to set on the transaction. Only required if period validation is disabled.
recognitionDate Date The RecognitionDate for the transaction. This is used when performing calculations and checking if the value to recognize is correct.

Methods

HeaderDetails

global HeaderDetails()

If set to true when replacing lines any amount on the old line will be transferred 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 RTs/RTLs

ffrr.TransactionService.LineDataToSave

global with sharing class LineDataToSave

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

This class contains deprecated items.

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 the Id of the source record to be recognised (Time Card 1 Id).
sampleLineData.recordIdList = new List<Id>{'a0va00000059tb8'};

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

//Optional fields
//Specify the home currency and rate
ffrr.CommonService.CurrencyType homeCurrency = new ffrr.CommonService.CurrencyType();
homeCurrency.ISOCode = 'USD';
homeCurrency.Rate = 1;
sampleLineData.homeCurrency = homeCurrency;

//Specify the document currency and rate
ffrr.CommonService.CurrencyType documentCurrency = new ffrr.CommonService.CurrencyType();
documentCurrency.ISOCode = 'CAD';
documentCurrency.Rate = 1.2354;
sampleLineData.documentCurrency = documentCurrency;

//Specify the dual currency and rate
ffrr.CommonService.CurrencyType dualCurrency = new ffrr.CommonService.CurrencyType();
dualCurrency.ISOCode = 'AUD';
dualCurrency.Rate = 0.2362;
sampleLineData.dualCurrency = dualCurrency;

Properties

Name Type Description
recordIdList List<Id> The Id of the record to be recognised.
documentCurrency ffrr.CommonService.CurrencyType CurrencyType that the document was reported in. The rate on the documentCurrency currencyType should be the rate of the document currency to the home currency."
Home Value = Document value / Document rate
dualCurrency ffrr.CommonService.CurrencyType CurrencyType to set the document DualType to. The rate on the dualCurrency CurrencyType should be the rate of the home currency to the dual currency.
HomeValue * dualCurrencyRate = DualCurrencyValue
homeCurrency ffrr.CommonService.CurrencyType CurrencyType for the homeCurrency of the org. This is the base currency for all currency conversion calculations. The rate on the homeCurrency currencyType will be ignored
toAmortizeThisPeriod Decimal Amount to amortize this period.
toRecognizeThisPeriod Decimal Amount to recognize this period.

Methods

LineDataToSave

global LineDataToSave()

Deprecated

The following items are deprecated and not supported for use. We recommend that you stop using these items to avoid exceptions.

Properties

Name Type Description Deprecation Details
templateID Id The template Id related to the record to be recognized.

ffrr.TransactionService.SaveResult

global with sharing 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.StagingSaveContext

global with sharing class StagingSaveContext

Contains details required to create 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 Recognition 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 Recognition 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
Details List<Id> All the staging detail records specified will be used to create Recognition Transactions. (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)
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)
Groupings List<Id> All the leaf staging detail records under the specified groupings will be used to create Recognition Transactions. (Optional)
StagingTransactionDetails List<ffrr.TransactionService.StagingTransactionDetails> Contains information that will be included on the Recognition Transaction record and additional options on how the save operation will be performed.
Summaries List<Id> All the leaf staging detail records under the specified summaries will be used to create Recognition Transactions. (Optional)
Versions List<Id> All the leaf staging detail records under the specified versions will be used to create Recognition Transactions. (Optional)

Methods

StagingSaveContext

global StagingSaveContext()

The hash that matches the values in the staging table. Used to query for records in the staging table to include in this save. One context per per primary grouping record will be created. We have agreed that this does not belong on the global contract and we do not want to polluted the global API. This will be moved lower down the code path and be part of the public and not global api.

ffrr.TransactionService.StagingSaveOptions

global with sharing 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 ffrr.CommonService.ApexTransactionType The type of the Apex Transaction that will be performed.

Methods

StagingSaveOptions

global StagingSaveOptions()

ffrr.TransactionService.StagingSaveResult

global with sharing 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 Recognition Transactions keyed by the version (see StagingTransactionDetails)

Methods

StagingSaveResult

global StagingSaveResult()

ffrr.TransactionService.StagingTransactionDetails

global with sharing class StagingTransactionDetails

Contains information that will be included on the Recognition Transaction record and additional options on 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 StagingTransactionDetails object
ffrr.TransactionService.StagingTransactionDetails details = new ffrr.TransactionService.StagingTransactionDetails();

// Specify the "In Progress" Recognition Transaction that the new lines will be attached to.
// If left empty a new Recognition 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 Recognition 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 Transactions to be created by group. For example, if grouping data by company:
// When true, separate transactions will be created per company.
// When false, transactions will contain details for all the companies.
details.CreateGroupedTransactions = true;

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

// Set whether or not RT lines for the same records on existing Recognition Transactions
// should replace the existing RT lines.
// When set to REPLACE the existing RT lines are removed and the new lines are created,
// when set to IGNORE the existing RT 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 Recognition Transaction to append to
CommitTransaction Boolean Whether or not to commit the Recognition Transaction after creating it
CreateGroupedTransactions Boolean Whether the resulting Recognition Transactions are created by group If multiple grouping criteria are applied, transactions are grouped by the first criteria only. For example, if you group by region, company and then account, the resulting transactions are grouped by region only.
Description String Description of the transaction.
LegislationType String The Recognition Transaction's Legislation Type.
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
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()
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()
Version Id Used by the process to group the staging detail records by version. A new Recognition Transaction (RT) is created for each version specified. Also used to retrieve additional information that will be added on the RT, such as Currency Name, Group Name and Recognition Date.

Methods

StagingTransactionDetails

global StagingTransactionDetails()

ffrr.TransactionService.TransactionLine

global with sharing class TransactionLine extends ViewService.Reference

Contains the details of a 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
amount Decimal The revenue recognized.
amountAmortized Decimal The cost recognized.
recognitionCurrency String The currency of the recognition line.
recognitionDate Date Date on which the revenue calculation was based.
status ffrr.TransactionService.Status Status of the transaction.

Methods

TransactionLine

global TransactionLine()

© Copyright 2009–2023 Certinia Inc. All rights reserved. Various trademarks held by their respective owners.