teodoro 0.47.1 → 0.47.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -114,7 +114,10 @@ module Teodoro
114
114
  private
115
115
 
116
116
  def nome_base_do_arquivo_data
117
- identificacao[0] + identificacao[1..].map { "[#{_1}]" }.join
117
+ identificacao[0] + identificacao[1..].map { "[#{_1}]" }
118
+ .join
119
+ .tr('àáäâãèéëẽêìíïîĩòóöôõùúüûũñç'.then{_1 + _1.upcase},
120
+ 'aaaaaeeeeeiiiiiooooouuuuunc'.then{_1 + _1.upcase})
118
121
  end
119
122
  end
120
123
  end
@@ -11,9 +11,13 @@ module Teodoro
11
11
 
12
12
  public
13
13
 
14
- def registrar_admissao(admissao:, afastamento:)
14
+ def to_a
15
+ contratos
16
+ end
17
+
18
+ def registrar_admissao(admissao:, inicio_de_afastamento:)
15
19
  contratos_por_matricula[admissao.matricula_do_trabalhador] =
16
- Contrato.new(admissao: admissao, afastamento: afastamento)
20
+ Contrato.new(admissao: admissao, inicio_de_afastamento: inicio_de_afastamento)
17
21
  trabalhadores << admissao.trabalhador
18
22
  end
19
23
 
@@ -38,20 +42,20 @@ module Teodoro
38
42
 
39
43
  private
40
44
 
41
- def contratos_por_matricula
42
- @contratos_por_matricula ||= {}
43
- end
44
-
45
45
  def contratos
46
46
  contratos_por_matricula.values
47
47
  end
48
48
 
49
+ def contratos_por_matricula
50
+ @contratos_por_matricula ||= {}
51
+ end
52
+
49
53
  class Contrato
50
54
  private
51
55
 
52
- def initialize(admissao:, afastamento:)
56
+ def initialize(admissao:, inicio_de_afastamento:)
53
57
  @admissao = admissao
54
- @afastamento = afastamento
58
+ @inicios_de_afastamento = inicio_de_afastamento ? [inicio_de_afastamento] : []
55
59
 
56
60
  @tipo_de_regime_previdenciario = admissao.tipo_de_regime_previdenciario
57
61
  @natureza_da_atividade = admissao.natureza_da_atividade
@@ -77,7 +81,7 @@ module Teodoro
77
81
  :categoria_do_trabalhador,
78
82
  :recibo
79
83
 
80
- attr_accessor :afastamento
84
+ attr_accessor :inicios_de_afastamento
81
85
 
82
86
  attr_reader :tipo_de_regime_previdenciario, :natureza_da_atividade, :duracao
83
87
 
@@ -11,8 +11,12 @@ module Teodoro
11
11
 
12
12
  public
13
13
 
14
- def registrar_inicio_de_contrato(inicio_de_contrato:, afastamento:)
15
- contratos << Contrato.new(inicio_de_contrato: inicio_de_contrato, afastamento: afastamento)
14
+ def to_a
15
+ contratos
16
+ end
17
+
18
+ def registrar_inicio_de_contrato(inicio_de_contrato:, inicio_de_afastamento:)
19
+ contratos << Contrato.new(inicio_de_contrato: inicio_de_contrato, inicio_de_afastamento: inicio_de_afastamento)
16
20
  trabalhadores << inicio_de_contrato.trabalhador
17
21
  end
18
22
 
@@ -47,9 +51,9 @@ module Teodoro
47
51
  class Contrato
48
52
  private
49
53
 
50
- def initialize(inicio_de_contrato:, afastamento:)
54
+ def initialize(inicio_de_contrato:, inicio_de_afastamento:)
51
55
  @inicio_de_contrato = inicio_de_contrato
52
- @afastamento = afastamento
56
+ @inicios_de_afastamento = inicio_de_afastamento ? [inicio_de_afastamento] : []
53
57
  end
54
58
 
55
59
  attr_reader :inicio_de_contrato, :data_do_termino
@@ -65,7 +69,7 @@ module Teodoro
65
69
  :data_de_inicio,
66
70
  :recibo
67
71
 
68
- attr_accessor :afastamento
72
+ attr_accessor :inicios_de_afastamento
69
73
 
70
74
  attr_writer :data_do_termino
71
75
 
@@ -89,6 +89,17 @@ module Teodoro
89
89
  @funcoes_geradas ||= FuncoesGeradas.new(self)
90
90
  end
91
91
 
92
+ def inicios_de_afastamento_por_numero_do_recibo
93
+ contratos_de_trabalho
94
+ .sum([], &:inicios_de_afastamento)
95
+ .group_by(&:numero_do_recibo)
96
+ .transform_values { _1.size == 1 ? _1.first : raise }
97
+ end
98
+
99
+ def contratos_de_trabalho
100
+ [*contratos_de_emprego, *contratos_de_trabalho_sem_vinculo]
101
+ end
102
+
92
103
  private
93
104
 
94
105
  def dar_feedback_para_o_usuario
@@ -14,7 +14,7 @@ module Teodoro
14
14
  def registrar_admissao
15
15
  contratos_de_emprego.registrar_admissao(
16
16
  admissao: admissao,
17
- afastamento: afastamento
17
+ inicio_de_afastamento: inicio_de_afastamento
18
18
  )
19
19
  end
20
20
 
@@ -127,7 +127,7 @@ module Teodoro
127
127
  empresa.contratos_de_emprego
128
128
  end
129
129
 
130
- def afastamento
130
+ def inicio_de_afastamento
131
131
  evento['vinculo/afastamento']&.then do |afastamento|
132
132
  Obj.new(
133
133
  data_de_inicio: afastamento['dtIniAfast'],
@@ -8,7 +8,7 @@ module Teodoro
8
8
  def dados_dos_arquivos_data
9
9
  [
10
10
  Obj.new(
11
- nome: "CAT_#{numero_do_recibo}",
11
+ nome: "CAT[#{cpf_trab}][#{matricula}][#{dt_acid.delete('-')}]_#{numero_do_recibo}",
12
12
  itens_do_conteudo: itens_do_conteudo
13
13
  )
14
14
  ]
@@ -21,10 +21,10 @@ module Teodoro
21
21
  ['verProc', versao_do_processo_de_emissao_do_evento],
22
22
  ['ideEmpregador/tpInsc', tipo_de_inscricao_do_empregador],
23
23
  ['ideEmpregador/nrInsc', numero_de_inscricao_do_empregador],
24
- ['cpfTrab', evento['ideVinculo/cpfTrab']],
25
- ['matricula', evento['ideVinculo/matricula']],
24
+ ['cpfTrab', cpf_trab],
25
+ ['matricula', matricula],
26
26
  ['codCateg', evento['ideVinculo/codCateg']],
27
- ['dtAcid', evento['cat/dtAcid']],
27
+ ['dtAcid', dt_acid],
28
28
  ['tpAcid', evento['cat/tpAcid']],
29
29
  ['hrAcid', evento['cat/hrAcid']],
30
30
  ['hrsTrabAntesAcid', evento['cat/hrsTrabAntesAcid']],
@@ -70,6 +70,18 @@ module Teodoro
70
70
  ['nrRecibo', numero_do_recibo]
71
71
  ]
72
72
  end
73
+
74
+ def cpf_trab
75
+ @cpf_trab ||= evento['ideVinculo/cpfTrab']
76
+ end
77
+
78
+ def matricula
79
+ @matricula ||= evento['ideVinculo/matricula']
80
+ end
81
+
82
+ def dt_acid
83
+ @dt_acid ||= evento['cat/dtAcid']
84
+ end
73
85
  end
74
86
  end
75
87
  end
@@ -8,7 +8,7 @@ module Teodoro
8
8
  def dados_dos_arquivos_data
9
9
  [
10
10
  Obj.new(
11
- nome: "ASO_#{numero_do_recibo}",
11
+ nome: "ASO[#{cpf_trab}][#{matricula}][#{dt_aso.delete('-')}]_#{numero_do_recibo}",
12
12
  itens_do_conteudo: itens_do_conteudo
13
13
  )
14
14
  ]
@@ -21,11 +21,11 @@ module Teodoro
21
21
  ['verProc', versao_do_processo_de_emissao_do_evento],
22
22
  ['ideEmpregador/tpInsc', tipo_de_inscricao_do_empregador],
23
23
  ['ideEmpregador/nrInsc', numero_de_inscricao_do_empregador],
24
- ['cpfTrab', evento['ideVinculo/cpfTrab']],
25
- ['matricula', evento['ideVinculo/matricula']],
24
+ ['cpfTrab', cpf_trab],
25
+ ['matricula', matricula],
26
26
  ['codCateg', evento['ideVinculo/codCateg']],
27
27
  ['tpExameOcup', evento['exMedOcup/tpExameOcup']],
