dtefacil_xml_builder 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/dtefacil_xml_builder.gemspec +1 -0
- data/lib/dtefacil_xml_builder/detalle.rb +7 -2
- data/lib/dtefacil_xml_builder/documentos.rb +55 -4
- data/lib/dtefacil_xml_builder/dte_builder.rb +7 -4
- data/lib/dtefacil_xml_builder/test_documents.rb +17 -6
- data/lib/dtefacil_xml_builder/version.rb +1 -1
- metadata +18 -2
@@ -1,9 +1,10 @@
|
|
1
1
|
module DtefacilXmlBuilder
|
2
2
|
class Detalle
|
3
|
-
attr_accessor :nombre, :cantidad, :precio_unitario, :descuento, :unidad, :exento
|
3
|
+
attr_accessor :nombre, :descripcion, :cantidad, :precio_unitario, :descuento, :unidad, :exento
|
4
4
|
|
5
|
-
def set_all_attr nombre, cantidad, precio_unitario, descuento, unidad, exento
|
5
|
+
def set_all_attr nombre, descripcion, cantidad, precio_unitario, descuento, unidad, exento
|
6
6
|
@nombre= nombre
|
7
|
+
@descripcion= descripcion
|
7
8
|
@cantidad= cantidad
|
8
9
|
@precio_unitario= precio_unitario
|
9
10
|
@descuento= descuento
|
@@ -18,6 +19,10 @@ module DtefacilXmlBuilder
|
|
18
19
|
@cantidad = detalle[:cantidad]
|
19
20
|
@precio_unitario = detalle[:precio_unitario]
|
20
21
|
|
22
|
+
if detalle[:descripcion]
|
23
|
+
@descripcion=detalle[:descripcion]
|
24
|
+
end
|
25
|
+
|
21
26
|
if detalle[:descuento]
|
22
27
|
@descuento = detalle[:descuento]
|
23
28
|
end
|
@@ -24,12 +24,63 @@ module DtefacilXmlBuilder
|
|
24
24
|
def render_xml
|
25
25
|
dtebuilder = DteBuilder.new
|
26
26
|
|
27
|
-
xml = Builder::XmlMarkup.new
|
27
|
+
xml = Builder::XmlMarkup.new
|
28
28
|
xml.instruct!(:xml, version: "1.0", encoding: "ISO-8859-1")
|
29
29
|
xml.facturaElectronica(xmlns: "http://dtefacil.cl/1.2"){
|
30
|
-
|
31
|
-
|
32
|
-
|
30
|
+
|f|
|
31
|
+
actividades_economicas.each do |act|
|
32
|
+
f.actividadEconomica act
|
33
|
+
end
|
34
|
+
|
35
|
+
f.receptor {
|
36
|
+
|r|
|
37
|
+
r.rut receptor.rut
|
38
|
+
r.razonSocial receptor.razon_social
|
39
|
+
r.giro receptor.giro
|
40
|
+
r.ubicacion{
|
41
|
+
|u|
|
42
|
+
u.direccion receptor.direccion
|
43
|
+
u.comuna receptor.comuna
|
44
|
+
u.ciudad receptor.ciudad
|
45
|
+
}
|
46
|
+
}
|
47
|
+
|
48
|
+
f.detalles {
|
49
|
+
|d|
|
50
|
+
#if descuento
|
51
|
+
# d.descuento{
|
52
|
+
# |desc|
|
53
|
+
# desc.porcentaje(descuento)
|
54
|
+
# }
|
55
|
+
#end
|
56
|
+
|
57
|
+
detalles.each do |detalle|
|
58
|
+
d.detalle{
|
59
|
+
|det|
|
60
|
+
det.nombre(detalle.nombre)
|
61
|
+
det.cantidad(detalle.cantidad)
|
62
|
+
det.precioUnitario(detalle.precio_unitario)
|
63
|
+
|
64
|
+
#if detalle.unidad
|
65
|
+
# det.unidad(detalle.unidad)
|
66
|
+
#end
|
67
|
+
|
68
|
+
#if detalle.descuento
|
69
|
+
# det.descuento{
|
70
|
+
# |desc_det|
|
71
|
+
# desc_det.porcentaje(detalle.descuento)
|
72
|
+
# }
|
73
|
+
#end
|
74
|
+
|
75
|
+
#if detalle.exento
|
76
|
+
# det.observaciones{
|
77
|
+
# |obs|
|
78
|
+
# obs.exento
|
79
|
+
# }
|
80
|
+
#end
|
81
|
+
}
|
82
|
+
end
|
83
|
+
}
|
33
84
|
}
|
34
85
|
end
|
35
86
|
end
|
@@ -4,14 +4,17 @@ module DtefacilXmlBuilder
|
|
4
4
|
|
5
5
|
class DteBuilder
|
6
6
|
def create_actividades_economicas actividades_economicas
|
7
|
-
builder = Builder::XmlMarkup.new
|
7
|
+
builder = Builder::XmlMarkup.new
|
8
8
|
actividades_economicas.each do |act|
|
9
|
-
builder.actividadEconomica
|
10
|
-
|
9
|
+
#builder.actividadEconomica "asdfasdf"
|
10
|
+
puts "asdfasf"
|
11
|
+
end
|
12
|
+
#builder.actividadEconomica "asdfas"
|
11
13
|
end
|
12
14
|
|
15
|
+
|
13
16
|
def create_detalles detalles, descuento
|
14
|
-
builder = Builder::XmlMarkup.new
|
17
|
+
builder = Builder::XmlMarkup.new
|
15
18
|
builder.detalles {
|
16
19
|
|d|
|
17
20
|
if descuento
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'rest-client'
|
2
|
+
|
1
3
|
module DtefacilXmlBuilder
|
2
4
|
class TestDocuments
|
3
5
|
|
@@ -7,20 +9,29 @@ module DtefacilXmlBuilder
|
|
7
9
|
d = Detalle.new
|
8
10
|
|
9
11
|
r.set_all_attr "15842089-9", "Vladimir Suarez", "Informaciones", "Pajaritos 345", "Maipu", "Santiago"
|
10
|
-
d.set_all_attr "
|
11
|
-
f.actividades_economicas= [
|
12
|
+
d.set_all_attr "CompuGay", "asdfaf", 4, 456, 0.1, "UF", true
|
13
|
+
f.actividades_economicas= [324]
|
12
14
|
f.descuento= 0.2
|
13
15
|
f.receptor= r
|
14
16
|
f.detalles= [d]
|
15
|
-
f.render_xml
|
17
|
+
#body = f.render_xml
|
18
|
+
#f.render_xml
|
19
|
+
#response = RestClient.get 'https://ptoTicket:pt0T1ck3t@api.dtefacil.cl/1.2/usuarios/yo'
|
20
|
+
#d = DteBuilder.new
|
21
|
+
|
22
|
+
|
23
|
+
response = RestClient.post 'https://ptoTicket:pt0T1ck3t@api.dtefacil.cl/1.2/documentos', f.render_xml, :content_type "Application/xml"
|
24
|
+
puts response.headers[:location]
|
25
|
+
|
16
26
|
end
|
17
27
|
|
18
28
|
def set_factura_electronica_with_hash
|
19
29
|
receptor = { :rut => "15842089-9", :razon_social => "Vladimir", :giro => "Computacion", :direccion => "Alameda", :comuna => "Santiago", :ciudad => "Satiago" }
|
20
|
-
detalles = [{:nombre => "Pelota", :cantidad => 3, :precio_unitario => 45
|
30
|
+
detalles = [{:nombre => "Pelota", :cantidad => 3, :precio_unitario => 45}]
|
21
31
|
f = FacturaElectronica.new
|
22
|
-
f.set_factura [
|
23
|
-
f.render_xml
|
32
|
+
f.set_factura [324], receptor, detalles
|
33
|
+
body = f.render_xml
|
34
|
+
|
24
35
|
end
|
25
36
|
|
26
37
|
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.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-08-
|
12
|
+
date: 2012-08-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: builder
|
@@ -27,6 +27,22 @@ dependencies:
|
|
27
27
|
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rest-client
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
30
46
|
description: Facilita la construcción y manipulacion de xml necesarios para DTE Fácil
|
31
47
|
1.2
|
32
48
|
email:
|