As indicated earlier in this document, AvaTax supports the following document types for beverage alcohol transactions:SalesInvoice
andReturnInvoice
.
This example shows how to refund a transaction using the CreateTransaction API with aReturnInvoice
document type. When refunding a transaction, AvaTax expects a positive quantity and a negative amount.
Keep in mind that when an item is returned, you still want to register refunded transactions using the RegisterShipment endpoint in order to adjust the volume metrics. Unlike the previous refund example, this example usesDELETE
instead of withPUT
. This voids the original transaction, so no record of the original sale is kept.
The following transaction shows a request for returning packaged alcohol wine.
curl
-X POST
-H 'Accept: application/json'
-H 'Authorization: Basic aHR0cHdhdQNoOmY='
-H 'Content-Type: application/json'
--data '{
"type":"ReturnInvoice",
"code": "123434390853",
"companyCode":"DEFAULT",
"customerCode":"13434",
"date":"2020-12-30",
"commit":true,
"lines": [
{
"number":"1",
"quantity":10,
"amount":-100,
"taxCode":"PA2020300",
"itemCode":"12345",
"description":"Packaged alcohol wine",
"parameters":[
{
"name":"AlcoholRouteType",
"value":"DTC"
},
{
"name":"RecipientName",
"value":"John Smith"
},
{
"name":"ContainerSize",
"value":"0.75",
"unit":"Litre"
},
{
"name":"AlcoholContent",
"value":"12.5",
"unit":"Percentage"
},
{
"name":"PackSize",
"value":"12",
"unit":"Count"
},
{
"name":"NetVolume",
"value":"750",
"unit":"Millilitre"
}
]
}
],
"addresses": {
"shipFrom":{
"line1":"2100 S Floyd St",
"city":"Louisville",
"region":"KY",
"country":"US",
"postalCode":"40292"
},
"shipTo":{
"line1":"255 S King St",
"line2":"Suite 1200",
"city":"Seattle",
"region":"WA",
"country":"US",
"postalCode":"98104"
}
}
}'
'https://sandbox-rest.avatax.com/api/v2/transactions/create'
Call the RegisterShipment endpoint withDELETE
to adjust volume metrics appropriately and void the original transaction. In the registration request, be sure to include yourcompanyCode
and the transactioncode
. In the transaction above, thecompanyCode
isDEFAULT
, and the transactioncode
is123434390853
. And by usingDELETE
, no record will be kept of the original transaction. Also, because this is a return invoice, be sure to includedocumentType=ReturnInvoice
in the request. You will receive an "Entity not found" error if you omit this from the request because the document type defaults toSalesInvoice
.
TIP: Only call the RegisterShipment endpoint when an item is returned. Do not call this endpoint for monetary-only refunds, where the customer still has the product.
curl
-X DELETE
-H 'Accept: application/json'
-H 'Authorization: Basic aHR0cHdhdQNoOmY='
-H 'Content-Type: application/json'
'https://sandbox-rest.avatax.com/api/v2/companies/DEFAULT/transactions/123434390853/shipment/registration?documentType=ReturnInvoice'
The response returns 204 upon success.