Rev 546 | Details | Compare with Previous | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 259 | espaco | 1 | package br.com.ec.domain.model; |
| 2 | |||
| 3 | import java.io.ByteArrayInputStream; |
||
| 4 | import java.io.ByteArrayOutputStream; |
||
| 5 | import java.io.IOException; |
||
| 6 | import java.io.Serializable; |
||
| 7 | import java.io.StringReader; |
||
| 8 | import java.util.Date; |
||
| 9 | import java.util.List; |
||
| 10 | |||
| 11 | import javax.persistence.Column; |
||
| 12 | import javax.persistence.Entity; |
||
| 13 | import javax.persistence.GeneratedValue; |
||
| 14 | import javax.persistence.GenerationType; |
||
| 15 | import javax.persistence.Id; |
||
| 16 | import javax.persistence.JoinColumn; |
||
| 17 | import javax.persistence.ManyToOne; |
||
| 474 | blopes | 18 | import javax.persistence.OneToOne; |
| 259 | espaco | 19 | import javax.persistence.SequenceGenerator; |
| 20 | import javax.persistence.Table; |
||
| 21 | import javax.persistence.Transient; |
||
| 22 | import javax.validation.constraints.NotNull; |
||
| 23 | import javax.validation.constraints.Size; |
||
| 24 | import javax.xml.bind.JAXBContext; |
||
| 25 | import javax.xml.bind.JAXBException; |
||
| 26 | import javax.xml.bind.Unmarshaller; |
||
| 27 | import javax.xml.parsers.DocumentBuilder; |
||
| 28 | import javax.xml.parsers.DocumentBuilderFactory; |
||
| 29 | import javax.xml.transform.Transformer; |
||
| 30 | import javax.xml.transform.TransformerFactory; |
||
| 31 | import javax.xml.transform.dom.DOMSource; |
||
| 32 | import javax.xml.transform.stream.StreamResult; |
||
| 33 | import javax.xml.transform.stream.StreamSource; |
||
| 34 | |||
| 35 | import org.apache.commons.io.IOUtils; |
||
| 36 | import org.hibernate.annotations.ForeignKey; |
||
| 37 | import org.primefaces.model.DefaultStreamedContent; |
||
| 38 | import org.w3c.dom.Document; |
||
| 39 | |||
| 40 | import br.com.ec.core.exception.NegocioException; |
||
| 41 | import br.com.ec.core.generic.identidade.Identidade; |
||
| 42 | import br.com.ec.core.interfaces.Alterar; |
||
| 43 | import br.com.ec.core.interfaces.Cadastrar; |
||
| 548 | blopes | 44 | import br.com.ec.core.util.DataUtils; |
| 259 | espaco | 45 | import br.com.ec.core.util.StringUtil; |
| 46 | import br.com.ec.core.util.VerificadorUtil; |
||
| 449 | blopes | 47 | import br.com.ec.domain.dto.NotaFiscalProdutoDTO; |
| 259 | espaco | 48 | import br.com.ec.domain.model.nfe.TipoModeloNotaFiscal; |
| 49 | import br.com.ec.domain.model.nfe.TipoNotaFiscal; |
||
| 492 | blopes | 50 | import br.com.ec.domain.model.nfe.TipoNotaFiscalConsumidorFinal; |
| 489 | blopes | 51 | import br.com.ec.domain.model.nfe.TipoNotaFiscalDestino; |
| 492 | blopes | 52 | import br.com.ec.domain.model.nfe.TipoNotaFiscalFinalidadeOperacao; |
| 489 | blopes | 53 | import br.com.ec.domain.model.nfe.TipoNotaFiscalIntermediario; |
| 259 | espaco | 54 | import br.com.ec.domain.model.nfe.TipoNotaFiscalNaturezaOperacao; |
| 55 | import br.com.ec.domain.model.nfe.TipoNotaFiscalPresencaComprador; |
||
| 56 | import br.com.ec.domain.model.nfe.TipoNotaFiscalStatusRetorno; |
||
| 492 | blopes | 57 | import br.com.ec.domain.shared.ConstantesSEC; |
| 259 | espaco | 58 | import br.com.ec.relatorio.util.RelatorioUtils; |
| 59 | import br.com.ec.web.util.DataUtil; |
||
| 492 | blopes | 60 | import nfce.TNfeProc; |
| 61 | import nfe.util.ConstantesUtil; |
||
| 259 | espaco | 62 | |
| 63 | @Entity |
||
| 64 | @Table(name="sec_nota_fiscal", schema="sc_sec") |
||
| 65 | public class NotaFiscal implements Serializable, Identidade { |
||
| 66 | |||
| 67 | private static final long serialVersionUID = 1L; |
||
| 68 | |||
| 69 | private Long sequencial; |
||
| 492 | blopes | 70 | private String codigoNotaFiscal; |
| 259 | espaco | 71 | private String tipoModeloNotaFiscal; |
| 72 | private String serie; |
||
| 73 | private Long numeroNotaFiscal; |
||
| 74 | private Date dataHoraEmissao; |
||
| 75 | |||
| 76 | private String chave; |
||
| 77 | |||
| 492 | blopes | 78 | private String tipoNotaFiscalConsumidorFinal; |
| 79 | private String tipoNotaFiscalNaturezaOperacao; |
||
| 80 | private String tipoNotaFiscalPresencaComprador; |
||
| 81 | private String tipoNotaFiscalIntermediario; |
||
| 82 | private String tipoNotaFiscalDestino; |
||
| 83 | private String tipoNotaFiscalFinalidade; |
||
| 259 | espaco | 84 | |
| 85 | private Venda venda; |
||
| 86 | private Pessoa pessoaEmitente; |
||
| 87 | private Pessoa pessoaDestinatario; |
||
| 88 | private String observacaoVenda; |
||
| 474 | blopes | 89 | |
| 259 | espaco | 90 | private String descricaoComplementares; |
| 91 | |||
| 92 | private String textoXml; |
||
| 93 | private String tipoNotaFiscal; |
||
| 94 | |||
| 95 | private String protocoloAutorizacao; |
||
| 96 | private String caminhoQrcode; |
||
| 97 | |||
| 98 | private String statusRetorno; |
||
| 99 | private String motivoRetorno; |
||
| 100 | private Date dataHoraEvento; |
||
| 101 | private String textoXmlEvento; |
||
| 102 | |||
| 492 | blopes | 103 | private String statusRetornoUltimo; |
| 104 | private String motivoRetornoUltimo; |
||
| 105 | private Date dataHoraEventoUltimo; |
||
| 106 | private String textoXmlEventoUltimo; |
||
| 107 | |||
| 474 | blopes | 108 | private Double valorFrete; |
| 109 | private Double valorSeguro; |
||
| 110 | private Double valorDesconto; |
||
| 111 | private Double outrasDespesas; |
||
| 112 | |||
| 113 | private Transporte transporte; |
||
| 114 | |||
| 259 | espaco | 115 | private byte[] arquivoXml; |
| 116 | |||
| 117 | // private List<Parcela> listaParcelas; |
||
| 118 | // private List<CompraProduto> listaCompraProduto; |
||
| 119 | private List<Lancamento> listaLancamento; |
||
| 120 | private List<VendaFormaPagamento> listaFormaPagamento; |
||
| 121 | |||
| 449 | blopes | 122 | private List<NotaFiscalProdutoDTO> listaProdutosVinculadosDTO; |
| 123 | |||
| 259 | espaco | 124 | private Boolean notaFiscalPendente; |
| 492 | blopes | 125 | private String versaoEmissor; |
| 126 | private String tipoImpressao; |
||
| 259 | espaco | 127 | |
| 414 | espaco | 128 | public NotaFiscal() {} |
| 129 | |||
| 130 | public NotaFiscal(Long sequencial) { |
||
| 131 | this.sequencial = sequencial; |
||
| 132 | } |
||
| 133 | |||
| 259 | espaco | 134 | @Override |
| 135 | @Transient |
||
| 136 | public Object getId() { |
||
| 137 | return this.getSequencial(); |
||
| 138 | } |
||
| 139 | @Override |
||
| 140 | public void setId(Object id) { |
||
| 141 | this.sequencial = (Long) id; |
||
| 142 | } |
||
| 143 | |||
| 144 | @Id |
||
| 145 | @SequenceGenerator(name = "sq_notafiscal") |
||
| 146 | @GeneratedValue(strategy = GenerationType.IDENTITY) |
||
| 147 | @Column(name="seq_nota_fiscal", nullable=false) |
||
| 148 | public Long getSequencial() { |
||
| 149 | return sequencial; |
||
| 150 | } |
||
| 151 | public void setSequencial(Long sequencial) { |
||
| 152 | this.sequencial = sequencial; |
||
| 153 | } |
||
| 154 | |||
| 492 | blopes | 155 | @Column(name="cod_notafiscal") |
| 156 | public String getCodigoNotaFiscal() { |
||
| 157 | return codigoNotaFiscal; |
||
| 158 | } |
||
| 159 | public void setCodigoNotaFiscal(String codigoNotaFiscal) { |
||
| 160 | this.codigoNotaFiscal = codigoNotaFiscal; |
||
| 161 | } |
||
| 162 | |||
| 259 | espaco | 163 | @Column(name="dsc_serie") |
| 164 | public String getSerie() { |
||
| 165 | return serie; |
||
| 166 | } |
||
| 167 | public void setSerie(String serie) { |
||
| 168 | this.serie = serie; |
||
| 169 | } |
||
| 170 | |||
| 171 | @Column(name="num_nota_fiscal", nullable=false) |
||
| 172 | public Long getNumeroNotaFiscal() { |
||
| 173 | return numeroNotaFiscal; |
||
| 174 | } |
||
| 175 | public void setNumeroNotaFiscal(Long numeroNotaFiscal) { |
||
| 176 | this.numeroNotaFiscal = numeroNotaFiscal; |
||
| 177 | } |
||
| 178 | |||
| 179 | @Column(name="cod_nota_fiscal") |
||
| 180 | public String getChave() { |
||
| 181 | return chave; |
||
| 182 | } |
||
| 183 | public void setChave(String chave) { |
||
| 184 | this.chave = chave; |
||
| 185 | } |
||
| 186 | |||
| 492 | blopes | 187 | @Column(name="tip_consumidorfinal") |
| 188 | public String getTipoNotaFiscalConsumidorFinal() { |
||
| 189 | return tipoNotaFiscalConsumidorFinal; |
||
| 190 | } |
||
| 191 | public void setTipoNotaFiscalConsumidorFinal(String tipoNotaFiscalConsumidorFinal) { |
||
| 192 | this.tipoNotaFiscalConsumidorFinal = tipoNotaFiscalConsumidorFinal; |
||
| 193 | } |
||
| 259 | espaco | 194 | @Transient |
| 492 | blopes | 195 | public String descricaoTipoNotaFiscalConsumidorFinal() { |
| 196 | return VerificadorUtil.naoEstaNuloOuVazio(getTipoNotaFiscalConsumidorFinal())? TipoNotaFiscalConsumidorFinal.parse(getTipoNotaFiscalConsumidorFinal()).getDescricao() : null; |
||
| 197 | } |
||
| 198 | |||
| 199 | @Column(name="tip_naturezaoperacao") |
||
| 259 | espaco | 200 | public String getTipoNotaFiscalNaturezaOperacao() { |
| 201 | return tipoNotaFiscalNaturezaOperacao; |
||
| 202 | } |
||
| 203 | public void setTipoNotaFiscalNaturezaOperacao(String tipoNotaFiscalNaturezaOperacao) { |
||
| 204 | this.tipoNotaFiscalNaturezaOperacao = tipoNotaFiscalNaturezaOperacao; |
||
| 205 | } |
||
| 206 | @Transient |
||
| 207 | public String descricaoTipoNotaFiscalNaturezaOperacao() { |
||
| 208 | return VerificadorUtil.naoEstaNuloOuVazio(getTipoNotaFiscalNaturezaOperacao())? TipoNotaFiscalNaturezaOperacao.parse(getTipoNotaFiscalNaturezaOperacao()).getDescricao() : null; |
||
| 209 | } |
||
| 210 | |||
| 492 | blopes | 211 | @Column(name="tip_presencacomprador") |
| 259 | espaco | 212 | public String getTipoNotaFiscalPresencaComprador() { |
| 213 | return tipoNotaFiscalPresencaComprador; |
||
| 214 | } |
||
| 215 | public void setTipoNotaFiscalPresencaComprador(String tipoNotaFiscalPresencaComprador) { |
||
| 216 | this.tipoNotaFiscalPresencaComprador = tipoNotaFiscalPresencaComprador; |
||
| 217 | } |
||
| 218 | @Transient |
||
| 219 | public String descricaoTipoNotaFiscalPresencaComprador() { |
||
| 220 | return VerificadorUtil.naoEstaNuloOuVazio(getTipoNotaFiscalPresencaComprador())? TipoNotaFiscalPresencaComprador.parse(getTipoNotaFiscalPresencaComprador()).getDescricao() : null; |
||
| 221 | } |
||
| 222 | |||
| 492 | blopes | 223 | @Column(name="tip_intermediario") |
| 489 | blopes | 224 | public String getTipoNotaFiscalIntermediario() { |
| 225 | return tipoNotaFiscalIntermediario; |
||
| 226 | } |
||
| 227 | public void setTipoNotaFiscalIntermediario(String tipoNotaFiscalIntermediario) { |
||
| 228 | this.tipoNotaFiscalIntermediario = tipoNotaFiscalIntermediario; |
||
| 229 | } |
||
| 230 | @Transient |
||
| 231 | public String descricaoTipoNotaFiscalIntermediario() { |
||
| 232 | return VerificadorUtil.naoEstaNuloOuVazio(getTipoNotaFiscalIntermediario())? TipoNotaFiscalIntermediario.parse(getTipoNotaFiscalIntermediario()).getDescricao() : null; |
||
| 233 | } |
||
| 234 | |||
| 492 | blopes | 235 | @Column(name="tip_destino") |
| 489 | blopes | 236 | public String getTipoNotaFiscalDestino() { |
| 237 | return tipoNotaFiscalDestino; |
||
| 238 | } |
||
| 239 | public void setTipoNotaFiscalDestino(String tipoNotaFiscalDestino) { |
||
| 240 | this.tipoNotaFiscalDestino = tipoNotaFiscalDestino; |
||
| 241 | } |
||
| 242 | @Transient |
||
| 243 | public String descricaoTipoNotaFiscalDestino() { |
||
| 244 | return VerificadorUtil.naoEstaNuloOuVazio(getTipoNotaFiscalDestino())? TipoNotaFiscalDestino.parse(getTipoNotaFiscalDestino()).getDescricao() : null; |
||
| 245 | } |
||
| 246 | |||
| 492 | blopes | 247 | @Column(name="tip_finalidade") |
| 248 | public String getTipoNotaFiscalFinalidade() { |
||
| 249 | return tipoNotaFiscalFinalidade; |
||
| 250 | } |
||
| 251 | public void setTipoNotaFiscalFinalidade(String tipoNotaFiscalFinalidade) { |
||
| 252 | this.tipoNotaFiscalFinalidade = tipoNotaFiscalFinalidade; |
||
| 253 | } |
||
| 254 | @Transient |
||
| 255 | public String descricaoTipoNotaFiscalFinalidade() { |
||
| 256 | return VerificadorUtil.naoEstaNuloOuVazio(getTipoNotaFiscalFinalidade())? TipoNotaFiscalFinalidadeOperacao.parse(getTipoNotaFiscalFinalidade()).getDescricao() : null; |
||
| 257 | } |
||
| 258 | |||
| 259 | espaco | 259 | @ManyToOne |
| 260 | @ForeignKey(name = "fk_notafiscal_venda") |
||
| 261 | @JoinColumn(name="seq_venda", referencedColumnName="seq_venda", insertable=true, updatable=false) |
||
| 262 | public Venda getVenda() { |
||
| 263 | return venda; |
||
| 264 | } |
||
| 265 | public void setVenda(Venda venda) { |
||
| 266 | this.venda = venda; |
||
| 267 | } |
||
| 268 | |||
| 269 | @ManyToOne |
||
| 270 | @ForeignKey(name = "fk_notafiscal_emitente") |
||
| 271 | @JoinColumn(name="seq_pessoa_emitente", referencedColumnName="seq_pessoa", insertable=true, updatable=true) |
||
| 272 | public Pessoa getPessoaEmitente() { |
||
| 273 | return pessoaEmitente; |
||
| 274 | } |
||
| 275 | public void setPessoaEmitente(Pessoa pessoaEmitente) { |
||
| 276 | this.pessoaEmitente = pessoaEmitente; |
||
| 277 | } |
||
| 278 | |||
| 279 | @ManyToOne |
||
| 280 | @ForeignKey(name = "fk_notafiscal_destinatario") |
||
| 281 | @JoinColumn(name="seq_pessoa_destinatario", referencedColumnName="seq_pessoa", insertable=true, updatable=true) |
||
| 282 | public Pessoa getPessoaDestinatario() { |
||
| 283 | return pessoaDestinatario; |
||
| 284 | } |
||
| 285 | public void setPessoaDestinatario(Pessoa pessoaDestinatario) { |
||
| 286 | this.pessoaDestinatario = pessoaDestinatario; |
||
| 287 | } |
||
| 288 | |||
| 289 | @Column(name="dsc_obs_venda") |
||
| 290 | @Size(max = 100, message = "Limite de caracteres ultrapassado: Observação da Venda") |
||
| 291 | public String getObservacaoVenda() { |
||
| 292 | return observacaoVenda; |
||
| 293 | } |
||
| 294 | public void setObservacaoVenda(String observacaoVenda) { |
||
| 492 | blopes | 295 | this.observacaoVenda = StringUtil.setarUpperCaseComTrim(observacaoVenda); |
| 259 | espaco | 296 | } |
| 297 | |||
| 298 | @Column(name="dsc_complementares") |
||
| 299 | @Size(max = 1500, message = "Limite de caracteres ultrapassado: Descrição Complementares") |
||
| 300 | public String getDescricaoComplementares() { |
||
| 301 | return descricaoComplementares; |
||
| 302 | } |
||
| 303 | public void setDescricaoComplementares(String descricaoComplementares) { |
||
| 304 | this.descricaoComplementares = descricaoComplementares; |
||
| 305 | } |
||
| 306 | |||
| 465 | blopes | 307 | @Column(name="dth_emissao") |
| 259 | espaco | 308 | public Date getDataHoraEmissao() { |
| 309 | return dataHoraEmissao; |
||
| 310 | } |
||
| 311 | public void setDataHoraEmissao(Date dataHoraEmissao) { |
||
| 312 | this.dataHoraEmissao = dataHoraEmissao; |
||
| 313 | } |
||
| 314 | |||
| 315 | @Column(name="txt_xml") |
||
| 316 | public String getTextoXml() { |
||
| 317 | return textoXml; |
||
| 318 | } |
||
| 319 | public void setTextoXml(String textoXml) { |
||
| 320 | this.textoXml = textoXml; |
||
| 321 | } |
||
| 322 | |||
| 323 | @Column(name="tip_nota_fiscal", nullable=false) |
||
| 324 | @NotNull(message="Obrigatório informar o tipo da nota fiscal", groups={Cadastrar.class, Alterar.class}) |
||
| 325 | public String getTipoNotaFiscal() { |
||
| 326 | return tipoNotaFiscal; |
||
| 327 | } |
||
| 328 | public void setTipoNotaFiscal(String tipoNotaFiscal) { |
||
| 329 | this.tipoNotaFiscal = tipoNotaFiscal; |
||
| 330 | } |
||
| 331 | @Transient |
||
| 332 | public String getDescricaoDoTipoNotaFiscal() { |
||
| 333 | return VerificadorUtil.naoEstaNuloOuVazio(getTipoNotaFiscal())? TipoNotaFiscal.parse(getTipoNotaFiscal()).getDescricao() : null; |
||
| 334 | } |
||
| 335 | |||
| 336 | @Column(name="tip_modelo_notafiscal", nullable=false) |
||
| 337 | @NotNull(message="Obrigatório informar o tipo do modelo da nota fiscal", groups={Cadastrar.class, Alterar.class}) |
||
| 338 | public String getTipoModeloNotaFiscal() { |
||
| 339 | return tipoModeloNotaFiscal; |
||
| 340 | } |
||
| 341 | public void setTipoModeloNotaFiscal(String tipoModeloNotaFiscal) { |
||
| 342 | this.tipoModeloNotaFiscal = tipoModeloNotaFiscal; |
||
| 343 | } |
||
| 344 | @Transient |
||
| 345 | public String getDescricaoDoTipoModeloNotaFiscal() { |
||
| 346 | return VerificadorUtil.naoEstaNuloOuVazio(getTipoModeloNotaFiscal())? TipoModeloNotaFiscal.parse(getTipoModeloNotaFiscal()).getDescricao() : null; |
||
| 347 | } |
||
| 348 | |||
| 349 | @Column(name="dsc_protocolo_autorizacao") |
||
| 350 | @Size(max = 100, message = "Limite de caracteres ultrapassado: Protocolo da Autorização") |
||
| 351 | public String getProtocoloAutorizacao() { |
||
| 352 | return protocoloAutorizacao; |
||
| 353 | } |
||
| 354 | public void setProtocoloAutorizacao(String protocoloAutorizacao) { |
||
| 355 | this.protocoloAutorizacao = protocoloAutorizacao; |
||
| 356 | } |
||
| 357 | |||
| 358 | @Column(name="dsc_caminho_qrcode") |
||
| 359 | @Size(max = 500, message = "Limite de caracteres ultrapassado: Caminho QRCode") |
||
| 360 | public String getCaminhoQrcode() { |
||
| 361 | return caminhoQrcode; |
||
| 362 | } |
||
| 363 | public void setCaminhoQrcode(String caminhoQrcode) { |
||
| 364 | this.caminhoQrcode = caminhoQrcode; |
||
| 365 | } |
||
| 366 | |||
| 367 | @Column(name="dsc_status_retorno") |
||
| 368 | @Size(max = 100, message = "Limite de caracteres ultrapassado: Status do Retorno") |
||
| 369 | public String getStatusRetorno() { |
||
| 370 | return statusRetorno; |
||
| 371 | } |
||
| 372 | public void setStatusRetorno(String statusRetorno) { |
||
| 373 | this.statusRetorno = statusRetorno; |
||
| 374 | } |
||
| 375 | @Transient |
||
| 376 | public String resultadoStatusRetorno() { |
||
| 377 | TipoNotaFiscalStatusRetorno tipoStatus = TipoNotaFiscalStatusRetorno.parse(new Long(getStatusRetorno())); |
||
| 378 | return VerificadorUtil.naoEstaNulo(tipoStatus)? tipoStatus.getDescricao() : getStatusRetorno(); |
||
| 379 | } |
||
| 380 | |||
| 381 | @Column(name="dsc_motivo_retorno") |
||
| 382 | @Size(max = 100, message = "Limite de caracteres ultrapassado: Motivo do Retorno") |
||
| 383 | public String getMotivoRetorno() { |
||
| 384 | return motivoRetorno; |
||
| 385 | } |
||
| 386 | public void setMotivoRetorno(String motivoRetorno) { |
||
| 387 | this.motivoRetorno = motivoRetorno; |
||
| 388 | } |
||
| 389 | |||
| 390 | @Column(name="dth_evento") |
||
| 391 | public Date getDataHoraEvento() { |
||
| 392 | return dataHoraEvento; |
||
| 393 | } |
||
| 394 | public void setDataHoraEvento(Date dataHoraEvento) { |
||
| 395 | this.dataHoraEvento = dataHoraEvento; |
||
| 396 | } |
||
| 397 | |||
| 398 | @Column(name="txt_xml_evento", nullable=false) |
||
| 399 | public String getTextoXmlEvento() { |
||
| 400 | return textoXmlEvento; |
||
| 401 | } |
||
| 402 | public void setTextoXmlEvento(String textoXmlEvento) { |
||
| 403 | this.textoXmlEvento = textoXmlEvento; |
||
| 404 | } |
||
| 405 | |||
| 492 | blopes | 406 | @Column(name="dsc_status_retorno_ultimo") |
| 407 | @Size(max = 100, message = "Limite de caracteres ultrapassado: Status do Retorno (Último)") |
||
| 408 | public String getStatusRetornoUltimo() { |
||
| 409 | return statusRetornoUltimo; |
||
| 410 | } |
||
| 411 | public void setStatusRetornoUltimo(String statusRetornoUltimo) { |
||
| 412 | this.statusRetornoUltimo = statusRetornoUltimo; |
||
| 413 | } |
||
| 414 | |||
| 415 | @Transient |
||
| 416 | public String resultadoStatusRetornoUltimo() { |
||
| 417 | TipoNotaFiscalStatusRetorno tipoStatus = TipoNotaFiscalStatusRetorno.parse(new Long(getStatusRetornoUltimo())); |
||
| 418 | return VerificadorUtil.naoEstaNulo(tipoStatus)? tipoStatus.getDescricao() : getStatusRetornoUltimo(); |
||
| 419 | } |
||
| 420 | |||
| 421 | @Column(name="dsc_motivo_retorno_ultimo") |
||
| 422 | @Size(max = 100, message = "Limite de caracteres ultrapassado: Motivo do Retorno (Último)") |
||
| 423 | public String getMotivoRetornoUltimo() { |
||
| 424 | return motivoRetornoUltimo; |
||
| 425 | } |
||
| 426 | public void setMotivoRetornoUltimo(String motivoRetornoUltimo) { |
||
| 427 | this.motivoRetornoUltimo = motivoRetornoUltimo; |
||
| 428 | } |
||
| 429 | |||
| 430 | @Column(name="dth_evento_ultimo") |
||
| 431 | public Date getDataHoraEventoUltimo() { |
||
| 432 | return dataHoraEventoUltimo; |
||
| 433 | } |
||
| 434 | public void setDataHoraEventoUltimo(Date dataHoraEventoUltimo) { |
||
| 435 | this.dataHoraEventoUltimo = dataHoraEventoUltimo; |
||
| 436 | } |
||
| 437 | |||
| 438 | @Column(name="txt_xml_evento_ultimo") |
||
| 439 | public String getTextoXmlEventoUltimo() { |
||
| 440 | return textoXmlEventoUltimo; |
||
| 441 | } |
||
| 442 | public void setTextoXmlEventoUltimo(String textoXmlEventoUltimo) { |
||
| 443 | this.textoXmlEventoUltimo = textoXmlEventoUltimo; |
||
| 444 | } |
||
| 445 | |||
| 480 | blopes | 446 | @Column(name="val_frete") |
| 447 | public Double getValorFrete() { |
||
| 448 | return valorFrete; |
||
| 449 | } |
||
| 450 | public void setValorFrete(Double valorFrete) { |
||
| 451 | this.valorFrete = valorFrete; |
||
| 452 | } |
||
| 453 | |||
| 454 | @Column(name="val_seguro") |
||
| 455 | public Double getValorSeguro() { |
||
| 456 | return valorSeguro; |
||
| 457 | } |
||
| 458 | public void setValorSeguro(Double valorSeguro) { |
||
| 459 | this.valorSeguro = valorSeguro; |
||
| 460 | } |
||
| 461 | |||
| 462 | @Column(name="val_desconto") |
||
| 463 | public Double getValorDesconto() { |
||
| 464 | return valorDesconto; |
||
| 465 | } |
||
| 466 | public void setValorDesconto(Double valorDesconto) { |
||
| 467 | this.valorDesconto = valorDesconto; |
||
| 468 | } |
||
| 469 | |||
| 470 | @Column(name="val_outrasdespesas") |
||
| 471 | public Double getOutrasDespesas() { |
||
| 472 | return outrasDespesas; |
||
| 473 | } |
||
| 474 | public void setOutrasDespesas(Double outrasDespesas) { |
||
| 475 | this.outrasDespesas = outrasDespesas; |
||
| 476 | } |
||
| 477 | |||
| 474 | blopes | 478 | @OneToOne |
| 479 | @JoinColumn(name="seq_transporte", referencedColumnName="seq_transporte", insertable=true, updatable=true, nullable=true) |
||
| 480 | public Transporte getTransporte() { |
||
| 481 | return transporte; |
||
| 482 | } |
||
| 483 | public void setTransporte(Transporte transporte) { |
||
| 484 | this.transporte = transporte; |
||
| 485 | } |
||
| 486 | |||
| 487 | /********************************************/ |
||
| 488 | |||
| 259 | espaco | 489 | @Transient |
| 490 | public Boolean temPessoaJuridica() { |
||
| 491 | if (VerificadorUtil.estaNulo(getVenda())) return false; |
||
| 492 | if (VerificadorUtil.estaNulo(getVenda().getLoja())) return false; |
||
| 493 | return VerificadorUtil.naoEstaNulo(getVenda().getLoja().getPessoaJuridica()); |
||
| 494 | } |
||
| 495 | |||
| 496 | @Transient |
||
| 497 | public String getRazaoSocialDaLoja() { |
||
| 498 | return temPessoaJuridica()? getVenda().getLoja().getPessoaJuridica().getRazaoSocial() : ""; |
||
| 499 | } |
||
| 500 | |||
| 501 | @Transient |
||
| 502 | public String getCnpjDaLoja() { |
||
| 503 | return temPessoaJuridica()? StringUtil.formatarCnpj(getVenda().getLoja().getPessoaJuridica().getCpfCnpj()) : ""; |
||
| 504 | } |
||
| 505 | |||
| 506 | @Transient |
||
| 507 | public byte[] getArquivoXml() { |
||
| 508 | return arquivoXml; |
||
| 509 | } |
||
| 510 | public void setArquivoXml(byte[] arquivoXml) { |
||
| 511 | this.arquivoXml = arquivoXml; |
||
| 512 | } |
||
| 513 | |||
| 514 | /* |
||
| 515 | @Transient |
||
| 516 | public List<Parcela> getListaParcelas() { |
||
| 517 | return listaParcelas; |
||
| 518 | } |
||
| 519 | public void setListaParcelas(List<Parcela> listaParcelas) { |
||
| 520 | this.listaParcelas = listaParcelas; |
||
| 521 | } |
||
| 522 | */ |
||
| 523 | |||
| 524 | /* |
||
| 525 | @Transient |
||
| 526 | public List<CompraProduto> getListaCompraProduto() { |
||
| 527 | return listaCompraProduto; |
||
| 528 | } |
||
| 529 | public void setListaCompraProduto(List<CompraProduto> listaCompraProduto) { |
||
| 530 | this.listaCompraProduto = listaCompraProduto; |
||
| 531 | } |
||
| 532 | */ |
||
| 533 | |||
| 534 | @Transient |
||
| 535 | public List<Lancamento> getListaLancamento() { |
||
| 536 | return listaLancamento; |
||
| 537 | } |
||
| 538 | public void setListaLancamento(List<Lancamento> listaLancamento) { |
||
| 539 | this.listaLancamento = listaLancamento; |
||
| 540 | } |
||
| 541 | |||
| 542 | @Transient |
||
| 543 | public List<VendaFormaPagamento> getListaFormaPagamento() { |
||
| 544 | return listaFormaPagamento; |
||
| 545 | } |
||
| 546 | public void setListaFormaPagamento(List<VendaFormaPagamento> listaFormaPagamento) { |
||
| 547 | this.listaFormaPagamento = listaFormaPagamento; |
||
| 548 | } |
||
| 549 | |||
| 449 | blopes | 550 | |
| 551 | // @OneToMany(mappedBy="notaFiscal", cascade=CascadeType.ALL, orphanRemoval=true) |
||
| 259 | espaco | 552 | @Transient |
| 449 | blopes | 553 | public List<NotaFiscalProdutoDTO> getListaProdutosVinculadosDTO() { |
| 554 | return listaProdutosVinculadosDTO; |
||
| 555 | } |
||
| 556 | public void setListaProdutosVinculadosDTO(List<NotaFiscalProdutoDTO> listaProdutosVinculadosDTO) { |
||
| 557 | this.listaProdutosVinculadosDTO = listaProdutosVinculadosDTO; |
||
| 558 | } |
||
| 559 | |||
| 560 | @Transient |
||
| 259 | espaco | 561 | public Boolean getNotaFiscalPendente() { |
| 562 | return notaFiscalPendente; |
||
| 563 | } |
||
| 564 | public void setNotaFiscalPendente(Boolean notaFiscalPendente) { |
||
| 565 | this.notaFiscalPendente = notaFiscalPendente; |
||
| 566 | } |
||
| 567 | |||
| 492 | blopes | 568 | @Transient |
| 569 | public String getVersaoEmissor() { |
||
| 570 | return versaoEmissor; |
||
| 571 | } |
||
| 572 | public void setVersaoEmissor(String versaoEmissor) { |
||
| 573 | this.versaoEmissor = versaoEmissor; |
||
| 574 | } |
||
| 575 | |||
| 576 | @Transient |
||
| 577 | public String getTipoImpressao() { |
||
| 578 | return tipoImpressao; |
||
| 579 | } |
||
| 580 | public void setTipoImpressao(String tipoImpressao) { |
||
| 581 | this.tipoImpressao = tipoImpressao; |
||
| 582 | } |
||
| 583 | |||
| 259 | espaco | 584 | @Override |
| 585 | public int hashCode() { |
||
| 586 | final int prime = 31; |
||
| 587 | int result = 1; |
||
| 588 | result = prime * result + ((chave == null) ? 0 : chave.hashCode()); |
||
| 589 | return result; |
||
| 590 | } |
||
| 591 | |||
| 592 | @Override |
||
| 593 | public boolean equals(Object obj) { |
||
| 594 | if (this == obj) |
||
| 595 | return true; |
||
| 596 | if (obj == null) |
||
| 597 | return false; |
||
| 598 | if (getClass() != obj.getClass()) |
||
| 599 | return false; |
||
| 600 | NotaFiscal other = (NotaFiscal) obj; |
||
| 601 | if (chave == null) { |
||
| 602 | if (other.chave != null) |
||
| 603 | return false; |
||
| 604 | } else if (!chave.equals(other.chave)) |
||
| 605 | return false; |
||
| 606 | return true; |
||
| 607 | } |
||
| 608 | |||
| 609 | @Transient |
||
| 610 | public Double getTotalLancamentos() { |
||
| 611 | Double total = 0.0; |
||
| 612 | if (!VerificadorUtil.isListaNulaOuVazia(getListaLancamento())) { |
||
| 613 | for (Lancamento lancamento : getListaLancamento()) { |
||
| 614 | total = total + lancamento.getValorVenda(); |
||
| 615 | } |
||
| 616 | } |
||
| 617 | return total; |
||
| 618 | } |
||
| 619 | |||
| 620 | @Transient |
||
| 621 | public Double getTotalPago() { |
||
| 622 | Double total = 0.0; |
||
| 623 | if (!VerificadorUtil.isListaNulaOuVazia(getListaFormaPagamento())) { |
||
| 624 | for (VendaFormaPagamento vendaFormaPagamento : getListaFormaPagamento()) { |
||
| 625 | total = total + vendaFormaPagamento.getValorPagamento(); |
||
| 626 | } |
||
| 627 | } |
||
| 628 | return total; |
||
| 629 | } |
||
| 630 | |||
| 631 | @Transient |
||
| 632 | public Double getValorNotaFiscal() { |
||
| 633 | if (VerificadorUtil.naoEstaNuloOuVazio(getTextoXml())) { |
||
| 634 | if (getTextoXml().indexOf("<vNF>") > 0) { |
||
| 635 | String valorLocalizado = getTextoXml().substring(getTextoXml().indexOf("<vNF>"), getTextoXml().indexOf("</vNF>")) |
||
| 636 | .replace("<vNF>", "").replace("</vNF>", ""); |
||
| 637 | return new Double(valorLocalizado); |
||
| 638 | } |
||
| 639 | } |
||
| 640 | return 0.0; |
||
| 641 | } |
||
| 642 | |||
| 643 | @Transient |
||
| 480 | blopes | 644 | public Double getTotalValorProdutosVinculados() { |
| 259 | espaco | 645 | Double total = new Double(0.0); |
| 480 | blopes | 646 | if (VerificadorUtil.naoEstaNuloOuVazio(getListaProdutosVinculadosDTO())) { |
| 647 | for (NotaFiscalProdutoDTO notaFiscalProdutoDTO : getListaProdutosVinculadosDTO()) { |
||
| 485 | blopes | 648 | total = total + (notaFiscalProdutoDTO.getValor() * notaFiscalProdutoDTO.getQuantidade()); |
| 259 | espaco | 649 | } |
| 650 | } |
||
| 651 | return total; |
||
| 652 | } |
||
| 653 | |||
| 480 | blopes | 654 | |
| 259 | espaco | 655 | @Transient |
| 656 | public Boolean ehNotaFiscalDeRemessa() { |
||
| 492 | blopes | 657 | return VerificadorUtil.naoEstaNulo(getTipoNotaFiscal()) ? getTipoNotaFiscal().equals(TipoNotaFiscal.NFE_REMESSA_SAIDA.getValor()) : false; |
| 259 | espaco | 658 | } |
| 659 | |||
| 660 | @Transient |
||
| 541 | blopes | 661 | public Boolean ehNotaFiscalDeDevolucao() { |
| 662 | return VerificadorUtil.naoEstaNulo(getTipoNotaFiscal()) ? getTipoNotaFiscal().equals(TipoNotaFiscal.NFE_DEVOLUCAO.getValor()) : false; |
||
| 663 | } |
||
| 664 | |||
| 665 | @Transient |
||
| 666 | public Boolean ehNotaFiscalDeImportacao() { |
||
| 667 | return VerificadorUtil.naoEstaNulo(getTipoNotaFiscal()) ? getTipoNotaFiscal().equals(TipoNotaFiscal.NFE_IMPORTACAO.getValor()) : false; |
||
| 668 | } |
||
| 669 | |||
| 670 | @Transient |
||
| 259 | espaco | 671 | public byte[] criarArquivoXml() { |
| 672 | ByteArrayInputStream in = null; |
||
| 673 | ByteArrayOutputStream bos = null; |
||
| 674 | try { |
||
| 675 | in = new ByteArrayInputStream(getTextoXml().getBytes()); |
||
| 676 | DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); |
||
| 677 | DocumentBuilder builder = dbf.newDocumentBuilder(); |
||
| 678 | Document xml = builder.parse(in); |
||
| 679 | |||
| 680 | bos = new ByteArrayOutputStream(); |
||
| 681 | TransformerFactory transformerFactory = TransformerFactory.newInstance(); |
||
| 682 | Transformer transformer = transformerFactory.newTransformer(); |
||
| 683 | DOMSource source = new DOMSource(xml); |
||
| 684 | StreamResult result = new StreamResult(bos); |
||
| 685 | transformer.transform(source, result); |
||
| 686 | |||
| 687 | DefaultStreamedContent arquivo = (DefaultStreamedContent) RelatorioUtils.gerarArquivo(bos.toByteArray(), "ArquivoXML", "xml"); |
||
| 688 | return IOUtils.toByteArray(arquivo.getStream()); |
||
| 689 | } catch (Exception e) { |
||
| 690 | e.printStackTrace(); |
||
| 691 | } finally { |
||
| 692 | try { |
||
| 693 | in.close(); |
||
| 694 | bos.close(); |
||
| 695 | } catch (IOException e) { |
||
| 696 | e.printStackTrace(); |
||
| 697 | } |
||
| 698 | } |
||
| 699 | return null; |
||
| 700 | } |
||
| 701 | |||
| 702 | @Transient |
||
| 703 | public byte[] getRetornarArquivoXml() { |
||
| 704 | setArquivoXml(criarArquivoXml()); |
||
| 705 | return getArquivoXml(); |
||
| 706 | } |
||
| 707 | |||
| 708 | @Transient |
||
| 709 | public void gerarChaveAcessoNfe(String codigoUFEmitente, String dataAAMM, String cnpjCpfEmitente, String modeloNf, |
||
| 710 | String serieNF, String tpEmissao, String numeroNF) { |
||
| 711 | try { |
||
| 712 | StringBuilder chave = new StringBuilder(); |
||
| 713 | chave.append(StringUtil.lpadTo(codigoUFEmitente, 2, '0')); |
||
| 714 | chave.append(StringUtil.lpadTo(dataAAMM, 4, '0')); |
||
| 715 | chave.append(StringUtil.lpadTo(cnpjCpfEmitente.replaceAll("\\D",""), 14, '0')); |
||
| 716 | chave.append(StringUtil.lpadTo(modeloNf, 2, '0')); |
||
| 717 | chave.append(StringUtil.lpadTo(serieNF, 3, '0')); |
||
| 718 | chave.append(StringUtil.lpadTo(String.valueOf(numeroNF), 9, '0')); |
||
| 719 | chave.append(StringUtil.lpadTo(tpEmissao, 1, '0')); |
||
| 720 | chave.append(StringUtil.lpadTo(numeroNF, 8, '0')); |
||
| 721 | chave.append(StringUtil.modulo11(chave.toString())); |
||
| 722 | chave.insert(0, "NFe"); |
||
| 723 | setChave(chave.toString()); |
||
| 724 | } catch (Exception e) { |
||
| 725 | System.out.println(e.toString()); |
||
| 726 | throw new NegocioException(e.getMessage()); |
||
| 727 | } |
||
| 728 | } |
||
| 729 | |||
| 730 | @Transient |
||
| 731 | public Long getSequencialDaVenda() { |
||
| 732 | return VerificadorUtil.naoEstaNulo(getVenda())? getVenda().getSequencial() : null; |
||
| 733 | } |
||
| 734 | |||
| 735 | @Transient |
||
| 736 | public void preencherNumeroPelaChave() { |
||
| 737 | if (VerificadorUtil.naoEstaNuloOuVazio(getChave())) { |
||
| 738 | setNumeroNotaFiscal(new Long(getChave().substring(25, 34))); |
||
| 739 | } |
||
| 740 | } |
||
| 741 | |||
| 742 | @Transient |
||
| 743 | public void preencherMotivoPadrao() { |
||
| 744 | setMotivoRetorno("Autorizado o uso da NF-e"); |
||
| 745 | } |
||
| 746 | |||
| 747 | @Transient |
||
| 748 | public void preencherSeriePadrao() { |
||
| 749 | setSerie("1"); |
||
| 750 | } |
||
| 751 | |||
| 752 | @Transient |
||
| 753 | public void preencherStatusPadrao() { |
||
| 754 | setStatusRetorno("100"); |
||
| 755 | } |
||
| 756 | |||
| 757 | @Transient |
||
| 758 | public void preencherQRCodePadrao() { |
||
| 759 | setCaminhoQrcode("http://nfce.sefaz.al.gov.br/QRCode/consultarNFCe.jsp?p=" + getChave() + "|2|1|1|437A52AD9DE9BDD04D6BFF55ED997C5199ECC64D"); |
||
| 760 | } |
||
| 761 | |||
| 762 | @Transient |
||
| 763 | public String retornarCodigoNumerico() { |
||
| 764 | if (VerificadorUtil.naoEstaNuloOuVazio(getChave())) { |
||
| 765 | if (getChave().length() > 42) { |
||
| 766 | return getChave().substring(35, 43); |
||
| 767 | } |
||
| 768 | } |
||
| 769 | return ""; |
||
| 770 | } |
||
| 771 | |||
| 772 | @Transient |
||
| 773 | public void preencherComXML() { |
||
| 774 | if (VerificadorUtil.naoEstaNuloOuVazio(this.getTextoXml())) { |
||
| 775 | TNfeProc tNfeProc = unmarshal(this.getTextoXml()); |
||
| 776 | preencher(tNfeProc); |
||
| 777 | } |
||
| 778 | |||
| 779 | } |
||
| 780 | |||
| 781 | @Transient |
||
| 782 | public void preencher(TNfeProc nfeProc) { |
||
| 783 | if (VerificadorUtil.naoEstaNulo(nfeProc)) { |
||
| 784 | if (VerificadorUtil.naoEstaNulo(nfeProc.getNFe())) { |
||
| 785 | if (VerificadorUtil.naoEstaNulo(nfeProc.getNFe().getInfNFe())) { |
||
| 786 | if (VerificadorUtil.naoEstaNulo(nfeProc.getNFe().getInfNFe().getIde())) { |
||
| 787 | //this.setCodigoNotaFiscal(new Long(nfeProc.getNFe().getInfNFe().getIde().getCNF())); |
||
| 788 | this.setNumeroNotaFiscal(new Long(nfeProc.getNFe().getInfNFe().getIde().getNNF())); |
||
| 789 | this.setSerie(nfeProc.getNFe().getInfNFe().getIde().getSerie()); |
||
| 790 | this.setDataHoraEmissao(DataUtil.retornarDataApartirString("yyyy-MM-dd'T'HH:mm:ss", nfeProc.getNFe().getInfNFe().getIde().getDhEmi())); |
||
| 791 | } |
||
| 792 | if (VerificadorUtil.naoEstaNulo(nfeProc.getNFe().getInfNFe().getInfAdic())) { |
||
| 793 | this.setDescricaoComplementares(nfeProc.getNFe().getInfNFe().getInfAdic().getInfCpl()); |
||
| 794 | } |
||
| 795 | } |
||
| 796 | if (VerificadorUtil.naoEstaNulo(nfeProc.getNFe().getInfNFeSupl())) {} |
||
| 797 | if (VerificadorUtil.naoEstaNulo(nfeProc.getNFe().getSignature())) {} |
||
| 798 | } |
||
| 799 | if (VerificadorUtil.naoEstaNulo(nfeProc.getProtNFe())) { |
||
| 800 | if (VerificadorUtil.naoEstaNulo(nfeProc.getProtNFe().getInfProt())) { |
||
| 801 | this.setChave(nfeProc.getProtNFe().getInfProt().getChNFe()); |
||
| 802 | this.setDataHoraEvento(DataUtil.retornarDataApartirString("yyyy-MM-dd'T'HH:mm:ss", nfeProc.getProtNFe().getInfProt().getDhRecbto())); |
||
| 803 | this.setProtocoloAutorizacao(nfeProc.getProtNFe().getInfProt().getNProt()); |
||
| 804 | this.setStatusRetorno(nfeProc.getProtNFe().getInfProt().getCStat()); |
||
| 805 | this.setMotivoRetorno(nfeProc.getProtNFe().getInfProt().getXMotivo()); |
||
| 806 | } |
||
| 807 | } |
||
| 808 | } |
||
| 809 | } |
||
| 810 | |||
| 811 | @Transient |
||
| 812 | public TNfeProc unmarshal(String stringXml) { |
||
| 813 | JAXBContext context = null; |
||
| 814 | try { |
||
| 815 | context = JAXBContext.newInstance(nfce.TNfeProc.class); |
||
| 816 | Unmarshaller unmarshaller = context.createUnmarshaller(); |
||
| 817 | return (TNfeProc) unmarshaller.unmarshal(new StreamSource(new StringReader(stringXml))); |
||
| 818 | } catch (JAXBException e) { |
||
| 819 | e.printStackTrace(); |
||
| 820 | } |
||
| 821 | return null; |
||
| 822 | } |
||
| 823 | |||
| 492 | blopes | 824 | @Transient |
| 541 | blopes | 825 | public void prepararNotaFiscalConsumidor() { |
| 826 | this.tipoModeloNotaFiscal = TipoModeloNotaFiscal.MODELO_NFCE_65.getValor(); |
||
| 827 | this.versaoEmissor = ConstantesUtil.VERSAO.NFE; |
||
| 828 | this.tipoImpressao = ConstantesSEC.NotaFiscal.TipoImpressao.IMPRESSAO_DANFE_NFCE_4; |
||
| 829 | } |
||
| 830 | |||
| 831 | @Transient |
||
| 832 | public void prepararNotaFiscalEletronica() { |
||
| 833 | this.tipoModeloNotaFiscal = TipoModeloNotaFiscal.MODELO_NFE_55.getValor(); |
||
| 834 | this.versaoEmissor = ConstantesUtil.VERSAO.NFE; |
||
| 835 | this.tipoImpressao = ConstantesSEC.NotaFiscal.TipoImpressao.IMPRESSAO_DANFE_RETRATO_1; |
||
| 836 | this.tipoNotaFiscalFinalidade = TipoNotaFiscalFinalidadeOperacao.NORMAL_1.getValor(); |
||
| 837 | } |
||
| 838 | |||
| 839 | @Transient |
||
| 492 | blopes | 840 | public void prepararNotaFiscalConsumidorVenda() { |
| 541 | blopes | 841 | prepararNotaFiscalConsumidor(); |
| 492 | blopes | 842 | this.tipoNotaFiscal = TipoNotaFiscal.NFCE_SAIDA.getValor(); |
| 843 | this.tipoNotaFiscalNaturezaOperacao = TipoNotaFiscalNaturezaOperacao.VENDA_NFCE_1.getValor(); |
||
| 844 | this.serie = TipoNotaFiscal.NFCE_SAIDA.getSerie(); |
||
| 845 | this.tipoNotaFiscalDestino = TipoNotaFiscalDestino.DESTINO_DENTRO_DO_ESTADO_1.getValor(); |
||
| 846 | this.tipoNotaFiscalConsumidorFinal = TipoNotaFiscalConsumidorFinal.CONSUMIDOR_FINAL_1.getValor(); |
||
| 847 | this.tipoNotaFiscalPresencaComprador = TipoNotaFiscalPresencaComprador.OPERACAO_PRESENCIAL_1.getValor(); |
||
| 848 | this.tipoNotaFiscalIntermediario = TipoNotaFiscalIntermediario.OPERACAO_SEM_INTERMEDIADOR_0.getValor(); |
||
| 849 | this.tipoNotaFiscalFinalidade = TipoNotaFiscalFinalidadeOperacao.NORMAL_1.getValor(); |
||
| 850 | //tpNF 0 - Entrada e 1 - Saída |
||
| 851 | } |
||
| 852 | |||
| 853 | @Transient |
||
| 854 | public void prepararNotaFiscalEletronicaVenda() { |
||
| 541 | blopes | 855 | prepararNotaFiscalEletronica(); |
| 492 | blopes | 856 | this.tipoNotaFiscal = TipoNotaFiscal.NFE_SAIDA.getValor(); |
| 857 | this.tipoNotaFiscalNaturezaOperacao = TipoNotaFiscalNaturezaOperacao.VENDA_NFE_2.getValor(); |
||
| 858 | this.serie = TipoNotaFiscal.NFE_SAIDA.getSerie(); |
||
| 859 | } |
||
| 860 | |||
| 861 | @Transient |
||
| 862 | public void prepararNotaFiscalEletronicaRemessa() { |
||
| 541 | blopes | 863 | prepararNotaFiscalEletronica(); |
| 492 | blopes | 864 | this.tipoNotaFiscal = TipoNotaFiscal.NFE_REMESSA_SAIDA.getValor(); |
| 541 | blopes | 865 | this.tipoNotaFiscalNaturezaOperacao = TipoNotaFiscalNaturezaOperacao.REMESSA_4.getValor(); |
| 492 | blopes | 866 | this.serie = TipoNotaFiscal.NFE_REMESSA_SAIDA.getSerie(); |
| 867 | this.tipoNotaFiscalIntermediario = TipoNotaFiscalIntermediario.OPERACAO_SEM_INTERMEDIADOR_0.getValor(); |
||
| 541 | blopes | 868 | } |
| 869 | |||
| 870 | @Transient |
||
| 871 | public void prepararNotaFiscalEletronicaDevolucao() { |
||
| 872 | prepararNotaFiscalEletronica(); |
||
| 873 | this.tipoNotaFiscal = TipoNotaFiscal.NFE_DEVOLUCAO.getValor(); |
||
| 546 | blopes | 874 | this.tipoNotaFiscalNaturezaOperacao = TipoNotaFiscalNaturezaOperacao.DEVOLUCAO_9.getValor(); |
| 541 | blopes | 875 | this.serie = TipoNotaFiscal.NFE_DEVOLUCAO.getSerie(); |
| 876 | this.tipoNotaFiscalIntermediario = TipoNotaFiscalIntermediario.OPERACAO_SEM_INTERMEDIADOR_0.getValor(); |
||
| 537 | blopes | 877 | this.tipoNotaFiscalFinalidade = TipoNotaFiscalFinalidadeOperacao.DEVOLUCAO_4.getValor(); |
| 492 | blopes | 878 | } |
| 541 | blopes | 879 | |
| 880 | @Transient |
||
| 881 | public void prepararNotaFiscalEletronicaImportacao() { |
||
| 882 | prepararNotaFiscalEletronica(); |
||
| 883 | this.tipoNotaFiscal = TipoNotaFiscal.NFE_IMPORTACAO.getValor(); |
||
| 884 | this.tipoNotaFiscalNaturezaOperacao = TipoNotaFiscalNaturezaOperacao.IMPORTACAO_3102_10.getValor(); |
||
| 885 | this.serie = TipoNotaFiscal.NFE_IMPORTACAO.getSerie(); |
||
| 886 | this.tipoNotaFiscalIntermediario = TipoNotaFiscalIntermediario.OPERACAO_SEM_INTERMEDIADOR_0.getValor(); |
||
| 887 | } |
||
| 548 | blopes | 888 | |
| 889 | @Transient |
||
| 890 | public String montarDadosDaNotaFiscal() { |
||
| 891 | StringBuilder conteudo = new StringBuilder(); |
||
| 892 | conteudo.append("NOTA FISCAL: " + this.getNumeroNotaFiscal() + "\n"); |
||
| 893 | conteudo.append("CHAVE: " + this.getChave() + "\n"); |
||
| 894 | conteudo.append("TIPO: " + this.getDescricaoDoTipoNotaFiscal() + "\n"); |
||
| 895 | // conteudo.append("" + "\n"); |
||
| 896 | conteudo.append("" + "\n"); |
||
| 897 | return conteudo.toString(); |
||
| 898 | } |
||
| 492 | blopes | 899 | |
| 548 | blopes | 900 | /* |
| 901 | public String montarDadosDaVenda(List<Lancamento> lancamentos, List<VendaFormaPagamento> pagamentos) { |
||
| 902 | StringBuilder conteudo = new StringBuilder(); |
||
| 903 | //conteudo.append("OPERAÇÃO REALIZADA POR: " + this.getUsuario().getNome() + "\n"); |
||
| 904 | conteudo.append("VENDA ID: " + this.getSequencial() + "\n"); |
||
| 905 | conteudo.append("DATA: " + DataUtils.converterDataComHorarioParaString(this.getDataVenda()) + "\n"); |
||
| 906 | conteudo.append("LOJA: " + this.getLoja().getDescricao() + "\n"); |
||
| 907 | conteudo.append("VENDEDOR: " + this.getVendedor().getNomeDaPessoa() + "\n"); |
||
| 908 | conteudo.append("TOTAL: " + valorTotalVenda(lancamentos) + "\n"); |
||
| 909 | conteudo.append("OBS.: " + this.getObservacao() + "\n"); |
||
| 910 | if (VerificadorUtil.naoEstaNuloOuVazio(this.getJustificativaParaExcluir())) { |
||
| 911 | conteudo.append("JUSTIFICATIVA: " + this.getJustificativaParaExcluir() + "\n"); |
||
| 912 | } else { |
||
| 913 | conteudo.append("SEM JUSTIFICATIVA\n"); |
||
| 914 | } |
||
| 915 | conteudo.append("__________________________________________________\n\n"); |
||
| 916 | for (Lancamento lancamento : lancamentos) { |
||
| 917 | conteudo.append(lancamento.getProduto().getCodigoProdutoPadrao() + " | "); |
||
| 918 | conteudo.append(lancamento.getProduto().getDescricaoComModeloCompleta() + ", "); |
||
| 919 | conteudo.append("R$" + lancamento.getValorVenda()); |
||
| 920 | if (lancamento.comDescontos()) { |
||
| 921 | conteudo.append(" (COM DESCONTO DE R$" + lancamento.valorDescontos() + ")"); |
||
| 922 | } |
||
| 923 | conteudo.append("\n"); |
||
| 924 | } |
||
| 925 | conteudo.append("__________________________________________________\n\n"); |
||
| 926 | for (VendaFormaPagamento pagamento : pagamentos) { |
||
| 927 | if (VerificadorUtil.naoEstaNulo(pagamento.getBandeiraCartao())) { |
||
| 928 | conteudo.append(pagamento.getFormaPagamento().getDescricao() + " - " + pagamento.getBandeiraCartao().getDescricao() + ": R$" + pagamento.getValorPagamento() + "\n"); |
||
| 929 | } else { |
||
| 930 | conteudo.append(pagamento.getFormaPagamento().getDescricao() + ": R$" + pagamento.getValorPagamento() + "\n"); |
||
| 931 | } |
||
| 932 | conteudo.append("\n"); |
||
| 933 | } |
||
| 934 | return conteudo.toString(); |
||
| 935 | } |
||
| 936 | */ |
||
| 937 | |||
| 259 | espaco | 938 | } |