diff --git a/app/controllers/orders_controller.rb b/app/controllers/orders_controller.rb index e31c1d9c..63c548ad 100644 --- a/app/controllers/orders_controller.rb +++ b/app/controllers/orders_controller.rb @@ -114,7 +114,7 @@ class OrdersController < ApplicationController def receive @order = Order.find(params[:id]) unless request.post? - @order_articles = @order.order_articles.ordered.includes(:article).order('articles.order_number, articles.name') + @order_articles = @order.order_articles.ordered_or_member.includes(:article).order('articles.order_number, articles.name') else s = update_order_amounts flash[:notice] = (s ? I18n.t('orders.receive.notice', :msg => s) : I18n.t('orders.receive.notice_none')) diff --git a/app/models/order_article.rb b/app/models/order_article.rb index a1eb19f4..5666a549 100644 --- a/app/models/order_article.rb +++ b/app/models/order_article.rb @@ -12,9 +12,9 @@ class OrderArticle < ActiveRecord::Base validate :article_and_price_exist validates_uniqueness_of :article_id, scope: :order_id - _ordered_sql = "units_to_order > 0 OR units_billed > 0 OR units_received > 0 OR order_articles.quantity > 0" + _ordered_sql = "order_articles.units_to_order > 0 OR order_articles.units_billed > 0 OR order_articles.units_received > 0" scope :ordered, -> { where(_ordered_sql) } - scope :ordered_or_member, -> { includes(:group_order_articles).where("#{_ordered_sql} OR group_order_articles.result > 0") } + scope :ordered_or_member, -> { includes(:group_order_articles).where("#{_ordered_sql} OR order_articles.quantity > 0 OR group_order_articles.result > 0") } before_create :init_from_balancing after_destroy :update_ordergroup_prices