Billing Central Apex API Developer Reference

ffbc.PlansService

global with sharing class PlansService

This class provides service functionality for the Plan object.

Enums

Status

An enum that represents the valid options for the status of plans.

Value Description
Draft Option to show the status of the plan is Draft.
Active Option to show the status of the plan is Active.
Expired Option to show the status of the plan is Expired.

Methods

addToContracts

global static Set<Id> addToContracts(List<ffbc.PlansService.ContractAddition> additions)

Creates new contract line items from plans.

Input Parameters

Name Type Description
additions List<ffbc.PlansService.ContractAddition> The list of wrappers for the addition criteria to be used such as plan Id, contract Id and start date.

Exceptions Thrown

Value Description
BillingCentralException An exception is thrown if:
- Any of the additions have no plan ID.
- Any of the additions have no contract ID.
- A plan with a given ID is not Active.
- A contract with a given ID is not in Draft status.
- The start date is null.
- The soft date used by a plan is invalid.
- Any of the contract line items would be created with an invalid state.

Return Value

The IDs of the contract line items that were created.

addToUnsavedContracts

global static ffbc.PlansService.AddToUnsavedContractsResult addToUnsavedContracts(List<ffbc.PlansService.UnsavedContractAddition> additions)

Creates new contract line items from plans, and returns the new lines without inserting them. The contracts being added to do not need to have been saved to the database yet. The lines created by this are of the type used by ContractsService.Contract. For example, this can be used when constructing a contract to send to ContractsService.save or ContractsService.saveNewChangeRequest.

Input Parameters

Name Type Description
additions List<ffbc.PlansService.UnsavedContractAddition> List of options for controlling the additions. Each one represents a contract and specifies the plan to add to it.

Exceptions Thrown

Value Description
BillingCentralException An exception is thrown if:
- The additions are null.
- Any of the additions have no plan ID.
- A plan with a given ID is not "Active".
- A plan ID is specified for which no plan exists.
- A plan with a given ID contains lines without products.
- The soft date used by a plan is invalid.

Return Value

A response containing results for each contract, mapped by the unique ID specified for that contract in the 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.

/**
 * This example shows how you can combine ffbc.PlansService.addToUnsavedContracts with methods from the Contracts
 * service to create a change request to upsell a contract with two plans.
 */

//These parameters would specify the contract which is being upsold, and the two plans to be added to it.
Id contractId;
Id planId1;
Id planId2;

//Create the change request without saving it to the database.
ffbc.ContractsService.Contract changeRequest = ffbc.ContractsService.createChangeRequestObject(contractId);

//Create the request from the contract data.
ffbc.PlansService.UnsavedContractAddition additionRequest = new ffbc.PlansService.UnsavedContractAddition();
additionRequest.UniqueId = contractId;
additionRequest.ContractStartDate = changeRequest.StartDate;
additionRequest.ContractEndDate = changeRequest.EndDate;
additionRequest.ContractFirstBillDate = changeRequest.FirstBillDate;
additionRequest.ContractCurrencyIsoCode = changeRequest.CurrencyIsoCode;
additionRequest.ContractName = changeRequest.ContractName;

//Create the requests to add the desired plans.
ffbc.PlansService.PlanToAdd planAddition1 = new ffbc.PlansService.PlanToAdd(planId1);
additionRequest.PlansToAdd.add(planAddition1);
ffbc.PlansService.PlanToAdd planAddition2 = new ffbc.PlansService.PlanToAdd(planId2);
additionRequest.PlansToAdd.add(planAddition2);

//Get the contract lines which are created as a result of adding these plans to the change request.
ffbc.PlansService.AddToUnsavedContractsResult result = ffbc.PlansService.addToUnsavedContracts(new List<ffbc.PlansService.UnsavedContractAddition>{additionRequest});
List<ffbc.ContractsService.ContractLineItem> linesCreated = result.ResultsByUniqueId.get(contractId).LineItems;

//Add the lines to the change request and send it back to ffbc.ContractsService.saveNewChangeRequest to be saved on the database.
for (ffbc.ContractsService.ContractLineItem line : linesCreated)
{
    changeRequest.addLineItem(line);
}
ffbc.ContractsService.saveNewChangeRequest(changeRequest);

convertToContracts

global static Set<Id> convertToContracts(List<ffbc.PlansService.ContractConversion> conversions)

