teodoro 0.40.1 → 0.41.1

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: 648f853591aa7964b70f197de4a64a4d8947502de0e1fd1a9cf56c3b973c812e
4
- data.tar.gz: 363fabc74c2524c3a66eeab8a89b19e8447712f3efb599ae715c5a9ea3a0b943
3
+ metadata.gz: 1200f1a480b9d8fc8b1d83acfdb4320e11c754719dd21fa44f930f1f055aa708
4
+ data.tar.gz: 5ca0c4c19ead745843d693d41be473be9db176587e41eb1f1a32b693d6fdab99
5
5
  SHA512:
6
- metadata.gz: 1368d1f9836ea1bf4cdc12be49cc988d999cf877e496f72c502b4134e883e990d29a6d3486af209fd739cbdc4f780a89858b4635fc5e79b0a21617202d985750
7
- data.tar.gz: 46366c1e9684fc093df1d8201c57eb70fac11282b6fabf598bc91885a5007bbbf33e0468556e9118bc562d08daaa7139c66f2f43fedb661d81b74b8f96260c43
6
+ metadata.gz: ea1667193779f9b1fb3a19779527b818eb6bb75a72eedbaf12e3c0f05ebe64897f1a61d7259e98757da43b2c6ea1e368b3bb8a7229567ab495f15bee4e7dce82
7
+ data.tar.gz: 91d6776e2c38ccbb3defdb02d378bf319f6a140155e6571a497c511f06edfd4786249a610bb63448334c1bbeae40652203f3ca7954b27be4825c2d6318433d74
@@ -18,7 +18,7 @@ module Teodoro
18
18
  attr_reader :nome
19
19
 
20
20
  def criar
21
- raise caminho if File.exist?(caminho)
21
+ raise 'evento duplicado' if File.exist?(caminho)
22
22
 
23
23
  File.open(caminho, 'w') do
24
24
  _1.puts(conteudo_do_arquivo)
@@ -73,7 +73,7 @@ module Teodoro
73
73
  data_aaaammdd: proc { _1.delete('-') if _1 },
74
74
  decimal: proc { _1.tr('.', ',') if _1 },
75
75
  mes_ano: proc { "#{_1[-2..]}/#{_1[0..3]}" if _1 },
76
- vazio: proc { nil }
76
+ vazio: proc {}
77
77
  }.freeze
78
78
 
79
79
  private
@@ -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?
@@ -103,6 +107,8 @@ module Teodoro
103
107
  validar_versao_do_leiaute
104
108
  processar_arquivo
105
109
  end
110
+ rescue StandardError => e
111
+ tratar_excecao(e)
106
112
  end
107
113
 
108
114
  private
@@ -123,10 +129,20 @@ module Teodoro
123
129
  File.read(caminho)
124
130
  end
125
131
 
132
+ def evento_retificavel?
133
+ TIPOS_DE_EVENTO_RETIFICAVEIS.include?(tipo_de_evento)
134
+ end
135
+
126
136
  def tipo_de_evento
127
137
  @tipo_de_evento ||= nome[-6..].delete('-')
128
138
  end
129
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
+
130
146
  def validar_versao_do_leiaute
131
147
  raise unless %w[
132
148
  02_04_01
@@ -182,5 +198,11 @@ module Teodoro
182
198
  def xml_do_recibo
183
199
  Nokogiri::XML(xml.css('/eSocial/retornoProcessamentoDownload/recibo/*/*').to_s)
184
200
  end
201
+
202
+ def tratar_excecao(excecao)
203
+ puts caminho
204
+ puts excecao.message
205
+ raise excecao
206
+ end
185
207
  end
186
208
  end
@@ -395,7 +395,24 @@ module Teodoro
395
395
  end
396
396
 
397
397
  def opcao_pelo_fgts
398
- @opcao_pelo_fgts ||= evento['vinculo/infoRegimeTrab/infoCeletista/FGTS'] ? 1 : 2
398
+ @opcao_pelo_fgts ||= optante_pelo_fgts? ? 1 : 2
399
+ end
400
+
401
+ def optante_pelo_fgts?
402
+ data_de_admissao >= (empregado_domestico? ? '2015-10-01' : '1988-10-05') ||
403
+ evento['vinculo/infoRegimeTrab/infoCeletista/FGTS']
404
+ end
405
+
406
+ def data_de_admissao
407
+ evento['vinculo/infoRegimeTrab/infoCeletista/dtAdm']
408
+ end
409
+
410
+ def empregado_domestico?
411
+ categoria_do_trabalhador == '104'
412
+ end
413
+
414
+ def categoria_do_trabalhador
415
+ evento['vinculo/infoContrato/codCateg']
399
416
  end
400
417
 
401
418
  def data_de_opcao_pelo_fgts
@@ -43,7 +43,11 @@ module Teodoro
43
43
  if inicio_do_afastamento?
44
44
  inicio_do_afastamento['dtIniAfast']
45
45
  else
46
- contrato_de_trabalho.afastamento.data_de_inicio
46
+ contrato_de_trabalho.afastamento.then do
47
+ raise 'término de afastamento sem início de afastamento' unless _1
48
+
49
+ _1.data_de_inicio
50
+ end
47
51
  end
48
52
  end
49
53
 
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.1'.freeze
15
+ VERSION = '0.41.1'.freeze
16
16
 
17
17
  CBOs = __FILE__
18
18
  .then { File.dirname(_1) }
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.1
4
+ version: 0.41.1
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-10 00:00:00.000000000 Z
11
+ date: 2021-09-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri