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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 68246bb16feef98b233a637240e1aa1d8006c211
4
- data.tar.gz: 2e1c8320dc3118bc00706d11e0e1658a22389a3b
3
+ metadata.gz: 3a5cf5ef7edefc4aef38f422576a458bc84fed4e
4
+ data.tar.gz: 952e768fd54967165beaf6e681441ea676f4473c
5
5
  SHA512:
6
- metadata.gz: 8f90a47cfa56d388408dae727b2fe254cff98ccf9539a16a460d2c6b13f812e19b9850615c9634c40e15d9b99a4925d79d0d0365786abb7322b26c276d8f03df
7
- data.tar.gz: c98466c34277acc0a7721efd8bec15444040a9d9567a5eda053ecfd6f7218dc7f2b5b1e311d4806dec1965746227176d14dbd5f0937e435530c8b953880f62be
6
+ metadata.gz: db9f36b65f272d525f31e6c8ee5b0029a1196152ca093c5ec2df54f9c7b7febb4b7dd7f05469785426d2c89493e0c476930440e3e14ca2a66b877ecdf9e470e6
7
+ data.tar.gz: fd33ac8bdf1111ef021baa0f85b378c981da051783e52cb165579f8cea0394c279826e107831f3c52c375c8ec350f5b5953bc53e5f424001e24fc7236630ba4a
@@ -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
- raise "Documento inválido: #{errors.messages}" unless valid?
72
- country = "506"
73
- day = "%02d" % @date.day
74
- month = "%02d" % @date.month
75
- year = "%02d" % (@date.year - 2000)
76
- id_number = @issuer.identification_document.id_number
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
- type = @document_situation
79
- security_code = @security_code
79
+ type = @document_situation
80
+ security_code = @security_code
80
81
 
81
- result = "#{country}#{day}#{month}#{year}#{id_number}#{sequence}#{type}#{security_code}"
82
- raise "The key is invalid: #{result}" unless result.length.eql?(50)
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
- result
85
+ result
86
+ end
85
87
  end
86
88
 
87
89
  def headquarters
@@ -1,3 +1,3 @@
1
1
  module FE
2
- VERSION = "1.0.4"
2
+ VERSION = "1.0.5"
3
3
  end
@@ -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
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-15 00:00:00.000000000 Z
11
+ date: 2018-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler