Skip to content

Commit 684f6e2

Browse files
- Adicionado calculos IBSCBS para Diferimento
- Atualizado Cacerts - Corrigido monofasia retida Anteriormente. - Corrigido Informacoes Fisco Impressao Danfe
1 parent 08a5d8b commit 684f6e2

File tree

19 files changed

+5638
-109
lines changed

19 files changed

+5638
-109
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
# Notas de versão
2-
- Corrigido monofasia retida Anteriormente.
2+
- Adicionado calculos IBSCBS para Diferimento
3+
- Atualizado Cacerts
4+
- Corrigido monofasia retida Anteriormente.
5+
- Corrigido Informacoes Fisco Impressao Danfe

README.md

Lines changed: 7 additions & 4 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.48/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.49/jar)
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.48</version>
25+
<version>4.00.49</version>
2626
</dependency>
2727
```
2828

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

@@ -44,8 +44,11 @@ ________________________________________________________________________________
4444

4545
# Historico de Versões
4646

47-
## v4.00.49 - ??? - Schemas PL.010b (v1.30)
47+
## v4.00.49 - 18/01/2026 - Schemas PL.010b (v1.30)
4848
- Corrigido monofasia retida Anteriormente.
49+
- Adicionado calculos IBSCBS para Diferimento
50+
- Atualizado Cacerts
51+
- Corrigido Informacoes Fisco Impressao Danfe
4952

5053
## v4.00.48 - 20/12/2025 - Schemas PL.010b (v1.30)
5154
- Adicionado Monofasico aos calculos IBSCBS

pom.xml

Lines changed: 2 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.48</version>
6+
<version>4.00.49</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.12</java-certificado.version>
34+
<java-certificado.version>3.13</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>

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.48",
113-
"20/12/2025",
112+
"4.00.49",
113+
"18/01/2026",
114114
pastaSchemas,
115115
ambiente,
116116
estado.getNome().toUpperCase()));

src/main/java/br/com/swconsultoria/nfe/util/IbsCbsUtil.java

Lines changed: 61 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ public class IbsCbsUtil {
2020
private static final String TOTAL_IBS_UF = "TOTAL_IBS_UF";
2121
private static final String TOTAL_IBS_MUN = "TOTAL_IBS_MUN";
2222
private static final String TOTAL_CBS = "TOTAL_CBS";
23+
private static final String TOTAL_DIFERIMENTO_IBS_UF = "TOTAL_DIFERIMENTO_IBS_UF";
24+
private static final String TOTAL_DIFERIMENTO_IBS_MUN = "TOTAL_DIFERIMENTO_IBS_MUN";
25+
private static final String TOTAL_DIFERIMENTO_CBS = "TOTAL_DIFERIMENTO_CBS";
2326
private static final BigDecimal CEM = BigDecimal.valueOf(100);
2427
private static final int SCALE_5 = 5;
2528

@@ -35,6 +38,7 @@ public class IbsCbsUtil {
3538
private BigDecimal pAliqIbsUf = new BigDecimal("0.1");
3639
private BigDecimal pAliqIbsMun = BigDecimal.ZERO;
3740
private BigDecimal pAliqCbs = new BigDecimal("0.9");
41+
private BigDecimal pAliqDiferimento = BigDecimal.ZERO;
3842
private BigDecimal baseCalculo = BigDecimal.ZERO;
3943

4044
public void setpAliqIbsUf(BigDecimal pAliqIbsUf) {
@@ -49,6 +53,10 @@ public void setpAliqCbs(BigDecimal pAliqCbs) {
4953
this.pAliqCbs = pAliqCbs;
5054
}
5155

56+
public void setpAliqDiferimento(BigDecimal pAliqDiferimento) {
57+
this.pAliqDiferimento = pAliqDiferimento;
58+
}
59+
5260
public IbsCbsUtil(@NonNull List<CstDTO> listaCstIbsCbs, @NonNull DocumentoEnum documento) {
5361
this.listaCstIbsCbs = listaCstIbsCbs;
5462
this.documento = documento;
@@ -66,6 +74,9 @@ private void inicializarTotais() {
6674
mapTotais.put(TOTAL_IBS_UF, BigDecimal.ZERO);
6775
mapTotais.put(TOTAL_IBS_MUN, BigDecimal.ZERO);
6876
mapTotais.put(TOTAL_CBS, BigDecimal.ZERO);
77+
mapTotais.put(TOTAL_DIFERIMENTO_IBS_UF, BigDecimal.ZERO);
78+
mapTotais.put(TOTAL_DIFERIMENTO_IBS_MUN, BigDecimal.ZERO);
79+
mapTotais.put(TOTAL_DIFERIMENTO_CBS, BigDecimal.ZERO);
6980
}
7081

7182
public TTribNFe montaImpostosDet(String cclassTrib, TNFe.InfNFe.Det det) throws NfeException {
@@ -94,7 +105,7 @@ public TTribNFe montaImpostosDet(String cclassTrib, TNFe.InfNFe.Det det, String
94105

95106
private TMonofasia montaGrupoMono(TNFe.InfNFe.Det det) {
96107
TMonofasia gMono = new TMonofasia();
97-
if(Boolean.TRUE.equals(classTribIbsCbs.getMonofasiaPadrao())) {
108+
if (Boolean.TRUE.equals(classTribIbsCbs.getMonofasiaPadrao())) {
98109
TMonofasia.GMonoPadrao monoPadrao = new TMonofasia.GMonoPadrao();
99110
monoPadrao.setQBCMono(ObjetoUtil.getValor4Casas(new BigDecimal(det.getProd().getQCom())));
100111
monoPadrao.setAdRemIBS("0.00");
@@ -104,7 +115,7 @@ private TMonofasia montaGrupoMono(TNFe.InfNFe.Det det) {
104115
gMono.setGMonoPadrao(monoPadrao);
105116
}
106117

107-
if(Boolean.TRUE.equals(classTribIbsCbs.getMonofasiaRetidaAnt())) {
118+
if (Boolean.TRUE.equals(classTribIbsCbs.getMonofasiaRetidaAnt())) {
108119
TMonofasia.GMonoRet monoRet = new TMonofasia.GMonoRet();
109120
monoRet.setQBCMonoRet(ObjetoUtil.getValor4Casas(new BigDecimal(det.getProd().getQCom())));
110121
monoRet.setAdRemCBSRet("0.00");
@@ -114,7 +125,7 @@ private TMonofasia montaGrupoMono(TNFe.InfNFe.Det det) {
114125
gMono.setGMonoRet(monoRet);
115126
}
116127

117-
if(Boolean.TRUE.equals(classTribIbsCbs.getMonofasiaSujeitaRetencao())) {
128+
if (Boolean.TRUE.equals(classTribIbsCbs.getMonofasiaSujeitaRetencao())) {
118129
TMonofasia.GMonoReten monoReten = new TMonofasia.GMonoReten();
119130
monoReten.setQBCMonoReten(ObjetoUtil.getValor4Casas(new BigDecimal(det.getProd().getQCom())));
120131
monoReten.setAdRemCBSReten("0.00");
@@ -124,7 +135,7 @@ private TMonofasia montaGrupoMono(TNFe.InfNFe.Det det) {
124135
gMono.setGMonoReten(monoReten);
125136
}
126137

127-
if(Boolean.TRUE.equals(classTribIbsCbs.getMonofasiaDiferimento())) {
138+
if (Boolean.TRUE.equals(classTribIbsCbs.getMonofasiaDiferimento())) {
128139
TMonofasia.GMonoDif gMonoDif = new TMonofasia.GMonoDif();
129140
gMonoDif.setPDifCBS("0.00");
130141
gMonoDif.setPDifIBS("0.00");
@@ -141,9 +152,9 @@ private TMonofasia montaGrupoMono(TNFe.InfNFe.Det det) {
141152

142153
private boolean deveMontarGrupoIBSCBS() {
143154
return Boolean.TRUE.equals(cstIbsCbs.getIndIBSCBS())
144-
|| Boolean.TRUE.equals(cstIbsCbs.getIndRedAliq())
145-
|| Boolean.TRUE.equals(cstIbsCbs.getIndDif())
146-
|| Boolean.TRUE.equals(cstIbsCbs.getIndTransfCred());
155+
|| Boolean.TRUE.equals(cstIbsCbs.getIndRedAliq())
156+
|| Boolean.TRUE.equals(cstIbsCbs.getIndDif())
157+
|| Boolean.TRUE.equals(cstIbsCbs.getIndTransfCred());
147158
}
148159

149160
private TCIBS montarGrupoIBSCBS() {
@@ -173,6 +184,15 @@ private void atualizarTotais(TCIBS.GIBSUF gIBSUF, TCIBS.GIBSMun gIBSMun, TCIBS.G
173184
mapTotais.merge(TOTAL_IBS_UF, new BigDecimal(gIBSUF.getVIBSUF()), BigDecimal::add);
174185
mapTotais.merge(TOTAL_IBS_MUN, new BigDecimal(gIBSMun.getVIBSMun()), BigDecimal::add);
175186
mapTotais.merge(TOTAL_CBS, new BigDecimal(gCBS.getVCBS()), BigDecimal::add);
187+
if(gIBSUF.getGDif() != null){
188+
mapTotais.merge(TOTAL_DIFERIMENTO_IBS_UF, new BigDecimal(gIBSUF.getGDif().getVDif()), BigDecimal::add);
189+
}
190+
if(gIBSMun.getGDif() != null){
191+
mapTotais.merge(TOTAL_DIFERIMENTO_IBS_MUN, new BigDecimal(gIBSMun.getGDif().getVDif()), BigDecimal::add);
192+
}
193+
if(gCBS.getGDif() != null){
194+
mapTotais.merge(TOTAL_DIFERIMENTO_CBS, new BigDecimal(gCBS.getGDif().getVDif()), BigDecimal::add);
195+
}
176196
}
177197

178198
private void filtraCClasstrib(String cclassTrib, String cclassTribRegular) {
@@ -218,9 +238,11 @@ private void validaClassTrib(String cclassTrib) throws NfeException {
218238
private TCIBS.GIBSUF criarGIBSUF() {
219239
return criarGrupoImposto(
220240
pAliqIbsUf,
241+
pAliqDiferimento,
221242
classTribIbsCbs.getPRedIBS(),
222243
TCIBS.GIBSUF::new,
223244
TCIBS.GIBSUF::setPIBSUF,
245+
TCIBS.GIBSUF::setGDif,
224246
TCIBS.GIBSUF::setGRed,
225247
TCIBS.GIBSUF::setVIBSUF
226248
);
@@ -229,9 +251,11 @@ private TCIBS.GIBSUF criarGIBSUF() {
229251
private TCIBS.GIBSMun criarGIBSMun() {
230252
return criarGrupoImposto(
231253
pAliqIbsMun,
254+
pAliqDiferimento,
232255
classTribIbsCbs.getPRedIBS(),
233256
TCIBS.GIBSMun::new,
234257
TCIBS.GIBSMun::setPIBSMun,
258+
TCIBS.GIBSMun::setGDif,
235259
TCIBS.GIBSMun::setGRed,
236260
TCIBS.GIBSMun::setVIBSMun
237261
);
@@ -240,9 +264,11 @@ private TCIBS.GIBSMun criarGIBSMun() {
240264
private TCIBS.GCBS criarGCBS() {
241265
return criarGrupoImposto(
242266
pAliqCbs,
267+
pAliqDiferimento,
243268
classTribIbsCbs.getPRedCBS(),
244269
TCIBS.GCBS::new,
245270
TCIBS.GCBS::setPCBS,
271+
TCIBS.GCBS::setGDif,
246272
TCIBS.GCBS::setGRed,
247273
TCIBS.GCBS::setVCBS
248274
);
@@ -263,16 +289,23 @@ private interface RedutorSetter<T> {
263289
void set(T grupo, TRed redutor);
264290
}
265291

292+
@FunctionalInterface
293+
private interface DifererimentoSetter<T> {
294+
void set(T grupo, TDif diferimento);
295+
}
296+
266297
@FunctionalInterface
267298
private interface ValorSetter<T> {
268299
void set(T grupo, String valor);
269300
}
270301

271302
private <T> T criarGrupoImposto(
272303
BigDecimal aliqPadrao,
304+
BigDecimal percentualDiferimento,
273305
BigDecimal percentualReducao,
274306
GrupoImpostoFactory<T> factory,
275307
AliquotaSetter<T> aliqSetter,
308+
DifererimentoSetter<T> difSetter,
276309
RedutorSetter<T> redSetter,
277310
ValorSetter<T> valorSetter) {
278311

@@ -283,16 +316,25 @@ private <T> T criarGrupoImposto(
283316

284317
aliqSetter.set(grupo, ObjetoUtil.getValor4Casas(aliq));
285318

286-
BigDecimal percentRed = ObjetoUtil.getOrZero(percentualReducao);
287319
BigDecimal aliqEfet = aliq;
288320

289321
if (Boolean.TRUE.equals(cstIbsCbs.getIndRedAliq())) {
322+
BigDecimal percentRed = ObjetoUtil.getOrZero(percentualReducao);
290323
TRed gRed = criarRedutor(percentRed, aliq);
291324
redSetter.set(grupo, gRed);
292325
aliqEfet = new BigDecimal(gRed.getPAliqEfet());
293326
}
294327

295328
BigDecimal valor = calcularValorImposto(aliqEfet);
329+
330+
if (Boolean.TRUE.equals(cstIbsCbs.getIndDif())) {
331+
BigDecimal percentDif = ObjetoUtil.getOrZero(percentualDiferimento);
332+
TDif gDif = criarDiferimento(percentDif, aliqEfet);
333+
difSetter.set(grupo, gDif);
334+
valor = valor.subtract(new BigDecimal(gDif.getVDif()));
335+
}
336+
337+
296338
valorSetter.set(grupo, ObjetoUtil.getValor2Casas(valor));
297339

298340
return grupo;
@@ -341,6 +383,14 @@ private static TRed criarRedutor(BigDecimal percentualReducao, BigDecimal aliqOr
341383
return gRed;
342384
}
343385

386+
private TDif criarDiferimento(BigDecimal percentualDiferimento, BigDecimal aliqEfet) {
387+
TDif gDif = new TDif();
388+
gDif.setPDif(ObjetoUtil.getValor4Casas(percentualDiferimento));
389+
BigDecimal valorDif = calcularValorImposto(percentualDiferimento).multiply(aliqEfet.divide(CEM, SCALE_5, RoundingMode.HALF_UP));
390+
gDif.setVDif(ObjetoUtil.getValor2Casas(valorDif));
391+
return gDif;
392+
}
393+
344394
@SuppressWarnings("unchecked")
345395
private void calcularBaseCalculoIBSCBS(TNFe.InfNFe.Det det) {
346396
BigDecimal vProd = ObjetoUtil.getBigDecimalOrZero(det.getProd().getVProd());
@@ -397,23 +447,23 @@ private TIBSCBSMonoTot.GIBS criarTotaisIBS() {
397447

398448
private TIBSCBSMonoTot.GIBS.GIBSUF criarGIBSUFTotal() {
399449
TIBSCBSMonoTot.GIBS.GIBSUF gIbsUF = new TIBSCBSMonoTot.GIBS.GIBSUF();
400-
gIbsUF.setVDif("0.00");
450+
gIbsUF.setVDif(ObjetoUtil.getValor2Casas(mapTotais.getOrDefault(TOTAL_DIFERIMENTO_IBS_UF, BigDecimal.ZERO)));
401451
gIbsUF.setVDevTrib("0.00");
402452
gIbsUF.setVIBSUF(ObjetoUtil.getValor2Casas(mapTotais.getOrDefault(TOTAL_IBS_UF, BigDecimal.ZERO)));
403453
return gIbsUF;
404454
}
405455

406456
private TIBSCBSMonoTot.GIBS.GIBSMun criarGIBSMunTotal() {
407457
TIBSCBSMonoTot.GIBS.GIBSMun gIbsMun = new TIBSCBSMonoTot.GIBS.GIBSMun();
408-
gIbsMun.setVDif("0.00");
458+
gIbsMun.setVDif(ObjetoUtil.getValor2Casas(mapTotais.getOrDefault(TOTAL_DIFERIMENTO_IBS_MUN, BigDecimal.ZERO)));
409459
gIbsMun.setVDevTrib("0.00");
410460
gIbsMun.setVIBSMun(ObjetoUtil.getValor2Casas(mapTotais.getOrDefault(TOTAL_IBS_MUN, BigDecimal.ZERO)));
411461
return gIbsMun;
412462
}
413463

414464
private TIBSCBSMonoTot.GCBS criarTotaisCBS() {
415465
TIBSCBSMonoTot.GCBS gCbs = new TIBSCBSMonoTot.GCBS();
416-
gCbs.setVDif("0.00");
466+
gCbs.setVDif(ObjetoUtil.getValor2Casas(mapTotais.getOrDefault(TOTAL_DIFERIMENTO_CBS, BigDecimal.ZERO)));
417467
gCbs.setVDevTrib("0.00");
418468
gCbs.setVCBS(ObjetoUtil.getValor2Casas(mapTotais.getOrDefault(TOTAL_CBS, BigDecimal.ZERO)));
419469
gCbs.setVCredPres("0.00");

src/main/java/br/com/swconsultoria/nfe/util/ObjetoUtil.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,14 @@ public static BigDecimal getOrZero(BigDecimal v) {
4040
}
4141

4242
public static String getValor2Casas(BigDecimal valor) {
43+
if (valor == null || valor.compareTo(BigDecimal.ZERO) < 0) {
44+
return "0.00";
45+
}
4346
return valor.setScale(2, RoundingMode.HALF_UP).toString();
4447
}
4548

4649
public static String getValor4Casas(BigDecimal valor) {
47-
if (valor == null) {
50+
if (valor == null || valor.compareTo(BigDecimal.ZERO) < 0) {
4851
return "0.0000";
4952
}
5053
return valor.setScale(4, RoundingMode.HALF_UP).toString();
225 Bytes
Binary file not shown.

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<property name="ireport.zoom" value="2.0"/>
55
<property name="ireport.x" value="322"/>
66
<property name="ireport.y" value="160"/>
7-
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="NF-e"/>
7+
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="DataAdapter.jrdax"/>
88
<style name="campoPequeno" hTextAlign="Left" hImageAlign="Left" vTextAlign="Top" vImageAlign="Top" markup="styled" pattern="" fontName="Verdana" fontSize="4" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" isPdfEmbedded="false"/>
99
<style name="borda" mode="Transparent" forecolor="#000000" fill="Solid" radius="3" scaleImage="Clip" hTextAlign="Left" hImageAlign="Left" vTextAlign="Top" vImageAlign="Top" markup="none" pattern="" fontName="Verdana" fontSize="5" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="true" isPdfEmbedded="false">
1010
<pen lineWidth="0.25"/>
@@ -294,6 +294,9 @@
294294
<property name="net.sf.jasperreports.xpath.field.expression" value="infAdProd"/>
295295
<fieldDescription><![CDATA[infAdProd]]></fieldDescription>
296296
</field>
297+
<field name="Informacoes_fisco" class="java.lang.String">
298+
<fieldDescription><![CDATA[../infAdic/infAdFisco]]></fieldDescription>
299+
</field>
297300
<variable name="count_itens" class="java.lang.Integer" resetType="None" incrementType="Report" calculation="Count">
298301
<variableExpression><![CDATA[$V{REPORT_COUNT}]]></variableExpression>
299302
<initialValueExpression><![CDATA[1]]></initialValueExpression>
@@ -998,7 +1001,8 @@ $F{Trans_CPF}.substring(9,11) : ""]]></textFieldExpression>
9981001
<textElement verticalAlignment="Top">
9991002
<font size="6" isItalic="false"/>
10001003
</textElement>
1001-
<textFieldExpression><![CDATA[$F{Informacoes}.replace(" ","").replace("\n"," ")]]></textFieldExpression>
1004+
<textFieldExpression><![CDATA["Inf. Contribuinte:"+$F{Informacoes}.replace(" ","").replace("\n"," ")+
1005+
"\nInf. Fisco:"+$F{Informacoes_fisco}.replace(" ","").replace("\n"," ")]]></textFieldExpression>
10021006
</textField>
10031007
<frame>
10041008
<reportElement positionType="FixRelativeToBottom" stretchType="ContainerBottom" mode="Transparent" x="0" y="0" width="565" height="34" isPrintWhenDetailOverflows="true" uuid="91c422c4-c8b1-42ed-accb-e694dbf89daa">
@@ -1064,7 +1068,6 @@ $F{Trans_CPF}.substring(9,11) : ""]]></textFieldExpression>
10641068
<textElement verticalAlignment="Top">
10651069
<font size="6" isItalic="false"/>
10661070
</textElement>
1067-
<textFieldExpression><![CDATA[$F{infAdFisco}.replace(" ","").replace("\n"," ")]]></textFieldExpression>
10681071
</textField>
10691072
</frame>
10701073
</band>

0 commit comments

Comments
 (0)