![]() Billing Central API Developer Reference
|
ffbc.ContractsServiceglobal with sharing class ContractsService
This class provides service functionality for Billing Central contracts. EnumsStatusAn enum that represents the valid options for the status of contracts.
TypeAn enum that represents the valid options for the contract type.
RenewalLineDurationOptionAn enum that represents the valid options for the duration of line items when creating a renewal.
Methods
activateglobal static void activate(ffbc.ContractsService.ActivationRequest request) Activates the contracts provided by changing their status to Active and starting an asynchronous process to create the first billing schedules for them. Input Parameters
Exceptions Thrown
loadglobal static List<ffbc.ContractsService.Contract> load(Set<Id> contractIds) Returns all contracts and contract line items based on the Ids of the contract. Input Parameters
Return ValueA list of contracts and their corresponding line items. The line items for a contract will be ordered by their Contract Line Item Number. saveglobal static Set<Id> save(List<ffbc.ContractsService.Contract> contractsToSave) Converts the Contract objects provided into Contract__c SObjects and then inserts or updates them as necessary. This method cannot be used to insert change requests. To insert a change request call saveNewChangeRequest. Input Parameters
Exceptions Thrown
Return ValueThe set of Ids of the inserted/updated Contract__c objects. deleteContractsglobal static void deleteContracts(Set<Id> contractsToDelete) Deletes the contracts with the IDs provided. Input Parameters
calculateTotalValuesThis method has been deprecated and always throws an exception to indicate that it cannot be invoked. global static ffbc.Response calculateTotalValues(Set<Id> contractsToCalculateTotalValue) Input Parameters
Exceptions Thrown
Return ValueNull. calculateFieldsglobal static ffbc.ContractsService.CalculateFieldsResponse calculateFields(ffbc.ContractsService.CalculateFieldsRequest calculateRequest) Calculates the projected value and totals for the specified contracts over their lifetime. The total value fields of the contracts are updated. To achieve this, the SalesPriceOverride__c field is calculated to ensure that the Monthly Recurring Revenue and Annual Recurring Revenue values are correct. Input Parameters
Return ValueA CalculateFieldsResponse containing the errors that occurred for each contract. getContractSummariesForAccountglobal static List<ffbc.ContractsService.ContractSummary> getContractSummariesForAccount(Set<Id> accountIds) Retrieves the contracts associated with the account using the account IDs provided and returns summary wrappers for them. Input Parameters
Return ValueA list of wrappers of the contract summary information for each contract retrieved. getContractSummariesForBillingDocumentRelationglobal static List<ffbc.ContractsService.ContractSummary> getContractSummariesForBillingDocumentRelation(ffbc.ContractsService.ContractSummaryRequest request) Retrieves summaries of contracts that can be associated with billing documents. This only includes contracts with the status Draft, Active or Expired. Input Parameters
Return ValueA list of summaries for the contracts. createChangeRequestglobal static Id createChangeRequest(Id contractId) Creates a change request for the contract ID provided. This creates the change request and returns its ID. All values of custom fields on the active contract are copied to the change request. When a change request is created from a contract, pricing structures on the active contract line items are copied and the copies are applied to the change request line items. Pricing structures on active contract line items are unaffected by changes made to pricing structures on change request line items. Input Parameters
Return ValueThe ID of the change request record created. createChangeRequestObjectglobal static ffbc.ContractsService.Contract createChangeRequestObject(Id contractId) Creates a change request for the contract provided. This copies the contract and returns a populated ffbc.ContractsService.Contract DTO that represents the new change request. This does not insert the new record into the database. The ID properties of the returned contract and its lines are null. When a change request is created from a contract, pricing structures on the active contract line items are copied and the copies are applied to the change request line items. Pricing structures on active contract line items are unaffected by changes made to pricing structures on change request line items. Input Parameters
Return ValueThe ContractsService.Contract DTO for the change request created. saveNewChangeRequestglobal static Id saveNewChangeRequest(ffbc.ContractsService.Contract changeRequest) Saves a new change request to the database. All custom fields that are not included in the object provided are copied from the existing active contract to which the new change request relates. Input Parameters
Exceptions Thrown
Return ValueID of the inserted Contract__c object for the change request. 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. /** * Example of creating a Change Request, where the change is adding a new line to the Contract. * Variables marked by asterisks need to be queried from your organisation's data. */ ContractsService.Contract changeRequest = ContractsService.createChangeRequestObject(*contractId*); //Lines on a Change Request must always be ready for billing, so Billing Term, Billing Type and First Bill Date must be set. //If the EndDate is not specified then it will be copied from the header. ContractsService.ContractLineItem newLineItem = new ContractsService.ContractLineItem(); newLineItem.ProductService = *productId*; newLineItem.BillingTerm = *billingTermId*; newLineItem.StartDate = System.today(); newLineItem.FirstBillDate = System.today(); newLineItem.UnitPrice = 50; newLineItem.Quantity = 1; newLineItem.BillingType = BillingService.BillingType.RecurringFixed; changeRequest.addLineItem(newLineItem); ContractsService.saveNewChangeRequest(changeRequest); applyChangeRequestsglobal static ffbc.ContractsService.ApplyChangeRequestsResponse applyChangeRequests(ffbc.ContractsService.ApplyChangeRequestsRequest request) Applies each change request specified in the request object to the active contract to which it belongs. This also generates billing schedules for the number of months specifed in the request. Input Parameters
Return ValueThe Response object containing errors that occurred or the active contract IDs of the change requests that were applied. createRenewalsWithNoPriceChangeglobal static ffbc.ContractsService.CreateRenewalResponse createRenewalsWithNoPriceChange(ffbc.ContractsService.CreateRenewalRequest request) Creates renewals for the contract IDs provided without pricing changes. This creates renewals and returns their IDs. All values of custom fields on the active contracts are copied to the renewals. Input Parameters
Return ValueThe Response object containing errors that occurred and the IDs of the renewals that were created. createRenewalsWithPercentageAdjustmentglobal static ffbc.ContractsService.CreateRenewalResponse createRenewalsWithPercentageAdjustment(ffbc.ContractsService.CreateRenewalWithPercentageAdjustmentRequest request) Creates renewals for the contract IDs provided with pricing changes based on the percentage adjustment. This creates renewals and returns their IDs. All values of custom fields on the active contracts are copied to the renewals. Input Parameters
Return ValueThe Response object containing errors that occurred and the IDs of the renewals that were created. createRenewalsFromPricebookglobal static ffbc.ContractsService.CreateRenewalResponse createRenewalsFromPricebook(ffbc.ContractsService.CreateRenewalWithPricebookRequest request) Creates renewals for the contract IDs provided with pricing changes from the price book provided. This creates renewals and returns their IDs. All values of custom fields on the active contracts are copied to the renewals. Input Parameters
Return ValueThe Response object containing errors that occurred and the IDs of the renewals that were created. createRenewalsWithNoPriceChangeAsyncglobal static Id createRenewalsWithNoPriceChangeAsync(ffbc.ContractsService.CreateRenewalRequest request) Creates renewals for the contract IDs provided using a batch or queueable background process. This creates the renewals without pricing changes and returns the ID of the batch or queueable process used. All values of custom fields on the active contracts are copied to the renewals. The start, end and first bill dates are set depending on the RenewalLineDurationOption value. Input Parameters
Return ValueThe ID of the asynchronous process that is to create the renewals. createRenewalsWithPercentageAdjustmentAsyncglobal static Id createRenewalsWithPercentageAdjustmentAsync(ffbc.ContractsService.CreateRenewalWithPercentageAdjustmentRequest request) Creates renewals for the contract IDs provided using a batch or queueable background process. This creates the renewals with pricing changes based on the percentage adjustment and returns the ID of the batch or queueable process used. All values of custom fields on the active contracts are copied to the renewals. The start, end and first bill dates are set depending on the RenewalLineDurationOption value. Input Parameters
Return ValueThe ID of the asynchronous process that is to create the renewals. createRenewalsFromPriceBookAsyncglobal static Id createRenewalsFromPriceBookAsync(ffbc.ContractsService.CreateRenewalWithPricebookRequest request) Creates renewals for the contract IDs provided using a batch or queueable background process. This creates the renewals with pricing changes from the price book provided and returns the ID of the batch or queueable process used. All values of custom fields on the active contracts are copied to the renewals. The start, end and first bill dates are set depending on the RenewalLineDurationOption value. Input Parameters
Return ValueThe ID of the asynchronous process that is to create the renewals. getAdditionalFieldMetadataglobal static List<ffbc.FieldMetadata> getAdditionalFieldMetadata() Retrieves metadata for additional contract and contract line item fields that are visible when viewing, creating and editing a contract. Return ValueA list of metadata wrappers for additional fields. expireglobal static ffbc.ContractsService.ExpireResponse expire(ffbc.ContractsService.ExpireRequest request) Expires active contracts using the contract IDs provided. Input Parameters
Exceptions Thrown
Return ValueAn ExpireResponse object containing the errors that occurred and the IDs of the contracts that were expired. expireAsyncglobal static Id expireAsync(ffbc.ContractsService.ExpireRequest request) Expires active contracts for the contract IDs provided using a batch or queueable background process. If no IDs are provided all valid active contracts are expired. Input Parameters
Return ValueThe ID of the asynchronous process that is to expire the contracts. endglobal static ffbc.ContractsService.EndingResponse end(Map<Id, ffbc.ContractsService.EndingParameter> endingRequestMap) Ends active contracts early using the requested new end date, reason for ending the contract and additional notes. An error occurs if the contract is associated with an open change request that has not been rejected or a draft renewal. Input Parameters
Return ValueA response containing the results from the process. The response contains the list of the contracts successfully processed and the errors associated with each Contract ID. endAndCleanglobal static ffbc.ContractsService.EndingResponse endAndClean(Map<Id, ffbc.ContractsService.EndingParameter> endingRequestMap) Ends active contracts using the requested new end date, reason for ending the contract and additional notes. If the contracts are associated with open change requests that have not been rejected or draft renewals, these are automatically deleted. Input Parameters
Return ValueA response containing the results from the process. The response contains the list of the contracts successfully processed and the errors associated with each Contract ID. validateForScheduleGenerationglobal static void validateForScheduleGeneration(ffbc.ContractsService.ValidateForScheduleGenerationRequest request) Checks the contract information provided and determines whether it is valid to generate schedules for that contract. Input Parameters
Exceptions Thrown
validateForFieldsCalculationglobal static void validateForFieldsCalculation(ffbc.ContractsService.ValidateForFieldsCalculationRequest request) Checks the contract information provided and determines whether it is valid to calculate the total reporting fields of the contract. Input Parameters
Exceptions Thrown
validateForTotalValueCalculationThis method has been deprecated and always throws an exception to indicate that the new method should be used. global static void validateForTotalValueCalculation(ffbc.ContractsService.ValidateForTotalValueCalculationRequest request) Input Parameters
Exceptions Thrown
validateForCreatingBillingDocumentglobal static void validateForCreatingBillingDocument(ffbc.ContractsService.ValidateForCreatingBillingDocumentRequest request) Checks the contract information provided and determines whether it is valid to create billing documents for that contract. Input Parameters
Exceptions Thrown
validateForActivationglobal static ffbc.Response validateForActivation(ffbc.ContractsService.ValidateForActivationRequest request) Checks the contracts provided and determines whether they are valid to be activated. Input Parameters
Return ValueA Response that holds the errors relating to the validated Contracts. Errors are returned if: A contract has a status other than draft. A contract has a type other than Contract. A contract has no related contract lines. Any of the contract line items do not contain a billing type. Any of the contract line items do not contain a billing term. Any of the contract line items do not contain a first bill date. validateForAddPlanglobal static void validateForAddPlan(ffbc.ContractsService.ValidateForAddPlanRequest request) Checks the contract information provided and determines whether it is valid to add plans to that contract. Input Parameters
Exceptions Thrown
validateForEndingglobal static void validateForEnding(ffbc.ContractsService.ValidateForEndingRequest request) Checks the contract information provided and determines whether it is valid to end that contract. Input Parameters
Exceptions Thrown
ffbc.ContractsService.Contractglobal class Contract Represents a Contract SObject including the contract line items and the relevant fields for creating, editing and viewing them. Properties
Methods
Contractglobal Contract() Constructs an empty Contract of type Contract. The LineItems list is initialised to an empty list. addLineItemglobal ffbc.ContractsService.Contract addLineItem(ffbc.ContractsService.ContractLineItem lineItem) This method adds a ContractLineItem to the Contract and links that line to that Contract. If the ContractLineItem is null it is not added. Input Parameters
Return ValueThe Contract with the new contract line item added. ffbc.ContractsService.ContractLineItemglobal class ContractLineItem Represents a Contract Line Item, including the fields required to create, edit and view contracts. Properties
Methodsffbc.ContractsService.BillingScheduleGenerationRequestglobal abstract class BillingScheduleGenerationRequest This class cannot be instantiated. It is used as an extension point by other request objects within the ContractsService. Properties
ffbc.ContractsService.ActivationRequestglobal class ActivationRequest extends BillingScheduleGenerationRequest This class wraps the criteria to be used when activating contracts. This class extends ffbc.ContractsService.BillingScheduleGenerationRequest Properties
Methodsffbc.ContractsService.ApplyChangeRequestsRequestglobal class ApplyChangeRequestsRequest extends BillingScheduleGenerationRequest This class wraps the criteria to be used when applying change requests to contracts. This class extends ffbc.ContractsService.BillingScheduleGenerationRequest Properties
MethodsApplyChangeRequestsRequestglobal ApplyChangeRequestsRequest() The default constructor for an ApplyChangeRequestsRequest. ffbc.ContractsService.ApplyChangeRequestsResponseglobal class ApplyChangeRequestsResponse extends Response The response to a request to apply change requests. This contains the errors for the change requests that could not be applied. This class extends ffbc.Response ffbc.ContractsService.CreateRenewalBaseRequestglobal abstract class CreateRenewalBaseRequest The base request object used by the createRenewals service. This contains the ContractIds to create renewals for and whether or not to extend the start, end and first bill dates on the renewal created. Properties
ffbc.ContractsService.CreateRenewalRequestglobal class CreateRenewalRequest extends CreateRenewalBaseRequest A request object used by the createRenewals service. This request does not modify unit prices of associated lines and price breaks for the renewal. This class extends ffbc.ContractsService.CreateRenewalBaseRequest MethodsCreateRenewalRequestglobal CreateRenewalRequest() The default constructor for a CreateRenewalRequest. ffbc.ContractsService.CreateRenewalWithPercentageAdjustmentRequestglobal class CreateRenewalWithPercentageAdjustmentRequest extends CreateRenewalBaseRequest A request object used by the createRenewals service. This request modifies unit prices of associated lines and price breaks by a percentage for the renewal. This class extends ffbc.ContractsService.CreateRenewalBaseRequest Properties
MethodsCreateRenewalWithPercentageAdjustmentRequestglobal CreateRenewalWithPercentageAdjustmentRequest() The default constructor for a CreateRenewalWithPercentageAdjustmentRequest. ffbc.ContractsService.CreateRenewalWithPricebookRequestglobal class CreateRenewalWithPricebookRequest extends CreateRenewalBaseRequest A request object used by the createRenewals service. This request modifies unit prices of associated lines and price breaks from a price book for the renewal. This class extends ffbc.ContractsService.CreateRenewalBaseRequest Properties
MethodsCreateRenewalWithPricebookRequestglobal CreateRenewalWithPricebookRequest() The default constructor for an CreateRenewalWithPricebookRequest. ffbc.ContractsService.CreateRenewalResponseglobal class CreateRenewalResponse extends Response The ffbc.Response object used by the createRenewals service. This contains the errors for the renewals that could not be created and a set containing the IDs of all the renewals created. This class cannot be instantiated. This class extends ffbc.Response MethodsgetRenewalsCreatedglobal List<Id> getRenewalsCreated() This method is used to access the list of renewals generated by the create response process. Return ValueA list of IDs of the renewals created. ffbc.ContractsService.ExpireRequestglobal class ExpireRequest The request object used by the Expire service. This contains the ContractIds to expire. Properties
Methodsffbc.ContractsService.ExpireResponseglobal class ExpireResponse extends Response The ffbc.Response object used by the Expire service. This contains the errors for the contracts that could not be expired and a list containing the IDs of all the expired contracts. This class cannot be instantiated. This class extends ffbc.Response Properties
ffbc.ContractsService.ContractSummaryglobal class ContractSummary This class wraps the fields that identify a contract. Properties
ffbc.ContractsService.ContractSummaryRequestglobal class ContractSummaryRequest A request object containing criteria for which to retrieve contracts. Properties
Methodsffbc.ContractsService.QuantityBreakglobal class QuantityBreak This class models a quantity break. Properties
Methodsffbc.ContractsService.PricingStructureglobal class PricingStructure This class models a pricing structure with quantity breaks. Properties
Methodsffbc.ContractsService.ValidateForScheduleGenerationRequestglobal class ValidateForScheduleGenerationRequest A request object for the ValidateForScheduleGeneration method. Properties
MethodsValidateForScheduleGenerationRequestglobal ValidateForScheduleGenerationRequest() The default constructor for this object. ffbc.ContractsService.ValidateForTotalValueCalculationRequestglobal class ValidateForTotalValueCalculationRequest
A request object for the ValidateForTotalValueCalculation method. Properties
Methods
ValidateForTotalValueCalculationRequestThe default constructor for this object. global ValidateForTotalValueCalculationRequest() ffbc.ContractsService.ValidateForFieldsCalculationRequestglobal class ValidateForFieldsCalculationRequest A request object for the ValidateForFieldsCalculation method. Properties
MethodsValidateForFieldsCalculationRequestglobal ValidateForFieldsCalculationRequest() The default constructor for this object. ffbc.ContractsService.ValidateForCreatingBillingDocumentRequestglobal class ValidateForCreatingBillingDocumentRequest A request object for the ValidateForCreatingBillingDocument method. Properties
MethodsValidateForCreatingBillingDocumentRequestglobal ValidateForCreatingBillingDocumentRequest() The default constructor for this object. ffbc.ContractsService.ValidateForActivationRequestglobal class ValidateForActivationRequest A request object for the ValidateForActivation method. Properties
MethodsValidateForActivationRequestglobal ValidateForActivationRequest() The default constructor for this object. ffbc.ContractsService.ValidateForAddPlanRequestglobal class ValidateForAddPlanRequest A request object for the ValidateForAddPlan method. Properties
MethodsValidateForAddPlanRequestglobal ValidateForAddPlanRequest() The default constructor for this object. ffbc.ContractsService.ValidateForEndingRequestglobal class ValidateForEndingRequest A request object for the ValidateForEnding method. Properties
Methodsffbc.ContractsService.EndingParameterglobal class EndingParameter This class holds the parameters for the ending a contract early. Properties
Methodsffbc.ContractsService.EndingResponseglobal class EndingResponse extends Response The ffbc.Response object used by the Ending service. This contains the errors for the contracts that could not be ended and a list containing the IDs of all contracts that were ended. This class cannot be instantiated. This class extends ffbc.Response Properties
ffbc.ContractsService.CalculateFieldsRequestglobal class CalculateFieldsRequest This class holds the parameters to calculate the values of the contract. Properties
Methodsffbc.ContractsService.CalculateFieldsResponseglobal class CalculateFieldsResponse extends Response The ffbc.Response object used by the Calculate fields service. This contains the errors for the contract fields calculation. This class cannot be instantiated. This class extends ffbc.Response Properties
|