dtefacil_xml_builder 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/dtefacil_xml_builder.rb +1 -0
- data/lib/dtefacil_xml_builder/detalle.rb +11 -0
- data/lib/dtefacil_xml_builder/documentos.rb +20 -3
- data/lib/dtefacil_xml_builder/dte_builder.rb +3 -1
- data/lib/dtefacil_xml_builder/receptor.rb +9 -0
- data/lib/dtefacil_xml_builder/test_documents.rb +27 -0
- data/lib/dtefacil_xml_builder/version.rb +1 -1
- metadata +2 -1
data/lib/dtefacil_xml_builder.rb
CHANGED
@@ -1,6 +1,17 @@
|
|
1
1
|
module DtefacilXmlBuilder
|
2
2
|
class Detalle
|
3
3
|
attr_accessor :nombre, :cantidad, :precio_unitario, :descuento, :unidad, :exento
|
4
|
+
|
5
|
+
def set_all_attr nombre, cantidad, precio_unitario, descuento, unidad, exento
|
6
|
+
@nombre= nombre
|
7
|
+
@cantidad= cantidad
|
8
|
+
@precio_unitario= precio_unitario
|
9
|
+
@descuento= descuento
|
10
|
+
@unidad= unidad
|
11
|
+
@exento= exento
|
12
|
+
end
|
13
|
+
|
14
|
+
|
4
15
|
|
5
16
|
def set_detalle detalle
|
6
17
|
@nombre = detalle[:nombre]
|
@@ -1,11 +1,28 @@
|
|
1
|
+
require 'builder'
|
2
|
+
|
1
3
|
module DtefacilXmlBuilder
|
2
4
|
|
3
5
|
class FacturaElectronica
|
4
6
|
|
5
7
|
attr_accessor :descuento, :actividades_economicas, :receptor, :detalles
|
6
8
|
|
9
|
+
def set_factura actividades_economicas, receptor, detalles
|
10
|
+
@actividades_economicas=actividades_economicas
|
11
|
+
@r= Receptor.new
|
12
|
+
@r.set_receptor receptor
|
13
|
+
@receptor= @r
|
14
|
+
@detalles = []
|
15
|
+
|
16
|
+
detalles.each do |detalle|
|
17
|
+
@d = Detalle.new
|
18
|
+
@d.set_detalle detalle
|
19
|
+
@detalles[@detalles.length]=@d
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
|
7
24
|
def render_xml
|
8
|
-
dtebuilder =
|
25
|
+
dtebuilder = DteBuilder.new
|
9
26
|
|
10
27
|
xml = Builder::XmlMarkup.new(:target=>STDOUT, :indent=>2)
|
11
28
|
xml.instruct!(:xml, version: "1.0", encoding: "ISO-8859-1")
|
@@ -23,7 +40,7 @@ module DtefacilXmlBuilder
|
|
23
40
|
attr_accessor :referencia, :tipo, :receptor, :detalles
|
24
41
|
|
25
42
|
def render_xml
|
26
|
-
dtebuilder =
|
43
|
+
dtebuilder = DteBuilder.new
|
27
44
|
|
28
45
|
xml = Builder::XmlMarkup.new(:target=>STDOUT, :indent=>2)
|
29
46
|
xml.instruct!(:xml, version: "1.0", encoding: "ISO-8859-1")
|
@@ -54,7 +71,7 @@ module DtefacilXmlBuilder
|
|
54
71
|
attr_accessor :descuento, :actividades_economicas, :receptor, :detalles
|
55
72
|
|
56
73
|
def render_xml
|
57
|
-
dtebuilder =
|
74
|
+
dtebuilder = DteBuilder.new
|
58
75
|
|
59
76
|
xml = Builder::XmlMarkup.new(:target=>STDOUT, :indent=>2)
|
60
77
|
xml.instruct!(:xml, version: "1.0", encoding: "ISO-8859-1")
|
@@ -2,6 +2,15 @@ module DtefacilXmlBuilder
|
|
2
2
|
class Receptor
|
3
3
|
attr_accessor :rut, :razon_social, :giro, :direccion, :comuna, :ciudad
|
4
4
|
|
5
|
+
def set_all_attr rut, razon_social, giro, direccion, comuna, ciudad
|
6
|
+
@rut = rut
|
7
|
+
@razon_social = razon_social
|
8
|
+
@giro = giro
|
9
|
+
@direccion = direccion
|
10
|
+
@comuna = comuna
|
11
|
+
@ciudad = ciudad
|
12
|
+
end
|
13
|
+
|
5
14
|
def set_receptor receptor
|
6
15
|
@rut = receptor[:rut]
|
7
16
|
@razon_social = receptor[:razon_social]
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module DtefacilXmlBuilder
|
2
|
+
class TestDocuments
|
3
|
+
|
4
|
+
def factura_electronica_test
|
5
|
+
f = FacturaElectronica.new
|
6
|
+
r = Receptor.new
|
7
|
+
d = Detalle.new
|
8
|
+
|
9
|
+
r.set_all_attr "15842089-9", "Vladimir Suarez", "Informaciones", "Pajaritos 345", "Maipu", "Santiago"
|
10
|
+
d.set_all_attr "Pelota", 4, 456, 0.1, "UF", true
|
11
|
+
f.actividades_economicas= [345, 546, 56767]
|
12
|
+
f.descuento= 0.2
|
13
|
+
f.receptor= r
|
14
|
+
f.detalles= [d]
|
15
|
+
f.render_xml
|
16
|
+
end
|
17
|
+
|
18
|
+
def set_factura_electronica_with_hash
|
19
|
+
receptor = { :rut => "15842089-9", :razon_social => "Vladimir", :giro => "Computacion", :direccion => "Alameda", :comuna => "Santiago", :ciudad => "Satiago" }
|
20
|
+
detalles = [{:nombre => "Pelota", :cantidad => 3, :precio_unitario => 45, :descuento => 0.4, :unidad => "UF", :exento => true}]
|
21
|
+
f = FacturaElectronica.new
|
22
|
+
f.set_factura [345, 345, 345], receptor, detalles
|
23
|
+
f.render_xml
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dtefacil_xml_builder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -46,6 +46,7 @@ files:
|
|
46
46
|
- lib/dtefacil_xml_builder/documentos.rb
|
47
47
|
- lib/dtefacil_xml_builder/dte_builder.rb
|
48
48
|
- lib/dtefacil_xml_builder/receptor.rb
|
49
|
+
- lib/dtefacil_xml_builder/test_documents.rb
|
49
50
|
- lib/dtefacil_xml_builder/version.rb
|
50
51
|
homepage: ''
|
51
52
|
licenses: []
|