Merge branch 'master' into fresh-flow
Conflicts: app/assets/stylesheets/bootstrap_and_overrides.css.less
This commit is contained in:
commit
2b511ee559
96 changed files with 1389 additions and 1556 deletions
|
|
@ -26,6 +26,11 @@ class Ordergroup < Group
|
|||
User.natural_order.all.reject { |u| (users.include?(u) || u.ordergroup) }
|
||||
end
|
||||
|
||||
# the most recent order this ordergroup was participating in
|
||||
def last_order
|
||||
orders.order('orders.starts DESC').first
|
||||
end
|
||||
|
||||
def value_of_open_orders(exclude = nil)
|
||||
group_orders.in_open_orders.reject{|go| go == exclude}.collect(&:price).sum
|
||||
end
|
||||
|
|
|
|||
|
|
@ -14,10 +14,14 @@ class StockArticle < Article
|
|||
|
||||
# Check for unclosed orders and substract its ordered quantity
|
||||
def quantity_available
|
||||
quantity - OrderArticle.where(article_id: id).
|
||||
quantity - quantity_ordered
|
||||
end
|
||||
|
||||
def quantity_ordered
|
||||
OrderArticle.where(article_id: id).
|
||||
joins(:order).where("orders.state = 'open' OR orders.state = 'finished'").sum(:units_to_order)
|
||||
end
|
||||
|
||||
|
||||
def quantity_history
|
||||
stock_changes.reorder('stock_changes.created_at ASC').map{|s| s.quantity}.cumulative_sum
|
||||
end
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ class User < ActiveRecord::Base
|
|||
validates_presence_of :password, :on => :create
|
||||
validates_format_of :email, :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i
|
||||
validates_uniqueness_of :email, :case_sensitive => false
|
||||
validates_presence_of :first_name # for simple_form validations
|
||||
validates_length_of :first_name, :in => 2..50
|
||||
validates_confirmation_of :password
|
||||
validates_length_of :password, :in => 5..25, :allow_blank => true
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue