Updating inventory count after order item quantity change

Hi, I’m new to the forum and trying to think through the design of my inventory management app.

If the available inventory for Product A is currently 1000 units and a customer places an order for 200 units of Product A, we will reduce Product A’s available inventory to 800 units.

But if the customer changes their original order quantity to 250 units (as they can edit pending orders), what would be the simplest way to update the available inventory quantity for changes to their original order quantity?

Do I need to create a state called ‘Original order’ that holds their original quantity of 200 units and then update Product A’s available inventory by the difference between the newly entered quantity and the ‘Original order’ state’s quantity (+50)?

I’m probably overthinking this but I couldn’t find any existing forum topics on making changes to existing order quantities other than in increments of 1 (using button clicks).

Thanks in advance for your help!

Hey Andy!

So, in my opinion, your description seems to be exactly how I would solve it.

I would use custom states to store both the old quantity and the new at first, and then run a back-end workflow to actually do the updating with the database.

How I would do it is:

When a user inputs a new quantity:

  • Set State of “Quantity Input” → State “Old Quantity” → 100 random number
  • Set State of “Quantity Input” → State “Difference” → Quantity Input’s Old Quantity - Quality Input’s Value

So if the old quantity was 100, and new was 50, it would be 100 - 50 = 50

Now, if the quantity went up, it would be like so:
100 (Old) - 105 (New) = -5

Now, we can either run a backend workflow called “Update Inventory” (just so you can use that same workflow in multiple places), or just make the change in the Workflow.

Make changes to thing → Thing to change: Product A → Availability = Product A’s Availability - Quantity Input’s Difference

Even if they added more, say that -5 example, it would do 100 - (-5) = 105

I hope that helps and makes sense?
Drake!

2 Likes

@draked123 - Thank you very much for your quick reply.

I didn’t think about storing both old and new quantities in custom states but your explanation makes a lot of sense. And using backend workflow sounds like the way to go as I’ll be needing to reuse this workflow.

I was hoping there may be an even easier method as I will be needing to do this for incoming shipments too as well as updating inventory values based on the order status (Draft, Pending, Completed, Cancelled). But I’m sure once I set it up especially with the backend workflows, it shouldn’t be too onerous.

I’m actually rebuilding this inventory management in Bubble from a system I already built out using Airtable. In Airtable for the Inventory count, it does a ‘rollup’ where it sums all the incoming shipments quantities less the all the outgoing order quantities. I was originally thinking of doing the same in Bubble, but I can imagine the overhead of doing this sum calculation dynamically would be pretty taxing once there are a lot of incoming and outgoing records.