ffbc.BillingDocumentsService
global with sharing class BillingDocumentsService
This class provides service functionality for billing documents.
This class contains deprecated items.
Enums
Status
an enum that represents the valid statuses of billing documents.
Draft |
The document is in draft. |
ReadyForReview |
The document is ready for review. |
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.
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
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
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
Exceptions Thrown
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
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
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.
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. |
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
Exceptions Thrown
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
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
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.
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. |
validateForComplete
global static ffbc.BillingDocumentsService.ValidateCompleteResponse validateForComplete(ffbc.BillingDocumentsService.ValidateCompleteRequest request)
Validates that the billing documents supplied can be completed.
Input Parameters
Return Value
Object containing information about the Validate for Complete process including valid billing documents and the errors that occurred.
Deprecated
The following items are deprecated and not supported for use. We recommend that you stop using these items to avoid exceptions.
Properties
EXTERNAL_TAX_STATUS_CALCULATED |
String |
|
Do not use. |
EXTERNAL_TAX_STATUS_NOT_CALCULATED |
String |
|
Do not use. |
EXTERNAL_TAX_STATUS_FINALIZED |
String |
|
Do not use. |
Methods
completeAndUpdateBilledData
Deprecated: 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
billingDocumentIds |
Set<Id> |
Set of IDs of the billing documents to be completed. |
Return Value
List of results for each billing document provided.
convertInvoiceToCreditNoteAndUpdateBilledData
Deprecated: 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
Exceptions Thrown
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.
ffbc.BillingDocumentsService.BillingDocument
global with sharing 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 with sharing 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. |
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. |
CompanySiteId |
Id |
the id of the company site associated with the billing document line item sobject being represented. |
ShippingStreet |
String |
the shipping street of the billing document line item sobject being represented. |
ShippingCity |
String |
the shipping city of the billing document line item sobject being represented. |
ShippingState |
String |
the shipping state of the billing document line item sobject being represented. |
ShippingPostalCode |
String |
the shipping zip/postal code of the billing document line item sobject being represented. |
ShippingCountry |
String |
the shipping country of 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.
|
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
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
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
ffbc.BillingDocumentsService.CreditingRequestItem
global with sharing class CreditingRequestItem
this class contains the information required to credit one billing document.
Properties
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
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.
Properties
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.
Properties
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
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
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
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
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 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 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 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
AccountId |
Id |
The ID of the account associated with the document.
|
CompanyId |
Id |
The ID of the 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
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
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
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.
Properties
BillingDocumentIds |
List<Id> |
Read only. The list of billing documents that are valid for completion.
|
|