Sha256: 7f6a3ebda801ebf7165fb5910def014548f1202ed349dada19e60d8d8098043b

Contents?: true

Size: 1.07 KB

Versions: 5

Compression:

Stored size: 1.07 KB

Contents

module BrDanfe
  module DanfeLib
    module NfeLib
      class Issqn
        attr_reader :y_position

        Y_POSITION = 25.72 + SPACE_BETWEEN_GROUPS

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

          @y_position = Entrega.delivery_local?(@xml) ? Y_POSITION + 3.00 : Y_POSITION
          @title = @y_position - 0.42

          @serv = 'total/ISSQNtot/vServ'
          @bc = 'total/ISSQNtot/vBC'
          @iss = 'total/ISSQNtot/vISS'
        end

        def render
          if can_render?
            @pdf.ititle 0.42, 10.00, 0.75, @title, 'issqn.title'
            @pdf.lbox LINE_HEIGHT, 4.64, 0.75, @y_position, @xml, 'emit/IM'
            @pdf.lnumeric LINE_HEIGHT, 5.14, 5.39, @y_position, @xml, @serv
            @pdf.lnumeric LINE_HEIGHT, 5.14, 10.53, @y_position, @xml, @bc
            @pdf.lnumeric LINE_HEIGHT, 4.64, 15.67, @y_position, @xml, @iss
          end
        end

        private

        def can_render?
          @xml[@serv].to_f.positive? || @xml[@bc].to_f.positive? || @xml[@iss].to_f.positive?
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
br_danfe-1.2.2 lib/br_danfe/danfe_lib/nfe_lib/issqn.rb
br_danfe-1.2.1 lib/br_danfe/danfe_lib/nfe_lib/issqn.rb
br_danfe-1.2.0 lib/br_danfe/danfe_lib/nfe_lib/issqn.rb
br_danfe-1.1.0 lib/br_danfe/danfe_lib/nfe_lib/issqn.rb
br_danfe-1.0.0 lib/br_danfe/danfe_lib/nfe_lib/issqn.rb