Creates new contracts from plans.

Input Parameters

Name Type Description
conversions List<ffbc.PlansService.ContractConversion> List of wrappers for the conversion criteria to be used when creating contracts such as plan ID, account ID, name and start date.

Exceptions Thrown

Value Description
BillingCentralException An exception is thrown if:
- Any of the conversions do not have an account ID.
- Any of the conversions do not have a plan ID.
- A plan for the given ID is not Active.
- The start date is null.
- The soft date used by a plan is invalid.

Return Value

The Ids of the created contracts.

deletePlans

global static void deletePlans(Set<Id> planIds)

Deletes the plans with the given IDs.

Input Parameters

Name Type Description
planIds Set<Id> The IDs of the plans to be deleted.

getAllActivePlanSummaries

global static List<ffbc.PlansService.PlanSummary> getAllActivePlanSummaries()

Retrieves a list of summarised Plan details from all active plans.

Return Value

A list of summarised active Plans

load

global static List<ffbc.PlansService.Plan> load(Set<Id> planIds)

Retrieves the plans from the IDs provided and returns a wrapper for each plan and its line items.

Input Parameters

Name Type Description
planIds Set<Id> The plans to query.

Return Value

The wrapper for each plan and its list of line items.

save

global static Set<Id> save(List<ffbc.PlansService.Plan> plansToSave)

Saves new or existing plans and plan line items. Existing plan line items which are not included in the parent plan are deleted.

Input Parameters

Name Type Description
plansToSave List<ffbc.PlansService.Plan> The list of plans to be saved including their plan line items.

Exceptions Thrown

Value Description
BillingCentralException An exception is thrown if any of the records have invalid data, or if an existing plan line item is associated with a plan other than its parent.

Return Value

The set of IDs of plans that have been saved.

ffbc.PlansService.AddToContractResult

global with sharing class AddToContractResult

This class represents the results for a single contract by PlansService.addToUnsavedContracts. All line items which have been created are stored on this object.

Properties

Name Type Description
LineItems List<ffbc.ContractsService.ContractLineItem> Read only. The new contract line items which have been created for this contract.

ffbc.PlansService.AddToUnsavedContractsResult

global with sharing class AddToUnsavedContractsResult

This class represents the results of a single call to PlansService.addToUnsavedContracts. All results for all plans and contracts are grouped under one of these.

Properties

Name Type Description
ResultsByUniqueId Map<String, ffbc.PlansService.AddToContractResult> Read only. The results for each contract which had plans added to it by this process. These are mapped by the unique IDs which the contracts were identified by on the request sent to the service.

ffbc.PlansService.ContractAddition

global with sharing class ContractAddition

This class wraps the criteria to be used when adding plans to contracts.

Properties

Name Type Description
ContractId Id The ID of the Contract.
PlanId Id The ID of the Plan.
StartDate Date The Start Date of the Contract Line Items to be created.
FirstBillDate Date The First Bill Date of the Contract Line Items to be created. If this is not specified, the First Bill Date of the Contract is used.

Methods

ContractAddition

global ContractAddition()

The default constructor for a ContractAddition object.

ffbc.PlansService.ContractConversion

global with sharing class ContractConversion

This class sets the data required to convert a plan to a contract.

Properties

Name Type Description
PlanId Id The ID of the Plan.
AccountId Id The ID of the Account.
Name String The Contract Name.
StartDate Date The Start Date of the Contract.
FirstBillDate Date The First Bill Date of the Contract.

Methods

ContractConversion

global ContractConversion()

The default constructor for a ContractConversion object.

ffbc.PlansService.Plan

global with sharing class Plan

This class models a plan with plan line items, including fields that are relevant to plan creation, viewing and editing. 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

Name Type Description
Id Id The ID of the Plan.
Name String The Plan Name.
CompanyId Id The Company ID of the Plan SObject being represented.
Description String The Description of the Plan SObject being represented.
NumberOfTerms Integer The Number Of Billing Terms of the Plan SObject being represented.
IsContinuous Boolean The Continuous status of the Plan SObject being represented.
TermId Id The Billing Term ID of the Plan SObject being represented.
StartDate Date The Start Date of the Plan SObject being represented.
EndDate Date The End Date of the Plan SObject being represented.
Status ffbc.PlansService.Status The Status of the Plan SObject being represented.
CurrencyIsoCode String The Currency ISO Code of the Plan SObject being represented.
LineItems List<ffbc.PlansService.PlanLineItem> The Plan Line Items related to the Plan SObject being represented. See PlanLineItem for details of that object.
TotalValue Decimal The Total Value of the Plan SObject being represented.
AnnualValue Decimal The Annual Value of the Plan SObject being represented.
OneOffValue Decimal The One-off Value of the Plan SObject being represented.
TermValue Decimal The Billing Term Value of the Plan SObject being represented.

