Newer Version Available

This content describes an older version of this product. View Latest

REST API for Converting Invoice Lines with Negative Balances

Use the REST API service blng__NegativeInvoiceToCreditNoteAction to evaluate invoices in bulk and create credit notes for each invoice containing invoice lines with negative balances.

This object is available in API version 48.0 and later.

Supported REST HTTP Methods

URI
/services/data/XX.X/actions/custom/apex/blng__NegativeInvoiceToCreditNoteAction
Formats
JSON, XML
HTTP Methods
POST
Authentication
Authorization: Bearer token

Parameters

Parameter Description
invoiceId
Type
ID
Description
The REST service evaluates this invoice for invoice lines with a negative balance. For each invoice, it creates a credit note containing one credit note line for each negative invoice line, unless an error occurs during credit note line creation. If even one of the -ve invoice line conversions errors out, all of them fail. No partial conversion can occur.
Each credit note line has a balance that’s the positive equivalent of the corresponding negative invoice line. The credit note lines are unallocated, so users must manually allocate them as needed.

Response Body

Parameter Description
invoiceId
Type
String
Description
The invoice that the REST service evaluated.
isSuccess
Type
Boolean
Description
Indicates whether the invoice was successfully evaluated (True) or could not be evaluated (False).
errorMessage
Type
String
Description
Error message indicating why the REST service couldn’t convert any negative invoice lines on the provided invoice. For example, the invoice did not have any negative invoice lines.

Samples

Sample Request Body
This payload passes two invoice IDs to the negative invoice line conversion service.
1{
2"inputs":[
3        {
4            "invoiceId":"a1oS0000001NEixIAG"
5        },
6        {
7            "invoiceId":"a1oS0000001NEixIAE"
8        }
9    ]
10}
Sample Response Body
In this case, we receive a response with one error because the sample payload contained an invoice that didn’t have any negative invoice lines.
1[
2    {
3        "actionName" : "blng__NegativeInvoiceToCreditNoteAction",
4        "errors" : null,
5        "isSuccess" : true,
6        "outputValues" : {
7            "errorMessage" : "Null"
8            "invoiceId" : "a1oS0000001NEixIAG"
9            "isSuccess" : "true" 
10        }
11    }
12
13 {
14        "actionName" : "blng__NegativeInvoiceToCreditNoteAction",
15        "errors" : null,
16        "isSuccess" : true,
17        "outputValues" : {
18            "errorMessage" : "The invoice does not have any negative invoice lines."
19            "invoiceId" : "a1oS0000001NEixIAE"
20            "isSuccess" : "false" 
21        }
22    }
23
24]