Move inventory functions to inventory.sql