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