Sha256: 60f6ba72b43d9915c084d3462df9b7ee6dcb719774c51ffaddb13ce81993399c

Contents?: true

Size: 1.15 KB

Versions: 3

Compression:

Stored size: 1.15 KB

Contents

module BrDanfe
  class Dup
    def initialize(pdf, xml)
      @pdf = pdf
      @xml = xml
    end

    def render
      @pdf.ititle 0.42, 10.00, 0.25, 11.12, "dup.title"
      @pdf.ibox 0.85, 20.57, 0.25, 11.51

      x = 0.25
      y = 11.51
      @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 = dtduplicata[8,2] + "/" + dtduplicata[5, 2] + "/" + dtduplicata[0, 4]
      dtduplicata
    end

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

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
br_danfe-0.0.4 lib/br_danfe/dup.rb
br_danfe-0.0.3 lib/br_danfe/dup.rb
br_danfe-0.0.2 lib/br_danfe/dup.rb