teodoro 0.40.2 → 0.40.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: efa860014fc3400f46dd178668f23c99a5038da1365d0ac01ffb79b84289b4d1
4
- data.tar.gz: c3611aeedb378f6b51c4e5f190c10d7c861278a3491ea4cab5e4c6c57ab94d73
3
+ metadata.gz: 29ec7f364493911d10565a2501b275843a19f6bd18a345d96ad595a2c02fa615
4
+ data.tar.gz: 1962eedd713cf5d5d0402fecfd675ee95f93047914625e358d578396320555ac
5
5
  SHA512:
6
- metadata.gz: 15cc83830666bff67c99e9ffc428d894f9552f5df6936091d10e2d3af5d5bb68fff4b61239ae75cb06a532c6d8248af3860bdc12cd7f2ce6b6da3cd00bcd156d
7
- data.tar.gz: c53d0a46636325d37ba379f42c356f49f680fea8325ff5fb5a19cbfca3e9d641eb6796733b2a646dac18e6870aa457bd8d0b0f72613b7a6a1d94ec42ddc4738b
6
+ metadata.gz: c850788fc616fc813fbdd3659026cdfb057afa316c21bc61e4d32b0a79e03bf2b50d0a258cfad904ba6a2c1cb8dc02b53552c8a102dc2320bfd8dea41c83f614
7
+ data.tar.gz: a822530efec002f1147d9313801dfb1aa657e1b269e924e70dfd6c5ce01dacab147a4472044b6043fa78df7a6274ea7313d60f5d9bd707ce84429291b5cda100
data/lib/teodoro.rb CHANGED
@@ -12,7 +12,7 @@ require_relative 'teodoro/empresa'
12
12
  require_relative 'teodoro/obj'
13
13
 
14
14
  module Teodoro
15
- VERSION = '0.40.2'.freeze
15
+ VERSION = '0.40.3'.freeze
16
16
 
17
17
  CBOs = __FILE__
18
18
  .then { File.dirname(_1) }
@@ -80,10 +80,14 @@ module Teodoro
80
80
  Console.print "carregando #{nome}.xml..." do
81
81
  evento, recibo = carregar_evento_e_recibo
82
82
 
83
- @retificacao = TIPOS_DE_EVENTO_RETIFICAVEIS.include?(tipo_de_evento) && evento['ideEvento/indRetif'] == '2'
83
+ @retificacao = evento_retificavel? && evento['ideEvento/indRetif'] == '2'
84
84
  @numero_do_recibo_a_retificar = evento['ideEvento/nrRecibo'] if retificacao?
85
85
  @momento_de_processamento_pelo_e_social = recibo['processamento/dhProcessamento']
86
+
87
+ validar_carregamento
86
88
  end
89
+ rescue StandardError => e
90
+ tratar_excecao(e)
87
91
  end
88
92
 
89
93
  def retificacao?
@@ -104,9 +108,7 @@ module Teodoro
104
108
  processar_arquivo
105
109
  end
106
110
  rescue StandardError => e
107
- puts caminho
108
- puts e.message
109
- raise e
111
+ tratar_excecao(e)
110
112
  end
111
113
 
112
114
  private
@@ -127,10 +129,20 @@ module Teodoro
127
129
  File.read(caminho)
128
130
  end
129
131
 
132
+ def evento_retificavel?
133
+ TIPOS_DE_EVENTO_RETIFICAVEIS.include?(tipo_de_evento)
134
+ end
135
+
130
136
  def tipo_de_evento
131
137
  @tipo_de_evento ||= nome[-6..].delete('-')
132
138
  end
133
139
 
140
+ def validar_carregamento
141
+ return if momento_de_processamento_pelo_e_social
142
+
143
+ raise 'arquivo corrompido (sem data e horário do processamento do evento)'
144
+ end
145
+
134
146
  def validar_versao_do_leiaute
135
147
  raise unless %w[
136
148
  02_04_01
@@ -186,5 +198,11 @@ module Teodoro
186
198
  def xml_do_recibo
187
199
  Nokogiri::XML(xml.css('/eSocial/retornoProcessamentoDownload/recibo/*/*').to_s)
188
200
  end
201
+
202
+ def tratar_excecao(excecao)
203
+ puts caminho
204
+ puts excecao.message
205
+ raise excecao
206
+ end
189
207
  end
190
208
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: teodoro
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.40.2
4
+ version: 0.40.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Clavius Tales
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-12 00:00:00.000000000 Z
11
+ date: 2021-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri