Billing Central Apex API Developer Reference

ffbc.BillingDocumentsService

global with sharing class BillingDocumentsService

This class provides service functionality for billing documents.

Enums

Status

An enum that represents the valid statuses of billing documents.

Value Description
Draft The document is in draft.
Discarded The document has been discarded.
Complete The document is complete.
Superseded The document has been superseded by a consolidated billing document.

Type

An enum that represents the valid types of billing documents.

Value Description
Invoice The document is an invoice.
CreditNote The document is a credit note.

Methods

complete

global static List<ffbc.BillingDocumentsService.CompleteResponse> complete(Set<Id> billingDocumentIds)

Completes the supplied billing documents by changing their status to Complete and updating the billed data in related contract line items.

Input Parameters

Name Type Description
billingDocumentIds Set<Id> Set of IDs of the billing documents to be completed.

Return Value

List of results for each billing document provided.

completeAndUpdateBilledData

The functionality of this service has been moved into the complete service.

global static List<ffbc.BillingDocumentsService.CompleteResponse> completeAndUpdateBilledData(Set<Id> billingDocumentIds)

Completes the supplied billing documents by changing their status to Complete and updating the billed data in related contract line items.

Input Parameters

Name Type Description
billingDocumentIds Set<Id> Set of IDs of the billing documents to be completed.

Return Value

List of results for each billing document provided.

completeAsync

global static Id completeAsync(Set<Id> billingDocumentIds)

Completes the supplied billing documents asynchronously. After completion, a separate asynchronous job is created to update the billing data of contract line items associated with the billing documents that were successfully completed.

Input Parameters

Name Type Description
billingDocumentIds Set<Id> The IDs of the billing documents to be completed.

Return Value

The ID of the asynchronous process that will complete the billing documents.

convertInvoiceToCreditNote

global static ffbc.BillingDocumentsService.CreditingResponse convertInvoiceToCreditNote(ffbc.BillingDocumentsService.CreditingRequest request)

Converts the supplied billing documents to credit notes. Only Complete invoices can be converted. An error message is returned for each billing document that could not be converted. Once a billing document is converted, the Billing Document Line Item field on related billing schedules is cleared if the option to allow further billing for that invoice was selected.

Input Parameters

Name Type Description
request ffbc.BillingDocumentsService.CreditingRequest Object containing information about the billing documents to be converted including whether further billing is allowed.

Exceptions Thrown

Value Description
DmlException An exception is thrown if the generated credit notes fail to be inserted, or the billing documents fail to be updated.

Return Value

Object containing information about the Convert Invoice to Credit Note process including the credit notes created and the errors that occurred.

convertInvoiceToCreditNoteAndUpdateBilledData

This method has been deprecated, use the convertInvoiceToCreditNote instead.

global static ffbc.BillingDocumentsService.CreditingResponse convertInvoiceToCreditNoteAndUpdateBilledData(ffbc.BillingDocumentsService.CreditingRequest request)

Converts the supplied billing documents to credit notes by copying all the data. Only Complete invoices can be converted. An error message is returned for each billing document that could not be converted. Once a billing document is converted, the Billing Document Line Item field on related schedules is cleared if the option to allow further billing for that invoice was selected. In addition, an asynchronous process is started to update the billed data in related contract line items.

Input Parameters

Name Type Description
request ffbc.BillingDocumentsService.CreditingRequest Object containing information about the billing documents to be converted including whether further billing is allowed.

Exceptions Thrown

Value Description
DmlException An exception is thrown if the generated credit notes fail to be inserted, or the billing documents fail to be updated.

Return Value

Object containing information about the Convert Invoice to Credit Note process including the credit notes created and the errors that occurred.

convertInvoiceToCreditNoteAsync

global static Id convertInvoiceToCreditNoteAsync(ffbc.BillingDocumentsService.CreditingRequest request)

Converts the supplied billing documents to credit notes by copying all the data asynchonously. Only Complete invoices can be converted. An error message is returned for each billing document that could not be converted. Once a billing document is converted, the Billing Document Line Item field on related billing schedules is cleared if the option to allow further billing for that invoice was selected.

Input Parameters

Name Type Description
request ffbc.BillingDocumentsService.CreditingRequest Object containing information about the billing documents to be converted including whether further billing is allowed.

Return Value

The ID of the asynchronous process that is to convert the billing documents.

deleteBillingDocuments

global static void deleteBillingDocuments(Set<Id> billingDocumentIds)

Deletes the billing documents with the IDs provided.

Input Parameters

Name Type Description
billingDocumentIds Set<Id> The IDs of the billing documents to be deleted.

discard

