make both ordered and received products visible in order screens and pdfs
This commit is contained in:
parent
ee31c0c2af
commit
8ca95f396f
7 changed files with 60 additions and 30 deletions
|
|
@ -12,20 +12,29 @@ class OrderByArticles < OrderPdf
|
|||
|
||||
def body
|
||||
@order.order_articles.ordered.each do |order_article|
|
||||
text "#{order_article.article.name} (#{order_article.article.unit} | #{order_article.price.unit_quantity.to_s} | #{number_with_precision(order_article.price.fc_price, precision: 2)})",
|
||||
style: :bold, size: 10
|
||||
rows = []
|
||||
rows << I18n.t('documents.order_by_articles.rows')
|
||||
dimrows = []
|
||||
for goa in order_article.group_order_articles
|
||||
rows << [goa.group_order.ordergroup.name,
|
||||
"#{goa.quantity} + #{goa.tolerance}",
|
||||
goa.result,
|
||||
number_with_precision(order_article.price.fc_price * goa.result, precision: 2)]
|
||||
dimrows << rows.length if goa.result == 0
|
||||
end
|
||||
next if rows.length == 0
|
||||
rows.unshift I18n.t('documents.order_by_articles.rows') # table header
|
||||
|
||||
table rows, column_widths: [200,40,40], cell_style: {size: 8, overflow: :shrink_to_fit} do |table|
|
||||
table.columns(1..2).align = :right
|
||||
text "#{order_article.article.name} (#{order_article.article.unit} | #{order_article.price.unit_quantity.to_s} | #{number_with_precision(order_article.price.fc_price, precision: 2)})",
|
||||
style: :bold, size: 10
|
||||
table rows, cell_style: {size: 8, overflow: :shrink_to_fit} do |table|
|
||||
table.column(0).width = 200
|
||||
table.columns(1..3).align = :right
|
||||
table.column(2).font_style = :bold
|
||||
table.cells.border_width = 1
|
||||
table.cells.border_color = '666666'
|
||||
table.rows(0).border_bottom_width = 2
|
||||
# dim rows which were ordered but not received
|
||||
dimrows.each { |ri| table.row(ri).text_color = '999999' }
|
||||
end
|
||||
move_down 10
|
||||
end
|
||||
|
|
|
|||
|
|
@ -13,11 +13,9 @@ class OrderByGroups < OrderPdf
|
|||
def body
|
||||
# Start rendering
|
||||
@order.group_orders.each do |group_order|
|
||||
text group_order.ordergroup.name, size: 9, style: :bold
|
||||
|
||||
total = 0
|
||||
rows = []
|
||||
rows << I18n.t('documents.order_by_groups.rows') # Table Header
|
||||
dimrows = []
|
||||
|
||||
group_order_articles = group_order.group_order_articles.ordered
|
||||
group_order_articles.each do |goa|
|
||||
|
|
@ -25,15 +23,20 @@ class OrderByGroups < OrderPdf
|
|||
sub_total = price * goa.result
|
||||
total += sub_total
|
||||
rows << [goa.order_article.article.name,
|
||||
"#{goa.quantity} + #{goa.tolerance}",
|
||||
goa.result,
|
||||
number_with_precision(price, precision: 2),
|
||||
goa.order_article.price.unit_quantity,
|
||||
goa.order_article.article.unit,
|
||||
number_with_precision(sub_total, precision: 2)]
|
||||
dimrows << rows.length if goa.result == 0
|
||||
end
|
||||
rows << [ I18n.t('documents.order_by_groups.sum'), nil, nil, nil, nil, number_with_precision(total, precision: 2)]
|
||||
next if rows.length == 0
|
||||
rows << [ I18n.t('documents.order_by_groups.sum'), nil, nil, nil, nil, nil, number_with_precision(total, precision: 2)]
|
||||
rows.unshift I18n.t('documents.order_by_groups.rows') # Table Header
|
||||
|
||||
table rows, column_widths: [250,50,50,50,50,50], cell_style: {size: 8, overflow: :shrink_to_fit} do |table|
|
||||
text group_order.ordergroup.name, size: 9, style: :bold
|
||||
table rows, width: 500, cell_style: {size: 8, overflow: :shrink_to_fit} do |table|
|
||||
# borders
|
||||
table.cells.borders = []
|
||||
table.row(0).borders = [:bottom]
|
||||
|
|
@ -41,8 +44,14 @@ class OrderByGroups < OrderPdf
|
|||
table.cells.border_width = 1
|
||||
table.cells.border_color = '666666'
|
||||
|
||||
table.columns(1..3).align = :right
|
||||
table.columns(5).align = :right
|
||||
table.column(0).width = 240
|
||||
table.column(2).font_style = :bold
|
||||
table.columns(1..4).align = :right
|
||||
table.column(6).align = :right
|
||||
table.column(6).font_style = :bold
|
||||
|
||||
# dim rows which were ordered but not received
|
||||
dimrows.each { |ri| table.row(ri).text_color = '999999' }
|
||||
end
|
||||
|
||||
move_down 15
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue