Entry of a Direct Sales Invoice

A point-of-sale (POS) system can create and process direct sales invoices—that is, sales invoices created on the Invoices (SO303000) form for which neither a sales order nor a shipment has been created. The POS system creates the direct sales invoice on the Invoices (SO303000) form and the payment on the Payments and Applications (AR302000) form for it. It then applies this payment to the invoice and releases the invoice.

In this topic, you will implement HTTP requests for the following user scenario. A customer comes to the store, picks up a number of items (including a jar of cherry jam, which has a serial number assigned), and orders billboard advertising. The customer would like to buy the items and pay for the order. In the POS system, one invoice is created for this 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.
  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: Assign a Tax Zone to a Customer

For the payment amount that is used in this example, the FRUITICO customer is assigned the NYSTATE tax zone. You use the following example of an HTTP request to assign the tax zone to the customer.

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

{
    "CustomerID": {"value": "FRUITICO"},
    "TaxZone": {"value": "NYSTATE"}
}

Step 2: Create a Payment

You use the following example of an HTTP request to create a payment that is sufficient to pay the direct sales invoice, which has not yet been created, and to remove the payment from hold. In this example, you create a payment before you create a direct sales order in order to show how to use one call to create a sales order and apply a payment to it.

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": 1235.27},
    "Type": {"value": "Payment"}
}

Step 3: Release the Payment

You use the following example of an HTTP request to release the payment that was created in the previous step (whose reference number 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" : {}
}

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

Step 4: Create a Direct Sales Invoice

You use the following example of an HTTP request to create a direct sales invoice containing the customer's purchased items and ordered service. In the request, you will also specify the billing settings, apply the previously released payment to the invoice, and remove the invoice from hold.

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": "CHERJAM32"},
            "Qty": {"value": 1},
            "UOM": {"value": "PIECE"},
            "LotSerialNbr": {"value": "JM2301290000"}
        },
        {
            "Branch": {"value": "HEADOFFICE"},
            "InventoryID": {"value": "APJAM32"},
            "Qty": {"value": 2},
            "UOM": {"value": "BOX"}
        },
        {
            "Branch": {"value": "HEADOFFICE"},
            "InventoryID": {"value": "ADVERT"},
            "Qty": {"value": 1},
            "UnitPrice": {"value": 1000},
            "UOM": {"value": "DAY"}
        }
    ],
    "BillingSettings":
    {
        "BillToAddressOverride": {"value": true},
        "BillToAddress":
        {
            "AddressLine1": {"value": "Fillmore Str"},
            "City": {"value": "San Francisco"},
            "State": {"value": "CA"}
        }
    },
    "ApplicationsInvoice":
    [
        {
            "DocType": {"value": "Payment"},
            "AdjustingDocReferenceNbr": {"value": "000076"},
            "AmountPaid": {"value": 1235.27}
        }
    ]
}

Step 5: Release the Direct Sales Invoice

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

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