module BrInvoicesPdf::Util::ProductTable
Constants
- PRODUCT_TABLE_BASE_DATA
Public Instance Methods
format_columns(table)
click to toggle source
:reek: FeatureEnvy
# File lib/br_invoices_pdf/util/product_table.rb, line 40 def format_columns(table) table.columns(0..5).valign = :center table.columns([2, 4, 5]).align = :right table.column(3).align = :center table_widths(table, table.width) end
format_row(row)
click to toggle source
# File lib/br_invoices_pdf/util/product_table.rb, line 33 def format_row(row) row.font_style = :bold row.align = :center end
format_table(pdf, table_data)
click to toggle source
# File lib/br_invoices_pdf/util/product_table.rb, line 24 def format_table(pdf, table_data) width = page_content_width(pdf) pdf.table(table_data, width: width) do |table| format_row(table.row(0)) format_columns(table) end end
product_table_data(data)
click to toggle source
:reek: FeatureEnvy
# File lib/br_invoices_pdf/util/product_table.rb, line 10 def product_table_data(data) data[:products].reduce(PRODUCT_TABLE_BASE_DATA) do |result, cur| result + [[ cur[:code], cur[:description], format_number(cur[:quantity]), cur[:unit_label], format_currency(cur[:unit_value]), format_currency(cur[:total_value]) ]] end end
table_widths(table, width)
click to toggle source
:reek: FeatureEnvy
# File lib/br_invoices_pdf/util/product_table.rb, line 49 def table_widths(table, width) table.column(0).width = width * 0.16 table.columns([2, 3]).width = width * 0.155 table.column([4, 5]).width = width * 0.135 end