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

wmixvideo / nfe / #7320

24 Jun 2025 02:03AM UTC coverage: 51.463% (+1.1%) from 50.377%
#7320

push

web-flow
Merge 80a657e41 into bb9f583b3

14 of 20 new or added lines in 1 file covered. (70.0%)

812 existing lines in 45 files now uncovered.

14018 of 27239 relevant lines covered (51.46%)

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/mdfe3/classes/parsers/MDFChaveParser.java
1
package com.fincatto.documentofiscal.mdfe3.classes.parsers;
2

3
import com.fincatto.documentofiscal.DFModelo;
4
import com.fincatto.documentofiscal.DFUnidadeFederativa;
5
import com.fincatto.documentofiscal.mdfe3.classes.def.MDFTipoEmissao;
6
import org.apache.commons.lang3.StringUtils;
7
import java.time.LocalDate;
8

9
public class MDFChaveParser {
10

11
    private final String chave;
12

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

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

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

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

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

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

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

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

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

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

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

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

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

68
    public String getFormatado() {
UNCOV
69
        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");
×
70
    }
71
}
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