Added some more eager loading for balancing view.
This commit is contained in:
parent
07581b7ecf
commit
9cc98b4662
2 changed files with 14 additions and 14 deletions
|
@ -10,7 +10,7 @@ class Finance::BalancingController < Finance::BaseController
|
|||
flash.now.alert = "Achtung, Bestellung wurde schon abgerechnet" if @order.closed?
|
||||
@comments = @order.comments
|
||||
|
||||
@articles = @order.order_articles.ordered.includes(:order, :article_price,
|
||||
@articles = @order.order_articles.ordered.includes(:article, :article_price,
|
||||
group_order_articles: {group_order: :ordergroup})
|
||||
|
||||
sort_param = params['sort'] || 'name'
|
||||
|
|
|
@ -113,7 +113,7 @@ class Order < ActiveRecord::Base
|
|||
def sum(type = :gross)
|
||||
total = 0
|
||||
if type == :net || type == :gross || type == :fc
|
||||
for oa in order_articles.ordered.all(:include => [:article,:article_price])
|
||||
for oa in order_articles.ordered.includes(:article, :article_price)
|
||||
quantity = oa.units_to_order * oa.price.unit_quantity
|
||||
case type
|
||||
when :net
|
||||
|
@ -125,8 +125,8 @@ class Order < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
elsif type == :groups || type == :groups_without_markup
|
||||
for go in group_orders.all(:include => :group_order_articles)
|
||||
for goa in go.group_order_articles.all(:include => [:order_article])
|
||||
for go in group_orders.includes(group_order_articles: {order_article: [:article, :article_price]})
|
||||
for goa in go.group_order_articles
|
||||
case type
|
||||
when :groups
|
||||
total += goa.result * goa.order_article.price.fc_price
|
||||
|
|
Loading…
Reference in a new issue