Skip to content

Commit

Permalink
Corrigido verificacao de qtd de notas por lote.
Browse files Browse the repository at this point in the history
  • Loading branch information
fincatto committed Apr 29, 2016
1 parent 0bf6a2a commit 63c6e2f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/main/java/com/fincatto/nfe310/webservices/WSLoteEnvio.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,23 +56,25 @@ public NFLoteEnvioRetorno enviaLote(final NFLoteEnvio lote) throws Exception {
final NFLoteEnvio loteAssinado = new NotaParser().loteParaObjeto(documentoAssinado);

//verifica se nao tem NFCe junto com NFe no lote e gera qrcode (apos assinar mesmo, eh assim)
int countNFCe = 0;
int qtdNF = 0, qtdNFC = 0;
for (final NFNota nota : loteAssinado.getNotas()) {
if (NFModelo.NFCE.equals(nota.getInfo().getIdentificacao().getModelo())) {
final NFGeraQRCode geraQRCode = new NFGeraQRCode(nota, this.config);
nota.setInfoSuplementar(new NFNotaInfoSuplementar());
nota.getInfoSuplementar().setQrCode(geraQRCode.getQRCode());
countNFCe++;
qtdNFC++;
} else {
qtdNF++;
}
}

//verifica se todas as notas do lote sao do mesmo modelo
if (countNFCe != loteAssinado.getNotas().size()) {
if ((qtdNF > 0) && (qtdNFC > 0)) {
throw new IllegalArgumentException("Lote contendo notas de modelos diferentes!");
}

//guarda o modelo das notas
final NFModelo modelo = countNFCe > 0 ? NFModelo.NFCE : NFModelo.NFE;
final NFModelo modelo = qtdNFC > 0 ? NFModelo.NFCE : NFModelo.NFE;

//comunica o lote
final String xml = loteAssinado.toString();
Expand Down

0 comments on commit 63c6e2f

Please sign in to comment.