Stock level changes on order/invoice

rhoflandrhofland Member Posts: 6
edited February 20 in Development

Hello,

questions regarding inventory stock level and orders:

  1. I am looking at https://developers.lightspeedhq.com/ecom/endpoints/variantmovement. In one of our orders a product was ordered with a quantity of 3. Then a credit was created for 1 of those products. When the credit invoice was created, the user toggled 'Update Stock' to 'on'. I see a record in variant movement with stockLevelChange set to -3 (for original order), then I see a record in variant movement with the stockLevelChange field is set to -2. I would expect that last record to indicate +1 as a credit is returning to the product to inventory. Could you please explain how to interpret the variant movement api endpoint
  2. In the case above, no 'Return' record (https://developers.lightspeedhq.com/ecom/endpoints/return/) was created, only the toggle 'Update stock' was used. I noticed in other orders where 'Return' was used, the orderProducts (https://developers.lightspeedhq.com/ecom/endpoints/orderproduct/) quantityReturned field was correctly updated. But when the credit invoice (with toggle 'Update stock') was used it did not update the quantityReturned field for that OrderProduct. Is this expected behavior?
  3. Is there a consistent way to know if a product was returned to the inventory (whether a "Return" or 'Update stock' toggle was used) and tie it to the original order product (or invoice item)?

Thanks,

Post edited by rhofland on

2 comments

  • rhoflandrhofland Member Posts: 6

    Would anyone be able to answer my question? Thanks.

  • LucienVersendaalLucienVersendaal Moderator, Lightspeed Staff Posts: 119 moderator

    Hi @rhofland,

    Thank you for reaching out to us. I apologize for not responding to your message before.

    I would expect that last record to indicate +1 as a credit is returning to the product to inventory. Could you please explain how to interpret the variant movement API endpoint. That's a difficult question why our devs choose to do it on this way. What I recommend doing because our variantMovements endpoint is not complete, is to use Variant Webhooks. Most of the changes that made on the variant will show up there also, stockLevel and stockSold, I think this will be better for you to use.

    But when the credit invoice (with toggle 'Update stock') was used it did not update the quantityReturned field for that OrderProduct. Is this expected behavior? This is expected behaviour because an order can be cancelled while the products hasn't been returned. The "quantityReturned" field is only triggered when you create a return.

    Is there a consistent way to know if a product was returned to the inventory (whether a "Return" or 'Update stock' toggle was used) and tie it to the original order product (or invoice item)? The best way to do this is to use a variant webhook, when the stock has changed(manually or an order) the webhook will be triggered. Below you'll see an example where I ordered 1 item with quantity of 3. When I made the order you'll see this in the webhook(my initial stock was 3 for this variant).

    After I create a return whitout updating the stock, now I create a credit for this product and update the stock here. Now you'll see this is in the webhook.

    Stocklevel is now +1 and stockSold is -1 so it will display 2, what's correct.

    I hope this helps you a lot in finding the best way to follow your inventory level by using webhooks, these are triggered by themself so you don't have to make a call to the "variantMovements" endpoint. TIP: to see more information about your products weither they are returned or refunded you can check GET /orders/{order_id/products.json

    To create a webhook, please visit https://developers.lightspeedhq.com/ecom/endpoints/webhook/

    I hope this will help :-)

Sign In or Register to comment.