Rev 353 | Rev 413 | 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; |
||
| 4 | |||
| 5 | import javax.inject.Inject; |
||
| 6 | import javax.inject.Named; |
||
| 7 | |||
| 8 | import org.springframework.context.annotation.Scope; |
||
| 9 | |||
| 10 | import br.com.ec.controller.consultademanda.NotaFiscalConsultaPorDemanda; |
||
| 11 | import br.com.ec.core.generic.GenericService; |
||
| 12 | import br.com.ec.domain.dto.consulta.ParametrosConsultaNotaFiscal; |
||
| 13 | import br.com.ec.domain.model.NotaFiscal; |
||
| 14 | import br.com.ec.domain.model.Papel; |
||
| 15 | import br.com.ec.domain.model.nfe.TipoNotaFiscal; |
||
| 16 | import br.com.ec.domain.service.NotaFiscalService; |
||
| 17 | import br.com.ec.web.exception.VerificadorLancamentoException; |
||
| 18 | import br.com.ec.web.exception.VerificadorLancamentoException.CommandBean; |
||
| 19 | import br.com.ec.web.generic.AbstractBean; |
||
| 20 | import br.com.ec.web.message.LancadorMensagem; |
||
| 21 | import br.com.ec.web.util.TipoOperacao; |
||
| 369 | espaco | 22 | import br.com.swconsultoria.nfe.Nfe; |
| 23 | import br.com.swconsultoria.nfe.dom.ConfiguracoesNfe; |
||
| 24 | import br.com.swconsultoria.nfe.dom.enuns.*; |
||
| 25 | import br.com.swconsultoria.nfe.exception.NfeException; |
||
| 26 | import br.com.swconsultoria.nfe.schema.envEventoCancNFe.TEnvEvento; |
||
| 27 | import br.com.swconsultoria.nfe.schema.envEventoCancNFe.TRetEnvEvento; |
||
| 28 | import br.com.swconsultoria.nfe.schema.retConsCad.TRetConsCad; |
||
| 29 | import br.com.swconsultoria.nfe.schema.retdistdfeint.RetDistDFeInt; |
||
| 30 | import br.com.swconsultoria.nfe.schema_4.enviNFe.TEnviNFe; |
||
| 31 | import br.com.swconsultoria.nfe.schema_4.enviNFe.TRetEnviNFe; |
||
| 32 | import br.com.swconsultoria.nfe.schema_4.inutNFe.TInutNFe; |
||
| 33 | import br.com.swconsultoria.nfe.schema_4.inutNFe.TRetInutNFe; |
||
| 34 | import br.com.swconsultoria.nfe.schema_4.retConsReciNFe.TRetConsReciNFe; |
||
| 35 | import br.com.swconsultoria.nfe.schema_4.retConsSitNFe.TRetConsSitNFe; |
||
| 36 | import br.com.swconsultoria.nfe.schema_4.retConsStatServ.TRetConsStatServ; |
||
| 37 | import br.com.swconsultoria.nfe.util.ConfiguracoesUtil; |
||
| 353 | espaco | 38 | |
| 39 | @Named |
||
| 40 | @Scope("view") |
||
| 41 | public class NotaFiscalBean extends AbstractBean<NotaFiscal> implements Serializable { |
||
| 42 | |||
| 43 | private static final long serialVersionUID = 1L; |
||
| 44 | |||
| 45 | private NotaFiscalService notaFiscalService; |
||
| 46 | |||
| 47 | private ParametrosConsultaNotaFiscal parametrosConsultaNotaFiscal; |
||
| 48 | private NotaFiscalConsultaPorDemanda lazy; |
||
| 49 | |||
| 50 | private Long sequencialVendaParaVinculo; |
||
| 51 | |||
| 52 | @Inject |
||
| 53 | public NotaFiscalBean(NotaFiscalConsultaPorDemanda lazy, NotaFiscalService notaFiscalService) { |
||
| 54 | this.lazy = lazy; |
||
| 55 | this.notaFiscalService = notaFiscalService; |
||
| 56 | } |
||
| 57 | |||
| 58 | @Override |
||
| 59 | public void preCarregamento() { |
||
| 60 | parametrosConsultaNotaFiscal = new ParametrosConsultaNotaFiscal(); |
||
| 61 | prepararConsultaDemanda(); |
||
| 62 | limparEntidade(); |
||
| 63 | } |
||
| 64 | |||
| 65 | @Override |
||
| 66 | public void limparEntidade() { |
||
| 67 | setEntidade(new NotaFiscal()); |
||
| 68 | } |
||
| 69 | |||
| 70 | @Override |
||
| 71 | public GenericService<NotaFiscal> getService() { |
||
| 72 | return notaFiscalService; |
||
| 73 | } |
||
| 74 | |||
| 75 | @Override |
||
| 76 | public NotaFiscal getEntidade() { |
||
| 77 | return entidade; |
||
| 78 | } |
||
| 79 | |||
| 80 | @Override |
||
| 81 | public void preConsultar() { |
||
| 82 | setTipoOperacao(TipoOperacao.CONSULTAR); |
||
| 83 | } |
||
| 84 | |||
| 85 | @Override |
||
| 86 | public NotaFiscal getId() { |
||
| 87 | return getEntidade(); |
||
| 88 | } |
||
| 89 | |||
| 90 | public ParametrosConsultaNotaFiscal getParametrosConsultaNotaFiscal() { |
||
| 91 | return parametrosConsultaNotaFiscal; |
||
| 92 | } |
||
| 93 | public void setParametrosConsultaNotaFiscal(ParametrosConsultaNotaFiscal parametrosConsultaNotaFiscal) { |
||
| 94 | this.parametrosConsultaNotaFiscal = parametrosConsultaNotaFiscal; |
||
| 95 | } |
||
| 96 | |||
| 97 | public NotaFiscalConsultaPorDemanda getLazy() { |
||
| 98 | return lazy; |
||
| 99 | } |
||
| 100 | public void setLazy(NotaFiscalConsultaPorDemanda lazy) { |
||
| 101 | this.lazy = lazy; |
||
| 102 | } |
||
| 103 | public void prepararConsultaDemanda() { |
||
| 104 | lazy.setarParametrosConsulta(getParametrosConsultaNotaFiscal()); |
||
| 105 | } |
||
| 106 | |||
| 107 | public TipoNotaFiscal[] getTiposNotaFiscal() { |
||
| 108 | return TipoNotaFiscal.values(); |
||
| 109 | } |
||
| 110 | |||
| 111 | public Long getSequencialVendaParaVinculo() { |
||
| 112 | return sequencialVendaParaVinculo; |
||
| 113 | } |
||
| 114 | public void setSequencialVendaParaVinculo(Long sequencialVendaParaVinculo) { |
||
| 115 | this.sequencialVendaParaVinculo = sequencialVendaParaVinculo; |
||
| 116 | } |
||
| 117 | |||
| 118 | /**************************************************/ |
||
| 119 | |||
| 120 | public void desvincularVenda() { |
||
| 121 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 122 | public void execute() { |
||
| 123 | // pessoaPapelService.adicionarPapel(getEntidade().getPessoa(), new Papel(getPessoaPapelDTO().getCodigoPapel())); |
||
| 124 | // getEntidadeDTO().setPapeisDTO(pessoaPapelService.consultarPapeisDaPessoa(getPessoaPapelDTO().getSequencialPessoa())); |
||
| 125 | LancadorMensagem.lancarSucesso("VENDA DESVINCULADA COM SUCESSO"); |
||
| 126 | } |
||
| 127 | }); |
||
| 128 | } |
||
| 129 | |||
| 130 | public void vincularVenda() { |
||
| 131 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 132 | public void execute() { |
||
| 133 | // pessoaPapelService.adicionarPapel(getEntidade().getPessoa(), new Papel(getPessoaPapelDTO().getCodigoPapel())); |
||
| 134 | // getEntidadeDTO().setPapeisDTO(pessoaPapelService.consultarPapeisDaPessoa(getPessoaPapelDTO().getSequencialPessoa())); |
||
| 135 | LancadorMensagem.lancarSucesso("VENDA VINCULADA COM SUCESSO"); |
||
| 136 | } |
||
| 137 | }); |
||
| 138 | } |
||
| 139 | |||
| 140 | } |