Revenue Management API Developer Reference

ffrr.CalculationService

global with sharing class CalculationService

Enums

LineType

Indicates the type of revenue recognition display record.

Value Description
Detail A detail record.
Summary A summary record.

Methods

retrieveRecordDetails

global static ffrr.CalculationService.Record retrieveRecordDetails(Id recordId)

Retrieves the detail of the specified record. The returned data will include the values used in calculations and high level details of the record.

Input Parameters

Name Type Description
recordId Id The record's ID.

Return Value

This service returns a ffrr.CalculationService.Record object.

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 retrieveRecordDetails method and
//therefore relies on there being data within the system (if no data is available,
//no data will be retrieved). Given the nature of this sample, setting the ID of the
//record to be retrieved isn't possible. If you wish to fully test the sample code
//you will need to configure your Settings, Templates etc. and populate recordID
//with the ID of one of your data records
ID recordID = null;

//Call the method
ffrr.CalculationService.Record recordDetails = ffrr.CalculationService.retrieveRecordDetails(recordID);

//Output the data that was returned
system.debug('RecordDetails: ' + recordDetails);

retrieveRecordDetails

global static ffrr.CalculationService.Record retrieveRecordDetails(Id recordId, ffrr.ViewService.ViewType viewType)

Retrieves the detail of the specified record. The returned data will include the values used in calculations and high level details of the record.

Input Parameters

Name Type Description
recordId Id The record's ID.
viewType ffrr.ViewService.ViewType The record's type.

Return Value

This service returns a ffrr.CalculationService.Record object.

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 retrieveRecordDetails method and 
//therefore relies on there being data within the system (if no data is available,
//no data will be retrieved). Given the nature of this sample, setting the ID of the
//record to be retrieved isn't possible. If you wish to fully test the sample code
//you will need to configure your Settings, Templates etc. and populate recordID
//with the ID of one of your data records. The View Type determines the type ( e.g. Actual, Forecast) of the records
//to be retrieved.
ID recordID = null;

//Call the method (retrieve details for a record of type Foreacast)
ffrr.CalculationService.Record recordDetails = ffrr.CalculationService.retrieveRecordDetails(recordID, ffrr.ViewService.ViewType.FORECAST);

//Output the data that was returned
system.debug('RecordDetails: ' + recordDetails);

retrieveLines

global static List<ffrr.CalculationService.LineDetail> retrieveLines(Id parentID, Integer parentLevel, ffrr.ViewService.Tab filters)

Gets the detail lines when drilling into a summary item on the Recognize Revenue page for the specified parent item and applying the supplied filters. The returned data will include both detail and summary items (which may then be used to drill deeper into the available data).

Input Parameters

Name Type Description
parentID Id ID of item being expanded.
parentLevel Integer Settings level of item being expanded. For primary level items use 0 or null.
filters ffrr.ViewService.Tab The filters to apply.

Return Value

This service returns a list of ffrr.CalculationService.LineDetail objects.

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 retrieveLines method and therefore
//relies on there being data within the system (if no data is available, no data
//will be retrieved). If you wish to add Settings, Templates, Recognition Years
//and Periods, and the corresponding data items then the results that are returned
//will alter and, depending on the data, demonstrate drilling down into data

//Setup the recognition date that we'll be using
Date recognitionDate = Date.newInstance(2013, 01, 05);

//Setup the items that we'll be filtering by. For the purposes of this sample we
//won't add any filters
ffrr.ViewService.Tab filters = new ffrr.ViewService.Tab();
ffrr.ViewService.TabFilter tabFilter = new ffrr.ViewService.TabFilter();

if (UserInfo.isMultiCurrencyOrganization())                  //If this is a multi-currency org...
{
    tabFilter.currencyName = UserInfo.getDefaultCurrency();      //...set the currency filter
}

tabFilter.recognitionDate = recognitionDate;

filters.tabFilter = tabFilter;

//Note: The objectType is the object type of the group/tab being queried - adjust as necessary
filters.objectType = Opportunity.getSObjectType();


//Extract the top level items (e.g. projects)
List<ffrr.CalculationService.LineDetail> displayLines = ffrr.CalculationService.retrieveLines(null, null, filters);
ID drillDownID = null;

//Output how many items we retrieved
system.debug('Returned Lines: ' + displayLines.Size());

//Output each of the lines that we retrieved
for (ffrr.CalculationService.LineDetail displayLine : displayLines)
{
    system.debug('displayLine (Root): ' + displayLine);

    //To demonstrate drilling down into data, see if this is a Summary line (i.e. something that
    //that we *can* drill into) and record the line's ID
    if (displayLine.lineType == ffrr.CalculationService.LineType.SUMMARY)
    {
        drillDownID = displayLine.ID;
    }
}

//Note: The following section of code demonstrates how to drill into a summary item. It will only
//execute if we identified something to drill into though in the above loop
if (drillDownID != null)    //Do we have a line to drill into?
{                               //Yes - Try to drill down into it
    displayLines = ffrr.CalculationService.retrieveLines(drillDownID, 1, filters);

    //Output each of the child lines that we retrieved
    for (ffrr.CalculationService.LineDetail displayLine : displayLines)
    {
        system.debug('displayLine (Child): ' + displayLine);
    }
}

loadLines

global static Id loadLines(Schema.Sobjecttype groupName, Date recognitionDate)

Updates the staging table data for the specified group and current user at the recognition date. The loadLines method does not remove any existing data from the staging tables, instead overwriting and adding as necessary. Due to the potential volume of data involved, the actual loading is handled via a batch job and therefore the time involved will depend on factors such as data volume, server load and network traffic.

Input Parameters

Name Type Description
groupName Schema.Sobjecttype Name of the group.
recognitionDate Date Date to generate data for.

Return Value

This service returns an ID object.

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.

//Setup the recognition date that we'll be using
Date recognitionDate = Date.newInstance(2013, 01, 05);

//Call the method to populate/update the Revenue Recognition Staging tables
ID loadBatchID = ffrr.CalculationService.loadLines(Opportunity.SObjectType, recognitionDate);

deleteLines

global static Id deleteLines(Schema.SObjectType groupName, Boolean loadLines, Date recognitionDate)

Deletes data for a specific group from the staging tables, optionally repopulating the tables afterwards for the specific group using the supplied recognition date. Due to the potential volume of data involved, the actual deletion (and optional repopulation) is handled via a batch job and therefore the time involved will depend on factors such as data volume, server load and network traffic.

Input Parameters

Name Type Description
groupName Schema.SObjectType Name of the recognition group to delete and optionally repopulate.
loadLines Boolean True = Repopulate tables after deletion. False = Leave empty.
recognitionDate Date Recognition date to repopulate records.

Return Value

This service returns an ID object.

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.

//Setup the recognition date that we'll be using
Date recognitionDate = Date.newInstance(2013, 01, 05);

//Note: This sample code shows how to clear the Recognition Staging Tables of data
//for the Opportunity group and then repopulate the table. To clear and *not*
//repopulate the tables, pass false as the second parameter.
ID deleteBatchID = ffrr.CalculationService.deleteLines(Opportunity.SObjectType, true, recognitionDate);

deleteAllLines

global static Id deleteAllLines()

Deletes all staging table data created by the current user regardless of recognition date or group. Due to the potential volume of data involved, the actual deletion is handled via a batch job and therefore the time involved will depend on factors such as data volume, server load and network traffic.

Return Value

This service returns an ID object.

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.

//Call the method
ID deleteBatchID = ffrr.CalculationService.deleteAllLines();

calculateRevenue

global static ffrr.CalculationService.Calculation calculateRevenue(SObject record, Date recognitionDate, String currencyFilter)

Calculates revenue based on the template associated with the supplied record. The method will automatically extract the required values based on the record's template, determine the calculation type involved, validate any needed data and perform the calculation.

