Fix rendering of stock order in OrderByGroups

This commit is contained in:
Patrick Gansterer 2019-01-28 06:08:04 +01:00
parent 52f322bf6e
commit d925533366
2 changed files with 3 additions and 3 deletions

View file

@ -16,6 +16,7 @@ class GroupOrder < ApplicationRecord
scope :in_open_orders, -> { joins(:order).merge(Order.open) } scope :in_open_orders, -> { joins(:order).merge(Order.open) }
scope :in_finished_orders, -> { joins(:order).merge(Order.finished_not_closed) } scope :in_finished_orders, -> { joins(:order).merge(Order.finished_not_closed) }
scope :stock, -> { where(ordergroup: 0) }
scope :ordered, -> { includes(:ordergroup).order('groups.name') } scope :ordered, -> { includes(:ordergroup).order('groups.name') }

View file

@ -73,7 +73,7 @@ class OrderPdf < RenderPDF
group('groups.id'). group('groups.id').
offset(offset). offset(offset).
limit(limit). limit(limit).
pluck('groups.name', 'SUM(group_orders.price)', 'groups.id') pluck('groups.name', 'SUM(group_orders.price)', 'ordergroup_id')
result.map do |item| result.map do |item|
[item.first || stock_ordergroup_name] + item[1..-1] [item.first || stock_ordergroup_name] + item[1..-1]
@ -129,10 +129,9 @@ class OrderPdf < RenderPDF
end end
def stock_ordergroup_name def stock_ordergroup_name
users = GroupOrder. users = GroupOrder.stock.
eager_load(:updated_by). eager_load(:updated_by).
where(order: @orders). where(order: @orders).
where(ordergroup: nil).
map(&:updated_by). map(&:updated_by).
map{ |u| u.try(&:name) || '?' } map{ |u| u.try(&:name) || '?' }