🔄 FLOW STO (Best Practice) 1. Create STO status = DRAFT 2. Approve STO status = APPROVED 3. Ship Barang status = IN_TRANSIT inventory asal berkurang insert stock_movements (TRANSFER_OUT) 4. Receive Barang status = COMPLETED inventory tujuan bertambah insert stock_movements (TRANSFER_IN) 📡 Contoh Query Penting 🔍 Scan Barcode → Ambil Item SELECT i.* FROM item_barcodes b JOIN items i ON i.id = b.item_id WHERE b.barcode = '123456789'; 📦 Cek Stok SELECT i.name, l.name AS location, inv.quantity FROM inventories inv JOIN items i ON i.id = inv.item_id JOIN locations l ON l.id = inv.location_id WHERE i.sku = 'SKU-001'; ⚠️ Best Practice Production Gunakan transaction (BEGIN / COMMIT) saat STO Lock inventory saat update (hindari race condition) Gunakan index di: SKU barcode sto_number Pisahkan movement vs inventory (JANGAN digabung) 🚀 BONUS (Kalau mau lebih advance) Kalau kamu mau naik level: Tambahkan batch / lot number Tambahkan expiry date Gunakan event sourcing (movement only) Integrasi barcode scanner (keyboard input / camera)