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

wmixvideo / nfe / #9047

24 Jun 2025 01:09AM UTC coverage: 50.719% (+0.3%) from 50.407%
#9047

push

web-flow
Merge 0ce3effce into bb9f583b3

14005 of 27613 relevant lines covered (50.72%)

0.51 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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

77
    public String getFormatado() {
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 · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc