• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

wmixvideo / nfe / #9463

23 Jul 2025 01:31AM UTC coverage: 51.794% (+0.8%) from 50.977%
#9463

push

web-flow
Merge e37a5245a into cb8c6ab74

122 of 122 new or added lines in 1 file covered. (100.0%)

1090 existing lines in 75 files now uncovered.

14360 of 27725 relevant lines covered (51.79%)

0.52 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/main/java/com/fincatto/documentofiscal/cte400/parsers/CTChaveParser.java
1
package com.fincatto.documentofiscal.cte400.parsers;
2

3
import com.fincatto.documentofiscal.DFModelo;
4
import com.fincatto.documentofiscal.DFUnidadeFederativa;
5
import com.fincatto.documentofiscal.cte.CTTipoEmissao;
6
import org.apache.commons.lang3.StringUtils;
7

8
import java.time.LocalDate;
9

10
public class CTChaveParser {
11

12
    private final String chave;
13

UNCOV
14
    public CTChaveParser(final String chave) {
×
UNCOV
15
        this.chave = StringUtils.stripToEmpty(chave).replaceAll("\\D", "");
×
UNCOV
16
        if (this.chave.length() != 44) {
×
UNCOV
17
            throw new IllegalArgumentException(String.format("A chave deve ter exatos 44 caracteres numericos: %s", chave));
×
18
        }
UNCOV
19
    }
×
20

21
    public String getChave() {
UNCOV
22
        return chave;
×
23
    }
24

25
    public DFUnidadeFederativa getNFUnidadeFederativa() {
UNCOV
26
        return DFUnidadeFederativa.valueOfCodigo(this.chave.substring(0, 2));
×
27
    }
28

29
    public LocalDate getDataEmissao() {
UNCOV
30
        return LocalDate.of(this.getDataEmissaoAno(), this.getDataEmissaoMes(), 1);
×
31
    }
32

33
    private int getDataEmissaoMes() {
UNCOV
34
        return Integer.parseInt(this.chave.substring(4, 6));
×
35
    }
36

37
    private int getDataEmissaoAno() {
UNCOV
38
        return 2000 + Integer.parseInt(this.chave.substring(2, 4));
×
39
    }
40

41
    public String getCnpjEmitente() {
UNCOV
42
        return this.chave.substring(6, 20);
×
43
    }
44

45
    public DFModelo getModelo() {
UNCOV
46
        return DFModelo.valueOfCodigo(this.chave.substring(20, 22));
×
47
    }
48

49
    public String getSerie() {
UNCOV
50
        return this.chave.substring(22, 25);
×
51
    }
52

53
    public String getNumero() {
UNCOV
54
        return this.chave.substring(25, 34);
×
55
    }
56

57
    public CTTipoEmissao getFormaEmissao() {
UNCOV
58
        return CTTipoEmissao.valueOfCodigo(this.chave.substring(34, 35));
×
59
    }
60

61
    public String getCodigoNumerico() {
UNCOV
62
        return this.chave.substring(35, 43);
×
63
    }
64

65
    public String getDV() {
UNCOV
66
        return this.chave.substring(43, 44);
×
67
    }
68

69
    public boolean isEmitidaContingenciaSCVSP() {
UNCOV
70
        return getFormaEmissao() == CTTipoEmissao.CONTINGENCIA_SVCSP;
×
71
    }
72

73
    public boolean isEmitidaContingenciaSCVRS() {
UNCOV
74
        return getFormaEmissao() == CTTipoEmissao.CONTINGENCIA_SVCRS;
×
75
    }
76

77
    public String getFormatado() {
UNCOV
78
        return this.chave.replaceFirst("(\\d{4})(\\d{4})(\\d{4})(\\d{4})(\\d{4})(\\d{4})(\\d{4})(\\d{4})(\\d{4})(\\d{4})(\\d{4})", "$1 $2 $3 $4 $5 $6 $7 $8 $9 $10 $11");
×
79
    }
80
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc