Entry of a Credit Memo for an Unshipped RMA Order

A point-of-sale (POS) system can create and process credit memos on the Invoices (SO303000) form that contain both of the following types of lines:

  • Lines that have been linked to a return merchandise authorization (RMA) order—that is, a return order of the RM type created on the Sales Orders (SO301000) form
  • Lines that have not been linked to any order

During the creation and processing of such a credit memo, the POS system creates an RMA order, creates a credit memo, adds to the credit memo the lines from the RMA order and other lines, and releases the credit memo.

In this topic, you will implement HTTP requests for the following user scenario. In the online shop, a customer creates an RMA order to buy a small jar of apple jam and to return a box of medium-sized jars of apple jam that the customer previously bought in the store. The customer then decides to procure and return the respective items in the store. Before leaving for the store, the customer decides to also return a large jar of apple jam (also bought in the store); the customer then goes to the store. In the POS system, one sales credit memo is created for the whole operation. The customer is given the difference between the return and sale.

Testing of the Requests

Before you test the code below, you need to do the following to configure your client application and the MYOB Acumatica instance to be used:
  1. Deploy a new MYOB Acumatica instance with the U100 dataset. For details on deploying an instance, see To Deploy an MYOB Acumatica Instance.
  2. To sign in to the instance in the client application, use the tenant name (which you specified when you created the instance) and the HEADOFFICE branch.
  3. If you use Postman as the client application for testing, in the IntegrationDevelopmentGuide.postman_collection.json collection (which is located in the IntegrationDevelopment\Help folder of the Help-and-Training-Examples repository on GitHub), make sure the collection variables have the proper values.
  4. On the Enable/Disable Features (CS100000) form, make sure that the Inventory and Order Management, Lot and Serial Tracking, and Advanced SO Invoices features are enabled.
