Class: Nfe::Models::Taxes::PISCOFINSQtde

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(xml_value) ⇒ PISCOFINSQtde

Returns a new instance of PISCOFINSQtde.



31
32
33
# File 'lib/nfe/models/taxes/PISCOFINSQtde.rb', line 31

def initialize(xml_value)
  @xml_value = xml_value
end

Instance Attribute Details

#qBCProdObject

Returns the value of attribute qBCProd.



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

def qBCProd
  @qBCProd
end

#vAliqProdObject

Returns the value of attribute vAliqProd.



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

def vAliqProd
  @vAliqProd
end

#valueObject

Returns the value of attribute value.



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

def value
  @value
end

Instance Method Details

#cstObject



9
10
11
# File 'lib/nfe/models/taxes/PISCOFINSQtde.rb', line 9

def cst
  "03"
end

#parse!(xml) ⇒ Object



35
36
37
38
39
40
41
# File 'lib/nfe/models/taxes/PISCOFINSQtde.rb', line 35

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

  @qBCProd = doc.css("qBCProd").text.to_f
  @vAliqProd = doc.css("vAliqProd").text.to_f
  @value = doc.css(@xml_value).text.to_f
end

#to_xmlObject



43
44
45
46
47
48
49
50
51
52
# File 'lib/nfe/models/taxes/PISCOFINSQtde.rb', line 43

def to_xml
  xml = Builder::XmlMarkup.new

  xml.CST self.cst
  xml.qBCProd "%0.4f" % @qBCProd
  xml.vAliqProd "%0.4f" % @vAliqProd
  xml.tag!(@xml_value) { |node| node << "%0.2f" % @value }

  xml.target!
end