Input Parameters

Name Type Description
record SObject The item to calculate revenue for.
recognitionDate Date Date on which to base calculations.
currencyFilter String Currency ISO code to use in the calculation.

Return Value

This service returns a ffrr.CalculationService.Calculation object.

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 requires that a complete set of Settings, Templates, and Recognition
//Years and Periods (covering the year 2013) are available within the system. For the
//purposes of this example it is assumed that a record has been created which is
//correctly connected to a valid Template.

SObject mySourceObject = null;        //The item that we'll be calculating revenue for

//Note: The mySourceObject needs to be populated at this point. *How* it is populated,
//naturally, depends on the object type etc. but the extracted record must include the
//ffrrTemplate__c field, any required fields based on that template.
//For example, if the template is of type '% Complete', then the 'Complete' field must be included

//Setup the recognition date that we'll be using
Date recognitionDate = Date.newInstance(2013, 01, 05);

//Call the method
ffrr.CalculationService.Calculation revenueRecord = ffrr.CalculationService.calculateRevenue(mySourceObject, recognitionDate, 'USD');

//Output the results that came back
System.debug('RecognizedToDate: ' + revenueRecord.recognizedToDate);
System.debug('PreviouslyRecognized: ' + revenueRecord.previouslyRecognized);
System.debug('ToRecognizeThisPeriod: ' + revenueRecord.toRecognizeThisPeriod);
System.debug('TotalRevenue: ' + revenueRecord.totalRevenue);
System.debug('CalculatedTotalRevenue: ' + revenueRecord.calculatedTotalRevenue);
System.debug('Errors: ' + revenueRecord.errors);

calculateEqualSplit445

global static ffrr.CalculationService.Calculation calculateEqualSplit445(decimal totalRevenue, decimal prevRecognized, Date startDate, Date endDate, Date recognitionDate)

Calculates revenue for an Equal Split template type and a 445 calculation type using the supplied values. The results are calculated using the 445 recognition periods and years defined in the system.

Input Parameters

Name Type Description
totalRevenue decimal Total revenue for the calculation.
prevRecognized decimal Amount previously recognized.
startDate Date Start date of the item.
endDate Date End date of the item.
recognitionDate Date Date on which to base calculations.

Return Value

This service returns a ffrr.CalculationService.Calculation object.

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.

//This sample requires that Revenue Recognition years and periods exist within
//the system as, without them, calculations that rely on periods cannot be performed.

//Setup the dates involved
Date startDate = Date.newInstance(2013, 01, 01);
Date endDate = Date.newInstance(2013, 12, 31);
Date recognitionDate = Date.newInstance(2013, 01, 05);

//Actually call the calculateEqualSplit445 method
ffrr.CalculationService.Calculation revenueRecord = ffrr.CalculationService.calculateEqualSplit445(1200.00, 50.00, startDate, endDate, recognitionDate);

//Output the results that came back
System.debug('RecognizedToDate: ' + revenueRecord.recognizedToDate);
System.debug('PreviouslyRecognized: ' + revenueRecord.previouslyRecognized);
System.debug('ToRecognizeThisPeriod: ' + revenueRecord.toRecognizeThisPeriod);
System.debug('TotalRevenue: ' + revenueRecord.totalRevenue);
System.debug('CalculatedTotalRevenue: ' + revenueRecord.calculatedTotalRevenue);
System.debug('Errors: ' + revenueRecord.errors);

calculateEqualSplitDays

global static ffrr.CalculationService.Calculation calculateEqualSplitDays(decimal totalRevenue, decimal prevRecognized, Date startDate, Date endDate, Date recognitionDate)

Calculates revenue for an Equal Split template type and a calculation type of Days using the supplied values. The results are calculated according to the number of days between the specified start and recognition dates and the mean value per day between the specified start and end dates.

Input Parameters

