fix articles with zero quantity showing

complements 8913ad615c
This commit is contained in:
wvengen 2014-09-11 13:47:03 +02:00
parent ee1874a15f
commit cf360335ee
2 changed files with 3 additions and 3 deletions

View file

@ -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'))

View file

@ -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