Rev 449 | Rev 465 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 449 | Rev 462 | ||
|---|---|---|---|
| Line 8... | Line 8... | ||
| 8 | import org.primefaces.model.StreamedContent; |
8 | import org.primefaces.model.StreamedContent; |
| 9 | import org.springframework.context.annotation.Scope; |
9 | import org.springframework.context.annotation.Scope; |
| 10 | 10 | ||
| 11 | import br.com.ec.controller.consultademanda.NotaFiscalConsultaPorDemanda; |
11 | import br.com.ec.controller.consultademanda.NotaFiscalConsultaPorDemanda; |
| 12 | import br.com.ec.core.generic.GenericService; |
12 | import br.com.ec.core.generic.GenericService; |
| - | 13 | import br.com.ec.domain.dto.NotaFiscalDTO; |
|
| - | 14 | import br.com.ec.domain.dto.NotaFiscalProdutoDTO; |
|
| - | 15 | import br.com.ec.domain.dto.NotaFiscalReferenciadaDTO; |
|
| - | 16 | import br.com.ec.domain.dto.ProdutoDTO; |
|
| 13 | import br.com.ec.domain.dto.consulta.ParametrosConsultaNotaFiscal; |
17 | import br.com.ec.domain.dto.consulta.ParametrosConsultaNotaFiscal; |
| 14 | import br.com.ec.domain.model.NotaFiscal; |
18 | import br.com.ec.domain.model.NotaFiscal; |
| 15 | import br.com.ec.domain.model.Pessoa; |
19 | import br.com.ec.domain.model.Pessoa; |
| 16 | import br.com.ec.domain.model.Venda; |
20 | import br.com.ec.domain.model.Venda; |
| 17 | import br.com.ec.domain.model.nfe.TipoNotaFiscal; |
21 | import br.com.ec.domain.model.nfe.TipoNotaFiscal; |
| 18 | import br.com.ec.domain.service.EmissorRelatorioService; |
22 | import br.com.ec.domain.service.EmissorRelatorioService; |
| - | 23 | import br.com.ec.domain.service.NotaFiscalProdutoService; |
|
| - | 24 | import br.com.ec.domain.service.NotaFiscalReferenciadaService; |
|
| 19 | import br.com.ec.domain.service.NotaFiscalService; |
25 | import br.com.ec.domain.service.NotaFiscalService; |
| - | 26 | import br.com.ec.domain.service.ProdutoService; |
|
| 20 | import br.com.ec.web.exception.VerificadorLancamentoException; |
27 | import br.com.ec.web.exception.VerificadorLancamentoException; |
| 21 | import br.com.ec.web.exception.VerificadorLancamentoException.CommandBean; |
28 | import br.com.ec.web.exception.VerificadorLancamentoException.CommandBean; |
| 22 | import br.com.ec.web.exception.VerificadorLancamentoException.CommandRelatorioStreamedContent; |
29 | import br.com.ec.web.exception.VerificadorLancamentoException.CommandRelatorioStreamedContent; |
| 23 | import br.com.ec.web.generic.AbstractBean; |
30 | import br.com.ec.web.generic.AbstractBean; |
| 24 | import br.com.ec.web.message.LancadorMensagem; |
31 | import br.com.ec.web.message.LancadorMensagem; |
| Line 29... | Line 36... | ||
| 29 | public class NotaFiscalBean extends AbstractBean<NotaFiscal> implements Serializable { |
36 | public class NotaFiscalBean extends AbstractBean<NotaFiscal> implements Serializable { |
| 30 | 37 | ||
| 31 | private static final long serialVersionUID = 1L; |
38 | private static final long serialVersionUID = 1L; |
| 32 | 39 | ||
| 33 | private NotaFiscalService notaFiscalService; |
40 | private NotaFiscalService notaFiscalService; |
| - | 41 | private NotaFiscalProdutoService notaFiscalProdutoService; |
|
| - | 42 | private NotaFiscalReferenciadaService notaFiscalReferenciadaService; |
|
| - | 43 | private ProdutoService produtoService; |
|
| 34 | private EmissorRelatorioService emissorRelatorioService; |
44 | private EmissorRelatorioService emissorRelatorioService; |
| 35 | 45 | ||
| 36 | private ParametrosConsultaNotaFiscal parametrosConsultaNotaFiscal; |
46 | private ParametrosConsultaNotaFiscal parametrosConsultaNotaFiscal; |
| 37 | private NotaFiscalConsultaPorDemanda lazy; |
47 | private NotaFiscalConsultaPorDemanda lazy; |
| 38 | 48 | ||
| 39 | private Long sequencialVendaParaVinculo; |
49 | private Long sequencialVendaParaVinculo; |
| 40 | private StreamedContent danfeNfePreVisualizacao; |
50 | private StreamedContent danfeNfePreVisualizacao; |
| 41 | private StreamedContent danfeNfe; |
51 | private StreamedContent danfeNfe; |
| - | 52 | ||
| - | 53 | private String codigoProdutoParaVinculoNotaFiscal = ""; |
|
| - | 54 | private Integer quantidadeProdutoParaVinculoNotaFiscal = 0; |
|
| - | 55 | private ProdutoDTO produtoDTOParaVinculoNotaFiscal; |
|
| - | 56 | ||
| - | 57 | private String chaveNotaFiscalParaReferenciaNotaFiscal = ""; |
|
| - | 58 | private NotaFiscalDTO notaFiscalDTOParaReferenciaNotaFiscal; |
|
| 42 | 59 | ||
| 43 | @Inject |
60 | @Inject |
| 44 | public NotaFiscalBean(NotaFiscalConsultaPorDemanda lazy, NotaFiscalService notaFiscalService, EmissorRelatorioService emissorRelatorioService) { |
- | |
| - | 61 | public NotaFiscalBean(NotaFiscalConsultaPorDemanda lazy, NotaFiscalService notaFiscalService, NotaFiscalProdutoService notaFiscalProdutoService, |
|
| - | 62 | NotaFiscalReferenciadaService notaFiscalReferenciadaService, ProdutoService produtoService, EmissorRelatorioService emissorRelatorioService) { |
|
| 45 | this.lazy = lazy; |
63 | this.lazy = lazy; |
| 46 | this.notaFiscalService = notaFiscalService; |
64 | this.notaFiscalService = notaFiscalService; |
| - | 65 | this.notaFiscalProdutoService = notaFiscalProdutoService; |
|
| - | 66 | this.notaFiscalReferenciadaService = notaFiscalReferenciadaService; |
|
| - | 67 | this.produtoService = produtoService; |
|
| 47 | this.emissorRelatorioService = emissorRelatorioService; |
68 | this.emissorRelatorioService = emissorRelatorioService; |
| 48 | }
|
69 | }
|
| 49 | 70 | ||
| 50 | @Override |
71 | @Override |
| 51 | public void preCarregamento() { |
72 | public void preCarregamento() { |
| Line 125... | Line 146... | ||
| 125 | public StreamedContent getDanfeNfe() { |
146 | public StreamedContent getDanfeNfe() { |
| 126 | return danfeNfe; |
147 | return danfeNfe; |
| 127 | }
|
148 | }
|
| 128 | public void setDanfeNfe(StreamedContent danfeNfe) { |
149 | public void setDanfeNfe(StreamedContent danfeNfe) { |
| 129 | this.danfeNfe = danfeNfe; |
150 | this.danfeNfe = danfeNfe; |
| - | 151 | }
|
|
| - | 152 | ||
| - | 153 | public String getCodigoProdutoParaVinculoNotaFiscal() { |
|
| - | 154 | return codigoProdutoParaVinculoNotaFiscal; |
|
| - | 155 | }
|
|
| - | 156 | public void setCodigoProdutoParaVinculoNotaFiscal(String codigoProdutoParaVinculoNotaFiscal) { |
|
| - | 157 | this.codigoProdutoParaVinculoNotaFiscal = codigoProdutoParaVinculoNotaFiscal; |
|
| - | 158 | }
|
|
| - | 159 | ||
| - | 160 | public Integer getQuantidadeProdutoParaVinculoNotaFiscal() { |
|
| - | 161 | return quantidadeProdutoParaVinculoNotaFiscal; |
|
| - | 162 | }
|
|
| - | 163 | public void setQuantidadeProdutoParaVinculoNotaFiscal(Integer quantidadeProdutoParaVinculoNotaFiscal) { |
|
| - | 164 | this.quantidadeProdutoParaVinculoNotaFiscal = quantidadeProdutoParaVinculoNotaFiscal; |
|
| - | 165 | }
|
|
| - | 166 | ||
| - | 167 | public ProdutoDTO getProdutoDTOParaVinculoNotaFiscal() { |
|
| - | 168 | return produtoDTOParaVinculoNotaFiscal; |
|
| - | 169 | }
|
|
| - | 170 | public void setProdutoDTOParaVinculoNotaFiscal(ProdutoDTO produtoDTOParaVinculoNotaFiscal) { |
|
| - | 171 | this.produtoDTOParaVinculoNotaFiscal = produtoDTOParaVinculoNotaFiscal; |
|
| - | 172 | }
|
|
| - | 173 | ||
| - | 174 | public String getChaveNotaFiscalParaReferenciaNotaFiscal() { |
|
| - | 175 | return chaveNotaFiscalParaReferenciaNotaFiscal; |
|
| - | 176 | }
|
|
| - | 177 | public void setChaveNotaFiscalParaReferenciaNotaFiscal(String chaveNotaFiscalParaReferenciaNotaFiscal) { |
|
| - | 178 | this.chaveNotaFiscalParaReferenciaNotaFiscal = chaveNotaFiscalParaReferenciaNotaFiscal; |
|
| - | 179 | }
|
|
| - | 180 | ||
| - | 181 | public NotaFiscalDTO getNotaFiscalDTOParaReferenciaNotaFiscal() { |
|
| - | 182 | return notaFiscalDTOParaReferenciaNotaFiscal; |
|
| - | 183 | }
|
|
| - | 184 | public void setNotaFiscalDTOParaReferenciaNotaFiscal(NotaFiscalDTO notaFiscalDTOParaReferenciaNotaFiscal) { |
|
| - | 185 | this.notaFiscalDTOParaReferenciaNotaFiscal = notaFiscalDTOParaReferenciaNotaFiscal; |
|
| 130 | }
|
186 | }
|
| 131 | 187 | ||
| 132 | /**************************************************/
|
188 | /**************************************************/
|
| 133 | 189 | ||
| 134 | public void desvincularVenda() { |
190 | public void desvincularVenda() { |
| Line 210... | Line 266... | ||
| 210 | getEntidade().setPessoaDestinatario(null); |
266 | getEntidade().setPessoaDestinatario(null); |
| 211 | }
|
267 | }
|
| 212 | 268 | ||
| 213 | public void consultarProdutosVinculados() { |
269 | public void consultarProdutosVinculados() { |
| 214 | getEntidade().setListaProdutosVinculadosDTO(notaFiscalService.consultarProdutosVinculados(getEntidade().getSequencial())); |
270 | getEntidade().setListaProdutosVinculadosDTO(notaFiscalService.consultarProdutosVinculados(getEntidade().getSequencial())); |
| - | 271 | }
|
|
| - | 272 | ||
| - | 273 | public void consultarNfReferenciadas() { |
|
| - | 274 | getEntidade().setListaNfeReferenciadasDTO(notaFiscalService.consultarNfReferenciadas(getEntidade().getSequencial())); |
|
| - | 275 | }
|
|
| - | 276 | ||
| - | 277 | public void excluirVinculoNotaFiscalProduto(NotaFiscalProdutoDTO notaFiscalProdutoDTO) { |
|
| - | 278 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
|
| - | 279 | public void execute() { |
|
| - | 280 | notaFiscalProdutoService.excluirNotaFiscalProduto(notaFiscalProdutoDTO); |
|
| - | 281 | consultarProdutosVinculados(); |
|
| - | 282 | LancadorMensagem.lancarSucesso("VÍNCULO EXCLUÍDO COM SUCESSO"); |
|
| - | 283 | }
|
|
| - | 284 | }); |
|
| - | 285 | }
|
|
| - | 286 | ||
| - | 287 | public void consultarProdutoParaVinculoNotaFiscal() { |
|
| - | 288 | setProdutoDTOParaVinculoNotaFiscal(produtoService.consultarProdutoDTOPorCodigoOuCodigoEAN(getCodigoProdutoParaVinculoNotaFiscal())); |
|
| - | 289 | }
|
|
| - | 290 | ||
| - | 291 | public void vinculoProdutoNaNotaFiscal() { |
|
| - | 292 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
|
| - | 293 | public void execute() { |
|
| - | 294 | notaFiscalProdutoService.vinculoProdutoNaNotaFiscal(getEntidade().getSequencial(), |
|
| - | 295 | getProdutoDTOParaVinculoNotaFiscal().getSequencial(), |
|
| - | 296 | getQuantidadeProdutoParaVinculoNotaFiscal()); |
|
| - | 297 | setCodigoProdutoParaVinculoNotaFiscal(""); |
|
| - | 298 | setProdutoDTOParaVinculoNotaFiscal(null); |
|
| - | 299 | setQuantidadeProdutoParaVinculoNotaFiscal(0); |
|
| - | 300 | consultarProdutosVinculados(); |
|
| - | 301 | LancadorMensagem.lancarSucesso("PRODUTO VINCULADO COM SUCESSO"); |
|
| - | 302 | }
|
|
| - | 303 | }); |
|
| - | 304 | }
|
|
| - | 305 | ||
| - | 306 | public void consultarNotaFiscalParaReferenciarNotaFiscal() { |
|
| - | 307 | setNotaFiscalDTOParaReferenciaNotaFiscal(notaFiscalService.consultarPorChave(getChaveNotaFiscalParaReferenciaNotaFiscal())); |
|
| - | 308 | }
|
|
| - | 309 | ||
| - | 310 | public void referenciarNotaFiscalNaNotaFiscal() { |
|
| - | 311 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
|
| - | 312 | public void execute() { |
|
| - | 313 | notaFiscalReferenciadaService.referenciarNotaFiscal(getEntidade().getSequencial(), getNotaFiscalDTOParaReferenciaNotaFiscal().getSequencialNotaFiscal()); |
|
| - | 314 | setChaveNotaFiscalParaReferenciaNotaFiscal(""); |
|
| - | 315 | setNotaFiscalDTOParaReferenciaNotaFiscal(null); |
|
| - | 316 | consultarNfReferenciadas(); |
|
| - | 317 | LancadorMensagem.lancarSucesso("NOTA FISCAL REFERENCIADA COM SUCESSO"); |
|
| - | 318 | }
|
|
| - | 319 | }); |
|
| - | 320 | }
|
|
| - | 321 | ||
| - | 322 | public void excluirNotaFiscalReferenciada(NotaFiscalReferenciadaDTO notaFiscalReferenciadaDTO) { |
|
| - | 323 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
|
| - | 324 | public void execute() { |
|
| - | 325 | notaFiscalReferenciadaService.excluirNotaFiscalReferenciada(notaFiscalReferenciadaDTO); |
|
| - | 326 | consultarNfReferenciadas(); |
|
| - | 327 | LancadorMensagem.lancarSucesso("REFERÊNCIA EXCLUÍDA COM SUCESSO"); |
|
| - | 328 | }
|
|
| - | 329 | }); |
|
| 215 | }
|
330 | }
|
| 216 | 331 | ||
| 217 | /*
|
332 | /*
|
| 218 | private StreamedContent chart;
|
333 | private StreamedContent chart;
|
| 219 | public StreamedContent getChart() {
|
334 | public StreamedContent getChart() {
|