28
- ['dtAso', evento['exMedOcup/aso/dtAso']],
28
+ ['dtAso', dt_aso],
29
29
  ['resAso', evento['exMedOcup/aso/resAso']],
30
30
  *evento.*('exMedOcup/aso/exame').map.with_index(1) do |exame, seq|
31
31
  [
@@ -46,6 +46,18 @@ module Teodoro
46
46
  ['nrRecibo', numero_do_recibo]
47
47
  ]
48
48
  end
49
+
50
+ def cpf_trab
51
+ @cpf_trab ||= evento['ideVinculo/cpfTrab']
52
+ end
53
+
54
+ def matricula
55
+ @matricula ||= evento['ideVinculo/matricula']
56
+ end
57
+
58
+ def dt_aso
59
+ @dt_aso ||= evento['exMedOcup/aso/dtAso']
60
+ end
49
61
  end
50
62
  end
51
63
  end
@@ -32,9 +32,11 @@ module Teodoro
32
32
  end
33
33
 
34
34
  def registrar_inicio_do_afastamento
35
- contrato_de_trabalho.afastamento = Obj.new(
35
+ contrato_de_trabalho.inicios_de_afastamento << InicioDeAfastamento.new(
36
+ inicios_de_afastamento: contrato_de_trabalho.inicios_de_afastamento,
36
37
  data_de_inicio: data_de_inicio_do_afastamento,
37
- codigo_do_motivo: codigo_do_motivo_de_afastamento
38
+ codigo_do_motivo: codigo_do_motivo_de_afastamento,
39
+ numero_do_recibo: numero_do_recibo
38
40
  )
39
41
  end
40
42
 
@@ -43,7 +45,7 @@ module Teodoro
43
45
  if inicio_do_afastamento?
44
46
  inicio_do_afastamento['dtIniAfast']
45
47
  else
46
- contrato_de_trabalho.afastamento.then do |afastamento|
48
+ ultimo_inicio_de_afastamento_do_contrato_de_trabalho.then do |afastamento|
47
49
  raise 'término de afastamento sem início de afastamento' unless afastamento
48
50
 
49
51
  afastamento.data_de_inicio
@@ -51,12 +53,16 @@ module Teodoro
51
53
  end
52
54
  end
53
55
 
56
+ def ultimo_inicio_de_afastamento_do_contrato_de_trabalho
57
+ @ultimo_inicio_de_afastamento_do_contrato_de_trabalho ||= contrato_de_trabalho.inicios_de_afastamento.last
58
+ end
59
+
54
60
  def codigo_do_motivo_de_afastamento
55
61
  @codigo_do_motivo_de_afastamento ||=
56
62
  if inicio_do_afastamento?
57
63
  evento['infoAfastamento/iniAfastamento/codMotAfast']
58
64
  else
59
- contrato_de_trabalho.afastamento.codigo_do_motivo
65
+ ultimo_inicio_de_afastamento_do_contrato_de_trabalho.codigo_do_motivo
60
66
  end
61
67
  end
62
68
 
@@ -170,6 +176,27 @@ module Teodoro
170
176
  def data_de_inicio_do_contrato_de_trabalho
171
177
  contrato_de_trabalho_sem_vinculo.data_de_inicio
172
178
  end
179
+
180
+ class InicioDeAfastamento
181
+ private
182
+
183
+ def initialize(inicios_de_afastamento:, data_de_inicio:, codigo_do_motivo:, numero_do_recibo:)
184
+ @inicios_de_afastamento = inicios_de_afastamento
185
+ @data_de_inicio = data_de_inicio
186
+ @codigo_do_motivo = codigo_do_motivo
187
+ @numero_do_recibo = numero_do_recibo
188
+ end
189
+
190
+ attr_reader :inicios_de_afastamento
191
+
192
+ public
193
+
194
+ attr_reader :data_de_inicio, :codigo_do_motivo, :numero_do_recibo
195
+
196
+ def excluir
197
+ inicios_de_afastamento.pop.then { raise unless _1 == self }
198
+ end
199
+ end
173
200
  end
174
201
  end
175
202
  end
@@ -8,7 +8,7 @@ module Teodoro
8
8
  def dados_dos_arquivos_data
9
9
  [
10
10
  Obj.new(
11
- nome: "AMB_#{numero_do_recibo}",
11
+ nome: "AMB[#{cpf_trab}][#{matricula}][#{dt_ini_condicao.delete('-')}]_#{numero_do_recibo}",
12
12
  itens_do_conteudo: itens_do_conteudo
13
13
  )
14
14
  ]
@@ -21,10 +21,10 @@ module Teodoro
21
21
  ['verProc', versao_do_processo_de_emissao_do_evento],
22
22
  ['ideEmpregador/tpInsc', tipo_de_inscricao_do_empregador],
23
23
  ['ideEmpregador/nrInsc', numero_de_inscricao_do_empregador],
24
- ['cpfTrab', evento['ideVinculo/cpfTrab']],
25
- ['matricula', evento['ideVinculo/matricula']],
24
+ ['cpfTrab', cpf_trab],
25
+ ['matricula', matricula],
26
26
  ['codCateg', evento['ideVinculo/codCateg']],
27
- ['dtIniCondicao', evento['infoExpRisco/dtIniCondicao']],
27
+ ['dtIniCondicao', dt_ini_condicao],
28
28
  ['localAmb', evento['infoExpRisco/infoAmb/localAmb']],
29
29
  ['dscSetor', evento['infoExpRisco/infoAmb/dscSetor']],
30
30
  ['infoAmb/tpInsc', evento['infoExpRisco/infoAmb/tpInsc']],
@@ -70,6 +70,18 @@ module Teodoro
70
70
  ['nrRecibo', numero_do_recibo]
71
71
  ]
