InvoiceAPI Class
Global API Apex class for Salesforce Billing. Contains methods that you can call to cancel and rebill an invoice, or to credit an invoice.
blng
The InvoiceAPI class contains the creditInvoice method, which can be used to cancel and rebill an invoice, or to credit an invoice for a specified invoice ID.
-
Learn more about the methods available with the InvoiceAPI class.
Learn more about the methods available with the InvoiceAPI class.
The InvoiceAPI class includes these methods.
-
creditInvoice(invoiceId, action)
Use this method to cancel or rebill an invoice, or to credit an invoice.
Use this method to cancel or rebill an invoice, or to credit an invoice.
global static String creditInvoice(Id invoiceId, String action)
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—The invoice must be in thePostedstatus. -
Cancel and Rebill—If the invoice is in
Postedstatus, 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 toRebilled.If the invoice is in
Draftstatus, then Salesforce Billing sets the status toCancelledfor the invoice and all invoice lines. This action also sets theInvoice Run Processing Status field of the order products toPending Billingstatus.
Type: String
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
CreditandCancel and Rebillactions. The status of the invoice is changed toCredited.
For more information about Cancel and Rebill, as well as Credit actions, see Issuing Credits.