Reaction: Product inventory should update when a new order is created

Created on 19 Jun 2018  路  7Comments  路  Source: reactioncommerce/reaction

Prerequisites

  • [x] Are you running the latest version?
  • [x] Are you able to consistently reproduce the issue?
  • [x] Did you search the issue queue for existing issue? Search issues

Issue Description

Currently, RC updates a product's inventory count after an admin processes an order. A product's inventory count should update when a new order is created.

Steps to Reproduce

  1. Spin up a fresh RC shop, log in as an admin and create a new product with a quantity of 2.
  2. In another browser as a customer purchase 1 of the newly created product.
  3. As an admin view the new product's quantity to see it still at 2
  4. As an admin process the new order to completion then check the new product's quantity. It should now show 1.

Possible Solution

N/A

Versions

Node: 8.9.4
NPM: 5.6.0
Meteor Node: 8.9.4
Meteor NPM: 5.6.0
Reaction CLI: 0.29.0
Reaction: 1.12.1
Reaction branch: master
bug

All 7 comments

Quantity should not be updated on the admin side when an Sale order is created. Admin should see the actual quantity but on the customer side product鈥檚 quantity should first less the quantity of products in sale orders and show that quantity to avoid over sold products.

We'll schedule this bugfix once we start to work on the GraphQL API for checkout and orders.

I actually think this was "as designed", since there were concerns that the store owner "accept' the order before it reduce inventory. More likely this should be configurable.

This points to two separate but connected issues - as @mkhizeryounas has noted.

  1. There should be a way to track inventory levels for a product which track with the actual number of items in stock. This should not be decremented when an order is placed, but rather when the item is picked from the shelves.
  1. There should also be a way to track the number of items that are "Available To Sell" (ATS). This number should be the inventory minus the quantity of items that are in open orders and have not been picked yet.

Both of these numbers are important, and it seems that we need to add some property or method to keep track of the ATS numbers so that shops can prevent overselling.

The actual inventory should not minus when an order is placed but invetory available to sell on storefront shou reflect the actual inventory - sale orders to avoid negitive order placement.

I've been working on this. PR #4859 has the solutions.

We've added a second field, inventoryAvailableToSell, which is the inventory that a customer is allowed to purchase. inventoryAvailableToSell is updated when a customer places an order.

The existing field, inventoryQuantity (called inventoryInStock` in the Catalog), stays the same, and is updated when the operator approves or cancels an order.

In the time between when a customer places an order, and the order is approved, these numbers will be different.

The operator will see an editable field for inventoryQuantity in the operator UI. The inventoryAvailableToSell will calculate itself based on this number, minus "reserved" items that a user has in an order. The operator will see a non-editable field for inventoryAvailableToSell in the operator UI.

The customer will always see inventory numbers and statuses based off the inventoryAvailableToSell number.

Closed via #4859

Was this page helpful?
0 / 5 - 0 ratings