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

wmixvideo / nfe / #6284

02 Jun 2016 11:49PM UTC coverage: 79.364% (-0.4%) from 79.804%
#6284

push

travis-ci

fincatto
Atualizado xsd de validacao de envio de lote, que valida as notas com assinatura.
Atualizado para versão 2.0.0-SNAPSHOT, pois o codigo quebrou a compatibilidade.

0 of 1 new or added line in 1 file covered. (0.0%)

338 existing lines in 67 files now uncovered.

4742 of 5975 relevant lines covered (79.36%)

50.29 hits per line

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

94.44
/src/main/java/com/fincatto/nfe310/parsers/NotaFiscalChaveParser.java
1
package com.fincatto.nfe310.parsers;
2

3
import java.util.Date;
4
import java.util.GregorianCalendar;
5

6
import com.fincatto.nfe310.classes.NFModelo;
7
import com.fincatto.nfe310.classes.NFTipoEmissao;
8
import com.fincatto.nfe310.classes.NFUnidadeFederativa;
9

10
public class NotaFiscalChaveParser {
11
    private final String chave;
12

13
    public NotaFiscalChaveParser(final String chave) {
16✔
14
        if (chave == null || chave.replaceAll("\\D", "").length() != 44) {
16✔
15
            throw new IllegalArgumentException(String.format("A chave deve ter exatos 44 caracteres numericos: %s", chave));
3✔
16
        }
17
        this.chave = chave.replaceAll("\\D", "");
13✔
18
    }
13✔
19

20
    public NFUnidadeFederativa getNFUnidadeFederativa() {
21
        return NFUnidadeFederativa.valueOfCodigo(this.chave.substring(0, 2));
2✔
22
    }
23

24
    public Date getDataEmissao() {
25
        return new GregorianCalendar(this.getDataEmissaoAno(), this.getDataEmissaoMes(), 1).getTime();
1✔
26
    }
27

28
    private int getDataEmissaoMes() {
29
        return Integer.parseInt(this.chave.substring(4, 6)) - 1;
1✔
30
    }
31

32
    private int getDataEmissaoAno() {
33
        return 2000 + Integer.parseInt(this.chave.substring(2, 4));
1✔
34
    }
35

36
    public String getCnpjEmitente() {
37
        return this.chave.substring(6, 20);
1✔
38
    }
39
    
40
    public NFModelo getModelo() {
UNCOV
41
            return NFModelo.valueOfCodigo(this.chave.substring(20, 22));
×
42
    }
43

44
    public String getSerie() {
45
        return this.chave.substring(22, 25);
5✔
46
    }
47

48
    public String getNumero() {
49
        return this.chave.substring(25, 34);
1✔
50
    }
51

52
    public NFTipoEmissao getFormaEmissao() {
53
        return NFTipoEmissao.valueOfCodigo(this.chave.substring(34, 35));
1✔
54
    }
55

56
    public String getCodigoNumerico() {
57
        return this.chave.substring(35, 43);
1✔
58
    }
59

60
    public String getDV() {
61
        return this.chave.substring(43, 44);
1✔
62
    }
63

64
    public boolean isEmitidaContingenciaSCAN() {
65
        return this.getSerie().matches("9[0-9]{2}");
4✔
66
    }
67

68
    public String getFormatado() {
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");
1✔
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

© 2025 Coveralls, Inc