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