Entry of a Direct Sales Invoice Along with a Return

A point-of-sale (POS) system can create and process direct sales invoices (that is, invoices for which neither a sales order nor a shipment has been created) and include in these invoices lines for returned items that were previously sold. The POS system creates the direct sales invoice on the Invoices (SO303000) form and releases the invoice.

In this topic, you will implement HTTP requests for the following user scenario. A customer comes to the store and picks up a number of items (including items that are tracked by their serial numbers). The customer would like to buy these items and to return a previously purchased box of pens. In the POS system, one invoice is created for this operation. The customer pays the difference between the sale and the return.

For simplicity, this example does not include the creation of the payment or the application of the payment to the invoice. You can find an example showing how to create and apply a payment related to a direct sales invoice in Entry of a Direct Sales Invoice.

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 Direct Sales Invoice

You use the following example of an HTTP request to create a direct sales invoice containing the picked items and the items to be returned, and release the invoice from hold.

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": "Invoice"},
    "Hold": {"value": false},
    "Details":
    [
        {
            "Branch": {"value": "HEADOFFICE"},
            "InventoryID": {"value": "CHERJAM32"},
            "Qty": {"value": 1},
            "UOM": {"value": "PIECE"},
            "LotSerialNbr": {"value": "JM2302010003"}
        },
        {
            "Branch": {"value": "HEADOFFICE"},
            "InventoryID": {"value": "BANANAS"},
            "WarehouseID": {"value": "WHOLESALE"},
            "Location": {"value": "F2S2"},
            "Qty": {"value": 5},
            "UOM": {"value": "LB"},
            "UnitPrice": {"value": 1},
            "LotSerialNbr": {"value": "FR200384"}
        },
        {
            "Branch": {"value": "HEADOFFICE"},
            "InventoryID": {"value": "PEN"},
            "Location": {"value": "MAIN"},
            "Qty": {"value": -1},
            "UnitPrice": {"value": 2},
            "UOM": {"value": "PIECE"}
        }
    ]
}

Step 2: Release the Invoice

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

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": "000116"},
      "Type": {"value": "Invoice"}
      },
  "parameters" : {}
}

You would then check the status of this operation by performing similar actions to those described in Execute an Action That Is Present in an Endpoint. For simplicity, the checking requests are not provided here.