Skip to content

Instantly share code, notes, and snippets.

@shwoodard
Created May 28, 2009 00:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shwoodard/119013 to your computer and use it in GitHub Desktop.
Save shwoodard/119013 to your computer and use it in GitHub Desktop.
def qty_available_for_sale(as_of = Time.zone.new)
qty = wac_and_qty(as_of)[1]
inventory_adjustment_entries.find_after(as_of).each do |entry|
qty = qty + (entry.debit_credit_flag == 'Debit' ? entry.item_qty : -entry.item_qty)
min_qty = [qty, min_qty].min
end
qty
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment