Fix rendering of stock order in OrderByGroups
This commit is contained in:
parent
52f322bf6e
commit
d925533366
2 changed files with 3 additions and 3 deletions
|
@ -16,6 +16,7 @@ class GroupOrder < ApplicationRecord
|
|||
|
||||
scope :in_open_orders, -> { joins(:order).merge(Order.open) }
|
||||
scope :in_finished_orders, -> { joins(:order).merge(Order.finished_not_closed) }
|
||||
scope :stock, -> { where(ordergroup: 0) }
|
||||
|
||||
scope :ordered, -> { includes(:ordergroup).order('groups.name') }
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ class OrderPdf < RenderPDF
|
|||
group('groups.id').
|
||||
offset(offset).
|
||||
limit(limit).
|
||||
pluck('groups.name', 'SUM(group_orders.price)', 'groups.id')
|
||||
pluck('groups.name', 'SUM(group_orders.price)', 'ordergroup_id')
|
||||
|
||||
result.map do |item|
|
||||
[item.first || stock_ordergroup_name] + item[1..-1]
|
||||
|
@ -129,10 +129,9 @@ class OrderPdf < RenderPDF
|
|||
end
|
||||
|
||||
def stock_ordergroup_name
|
||||
users = GroupOrder.
|
||||
users = GroupOrder.stock.
|
||||
eager_load(:updated_by).
|
||||
where(order: @orders).
|
||||
where(ordergroup: nil).
|
||||
map(&:updated_by).
|
||||
map{ |u| u.try(&:name) || '?' }
|
||||
|
||||
|
|
Loading…
Reference in a new issue