Deducting product stock from a list of products

Hey guys!

I’m building a product inventory app that allows a user to checkout stock etc.

So the user can create a new product with a name and the total stock on hand.

This newly created product will also have an attribute called “Owner” that is a ‘User’ and will be saved as the ‘current user’.

Now the user can check out a list of products as well as enter the quantity of each product they check out.

For example, there are 12 Apples in stock and 6 Oranges.

The user then checks out 2 Apples as well as 3 Oranges. Thus in the list of products, 2 should be deducted from the current 12 in stock apples as well as 3 oranges from the 6 in stock oranges.

What I’m struggling with is that on checkout, the app should reduce the corresponding product’s stock with the checkout stock to accurately keep stock.

I can’t find a way to search for products and minus X amount of stock without affecting other stock amounts.

Please help.

Picture2

This might help you with the database structure

If it doesn’t answer your question directly, it will at least help get the gears turning to come up with a solution that works for you.

I spent the past four hours going through various models that have to do with products from this site…there are a bunch that are relevant, and you might find some that you would use in the future as well

https://www.vertabelo.com/blog/

1 Like

Thanks! I’ll give it a go.

This topic was automatically closed after 70 days. New replies are no longer allowed.