Rev 499 | Rev 541 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 353 | espaco | 1 | package br.com.ec.controller; |
| 2 | |||
| 3 | import java.io.Serializable; |
||
| 468 | blopes | 4 | import java.util.List; |
| 353 | espaco | 5 | |
| 6 | import javax.inject.Inject; |
||
| 7 | import javax.inject.Named; |
||
| 8 | |||
| 414 | espaco | 9 | import org.primefaces.model.StreamedContent; |
| 353 | espaco | 10 | import org.springframework.context.annotation.Scope; |
| 11 | |||
| 12 | import br.com.ec.controller.consultademanda.NotaFiscalConsultaPorDemanda; |
||
| 13 | import br.com.ec.core.generic.GenericService; |
||
| 474 | blopes | 14 | import br.com.ec.core.util.VerificadorUtil; |
| 468 | blopes | 15 | import br.com.ec.domain.dto.CompraProdutoDTO; |
| 462 | blopes | 16 | import br.com.ec.domain.dto.NotaFiscalDTO; |
| 17 | import br.com.ec.domain.dto.NotaFiscalProdutoDTO; |
||
| 18 | import br.com.ec.domain.dto.ProdutoDTO; |
||
| 353 | espaco | 19 | import br.com.ec.domain.dto.consulta.ParametrosConsultaNotaFiscal; |
| 20 | import br.com.ec.domain.model.NotaFiscal; |
||
| 449 | blopes | 21 | import br.com.ec.domain.model.Pessoa; |
| 474 | blopes | 22 | import br.com.ec.domain.model.Transporte; |
| 413 | espaco | 23 | import br.com.ec.domain.model.Venda; |
| 465 | blopes | 24 | import br.com.ec.domain.model.nfe.TipoModeloNotaFiscal; |
| 353 | espaco | 25 | import br.com.ec.domain.model.nfe.TipoNotaFiscal; |
| 492 | blopes | 26 | import br.com.ec.domain.model.nfe.TipoNotaFiscalConsumidorFinal; |
| 489 | blopes | 27 | import br.com.ec.domain.model.nfe.TipoNotaFiscalDestino; |
| 28 | import br.com.ec.domain.model.nfe.TipoNotaFiscalIntermediario; |
||
| 492 | blopes | 29 | import br.com.ec.domain.model.nfe.TipoNotaFiscalModalidadeFrete; |
| 489 | blopes | 30 | import br.com.ec.domain.model.nfe.TipoNotaFiscalPresencaComprador; |
| 468 | blopes | 31 | import br.com.ec.domain.service.CompraProdutoService; |
| 414 | espaco | 32 | import br.com.ec.domain.service.EmissorRelatorioService; |
| 462 | blopes | 33 | import br.com.ec.domain.service.NotaFiscalProdutoService; |
| 353 | espaco | 34 | import br.com.ec.domain.service.NotaFiscalService; |
| 462 | blopes | 35 | import br.com.ec.domain.service.ProdutoService; |
| 353 | espaco | 36 | import br.com.ec.web.exception.VerificadorLancamentoException; |
| 37 | import br.com.ec.web.exception.VerificadorLancamentoException.CommandBean; |
||
| 446 | blopes | 38 | import br.com.ec.web.exception.VerificadorLancamentoException.CommandRelatorioStreamedContent; |
| 353 | espaco | 39 | import br.com.ec.web.generic.AbstractBean; |
| 40 | import br.com.ec.web.message.LancadorMensagem; |
||
| 41 | import br.com.ec.web.util.TipoOperacao; |
||
| 42 | |||
| 43 | @Named |
||
| 44 | @Scope("view") |
||
| 45 | public class NotaFiscalBean extends AbstractBean<NotaFiscal> implements Serializable { |
||
| 46 | |||
| 47 | private static final long serialVersionUID = 1L; |
||
| 48 | |||
| 467 | blopes | 49 | private String statusSefaz = ""; |
| 353 | espaco | 50 | |
| 51 | private ParametrosConsultaNotaFiscal parametrosConsultaNotaFiscal; |
||
| 52 | private NotaFiscalConsultaPorDemanda lazy; |
||
| 53 | |||
| 54 | private Long sequencialVendaParaVinculo; |
||
| 446 | blopes | 55 | private StreamedContent danfeNfePreVisualizacao; |
| 414 | espaco | 56 | private StreamedContent danfeNfe; |
| 449 | blopes | 57 | |
| 462 | blopes | 58 | private String codigoProdutoParaVinculoNotaFiscal = ""; |
| 59 | private ProdutoDTO produtoDTOParaVinculoNotaFiscal; |
||
| 468 | blopes | 60 | private CompraProdutoDTO compraProdutoDTOParaVinculoNotaFiscal; |
| 61 | private List<CompraProdutoDTO> listaCompraProdutoDTOParaVinculoNotaFiscal; |
||
| 462 | blopes | 62 | |
| 63 | private String chaveNotaFiscalParaReferenciaNotaFiscal = ""; |
||
| 64 | private NotaFiscalDTO notaFiscalDTOParaReferenciaNotaFiscal; |
||
| 488 | blopes | 65 | private Transporte transporteSelecionado; |
| 462 | blopes | 66 | |
| 467 | blopes | 67 | private NotaFiscalService notaFiscalService; |
| 68 | private NotaFiscalProdutoService notaFiscalProdutoService; |
||
| 69 | private ProdutoService produtoService; |
||
| 468 | blopes | 70 | private CompraProdutoService compraProdutoService; |
| 467 | blopes | 71 | private EmissorRelatorioService emissorRelatorioService; |
| 72 | |||
| 353 | espaco | 73 | @Inject |
| 462 | blopes | 74 | public NotaFiscalBean(NotaFiscalConsultaPorDemanda lazy, NotaFiscalService notaFiscalService, NotaFiscalProdutoService notaFiscalProdutoService, |
| 487 | blopes | 75 | ProdutoService produtoService, CompraProdutoService compraProdutoService, EmissorRelatorioService emissorRelatorioService) { |
| 353 | espaco | 76 | this.lazy = lazy; |
| 77 | this.notaFiscalService = notaFiscalService; |
||
| 462 | blopes | 78 | this.notaFiscalProdutoService = notaFiscalProdutoService; |
| 79 | this.produtoService = produtoService; |
||
| 468 | blopes | 80 | this.compraProdutoService = compraProdutoService; |
| 414 | espaco | 81 | this.emissorRelatorioService = emissorRelatorioService; |
| 353 | espaco | 82 | } |
| 83 | |||
| 84 | @Override |
||
| 85 | public void preCarregamento() { |
||
| 86 | parametrosConsultaNotaFiscal = new ParametrosConsultaNotaFiscal(); |
||
| 87 | prepararConsultaDemanda(); |
||
| 88 | limparEntidade(); |
||
| 89 | } |
||
| 90 | |||
| 91 | @Override |
||
| 92 | public void limparEntidade() { |
||
| 93 | setEntidade(new NotaFiscal()); |
||
| 94 | } |
||
| 95 | |||
| 96 | @Override |
||
| 97 | public GenericService<NotaFiscal> getService() { |
||
| 98 | return notaFiscalService; |
||
| 99 | } |
||
| 100 | |||
| 101 | @Override |
||
| 102 | public NotaFiscal getEntidade() { |
||
| 103 | return entidade; |
||
| 104 | } |
||
| 105 | |||
| 106 | @Override |
||
| 107 | public void preConsultar() { |
||
| 108 | setTipoOperacao(TipoOperacao.CONSULTAR); |
||
| 109 | } |
||
| 449 | blopes | 110 | |
| 474 | blopes | 111 | @Override |
| 488 | blopes | 112 | public void preCadastrar() { |
| 113 | setTransporteSelecionado(new Transporte()); |
||
| 114 | super.preCadastrar(); |
||
| 115 | } |
||
| 116 | |||
| 117 | @Override |
||
| 118 | public void cadastrar() { |
||
| 119 | getEntidade().setTransporte(getTransporteSelecionado()); |
||
| 120 | super.cadastrar(); |
||
| 121 | } |
||
| 122 | |||
| 123 | @Override |
||
| 474 | blopes | 124 | public void preAlterar(NotaFiscal notaFiscal) { |
| 125 | if (VerificadorUtil.estaNulo(notaFiscal.getTransporte())) { |
||
| 488 | blopes | 126 | setTransporteSelecionado(new Transporte()); |
| 127 | } else { |
||
| 128 | setTransporteSelecionado(notaFiscal.getTransporte()); |
||
| 474 | blopes | 129 | } |
| 130 | super.preAlterar(notaFiscal); |
||
| 131 | } |
||
| 132 | |||
| 488 | blopes | 133 | @Override |
| 134 | public void alterar() { |
||
| 135 | getEntidade().setTransporte(getTransporteSelecionado()); |
||
| 136 | super.alterar(); |
||
| 137 | } |
||
| 138 | |||
| 449 | blopes | 139 | /* |
| 353 | espaco | 140 | @Override |
| 449 | blopes | 141 | public void preAlterar(NotaFiscal notaFiscal) { |
| 142 | NotaFiscal notaFiscalDetalhada = notaFiscalService.detalhar(notaFiscal.getSequencial()); |
||
| 143 | super.preAlterar(notaFiscalDetalhada); |
||
| 144 | } |
||
| 145 | */ |
||
| 146 | |||
| 147 | @Override |
||
| 353 | espaco | 148 | public NotaFiscal getId() { |
| 149 | return getEntidade(); |
||
| 150 | } |
||
| 151 | |||
| 152 | public ParametrosConsultaNotaFiscal getParametrosConsultaNotaFiscal() { |
||
| 153 | return parametrosConsultaNotaFiscal; |
||
| 154 | } |
||
| 155 | public void setParametrosConsultaNotaFiscal(ParametrosConsultaNotaFiscal parametrosConsultaNotaFiscal) { |
||
| 156 | this.parametrosConsultaNotaFiscal = parametrosConsultaNotaFiscal; |
||
| 157 | } |
||
| 158 | |||
| 159 | public NotaFiscalConsultaPorDemanda getLazy() { |
||
| 160 | return lazy; |
||
| 161 | } |
||
| 162 | public void setLazy(NotaFiscalConsultaPorDemanda lazy) { |
||
| 163 | this.lazy = lazy; |
||
| 164 | } |
||
| 165 | public void prepararConsultaDemanda() { |
||
| 166 | lazy.setarParametrosConsulta(getParametrosConsultaNotaFiscal()); |
||
| 167 | } |
||
| 168 | |||
| 492 | blopes | 169 | public TipoNotaFiscalModalidadeFrete[] getTiposModalidadeFrete() { |
| 170 | return TipoNotaFiscalModalidadeFrete.values(); |
||
| 171 | } |
||
| 172 | |||
| 353 | espaco | 173 | public TipoNotaFiscal[] getTiposNotaFiscal() { |
| 174 | return TipoNotaFiscal.values(); |
||
| 175 | } |
||
| 176 | |||
| 492 | blopes | 177 | public TipoNotaFiscalConsumidorFinal[] getTiposConsumidorFinal() { |
| 178 | return TipoNotaFiscalConsumidorFinal.values(); |
||
| 179 | } |
||
| 180 | |||
| 489 | blopes | 181 | public TipoNotaFiscalPresencaComprador[] getTiposPresencaComprador() { |
| 182 | return TipoNotaFiscalPresencaComprador.values(); |
||
| 474 | blopes | 183 | } |
| 184 | |||
| 489 | blopes | 185 | public TipoNotaFiscalIntermediario[] getTiposIntermediario() { |
| 186 | return TipoNotaFiscalIntermediario.values(); |
||
| 187 | } |
||
| 188 | |||
| 189 | public TipoNotaFiscalDestino[] getTiposDestino() { |
||
| 190 | return TipoNotaFiscalDestino.values(); |
||
| 191 | } |
||
| 192 | |||
| 353 | espaco | 193 | public Long getSequencialVendaParaVinculo() { |
| 194 | return sequencialVendaParaVinculo; |
||
| 195 | } |
||
| 196 | public void setSequencialVendaParaVinculo(Long sequencialVendaParaVinculo) { |
||
| 197 | this.sequencialVendaParaVinculo = sequencialVendaParaVinculo; |
||
| 198 | } |
||
| 199 | |||
| 446 | blopes | 200 | public StreamedContent getDanfeNfePreVisualizacao() { |
| 201 | return danfeNfePreVisualizacao; |
||
| 202 | } |
||
| 203 | public void setDanfeNfePreVisualizacao(StreamedContent danfeNfePreVisualizacao) { |
||
| 204 | this.danfeNfePreVisualizacao = danfeNfePreVisualizacao; |
||
| 205 | } |
||
| 206 | |||
| 414 | espaco | 207 | public StreamedContent getDanfeNfe() { |
| 208 | return danfeNfe; |
||
| 209 | } |
||
| 210 | public void setDanfeNfe(StreamedContent danfeNfe) { |
||
| 211 | this.danfeNfe = danfeNfe; |
||
| 212 | } |
||
| 213 | |||
| 462 | blopes | 214 | public String getCodigoProdutoParaVinculoNotaFiscal() { |
| 215 | return codigoProdutoParaVinculoNotaFiscal; |
||
| 216 | } |
||
| 217 | public void setCodigoProdutoParaVinculoNotaFiscal(String codigoProdutoParaVinculoNotaFiscal) { |
||
| 218 | this.codigoProdutoParaVinculoNotaFiscal = codigoProdutoParaVinculoNotaFiscal; |
||
| 219 | } |
||
| 220 | |||
| 221 | public ProdutoDTO getProdutoDTOParaVinculoNotaFiscal() { |
||
| 222 | return produtoDTOParaVinculoNotaFiscal; |
||
| 223 | } |
||
| 224 | public void setProdutoDTOParaVinculoNotaFiscal(ProdutoDTO produtoDTOParaVinculoNotaFiscal) { |
||
| 225 | this.produtoDTOParaVinculoNotaFiscal = produtoDTOParaVinculoNotaFiscal; |
||
| 226 | } |
||
| 227 | |||
| 468 | blopes | 228 | public CompraProdutoDTO getCompraProdutoDTOParaVinculoNotaFiscal() { |
| 229 | return compraProdutoDTOParaVinculoNotaFiscal; |
||
| 230 | } |
||
| 231 | public void setCompraProdutoDTOParaVinculoNotaFiscal(CompraProdutoDTO compraProdutoDTOParaVinculoNotaFiscal) { |
||
| 232 | this.compraProdutoDTOParaVinculoNotaFiscal = compraProdutoDTOParaVinculoNotaFiscal; |
||
| 233 | } |
||
| 234 | |||
| 235 | public List<CompraProdutoDTO> getListaCompraProdutoDTOParaVinculoNotaFiscal() { |
||
| 236 | return listaCompraProdutoDTOParaVinculoNotaFiscal; |
||
| 237 | } |
||
| 238 | public void setListaCompraProdutoDTOParaVinculoNotaFiscal(List<CompraProdutoDTO> listaCompraProdutoDTOParaVinculoNotaFiscal) { |
||
| 239 | this.listaCompraProdutoDTOParaVinculoNotaFiscal = listaCompraProdutoDTOParaVinculoNotaFiscal; |
||
| 240 | } |
||
| 241 | |||
| 462 | blopes | 242 | public String getChaveNotaFiscalParaReferenciaNotaFiscal() { |
| 243 | return chaveNotaFiscalParaReferenciaNotaFiscal; |
||
| 244 | } |
||
| 245 | public void setChaveNotaFiscalParaReferenciaNotaFiscal(String chaveNotaFiscalParaReferenciaNotaFiscal) { |
||
| 246 | this.chaveNotaFiscalParaReferenciaNotaFiscal = chaveNotaFiscalParaReferenciaNotaFiscal; |
||
| 247 | } |
||
| 248 | |||
| 249 | public NotaFiscalDTO getNotaFiscalDTOParaReferenciaNotaFiscal() { |
||
| 250 | return notaFiscalDTOParaReferenciaNotaFiscal; |
||
| 251 | } |
||
| 252 | public void setNotaFiscalDTOParaReferenciaNotaFiscal(NotaFiscalDTO notaFiscalDTOParaReferenciaNotaFiscal) { |
||
| 253 | this.notaFiscalDTOParaReferenciaNotaFiscal = notaFiscalDTOParaReferenciaNotaFiscal; |
||
| 254 | } |
||
| 255 | |||
| 488 | blopes | 256 | public Transporte getTransporteSelecionado() { |
| 257 | return transporteSelecionado; |
||
| 258 | } |
||
| 259 | public void setTransporteSelecionado(Transporte transporteSelecionado) { |
||
| 260 | this.transporteSelecionado = transporteSelecionado; |
||
| 261 | } |
||
| 262 | |||
| 467 | blopes | 263 | public String getStatusSefaz() { |
| 264 | return statusSefaz; |
||
| 265 | } |
||
| 266 | public void setStatusSefaz(String statusSefaz) { |
||
| 267 | this.statusSefaz = statusSefaz; |
||
| 268 | } |
||
| 269 | |||
| 353 | espaco | 270 | /**************************************************/ |
| 271 | |||
| 467 | blopes | 272 | public void atualizarStatusSefaz() { |
| 273 | setStatusSefaz(notaFiscalService.retornarStatusSefaz()); |
||
| 274 | } |
||
| 275 | |||
| 353 | espaco | 276 | public void desvincularVenda() { |
| 277 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 278 | public void execute() { |
||
| 413 | espaco | 279 | notaFiscalService.desvincularVenda(getEntidade().getSequencial()); |
| 280 | getEntidade().setVenda(null); |
||
| 353 | espaco | 281 | LancadorMensagem.lancarSucesso("VENDA DESVINCULADA COM SUCESSO"); |
| 282 | } |
||
| 283 | }); |
||
| 284 | } |
||
| 285 | |||
| 286 | public void vincularVenda() { |
||
| 287 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 288 | public void execute() { |
||
| 413 | espaco | 289 | Venda vendaVinculada = notaFiscalService.vincularVenda(getEntidade().getSequencial(), getSequencialVendaParaVinculo()); |
| 290 | getEntidade().setVenda(vendaVinculada); |
||
| 353 | espaco | 291 | LancadorMensagem.lancarSucesso("VENDA VINCULADA COM SUCESSO"); |
| 292 | } |
||
| 293 | }); |
||
| 294 | } |
||
| 295 | |||
| 414 | espaco | 296 | public void emitirDanfeNfe(Long sequencialNotaFiscal) { |
| 447 | blopes | 297 | setDanfeNfePreVisualizacao(notaFiscalService.gerarDanfeNfePreVisualizacao(sequencialNotaFiscal)); |
| 414 | espaco | 298 | setDanfeNfe(notaFiscalService.gerarDanfeNfe(sequencialNotaFiscal)); |
| 446 | blopes | 299 | } |
| 300 | |||
| 301 | public void emitirDanfeNfePreVisualizacao(Long sequencialNotaFiscal) { |
||
| 302 | setDanfeNfePreVisualizacao(notaFiscalService.gerarDanfeNfePreVisualizacao(sequencialNotaFiscal)); |
||
| 303 | setDanfeNfe(notaFiscalService.gerarDanfeNfe(sequencialNotaFiscal)); |
||
| 414 | espaco | 304 | /* |
| 305 | return new VerificadorLancamentoException().verificarLancamentoException(new CommandRelatorioStreamedContent() { |
||
| 306 | @Override |
||
| 307 | public StreamedContent execute() { |
||
| 308 | return notaFiscalService.gerarDanfeNfe(getEntidade().getSequencial()); |
||
| 309 | } |
||
| 310 | }); |
||
| 311 | */ |
||
| 312 | } |
||
| 313 | |||
| 446 | blopes | 314 | public StreamedContent downloadNotaFiscal() { |
| 315 | return new VerificadorLancamentoException().verificarLancamentoException(new CommandRelatorioStreamedContent() { |
||
| 316 | @Override |
||
| 317 | public StreamedContent execute() { |
||
| 318 | return getDanfeNfe(); |
||
| 319 | } |
||
| 320 | }); |
||
| 321 | } |
||
| 322 | |||
| 425 | espaco | 323 | public void emitirDanfeNfeTeste() { |
| 324 | Long sequencialNotaFiscal = new Long(168722); |
||
| 446 | blopes | 325 | setDanfeNfePreVisualizacao(notaFiscalService.gerarDanfeNfePreVisualizacao(sequencialNotaFiscal)); |
| 425 | espaco | 326 | setDanfeNfe(notaFiscalService.gerarDanfeNfe(sequencialNotaFiscal)); |
| 327 | } |
||
| 328 | |||
| 478 | blopes | 329 | public void visualizarDanfe() { |
| 330 | Long sequencialNotaFiscal = getEntidade().getSequencial(); |
||
| 331 | setDanfeNfePreVisualizacao(notaFiscalService.gerarDanfeNfePreVisualizacao(sequencialNotaFiscal)); |
||
| 332 | } |
||
| 333 | |||
| 334 | public StreamedContent downloadNotaFiscalPreVisualizada() { |
||
| 335 | return new VerificadorLancamentoException().verificarLancamentoException(new CommandRelatorioStreamedContent() { |
||
| 336 | @Override |
||
| 337 | public StreamedContent execute() { |
||
| 338 | return getDanfeNfePreVisualizacao(); |
||
| 339 | } |
||
| 340 | }); |
||
| 341 | } |
||
| 342 | |||
| 449 | blopes | 343 | public void selecionarEmitente(final Pessoa pessoa) { |
| 344 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 345 | public void execute() { |
||
| 346 | getEntidade().setPessoaEmitente(pessoa); |
||
| 347 | adicionandoParametroArgsConfirmandoAcao(true); |
||
| 348 | } |
||
| 349 | }); |
||
| 350 | } |
||
| 351 | |||
| 352 | public void retirarEmitente() { |
||
| 353 | getEntidade().setPessoaEmitente(null); |
||
| 354 | } |
||
| 355 | |||
| 356 | public void selecionarDestinatario(final Pessoa pessoa) { |
||
| 357 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 358 | public void execute() { |
||
| 359 | getEntidade().setPessoaDestinatario(pessoa); |
||
| 360 | adicionandoParametroArgsConfirmandoAcao(true); |
||
| 361 | } |
||
| 362 | }); |
||
| 363 | } |
||
| 364 | |||
| 365 | public void retirarDestinatario() { |
||
| 366 | getEntidade().setPessoaDestinatario(null); |
||
| 367 | } |
||
| 368 | |||
| 465 | blopes | 369 | /************************************/ |
| 370 | /** REMESSA **/ |
||
| 371 | /************************************/ |
||
| 372 | |||
| 373 | public void prepararNotaFiscalRemessa() { |
||
| 374 | preCadastrar(); |
||
| 492 | blopes | 375 | getEntidade().prepararNotaFiscalEletronicaRemessa(); |
| 465 | blopes | 376 | } |
| 377 | |||
| 378 | public void emitirNotaFiscalRemessa() { |
||
| 379 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 380 | public void execute() { |
||
| 492 | blopes | 381 | notaFiscalService.emitirNotaFiscalEletronica(getEntidade()); |
| 480 | blopes | 382 | LancadorMensagem.lancarSucesso("NOTA FISCAL DE REMESSA EMITIDA COM SUCESSO"); |
| 465 | blopes | 383 | } |
| 384 | }); |
||
| 385 | } |
||
| 386 | |||
| 492 | blopes | 387 | public void cancelarNotaFiscal() { |
| 388 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 389 | public void execute() { |
||
| 390 | notaFiscalService.cancelarNotaFiscalEletronica(getEntidade()); |
||
| 391 | LancadorMensagem.lancarSucesso("NOTA FISCAL CANCELADA COM SUCESSO"); |
||
| 392 | } |
||
| 393 | }); |
||
| 394 | } |
||
| 395 | |||
| 449 | blopes | 396 | public void consultarProdutosVinculados() { |
| 397 | getEntidade().setListaProdutosVinculadosDTO(notaFiscalService.consultarProdutosVinculados(getEntidade().getSequencial())); |
||
| 398 | } |
||
| 399 | |||
| 468 | blopes | 400 | public void selecionarCompraProdutoParaVinculoNotaFiscal(CompraProdutoDTO compraProdutoDTO) { |
| 485 | blopes | 401 | compraProdutoDTO.setValorProdutoParaVinculoNotaFiscal(compraProdutoDTO.getValorCompra()); |
| 468 | blopes | 402 | setCompraProdutoDTOParaVinculoNotaFiscal(compraProdutoDTO); |
| 403 | } |
||
| 404 | |||
| 462 | blopes | 405 | public void excluirVinculoNotaFiscalProduto(NotaFiscalProdutoDTO notaFiscalProdutoDTO) { |
| 406 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 407 | public void execute() { |
||
| 408 | notaFiscalProdutoService.excluirNotaFiscalProduto(notaFiscalProdutoDTO); |
||
| 409 | consultarProdutosVinculados(); |
||
| 410 | LancadorMensagem.lancarSucesso("VÍNCULO EXCLUÍDO COM SUCESSO"); |
||
| 411 | } |
||
| 412 | }); |
||
| 413 | } |
||
| 414 | |||
| 415 | public void consultarProdutoParaVinculoNotaFiscal() { |
||
| 416 | setProdutoDTOParaVinculoNotaFiscal(produtoService.consultarProdutoDTOPorCodigoOuCodigoEAN(getCodigoProdutoParaVinculoNotaFiscal())); |
||
| 468 | blopes | 417 | setListaCompraProdutoDTOParaVinculoNotaFiscal(produtoService.consultarComprasDoProduto(getProdutoDTOParaVinculoNotaFiscal().getSequencial())); |
| 462 | blopes | 418 | } |
| 419 | |||
| 420 | public void vinculoProdutoNaNotaFiscal() { |
||
| 421 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 422 | public void execute() { |
||
| 423 | notaFiscalProdutoService.vinculoProdutoNaNotaFiscal(getEntidade().getSequencial(), |
||
| 499 | blopes | 424 | getProdutoDTOParaVinculoNotaFiscal(), |
| 485 | blopes | 425 | getCompraProdutoDTOParaVinculoNotaFiscal()); |
| 462 | blopes | 426 | setCodigoProdutoParaVinculoNotaFiscal(""); |
| 427 | setProdutoDTOParaVinculoNotaFiscal(null); |
||
| 468 | blopes | 428 | setCompraProdutoDTOParaVinculoNotaFiscal(null); |
| 462 | blopes | 429 | consultarProdutosVinculados(); |
| 430 | LancadorMensagem.lancarSucesso("PRODUTO VINCULADO COM SUCESSO"); |
||
| 431 | } |
||
| 432 | }); |
||
| 433 | } |
||
| 434 | |||
| 435 | public void consultarNotaFiscalParaReferenciarNotaFiscal() { |
||
| 436 | setNotaFiscalDTOParaReferenciaNotaFiscal(notaFiscalService.consultarPorChave(getChaveNotaFiscalParaReferenciaNotaFiscal())); |
||
| 437 | } |
||
| 438 | |||
| 478 | blopes | 439 | public void gerarDadosAdicionais() { |
| 440 | consultarProdutosVinculados(); |
||
| 441 | |||
| 442 | StringBuilder dadosAdicionais = new StringBuilder(""); |
||
| 443 | |||
| 444 | if (getEntidade().ehNotaFiscalDeRemessa()) { |
||
| 445 | if (!VerificadorUtil.isListaNulaOuVazia(getEntidade().getListaProdutosVinculadosDTO())) { |
||
| 492 | blopes | 446 | dadosAdicionais.append("Devolução parcial das Notas Fiscais abaixo:\n"); |
| 478 | blopes | 447 | for (NotaFiscalProdutoDTO notaFiscalProdutoDTO : getEntidade().getListaProdutosVinculadosDTO()) { |
| 448 | NotaFiscalDTO notaFiscalDTOCompra = notaFiscalProdutoDTO.getCompraProdutoDTO().getCompraDTO().getNotaFiscalDTO(); |
||
| 449 | if (!dadosAdicionais.toString().contains(notaFiscalDTOCompra.getChave())) { |
||
| 450 | dadosAdicionais.append(notaFiscalDTOCompra.getNumero()); |
||
| 451 | dadosAdicionais.append(", Chave de acesso: "); |
||
| 452 | dadosAdicionais.append(notaFiscalDTOCompra.getChave()); |
||
| 453 | dadosAdicionais.append(", emitida em "); |
||
| 454 | dadosAdicionais.append(notaFiscalDTOCompra.getDataEmissaoFormatada()); |
||
| 455 | dadosAdicionais.append(" | "); |
||
| 456 | } |
||
| 457 | } |
||
| 492 | blopes | 458 | dadosAdicionais.append("\n"); |
| 478 | blopes | 459 | } |
| 460 | } |
||
| 461 | |||
| 462 | // EMAIL DO DESTINATÁRIO |
||
| 463 | dadosAdicionais.append(getEntidade().getPessoaDestinatario().getEmail()); |
||
| 502 | blopes | 464 | dadosAdicionais.append(". "); |
| 478 | blopes | 465 | |
| 466 | getEntidade().setDescricaoComplementares(dadosAdicionais.toString()); |
||
| 467 | } |
||
| 468 | |||
| 353 | espaco | 469 | } |