Rev 624 | Go to most recent revision | Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 623 | blopes | 1 | package br.com.ec.controller; |
| 2 | |||
| 3 | import java.io.Serializable; |
||
| 4 | import java.util.ArrayList; |
||
| 5 | import java.util.Date; |
||
| 6 | import java.util.List; |
||
| 7 | |||
| 8 | import javax.inject.Inject; |
||
| 9 | import javax.inject.Named; |
||
| 10 | |||
| 11 | import org.springframework.context.annotation.Scope; |
||
| 12 | |||
| 13 | import br.com.ec.core.generic.GenericService; |
||
| 14 | import br.com.ec.core.util.DataUtils; |
||
| 15 | import br.com.ec.domain.dto.ClienteDTO; |
||
| 16 | import br.com.ec.domain.dto.ComercialPosVendaDTO; |
||
| 17 | import br.com.ec.domain.dto.PosVendaDTO; |
||
| 18 | import br.com.ec.domain.dto.VendaDTO; |
||
| 19 | import br.com.ec.domain.model.tipos.TipoPeriodoConsulta; |
||
| 20 | import br.com.ec.domain.service.PosVendaService; |
||
| 21 | import br.com.ec.domain.service.TransferenciaService; |
||
| 22 | import br.com.ec.web.exception.VerificadorLancamentoException; |
||
| 23 | import br.com.ec.web.exception.VerificadorLancamentoException.CommandBean; |
||
| 24 | import br.com.ec.web.generic.AbstractBean; |
||
| 25 | |||
| 26 | @Named |
||
| 27 | @Scope("view") |
||
| 28 | public class PosVendaBean extends AbstractBean<ComercialPosVendaDTO> implements Serializable { |
||
| 29 | |||
| 30 | private static final long serialVersionUID = 1L; |
||
| 31 | |||
| 32 | private PosVendaService posVendaService; |
||
| 33 | |||
| 34 | private PosVendaDTO posVendaSelecionado; |
||
| 35 | |||
| 36 | @Inject |
||
| 37 | public PosVendaBean(PosVendaService posVendaService) { |
||
| 38 | this.posVendaService = posVendaService; |
||
| 39 | } |
||
| 40 | |||
| 41 | @Override |
||
| 42 | public GenericService<ComercialPosVendaDTO> getService() { |
||
| 43 | return null; |
||
| 44 | } |
||
| 45 | |||
| 46 | @Override |
||
| 47 | public ComercialPosVendaDTO getId() { |
||
| 48 | return null; |
||
| 49 | } |
||
| 50 | |||
| 51 | @Override |
||
| 52 | public void preCarregamento() { |
||
| 53 | limparEntidade(); |
||
| 54 | } |
||
| 55 | |||
| 56 | @Override |
||
| 57 | public void limparEntidade() { |
||
| 58 | setEntidade(iniciarDados()); |
||
| 59 | } |
||
| 60 | |||
| 61 | public PosVendaDTO getPosVendaSelecionado() { |
||
| 62 | return posVendaSelecionado; |
||
| 63 | } |
||
| 64 | public void setPosVendaSelecionado(PosVendaDTO posVendaSelecionado) { |
||
| 65 | this.posVendaSelecionado = posVendaSelecionado; |
||
| 66 | } |
||
| 67 | |||
| 68 | /**************************************************/ |
||
| 69 | |||
| 70 | public TipoPeriodoConsulta[] getTiposPeriodoConsulta() { |
||
| 71 | return TipoPeriodoConsulta.values(); |
||
| 72 | } |
||
| 73 | |||
| 74 | /**************************************************/ |
||
| 75 | |||
| 76 | public void consultarPosVenda() { |
||
| 77 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 78 | public void execute() { |
||
| 79 | // iniciarDados(); |
||
| 80 | ComercialPosVendaDTO comercialDTO = new ComercialPosVendaDTO(); |
||
| 81 | List<PosVendaDTO> listaPosVendaDTO = new ArrayList<PosVendaDTO>(); |
||
| 82 | listaPosVendaDTO.addAll(posVendaService.consultarNaoFinalizadas()); |
||
| 83 | comercialDTO.setListaPosVenda(listaPosVendaDTO); |
||
| 84 | setEntidade(comercialDTO); |
||
| 85 | } |
||
| 86 | }); |
||
| 87 | } |
||
| 88 | |||
| 89 | public void selecionarPosVenda(PosVendaDTO posVenda/* , TipoPosVendaAtivacao tipoAtivacao */) { |
||
| 90 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 91 | public void execute() { |
||
| 92 | // CONSULTAR DETALHES BASEANDO-SE NO TIPO DE ATIVACAO |
||
| 93 | setPosVendaSelecionado(posVenda); |
||
| 94 | } |
||
| 95 | }); |
||
| 96 | } |
||
| 97 | |||
| 98 | private ComercialPosVendaDTO iniciarDados() { |
||
| 99 | ComercialPosVendaDTO comercialDTO = new ComercialPosVendaDTO(); |
||
| 100 | List<PosVendaDTO> listaPosVendaDTO = new ArrayList<PosVendaDTO>(); |
||
| 101 | listaPosVendaDTO.addAll(posVendaService.consultarNaoFinalizadas()); |
||
| 102 | comercialDTO.setListaPosVenda(listaPosVendaDTO); |
||
| 103 | return comercialDTO; |
||
| 104 | |||
| 105 | /* |
||
| 106 | ComercialPosVendaDTO comercialDTO = new ComercialPosVendaDTO(); |
||
| 107 | List<PosVendaDTO> listaPosVendaDTO = new ArrayList<PosVendaDTO>(); |
||
| 108 | |||
| 109 | PosVendaDTO posVendaDTO = new PosVendaDTO(); |
||
| 110 | VendaDTO vendaDTO = new VendaDTO(); |
||
| 111 | vendaDTO.setSequencial(new Long(123456)); |
||
| 112 | Date data = DataUtils.acrescentarDias(new Date(), -5); |
||
| 113 | vendaDTO.setDataVenda(data); |
||
| 114 | ClienteDTO clienteDTO = new ClienteDTO(); |
||
| 115 | clienteDTO.setNome("BRUNO LOPES PEIXOTO"); |
||
| 116 | clienteDTO.setCpfCnpj("06256954459"); |
||
| 117 | clienteDTO.setContato("82996062514"); |
||
| 118 | vendaDTO.setCliente(clienteDTO); |
||
| 119 | posVendaDTO.setVendaDTO(vendaDTO); |
||
| 120 | posVendaDTO.setDataCadastro(data); |
||
| 121 | listaPosVendaDTO.add(posVendaDTO); |
||
| 122 | |||
| 123 | posVendaDTO = new PosVendaDTO(); |
||
| 124 | vendaDTO = new VendaDTO(); |
||
| 125 | vendaDTO.setSequencial(new Long(321654)); |
||
| 126 | vendaDTO.setDataVenda(new Date()); |
||
| 127 | clienteDTO = new ClienteDTO(); |
||
| 128 | clienteDTO.setNome("BÁRBARA ALVES"); |
||
| 129 | clienteDTO.setCpfCnpj("01234567890"); |
||
| 130 | clienteDTO.setContato("8299990000"); |
||
| 131 | vendaDTO.setCliente(clienteDTO); |
||
| 132 | posVendaDTO.setVendaDTO(vendaDTO); |
||
| 133 | posVendaDTO.setDataCadastro(new Date()); |
||
| 134 | listaPosVendaDTO.add(posVendaDTO); |
||
| 135 | |||
| 136 | comercialDTO.setListaPosVenda(listaPosVendaDTO); |
||
| 137 | |||
| 138 | return comercialDTO; |
||
| 139 | */ |
||
| 140 | } |
||
| 141 | |||
| 142 | public void efetivarTransferencias() { |
||
| 143 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 144 | public void execute() { |
||
| 145 | } |
||
| 146 | }); |
||
| 147 | } |
||
| 148 | |||
| 149 | } |