tiny change to pdf

This commit is contained in:
viehlieb 2025-05-23 14:22:47 +02:00
parent ca3db24b8d
commit 7130a1aab4

View file

@ -85,17 +85,12 @@ class GroupOrderInvoicePdf < RenderPdf
group_order_articles = GroupOrderArticle.where(group_order_id: @options[:group_order_ids]) group_order_articles = GroupOrderArticle.where(group_order_id: @options[:group_order_ids])
separate_deposits = FoodsoftConfig[:group_order_invoices]&.[](:separate_deposits) separate_deposits = FoodsoftConfig[:group_order_invoices]&.[](:separate_deposits)
supplier = "" supplier = ""
headlines = []
index = 0
group_order_articles.each do |goa| group_order_articles.each do |goa|
# if no unit is received, nothing is to be charged # if no unit is received, nothing is to be charged
next if goa.result.to_i == 0 next if goa.result.to_i == 0
index +=1
if goa.group_order.order.supplier.name != supplier if goa.group_order.order.supplier.name != supplier
headlines << index
supplier = goa.group_order.order.supplier.name supplier = goa.group_order.order.supplier.name
data << [supplier,"","",""] data << [supplier,"","",""]
index +=1
end end
goa_total_price = separate_deposits ? goa.total_price_without_deposit : goa.total_price goa_total_price = separate_deposits ? goa.total_price_without_deposit : goa.total_price
data << [goa.order_article.article.name, data << [goa.order_article.article.name,
@ -120,7 +115,6 @@ class GroupOrderInvoicePdf < RenderPdf
table.cells.border_color = '666666' table.cells.border_color = '666666'
table.row(0).column(0..4).width = 80 table.row(0).column(0..4).width = 80
table.row(0).column(0).width = 180 table.row(0).column(0).width = 180
table.row(headlines).font_style= :bold
table.row(0).border_bottom_width = 2 table.row(0).border_bottom_width = 2
table.columns(1).align = :right table.columns(1).align = :right
table.columns(1..6).align = :right table.columns(1..6).align = :right
@ -184,18 +178,14 @@ class GroupOrderInvoicePdf < RenderPdf
end end
group_order_articles = GroupOrderArticle.where(group_order_id: @options[:group_order_ids]).includes(group_order: { order: :supplier }) group_order_articles = GroupOrderArticle.where(group_order_id: @options[:group_order_ids]).includes(group_order: { order: :supplier })
index = 0
supplier_headlines = []
group_order_articles.group_by { |goa| goa.group_order.order.supplier.name }.each do |supplier_name, articles| group_order_articles.group_by { |goa| goa.group_order.order.supplier.name }.each do |supplier_name, articles|
if articles.map(&:result).sum > 0 if articles.map(&:result).sum > 0
data << [supplier_name, "", "", "", "", ""] data << [supplier_name, "", "", "", "", ""]
index += 1
supplier_headlines << index
end end
articles.each do |goa| articles.each do |goa|
next if goa.result.to_i == 0 next if goa.result.to_i == 0
index += 1
order_article = goa.order_article order_article = goa.order_article
tax = order_article.price.tax tax = order_article.price.tax
@ -256,9 +246,6 @@ class GroupOrderInvoicePdf < RenderPdf
table.row(0).border_bottom_width = 2 table.row(0).border_bottom_width = 2
table.columns(1).align = :right table.columns(1).align = :right
table.columns(1..6).align = :right table.columns(1..6).align = :right
supplier_headlines.each do |row_index|
table.row(row_index).columns(0..6).style(font_style: :bold)
end
end end
if marge > 0 if marge > 0