class BrDanfe::DanfeLib::NfeLib::InfadicVol

Public Class Methods

new(xml, pdf) click to toggle source
# File lib/br_danfe/danfe_lib/nfe_lib/infadic_vol.rb, line 5
def initialize(xml, pdf)
  @xml = xml
  @pdf = pdf
  @y_position = 27.56
end

Public Instance Methods

render() click to toggle source
# File lib/br_danfe/danfe_lib/nfe_lib/infadic_vol.rb, line 11
def render
  render_volume_title
  render_volume
end

Private Instance Methods

render_esp(det, y_position) click to toggle source
# File lib/br_danfe/danfe_lib/nfe_lib/infadic_vol.rb, line 46
def render_esp(det, y_position)
  render_item_title 0.5, 1.35, 'esp', y_position
  render_item_field det.css('esp').text, 3, 1.75, y_position
end
render_fields(det, y_position) click to toggle source
# File lib/br_danfe/danfe_lib/nfe_lib/infadic_vol.rb, line 37
def render_fields(det, y_position)
  render_esp det, y_position
  render_marca det, y_position
  render_qvol det, y_position
  render_nvol det, y_position
  render_pesob det, y_position
  render_pesol det, y_position
end
render_item_field(value, width, x_position, y_position) click to toggle source
# File lib/br_danfe/danfe_lib/nfe_lib/infadic_vol.rb, line 60
def render_item_field(value, width, x_position, y_position)
  @pdf.ibox 0.35, width, x_position, y_position, '', value, style_italic
end
render_item_title(width, x_position, field, y_position) click to toggle source
# File lib/br_danfe/danfe_lib/nfe_lib/infadic_vol.rb, line 51
def render_item_title(width, x_position, field, y_position)
  label = I18n.t("danfe.infAdic.vol.#{field}")
  @pdf.ibox 0.35, width, x_position, y_position, '', label, style_normal
end
render_marca(det, y_position) click to toggle source
# File lib/br_danfe/danfe_lib/nfe_lib/infadic_vol.rb, line 68
def render_marca(det, y_position)
  render_item_title 0.7, 4.15, 'marca', y_position
  render_item_field det.css('marca').text, 2, 4.75, y_position
end
render_nvol(det, y_position) click to toggle source
# File lib/br_danfe/danfe_lib/nfe_lib/infadic_vol.rb, line 78
def render_nvol(det, y_position)
  render_item_title 1, 6.1, 'nVol', y_position
  render_item_field det.css('nVol').text, 1, 6.7, y_position
end
render_peso_item_field(value, width, x_position, y_pos) click to toggle source
# File lib/br_danfe/danfe_lib/nfe_lib/infadic_vol.rb, line 88
def render_peso_item_field(value, width, x_position, y_pos)
  @pdf.inumeric 0.35, width, x_position, y_pos, '', value, style_decimal
end
render_pesob(det, y_position) click to toggle source
# File lib/br_danfe/danfe_lib/nfe_lib/infadic_vol.rb, line 83
def render_pesob(det, y_position)
  render_item_title 1.3, 7, 'pesoB', y_position
  render_peso_item_field det.css('pesoB').text, 1.3, 7, y_position
end
render_pesol(det, y_position) click to toggle source
# File lib/br_danfe/danfe_lib/nfe_lib/infadic_vol.rb, line 96
def render_pesol(det, y_position)
  render_item_title 0.9, 8.5, 'pesoL', y_position
  render_peso_item_field det.css('pesoL').text, 1.5, 8.5, y_position
end
render_qvol(det, y_position) click to toggle source
# File lib/br_danfe/danfe_lib/nfe_lib/infadic_vol.rb, line 73
def render_qvol(det, y_position)
  render_item_title 0.7, 0.75, 'qVol', y_position
  render_item_field det.css('qVol').text, 0.7, 1.04, y_position
end
render_volume() click to toggle source
# File lib/br_danfe/danfe_lib/nfe_lib/infadic_vol.rb, line 23
def render_volume
  volumes = 0
  y_position = @y_position + 0.47

  @xml.collect('xmlns', 'vol') do |det|
    volumes += 1

    if volumes > 1
      render_fields det, y_position
      y_position += 0.15
    end
  end
end
render_volume_title() click to toggle source
# File lib/br_danfe/danfe_lib/nfe_lib/infadic_vol.rb, line 18
def render_volume_title
  @pdf.ibox 2.65, 12.45, 0.75, @y_position + 0.30, '', I18n.t('danfe.infAdic.vol.title'), size: 5, valign: :top,
    border: 0
end
style_decimal() click to toggle source
# File lib/br_danfe/danfe_lib/nfe_lib/infadic_vol.rb, line 92
def style_decimal
  style_italic.merge(decimals: 3)
end
style_italic() click to toggle source
# File lib/br_danfe/danfe_lib/nfe_lib/infadic_vol.rb, line 64
def style_italic
  style_normal.merge(style: :italic)
end
style_normal() click to toggle source
# File lib/br_danfe/danfe_lib/nfe_lib/infadic_vol.rb, line 56
def style_normal
  { size: 4, border: 0 }
end