ffbc.ContractsServiceglobal with sharing class ContractsService
This class provides service functionality for Billing Central contracts. This class contains deprecated items. 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.
RenewalDurationOptionThe valid options for the new contract duration when creating a renewal.
Methods
activationglobal static ffbc.ContractsService.ActivationResponse activation(ffbc.ContractsService.ActivationRequest activationRequest) Activates the contracts provided by changing their status to Active. An asynchronous process is then started to create the first billing schedules for the contracts. Input Parameters
Exceptions Thrown
Return ValueA response object containing the errors that occurred while activating contracts. activationAsyncglobal static Id activationAsync(ffbc.ContractsService.ActivationRequest request) Activates the contracts provided by changing their status to Active using a background process. This returns an ID for the background process that is processing the contracts. An asynchronous process is then started to create the first billing schedules for the contracts. Input Parameters
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. Creates credit notes for periods that have been billed in advance. The generated credit note IDs are included in the response. Input Parameters
Return ValueThe Response object containing errors that occurred. assignProrationPolicyglobal static ffbc.ContractsService.AssignProrationPolicyResponse assignProrationPolicy(ffbc.ContractsService.AssignProrationPolicyRequest request) Assigns a proration policy to contracts and updates their values. If the contracts are active, and your settings allow updating the proration policy on active contracts, draft billing documents will be deleted or discarded, and any billing schedules associated with Recurring Fixed contract lines that have not been billed will be updated. Only the first and last periods of each contract line will be prorated. Input Parameters
Exceptions Thrown
Return ValueThe contracts that have been updated, and errors for contracts that could not be updated. 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 shows how to use the ffbc.ContractsService.assignProrationPolicy method to assign a proration policy * to a collection of contracts in bulk. This service is synchronous so you will get the results immediately but you * will not be able to update any more than 10000 contracts. To update more than 10000 contracts use the asynchronous * version of this method (ffbc.ContractsService.assignProrationPolicyAsync). */ //Given a collection of contract IDs and a proration policy ID Set<Id> contractIds; Id prorationPolicyId; // Build a request object specifying the contract IDs that you want updated and the ID of the proration policy // that you want to be applied to the contracts. ffbc.ContractsService.AssignProrationPolicyRequest request = new ffbc.ContractsService.AssignProrationPolicyRequest(); request.ContractIds = contractIds; request.ProrationPolicyId = prorationPolicyId; // Send the request to the service and receive the response ffbc.ContractsService.AssignProrationPolicyResponse response = ffbc.ContractsService.assignProrationPolicy(request); // The response can be checked for any errors if(response.hasErrors()) { throw new Exception(response.getStringErrors()); } // The response can be checked to ensure all contracts were updated for(Id contractId : contractIds) { System.assert(response.UpdatedContractIds.contains(contractId), 'Contract ' + contractId + ' was not updated.'); } assignProrationPolicyAsyncglobal static Id assignProrationPolicyAsync(ffbc.ContractsService.AssignProrationPolicyRequest request) Assigns a proration policy to contracts using a batch or queueable background process. Input Parameters
Return ValueThe ID of the asynchronous process that is to update the contracts. 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 shows how to use the ffbc.ContractsService.assignProrationPolicyAsync method to assign a proration * policy to a collection of contracts in bulk. This service will schedule an asynchronous job to iterate over * the provided contracts to enable volumes in excess of 10000 contracts to be updated with a new proration policy. */ //Given a collection of contract IDs and a proration policy ID Set<Id> contractIds; Id prorationPolicyId; // Build a request object specifying the contract IDs that you want updated and the ID of the proration policy // that you want to be applied to the contracts. ffbc.ContractsService.AssignProrationPolicyRequest request = new ffbc.ContractsService.AssignProrationPolicyRequest(); request.ContractIds = contractIds; request.ProrationPolicyId = prorationPolicyId; // Send the request to the service and receive the ID of the AsyncApexJob that the contracts will be processed within Id jobId = ffbc.ContractsService.assignProrationPolicyAsync(request); // The job can then be selected from the AsyncApexJob table to inspect various details for example the status or the // number of errors encountered. Keep in mind though that this is asynchronous, you won't see the job complete within // the same execution context. The job may also start other jobs so the completion of this job may not mean that all // the work is done - the system will send a notification when all the contracts have been updated. Background Process // Settings control how you are notified. AsyncApexJob job = [SELECT Status, NumberOfErrors, ExtendedStatus FROM AsyncApexJob WHERE ID = :jobId]; // If there are errors then you could throw an exception with a summary of the first error if(job.NumberOfErrors > 0) { throw new Exception(job.ExtendedStatus); } calculateFieldsWithoutSaveglobal static ffbc.ContractsService.CalculateFieldsWithoutSaveResponse calculateFieldsWithoutSave(ffbc.ContractsService.CalculateFieldsWithoutSaveRequest request) Calculates the projected value and totals for the specified contracts over their lifetime. This is an equivalent to the calculateFields method that can be used without having a contract saved on the database. For example, this could be used to preview the effect of changing a contract, or to correctly set the sales prices and total values before saving. Input Parameters
Exceptions Thrown
Return ValueA response containing the values calculated for each contract. Contracts and lines are returned in the order that they are present in the request. In the event that a contract or line has missing or invalid information, a warning is included and any fields that could not be calculated are returned as null. 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 shows how to use the ffbc.ContractsService.calculateFieldsWithoutSave method to work out the sales price and total value of the * lines of a contract before saving it. This allows you to set these fields to their correct values before saving a new contract * on the database, or to make decisions based on their values. */ //Given a contract that has been constructed elsewhere ffbc.ContractsService.Contract contractToSave; ffbc.ContractsService.CalculateFieldsWithoutSaveHeaderRequest headerRequest = new ffbc.ContractsService.CalculateFieldsWithoutSaveHeaderRequest(); headerRequest.Identifier = contractToSave.Id; headerRequest.EndDate = contractToSave.EndDate; List<ffbc.ContractsService.CalculateFieldsWithoutSaveLineRequest> lineRequests = new List<ffbc.ContractsService.CalculateFieldsWithoutSaveLineRequest>(); for (ffbc.ContractsService.ContractLineItem line : contractToSave.LineItems) { ffbc.ContractsService.CalculateFieldsWithoutSaveLineRequest lineRequest = new ffbc.ContractsService.CalculateFieldsWithoutSaveLineRequest(); lineRequest.Identifier = line.Id; lineRequest.Quantity = line.Quantity; lineRequest.UnitPrice = line.UnitPrice; lineRequest.StartDate = line.StartDate; lineRequest.EndDate = line.EndDate; lineRequest.BillingType = line.BillingType; lineRequest.BillingTerm = line.BillingTerm; lineRequest.Discount = line.Discount; lineRequest.PricingType = line.PricingStructure.PricingType; lineRequest.QuantityBreaks = line.PricingStructure.QuantityBreaks; lineRequests.add(lineRequest); } headerRequest.Lines = lineRequests; ffbc.ContractsService.CalculateFieldsWithoutSaveRequest request = new ffbc.ContractsService.CalculateFieldsWithoutSaveRequest(); request.Contracts = new List<ffbc.ContractsService.CalculateFieldsWithoutSaveHeaderRequest>{headerRequest}; ffbc.ContractsService.CalculateFieldsWithoutSaveResponse response = ffbc.ContractsService.calculateFieldsWithoutSave(request); ffbc.ContractsService.CalculateFieldsWithoutSaveHeaderResponse contractResponse = response.Contracts[0]; if (contractResponse.TotalContractValue > 10000) { //We now know what values the contract would have before saving, so pre-emptive action can be taken if, for //example, high-value contracts need extra operations. } //We can now set the values on the contract that is to be saved, so it will save with the correct sales prices, total line values //and total contract value. contractToSave.TotalContractValue = contractResponse.TotalContractValue; for (Integer i = 0, size = contractToSave.LineItems.size(); i < size; i++) { ffbc.ContractsService.ContractLineItem lineToSave = contractToSave.LineItems[i]; ffbc.ContractsService.CalculateFieldsWithoutSaveLineResponse lineResponse = contractResponse.Lines[i]; if (lineToSave.Id != lineResponse.Identifier) { System.assert(false, 'The line responses will be returned in the same order that the requests are passed in, ' + 'so for this sample these values will always match. If you cannot use the ordering, you can use the ' + 'Identifier on the line response to work out which request line it corresponds to.'); } lineToSave.SalesPriceOverride = lineResponse.SalesPriceOverride; lineToSave.TotalContractLineValue = lineResponse.TotalContractLineValue; } 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. createChangeRequestObjectsglobal static ffbc.ContractsService.CreateChangeRequestObjectsResponse createChangeRequestObjects(ffbc.ContractsService.CreateChangeRequestObjectsRequest request) Creates change requests for the contract IDs provided. This copies the contracts and returns a map of populated ffbc.ContractsService.Contract DTOs that represent the new change requests, keyed by the IDs of the active contracts. This does not insert the new records into the database. The ID properties of the returned contracts and their lines are null. Input Parameters
Exceptions Thrown
Return ValueThe ContractsService.Contract DTO for the change request created. 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. */ ffbc.ContractsService.CreateChangeRequestObjectsRequest createRequest = new ffbc.ContractsService.CreateChangeRequestObjectsRequest(*contractIds*); //Do not include read-only fields as trying to write to these would produce an error when trying to save createRequest.IncludeReadOnlyFields = false; ffbc.ContractsService.CreateChangeRequestObjectsResponse createResult = ffbc.ContractsService.createChangeRequestObjects(createRequest); List<ffbc.ContractsService.Contract> changeRequests = createResult.ChangeRequestsByActiveContractId.values(); for (ffbc.ContractsService.Contract changeRequest : changeRequests) { //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. ffbc.ContractsService.ContractLineItem newLineItem = new ffbc.ContractsService.ContractLineItem(); newLineItem.ProductService = *productId*; newLineItem.BillingTerm = *billingTermId*; newLineItem.StartDate = System.today(); newLineItem.FirstBillDate = System.today(); newLineItem.UnitPrice = 50; newLineItem.Quantity = 1; newLineItem.BillingType = ffbc.BillingService.BillingType.RecurringFixed; changeRequest.addLineItem(newLineItem); } ffbc.ContractsService.SaveNewChangeRequestsRequest saveRequest = new ffbc.ContractsService.SaveNewChangeRequestsRequest(changeRequests); ffbc.ContractsService.saveNewChangeRequests(saveRequest); 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. 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 line start, line end and line first bill dates are set depending on the RenewalLineDurationOption value. The renewal start, renewal end and renewal first bill dates are set depending on the RenewalDurationOption value. Input Parameters
Return ValueThe ID of the asynchronous process that is to create the renewals. 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. 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 line start, line end and line first bill dates are set depending on the RenewalLineDurationOption value. The renewal start, renewal end and renewal first bill dates are set depending on the RenewalDurationOption value. Input Parameters
Return ValueThe ID of the asynchronous process that is to create the renewals. 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. 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 line start, line end and line first bill dates are set depending on the RenewalLineDurationOption value. The renewal start, renewal end and renewal first bill dates are set depending on the RenewalDurationOption value. Input Parameters
Return ValueThe ID of the asynchronous process that is to create the renewals. deleteContractsglobal static void deleteContracts(Set<Id> contractsToDelete) Deletes the contracts with the IDs provided. Input Parameters
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. An error occurs if there are any incomplete credit notes or consolidated billing documents linked to the contract. 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. An error occurs if there are any incomplete credit notes or consolidated billing documents linked to the contract. 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. endViaChangeRequestglobal static ffbc.ContractsService.EndViaChangeRequestResponse endViaChangeRequest(Map<Id, ffbc.ContractsService.EndingParameter> endingRequestMap) Creates change requests to end active contracts using the requested new end date, reason for ending the contract and additional notes. Related change requests and renewals for the contract will be deleted. This service supports a maximum of 10 contracts in a single execution. If you need to end more contracts, split them into multiple chunks. An error occurs if there are any incomplete credit notes or consolidated billing documents linked to the contract. Input Parameters
Exceptions Thrown
Return ValueA response containing the results from the process. The response contains a map of contract processed to change request, plus the errors associated with each Contract ID. 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. 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. getFieldsThatAffectPricingglobal static Set<SObjectField> getFieldsThatAffectPricing() Retrieves fields that affect pricing on a contract line item. Return ValueSet of fields that affect contract line pricing. 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. getValidationErrorsForCreatingRenewalglobal static ffbc.ContractsService.ValidateForCreatingRenewalResponse getValidationErrorsForCreatingRenewal(ffbc.ContractsService.ValidateForCreatingRenewalRequest request) Checks the contract information provided and determines whether it is valid to create a renewal for that contract. Input Parameters
Return ValueA response object that holds the errors relating to the validated contract. Errors are returned if: The contract type is not Contract. The status is not Active or Expired. There is no end date. There is a related renewal. 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 ffbc__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 ffbc__Contract__c objects. saveNewChangeRequestsglobal static ffbc.ContractsService.SaveNewChangeRequestsResponse saveNewChangeRequests(ffbc.ContractsService.SaveNewChangeRequestsRequest request) Saves new change requests to the database. All custom fields that are not included in the objects provided are copied from the existing active contract to which the new change request relates. If specifying the AlignForBilling__c field in CustomFields, the field value should be set to the ID of the controlling line on the active contract. When the change request is saved, this will result in the field value pointing to the corresponding controlling line on the change request. Input Parameters
Exceptions Thrown
Return ValueResponse containing the IDs of the inserted ffbc__Contract__c record for the change requests. The IDs in the response's ChangeRequestIds property will be in the same order as the change requests in request.ChangeRequests. 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. */ ffbc.ContractsService.CreateChangeRequestObjectsRequest createRequest = new ffbc.ContractsService.CreateChangeRequestObjectsRequest(*contractIds*); //Do not include read-only fields as trying to write to these would produce an error when trying to save createRequest.IncludeReadOnlyFields = false; ffbc.ContractsService.CreateChangeRequestObjectsResponse createResult = ffbc.ContractsService.createChangeRequestObjects(createRequest); List<ffbc.ContractsService.Contract> changeRequests = createResult.ChangeRequestsByActiveContractId.values(); for (ffbc.ContractsService.Contract changeRequest : changeRequests) { //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. ffbc.ContractsService.ContractLineItem newLineItem = new ffbc.ContractsService.ContractLineItem(); newLineItem.ProductService = *productId*; newLineItem.BillingTerm = *billingTermId*; newLineItem.StartDate = System.today(); newLineItem.FirstBillDate = System.today(); newLineItem.UnitPrice = 50; newLineItem.Quantity = 1; newLineItem.BillingType = ffbc.BillingService.BillingType.RecurringFixed; changeRequest.addLineItem(newLineItem); } ffbc.ContractsService.SaveNewChangeRequestsRequest saveRequest = new ffbc.ContractsService.SaveNewChangeRequestsRequest(changeRequests); ffbc.ContractsService.saveNewChangeRequests(saveRequest); validateChangeRequestsglobal static ffbc.ContractsService.ValidateChangeRequestsResponse validateChangeRequests(ffbc.ContractsService.ValidateChangeRequestsRequest request) Validates the change requests provided to determine if they can be applied. Input Parameters
Return ValueThe Response object containing errors that occurred. 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. Any of the contract line items do not contain a pricing structure or a unit price. 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
validateForAssignProrationPolicyglobal static ffbc.Response validateForAssignProrationPolicy(ffbc.ContractsService.ValidateForAssignProrationRequest request) Validates the contracts provided to determine if they can have a proration policy assigned. Input Parameters
Return ValueA Response containing the IDs of contracts that could not be assigned a proration policy, and the errors that occurred. 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 shows how to use the ffbc.ContractsService.validateForAssignProrationPolicy method to validate whether * a proration policy can be assigned to a collection of contracts in bulk. */ //Given a collection of contract IDs Set<Id> contractIds; // Build a request object specifying the contract IDs that you want updated. ffbc.ContractsService.ValidateForAssignProrationRequest request = new ffbc.ContractsService.ValidateForAssignProrationRequest(); request.ContractIds = contractIds; // Send the request to the service and receive the response ffbc.Response response = ffbc.ContractsService.validateForAssignProrationPolicy(request); // The response can be checked for any errors if(response.hasErrors()) { throw new Exception(response.getStringErrors()); } // The response can be checked to ensure all contracts were valid for update. for(Id contractId : contractIds) { System.assert(!response.hasErrors(contractId), 'Contract ' + contractId + ' can not be updated.'); } 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
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
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
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
DeprecatedThe following items are deprecated and not supported for use. We recommend that you stop using these items to avoid exceptions. Methods
activateDeprecated: This method has been deprecated, use activation instead. global 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
calculateFieldsDeprecated: This method has been deprecated because calculation is now done automatically via the trigger. 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 Sales Price Override field is calculated to ensure that the Monthly Recurring Revenue and Annual Recurring Revenue values are correct. If errors are encountered during calculation, fields that could not be calculated will be set to null. global static ffbc.ContractsService.CalculateFieldsResponse calculateFields(ffbc.ContractsService.CalculateFieldsRequest calculateRequest) Input Parameters
Return ValueA CalculateFieldsResponse containing the errors that occurred for each contract. calculateTotalValuesDeprecated: This 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. createChangeRequestObjectDeprecated: This method has been deprecated. Use createChangeRequestObjects instead. global 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. If the line items' CustomFields array includes the AlignForBilling__c field, the values will point to controlling lines on the active contract. These will be corrected to point to the corresponding controlling lines on the change request automatically when calling saveNewChangeRequest. Input Parameters
Return ValueThe ContractsService.Contract DTO for the change request created. createChangeRequestObjectWithoutReadOnlyFieldsDeprecated: This method has been deprecated. Use createChangeRequestObjects instead. global static ffbc.ContractsService.Contract createChangeRequestObjectWithoutReadOnlyFields(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. If the line items' CustomFields array includes the AlignForBilling__c field, the values will point to controlling lines on the active contract. These will be corrected to point to the corresponding controlling lines on the change request automatically when calling saveNewChangeRequest. Any read only custom fields get removed from the DTO. This feature is useful when calling saveNewChangeRequest as it does not require to remove the custom fields manually, avoiding errors when saving the change request. Input Parameters
Return ValueThe ContractsService.Contract DTO for the change request created. saveNewChangeRequestDeprecated: This method has been deprecated. Use saveNewChangeRequests instead. global 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. If specifying the AlignForBilling__c field in CustomFields, the field value should be set to the ID of the controlling line on the active contract. When the change request is saved, this will result in the field value pointing to the corresponding controlling line on the change request. Input Parameters
Exceptions Thrown
Return ValueID of the inserted ffbc__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. */ ffbc.ContractsService.Contract changeRequest = ffbc.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. ffbc.ContractsService.ContractLineItem newLineItem = new ffbc.ContractsService.ContractLineItem(); newLineItem.ProductService = *productId*; newLineItem.BillingTerm = *billingTermId*; newLineItem.StartDate = System.today(); newLineItem.FirstBillDate = System.today(); newLineItem.UnitPrice = 50; newLineItem.Quantity = 1; newLineItem.BillingType = ffbc.BillingService.BillingType.RecurringFixed; changeRequest.addLineItem(newLineItem); ffbc.ContractsService.saveNewChangeRequest(changeRequest); validateForCreatingRenewalDeprecated: This method has been deprecated, use getValidationErrorsForCreatingRenewal instead. global static void validateForCreatingRenewal(ffbc.ContractsService.ValidateForCreatingRenewalRequest request) Checks the contract information provided and determines whether it is valid to create a renewal for that contract. Input Parameters
Exceptions Thrown
validateForTotalValueCalculationDeprecated: This 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
ffbc.ContractsService.ActivationRequestglobal with sharing class ActivationRequest extends BillingScheduleGenerationRequest This class wraps the criteria to be used when activating contracts. This class extends ffbc.ContractsService.BillingScheduleGenerationRequest Properties
Methodsffbc.ContractsService.ActivationResponseglobal with sharing class ActivationResponse extends Response The response to a request to activate contracts. This contains the errors for the contracts that cannot be activated. This class extends ffbc.Response ffbc.ContractsService.ApplyChangeRequestsRequestglobal virtual with sharing 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 with sharing 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 Properties
Methods
getCreditNoteIdByChangeRequestIdglobal Id getCreditNoteIdByChangeRequestId(Id changeRequestId) Return the ID of any credit note created by applying the change request, or null if none was created. Input Parameters
Return ValueCredit note ID or null. hasCreditNoteIdForChangeRequestIdglobal Boolean hasCreditNoteIdForChangeRequestId(Id changeRequestId) Returns whether applying the specified change request resulted in a credit note being created. If true, getCreditNoteIdByChangeRequestId will return an ID when given this changeRequestId. Input Parameters
Return ValueTrue if a credit note was created by applying this change request. hasCreditNotesglobal Boolean hasCreditNotes() Whether any credit notes were created as a result of applying the given change requests. Return ValueTrue if any credit notes were created. ffbc.ContractsService.AssignProrationPolicyRequestglobal with sharing class AssignProrationPolicyRequest This class holds the parameters to assign a proration policy to multiple contracts. Properties
MethodsAssignProrationPolicyRequestglobal AssignProrationPolicyRequest() The default constructor for this object. ffbc.ContractsService.AssignProrationPolicyResponseglobal with sharing class AssignProrationPolicyResponse extends Response The ffbc.Response object used by the Assign Proration Policy service. This contains any errors produced by the proration policy assignment. This class cannot be instantiated. This class extends ffbc.Response Properties
ffbc.ContractsService.BillingScheduleGenerationRequestglobal with sharing 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.CalculateFieldsRequestglobal with sharing class CalculateFieldsRequest Deprecated: This object has been deprecated because calculation is now done automatically via the trigger. This class holds the parameters to calculate the values of the contract. Properties
Methodsffbc.ContractsService.CalculateFieldsResponseglobal with sharing class CalculateFieldsResponse extends Response Deprecated: This object has been deprecated because calculation is now done automatically via the trigger. 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
ffbc.ContractsService.CalculateFieldsWithoutSaveRequestglobal with sharing class CalculateFieldsWithoutSaveRequest This class holds a list of contracts to have their fields calculated. Properties
MethodsCalculateFieldsWithoutSaveRequestglobal CalculateFieldsWithoutSaveRequest() ffbc.ContractsService.CalculateFieldsWithoutSaveHeaderRequestglobal with sharing class CalculateFieldsWithoutSaveHeaderRequest This class holds the list of lines for a contract, and contract information used to calculate fields. Properties
MethodsCalculateFieldsWithoutSaveHeaderRequestglobal CalculateFieldsWithoutSaveHeaderRequest() ffbc.ContractsService.CalculateFieldsWithoutSaveLineRequestglobal with sharing class CalculateFieldsWithoutSaveLineRequest This class holds the parameters to calculate the values of the contract line and header. Properties
MethodsCalculateFieldsWithoutSaveLineRequestglobal CalculateFieldsWithoutSaveLineRequest() The default constructor for this object. ffbc.ContractsService.CalculateFieldsWithoutSaveResponseglobal with sharing class CalculateFieldsWithoutSaveResponse extends Response The ffbc.Response object used by the Calculate values service. This class cannot be instantiated. This class extends ffbc.Response Properties
ffbc.ContractsService.CalculateFieldsWithoutSaveHeaderResponseglobal with sharing class CalculateFieldsWithoutSaveHeaderResponse extends Response The ffbc.Response object used for Contract headers by the Calculate values service. This class cannot be instantiated. This class extends ffbc.Response Properties
ffbc.ContractsService.CalculateFieldsWithoutSaveLineResponseglobal with sharing class CalculateFieldsWithoutSaveLineResponse extends Response The ffbc.Response object used for lines by the Calculate values service. This class cannot be instantiated. This class extends ffbc.Response Properties
ffbc.ContractsService.Contractglobal with sharing class Contract Represents a Contract SObject including the contract line items and the relevant fields for creating, editing and viewing them. This class is marked as serializable and deserializable to work around an issue in enforcing JsonAccess for Visualforce remoting requests. Warning: Do not rely on any behavior available via serializing as or deserializing from JSON that is not part of the global API because it might be subject to change. 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 with sharing class ContractLineItem Represents a Contract Line Item, including the fields required to create, edit and view contracts. This class is marked as serializable and deserializable to work around an issue in enforcing JsonAccess for Visualforce remoting requests. Warning: Do not rely on any behavior available via serializing as or deserializing from JSON that is not part of the global API because it might be subject to change. Properties
Methodsffbc.ContractsService.ContractSummaryglobal with sharing class ContractSummary This class wraps the fields that identify a contract. This class is marked as serializable and deserializable to work around an issue in enforcing JsonAccess for Visualforce remoting requests. Warning: Do not rely on any behavior available via serializing as or deserializing from JSON that is not part of the global API because it might be subject to change. Properties
ffbc.ContractsService.ContractSummaryRequestglobal with sharing class ContractSummaryRequest A request object containing criteria for which to retrieve contracts. Properties
Methodsffbc.ContractsService.CreateChangeRequestObjectsRequestglobal with sharing class CreateChangeRequestObjectsRequest A request for the createChangeRequestObjects method. Properties
Methods
CreateChangeRequestObjectsRequestglobal CreateChangeRequestObjectsRequest() Default constructor that creates a request with an empty set of contract IDs. CreateChangeRequestObjectsRequestglobal CreateChangeRequestObjectsRequest(Set<Id> contractIds) Creates a request for the given contract IDs. ffbc.ContractsService.CreateChangeRequestObjectsResponseglobal with sharing class CreateChangeRequestObjectsResponse extends Response The result of creating change requests using the createChangeRequestObjects method. This extends ffbc.Response to allow expansion of the behaviour in future, but currently it will never populate any errors or warnings on the response. Errors in creating a change request for any contract will produce an exception. This class extends ffbc.Response Properties
Methods
CreateChangeRequestObjectsResponseglobal CreateChangeRequestObjectsResponse() Default constructor that creates a response with an empty map of change requests. CreateChangeRequestObjectsResponseglobal CreateChangeRequestObjectsResponse(Map<Id, ffbc.ContractsService.Contract> changeRequestsByActiveContractId) Creates a response with the given change requests. ffbc.ContractsService.CreateRenewalBaseRequestglobal with sharing 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 line start, end and first bill dates on the renewal created. It also contains an option to indicate whether the contract duration should change based on days or months, relative to the original contract duration. Properties
MethodsCreateRenewalBaseRequestglobal CreateRenewalBaseRequest() ffbc.ContractsService.CreateRenewalRequestglobal with sharing 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 with sharing 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 with sharing 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 with sharing 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.EndingParameterglobal with sharing class EndingParameter This class holds the parameters for the ending a contract early. Properties
Methodsffbc.ContractsService.EndingResponseglobal with sharing 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.EndViaChangeRequestResponseglobal with sharing class EndViaChangeRequestResponse extends Response The ffbc.Response object used by the Ending service for ending active contracts via change requests. This contains the errors for the contracts that could not be ended and a map of ended contract ID to change request ID. This class extends ffbc.Response Properties
MethodsEndViaChangeRequestResponseglobal EndViaChangeRequestResponse() Constructs an EndViaChangeRequestResponse with no errors or change request IDs. ffbc.ContractsService.ExpireRequestglobal with sharing class ExpireRequest The request object used by the Expire service. This contains the ContractIds to expire. Properties
Methodsffbc.ContractsService.ExpireResponseglobal with sharing 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.PricingStructureglobal with sharing class PricingStructure This class models a pricing structure with quantity breaks. This class is marked as serializable and deserializable to work around an issue in enforcing JsonAccess for Visualforce remoting requests. Warning: Do not rely on any behavior available via serializing as or deserializing from JSON that is not part of the global API because it might be subject to change. Properties
Methodsffbc.ContractsService.QuantityBreakglobal with sharing class QuantityBreak This class models a quantity break. This class is marked as serializable and deserializable to work around an issue in enforcing JsonAccess for Visualforce remoting requests. Warning: Do not rely on any behavior available via serializing as or deserializing from JSON that is not part of the global API because it might be subject to change. Properties
Methodsffbc.ContractsService.SaveNewChangeRequestsRequestglobal with sharing class SaveNewChangeRequestsRequest A request for the saveNewChangeRequests method Properties
Methods
SaveNewChangeRequestsRequestglobal SaveNewChangeRequestsRequest() Default constructor that creates a request with an empty list of change requests. SaveNewChangeRequestsRequestglobal SaveNewChangeRequestsRequest(List<ffbc.ContractsService.Contract> changeRequests) Creates a request with the given list of change requests. ffbc.ContractsService.SaveNewChangeRequestsResponseglobal with sharing class SaveNewChangeRequestsResponse extends Response The result of saving new change requests using the saveNewChangeRequests method. This extends ffbc.Response to allow expansion of the behaviour in future, but currently it will never populate any errors or warnings on the response. Errors in creating a change request for any contract will produce an exception. This class extends ffbc.Response Properties
Methods
SaveNewChangeRequestsResponseglobal SaveNewChangeRequestsResponse() Default constructor that creates a request with an empty map of IDs. SaveNewChangeRequestsResponseglobal SaveNewChangeRequestsResponse(Map<Id, Id> changeRequestIdsByActiveContractId) Creates a response with the given map of change request IDs by active contract ID. ffbc.ContractsService.ValidateChangeRequestsRequestglobal with sharing class ValidateChangeRequestsRequest extends ApplyChangeRequestsRequest This class wraps the criteria to be used when validating change requests for contracts. This class extends ffbc.ContractsService.ApplyChangeRequestsRequest MethodsValidateChangeRequestsRequestglobal ValidateChangeRequestsRequest() The default constructor for a ValidateChangeRequestsRequest. ffbc.ContractsService.ValidateChangeRequestsResponseglobal with sharing class ValidateChangeRequestsResponse extends Response The response to a request to validate change requests. This contains the errors for the change requests that failed validation. This class extends ffbc.Response ffbc.ContractsService.ValidateForActivationRequestglobal with sharing class ValidateForActivationRequest A request object for the ValidateForActivation method. Properties
MethodsValidateForActivationRequestglobal ValidateForActivationRequest() The default constructor for this object. ffbc.ContractsService.ValidateForAddPlanRequestglobal with sharing class ValidateForAddPlanRequest A request object for the ValidateForAddPlan method. Properties
MethodsValidateForAddPlanRequestglobal ValidateForAddPlanRequest() The default constructor for this object. ffbc.ContractsService.ValidateForAssignProrationRequestglobal with sharing class ValidateForAssignProrationRequest A request object for the validateForAssignProration method. Properties
MethodsValidateForAssignProrationRequestglobal ValidateForAssignProrationRequest() The default constructor for this object. ffbc.ContractsService.ValidateForCreatingBillingDocumentRequestglobal with sharing class ValidateForCreatingBillingDocumentRequest A request object for the ValidateForCreatingBillingDocument method. Properties
MethodsValidateForCreatingBillingDocumentRequestglobal ValidateForCreatingBillingDocumentRequest() The default constructor for this object. ffbc.ContractsService.ValidateForCreatingRenewalRequestglobal with sharing class ValidateForCreatingRenewalRequest A request object for the ValidateCreatingRenewal method. Properties
MethodsValidateForCreatingRenewalRequestglobal ValidateForCreatingRenewalRequest() The default constructor for this object. ffbc.ContractsService.ValidateForCreatingRenewalResponseglobal with sharing class ValidateForCreatingRenewalResponse extends Response The ffbc.Response object used by the getValidationErrorsForCreatingRenewal service. This contains the errors for the renewals that could not be created and a list containing any related contracts. This class cannot be instantiated. This class extends ffbc.Response Properties
ffbc.ContractsService.ValidateForEndingRequestglobal with sharing class ValidateForEndingRequest A request object for the ValidateForEnding method. Properties
Methodsffbc.ContractsService.ValidateForFieldsCalculationRequestglobal with sharing class ValidateForFieldsCalculationRequest A request object for the ValidateForFieldsCalculation method. Properties
MethodsValidateForFieldsCalculationRequestglobal ValidateForFieldsCalculationRequest() The default constructor for this object. ffbc.ContractsService.ValidateForScheduleGenerationRequestglobal with sharing class ValidateForScheduleGenerationRequest A request object for the ValidateForScheduleGeneration method. Properties
MethodsValidateForScheduleGenerationRequestglobal ValidateForScheduleGenerationRequest() The default constructor for this object. ffbc.ContractsService.ValidateForTotalValueCalculationRequestglobal with sharing class ValidateForTotalValueCalculationRequest Deprecated: A request object for the ValidateForTotalValueCalculation method. Properties
MethodsValidateForTotalValueCalculationRequestDeprecated: The default constructor for this object. global ValidateForTotalValueCalculationRequest() |