Entry of a Direct Sales Invoice for an Unshipped Sales Order

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

  • Lines that have not been linked to any sales order or shipment
  • Lines for which a sales order has been created and a shipment has not been created

Either type of line can include information about newly bought items or returned items. To process these invoices, the POS system performs the following steps:

  1. Creates a new return merchandise authorization (RMA) order—that is, a return order of the RM type created on the Sales Orders (SO301000) form—with the new items and returned items.
  2. Creates a payment.
  3. Creates a sales invoice and adds detail lines for both the new items and the returned items.
  4. Applies the payment to the invoice.
  5. Releases the invoice. As a result of this operation, the sales order gets the Completed status in MYOB Acumatica. The SO invoice is added to the Shipments tab of the Sales Orders (SO301000) form and is treated by the system as a shipment (that is, the invoice updates shipped quantity in the sales order lines and updates inventory).
Note: The sales order may not be completed if it was closed by the SO invoice partially (that is, if some lines of the sales order are not shipped or billed).

In this topic, you will implement HTTP requests for the following user scenario. A customer comes to the store and through a self-service terminal creates a sales order to buy a 32-ounce glass bottle and to return a 16-ounce glass bottle that the customer previously purchased in the store (this item is specified in the initial sales order). In a POS system, one invoice is created for the whole operation.

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 in the Installation Guide.
  2. 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.
  3. On the Sales Orders (SO301000) form, create a sales order to sell an ORG-16OZ-GBT item from the Retail warehouse to the FRUITICO customer.
  4. On the Invoices (SO303000) form, create a new sales invoice (its type must be Invoice) for the FRUITICO customer, and on the Details tab toolbar, click Add Order and add the sales order that was just created. In this example, the invoice number is assumed to be 000130.
  5. On the form toolbar, click Release to release the created invoice.
  6. 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.
  7. 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.
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 an RMA Order

You use the following example of an HTTP request to create an RMA order that contains the ORG-16OZ-GBT item (from the sales order that is created in the Testing of the Requests section) that the customer wants to return and an ORG-32OZ-GBT item that the customer wants to buy.

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" },
            "InvoiceNbr": { "value": "000130" },
            "Operation": { "value": "Receipt" },
            "InventoryID": { "value": "ORG-16OZ-GBT" },
            "OrderQty": { "value": -1 },
            "UOM": { "value": "EA" },
            "WarehouseID": { "value": "RETAIL" },
            "AutoCreateIssue": { "value": false }
        },
        {
            "Branch": { "value": "HEADOFFICE" },
            "Operation": { "value": "Issue" },
            "InventoryID": { "value": "ORG-32OZ-GBT" },
            "OrderQty": { "value": 1 },
            "UOM": { "value": "EA" },
            "WarehouseID": { "value": "RETAIL" },
            "AutoCreateIssue": { "value": false }
        }
    ]
}

Step 2: Correct the RMA Order

You use the following example of an HTTP request to set the value of the AutoCreateIssue field of the SalesOrder object to falseto avoid 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 are amending. 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": "bbbc7c53-e8ab-ed11-9e85-9828a61840c3",
    "Details": [
        {
            "id": "c1bc7c53-e8ab-ed11-9e85-9828a61840c3",
            "AutoCreateIssue": {"value": false}
        }
    ]
}

Step 3: Create a Payment

You use the following example of an HTTP request to create a payment with the paid amount that is equal to the total amount of the RMA order that was created in Step 1.

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

{
    "CashAccount": {"value": "10250ST"},
    "CustomerID": {"value": "FRUITICO"},
    "Hold": {"value": false},
    "PaymentAmount": {"value": 8.32},
    "Type": {"value": "Payment"}
}

Step 4: Release the Payment

You use the following example of an HTTP request to release the payment that you created in the previous step. The reference number of the payment is assumed to be 000076.

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

{
  "entity" : {
      "ReferenceNbr": {"value": "000076"},
      "Type": {"value": "Payment"}
      },
  "parameters" : {}
}

You need to check the status of this operation (as well as the status of another operation in this topic) by performing instructions similar to those described in Execute an Action That Is Present in an Endpoint. For simplicity, the checking requests are not provided here.

Step 5: Create a Sales Invoice for the RMA Order

You use the following example of an HTTP request to create a sales invoice that contains both lines of the RMA order (whose order number is assumed to be 000131) and apply the payment to the invoice.

PUT ?$expand=ApplicationsInvoice,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": "ORG-16OZ-GBT"},
            "Location": {"value": "MAIN"},
            "Qty": {"value": -1},
            "UOM": {"value": "EA"},
            "OrderType": {"value": "RM"},
            "OrderNbr": {"value": "000131"},
            "OrderLineNbr": {"value": 1}
        },
        {
            "Branch": {"value": "HEADOFFICE"},
            "InventoryID": {"value": "ORG-32OZ-GBT"},
            "Location": {"value": "MAIN"},
            "Qty": {"value": 1},
            "UOM": {"value": "EA"},
            "OrderType": {"value": "RM"},
            "OrderNbr": {"value": "000131"},
            "OrderLineNbr": {"value": 3}
        }
    ],
    "ApplicationsInvoice":
    [
        {
            "DocType": {"value": "Payment"},
            "AdjustingDocReferenceNbr": {"value": "000076"},
            "AmountPaid": {"value": 8.32}
        }
    ]
}

Step 6: Release the Sales Invoice

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

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