Name Type Description
totalRevenue decimal Total revenue for the calculation.
prevRecognized decimal Amount previously recognized.
startDate Date Start date of the item.
endDate Date End date of the item.
recognitionDate Date Date on which to base calculations.

Return Value

This service returns a ffrr.CalculationService.Calculation object.

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.

//This sample requires that Revenue Recognition years and periods exist within
//the system as, without them, calculations that rely on periods cannot be performed.

//Setup the dates involved
Date startDate = Date.newInstance(2013, 01, 01);
Date endDate = Date.newInstance(2013, 12, 31);
Date recognitionDate = Date.newInstance(2013, 01, 05);

//Call the method
ffrr.CalculationService.Calculation revenueRecord = ffrr.CalculationService.calculateEqualSplitDays(1200.00, 50.00, startDate, endDate, recognitionDate);

//Output the results that came back
System.debug('RecognizedToDate: ' + revenueRecord.recognizedToDate);
System.debug('PreviouslyRecognized: ' + revenueRecord.previouslyRecognized);
System.debug('ToRecognizeThisPeriod: ' + revenueRecord.toRecognizeThisPeriod);
System.debug('TotalRevenue: ' + revenueRecord.totalRevenue);
System.debug('CalculatedTotalRevenue: ' + revenueRecord.calculatedTotalRevenue);
System.debug('Errors: ' + revenueRecord.errors);

calculateEqualSplitMonthsPartPeriods

global static ffrr.CalculationService.Calculation calculateEqualSplitMonthsPartPeriods(decimal totalRevenue, decimal prevRecognized, Date startDate, Date endDate, Date recognitionDate)

Calculates revenue for an Equal Split template type and a calculation type of Months/Part Periods using the supplied values. The results are calculated using both whole and part months/periods.

Input Parameters

Name Type Description
totalRevenue decimal Total revenue for the calculation.
prevRecognized decimal Amount previously recognized.
startDate Date Start date of the item.
endDate Date End date of the item.
recognitionDate Date Date on which to base calculations.

Return Value

This service returns a ffrr.CalculationService.Calculation object.

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.

//This sample requires that Revenue Recognition years and periods exist within
//the system as, without them, calculations that rely on periods cannot be performed.

//Setup the dates involved
Date startDate = Date.newInstance(2013, 01, 01);
Date endDate = Date.newInstance(2013, 12, 31);
Date recognitionDate = Date.newInstance(2013, 01, 05);

//Actually call the calculateEqualSplitMonthsPartPeriods method
ffrr.CalculationService.Calculation revenueRecord = ffrr.CalculationService.calculateEqualSplitMonthsPartPeriods(1200.00, 50.00, startDate, endDate, recognitionDate);

//Output the results that came back
System.debug('RecognizedToDate: ' + revenueRecord.recognizedToDate);
System.debug('PreviouslyRecognized: ' + revenueRecord.previouslyRecognized);
System.debug('ToRecognizeThisPeriod: ' + revenueRecord.toRecognizeThisPeriod);
System.debug('TotalRevenue: ' + revenueRecord.totalRevenue);
System.debug('CalculatedTotalRevenue: ' + revenueRecord.calculatedTotalRevenue);
System.debug('Errors: ' + revenueRecord.errors);

calculateEqualSplit

global static ffrr.CalculationService.Calculation calculateEqualSplit(decimal totalRevenue, decimal prevRecognized, Date startDate, Date endDate, Date recognitionDate)

Calculates revenue for an Equal Split template type and a calculation type of Months using the supplied values. The results are calculated on whole months.

Input Parameters

Name Type Description
totalRevenue decimal Total revenue for the calculation.
prevRecognized decimal Amount previously recognized.
startDate Date Start date of the item.
endDate Date End date of the item.
recognitionDate Date Date on which to base calculations.

Return Value

This service returns a ffrr.CalculationService.Calculation object.

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.

//Setup the dates involved
Date startDate = Date.newInstance(2013, 01, 01);
Date endDate = Date.newInstance(2013, 12, 31);
Date recognitionDate = Date.newInstance(2013, 01, 05);

//Call the method
ffrr.CalculationService.Calculation revenueRecord = ffrr.CalculationService.calculateEqualSplit(1200.00, 50.00, startDate, endDate, recognitionDate);

//Output the results that came back
System.debug('RecognizedToDate: ' + revenueRecord.recognizedToDate);
System.debug('PreviouslyRecognized: ' + revenueRecord.previouslyRecognized);
System.debug('ToRecognizeThisPeriod: ' + revenueRecord.toRecognizeThisPeriod);
System.debug('TotalRevenue: ' + revenueRecord.totalRevenue);
System.debug('CalculatedTotalRevenue: ' + revenueRecord.calculatedTotalRevenue);
System.debug('Errors: ' + revenueRecord.errors);

calculatePercentageComplete

global static ffrr.CalculationService.Calculation calculatePercentageComplete(decimal totalRevenue, decimal prevRecognized, decimal percentageComplete)

Calculates revenue for a % Complete template type using the supplied values. The results are calculated as a percentage of the total revenue.

Input Parameters

Name Type Description
totalRevenue decimal Total revenue for the calculation.
prevRecognized decimal Amount previously recognized.
percentageComplete decimal Percentage of the item (for example, project or milestone) that is complete.

Return Value

This service returns a ffrr.CalculationService.Calculation object.

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.

//Call the method
ffrr.CalculationService.Calculation revenueRecord = ffrr.CalculationService.calculatePercentageComplete(1200.00, 50.00, 50.00);

//Output the results that came back
System.debug('RecognizedToDate: ' + revenueRecord.recognizedToDate);
System.debug('PreviouslyRecognized: ' + revenueRecord.previouslyRecognized);
System.debug('ToRecognizeThisPeriod: ' + revenueRecord.toRecognizeThisPeriod);
System.debug('TotalRevenue: ' + revenueRecord.totalRevenue);
System.debug('CalculatedTotalRevenue: ' + revenueRecord.calculatedTotalRevenue);
System.debug('Errors: ' + revenueRecord.errors);

calculateDeliverable

global static ffrr.CalculationService.Calculation calculateDeliverable(decimal totalRevenue, decimal prevRecognized)

Calculates revenue for a Deliverable template type using the supplied total revenue and previously recognized values.

Input Parameters

Name Type Description
totalRevenue decimal Total revenue for the calculation.
prevRecognized decimal Amount previously recognized.

Return Value

This service returns a ffrr.CalculationService.Calculation object.

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.

//Call the method
ffrr.CalculationService.Calculation revenueRecord = ffrr.CalculationService.calculateDeliverable(2000.00, 250.00);

//Output the results that came back
System.debug('RecognizedToDate: ' + revenueRecord.recognizedToDate);
System.debug('PreviouslyRecognized: ' + revenueRecord.previouslyRecognized);
System.debug('ToRecognizeThisPeriod: ' + revenueRecord.toRecognizeThisPeriod);
System.debug('TotalRevenue: ' + revenueRecord.totalRevenue);
System.debug('CalculatedTotalRevenue: ' + revenueRecord.calculatedTotalRevenue);
System.debug('Errors: ' + revenueRecord.errors);

ffrr.CalculationService.LineDetail

global class LineDetail extends Calculation

Contains a complete set of line or summary data as used by the revenue recognition user interface. The structure contains everything needed to recognize the row data.

This class extends ffrr.CalculationService.Calculation

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 account, template and parent/item reference data that we'll need
//Create the reference to the account
ffrr.ViewService.Reference sampleAccount = new ffrr.ViewService.Reference();
sampleAccount.id = 'a1ga00000111sg6';
sampleAccount.name = 'My Account';

