Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 1 | espaco | 1 | package br.com.ec.controller.managedbean; |
| 2 | |||
| 3 | import java.io.Serializable; |
||
| 4 | import java.util.List; |
||
| 5 | |||
| 6 | import javax.inject.Inject; |
||
| 7 | import javax.inject.Named; |
||
| 8 | |||
| 9 | import org.springframework.context.annotation.Scope; |
||
| 10 | |||
| 11 | import br.com.ec.domain.model.Cliente; |
||
| 12 | import br.com.ec.domain.model.EstoqueAuditoria; |
||
| 13 | import br.com.ec.domain.model.Loja; |
||
| 14 | import br.com.ec.domain.service.cliente.ClienteService; |
||
| 15 | import br.com.ec.domain.service.estoqueauditoria.EstoqueAuditoriaService; |
||
| 16 | import br.com.ec.domain.service.loja.LojaService; |
||
| 17 | import br.edu.cesmac.core.consulta.ParametrosConsulta; |
||
| 18 | import br.edu.cesmac.core.generic.GenericService; |
||
| 19 | import br.edu.cesmac.core.util.VerificadorUtil; |
||
| 20 | import br.edu.cesmac.web.exception.VerificadorLancamentoException; |
||
| 21 | import br.edu.cesmac.web.exception.VerificadorLancamentoException.CommandBean; |
||
| 22 | import br.edu.cesmac.web.generic.AbstractBean; |
||
| 23 | |||
| 24 | @Named |
||
| 25 | @Scope("view") |
||
| 26 | public class InformarTrocaBean extends AbstractBean<EstoqueAuditoria> implements Serializable { |
||
| 27 | |||
| 28 | private static final long serialVersionUID = 1L; |
||
| 29 | |||
| 30 | private Loja lojaSelecionada; |
||
| 31 | private String cpfCliente; |
||
| 32 | |||
| 33 | private List<EstoqueAuditoria> listaTrocasDoDia; |
||
| 34 | private List<EstoqueAuditoria> listaDevolucoesDoDia; |
||
| 35 | |||
| 36 | private EstoqueAuditoriaService estoqueAuditoriaService; |
||
| 37 | private LojaService lojaService; |
||
| 38 | private ClienteService clienteService; |
||
| 39 | |||
| 40 | @Inject |
||
| 41 | public InformarTrocaBean(EstoqueAuditoriaService estoqueAuditoriaService, LojaService lojaService, ClienteService clienteService) { |
||
| 42 | this.estoqueAuditoriaService = estoqueAuditoriaService; |
||
| 43 | this.lojaService = lojaService; |
||
| 44 | this.clienteService = clienteService; |
||
| 45 | } |
||
| 46 | |||
| 47 | @Override |
||
| 48 | public void preCarregamento() { |
||
| 49 | if (VerificadorUtil.estaNulo(parametrosConsulta)) { |
||
| 50 | entidade = new EstoqueAuditoria(); |
||
| 51 | parametrosConsulta = new ParametrosConsulta<EstoqueAuditoria>(); |
||
| 52 | parametrosConsulta.setEntidade(entidade); |
||
| 53 | setListaTrocasDoDia(estoqueAuditoriaService.consultarTrocasDoDia(getLojaSelecionada())); |
||
| 54 | setListaDevolucoesDoDia(estoqueAuditoriaService.consultarDevolucoesDoDia(getLojaSelecionada())); |
||
| 55 | } |
||
| 56 | } |
||
| 57 | |||
| 58 | @Override |
||
| 59 | public void limparEntidade() { |
||
| 60 | setEntidade(new EstoqueAuditoria()); |
||
| 61 | } |
||
| 62 | |||
| 63 | @Override |
||
| 64 | public GenericService<EstoqueAuditoria> getService() { |
||
| 65 | return estoqueAuditoriaService; |
||
| 66 | } |
||
| 67 | |||
| 68 | @Override |
||
| 69 | public EstoqueAuditoria getEntidade() { |
||
| 70 | return entidade; |
||
| 71 | } |
||
| 72 | |||
| 73 | @Override |
||
| 74 | public EstoqueAuditoria getId() { |
||
| 75 | return getEntidade(); |
||
| 76 | } |
||
| 77 | |||
| 78 | public Loja getLojaSelecionada() { |
||
| 79 | if (VerificadorUtil.estaNulo(lojaSelecionada)) { |
||
| 80 | Loja loja = new Loja(); |
||
| 81 | loja.setSequencial(new Long(getParametro("sequencialLoja").toString())); |
||
| 82 | lojaSelecionada = lojaService.consultarPorId(loja); |
||
| 83 | } |
||
| 84 | return lojaSelecionada; |
||
| 85 | } |
||
| 86 | public void setLojaSelecionada(Loja lojaSelecionada) { |
||
| 87 | this.lojaSelecionada = lojaSelecionada; |
||
| 88 | } |
||
| 89 | |||
| 90 | public String getCpfCliente() { |
||
| 91 | return VerificadorUtil.naoEstaNulo(cpfCliente)? cpfCliente.replace(".", "").replace("-", "") : cpfCliente; |
||
| 92 | } |
||
| 93 | public void setCpfCliente(String cpfCliente) { |
||
| 94 | this.cpfCliente = cpfCliente; |
||
| 95 | } |
||
| 96 | |||
| 97 | public List<EstoqueAuditoria> getListaTrocasDoDia() { |
||
| 98 | return listaTrocasDoDia; |
||
| 99 | } |
||
| 100 | public void setListaTrocasDoDia(List<EstoqueAuditoria> listaTrocasDoDia) { |
||
| 101 | this.listaTrocasDoDia = listaTrocasDoDia; |
||
| 102 | } |
||
| 103 | |||
| 104 | public List<EstoqueAuditoria> getListaDevolucoesDoDia() { |
||
| 105 | return listaDevolucoesDoDia; |
||
| 106 | } |
||
| 107 | public void setListaDevolucoesDoDia(List<EstoqueAuditoria> listaDevolucoesDoDia) { |
||
| 108 | this.listaDevolucoesDoDia = listaDevolucoesDoDia; |
||
| 109 | } |
||
| 110 | |||
| 111 | public void selecionarCliente(final Cliente cliente) { |
||
| 112 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 113 | public void execute() { |
||
| 114 | cliente.setAtivo(true); |
||
| 115 | clienteService.alterar(cliente); |
||
| 116 | getEntidade().setCliente(clienteService.consultarClientePorCpfCnpj(cliente.getCpfCnpj())); |
||
| 117 | setCpfCliente(null); |
||
| 118 | adicionandoParametroArgsConfirmandoAcao(true); |
||
| 119 | } |
||
| 120 | }); |
||
| 121 | } |
||
| 122 | |||
| 123 | public void retirarCliente() { |
||
| 124 | getEntidade().setCliente(null); |
||
| 125 | } |
||
| 126 | |||
| 127 | } |