Sha256: 6cd369ff4916e41920455eb559b09443c4cea8a7eae03c46df52497718973581

Contents?: true

Size: 1.34 KB

Versions: 11

Compression:

Stored size: 1.34 KB

Contents

module BrDanfe
  module DanfeLib
    module NfeLib
      class Dup
        Y = 12.92

        def initialize(pdf, xml)
          @pdf = pdf
          @xml = xml

          @ltitle = Y - 0.42
        end

        def render
          @pdf.ititle 0.42, 10.00, 0.75, @ltitle, 'dup.title'
          @pdf.ibox 0.85, 19.57, 0.75, Y

          x = 0.75
          y = Y
          @xml.collect('xmlns', 'dup') do |det|
            render_dup(det, x, y)
            x += 2.30
          end
        end

        private

        def render_dup(det, x, y)
          @pdf.ibox 0.85, 2.12, x, y, '', I18n.t('danfe.dup.nDup'), italic
          @pdf.ibox 0.85, 2.12, x + 0.70, y, '', det.css('nDup').text, normal
          @pdf.ibox 0.85, 2.12, x, y + 0.20, '', I18n.t('danfe.dup.dVenc'), italic

          @pdf.ibox 0.85, 2.12, x + 0.70, y + 0.20, '', dtduplicata(det), normal

          @pdf.ibox 0.85, 2.12, x, y + 0.40, '', I18n.t('danfe.dup.vDup'), italic
          @pdf.inumeric 0.85, 1.25, x + 0.70, y + 0.40, '', det.css('vDup').text, normal
        end

        def dtduplicata(det)
          dtduplicata = det.css('dVenc').text
          "#{dtduplicata[8, 2]}/#{dtduplicata[5, 2]}/#{dtduplicata[0, 4]}"
        end

        def normal
          { size: 6, border: 0 }
        end

        def italic
          normal.merge(style: :italic)
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
br_danfe-0.20.0 lib/br_danfe/danfe_lib/nfe_lib/dup.rb
br_danfe-0.19.0 lib/br_danfe/danfe_lib/nfe_lib/dup.rb
br_danfe-0.18.0 lib/br_danfe/danfe_lib/nfe_lib/dup.rb
br_danfe-0.17.8 lib/br_danfe/danfe_lib/nfe_lib/dup.rb
br_danfe-0.17.7 lib/br_danfe/danfe_lib/nfe_lib/dup.rb
br_danfe-0.17.6 lib/br_danfe/danfe_lib/nfe_lib/dup.rb
br_danfe-0.17.5 lib/br_danfe/danfe_lib/nfe_lib/dup.rb
br_danfe-0.17.4 lib/br_danfe/danfe_lib/nfe_lib/dup.rb
br_danfe-0.17.3 lib/br_danfe/danfe_lib/nfe_lib/dup.rb
br_danfe-0.17.2 lib/br_danfe/danfe_lib/nfe_lib/dup.rb
br_danfe-0.17.1 lib/br_danfe/danfe_lib/nfe_lib/dup.rb