Class: Nfe::Models::Taxes::PISCOFINSAliq

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(xml_tax, xml_value) ⇒ PISCOFINSAliq

Returns a new instance of PISCOFINSAliq.



35
36
37
38
# File 'lib/nfe/models/taxes/PISCOFINSAliq.rb', line 35

def initialize(xml_tax, xml_value)
  @xml_tax = xml_tax
  @xml_value = xml_value
end

Instance Attribute Details

#cstObject

Returns the value of attribute cst.



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

def cst
  @cst
end

#taxObject

Returns the value of attribute tax.



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

def tax
  @tax
end

#valueObject

Returns the value of attribute value.



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

def value
  @value
end

#vBCObject

Returns the value of attribute vBC.



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

def vBC
  @vBC
end

Class Method Details

.cstsObject



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

def self.csts
  ["01", "02"]
end

Instance Method Details

#parse!(xml) ⇒ Object



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

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

  @cst = doc.css("CST").text.to_s
  @vBC = doc.css("vBC").text.to_f
  @tax = doc.css(@xml_tax).text.to_f
  @value = doc.css(@xml_value).text.to_f
end

#to_xmlObject



49
50
51
52
53
54
55
56
57
58
# File 'lib/nfe/models/taxes/PISCOFINSAliq.rb', line 49

def to_xml
  xml = Builder::XmlMarkup.new

  xml.CST "%2.2d" % @cst
  xml.vBC "%0.2f" % @vBC
  xml.tag!(@xml_tax) { |node| node << "%0.2f" % @tax }
  xml.tag!(@xml_value) { |node| node << "%0.2f" % @value }

  xml.target!
end