Newer Version Available
InvoiceAPI Class
Namespace
blng
Usage
InvoiceAPI Methods
The InvoiceAPI class includes these methods.
creditInvoice(invoiceId, action)
Signature
global static String creditInvoice(Id invoiceId, String action)
Parameters
- invoiceId
- Type: String
- ID of the invoice.
- action
- Type: String
-
Action to perform against the invoice. For example, Credit or Cancel and Rebill.
Valid values are:
- Credit—Creates a credit note equal to the invoice’s total balance. The credit note contains credit note lines that are allocated in full to each of the invoice lines. The invoice must be in the Posted status.
-
Cancel and Rebill—
Creates a credit note equal to the invoice’s total balance. The credit note contains credit note lines that are allocated in full to each of the invoice lines.
If the invoice is in Posted status, then this action creates a credit note equal to the invoice’s total balance. The credit note contains credit note lines that are allocated in full to each of the invoice lines. This action also reverts the billing fields of an order product to their previous values. The status of the invoice is changed to Rebilled.
If the invoice is in Draft status, then Salesforce Billing sets the status to Cancelled for the invoice and all invoice lines.
Return Value
Type: String
Usage
Keep these considerations in mind when using this method.
- The invoice must not have any allocations before the credit invoice action is requested.
- The associated CreditNote, CreditNoteLine, and CreditNoteAllocation records are created against the posted invoice for both Credit and Cancel and Rebill actions. The status of the invoice is changed to Credited.
Example
1blng.InvoiceAPI.creditInvoice('aF15t000000GmjKCAS', 'Cancel and Rebill');1blng.InvoiceAPI.creditInvoice('aF15t000000GmjKCAS', 'Credit');