Entry of a Credit Memo with Positive and Negative Lines

A point-of-sale (POS) system can create and process credit memos with positive lines (for the returned items) and negative lines (for the purchased items). A credit memo is created on the Invoices (SO303000) form instead of a direct sales invoice if the payment amount of the returned items is greater than the payment amount of the newly purchased items. The POS system creates the credit memo, links the sales invoice with the returned lines to the credit memo, and releases the credit memo.

In this topic, you will implement HTTP requests for the following user scenario. A customer comes to the store and picks up a jar of apple jam. The customer would like to buy it and to return 10 previously purchased jars of cherry jam. The price of the returned items is greater than the price of the purchased item. In the POS system, one invoice is created for the whole operation. The customer is given the difference between the returned items and the sold items.

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 the Inventory and Order Management, Lot and Serial Tracking, and Advanced SO Invoices features are enabled.
  3. On the Invoices (SO303000) form, create a direct sales invoice for selling 10 CHERJAM32 items and other goods to the FRUITICO customer. The 10 CHERJAM32 items must be in line 1 of the invoice. Make a note of the invoice number. In the example, the invoice number is assumed to be 000114; you should instead use the number of the sales invoice you create.
  4. On the form toolbar, click Release to release the invoice.
  5. On the More menu (under Processing), click Pay to create a payment.
  6. On the Payments and Applications (AR302000) form, which opens, save the payment. On the form toolbar, click Remove Hold and then click Release.
  7. 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.
  8. 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 a Credit Memo

You use the following example of an HTTP request to create a credit memo and release it from hold. With the credit memo, the following is done:

  • The items in line 1 of the 000114 invoice are returned.
    Tip:
    Replace 000114 with the number of the invoice you have created.
  • One item of the APJAM08 goods is purchased.
  • The 000114 invoice is attached to the credit memo.
  • A total of $80 is credited from that invoice.
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": "000114" },
            "OrigInvType": { "value": "Invoice" },
            "OrigInvLineNbr": { "value": 1 },
            "Qty": { "value": 10 }
        },
        {
            "Branch": {"value": "HEADOFFICE"},
            "InventoryID": {"value": "APJAM08"},
            "WarehouseID": {"value": "WHOLESALE"},
            "Location": {"value": "MAIN"},
            "Qty": {"value": -1},
            "UOM": {"value": "PIECE"}
        }
    ],
    "ApplicationsCreditMemo":
    [
        {
            "Customer": {"value": "FRUITICO"},
            "DocType": {"value": "Invoice"},
            "ReferenceNbr": {"value": "000114"},
            "AmountPaid": {"value": 80}
        }
    ]
}

Step 2: 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 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": "Credit Memo"}
      },
  "parameters" : {}
}

You need to 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.