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.
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
Exceptions Thrown
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
Exceptions Thrown
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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | /**
* 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.
*/
Id contractId;
Id planId1;
Id planId2;
ffbc.ContractsService.Contract changeRequest = ffbc.ContractsService.createChangeRequestObject(contractId);
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;
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);
ffbc.PlansService.AddToUnsavedContractsResult result = ffbc.PlansService.addToUnsavedContracts( new List<ffbc.PlansService.UnsavedContractAddition>{additionRequest});
List<ffbc.ContractsService.ContractLineItem> linesCreated = result.ResultsByUniqueId.get(contractId).LineItems;
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
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
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
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
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
Exceptions Thrown
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
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
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
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
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.
Properties
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.
Properties
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
Properties
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
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
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
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.
|