simplify model

This commit is contained in:
wvengen 2013-11-26 13:22:44 +01:00
parent 9cb9bf6c1a
commit beabe22a01

View file

@ -12,8 +12,9 @@ class OrderArticle < ActiveRecord::Base
validate :article_and_price_exist validate :article_and_price_exist
validates_uniqueness_of :article_id, scope: :order_id validates_uniqueness_of :article_id, scope: :order_id
scope :ordered, -> { where("units_to_order > 0 OR units_billed > 0 OR units_received > 0") } _ordered_sql = "units_to_order > 0 OR units_billed > 0 OR units_received > 0"
scope :ordered_or_member, -> { includes(:group_order_articles).where("units_to_order > 0 OR units_billed > 0 OR units_received > 0 OR group_order_articles.result > 0") } scope :ordered, -> { where(_ordered_sql) }
scope :ordered_or_member, -> { includes(:group_order_articles).where("#{_ordered_sql} OR group_order_articles.result > 0") }
before_create :init_from_balancing before_create :init_from_balancing
after_destroy :update_ordergroup_prices after_destroy :update_ordergroup_prices