//Create the template
ffrr.CalculationService.Template sampleTemplate = new ffrr.CalculationService.Template();
sampleTemplate.id = 'a0ba00000512cc6';
sampleTemplate.name = 'TimeCard Template';
sampleTemplate.calculationType = 'Months / Part Periods';
sampleTemplate.revenueBasis = 'Total Revenue';
sampleTemplate.templateType = 'Equal Split';

//Create the parent/item references
ffrr.ViewService.Reference projectReference = new ffrr.ViewService.Reference();
projectReference.id = 'a0sa00000011op1';
projectReference.name = 'My Project';

ffrr.ViewService.Reference milestoneReference = new ffrr.ViewService.Reference();
milestoneReference.id = 'a0ga00000026abx';
milestoneReference.name = 'My Milestone';

ffrr.ViewService.Reference timecardReference = new ffrr.ViewService.Reference();
timecardReference.id = 'a0va00000059tb8';
timecardReference.name = 'My TimeCard';


//Create the LineDetail
ffrr.CalculationService.LineDetail ldSample = new ffrr.CalculationService.LineDetail();

//Populate the fields inherited from ffrr.ViewService.Reference
ldSample.id = 'a0va00000059tb8';
ldSample.name = 'My TimeCard';

//Populate the fields inherited from ffrr.CalculationService.Calculation
ldSample.errors = new List<String>();

ldSample.recognizedToDate = 1222.95;
ldSample.toRecognizeThisPeriod = 75.25;
ldSample.totalRevenue = 2000.00;

//Populate the fields specific to ffrr.CalculationService.LineDetail
ldSample.account = sampleAccount;
ldSample.stagingRecordID = 'a1za00001024zt2';
ldSample.template = sampleTemplate;

//Specify what type of line this is (detail or summary)
ldSample.lineType = ffrr.CalculationService.LineType.DETAIL;

//Create a list to hold the references to the object and all of its parents
ldSample.parentPath = new List<ffrr.ViewService.Reference>();

//Add the reference to the object and all of its parents
ldSample.parentPath.add(projectReference);
ldSample.parentPath.add(milestoneReference);
ldSample.parentPath.add(timecardReference);

Properties

Name Type Description
parentPath List<ffrr.ViewService.Reference> List of ids and names of the parent items.
account ffrr.ViewService.Reference Account name and ID.
stagingRecordId Id ID of the record in the staging table.
lineType ffrr.CalculationService.LineType The type of record.
template ffrr.CalculationService.Template The template.
totalChildren Integer The total number of child items (at any level) beneath this line item.
totalDirectChildren Integer The total number of children directly beneath this item.
itemHyperlink String The source record ID used to construct the hyperlink in the user interface.
linkRecordId Id The record ID used to create the hyperlink in the user interface.

ffrr.CalculationService.Record

global class Record extends ViewService.Reference

Contains the required details of a source record, based on the settings record and template associated it.

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 filters that apply to this item
//Create a filter for the billing country
ffrr.ViewService.TabSelectorFilter tsfBillingCountry = new ffrr.ViewService.TabSelectorFilter();
tsfBillingCountry.field = Account.BillingCountry;
tsfBillingCountry.values = new List<String>{'UK', 'US'};

//Create a filter for the industry
ffrr.ViewService.TabSelectorFilter tsfIndustry = new ffrr.ViewService.TabSelectorFilter();
tsfIndustry.field = Account.Industry;
tsfIndustry.values = new List<String>{'Insurance', 'Finance'};


//Create the Record
ffrr.CalculationService.Record rSample = new ffrr.CalculationService.Record();

//Populate the fields inherited from ffrr.ViewService.Reference
rSample.id = 'a0va00000059tb8';
rSample.name = 'My Account';

//Populate the fields specific to ffrr.CalculationService.Record
rSample.delivered = 'True';
rSample.description = 'Time card details for the start of the first quarter';

//Specify the start and end dates of the item
rSample.startDate = date.newInstance(2013, 1, 1);
rSample.endDate = date.newInstance(2013, 3, 31);

//Specify the values that we want to return for this item
rSample.percentageComplete = 25;
rSample.rate = 12.50;
rSample.totalUnits = 500;
rSample.vsoePercent = 80;
rSample.vsoeRate = 12.50;

//Create a list to hold any filters for this item
rSample.filters = new List<ffrr.ViewService.TabSelectorFilter>();

//Add the filters for this item
rSample.filters.add(tsfBillingCountry);
rSample.filters.add(tsfIndustry);

Properties

Name Type Description
startDate Date Value of the mapped field that contains the start date to use in the calculations.
endDate Date Value of the mapped field that contains the end date to use in calculations.
percentageComplete decimal Value of the mapped field that contains the percentage complete to use in calculations.
delivered String Value of the mapped field that indicates whether the item is completed or delivered.
description String Value of the mapped field that contains the item's description.
totalUnits decimal Value of the mapped field that contains the total number of units to use in calculations.
rate decimal Value of the mapped field that contains the rate to use in the calculations.
vsoeRate decimal Value of the mapped field that contains the VSOE rate to use in calculations.
vsoePercent decimal Value of the mapped field that contains the VSOE percentage to use in calculations.
filters List<ffrr.ViewService.TabSelectorFilter> List of any filters that have been set up against the item.

ffrr.CalculationService.Calculation

global virtual class Calculation extends ViewService.Reference

Contains the results of a revenue recognition calculation.

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 Calculation
ffrr.CalculationService.Calculation calc = new ffrr.CalculationService.Calculation();

//Populate the fields inherited from ffrr.ViewService.Reference
calc.id = 'a0va00000059tb8';
calc.name = 'My Calculation';

//Populate the fields from specific to ffrr.CalculationService.Calculation
calc.previouslyRecognized = 112.78;
calc.recognizedToDate = 1222.95;
calc.toRecognizeThisPeriod = 75.25;
calc.totalRevenue = 2000.00;
calc.calculatedTotalRevenue = 1500.00;

//Create a list to hold any errors for the calculation
calc.errors = new List<String>();

//Add the errors to the error list
calc.errors.add('Missing year/period');
calc.errors.add('Total recognized cannot be greater than total revenue');

Properties

Name Type Description
totalRevenue decimal Total revenue for the calculation.
calculatedTotalRevenue Decimal The modified total revenue used to perform the calculation, based on the Revenue Basis. If no Revenue Basis is specified this matches Total Revenue.
previouslyRecognized decimal Amount previously recognized.
toRecognizeThisPeriod decimal Amount to recognize this period.
recognizedToDate decimal Total amount recognized to date.
errors List<String> List of errors returned by the process.

ffrr.CalculationService.Template

global class Template extends ViewService.Reference

Contains the details of the calculation to be applied to the source data.

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 Template
ffrr.CalculationService.Template tmpSample = new ffrr.CalculationService.Template();

//Populate the fields inherited from ffrr.ViewService.Reference
tmpSample.id = 'a0ba00000512cc6';
tmpSample.name = 'TimeCard Template';

//Populate the fields specific to ffrr.CalculationService.Template
tmpSample.calculationType = 'Days';
tmpSample.revenueBasis = 'Total Revenue';
tmpSample.templateType = 'Equal Split';

Properties

Name Type Description
templateType String The type of template.
revenueBasis String The revenue basis.
calculationType String The type of calculation.

Methods

Template

global Template()

Contains the information of a template.

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 template
ffrr.CalculationService.Template tSample = new ffrr.CalculationService.Template();

//Populate the fields inherited from ffrr.ViewService.Reference
tSample.id = 'a0va00000059tb8';
tSample.name = 'My Template';

//Populate the fields specific for the ffrr.CalculationService.Template
tSample.templateType = 'Equal split';
tSample.revenueBasis = 'Total Revenue';
tSample.calculationType = 'Months';
© Copyright 2009–2017 FinancialForce.com, inc. All rights reserved. Various trademarks held by their respective owners.