global static ffbc.BillingDocumentsService.DiscardResponse discard(Set<Id> billingDocumentIds)

Discards the billing documents supplied by changing their Document Status to Discarded. The related billing schedules are deleted or their link to the billing document is removed. In addition, the related billing document line items are deleted.

Input Parameters

Name Type Description
billingDocumentIds Set<Id> Set of IDs of the billing documents to be discarded.

Return Value

Response containing the IDs of discarded Billing Documents and the errors that occurred.

discardAsync

global static Id discardAsync(Set<Id> billingDocumentIds)

Discards the billing documents supplied by changing their Document Status to Discarded. The related billing schedules are deleted or their link to the billing document is removed. In addition, the related billing document line items are deleted. These actions are carried out by an asynchronous process.

Input Parameters

Name Type Description
billingDocumentIds Set<Id> Set of IDs of the billing documents to be discarded.

Return Value

The ID of the asynchronous process that is to discard the billing documents.

email

global static Messaging.SendEmailResult email(Id billingDocumentId, Id billingContactId)

Sends the billing document to the billing contact by email using the Messaging.sendEmail method and updates the Date Issued field of the billing document if successful. This method can be called a maximum number of ten times in a single execution context.

Input Parameters

Name Type Description
billingDocumentId Id ID of the fferpcore__BillingDocument__c record to be emailed.
billingContactId Id ID of the contact who is to receive the billing document by email.

Exceptions Thrown

Value Description
BillingCentralException An exception is thrown if no billing document exists with the given ID or no email template exists for the document type.
BillingCentralException An exception is thrown if the billing document status is Discarded.

Return Value

The response from the email service. See Messaging.SendEmailResult for more details.

getAdditionalFieldMetadata

global static List<ffbc.FieldMetadata> getAdditionalFieldMetadata()

Retrieves metadata for additional billing document and billing document line item fields that are visible when viewing, creating and editing a billing document.

Return Value

Object containing basic field information for the additional fields.

getTax

global static ffbc.BillingDocumentsService.GetTaxResponse getTax(ffbc.BillingDocumentsService.GetTaxRequest request)

Calculates tax for the documents provided and returns the calculated tax data.

Input Parameters

Name Type Description
request ffbc.BillingDocumentsService.GetTaxRequest The request containing the documents for which to calculate tax.

Exceptions Thrown

Value Description
BillingCentralException An exception is thrown if the request contains invalid data or if the user does not have sufficient access to the necessary objects to calculate tax.

Return Value

A response containing results of calculating tax for each document.

getTotals

global static List<ffbc.BillingDocumentsService.Total> getTotals(Set<Id> billingDocumentIds)

Returns a list of totals for the billing documents supplied.

Input Parameters

Name Type Description
billingDocumentIds Set<Id> Set of IDs of the billing documents for which the totals need to be calculated.

Return Value

List of Totals that contains the billing document ID and its calculated totals.

load

global static List<ffbc.BillingDocumentsService.BillingDocument> load(Set<Id> billingDocumentIds)

Retrieves the billing documents from the IDs provided and returns a wrapper for each billing document. The additional fields to be shown on the enhanced Billing Document page are retrieved.

Input Parameters

Name Type Description
billingDocumentIds Set<Id> The billing documents to query.

Return Value

The wrappers for the billing documents.

save

global static Set<Id> save(List<ffbc.BillingDocumentsService.BillingDocument> documentsToSave)

Saves new or existing billing documents and billing document line items. Billing document line items that belong to the billing documents provided but are not included in the wrapper objects provided are deleted.

Input Parameters

Name Type Description
documentsToSave List<ffbc.BillingDocumentsService.BillingDocument> The list of billing documents to be saved.

Exceptions Thrown

Value Description
BillingCentralException An exception is thrown if a billing document or billing document line item is invalid. An exception is thrown if an error occurs when setting any custom field values which have been specified.

Return Value

The set of IDs of billing documents that have been saved.

updateBilledDataOnRelatedContractLines

global static void updateBilledDataOnRelatedContractLines(Set<Id> billingDocumentIds)

Updates the total billed value on the related contract line items. You can use this method to update the Total Billed and Billed To fields of related contract line items for complete billing documents. Billing documents are ignored if they are already complete and the billed data in related contract line items is up to date.

Input Parameters

Name Type Description
billingDocumentIds Set<Id> Set of IDs of the billing documents for which to update the Total Billed field of related contract line items.

validateForComplete

global static ffbc.BillingDocumentsService.ValidateCompleteResponse validateForComplete(ffbc.BillingDocumentsService.ValidateCompleteRequest request)

Validates that the billing documents supplied can be completed.

Input Parameters

Name Type Description
request ffbc.BillingDocumentsService.ValidateCompleteRequest Object containing information about the billing documents to be validated for completion.

Return Value

Object containing information about the Validate for Complete process including valid billing documents and the errors that occurred.

ffbc.BillingDocumentsService.BillingDocument

global with sharing class BillingDocument

This models a billing document, including fields that are relevant to creating, viewing and editing.

Properties

Name Type Description
Id Id The ID of the Billing Document SObject being represented.
Name String Read only. The Name of the Billing Document SObject being represented.
ContractId Id The ID of the contract associated with the Billing Document SObject being represented.
AccountId Id The ID of the account associated with the Billing Document SObject being represented.
CompanyId Id The ID of the company associated with the Billing Document SObject being represented.
Description String The Description of the Billing Document SObject being represented.
DocumentDate Date The Document Date of the Billing Document SObject being represented.
DueDate Date The Due Date of the Billing Document SObject being represented.
Status ffbc.BillingDocumentsService.Status Read only. The Status of the Billing Document SObject being represented.
Type ffbc.BillingDocumentsService.Type The Document Type of the Billing Document SObject being represented.
CustomerReference String The Customer Reference of the Billing Document SObject being represented.
DateIssued Date The Date Issued of the Billing Document SObject being represented.
CurrencyIsoCode String The CurrencyIsoCode of the Billing Document SObject being represented.
BillingAccountName String The Billing Account name of the Billing Document SObject being represented.
BillingStreet String The Billing Street of the Billing Document SObject being represented.
BillingCity String The Billing City of the Billing Document SObject being represented.
BillingState String The Billing State of the Billing Document SObject being represented.
BillingPostalCode String The Billing Zip/Postal Code of the Billing Document SObject being represented.
BillingCountry String The Billing Country of the Billing Document SObject being represented.
ShippingAccountName String The Shipping Account name of the Billing Document SObject being represented.
ShippingStreet String The Shipping Street of the Billing Document SObject being represented.
ShippingCity String The Shipping City of the Billing Document SObject being represented.
ShippingState String The Shipping State of the Billing Document SObject being represented.
ShippingPostalCode String The Shipping Zip/Postal Code of the Billing Document SObject being represented.
ShippingCountry String The Shipping Country of the Billing Document SObject being represented.
ContractName String Read only. The Contract Name of the contract associated with the Billing Document SObject being represented.
ContractNumber String Read only. The Contract Number of the contract associated with the Billing Document SObject being represented.
HeaderText String The Header Text of the Billing Document SObject being represented.
FooterText String The Footer Text of the Billing Document SObject being represented.
RelatedDocumentId Id Read only. The invoice or credit note related to the Billing Document SObject being represented.
RelatedDocumentType ffbc.BillingDocumentsService.Type Read only. The type to which the related document belongs for the Billing Document SObject being represented.
LineItems List<ffbc.BillingDocumentsService.BillingDocumentLineItem> The Billing Document Line Items associated with the Billing Document SObject being represented.
CustomFields List<ffbc.CustomFieldsService.Field> The additional fields to be displayed on the enhanced Billing Document Detail page. The fields and their order are defined by the field set specified in the 'Enhanced Billing Doc Field Set' setting of the Billing Central Settings custom setting. Read-only fields such as formulas, roll up summaries and system fields, as well as field paths which traverse related objects, are treated as read-only and should not be included in a call to saveBillingDocuments. When specifying custom fields from packages other than Billing Central, the namespace prefix must be included.

Methods

BillingDocument

global BillingDocument()

The default constructor for a Billing Document object.

ffbc.BillingDocumentsService.BillingDocumentLineItem

global with sharing class BillingDocumentLineItem

This models a billing document line item, including fields that are relevant to creating, viewing and editing.

Properties

