Class: RubyDanfe::Descricao

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_danfe/descricao.rb

Constant Summary collapse

LINEBREAK =
"\n"

Class Method Summary collapse

Class Method Details

.generate(det) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/ruby_danfe/descricao.rb', line 7

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