Methods

Plan

global Plan()

The default constructor for a Plan object.

ffbc.PlansService.PlanLineItem

global with sharing class PlanLineItem

This class models a Plan Line Item, including fields that are relevant to plan creation, viewing and editing. 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

Name Type Description
Id Id The ID of the Plan Line Item SObject being represented.
ProductId Id The Product ID of the Plan Line Item SObject being represented.
UnitOfMeasureId Id The Unit of Measure ID of the Plan Line Item SObject being represented.
BillingType ffbc.BillingService.BillingType The Billing Type of the Plan Line Item SObject being represented.
Description String The Description of the Plan Line Item SObject being represented.
UnitPrice Decimal The Unit Price of the Plan Line Item SObject being represented.
Quantity Decimal The Quantity of the Plan Line Item SObject being represented.
ProductName String Read only. The Name of the Product associated with the Plan Line Item SObject being represented.
ProductUrl String Read only. The URL pointing to the product detail page.

Methods

PlanLineItem

global PlanLineItem()

The default constructor for a PlanLineItem object.

ffbc.PlansService.PlanSummary

global with sharing class PlanSummary

This class presents a summarised detail of the Plan object 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

Name Type Description
Id Id Read only. The Salesforce ID of the Plan being summarised
Name String Read only. The Salesforce Name of the Plan being summarised
TotalValue Decimal Read only. The Total Value of the Plan being summarised
CurrencyIsoCode String Read only. The Currency Iso Code of the Plan being summarised

ffbc.PlansService.PlanToAdd

global with sharing class PlanToAdd

This class represents a plan which is to be added to a contract by PlansService.addToUnsavedContracts. It allows you to specify which plan will be added.

Properties

Name Type Description
PlanId Id The ID of the plan to be added.

Methods

PlanToAdd

global PlanToAdd(Id planId)

Constructs a PlanToAdd for a specific plan.

Input Parameters

Name Type Description
planId Id The ID of the plan to be added. This is assigned to the PlanId property.

ffbc.PlansService.UnsavedContractAddition

global with sharing class UnsavedContractAddition

This class represents a request to add plans to a particular contract, for use in PlansService.addToUnsavedContracts. You can specify fields for the contract which affect how the lines are produced, and a list of plans which are to be added to this contract.

Properties

Name Type Description
UniqueId String A unique identifier for the contract to be added to. If the contract exists on the database then the record ID would be an appropriate identifier. This identifies the response which contains lines for this contract.
ContractStartDate Date The start date of the contract to be added to. This determines the start date for new lines which are added to this contract. Lines start either on the contract start date or on the day when the process is run, whichever is latest.
ContractEndDate Date The end date of the contract to be added to. If specified, this determines the end date for new lines which are added to this contract. Lines end either on the contract end date, or their start date plus the length of the contract, whichever is earliest.
ContractFirstBillDate Date The first bill date of the contract to be added to. This sets the first bill date on any lines which are added to this contract.
ContractCurrencyIsoCode String The currency ISO code of the contract to be added to. Leave unspecified if in a single-currency organisation. This validates that the plans which have been selected for this contract are appropriate. Plans in a different currency cannot be allowed to be added to the contract.
ContractName String The name of the contract to be added to. This will be used in any error messages to help you identify which contract has a problem. If this is not specified, the unique ID of the contract is used.
PlansToAdd List<ffbc.PlansService.PlanToAdd> The list of plans which will be added to this contract. The plan line items from all of these plans create new contract line items on the response for this contract.
ProrationPolicyId Id The ID of the proration policy from the contract.

Methods

UnsavedContractAddition

global UnsavedContractAddition()

Constructs an empty addition. This sets PlansToAdd to an empty list, and ContractCurrencyIsoCode to the default currency for your organisation. If you do not use multiple currencies, this will be the only currency available.

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