Transfer products between different warehouses?

Hi everyone,
I’m building a work order and warehouse management app, and I need help with transferring products between warehouses.

Here’s how my setup looks:

  • I have a Products table (just a list of products, no stock info here).
  • I have a Stock table that shows stock per warehouse (if a warehouse has zero stock, it doesn’t appear in this table).
  • I also have other tables for work order management.

My goal:
Let’s say I want to transfer iPhone from Warehouse A to Warehouse B.
I want the logic to work like this:

  1. Check if Warehouse B exists in the Stock table.
  • If it doesn’t exist, create a new row for it.
  • If it does exist but has no iPhones, add a new row for iPhones in that warehouse.
  • If it already has iPhones, just increase the quantity (Set column value).
  1. At the same time, subtract the same quantity from Warehouse A’s iPhone stock.
  2. The system should not allow the transfer if Warehouse A doesn’t have enough stock (no negative stock allowed).

I’m not sure what’s the best structure or where I should run this logic from. Any advice would be appreciated!

Thanks in advance!

Here is a related thread that you might like:

1 Like