facturacr 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/facturacr/document.rb +14 -12
- data/lib/facturacr/version.rb +1 -1
- data/lib/facturacr/xml_document.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3a5cf5ef7edefc4aef38f422576a458bc84fed4e
|
4
|
+
data.tar.gz: 952e768fd54967165beaf6e681441ea676f4473c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db9f36b65f272d525f31e6c8ee5b0029a1196152ca093c5ec2df54f9c7b7febb4b7dd7f05469785426d2c89493e0c476930440e3e14ca2a66b877ecdf9e470e6
|
7
|
+
data.tar.gz: fd33ac8bdf1111ef021baa0f85b378c981da051783e52cb165579f8cea0394c279826e107831f3c52c375c8ec350f5b5953bc53e5f424001e24fc7236630ba4a
|
data/lib/facturacr/document.rb
CHANGED
@@ -43,7 +43,7 @@ module FE
|
|
43
43
|
:payment_type, :service_type, :reference_information,
|
44
44
|
:regulation, :number, :document_type, :security_code,
|
45
45
|
:items, :references, :namespaces, :summary, :document_situation,
|
46
|
-
:headquarters, :terminal, :others
|
46
|
+
:headquarters, :terminal, :others, :key
|
47
47
|
|
48
48
|
validates :date, presence: true
|
49
49
|
validates :number, presence: true
|
@@ -68,20 +68,22 @@ module FE
|
|
68
68
|
end
|
69
69
|
|
70
70
|
def key
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
71
|
+
@key ||= begin
|
72
|
+
raise "Documento inválido: #{errors.messages}" unless valid?
|
73
|
+
country = "506"
|
74
|
+
day = "%02d" % @date.day
|
75
|
+
month = "%02d" % @date.month
|
76
|
+
year = "%02d" % (@date.year - 2000)
|
77
|
+
id_number = @issuer.identification_document.id_number
|
77
78
|
|
78
|
-
|
79
|
-
|
79
|
+
type = @document_situation
|
80
|
+
security_code = @security_code
|
80
81
|
|
81
|
-
|
82
|
-
|
82
|
+
result = "#{country}#{day}#{month}#{year}#{id_number}#{sequence}#{type}#{security_code}"
|
83
|
+
raise "The key is invalid: #{result}" unless result.length.eql?(50)
|
83
84
|
|
84
|
-
|
85
|
+
result
|
86
|
+
end
|
85
87
|
end
|
86
88
|
|
87
89
|
def headquarters
|
data/lib/facturacr/version.rb
CHANGED
@@ -35,6 +35,7 @@ module FE
|
|
35
35
|
if @document.is_a?(FE::Document)
|
36
36
|
@document.date = DateTime.parse(@doc.css("#{root_tag} FechaEmision").text)
|
37
37
|
@key = @doc.css("#{root_tag} Clave").text
|
38
|
+
@document.key = @key if @key.present?
|
38
39
|
@document.number = @key[31..40].to_i
|
39
40
|
@document.document_situation = @key[41]
|
40
41
|
@document.security_code = @key[42..-1]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: facturacr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josef Sauter
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-11-
|
11
|
+
date: 2018-11-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|