Skip to content

Instantly share code, notes, and snippets.

@jimmybaker
Created July 1, 2009 20:10
Show Gist options
  • Save jimmybaker/139015 to your computer and use it in GitHub Desktop.
Save jimmybaker/139015 to your computer and use it in GitHub Desktop.
def inventory_for_warehouse(whs)
inventories.find_by_warehouse_id(whs.id)
end
def quantity_on_hand_for_warehouse(whs)
inventory = inventory_for_warehouse(whs)
inventory.starting_quantity + inventory.inventory_transactions.sum(:adjustment, :conditions => ['created_at >= ?', inventory.starting_date])
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment