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