Class: Nfe::Models::Taxes::PISCOFINSOutr
- Inherits:
-
Object
- Object
- Nfe::Models::Taxes::PISCOFINSOutr
- Includes:
- ActiveModel::Model, Helpers::XmlModel::NfeModel
- Defined in:
- lib/nfe/models/taxes/PISCOFINSOutr.rb
Instance Attribute Summary collapse
-
#tax ⇒ Object
Returns the value of attribute tax.
-
#value ⇒ Object
Returns the value of attribute value.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(xml_tax, xml_value) ⇒ PISCOFINSOutr
constructor
A new instance of PISCOFINSOutr.
- #parse!(xml) ⇒ Object
- #to_xml ⇒ Object
Methods included from Helpers::XmlModel::NfeModel
#add_elements, #check_present, included, #parse_elements, #present?, #validate_optional_attributes, #validate_required_attributes
Constructor Details
#initialize(xml_tax, xml_value) ⇒ PISCOFINSOutr
Returns a new instance of PISCOFINSOutr.
60 61 62 63 |
# File 'lib/nfe/models/taxes/PISCOFINSOutr.rb', line 60 def initialize(xml_tax, xml_value) @xml_tax = xml_tax @xml_value = xml_value end |
Instance Attribute Details
#tax ⇒ Object
Returns the value of attribute tax.
13 14 15 |
# File 'lib/nfe/models/taxes/PISCOFINSOutr.rb', line 13 def tax @tax end |
#value ⇒ Object
Returns the value of attribute value.
13 14 15 |
# File 'lib/nfe/models/taxes/PISCOFINSOutr.rb', line 13 def value @value end |
Class Method Details
.csts ⇒ Object
15 16 17 18 19 |
# File 'lib/nfe/models/taxes/PISCOFINSOutr.rb', line 15 def self.csts ["49", "50", "51", "52", "53", "54", "55", "56", "60", "61", "62", "63", "64", "65", "66", "67", "70", "71", "72", "73", "74", "75", "98", "99"] end |
Instance Method Details
#parse!(xml) ⇒ Object
66 67 68 69 70 71 72 |
# File 'lib/nfe/models/taxes/PISCOFINSOutr.rb', line 66 def parse!(xml) doc = Nokogiri::XML(xml) parse_elements doc @tax = doc.css(@xml_tax).present? ? doc.css(@xml_tax).text.to_f : nil @value = doc.css(@xml_value).text.to_f end |
#to_xml ⇒ Object
74 75 76 77 78 79 80 81 82 83 |
# File 'lib/nfe/models/taxes/PISCOFINSOutr.rb', line 74 def to_xml xml = Builder::XmlMarkup.new add_elements xml, :cst, :vBC xml.tag!(@xml_tax) { |node| node << "%0.2f" % @tax } if @tax.present? add_elements xml, :qBCProd, :vAliqProd xml.tag!(@xml_value) { |node| node << "%0.2f" % @value } xml.target! end |