Rev 480 | Rev 487 | 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, |
| 472 | blopes | 71 | ProdutoService produtoService, CompraProdutoService compraProdutoService, |
| 468 | blopes | 72 | EmissorRelatorioService emissorRelatorioService) { |
| 353 | espaco | 73 | this.lazy = lazy; |
| 74 | this.notaFiscalService = notaFiscalService; |
||
| 462 | blopes | 75 | this.notaFiscalProdutoService = notaFiscalProdutoService; |
| 76 | this.produtoService = produtoService; |
||
| 468 | blopes | 77 | this.compraProdutoService = compraProdutoService; |
| 414 | espaco | 78 | this.emissorRelatorioService = emissorRelatorioService; |
| 353 | espaco | 79 | } |
| 80 | |||
| 81 | @Override |
||
| 82 | public void preCarregamento() { |
||
| 83 | parametrosConsultaNotaFiscal = new ParametrosConsultaNotaFiscal(); |
||
| 84 | prepararConsultaDemanda(); |
||
| 85 | limparEntidade(); |
||
| 86 | } |
||
| 87 | |||
| 88 | @Override |
||
| 89 | public void limparEntidade() { |
||
| 90 | setEntidade(new NotaFiscal()); |
||
| 91 | } |
||
| 92 | |||
| 93 | @Override |
||
| 94 | public GenericService<NotaFiscal> getService() { |
||
| 95 | return notaFiscalService; |
||
| 96 | } |
||
| 97 | |||
| 98 | @Override |
||
| 99 | public NotaFiscal getEntidade() { |
||
| 100 | return entidade; |
||
| 101 | } |
||
| 102 | |||
| 103 | @Override |
||
| 104 | public void preConsultar() { |
||
| 105 | setTipoOperacao(TipoOperacao.CONSULTAR); |
||
| 106 | } |
||
| 449 | blopes | 107 | |
| 474 | blopes | 108 | @Override |
| 109 | public void preAlterar(NotaFiscal notaFiscal) { |
||
| 110 | if (VerificadorUtil.estaNulo(notaFiscal.getTransporte())) { |
||
| 111 | notaFiscal.setTransporte(new Transporte()); |
||
| 112 | } |
||
| 113 | super.preAlterar(notaFiscal); |
||
| 114 | } |
||
| 115 | |||
| 449 | blopes | 116 | /* |
| 353 | espaco | 117 | @Override |
| 449 | blopes | 118 | public void preAlterar(NotaFiscal notaFiscal) { |
| 119 | NotaFiscal notaFiscalDetalhada = notaFiscalService.detalhar(notaFiscal.getSequencial()); |
||
| 120 | super.preAlterar(notaFiscalDetalhada); |
||
| 121 | } |
||
| 122 | */ |
||
| 123 | |||
| 124 | @Override |
||
| 353 | espaco | 125 | public NotaFiscal getId() { |
| 126 | return getEntidade(); |
||
| 127 | } |
||
| 128 | |||
| 129 | public ParametrosConsultaNotaFiscal getParametrosConsultaNotaFiscal() { |
||
| 130 | return parametrosConsultaNotaFiscal; |
||
| 131 | } |
||
| 132 | public void setParametrosConsultaNotaFiscal(ParametrosConsultaNotaFiscal parametrosConsultaNotaFiscal) { |
||
| 133 | this.parametrosConsultaNotaFiscal = parametrosConsultaNotaFiscal; |
||
| 134 | } |
||
| 135 | |||
| 136 | public NotaFiscalConsultaPorDemanda getLazy() { |
||
| 137 | return lazy; |
||
| 138 | } |
||
| 139 | public void setLazy(NotaFiscalConsultaPorDemanda lazy) { |
||
| 140 | this.lazy = lazy; |
||
| 141 | } |
||
| 142 | public void prepararConsultaDemanda() { |
||
| 143 | lazy.setarParametrosConsulta(getParametrosConsultaNotaFiscal()); |
||
| 144 | } |
||
| 145 | |||
| 146 | public TipoNotaFiscal[] getTiposNotaFiscal() { |
||
| 147 | return TipoNotaFiscal.values(); |
||
| 148 | } |
||
| 149 | |||
| 474 | blopes | 150 | public TipoModalidadeFrete[] getTiposModalidadeFrete() { |
| 151 | return TipoModalidadeFrete.values(); |
||
| 152 | } |
||
| 153 | |||
| 353 | espaco | 154 | public Long getSequencialVendaParaVinculo() { |
| 155 | return sequencialVendaParaVinculo; |
||
| 156 | } |
||
| 157 | public void setSequencialVendaParaVinculo(Long sequencialVendaParaVinculo) { |
||
| 158 | this.sequencialVendaParaVinculo = sequencialVendaParaVinculo; |
||
| 159 | } |
||
| 160 | |||
| 446 | blopes | 161 | public StreamedContent getDanfeNfePreVisualizacao() { |
| 162 | return danfeNfePreVisualizacao; |
||
| 163 | } |
||
| 164 | public void setDanfeNfePreVisualizacao(StreamedContent danfeNfePreVisualizacao) { |
||
| 165 | this.danfeNfePreVisualizacao = danfeNfePreVisualizacao; |
||
| 166 | } |
||
| 167 | |||
| 414 | espaco | 168 | public StreamedContent getDanfeNfe() { |
| 169 | return danfeNfe; |
||
| 170 | } |
||
| 171 | public void setDanfeNfe(StreamedContent danfeNfe) { |
||
| 172 | this.danfeNfe = danfeNfe; |
||
| 173 | } |
||
| 174 | |||
| 462 | blopes | 175 | public String getCodigoProdutoParaVinculoNotaFiscal() { |
| 176 | return codigoProdutoParaVinculoNotaFiscal; |
||
| 177 | } |
||
| 178 | public void setCodigoProdutoParaVinculoNotaFiscal(String codigoProdutoParaVinculoNotaFiscal) { |
||
| 179 | this.codigoProdutoParaVinculoNotaFiscal = codigoProdutoParaVinculoNotaFiscal; |
||
| 180 | } |
||
| 181 | |||
| 182 | public ProdutoDTO getProdutoDTOParaVinculoNotaFiscal() { |
||
| 183 | return produtoDTOParaVinculoNotaFiscal; |
||
| 184 | } |
||
| 185 | public void setProdutoDTOParaVinculoNotaFiscal(ProdutoDTO produtoDTOParaVinculoNotaFiscal) { |
||
| 186 | this.produtoDTOParaVinculoNotaFiscal = produtoDTOParaVinculoNotaFiscal; |
||
| 187 | } |
||
| 188 | |||
| 468 | blopes | 189 | public CompraProdutoDTO getCompraProdutoDTOParaVinculoNotaFiscal() { |
| 190 | return compraProdutoDTOParaVinculoNotaFiscal; |
||
| 191 | } |
||
| 192 | public void setCompraProdutoDTOParaVinculoNotaFiscal(CompraProdutoDTO compraProdutoDTOParaVinculoNotaFiscal) { |
||
| 193 | this.compraProdutoDTOParaVinculoNotaFiscal = compraProdutoDTOParaVinculoNotaFiscal; |
||
| 194 | } |
||
| 195 | |||
| 196 | public List<CompraProdutoDTO> getListaCompraProdutoDTOParaVinculoNotaFiscal() { |
||
| 197 | return listaCompraProdutoDTOParaVinculoNotaFiscal; |
||
| 198 | } |
||
| 199 | public void setListaCompraProdutoDTOParaVinculoNotaFiscal(List<CompraProdutoDTO> listaCompraProdutoDTOParaVinculoNotaFiscal) { |
||
| 200 | this.listaCompraProdutoDTOParaVinculoNotaFiscal = listaCompraProdutoDTOParaVinculoNotaFiscal; |
||
| 201 | } |
||
| 202 | |||
| 462 | blopes | 203 | public String getChaveNotaFiscalParaReferenciaNotaFiscal() { |
| 204 | return chaveNotaFiscalParaReferenciaNotaFiscal; |
||
| 205 | } |
||
| 206 | public void setChaveNotaFiscalParaReferenciaNotaFiscal(String chaveNotaFiscalParaReferenciaNotaFiscal) { |
||
| 207 | this.chaveNotaFiscalParaReferenciaNotaFiscal = chaveNotaFiscalParaReferenciaNotaFiscal; |
||
| 208 | } |
||
| 209 | |||
| 210 | public NotaFiscalDTO getNotaFiscalDTOParaReferenciaNotaFiscal() { |
||
| 211 | return notaFiscalDTOParaReferenciaNotaFiscal; |
||
| 212 | } |
||
| 213 | public void setNotaFiscalDTOParaReferenciaNotaFiscal(NotaFiscalDTO notaFiscalDTOParaReferenciaNotaFiscal) { |
||
| 214 | this.notaFiscalDTOParaReferenciaNotaFiscal = notaFiscalDTOParaReferenciaNotaFiscal; |
||
| 215 | } |
||
| 216 | |||
| 467 | blopes | 217 | public String getStatusSefaz() { |
| 218 | return statusSefaz; |
||
| 219 | } |
||
| 220 | public void setStatusSefaz(String statusSefaz) { |
||
| 221 | this.statusSefaz = statusSefaz; |
||
| 222 | } |
||
| 223 | |||
| 353 | espaco | 224 | /**************************************************/ |
| 225 | |||
| 467 | blopes | 226 | public void atualizarStatusSefaz() { |
| 227 | setStatusSefaz(notaFiscalService.retornarStatusSefaz()); |
||
| 228 | } |
||
| 229 | |||
| 353 | espaco | 230 | public void desvincularVenda() { |
| 231 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 232 | public void execute() { |
||
| 413 | espaco | 233 | notaFiscalService.desvincularVenda(getEntidade().getSequencial()); |
| 234 | getEntidade().setVenda(null); |
||
| 353 | espaco | 235 | LancadorMensagem.lancarSucesso("VENDA DESVINCULADA COM SUCESSO"); |
| 236 | } |
||
| 237 | }); |
||
| 238 | } |
||
| 239 | |||
| 240 | public void vincularVenda() { |
||
| 241 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 242 | public void execute() { |
||
| 413 | espaco | 243 | Venda vendaVinculada = notaFiscalService.vincularVenda(getEntidade().getSequencial(), getSequencialVendaParaVinculo()); |
| 244 | getEntidade().setVenda(vendaVinculada); |
||
| 353 | espaco | 245 | LancadorMensagem.lancarSucesso("VENDA VINCULADA COM SUCESSO"); |
| 246 | } |
||
| 247 | }); |
||
| 248 | } |
||
| 249 | |||
| 414 | espaco | 250 | public void emitirDanfeNfe(Long sequencialNotaFiscal) { |
| 447 | blopes | 251 | setDanfeNfePreVisualizacao(notaFiscalService.gerarDanfeNfePreVisualizacao(sequencialNotaFiscal)); |
| 414 | espaco | 252 | setDanfeNfe(notaFiscalService.gerarDanfeNfe(sequencialNotaFiscal)); |
| 446 | blopes | 253 | } |
| 254 | |||
| 255 | public void emitirDanfeNfePreVisualizacao(Long sequencialNotaFiscal) { |
||
| 256 | setDanfeNfePreVisualizacao(notaFiscalService.gerarDanfeNfePreVisualizacao(sequencialNotaFiscal)); |
||
| 257 | setDanfeNfe(notaFiscalService.gerarDanfeNfe(sequencialNotaFiscal)); |
||
| 414 | espaco | 258 | /* |
| 259 | return new VerificadorLancamentoException().verificarLancamentoException(new CommandRelatorioStreamedContent() { |
||
| 260 | @Override |
||
| 261 | public StreamedContent execute() { |
||
| 262 | return notaFiscalService.gerarDanfeNfe(getEntidade().getSequencial()); |
||
| 263 | } |
||
| 264 | }); |
||
| 265 | */ |
||
| 266 | } |
||
| 267 | |||
| 446 | blopes | 268 | public StreamedContent downloadNotaFiscal() { |
| 269 | return new VerificadorLancamentoException().verificarLancamentoException(new CommandRelatorioStreamedContent() { |
||
| 270 | @Override |
||
| 271 | public StreamedContent execute() { |
||
| 272 | return getDanfeNfe(); |
||
| 273 | } |
||
| 274 | }); |
||
| 275 | } |
||
| 276 | |||
| 425 | espaco | 277 | public void emitirDanfeNfeTeste() { |
| 278 | Long sequencialNotaFiscal = new Long(168722); |
||
| 446 | blopes | 279 | setDanfeNfePreVisualizacao(notaFiscalService.gerarDanfeNfePreVisualizacao(sequencialNotaFiscal)); |
| 425 | espaco | 280 | setDanfeNfe(notaFiscalService.gerarDanfeNfe(sequencialNotaFiscal)); |
| 281 | } |
||
| 282 | |||
| 478 | blopes | 283 | public void visualizarDanfe() { |
| 284 | Long sequencialNotaFiscal = getEntidade().getSequencial(); |
||
| 285 | setDanfeNfePreVisualizacao(notaFiscalService.gerarDanfeNfePreVisualizacao(sequencialNotaFiscal)); |
||
| 286 | } |
||
| 287 | |||
| 288 | public StreamedContent downloadNotaFiscalPreVisualizada() { |
||
| 289 | return new VerificadorLancamentoException().verificarLancamentoException(new CommandRelatorioStreamedContent() { |
||
| 290 | @Override |
||
| 291 | public StreamedContent execute() { |
||
| 292 | return getDanfeNfePreVisualizacao(); |
||
| 293 | } |
||
| 294 | }); |
||
| 295 | } |
||
| 296 | |||
| 449 | blopes | 297 | public void selecionarEmitente(final Pessoa pessoa) { |
| 298 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 299 | public void execute() { |
||
| 300 | getEntidade().setPessoaEmitente(pessoa); |
||
| 301 | adicionandoParametroArgsConfirmandoAcao(true); |
||
| 302 | } |
||
| 303 | }); |
||
| 304 | } |
||
| 305 | |||
| 306 | public void retirarEmitente() { |
||
| 307 | getEntidade().setPessoaEmitente(null); |
||
| 308 | } |
||
| 309 | |||
| 310 | public void selecionarDestinatario(final Pessoa pessoa) { |
||
| 311 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 312 | public void execute() { |
||
| 313 | getEntidade().setPessoaDestinatario(pessoa); |
||
| 314 | adicionandoParametroArgsConfirmandoAcao(true); |
||
| 315 | } |
||
| 316 | }); |
||
| 317 | } |
||
| 318 | |||
| 319 | public void retirarDestinatario() { |
||
| 320 | getEntidade().setPessoaDestinatario(null); |
||
| 321 | } |
||
| 322 | |||
| 465 | blopes | 323 | /************************************/ |
| 324 | /** REMESSA **/ |
||
| 325 | /************************************/ |
||
| 326 | |||
| 327 | public void prepararNotaFiscalRemessa() { |
||
| 328 | preCadastrar(); |
||
| 329 | getEntidade().setTipoModeloNotaFiscal(TipoModeloNotaFiscal.MODELO_NFE_55.getValor()); |
||
| 330 | getEntidade().setTipoNotaFiscal(TipoNotaFiscal.NFE_REMESSA.getValor()); |
||
| 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 | } |