Add transport to OrderPDF
This commit is contained in:
parent
ca0398632b
commit
1656efd845
2 changed files with 12 additions and 2 deletions
|
@ -11,7 +11,8 @@ class OrderByGroups < OrderPdf
|
||||||
end
|
end
|
||||||
|
|
||||||
def body
|
def body
|
||||||
each_ordergroup do |oa_name, oa_total, oa_id|
|
each_ordergroup do |oa_name, oa_total, oa_id, oa_transport|
|
||||||
|
has_transport = !oa_transport.nil? && oa_transport > 0
|
||||||
dimrows = []
|
dimrows = []
|
||||||
rows = [[
|
rows = [[
|
||||||
OrderArticle.human_attribute_name(:article),
|
OrderArticle.human_attribute_name(:article),
|
||||||
|
@ -33,10 +34,19 @@ class OrderByGroups < OrderPdf
|
||||||
end
|
end
|
||||||
next unless rows.length > 1
|
next unless rows.length > 1
|
||||||
rows << [nil, nil, nil, nil, nil, number_to_currency(oa_total)]
|
rows << [nil, nil, nil, nil, nil, number_to_currency(oa_total)]
|
||||||
|
if has_transport
|
||||||
|
rows << [GroupOrder.human_attribute_name(:transport), nil, nil, nil, nil, number_to_currency(oa_transport)]
|
||||||
|
rows << [nil, nil, nil, nil, nil, number_to_currency(oa_total + oa_transport)]
|
||||||
|
end
|
||||||
|
|
||||||
rows.each { |row| row.delete_at 1 } unless @options[:show_supplier]
|
rows.each { |row| row.delete_at 1 } unless @options[:show_supplier]
|
||||||
|
|
||||||
nice_table oa_name || stock_ordergroup_name, rows, dimrows do |table|
|
nice_table oa_name || stock_ordergroup_name, rows, dimrows do |table|
|
||||||
|
if has_transport
|
||||||
|
table.row(-4).border_width = 1
|
||||||
|
table.row(-4).border_color = '666666'
|
||||||
|
end
|
||||||
|
|
||||||
table.row(-2).border_width = 1
|
table.row(-2).border_width = 1
|
||||||
table.row(-2).border_color = '666666'
|
table.row(-2).border_color = '666666'
|
||||||
table.row(-1).borders = []
|
table.row(-1).borders = []
|
||||||
|
|
|
@ -86,7 +86,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)', 'ordergroup_id')
|
pluck('groups.name', 'SUM(group_orders.price)', 'ordergroup_id', 'SUM(group_orders.transport)')
|
||||||
|
|
||||||
result.map do |item|
|
result.map do |item|
|
||||||
[item.first || stock_ordergroup_name] + item[1..-1]
|
[item.first || stock_ordergroup_name] + item[1..-1]
|
||||||
|
|
Loading…
Reference in a new issue