Skip to content

Commit

Permalink
Adicionado Melhorias JaxB
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuel-Oliveira committed May 1, 2022
1 parent 4c0dd24 commit bafd4df
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ ________________________________________________________________________________
- Atualizado Servidro DFe Homologação
- Adicionado Compatibilidade com Java 14+
- Adicionado Envento Ator Interessado
- Corrigido erro de Logs
- Adicionado Melhorias JaxB

Snapshot é a versão que se encontra em teste, só use em caso de extrema necessidade.
Para usar, adicione o repositorio de Snapshot ao Maven:
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/br/com/swconsultoria/nfe/util/RetornoUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,23 @@
*/
public class RetornoUtil {

/**
* Valida Retorno Assincrono Trasmissão de Contingencia!
*
* @param retorno
* @throws NfeException
*/
public static void validaSincronoTrasmissaoContingencia(TRetEnviNFe retorno) throws NfeException {

if (!retorno.getCStat().equals(StatusEnum.LOTE_RECEBIDO.getCodigo()) && !retorno.getCStat().equals(StatusEnum.LOTE_PROCESSADO.getCodigo())) {
throw new NfeException(retorno.getCStat() + " - " + retorno.getXMotivo());
}

if (!retorno.getProtNFe().getInfProt().getCStat().equals(StatusEnum.AUTORIZADO.getCodigo()) && !retorno.getProtNFe().getInfProt().getCStat().equals(StatusEnum.AUTORIZADO_FORA_PRAZO.getCodigo())) {
throw new NfeException(retorno.getProtNFe().getInfProt().getCStat() + " - " + retorno.getProtNFe().getInfProt().getXMotivo());
}
}

/**
* Valida o Retorno Do Cancelamento
*
Expand Down
6 changes: 1 addition & 5 deletions src/main/java/br/com/swconsultoria/nfe/util/XmlNfeUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,7 @@ public class XmlNfeUtil {
* @return T
*/
public static <T> T xmlToObject(String xml, Class<T> classe) throws JAXBException {

JAXBContext context = JAXBContext.newInstance(classe);
Unmarshaller unmarshaller = context.createUnmarshaller();

return unmarshaller.unmarshal(new StreamSource(new StringReader(xml)), classe).getValue();
return JAXB.unmarshal(new StreamSource(new StringReader(xml)), classe);
}

/**
Expand Down

0 comments on commit bafd4df

Please sign in to comment.