-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #397 from tst-labs/CADASTRO-TSV
Informações de alteração e encerramento de TSV
- Loading branch information
Showing
22 changed files
with
1,209 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/esocial-jt-dominio/src/main/java/br/jus/tst/esocial/ret/tsv/DadosDesligamento.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package br.jus.tst.esocial.ret.tsv; | ||
|
||
import br.jus.tst.esocial.dominio.semvinculo.termino.InfoTSVTermino; | ||
|
||
import java.util.Objects; | ||
|
||
public class DadosDesligamento { | ||
public InfoTSVTermino infoTSVTermino; | ||
|
||
public InfoTSVTermino getInfoTSVTermino() { | ||
return infoTSVTermino; | ||
} | ||
|
||
public void setInfoTSVTermino(InfoTSVTermino infoTSVTermino) { | ||
this.infoTSVTermino = infoTSVTermino; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
DadosDesligamento that = (DadosDesligamento) o; | ||
return Objects.equals(infoTSVTermino, that.infoTSVTermino); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(infoTSVTermino); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
...cial-jt-service/src/main/java/br/jus/tst/esocialjt/ret/semvinculo/Processador2205TSV.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package br.jus.tst.esocialjt.ret.semvinculo; | ||
|
||
import br.jus.tst.esocial.ocorrencia.dados.AltCadastral; | ||
import br.jus.tst.esocialjt.dominio.Ocorrencia; | ||
import org.springframework.beans.BeanUtils; | ||
|
||
import java.util.ArrayList; | ||
|
||
public class Processador2205TSV implements ProcessadorTrabalhadorSemVinculo { | ||
|
||
@Override | ||
public void processaRegistro(ArrayList<RetTrabalhadorSemVinculo> listaRetTrabalhadorSemVinculo, Ocorrencia ocorrencia) { | ||
AltCadastral alteracao = (AltCadastral) ocorrencia.getDadosOcorrencia(); | ||
|
||
listaRetTrabalhadorSemVinculo.forEach(re -> { | ||
BeanUtils.copyProperties(alteracao.getAlteracao().getDadosTrabalhador(), re.trabalhadorSemVinculo.dadosCadastrais); | ||
re.trabalhadorSemVinculo.dadosCadastrais.nascimento.setPaisNac(alteracao.getAlteracao().getDadosTrabalhador().getPaisNac()); | ||
re.addOcorrencia(ocorrencia); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
...esocial-jt-service/src/main/java/br/jus/tst/esocialjt/ret/semvinculo/Processador2306.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package br.jus.tst.esocialjt.ret.semvinculo; | ||
|
||
import br.jus.tst.esocial.dominio.semvinculo.InfoComplementares; | ||
import br.jus.tst.esocial.dominio.semvinculo.InfoDirigenteSindical; | ||
import br.jus.tst.esocial.dominio.semvinculo.InfoMandElet; | ||
import br.jus.tst.esocial.dominio.semvinculo.InfoTrabCedido; | ||
import br.jus.tst.esocial.ocorrencia.dados.TSVAltContr; | ||
import br.jus.tst.esocialjt.dominio.Ocorrencia; | ||
import org.apache.commons.lang3.StringUtils; | ||
|
||
import java.util.ArrayList; | ||
|
||
public class Processador2306 implements ProcessadorTrabalhadorSemVinculo { | ||
@Override | ||
public void processaRegistro(ArrayList<RetTrabalhadorSemVinculo> listaRetTrabalhadorSemVinculo, Ocorrencia ocorrencia) { | ||
TSVAltContr alteracao = (TSVAltContr) ocorrencia.getDadosOcorrencia(); | ||
String matriculaOcorrencia = ocorrencia.getDadosOcorrencia().getMatricula(); | ||
Integer codCateg = alteracao.getIdeTrabSemVinculo().getCodCateg(); | ||
|
||
listaRetTrabalhadorSemVinculo | ||
.stream() | ||
.filter(re -> StringUtils.equals(matriculaOcorrencia, re.getMatricula())) | ||
.filter(re -> codCateg == null || codCateg.equals(re.trabalhadorSemVinculo.getDadosContratuais().getCodCateg())) | ||
.forEach(re -> { | ||
InfoComplementares infoComplementares = re.trabalhadorSemVinculo.dadosContratuais.getInfoComplementares(); | ||
InfoComplementares infoComplementaresAlt = alteracao.getInfoTSVAlteracao().getInfoComplementares(); | ||
if (infoComplementaresAlt != null && infoComplementares != null) { | ||
infoComplementares.setCargoFuncao(infoComplementaresAlt.getCargoFuncao()); | ||
infoComplementares.setRemuneracao(infoComplementaresAlt.getRemuneracao()); | ||
infoComplementares.setInfoEstagiario(infoComplementaresAlt.getInfoEstagiario()); | ||
infoComplementares.setLocalTrabGeral(infoComplementaresAlt.getLocalTrabGeral()); | ||
preencherInfoDirigenteSindical(infoComplementares, infoComplementaresAlt); | ||
preencherInfoTrabCedido(infoComplementares, infoComplementaresAlt); | ||
preencherInfoMandElet(infoComplementares, infoComplementaresAlt); | ||
} | ||
re.addOcorrencia(ocorrencia); | ||
}); | ||
} | ||
|
||
private static void preencherInfoMandElet(InfoComplementares infoComplementares, InfoComplementares infoComplementaresAlt) { | ||
InfoMandElet infoMandElet = infoComplementares.getInfoMandElet(); | ||
InfoMandElet infoMandEletAlt = infoComplementaresAlt.getInfoMandElet(); | ||
if (infoMandEletAlt != null && infoMandElet != null) { | ||
infoMandElet.setTpRegPrev(infoMandEletAlt.getTpRegPrev()); | ||
infoMandElet.setIndRemunCargo(infoMandEletAlt.getIndRemunCargo()); | ||
} else { | ||
infoComplementares.setInfoMandElet(infoMandEletAlt); | ||
} | ||
} | ||
|
||
private static void preencherInfoTrabCedido(InfoComplementares infoComplementares, InfoComplementares infoComplementaresAlt) { | ||
InfoTrabCedido infoTrabCedido = infoComplementares.getInfoTrabCedido(); | ||
InfoTrabCedido infoTrabCedidoAlt = infoComplementaresAlt.getInfoTrabCedido(); | ||
|
||
if (infoTrabCedidoAlt != null && infoTrabCedido != null) { | ||
infoTrabCedido.setTpRegPrev(infoTrabCedidoAlt.getTpRegPrev()); | ||
} else { | ||
infoComplementares.setInfoTrabCedido(infoTrabCedidoAlt); | ||
} | ||
} | ||
|
||
private static void preencherInfoDirigenteSindical(InfoComplementares infoComplementares, InfoComplementares infoComplementaresAlt) { | ||
InfoDirigenteSindical infoDirigenteSindical = infoComplementares.getInfoDirigenteSindical(); | ||
InfoDirigenteSindical infoDirigenteSindicalAlt = infoComplementaresAlt.getInfoDirigenteSindical(); | ||
if (infoDirigenteSindicalAlt != null && infoDirigenteSindical != null) { | ||
infoDirigenteSindical.setTpRegPrev(infoDirigenteSindicalAlt.getTpRegPrev()); | ||
} else { | ||
infoComplementares.setInfoDirigenteSindical(infoDirigenteSindicalAlt); | ||
} | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
...esocial-jt-service/src/main/java/br/jus/tst/esocialjt/ret/semvinculo/Processador2399.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package br.jus.tst.esocialjt.ret.semvinculo; | ||
|
||
import br.jus.tst.esocial.dominio.semvinculo.termino.InfoTSVTermino; | ||
import br.jus.tst.esocial.ocorrencia.dados.TSVTermino; | ||
import br.jus.tst.esocial.ret.tsv.DadosDesligamento; | ||
import br.jus.tst.esocialjt.dominio.Ocorrencia; | ||
import org.apache.commons.lang3.StringUtils; | ||
import org.springframework.beans.BeanUtils; | ||
|
||
import java.util.ArrayList; | ||
|
||
public class Processador2399 implements ProcessadorTrabalhadorSemVinculo { | ||
|
||
@Override | ||
public void processaRegistro(ArrayList<RetTrabalhadorSemVinculo> listaRetTrabalhadorSemVinculo, Ocorrencia ocorrencia) { | ||
TSVTermino termino = (TSVTermino) ocorrencia.getDadosOcorrencia(); | ||
String matriculaOcorrencia = ocorrencia.getDadosOcorrencia().getMatricula(); | ||
Integer codCateg = termino.getIdeTrabSemVinculo().getCodCateg(); | ||
|
||
listaRetTrabalhadorSemVinculo | ||
.stream() | ||
.filter(re -> StringUtils.equals(matriculaOcorrencia, re.getMatricula())) | ||
.filter(re -> codCateg == null || codCateg.equals(re.trabalhadorSemVinculo.getDadosContratuais().getCodCateg())) | ||
.forEach(re -> { | ||
re.trabalhadorSemVinculo.dadosDesligamento = new DadosDesligamento(); | ||
re.trabalhadorSemVinculo.dadosDesligamento.infoTSVTermino = new InfoTSVTermino(); | ||
BeanUtils.copyProperties(termino.getInfoTSVTermino(), re.trabalhadorSemVinculo.dadosDesligamento.infoTSVTermino); | ||
re.addOcorrencia(ocorrencia); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
...-jt-service/src/test/java/br/jus/tst/esocialjt/ret/semvinculo/Processador2205TSVTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package br.jus.tst.esocialjt.ret.semvinculo; | ||
|
||
import br.jus.tst.esocial.ret.tsv.TrabalhadorSemVinculo; | ||
import br.jus.tst.esocialjt.dominio.Ocorrencia; | ||
import br.jus.tst.esocialjt.util.OcorrenciaUtil; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.ArrayList; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
class Processador2205TSVTest { | ||
|
||
@Test | ||
public void deveProcessar2205SobreTSVExistente() { | ||
ArrayList<RetTrabalhadorSemVinculo> listaRetTrabalhadorSemVinculo = new ArrayList<>(); | ||
TrabalhadorSemVinculo inicial = OcorrenciaUtil.lerTrabalhadorSemVinculo("ret/trabalhadorsemvinculo/s2205/inicial.json"); | ||
RetTrabalhadorSemVinculo retTSV = new RetTrabalhadorSemVinculo(); | ||
retTSV.trabalhadorSemVinculo = inicial; | ||
|
||
listaRetTrabalhadorSemVinculo.add(retTSV); | ||
|
||
Ocorrencia ocorrencia = OcorrenciaUtil.lerOcorrencia("ret/trabalhadorsemvinculo/s2205/alteracao_cadastral.json"); | ||
TrabalhadorSemVinculo esperado = OcorrenciaUtil.lerTrabalhadorSemVinculo("ret/trabalhadorsemvinculo/s2205/esperado.json"); | ||
|
||
Processador2205TSV processador = new Processador2205TSV(); | ||
processador.processaRegistro(listaRetTrabalhadorSemVinculo, ocorrencia); | ||
|
||
assertThat(listaRetTrabalhadorSemVinculo).hasSize(1); | ||
|
||
assertThat(listaRetTrabalhadorSemVinculo.get(0).trabalhadorSemVinculo).usingRecursiveComparison().isEqualTo(esperado); | ||
assertThat(listaRetTrabalhadorSemVinculo.get(0).ocorrencias).contains(ocorrencia); | ||
} | ||
|
||
@Test | ||
public void deveProcessar2205SobreMaisDeUmTSVExistente() { | ||
ArrayList<RetTrabalhadorSemVinculo> listaRetTrabalhadorSemVinculo = new ArrayList<>(); | ||
TrabalhadorSemVinculo inicial1 = OcorrenciaUtil.lerTrabalhadorSemVinculo("ret/trabalhadorsemvinculo/s2205/inicial.json"); | ||
TrabalhadorSemVinculo inicial2 = OcorrenciaUtil.lerTrabalhadorSemVinculo("ret/trabalhadorsemvinculo/s2205/inicial.json"); | ||
|
||
RetTrabalhadorSemVinculo retEmpregado1 = new RetTrabalhadorSemVinculo(); | ||
retEmpregado1.trabalhadorSemVinculo = inicial1; | ||
listaRetTrabalhadorSemVinculo.add(retEmpregado1); | ||
|
||
RetTrabalhadorSemVinculo retEmpregado2 = new RetTrabalhadorSemVinculo(); | ||
retEmpregado2.trabalhadorSemVinculo = inicial2; | ||
listaRetTrabalhadorSemVinculo.add(retEmpregado2); | ||
|
||
Ocorrencia ocorrencia = OcorrenciaUtil.lerOcorrencia("ret/trabalhadorsemvinculo/s2205/alteracao_cadastral.json"); | ||
TrabalhadorSemVinculo esperado = OcorrenciaUtil.lerTrabalhadorSemVinculo("ret/trabalhadorsemvinculo/s2205/esperado.json"); | ||
|
||
Processador2205TSV processador = new Processador2205TSV(); | ||
processador.processaRegistro(listaRetTrabalhadorSemVinculo, ocorrencia); | ||
|
||
assertThat(listaRetTrabalhadorSemVinculo).hasSize(2); | ||
|
||
listaRetTrabalhadorSemVinculo.forEach(re -> { | ||
assertThat(re.trabalhadorSemVinculo).usingRecursiveComparison().isEqualTo(esperado); | ||
assertThat(re.ocorrencias).contains(ocorrencia); | ||
}); | ||
|
||
} | ||
|
||
} |
7 changes: 2 additions & 5 deletions
7
...lhadorsemvinculo/Processador2300Test.java → ...t/ret/semvinculo/Processador2300Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.