fm_timbrado_cfdi 0.0.4 → 0.0.5

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c53655154992b61d9112255b533ee3e53c96edc4
4
- data.tar.gz: 5223cc5a316f3e155fb393e8c81fdf9be5147a40
3
+ metadata.gz: fbc2bf017ec4bad2e4f98767fe8d7bb7063acc6b
4
+ data.tar.gz: ade15dfa5710859dc6ab817ac561089e335a4c44
5
5
  SHA512:
6
- metadata.gz: 1577e3b67ca31f0800c44fc179e556d7d0dc4e5418fcceebe1d1e2595d25f995e864ec69c1759a24e5985d38b7da2aee9369732f66a58dac903ac8ad193f7ea1
7
- data.tar.gz: d57e5d66acfd1d04c6e271dfbac007d8d3c73bacbdddf29be48c7ce4d42e93ee75cb3ca83fdf66a61fd5c9c449552434a80899065580aa0defc3c5bdc1004a0f
6
+ metadata.gz: ca8bf36f2093873b44884c355e234bb75116834e7fc8903df498c22d29a1c3e65f88536e6370d8fed4df1394c2750fee57aacfdd239b5cd830fcfd98eb232484
7
+ data.tar.gz: d4496d0559a34de15bc6e153065b0d4bd9e6ff3bb719e35cde583321f5f3d14819a21a3890c47646488938c662f9e28820318e001e3c59a1d52b06f03c4b1a56
@@ -0,0 +1,51 @@
1
+ # -*- encoding : utf-8 -*-
2
+ require 'nokogiri'
3
+
4
+ module FmTimbradoCfdi
5
+ class FmInformacionCfdi
6
+ attr_reader :total, :subtotal, :descuento
7
+
8
+ def initialize ( nodo_timbre )
9
+ parse( nodo_timbre )
10
+ end
11
+
12
+ private
13
+ def parse ( nodo_timbre )
14
+ xml = Nokogiri::XML(nodo_timbre)
15
+ ns = generar_namespaces(xml)
16
+ atributos.each do |variable|
17
+ instance_variable_set("@#{variable}", send("obtener_#{variable}", xml, ns))
18
+ end
19
+ end
20
+
21
+ def atributos
22
+ [ 'total',
23
+ 'subtotal',
24
+ 'descuento',
25
+ ]
26
+ end
27
+
28
+ def obtener_total(xml,ns)
29
+ xml.xpath("//cfdi:Comprobante",ns).attribute('total').value rescue nil
30
+ end
31
+
32
+ def obtener_subtotal(xml,ns)
33
+ xml.xpath("//cfdi:Comprobante",ns).attribute('subTotal').value rescue nil
34
+ end
35
+
36
+ def obtener_descuento(xml,ns)
37
+ xml.xpath("//cfdi:Comprobante",ns).attribute('descuento').value rescue nil
38
+ end
39
+
40
+ def generar_namespaces(xml)
41
+ namespaces = xml.collect_namespaces
42
+ ns = {}
43
+ namespaces.each_pair do |key, value|
44
+ ns[key.sub(/^xmlns:/, '')] = value
45
+ end
46
+ ns
47
+ end
48
+
49
+ end
50
+ end
51
+
@@ -1,3 +1,3 @@
1
1
  module FmTimbradoCfdi
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -1,5 +1,6 @@
1
1
  require "fm_timbrado_cfdi/version"
2
2
  require "fm_timbrado_cfdi/fm_cliente"
3
+ require "fm_timbrado_cfdi/fm_informacion_cfdi"
3
4
  require 'nokogiri'
4
5
  require 'base64'
5
6
 
@@ -0,0 +1,17 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ describe FmTimbradoCfdi::FmInformacionCfdi do
5
+ context "debe crear un objeto válido" do
6
+ let(:plantilla){File.open('spec/fixtures/layout_example.txt').read}
7
+ let(:layout){ plantilla.gsub('--fecha-comprobante--', 'asignarFecha' )}
8
+ let(:respuesta){ FmTimbradoCfdi.timbra_cfdi_layout 'ESI920427886', layout }
9
+ let(:informacion) { FmTimbradoCfdi::FmInformacionCfdi.new(respuesta.xml)}
10
+ it { informacion.total.should_not be_nil }
11
+ it { informacion.total.should == "116.00"}
12
+ it { informacion.subtotal.should_not be_nil }
13
+ it { informacion.subtotal.should == "100.00"}
14
+ it { informacion.descuento.should_not be_nil }
15
+ it { informacion.descuento.should == "0.00" }
16
+ end
17
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fm_timbrado_cfdi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carlos García
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-01-11 00:00:00.000000000 Z
13
+ date: 2014-01-18 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: nokogiri
@@ -73,6 +73,7 @@ files:
73
73
  - fm_timbrado_cfdi.gemspec
74
74
  - lib/fm_timbrado_cfdi.rb
75
75
  - lib/fm_timbrado_cfdi/fm_cliente.rb
76
+ - lib/fm_timbrado_cfdi/fm_informacion_cfdi.rb
76
77
  - lib/fm_timbrado_cfdi/fm_respuesta.rb
77
78
  - lib/fm_timbrado_cfdi/fm_respuesta_cancelacion.rb
78
79
  - lib/fm_timbrado_cfdi/fm_timbre.rb
@@ -87,6 +88,7 @@ files:
87
88
  - spec/fixtures/soap_response.txt
88
89
  - spec/fixtures/soap_response_sin_xml.txt
89
90
  - spec/fixtures/timbre_example.txt
91
+ - spec/fm_timbrado_cfdi/fm_informacion_cfdi_spec.rb
90
92
  - spec/fm_timbrado_cfdi/fm_respuesta_spec.rb
91
93
  - spec/fm_timbrado_cfdi/fm_timbre_spec.rb
92
94
  - spec/fm_timbrado_cfdi_spec.rb
@@ -126,6 +128,7 @@ test_files:
126
128
  - spec/fixtures/soap_response.txt
127
129
  - spec/fixtures/soap_response_sin_xml.txt
128
130
  - spec/fixtures/timbre_example.txt
131
+ - spec/fm_timbrado_cfdi/fm_informacion_cfdi_spec.rb
129
132
  - spec/fm_timbrado_cfdi/fm_respuesta_spec.rb
130
133
  - spec/fm_timbrado_cfdi/fm_timbre_spec.rb
131
134
  - spec/fm_timbrado_cfdi_spec.rb