Merge branch 'master' into allow-no-nickname
Conflicts: app/views/foodcoop/users/_users.html.haml
This commit is contained in:
commit
c37ed74942
84 changed files with 1712 additions and 2579 deletions
|
|
@ -155,7 +155,7 @@ class Order < ActiveRecord::Base
|
|||
unless finished?
|
||||
Order.transaction do
|
||||
# set new order state (needed by notify_order_finished)
|
||||
update_attributes(:state => 'finished', :ends => Time.now, :updated_by => user)
|
||||
update_attributes!(:state => 'finished', :ends => Time.now, :updated_by => user)
|
||||
|
||||
# Update order_articles. Save the current article_price to keep price consistency
|
||||
# Also save results for each group_order_result
|
||||
|
|
|
|||
|
|
@ -12,7 +12,8 @@ class OrderArticle < ActiveRecord::Base
|
|||
validate :article_and_price_exist
|
||||
validates_uniqueness_of :article_id, scope: :order_id
|
||||
|
||||
scope :ordered, :conditions => "units_to_order >= 1"
|
||||
scope :ordered, :conditions => "units_to_order > 0"
|
||||
scope :ordered_or_member, -> { includes(:group_order_articles).where("units_to_order > 0 OR group_order_articles.result > 0") }
|
||||
|
||||
before_create :init_from_balancing
|
||||
after_destroy :update_ordergroup_prices
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ class Ordergroup < Group
|
|||
end
|
||||
|
||||
def avg_jobs_per_euro
|
||||
stats[:orders_sum] != 0 ? stats[:jobs_size].to_f / stats[:orders_sum].to_f : 0
|
||||
stats[:jobs_size].to_f / stats[:orders_sum].to_f rescue 0
|
||||
end
|
||||
|
||||
# This is the ordergroup job per euro performance
|
||||
|
|
@ -90,7 +90,7 @@ class Ordergroup < Group
|
|||
# Global average
|
||||
def self.avg_jobs_per_euro
|
||||
stats = Ordergroup.pluck(:stats)
|
||||
stats.sum {|s| s[:jobs_size].to_f } / stats.sum {|s| s[:orders_sum].to_f }
|
||||
stats.sum {|s| s[:jobs_size].to_f } / stats.sum {|s| s[:orders_sum].to_f } rescue 0
|
||||
end
|
||||
|
||||
def account_updated
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue