Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ target/
.idea/
*.iml
/target/
/.github/*.md
show,
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Java-NFe [![MIT License](https://img.shields.io/github/license/Samuel-Oliveira/Java_NFe.svg) ](https://github.com/Samuel-Oliveira/Java_NFe/blob/master/LICENSE) [![Maven Central](https://img.shields.io/maven-central/v/br.com.swconsultoria/java-nfe.svg?label=Maven%20Central)](https://search.maven.org/artifact/br.com.swconsultoria/java-nfe/4.00.49/jar)
# Java-NFe [![MIT License](https://img.shields.io/github/license/Samuel-Oliveira/Java_NFe.svg) ](https://github.com/Samuel-Oliveira/Java_NFe/blob/master/LICENSE) [![Maven Central](https://img.shields.io/maven-central/v/br.com.swconsultoria/java-nfe.svg?label=Maven%20Central)](https://search.maven.org/artifact/br.com.swconsultoria/java-nfe/4.00.51/jar) [![Coverage Status](https://coveralls.io/repos/github/Samuel-Oliveira/Java_NFe/badge.svg?branch=master)](https://coveralls.io/github/Samuel-Oliveira/Java_NFe?branch=master)
Biblioteca Java para consumo do WebService de NFe/NFCe

### Powered by
Expand All @@ -22,7 +22,7 @@ Para Iniciar :
<dependency>
<groupId>br.com.swconsultoria</groupId>
<artifactId>java-nfe</artifactId>
<version>4.00.49</version>
<version>4.00.51</version>
</dependency>
```

Expand All @@ -34,7 +34,7 @@ repositories {
}
}
dependencies {
implementation "br.com.swconsultoria:java-nfe:4.00.49"
implementation "br.com.swconsultoria:java-nfe:4.00.51"
}
```

Expand All @@ -44,6 +44,13 @@ ________________________________________________________________________________

# Historico de Versões

## v4.00.51 - 19/03/2026 - Schemas PL.010b (v1.30)
- Adicionado Teste Unitarios
- Atualizado Cacert

## v4.00.50 - 16/02/2026 - Schemas PL.010b (v1.30)
- Ajustes Impressao Danfe

## v4.00.49 - 18/01/2026 - Schemas PL.010b (v1.30)
- Corrigido monofasia retida Anteriormente.
- Adicionado calculos IBSCBS para Diferimento
Expand Down
4 changes: 2 additions & 2 deletions pom-base.xml
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Medium Sensitive Data Finding

PII

More Details
Attribute Value
Data Classifier PII/Name
Data Classifier ID BUILTIN-125

Sampled Examples

Key Value
developer.name Sa***l *****s

Rule ID: BUILTIN-125


To ignore this finding as an exception, reply to this conversation with #wiz_ignore reason

If you'd like to ignore this finding in all future scans, add an exception in the .wiz file (learn more) or create an Ignore Rule (learn more).


To get more details on how to remediate this issue using AI, reply to this conversation with #wiz remediate

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<groupId>br.com.swconsultoria</groupId>
<artifactId>java-nfe</artifactId>
<version>4.00.49-${versao}-SNAPSHOT</version>
<version>4.00.51-${versao}-SNAPSHOT</version>
<name>Java_NFe</name>
<description>Api java para consumo do webService de nota fiscal eletronica</description>
<url>https://github.com/Samuel-Oliveira/Java_NFe</url>
Expand Down Expand Up @@ -31,7 +31,7 @@
<java.version>1.8</java.version>

<!-- Versions -->
<java-certificado.version>3.13</java-certificado.version>
<java-certificado.version>3.14</java-certificado.version>
<httpcore.version>4.4.6</httpcore.version>
<jaxb-impl.version>2.3.1</jaxb-impl.version>
<jaxb-xjc.version>2.3.1</jaxb-xjc.version>
Expand Down
13 changes: 11 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<groupId>br.com.swconsultoria</groupId>
<artifactId>java-nfe</artifactId>
<version>4.00.49</version>
<version>4.00.51</version>
<name>Java_NFe</name>
<description>Api java para consumo do webService de nota fiscal eletronica</description>
<url>https://github.com/Samuel-Oliveira/Java_NFe</url>
Expand Down Expand Up @@ -31,7 +31,7 @@
<java.version>1.8</java.version>

<!-- Versions -->
<java-certificado.version>3.13</java-certificado.version>
<java-certificado.version>3.14</java-certificado.version>
<httpcore.version>4.4.6</httpcore.version>
<jaxb-impl.version>2.3.1</jaxb-impl.version>
<jaxb-xjc.version>2.3.1</jaxb-xjc.version>
Expand Down Expand Up @@ -279,6 +279,15 @@
<autoPublish>true</autoPublish>
</configuration>
</plugin>
<!-- Cobertura de testes -->
<plugin>
<groupId>org.eluder.coveralls</groupId>
<artifactId>coveralls-maven-plugin</artifactId>
<version>4.3.0</version>
<configuration>
<repoToken>paGe4qkZvPNJtvxqY8NaJN5ImZO56RqB6</repoToken>
Comment thread
Jair-Diniz marked this conversation as resolved.
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ public static ConfiguracoesNfe criarConfiguracoes(EstadosEnum estado, AmbienteEn

log.info(String.format("JAVA-NFE | Samuel Oliveira | samuel@swconsultoria.com.br " +
"| VERSAO=%s | DATA_VERSAO=%s | PASTA_SCHEMAS=%s | AMBIENTE=%s | ESTADO=%s",
"4.00.49",
"18/01/2026",
"4.00.51",
"19/03/2026",
pastaSchemas,
ambiente,
estado.getNome().toUpperCase()));
Expand Down
Binary file modified src/main/resources/jasper/nfe/danfe.jasper
Binary file not shown.
4 changes: 2 additions & 2 deletions src/main/resources/jasper/nfe/danfe.jrxml
Original file line number Diff line number Diff line change
Expand Up @@ -1001,8 +1001,8 @@ $F{Trans_CPF}.substring(9,11) : ""]]></textFieldExpression>
<textElement verticalAlignment="Top">
<font size="6" isItalic="false"/>
</textElement>
<textFieldExpression><![CDATA["Inf. Contribuinte:"+$F{Informacoes}.replace(" ","").replace("\n"," ")+
"\nInf. Fisco:"+$F{Informacoes_fisco}.replace(" ","").replace("\n"," ")]]></textFieldExpression>
<textFieldExpression><![CDATA[($F{Informacoes} != null ? ("Inf. Contribuinte:"+$F{Informacoes}.replace(" ","").replace("\n"," ") + "\n") : "") +
($F{Informacoes_fisco} != null ? ("Inf. Fisco:"+$F{Informacoes_fisco}.replace(" ","").replace("\n"," ")): "")]]></textFieldExpression>
</textField>
<frame>
<reportElement positionType="FixRelativeToBottom" stretchType="ContainerBottom" mode="Transparent" x="0" y="0" width="565" height="34" isPrintWhenDetailOverflows="true" uuid="91c422c4-c8b1-42ed-accb-e694dbf89daa">
Expand Down
120 changes: 120 additions & 0 deletions src/test/java/br/com/swconsultoria/nfe/CancelarTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
package br.com.swconsultoria.nfe;

import br.com.swconsultoria.nfe.dom.ConfiguracoesNfe;
import br.com.swconsultoria.nfe.dom.Evento;
import br.com.swconsultoria.nfe.dom.enuns.AmbienteEnum;
import br.com.swconsultoria.nfe.dom.enuns.AssinaturaEnum;
import br.com.swconsultoria.nfe.dom.enuns.DocumentoEnum;
import br.com.swconsultoria.nfe.dom.enuns.EstadosEnum;
import br.com.swconsultoria.nfe.exception.NfeException;
import br.com.swconsultoria.nfe.schema.envEventoCancNFe.TEnvEvento;
import br.com.swconsultoria.nfe.schema.envEventoCancNFe.TRetEnvEvento;
import br.com.swconsultoria.nfe.util.CancelamentoUtil;
import br.com.swconsultoria.nfe.util.StubUtil;
import br.com.swconsultoria.nfe.wsdl.NFeRecepcaoEvento.NFeRecepcaoEvento4Stub;
import mockit.Mock;
import mockit.MockUp;
import org.apache.axiom.om.util.AXIOMUtil;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;

class CancelarTest {

private static final String RET_EVENTO_XML =
"<retEnvEvento versao=\"1.00\" xmlns=\"http://www.portalfiscal.inf.br/nfe\">" +
"<idLote>1</idLote><tpAmb>2</tpAmb><verAplic>TESTE</verAplic>" +
"<cOrgao>91</cOrgao><cStat>128</cStat>" +
"<xMotivo>Lote de Evento Processado</xMotivo>" +
"</retEnvEvento>";

private ConfiguracoesNfe config;
private TEnvEvento enviEvento;

@BeforeEach
void setUp() throws NfeException {
config = new ConfiguracoesNfe();
config.setEstado(EstadosEnum.SP);
config.setAmbiente(AmbienteEnum.HOMOLOGACAO);
config.setEncode("UTF-8");

config.setZoneId(java.time.ZoneId.of("America/Sao_Paulo"));

Evento evento = new Evento();
evento.setChave("52230309158456000159550010000731791567812345");
evento.setCnpj("09158456000159");
evento.setProtocolo("352230000123456");
evento.setMotivo("Cancelamento por erro na emissao do documento fiscal");
evento.setDataEvento(java.time.LocalDateTime.of(2024, 1, 15, 10, 0, 0));
enviEvento = CancelamentoUtil.montaCancelamento(evento, config);
}

private void mockStubUtil() {
new MockUp<StubUtil>() {
@Mock
public void configuraHttpClient(org.apache.axis2.client.Stub stub,
ConfiguracoesNfe cfg, String url) { }
};
}

private void mockAssinar() {
new MockUp<Assinar>() {
@Mock
public String assinaNfe(ConfiguracoesNfe cfg, String xml,
AssinaturaEnum tipo) throws NfeException {
return xml;
}
};
}

private void mockEventosStub() {
new MockUp<NFeRecepcaoEvento4Stub>() {
@Mock
public void $init(String endpoint) { }

@Mock
public NFeRecepcaoEvento4Stub.NfeResultMsg nfeRecepcaoEvento(
NFeRecepcaoEvento4Stub.NfeDadosMsg data) throws Exception {
NFeRecepcaoEvento4Stub.NfeResultMsg result = new NFeRecepcaoEvento4Stub.NfeResultMsg();
result.setExtraElement(AXIOMUtil.stringToOM(RET_EVENTO_XML));
return result;
}
};
}

@Test
void eventoCancelamento_semValidacao_retornaEvento() throws NfeException {
mockStubUtil();
mockAssinar();
mockEventosStub();

TRetEnvEvento ret = Cancelar.eventoCancelamento(config, enviEvento, false, DocumentoEnum.NFE);

assertNotNull(ret);
assertEquals("128", ret.getCStat());
}

@Test
void eventoCancelamento_retornaLoteProcessado() throws NfeException {
mockStubUtil();
mockAssinar();
mockEventosStub();

TRetEnvEvento ret = Cancelar.eventoCancelamento(config, enviEvento, false, DocumentoEnum.NFE);

assertEquals("Lote de Evento Processado", ret.getXMotivo());
}

@Test
void eventoCancelamento_retornaAmbienteHomologacao() throws NfeException {
mockStubUtil();
mockAssinar();
mockEventosStub();

TRetEnvEvento ret = Cancelar.eventoCancelamento(config, enviEvento, false, DocumentoEnum.NFE);

assertEquals("2", ret.getTpAmb());
}
}
119 changes: 119 additions & 0 deletions src/test/java/br/com/swconsultoria/nfe/CartaCorrecaoTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
package br.com.swconsultoria.nfe;

import br.com.swconsultoria.nfe.dom.ConfiguracoesNfe;
import br.com.swconsultoria.nfe.dom.Evento;
import br.com.swconsultoria.nfe.dom.enuns.AmbienteEnum;
import br.com.swconsultoria.nfe.dom.enuns.AssinaturaEnum;
import br.com.swconsultoria.nfe.dom.enuns.EstadosEnum;
import br.com.swconsultoria.nfe.exception.NfeException;
import br.com.swconsultoria.nfe.schema.envcce.TEnvEvento;
import br.com.swconsultoria.nfe.schema.envcce.TRetEnvEvento;
import br.com.swconsultoria.nfe.util.CartaCorrecaoUtil;
import br.com.swconsultoria.nfe.util.StubUtil;
import br.com.swconsultoria.nfe.wsdl.NFeRecepcaoEvento.NFeRecepcaoEvento4Stub;
import mockit.Mock;
import mockit.MockUp;
import org.apache.axiom.om.util.AXIOMUtil;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;

class CartaCorrecaoTest {

private static final String RET_EVENTO_XML =
"<retEnvEvento versao=\"1.00\" xmlns=\"http://www.portalfiscal.inf.br/nfe\">" +
"<idLote>1</idLote><tpAmb>2</tpAmb><verAplic>TESTE</verAplic>" +
"<cOrgao>91</cOrgao><cStat>128</cStat>" +
"<xMotivo>Lote de Evento Processado</xMotivo>" +
"</retEnvEvento>";

private ConfiguracoesNfe config;
private TEnvEvento enviEvento;

@BeforeEach
void setUp() throws NfeException {
config = new ConfiguracoesNfe();
config.setEstado(EstadosEnum.SP);
config.setAmbiente(AmbienteEnum.HOMOLOGACAO);
config.setEncode("UTF-8");

config.setZoneId(java.time.ZoneId.of("America/Sao_Paulo"));

Evento evento = new Evento();
evento.setChave("52230309158456000159550010000731791567812345");
evento.setCnpj("09158456000159");
evento.setMotivo("Correcao no campo de endereco do destinatario da nota fiscal");
evento.setSequencia(1);
evento.setDataEvento(java.time.LocalDateTime.of(2024, 3, 10, 9, 0, 0));
enviEvento = CartaCorrecaoUtil.montaCCe(evento, config);
}

private void mockStubUtil() {
new MockUp<StubUtil>() {
@Mock
public void configuraHttpClient(org.apache.axis2.client.Stub stub,
ConfiguracoesNfe cfg, String url) { }
};
}

private void mockAssinar() {
new MockUp<Assinar>() {
@Mock
public String assinaNfe(ConfiguracoesNfe cfg, String xml,
AssinaturaEnum tipo) throws NfeException {
return xml;
}
};
}

private void mockEventosStub() {
new MockUp<NFeRecepcaoEvento4Stub>() {
@Mock
public void $init(String endpoint) { }

@Mock
public NFeRecepcaoEvento4Stub.NfeResultMsg nfeRecepcaoEvento(
NFeRecepcaoEvento4Stub.NfeDadosMsg data) throws Exception {
NFeRecepcaoEvento4Stub.NfeResultMsg result = new NFeRecepcaoEvento4Stub.NfeResultMsg();
result.setExtraElement(AXIOMUtil.stringToOM(RET_EVENTO_XML));
return result;
}
};
}

@Test
void eventoCCe_semValidacao_retornaEvento() throws NfeException {
mockStubUtil();
mockAssinar();
mockEventosStub();

TRetEnvEvento ret = CartaCorrecao.eventoCCe(config, enviEvento, false);

assertNotNull(ret);
assertEquals("128", ret.getCStat());
}

@Test
void eventoCCe_retornaLoteProcessado() throws NfeException {
mockStubUtil();
mockAssinar();
mockEventosStub();

TRetEnvEvento ret = CartaCorrecao.eventoCCe(config, enviEvento, false);

assertEquals("Lote de Evento Processado", ret.getXMotivo());
}

@Test
void eventoCCe_retornaAmbienteHomologacao() throws NfeException {
mockStubUtil();
mockAssinar();
mockEventosStub();

TRetEnvEvento ret = CartaCorrecao.eventoCCe(config, enviEvento, false);

assertEquals("2", ret.getTpAmb());
}
}
Loading
Loading