Sha256: 09b19c06bd32595327fc3ced7ee6fe3565097bf08ebde612a64edb7d2c74e67b

Contents?: true

Size: 1001 Bytes

Versions: 2

Compression:

Stored size: 1001 Bytes

Contents

#encoding: utf-8

module RubyDanfe
  class Descricao
    LINEBREAK = "\n"

    def self.generate(det)
      descricao = "#{det.css('prod/xProd').text}"

      if need_infAdProd(det)
        descricao += LINEBREAK
        descricao += det.css('infAdProd').text
      end

      if need_fci(det)
        descricao += LINEBREAK
        descricao += "FCI: #{det.css('prod/nFCI').text}"
      end

      if need_st(det)
        descricao += LINEBREAK
        descricao += "ST: MVA: #{det.css('ICMS/*/pMVAST').text}% "
        descricao += "* Alíq: #{det.css('ICMS/*/pICMSST').text}% "
        descricao += "* BC: #{det.css('ICMS/*/vBCST').text} "
        descricao += "* Vlr: #{det.css('ICMS/*/vICMSST').text}"
      end

      descricao
    end

    private
    def self.need_infAdProd(det)
      !det.css('infAdProd').text.empty?
    end

    def self.need_fci(det)
      !det.css('prod/nFCI').text.empty?
    end

    def self.need_st(det)
      det.css('ICMS/*/vBCST').text.to_i > 0
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ruby_danfe-1.13.2 lib/ruby_danfe/descricao.rb
ruby_danfe-1.11.5 lib/ruby_danfe/descricao.rb