ffbc.BillingDocumentsService
global with sharing class BillingDocumentsService
This class provides service functionality for billing documents.
Enums
Type
An enum that represents the valid types of billing documents.
Invoice |
The document is an invoice. |
CreditNote |
The document is a credit note. |
Status
An enum that represents the valid statuses of billing documents.
Draft |
The document is in draft. |
Discarded |
The document has been discarded. |
Complete |
The document is complete. |
Methods
complete
global static List<ffbc.BillingDocumentsService.CompleteResponse> complete(Set<Id> billingDocumentIds)
Completes the billing documents supplied by changing their current status to Complete.
Input Parameters
billingDocumentIds |
Set<Id> |
Set of IDs of the billing documents to be completed. |
Return Value
List of results for each billing document provided.
completeAndUpdateBilledData
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
billingDocumentIds |
Set<Id> |
Set of IDs of the billing documents to be completed. |
Return Value
List of results for each billing document provided.
getTotals
global static List<ffbc.BillingDocumentsService.Total> getTotals(Set<Id> billingDocumentIds)
Returns a list of totals for the billing documents supplied.
Input Parameters
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.
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
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
BillingCentralException |
An exception is thrown if no billing document exists with the given ID or no email template exists for the document type. |
Return Value
The response from the email service. See Messaging.SendEmailResult for more details.
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
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
Exceptions Thrown
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.
deleteBillingDocuments
global static void deleteBillingDocuments(Set<Id> billingDocumentIds)
Deletes the billing documents with the IDs provided.
Input Parameters
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
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
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.
convertInvoiceToCreditNoteAndUpdateBilledData
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
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
Return Value
The ID of the asynchronous process that is to convert the billing documents.
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
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.
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.
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
billingDocumentIds |
Set<Id> |
Set of IDs of the billing documents for which to update the Total Billed field of related contract line items. |
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
Return Value
Object containing information about the Convert Invoice to Credit Note process including the credit notes created and the errors that occurred.
ffbc.BillingDocumentsService.CompleteResponse
global class CompleteResponse
This class wraps a response for a request to complete a billing document.
Properties
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.Total
global class Total
This class contains the totals for the billing document.
Properties
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.BillingDocument
global class BillingDocument
This models a billing document, including fields that are relevant to creating, viewing and editing.
Properties
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 class BillingDocumentLineItem
This models a billing document line item, including fields that are relevant to creating, viewing and editing.
Properties
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. |
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. |
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.
|
Methods
BillingDocumentLineItem
global BillingDocumentLineItem()
The default constructor for a billing document line item object.
ffbc.BillingDocumentsService.CreditingRequest
global 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
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. |
ffbc.BillingDocumentsService.CreditingResponse
global 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.
Properties
CreditNotes |
List<Id> |
Read only. The list of credit notes that were converted from invoice billing documents. |
ffbc.BillingDocumentsService.DiscardResponse
global 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.
Properties
BillDocumentsDiscarded |
Set<Id> |
Read only. The list of billing documents that were discarded.
|
|