72
72
  end
73
+
74
+ def cpf_trab
75
+ @cpf_trab ||= evento['ideVinculo/cpfTrab']
76
+ end
77
+
78
+ def matricula
79
+ @matricula ||= evento['ideVinculo/matricula']
80
+ end
81
+
82
+ def dt_ini_condicao
83
+ @dt_ini_condicao ||= evento['infoExpRisco/dtIniCondicao']
84
+ end
73
85
  end
74
86
  end
75
87
  end
@@ -14,7 +14,7 @@ module Teodoro
14
14
  def registrar_inicio_de_contrato
15
15
  contratos_de_trabalho_sem_vinculo.registrar_inicio_de_contrato(
16
16
  inicio_de_contrato: inicio_de_contrato,
17
- afastamento: afastamento
17
+ inicio_de_afastamento: inicio_de_afastamento
18
18
  )
19
19
  end
20
20
 
@@ -119,7 +119,7 @@ module Teodoro
119
119
  )
120
120
  end
121
121
 
122
- def afastamento
122
+ def inicio_de_afastamento
123
123
  evento['infoTSVInicio/afastamento']&.then do |afastamento|
124
124
  Obj.new(
125
125
  data_de_inicio: afastamento['dtIniAfast'],
@@ -7,6 +7,7 @@ module Teodoro
7
7
  excluir_arquivos_data if tipo_de_evento_processavel?
8
8
  excluir_admissao if exclusao_de_admissao?
9
9
  excluir_inicio_de_tsv if exclusao_de_inicio_de_tsv?
10
+ excluir_inicio_de_afastamento if exclusao_de_inicio_de_afastamento?
10
11
  end
11
12
 
12
13
  private
@@ -50,6 +51,30 @@ module Teodoro
50
51
  def contratos_de_trabalho_sem_vinculo
51
52
  empresa.contratos_de_trabalho_sem_vinculo
52
53
  end
54
+
55
+ def exclusao_de_inicio_de_afastamento?
56
+ exclusao_de_afastamento? && inicio_de_afastamento?
57
+ end
58
+
59
+ def exclusao_de_afastamento?
60
+ tipo_de_evento == 'S2230'
61
+ end
62
+
63
+ def inicio_de_afastamento?
64
+ inicio_de_afastamento
65
+ end
66
+
67
+ def inicio_de_afastamento
68
+ @inicio_de_afastamento ||= inicios_de_afastamento_por_numero_do_recibo[numero_de_recibo_do_evento_a_excluir]
69
+ end
70
+
71
+ def inicios_de_afastamento_por_numero_do_recibo
72
+ empresa.inicios_de_afastamento_por_numero_do_recibo
73
+ end
74
+
75
+ def excluir_inicio_de_afastamento
76
+ inicio_de_afastamento.excluir
77
+ end
53
78
  end
54
79
  end
55
80
  end
@@ -1,3 +1,3 @@
1
1
  module Teodoro
2
- VERSION = '0.47.1'.freeze
2
+ VERSION = '0.47.4'.freeze
3
3
  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.47.1
4
+ version: 0.47.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fortes Tecnologia
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-23 00:00:00.000000000 Z
11
+ date: 2022-05-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri