Class: DtefacilXmlBuilder::DteReader
- Inherits:
-
Object
- Object
- DtefacilXmlBuilder::DteReader
- Defined in:
- lib/dtefacil_xml_builder/dte_reader.rb
Instance Attribute Summary collapse
-
#collection ⇒ Object
Returns the value of attribute collection.
-
#detalles ⇒ Object
Returns the value of attribute detalles.
-
#folio ⇒ Object
Returns the value of attribute folio.
-
#receptor ⇒ Object
Returns the value of attribute receptor.
-
#tipo ⇒ Object
Returns the value of attribute tipo.
Instance Method Summary collapse
Instance Attribute Details
#collection ⇒ Object
Returns the value of attribute collection.
6 7 8 |
# File 'lib/dtefacil_xml_builder/dte_reader.rb', line 6 def collection @collection end |
#detalles ⇒ Object
Returns the value of attribute detalles.
6 7 8 |
# File 'lib/dtefacil_xml_builder/dte_reader.rb', line 6 def detalles @detalles end |
#folio ⇒ Object
Returns the value of attribute folio.
6 7 8 |
# File 'lib/dtefacil_xml_builder/dte_reader.rb', line 6 def folio @folio end |
#receptor ⇒ Object
Returns the value of attribute receptor.
6 7 8 |
# File 'lib/dtefacil_xml_builder/dte_reader.rb', line 6 def receptor @receptor end |
#tipo ⇒ Object
Returns the value of attribute tipo.
6 7 8 |
# File 'lib/dtefacil_xml_builder/dte_reader.rb', line 6 def tipo @tipo end |
Instance Method Details
#dte=(xml) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/dtefacil_xml_builder/dte_reader.rb', line 8 def dte= xml ref = XmlSimple.xml_in xml id_doc_hash = ref['Documento'].map{ |i| i['Encabezado'].map{|f| f['IdDoc']}}.flatten receptor_hash = ref['Documento'].map{ |i| i['Encabezado'].map{|f| f['Receptor']}}.flatten @tipo = id_doc_hash.first["TipoDTE"].first @folio = id_doc_hash.first["Folio"].first r = Receptor.new r.rut= receptor_hash.first["RUTRecep"].first r.= receptor_hash.first["RznSocRecep"].first r.giro= receptor_hash.first["GiroRecep"].first r.direccion= receptor_hash.first["DirRecep"].first r.comuna= receptor_hash.first["CmnaRecep"].first r.ciudad= receptor_hash.first["CiudadRecep"].first @receptor=r @detalles=[] detalles_hash_array= ref['Documento'].map{ |d| d['Detalle']}.flatten detalles_hash_array.each do |det| d = Detalle.new d.nombre= det["NmbItem"].first d.numero_linea=det["NroLinDet"].first d.cantidad=det["QtyItem"].first d.precio_unitario=det["PrcItem"].first d.monto= det["MontoItems"].first if det["DescuentoMonto"].first d.descuento= det["DescuentoMonto"].first end if det["IndExe"].first d.exento= true end if det["UnmdItem"].first d.unidad= det["UnmdItem"].first end @detalles[@detalles.length]=d end end |