Name Type Description
Id Id The ID of the Billing Document Line Item SObject being represented.
Name String Read only. The name of the Billing Document Line Item SObject being represented.
UnitPrice Decimal The unit price of the Billing Document Line Item SObject being represented.
Quantity Decimal The quantity of the Billing Document Line Item SObject being represented.
UnitOfMeasureId Id The ID of the unit of measure associated with the Billing Document Line Item SObject being represented.
Description String The description of the Billing Document Line Item SObject being represented.
PlanId Id The ID of the plan associated with the Billing Document Line Item SObject being represented.
PlanName String Read only. The name of the plan associated with the Billing Document Line Item SObject being represented.
PlanUrl String Read only. The URL pointing to the plan detail page.
ProductId Id The ID of the product associated with the Billing Document Line Item SObject being represented.
ProductName String Read only. The name of the product associated with the Billing Document Line Item SObject being represented.
ProductUrl String Read only. The URL pointing to the product detail page.
TaxCode1Id Id The ID of a tax code associated with the Billing Document Line Item SObject being represented.
TaxRate1 Decimal A rate of tax to apply to the Billing Document Line Item SObject being represented.
TaxValue1 Decimal The value of the tax associated with a single tax code and rate on the Billing Document Line Item SObject being represented.
TaxCode2Id Id The ID of a tax code associated with the Billing Document Line Item SObject being represented.
TaxRate2 Decimal A rate of tax to apply to the Billing Document Line Item SObject being represented.
TaxValue2 Decimal The value of the tax associated with a single tax code and rate on the Billing Document Line Item SObject being represented.
TaxCode3Id Id The ID of a tax code associated with the Billing Document Line Item SObject being represented.
TaxRate3 Decimal A rate of tax to apply to the Billing Document Line Item SObject being represented.
TaxValue3 Decimal The value of the tax associated with a single tax code and rate on the Billing Document Line Item SObject being represented.
NetValueOverride Decimal The value with which to override the Net Value.
CustomFields List<ffbc.CustomFieldsService.Field> The additional fields to be displayed on the enhanced Billing Document Detail page. The fields and their order are defined by the field set specified in the 'Enhanced Billing Doc Line Field Set' setting of the Billing Central Settings custom setting. Read-only fields such as formulas, roll up summaries and system fields, as well as field paths which traverse related objects, are treated as read-only and should not be included in a call to save. When specifying custom fields from packages other than Billing Central, the namespace prefix must be included.
BillingPeriodStartDate Date The start date of the billing period.
BillingPeriodEndDate Date The start date of the billing period.

Methods

BillingDocumentLineItem

global BillingDocumentLineItem()

The default constructor for a billing document line item object.

ffbc.BillingDocumentsService.CompleteResponse

global with sharing class CompleteResponse

This class wraps a response for a request to complete a billing document.

Properties

Name Type Description
Id Id Read only. ID of the billing document associated with this response.
ErrorMessage String Read only. The error message that occurs if the request to complete the billing document is unsuccessful. If the request is successful, it is null.

ffbc.BillingDocumentsService.CreditingRequest

global with sharing class CreditingRequest

This class provides the parameters for converting invoices to credit notes.

Methods

CreditingRequest

global CreditingRequest()

The default constructor for a CreditingRequest object.

addBillingDocument

global void addBillingDocument(Id billDocId, Boolean allowConvertedInvoiceToBeRebilled)

Adds a billing document to be processed.

Input Parameters

Name Type Description
billDocId Id ID of an invoice billing document to be converted to a credit note.
allowConvertedInvoiceToBeRebilled Boolean Flag that indicates whether the Billing Document Line Item field on related billing schedules is to be cleared to allow the document to be rebilled.

addCreditingRequestItem

global void addCreditingRequestItem(ffbc.BillingDocumentsService.CreditingRequestItem document)

Adds a billing document to be processed. This method supports changing the values of custom fields on the credit note.

Input Parameters

Name Type Description
document ffbc.BillingDocumentsService.CreditingRequestItem A specification of how to credit the billing document.

ffbc.BillingDocumentsService.CreditingRequestItem

global class CreditingRequestItem

This class contains the information required to credit one billing document.

Properties

Name Type Description
DocumentId Id ID of an invoice billing document to be converted to a credit note.
AllowRebilling Boolean Flag that indicates whether the Billing Document Line Item field on related billing schedules is to be cleared to allow the document to be rebilled.
FieldOverrides List<ffbc.CustomFieldsService.Field> List of fields and their values to be set on the header of the credit note.

Methods

CreditingRequestItem

global CreditingRequestItem(Id DocumentId, Boolean AllowRebilling)

The constructor for a CreditingRequestItem object.

addFieldOverrides

global void addFieldOverrides(List<ffbc.CustomFieldsService.Field> fieldOverrides)

Adds a list of custom fields to the crediting request item.

Input Parameters

Name Type Description
fieldOverrides List<ffbc.CustomFieldsService.Field> List of custom fields to to be added.

ffbc.BillingDocumentsService.CreditingResponse

global with sharing class CreditingResponse extends Response

This class is returned by methods which convert invoices to credit notes. You can use this class to discover if there were any errors when converting invoice billing documents to credit notes and to get a list of the IDs of documents that were converted to a credit note.

This class extends ffbc.Response

Properties

Name Type Description
CreditNotes List<Id> Read only. The list of credit notes that were converted from invoice billing documents.

ffbc.BillingDocumentsService.DiscardResponse

global with sharing class DiscardResponse extends Response

This class is returned by the discard method. You can use this class to discover if there were any errors when discarding billing documents, and to get a list of the IDs of the billing documents that were discarded.

This class extends ffbc.Response

Properties

Name Type Description
BillDocumentsDiscarded Set<Id> Read only. The list of billing documents that were discarded.

ffbc.BillingDocumentsService.GetTaxRequest

global with sharing class GetTaxRequest

Contains the parameters required for calculating tax on multiple documents.

Properties

Name Type Description
Documents List<ffbc.BillingDocumentsService.TaxDocument> Required. The list of documents that are to have tax calculated.

Methods

GetTaxRequest

global GetTaxRequest()

The default constructor for this object.

ffbc.BillingDocumentsService.GetTaxResponse

global with sharing class GetTaxResponse

The response returned when calculating tax on a document.

Properties

Name Type Description
Results List<ffbc.BillingDocumentsService.GetTaxResult> A list of tax calculation results for each document that had tax calculated. The results for each document are returned in the same order as they were supplied in the request.

ffbc.BillingDocumentsService.GetTaxResult

global with sharing class GetTaxResult

A result from the tax calculation process for a taxable document.

Properties

Name Type Description
Lines List<ffbc.BillingDocumentsService.GetTaxLineResult> A list of tax results for each line in the document. If tax calculation fails, no lines are returned.
Errors List<String> A list of errors generated while attempting to calculate tax for each of the document lines. The tax calculation was successful only if there are no errors.

ffbc.BillingDocumentsService.GetTaxLineResult

global with sharing class GetTaxLineResult

Contains the calculated tax codes, rates, and values for a document line.

Properties

Name Type Description
LineId String The line name or number that uniquely identifies the line on the document. This corresponds to the line ID specified in the request.
TaxCode1Id Id The ID for the first ERP tax code derived for the document line.
TaxRate1 Decimal The first tax rate that was calculated for the document line.
TaxValue1 Decimal The first tax value that was calculated for the document line.
TaxCode2Id Id The ID for the second ERP tax code derived for the document line.
TaxRate2 Decimal The second tax rate that was calculated for the document line.
TaxValue2 Decimal The second tax value that was calculated for the document line.
TaxCode3Id Id The ID for the third ERP tax code derived for the document line.
TaxRate3 Decimal The third tax rate that was calculated for the document line.
TaxValue3 Decimal The third tax value that was calculated for the document line.

ffbc.BillingDocumentsService.TaxDocument

global with sharing class TaxDocument

A document for which you can calculate tax.

Properties

Name Type Description
AccountId Id The ID of the account associated with the document.
CompanyId Id The ID of the ERP company associated with the document.
Lines List<ffbc.BillingDocumentsService.TaxDocumentLine> Required. The lines that belong to the document.
DocumentDate Date Required. The document date.

Methods

TaxDocument

global TaxDocument()

The default constructor for this object.

ffbc.BillingDocumentsService.TaxDocumentLine

global with sharing class TaxDocumentLine

A line on a taxable document.

Properties

Name Type Description
LineId String The line name or ID that uniquely identifies the line on the document.
ProductId Id The ID of the product associated with the document line.
NetValue Decimal Required. The net value of this line.

Methods

TaxDocumentLine

global TaxDocumentLine()

The default constructor for this object.

ffbc.BillingDocumentsService.Total

global with sharing class Total

This class contains the totals for the billing document.

Properties

Name Type Description
Id Id Read only. The ID of the billing document for which totals have been calculated.
NetTotal Decimal Read only. Total net value for the billing document line items attached to the billing document.
TaxTotal Decimal Read only. Total tax value for the billing document line items attached to the billing document.
DocTotal Decimal Read only. Total document value for the billing document line items attached to the billing document.

ffbc.BillingDocumentsService.ValidateCompleteRequest

global with sharing class ValidateCompleteRequest

This class wraps a request to validate the completion of billing documents.

Properties

Name Type Description
BillingDocumentIds Set<Id> The list of billing documents that are to be validated.

Methods

ValidateCompleteRequest

global ValidateCompleteRequest()

The default constructor for a ValidateCompleteRequest object.

ffbc.BillingDocumentsService.ValidateCompleteResponse

global with sharing class ValidateCompleteResponse extends Response

This class wraps a response for a request to validate the completion of a billing document.

This class extends ffbc.Response

Properties

Name Type Description
BillingDocumentIds List<Id> Read only. The list of billing documents that are valid for completion.
© Copyright 2009–2019 FinancialForce.com, inc. All rights reserved. Various trademarks held by their respective owners.