Updating Purchase Orders quantity received on API doesn't update product inventory

Hi there!

We have a problem when manipulating Purchase Orders(PO) with the API, basically when creating or updating the PO line items quantity_received, it gets updated on the PO but the inventory doesn’t update on the Product, if we update the PO item quantity received on the receive page from web manually (https://purchase-orders.shiphero.com/purchase-orders/details/XXYYZZ/receive) it does change the product inventory as expected.

Is this behavior intentional and we must update the inventory manually on the product with the API as well or is a bug and it SHOULD update the product inventory when interacting with the PO with the API?

Here is the creation mutation we have tried:

mutation($input: CreatePurchaseOrderInput!){
  purchase_order_create(data: $input){
    complexity
    purchase_order{
      id
      legacy_id
      po_number
    }
  }
}

Input:

    {
    	"input": {
    		"vendor_id": "VmVuZG9yOjE2MTg3Nw==",
    		"po_number": "DEV TEST GQL - #55",
    		"line_items": [
    			{
    				"sku": "APUBROWSER",
    				"quantity": 1,
    				"price": "0",
    				"sell_ahead": 0,
    				"quantity_received": 1,
    				"expected_weight_in_lbs": "0"
    			}
    		],
    		"po_date": "2019-12-18T12:00:00",
    		"subtotal": "0",
    		"shipping_price": "0",
    		"total_price": "0",
    		"warehouse_id": "V2FyZWhvdXNlOjEwMjMy"
    	}
    }

With that we got everything set on the PO correctly, but the product itself doesn’t get its inventory updated.

I thought it had to do with the creation mutation but tested the purchase_order_update endpoint to no avail, only the PO quantity gets update without change on the product:

mutation($input: UpdatePurchaseOrderInput!){
  purchase_order_update(data: $input){
    complexity
    purchase_order{
      id
      legacy_id
      po_number
    }
  }
}

Input:

{
	"input": {
		"po_id": "UHVyY2hhc2VPcmRlcjo0Mjg2NzA=",
		"line_items": [
			{
				"sku": "APUBROWSER",
				"quantity_received": 2
			}
		]
	}
}

Hi @vicvans20,
You are right about this behavior. We don’t currently change inventory when using the purchase_order_update mutation. It will only update the quantity received, but will not affect inventory quantities.

I’ve already submitted a request to be able to receive and update inventory as well, so I will let you know as soon as I have an update on this.
Just out of curiosity, is there any particular reason you are not using the web app for receiving the PO?
Thanks for catching this!
Tom

1 Like

Hi @tomasw,

Thanks for the fast response, I will be waiting for the update on that then.

Yes, the reason is that we have a particular event in which we have an optimistic like approach that automatize the process of the creation+completion of the PO.

What is the reason for wanting to use the API to receive POs? that’s typically done from https://purchase-orders.shiphero.com/purchase-orders

We have a system that handle some events, with some of those events we need to create the PO automatically and approve it at that moment, we can’t wait to manually update them on the website, so that’s why, there is an endpoint for that task, so I expected it to behave as the website with the inventory update.