Skip to content

Commit 65691bf

Browse files
committed
Merge branch 'master' into SKYW-1751-Atualizar-biblioteca-Java_NFe-para-a-versao-mais-recente
2 parents 0f0db02 + e957127 commit 65691bf

34 files changed

+2652
-18
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ target/
22
.idea/
33
*.iml
44
/target/
5+
/.github/*.md
6+
show,

README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 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)
1+
# 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)
22
Biblioteca Java para consumo do WebService de NFe/NFCe
33

44
### Powered by
@@ -22,7 +22,7 @@ Para Iniciar :
2222
<dependency>
2323
<groupId>br.com.swconsultoria</groupId>
2424
<artifactId>java-nfe</artifactId>
25-
<version>4.00.49</version>
25+
<version>4.00.51</version>
2626
</dependency>
2727
```
2828

@@ -34,7 +34,7 @@ repositories {
3434
}
3535
}
3636
dependencies {
37-
implementation "br.com.swconsultoria:java-nfe:4.00.49"
37+
implementation "br.com.swconsultoria:java-nfe:4.00.51"
3838
}
3939
```
4040

@@ -44,6 +44,13 @@ ________________________________________________________________________________
4444

4545
# Historico de Versões
4646

47+
## v4.00.51 - 19/03/2026 - Schemas PL.010b (v1.30)
48+
- Adicionado Teste Unitarios
49+
- Atualizado Cacert
50+
51+
## v4.00.50 - 16/02/2026 - Schemas PL.010b (v1.30)
52+
- Ajustes Impressao Danfe
53+
4754
## v4.00.49 - 18/01/2026 - Schemas PL.010b (v1.30)
4855
- Corrigido monofasia retida Anteriormente.
4956
- Adicionado calculos IBSCBS para Diferimento

pom.xml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
<groupId>br.com.swconsultoria</groupId>
55
<artifactId>java-nfe</artifactId>
6-
<version>4.00.49</version>
6+
<version>4.00.51</version>
77
<name>Java_NFe</name>
88
<description>Api java para consumo do webService de nota fiscal eletronica</description>
99
<url>https://github.com/Samuel-Oliveira/Java_NFe</url>
@@ -31,7 +31,7 @@
3131
<java.version>1.8</java.version>
3232

3333
<!-- Versions -->
34-
<java-certificado.version>3.13</java-certificado.version>
34+
<java-certificado.version>3.14</java-certificado.version>
3535
<httpcore.version>4.4.6</httpcore.version>
3636
<jaxb-impl.version>2.3.1</jaxb-impl.version>
3737
<jaxb-xjc.version>2.3.1</jaxb-xjc.version>
@@ -279,6 +279,15 @@
279279
<autoPublish>true</autoPublish>
280280
</configuration>
281281
</plugin>
282+
<!-- Cobertura de testes -->
283+
<plugin>
284+
<groupId>org.eluder.coveralls</groupId>
285+
<artifactId>coveralls-maven-plugin</artifactId>
286+
<version>4.3.0</version>
287+
<configuration>
288+
<repoToken>paGe4qkZvPNJtvxqY8NaJN5ImZO56RqB6</repoToken>
289+
</configuration>
290+
</plugin>
282291
</plugins>
283292
</build>
284293
</project>

src/main/java/br/com/swconsultoria/nfe/dom/ConfiguracoesNfe.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ public static ConfiguracoesNfe criarConfiguracoes(EstadosEnum estado, AmbienteEn
109109

110110
log.info(String.format("JAVA-NFE | Samuel Oliveira | samuel@swconsultoria.com.br " +
111111
"| VERSAO=%s | DATA_VERSAO=%s | PASTA_SCHEMAS=%s | AMBIENTE=%s | ESTADO=%s",
112-
"4.00.49",
113-
"18/01/2026",
112+
"4.00.51",
113+
"19/03/2026",
114114
pastaSchemas,
115115
ambiente,
116116
estado.getNome().toUpperCase()));
539 Bytes
Binary file not shown.

src/main/resources/jasper/nfe/danfe.jrxml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,8 +1001,8 @@ $F{Trans_CPF}.substring(9,11) : ""]]></textFieldExpression>
10011001
<textElement verticalAlignment="Top">
10021002
<font size="6" isItalic="false"/>
10031003
</textElement>
1004-
<textFieldExpression><![CDATA["Inf. Contribuinte:"+$F{Informacoes}.replace(" ","").replace("\n"," ")+
1005-
"\nInf. Fisco:"+$F{Informacoes_fisco}.replace(" ","").replace("\n"," ")]]></textFieldExpression>
1004+
<textFieldExpression><![CDATA[($F{Informacoes} != null ? ("Inf. Contribuinte:"+$F{Informacoes}.replace(" ","").replace("\n"," ") + "\n") : "") +
1005+
($F{Informacoes_fisco} != null ? ("Inf. Fisco:"+$F{Informacoes_fisco}.replace(" ","").replace("\n"," ")): "")]]></textFieldExpression>
10061006
</textField>
10071007
<frame>
10081008
<reportElement positionType="FixRelativeToBottom" stretchType="ContainerBottom" mode="Transparent" x="0" y="0" width="565" height="34" isPrintWhenDetailOverflows="true" uuid="91c422c4-c8b1-42ed-accb-e694dbf89daa">
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
package br.com.swconsultoria.nfe;
2+
3+
import br.com.swconsultoria.nfe.dom.ConfiguracoesNfe;
4+
import br.com.swconsultoria.nfe.dom.Evento;
5+
import br.com.swconsultoria.nfe.dom.enuns.AmbienteEnum;
6+
import br.com.swconsultoria.nfe.dom.enuns.AssinaturaEnum;
7+
import br.com.swconsultoria.nfe.dom.enuns.DocumentoEnum;
8+
import br.com.swconsultoria.nfe.dom.enuns.EstadosEnum;
9+
import br.com.swconsultoria.nfe.exception.NfeException;
10+
import br.com.swconsultoria.nfe.schema.envEventoCancNFe.TEnvEvento;
11+
import br.com.swconsultoria.nfe.schema.envEventoCancNFe.TRetEnvEvento;
12+
import br.com.swconsultoria.nfe.util.CancelamentoUtil;
13+
import br.com.swconsultoria.nfe.util.StubUtil;
14+
import br.com.swconsultoria.nfe.wsdl.NFeRecepcaoEvento.NFeRecepcaoEvento4Stub;
15+
import mockit.Mock;
16+
import mockit.MockUp;
17+
import org.apache.axiom.om.util.AXIOMUtil;
18+
import org.junit.jupiter.api.BeforeEach;
19+
import org.junit.jupiter.api.Test;
20+
21+
import static org.junit.jupiter.api.Assertions.assertEquals;
22+
import static org.junit.jupiter.api.Assertions.assertNotNull;
23+
24+
class CancelarTest {
25+
26+
private static final String RET_EVENTO_XML =
27+
"<retEnvEvento versao=\"1.00\" xmlns=\"http://www.portalfiscal.inf.br/nfe\">" +
28+
"<idLote>1</idLote><tpAmb>2</tpAmb><verAplic>TESTE</verAplic>" +
29+
"<cOrgao>91</cOrgao><cStat>128</cStat>" +
30+
"<xMotivo>Lote de Evento Processado</xMotivo>" +
31+
"</retEnvEvento>";
32+
33+
private ConfiguracoesNfe config;
34+
private TEnvEvento enviEvento;
35+
36+
@BeforeEach
37+
void setUp() throws NfeException {
38+
config = new ConfiguracoesNfe();
39+
config.setEstado(EstadosEnum.SP);
40+
config.setAmbiente(AmbienteEnum.HOMOLOGACAO);
41+
config.setEncode("UTF-8");
42+
43+
config.setZoneId(java.time.ZoneId.of("America/Sao_Paulo"));
44+
45+
Evento evento = new Evento();
46+
evento.setChave("52230309158456000159550010000731791567812345");
47+
evento.setCnpj("09158456000159");
48+
evento.setProtocolo("352230000123456");
49+
evento.setMotivo("Cancelamento por erro na emissao do documento fiscal");
50+
evento.setDataEvento(java.time.LocalDateTime.of(2024, 1, 15, 10, 0, 0));
51+
enviEvento = CancelamentoUtil.montaCancelamento(evento, config);
52+
}
53+
54+
private void mockStubUtil() {
55+
new MockUp<StubUtil>() {
56+
@Mock
57+
public void configuraHttpClient(org.apache.axis2.client.Stub stub,
58+
ConfiguracoesNfe cfg, String url) { }
59+
};
60+
}
61+
62+
private void mockAssinar() {
63+
new MockUp<Assinar>() {
64+
@Mock
65+
public String assinaNfe(ConfiguracoesNfe cfg, String xml,
66+
AssinaturaEnum tipo) throws NfeException {
67+
return xml;
68+
}
69+
};
70+
}
71+
72+
private void mockEventosStub() {
73+
new MockUp<NFeRecepcaoEvento4Stub>() {
74+
@Mock
75+
public void $init(String endpoint) { }
76+
77+
@Mock
78+
public NFeRecepcaoEvento4Stub.NfeResultMsg nfeRecepcaoEvento(
79+
NFeRecepcaoEvento4Stub.NfeDadosMsg data) throws Exception {
80+
NFeRecepcaoEvento4Stub.NfeResultMsg result = new NFeRecepcaoEvento4Stub.NfeResultMsg();
81+
result.setExtraElement(AXIOMUtil.stringToOM(RET_EVENTO_XML));
82+
return result;
83+
}
84+
};
85+
}
86+
87+
@Test
88+
void eventoCancelamento_semValidacao_retornaEvento() throws NfeException {
89+
mockStubUtil();
90+
mockAssinar();
91+
mockEventosStub();
92+
93+
TRetEnvEvento ret = Cancelar.eventoCancelamento(config, enviEvento, false, DocumentoEnum.NFE);
94+
95+
assertNotNull(ret);
96+
assertEquals("128", ret.getCStat());
97+
}
98+
99+
@Test
100+
void eventoCancelamento_retornaLoteProcessado() throws NfeException {
101+
mockStubUtil();
102+
mockAssinar();
103+
mockEventosStub();
104+
105+
TRetEnvEvento ret = Cancelar.eventoCancelamento(config, enviEvento, false, DocumentoEnum.NFE);
106+
107+
assertEquals("Lote de Evento Processado", ret.getXMotivo());
108+
}
109+
110+
@Test
111+
void eventoCancelamento_retornaAmbienteHomologacao() throws NfeException {
112+
mockStubUtil();
113+
mockAssinar();
114+
mockEventosStub();
115+
116+
TRetEnvEvento ret = Cancelar.eventoCancelamento(config, enviEvento, false, DocumentoEnum.NFE);
117+
118+
assertEquals("2", ret.getTpAmb());
119+
}
120+
}
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
package br.com.swconsultoria.nfe;
2+
3+
import br.com.swconsultoria.nfe.dom.ConfiguracoesNfe;
4+
import br.com.swconsultoria.nfe.dom.Evento;
5+
import br.com.swconsultoria.nfe.dom.enuns.AmbienteEnum;
6+
import br.com.swconsultoria.nfe.dom.enuns.AssinaturaEnum;
7+
import br.com.swconsultoria.nfe.dom.enuns.EstadosEnum;
8+
import br.com.swconsultoria.nfe.exception.NfeException;
9+
import br.com.swconsultoria.nfe.schema.envcce.TEnvEvento;
10+
import br.com.swconsultoria.nfe.schema.envcce.TRetEnvEvento;
11+
import br.com.swconsultoria.nfe.util.CartaCorrecaoUtil;
12+
import br.com.swconsultoria.nfe.util.StubUtil;
13+
import br.com.swconsultoria.nfe.wsdl.NFeRecepcaoEvento.NFeRecepcaoEvento4Stub;
14+
import mockit.Mock;
15+
import mockit.MockUp;
16+
import org.apache.axiom.om.util.AXIOMUtil;
17+
import org.junit.jupiter.api.BeforeEach;
18+
import org.junit.jupiter.api.Test;
19+
20+
import static org.junit.jupiter.api.Assertions.assertEquals;
21+
import static org.junit.jupiter.api.Assertions.assertNotNull;
22+
23+
class CartaCorrecaoTest {
24+
25+
private static final String RET_EVENTO_XML =
26+
"<retEnvEvento versao=\"1.00\" xmlns=\"http://www.portalfiscal.inf.br/nfe\">" +
27+
"<idLote>1</idLote><tpAmb>2</tpAmb><verAplic>TESTE</verAplic>" +
28+
"<cOrgao>91</cOrgao><cStat>128</cStat>" +
29+
"<xMotivo>Lote de Evento Processado</xMotivo>" +
30+
"</retEnvEvento>";
31+
32+
private ConfiguracoesNfe config;
33+
private TEnvEvento enviEvento;
34+
35+
@BeforeEach
36+
void setUp() throws NfeException {
37+
config = new ConfiguracoesNfe();
38+
config.setEstado(EstadosEnum.SP);
39+
config.setAmbiente(AmbienteEnum.HOMOLOGACAO);
40+
config.setEncode("UTF-8");
41+
42+
config.setZoneId(java.time.ZoneId.of("America/Sao_Paulo"));
43+
44+
Evento evento = new Evento();
45+
evento.setChave("52230309158456000159550010000731791567812345");
46+
evento.setCnpj("09158456000159");
47+
evento.setMotivo("Correcao no campo de endereco do destinatario da nota fiscal");
48+
evento.setSequencia(1);
49+
evento.setDataEvento(java.time.LocalDateTime.of(2024, 3, 10, 9, 0, 0));
50+
enviEvento = CartaCorrecaoUtil.montaCCe(evento, config);
51+
}
52+
53+
private void mockStubUtil() {
54+
new MockUp<StubUtil>() {
55+
@Mock
56+
public void configuraHttpClient(org.apache.axis2.client.Stub stub,
57+
ConfiguracoesNfe cfg, String url) { }
58+
};
59+
}
60+
61+
private void mockAssinar() {
62+
new MockUp<Assinar>() {
63+
@Mock
64+
public String assinaNfe(ConfiguracoesNfe cfg, String xml,
65+
AssinaturaEnum tipo) throws NfeException {
66+
return xml;
67+
}
68+
};
69+
}
70+
71+
private void mockEventosStub() {
72+
new MockUp<NFeRecepcaoEvento4Stub>() {
73+
@Mock
74+
public void $init(String endpoint) { }
75+
76+
@Mock
77+
public NFeRecepcaoEvento4Stub.NfeResultMsg nfeRecepcaoEvento(
78+
NFeRecepcaoEvento4Stub.NfeDadosMsg data) throws Exception {
79+
NFeRecepcaoEvento4Stub.NfeResultMsg result = new NFeRecepcaoEvento4Stub.NfeResultMsg();
80+
result.setExtraElement(AXIOMUtil.stringToOM(RET_EVENTO_XML));
81+
return result;
82+
}
83+
};
84+
}
85+
86+
@Test
87+
void eventoCCe_semValidacao_retornaEvento() throws NfeException {
88+
mockStubUtil();
89+
mockAssinar();
90+
mockEventosStub();
91+
92+
TRetEnvEvento ret = CartaCorrecao.eventoCCe(config, enviEvento, false);
93+
94+
assertNotNull(ret);
95+
assertEquals("128", ret.getCStat());
96+
}
97+
98+
@Test
99+
void eventoCCe_retornaLoteProcessado() throws NfeException {
100+
mockStubUtil();
101+
mockAssinar();
102+
mockEventosStub();
103+
104+
TRetEnvEvento ret = CartaCorrecao.eventoCCe(config, enviEvento, false);
105+
106+
assertEquals("Lote de Evento Processado", ret.getXMotivo());
107+
}
108+
109+
@Test
110+
void eventoCCe_retornaAmbienteHomologacao() throws NfeException {
111+
mockStubUtil();
112+
mockAssinar();
113+
mockEventosStub();
114+
115+
TRetEnvEvento ret = CartaCorrecao.eventoCCe(config, enviEvento, false);
116+
117+
assertEquals("2", ret.getTpAmb());
118+
}
119+
}

0 commit comments

Comments
 (0)