ffrr.CalculationServiceglobal with sharing class CalculationService EnumsLineTypeIndicates the type of revenue recognition display record.
Methods
calculateDeliverableglobal static ffrr.CalculationService.Calculation calculateDeliverable(Decimal totalRevenue, Decimal prevRecognized) Calculates revenue for a Deliverable recognition method using the supplied total revenue and previously recognized values. Input Parameters
Return ValueThis 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); calculateEqualSplitglobal static ffrr.CalculationService.Calculation calculateEqualSplit(Decimal totalRevenue, Decimal prevRecognized, Date startDate, Date endDate, Date recognitionDate) Calculates revenue for an Equal Split recognition method and a calculation type of Months using the supplied values. The results are calculated on whole months. Input Parameters
Return ValueThis 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); calculateEqualSplit445global static ffrr.CalculationService.Calculation calculateEqualSplit445(Decimal totalRevenue, Decimal prevRecognized, Date startDate, Date endDate, Date recognitionDate) Calculates revenue for an Equal Split recognition method 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
Return ValueThis 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); calculateEqualSplitDaysglobal static ffrr.CalculationService.Calculation calculateEqualSplitDays(Decimal totalRevenue, Decimal prevRecognized, Date startDate, Date endDate, Date recognitionDate) Calculates revenue for an Equal Split recognition method 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
Return ValueThis 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); calculateEqualSplitMonthsPartPeriodsglobal static ffrr.CalculationService.Calculation calculateEqualSplitMonthsPartPeriods(Decimal totalRevenue, Decimal prevRecognized, Date startDate, Date endDate, Date recognitionDate) Calculates revenue for an Equal Split recognition method 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
Return ValueThis 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); calculateEqualSplitMonthsPartPeriodsWithProratedPartPeriodsglobal static ffrr.CalculationService.Calculation calculateEqualSplitMonthsPartPeriodsWithProratedPartPeriods(Decimal totalRevenue, Decimal prevRecognized, Date startDate, Date endDate, Date recognitionDate) Calculates revenue for an Equal Split Months / Actual Days in Part Periods recognition method and a calculation type of Months / Actual Days in Part Periods using the supplied values. The results are calculated using both whole and part months/periods. Input Parameters
Return ValueThis 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(2021, 01, 16); Date endDate = Date.newInstance(2021, 09, 05); Date recognitionDate = Date.newInstance(2021, 01, 31); //Actually call the calculateEqualSplitMonthsPartPeriodsWithProratedPartPeriods method ffrr.CalculationService.Calculation revenueRecord = ffrr.CalculationService.calculateEqualSplitMonthsPartPeriodsWithProratedPartPeriods(1000.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); calculatePercentageCompleteglobal static ffrr.CalculationService.Calculation calculatePercentageComplete(Decimal totalRevenue, Decimal prevRecognized, Decimal percentageComplete) Calculates revenue for a % Complete recognition method using the supplied values. The results are calculated as a percentage of the total revenue. Input Parameters
Return ValueThis 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); calculateRevenueglobal 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
Return ValueThis 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 Recognition Settings, Recognition 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 we are using an ffrr__PerformanceObligation__c record which is //correctly connected to a valid Template. You can put any source record here. //The item that we'll be calculating revenue for. You would use your SObject here. SObject mySourceObject = [ SELECT Id, Name, ffrr__ffrrTemplate__c, ffrr__StartDate__c, ffrr__EndDate__c, ffrr__Revenue__c FROM ffrr__PerformanceObligation__c LIMIT 1 ]; //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 and any required fields based on that template. //For example, if the recognition 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); retrieveRecordDetailsglobal 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
Return ValueThis 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 Recognition Settings, Recognition 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); retrieveRecordDetailsglobal 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
Return ValueThis 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 Recognition Settings, Recognition 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 Forecast) ffrr.CalculationService.Record recordDetails = ffrr.CalculationService.retrieveRecordDetails(recordID, ffrr.ViewService.ViewType.FORECAST); //Output the data that was returned system.debug('RecordDetails: ' + recordDetails); ffrr.CalculationService.Calculationglobal virtual with sharing 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
MethodsCalculationglobal Calculation() ffrr.CalculationService.CalculationPartglobal virtual with sharing class CalculationPart Contains the results of a revenue recognition calculation for Cost or Revenue. 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
ffrr.CalculationService.CalculationResultglobal with sharing class CalculationResult extends ViewService.Reference This class extends ffrr.ViewService.Reference Properties
MethodsCalculationResultglobal CalculationResult() ffrr.CalculationService.LineDetailglobal with sharing class LineDetail extends Calculation Deprecated: 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, recognition 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 recognition 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
ffrr.CalculationService.Recordglobal with sharing class Record extends ViewService.Reference Contains the required details of a source record, based on the recognition settings and template associated with 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
ffrr.CalculationService.Templateglobal with sharing 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 Recognition 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
MethodsTemplateglobal 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 recognition 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'; |