Class: Nfe::Models::Taxes::PISCOFINS

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model
Defined in:
lib/nfe/models/taxes/PISCOFINS.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type) ⇒ PISCOFINS



17
18
19
20
21
22
23
# File 'lib/nfe/models/taxes/PISCOFINS.rb', line 17

def initialize(type)
  if type == "cofins"
    @type = "COFINS"
  else
    @type = "PIS"
  end
end

Instance Attribute Details

#cstObject

Returns the value of attribute cst.



7
8
9
# File 'lib/nfe/models/taxes/PISCOFINS.rb', line 7

def cst
  @cst
end

#qBCProdObject

Returns the value of attribute qBCProd.



7
8
9
# File 'lib/nfe/models/taxes/PISCOFINS.rb', line 7

def qBCProd
  @qBCProd
end

#taxObject

Returns the value of attribute tax.



7
8
9
# File 'lib/nfe/models/taxes/PISCOFINS.rb', line 7

def tax
  @tax
end

#vAliqProdObject

Returns the value of attribute vAliqProd.



7
8
9
# File 'lib/nfe/models/taxes/PISCOFINS.rb', line 7

def vAliqProd
  @vAliqProd
end

#valueObject

Returns the value of attribute value.



7
8
9
# File 'lib/nfe/models/taxes/PISCOFINS.rb', line 7

def value
  @value
end

#vBCObject

Returns the value of attribute vBC.



7
8
9
# File 'lib/nfe/models/taxes/PISCOFINS.rb', line 7

def vBC
  @vBC
end

Instance Method Details

#parse!(xml) ⇒ Object



30
31
32
33
34
35
36
37
38
# File 'lib/nfe/models/taxes/PISCOFINS.rb', line 30

def parse!(xml)
  doc = Nokogiri::XML(xml)

  reset_values
  parse_when_aliq(doc)
  parse_when_qtde(doc)
  parse_when_nt(doc)
  parse_when_outr(doc)
end

#present?Boolean



25
26
27
28
# File 'lib/nfe/models/taxes/PISCOFINS.rb', line 25

def present?
  @cst.present? || @vBC.present? || @tax.present? || @qBCProd.present? ||
  @vAliqProd.present? || @qBCProd.present?
end

#to_xmlObject



40
41
42
43
44
45
46
47
48
49
# File 'lib/nfe/models/taxes/PISCOFINS.rb', line 40

def to_xml
  xml = Builder::XmlMarkup.new

  to_xml_when_aliq(xml)
  to_xml_when_qtde(xml)
  to_xml_when_nt(xml)
  to_xml_when_outr(xml)

  xml.target!
end