class BrDanfe::MdfeLib::Totalizer
Public Class Methods
Source
# File lib/br_danfe/mdfe_lib/totalizer.rb, line 4 def initialize(pdf, xml) @pdf = pdf @xml = xml end
Public Instance Methods
Source
# File lib/br_danfe/mdfe_lib/totalizer.rb, line 9 def generate generate_title nfe_quantity cte_quantity total_weight end
Private Instance Methods
Source
# File lib/br_danfe/mdfe_lib/totalizer.rb, line 45 def cte_quantity generate_box('QTD. CTe', '', 0) end
Source
# File lib/br_danfe/mdfe_lib/totalizer.rb, line 28 def generate_box(title, text, x_position, width = 60) @pdf.move_cursor_to 580 @pdf.stroke do @pdf.fill_color LIGHT_GRAY_COLOR @pdf.fill_rectangle([x_position, @pdf.cursor], width, 35) @pdf.fill_color BLACK_COLOR end @pdf.bounding_box([x_position, @pdf.cursor], width: width, height: 35) do @pdf.move_down 5 @pdf.text_box(title, size: 10, at: [3, @pdf.cursor]) @pdf.move_down 15 @pdf.text_box(text, size: 12, at: [3, @pdf.cursor]) end end
Source
# File lib/br_danfe/mdfe_lib/totalizer.rb, line 18 def generate_title title = 'Modelo Rodoviário de Carga' @pdf.text_box(title, size: 12, align: :left, style: :bold, at: [0, 600]) end
Source
# File lib/br_danfe/mdfe_lib/totalizer.rb, line 24 def nfe_quantity generate_box('QTD. NFe', @xml['qNFe'], 65) end
Source
# File lib/br_danfe/mdfe_lib/totalizer.rb, line 49 def total_weight weight = ActiveSupport::NumberHelper.number_to_rounded(@xml['qCarga'], precision: 2) weight = Helper.numerify(weight) generate_box('Peso total (Kg)', weight, 130, 90) end