Tip: In the request examples below, <MYOB Acumatica instance URL> is the URL of the MYOB Acumatica instance (such as https://my.acumatica.com/MyInstance). You can omit the instance name in the URL (such as https://my.acumatica.com) if the instance is installed in the root of the website.

Step 1: Create a Sales Order for the Initially Sold Item

You use the following example of an HTTP request to create a sales order to sell an APJAM32 item (a box of medium-sized jars of apple jam) to the FRUITICO customer.

PUT ?$expand=Details HTTP/1.1
Host: [<Acumatica ERP instance URL>]/entity/Default/23.200.001/SalesOrder
Accept: application/json
Content-Type: application/json

{
    "CustomerID": { "value": "FRUITICO" },
    "Details": [
        {
            "Branch": { "value": "HEADOFFICE" },
            "InventoryID": { "value": "APJAM32" },
            "OrderQty": { "value": 1 },
            "UOM": { "value": "BOX" },
            "WarehouseID": { "value": "WHOLESALE" }
        }
    ]
}

Step 2: Create a Shipment for the First Sales Order

You use the following example of an HTTP request to create a shipment for the sales order. To identify the sales order, you use the values of the key fields (OrderNbr and OrderType) that are received in the HTTP response of the previous step.

POST /SalesOrderCreateShipment HTTP/1.1
Host: [<Acumatica ERP instance URL>]/entity/Default/23.200.001/SalesOrder
Accept: application/json
Content-Type: application/json

{
  "entity":{
    "OrderType": {"value": "SO"},
    "OrderNbr": {"value": "000074"}
  },
  "parameters": {
      "ShipmentDate": { "value": "2023-02-16T00:00:00+03:00" },
      "WarehouseID": { "value": "WHOLESALE" }
  }
}

Step 3: Retrieve the Sales Order Shipment Number

You use the following example of an HTTP request to learn the number of the shipment that you created for the sales order in the previous step.

GET /SO/000074?$expand=Shipments&$select=OrderNbr,Shipments/ShipmentNbr HTTP/1.1
Host: [<Acumatica ERP instance URL>]/entity/Default/23.200.001/SalesOrder
Accept: application/json
Content-Type: application/json

Step 4: Confirm the Shipment

You use the following example of an HTTP request to confirm the shipment that you created in Step 2.

POST /ConfirmShipment HTTP/1.1
Host: [<Acumatica ERP instance URL>]/entity/Default/23.200.001/Shipment
Accept: application/json
Content-Type: application/json

{
  "entity":{
    "ShipmentNbr": {"value": "000072"},
    "ShipmentType":  {"value": "Shipment"}
  },
  "parameters": { }
}

Step 5: Prepare a Sales Invoice for the Shipment

You use the following example of an HTTP request to prepare a sales invoice for the shipment that you created in Step 2.

POST /PrepareInvoice HTTP/1.1
Host: [<Acumatica ERP instance URL>]/entity/Default/23.200.001/Shipment
Accept: application/json
Content-Type: application/json

{
  "entity":{
    "ShipmentNbr": {"value": "000072"},
    "ShipmentType":  {"value": "Shipment"}
  },
  "parameters": { }
}

Step 6: Retrieve the Sales Invoice Number

You use the following example of an HTTP request to learn the number of the sales invoice that you prepared for the shipment in Step 5.

GET ?$expand=Orders&$select=ShipmentNbr,Orders/InvoiceNbr&
    $filter=ShipmentNbr eq '000072' HTTP/1.1
Host: [<Acumatica ERP instance URL>]/entity/Default/23.200.001/Shipment
Accept: application/json
Content-Type: application/json

Step 7: Release the Sales Invoice

You use the following example of an HTTP request to release the sales invoice that you prepared in Step 5.

POST /ReleaseSalesInvoice HTTP/1.1
Host: [<Acumatica ERP instance URL>]/entity/Default/23.200.001/SalesInvoice
Accept: application/json
Content-Type: application/json

{
  "entity" : {
      "ReferenceNbr": {"value": "000137"},
      "Type": {"value": "Invoice"}
      },
  "parameters" : {}
}

Step 8: Create an Order of the RM Type

You use the following example of an HTTP request to create an order of the RM type on the Sales Orders (3010000) form that is intended to return the APJAM32 item that the FRUITICO customer bought earlier. The order also includes the APJAM08 item, which is being sold to the customer.

PUT ?$expand=Details HTTP/1.1
Host: [<Acumatica ERP instance URL>]/entity/Default/23.200.001/SalesOrder
Accept: application/json
Content-Type: application/json

{
    "CustomerID": { "value": "FRUITICO" },
    "OrderType": { "value": "RM" },
    "Details": [
        {
            "Branch": { "value": "HEADOFFICE" },
            "InventoryID": { "value": "APJAM08" },
            "OrderQty": { "value": 1 },
            "UOM": { "value": "PIECE" },
            "WarehouseID": { "value": "WHOLESALE" },
            "AutoCreateIssue": { "value": false }
        },
        {
            "Branch": { "value": "HEADOFFICE" },
            "InventoryID": { "value": "APJAM32" },
            "OrderQty": { "value": -1 },
            "UOM": { "value": "BOX" },
            "WarehouseID": { "value": "WHOLESALE" },
            "AutoCreateIssue": { "value": false }
        }
    ]
}

Step 9: Correct the Order of the RM Type

You use the following example of an HTTP request to set the value of the AutoCreateIssue field of the SalesOrder object to false to prevent the creation of an additional detail line in the sales order of the RM type. You use the id fields to identify both the sales order and the detail line you amend. You received the values of the id fields in the HTTP response in the previous step.

PUT ?$expand=Details HTTP/1.1
Host: [<Acumatica ERP instance URL>]/entity/Default/23.200.001/SalesOrder
Accept: application/json
Content-Type: application/json

{
    "id": "4cd96bb9-41ae-ed11-9e86-9828a61840c3",
    "Details": [
        {
            "id": "53d96bb9-41ae-ed11-9e86-9828a61840c3",
            "AutoCreateIssue": {"value": false}
        }
    ]
}

Step 10: Create a Credit Memo

You use the following example of an HTTP request to create a credit memo. In the credit memo, the item in line 1 of the 000137 invoice is being returned, the item in line 1 of the 000139 sales order of the RM type is being sold, and an APJAM96 item is also being returned.

PUT ?$expand=Details HTTP/1.1
Host: [<Acumatica ERP instance URL>]/entity/Default/23.200.001/SalesInvoice
Accept: application/json
Content-Type: application/json

{
    "CustomerID": {"value": "FRUITICO"},
    "Type": {"value": "Credit Memo"},
    "Hold": {"value": false},
    "Details":
    [
        {
            "OrigInvNbr": { "value": "000137" },
            "OrigInvType": { "value": "Invoice" },
            "OrigInvLineNbr": { "value": 1 },
            "Qty": { "value": 1 }
        },
        {
            "OrderNbr": { "value": "000139" },
            "OrderType": { "value": "RM" },
            "OrderLineNbr": { "value": 1 },
            "Qty": { "value": -1 }
        },
        {
            "Branch": {"value": "HEADOFFICE"},
            "InventoryID": {"value": "APJAM96"},
            "WarehouseID": {"value": "WHOLESALE"},
            "Location": {"value": "MAIN"},
            "Qty": {"value": 1},
            "UOM": {"value": "PIECE"}
        }
    ]
}

Step 11: Release the Credit Memo

You use the following example of an HTTP request to release the credit memo that you created in the previous step (whose reference number is assumed to be 000140).

POST /ReleaseSalesInvoice HTTP/1.1
Host: [<Acumatica ERP instance URL>]/entity/Default/23.200.001/SalesInvoice
Accept: application/json
Content-Type: application/json

{
  "entity" : {
      "ReferenceNbr": {"value": "000140"},
      "Type": {"value": "Credit Memo"}
      },
  "parameters" : {}
}