Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 200 | espaco | 1 | package br.com.ec.controller.managedbean; |
| 2 | |||
| 3 | import java.io.Serializable; |
||
| 4 | import java.util.ArrayList; |
||
| 5 | import java.util.List; |
||
| 6 | |||
| 7 | import javax.inject.Inject; |
||
| 8 | import javax.inject.Named; |
||
| 9 | |||
| 10 | import org.springframework.context.annotation.Scope; |
||
| 11 | |||
| 12 | import br.com.ec.controller.managedbean.consultademanda.VendaConsultaPorDemanda; |
||
| 13 | import br.com.ec.core.generic.GenericService; |
||
| 14 | import br.com.ec.core.util.VerificadorUtil; |
||
| 15 | import br.com.ec.domain.dto.ParametrosConsultaVendasDTO; |
||
| 16 | import br.com.ec.domain.dto.VendasDTO; |
||
| 17 | import br.com.ec.domain.model.BandeiraCartao; |
||
| 18 | import br.com.ec.domain.model.FormaPagamento; |
||
| 19 | import br.com.ec.domain.model.Lancamento; |
||
| 20 | import br.com.ec.domain.model.Loja; |
||
| 21 | import br.com.ec.domain.model.Venda; |
||
| 22 | import br.com.ec.domain.service.bandeiracartao.BandeiraCartaoService; |
||
| 23 | import br.com.ec.domain.service.formapagamento.FormaPagamentoService; |
||
| 24 | import br.com.ec.domain.service.lancamento.LancamentoService; |
||
| 25 | import br.com.ec.domain.service.loja.LojaService; |
||
| 26 | import br.com.ec.domain.service.venda.VendaService; |
||
| 27 | import br.com.ec.web.generic.AbstractBean; |
||
| 28 | |||
| 29 | @Named |
||
| 30 | @Scope("view") |
||
| 31 | public class VendasConsultaBean extends AbstractBean<Venda> implements Serializable { |
||
| 32 | |||
| 33 | private static final long serialVersionUID = 1L; |
||
| 34 | |||
| 35 | private ParametrosConsultaVendasDTO parametrosConsultaVendasDTO; |
||
| 36 | |||
| 37 | private VendaConsultaPorDemanda lazy; |
||
| 38 | private List<VendasDTO> vendas; |
||
| 39 | private List<Lancamento> lancamentosComDesconto; |
||
| 40 | private List<FormaPagamento> formasDePagamento; |
||
| 41 | private List<BandeiraCartao> bandeirasDeCartao; |
||
| 42 | |||
| 43 | private VendaService vendaService; |
||
| 44 | private LancamentoService lancamentoService; |
||
| 45 | private LojaService lojaService; |
||
| 46 | private FormaPagamentoService formaPagamentoService; |
||
| 47 | private BandeiraCartaoService bandeiraCartaoService; |
||
| 48 | |||
| 49 | @Inject |
||
| 50 | public VendasConsultaBean(VendaConsultaPorDemanda lazy, VendaService vendaService, LancamentoService lancamentoService, LojaService lojaService, |
||
| 51 | FormaPagamentoService formaPagamentoService, BandeiraCartaoService bandeiraCartaoService) { |
||
| 52 | this.lazy = lazy; |
||
| 53 | this.vendaService = vendaService; |
||
| 54 | this.lancamentoService = lancamentoService; |
||
| 55 | this.lojaService = lojaService; |
||
| 56 | this.formaPagamentoService = formaPagamentoService; |
||
| 57 | this.bandeiraCartaoService = bandeiraCartaoService; |
||
| 58 | } |
||
| 59 | |||
| 60 | @Override |
||
| 61 | public void preCarregamento() { |
||
| 62 | entidade = new Venda(); |
||
| 63 | parametrosConsultaVendasDTO = new ParametrosConsultaVendasDTO(); |
||
| 64 | parametrosConsultaVendasDTO.setEntidade(entidade); |
||
| 65 | |||
| 66 | if (VerificadorUtil.naoEstaNulo(getParametro("sequencialLoja"))) { |
||
| 67 | Loja loja = new Loja(); |
||
| 68 | loja.setSequencial(new Long(getParametro("sequencialLoja").toString())); |
||
| 69 | parametrosConsultaVendasDTO.setLoja(lojaService.consultarPorId(loja)); |
||
| 70 | } |
||
| 71 | |||
| 72 | prepararConsultaDemanda(); |
||
| 73 | setVendas(new ArrayList<VendasDTO>()); |
||
| 74 | // setLancamentosComDesconto(lancamentoService.consultarLancamentosComDescontos(DataUtils.getDataAtual(), DataUtils.getDataAtual())); |
||
| 75 | } |
||
| 76 | |||
| 77 | @Override |
||
| 78 | public void limparEntidade() { |
||
| 79 | setEntidade(new Venda()); |
||
| 80 | } |
||
| 81 | |||
| 82 | @Override |
||
| 83 | public GenericService<Venda> getService() { |
||
| 84 | return vendaService; |
||
| 85 | } |
||
| 86 | |||
| 87 | @Override |
||
| 88 | public Venda getEntidade() { |
||
| 89 | return entidade; |
||
| 90 | } |
||
| 91 | |||
| 92 | @Override |
||
| 93 | public Venda getId() { |
||
| 94 | return getEntidade(); |
||
| 95 | } |
||
| 96 | |||
| 97 | public ParametrosConsultaVendasDTO getParametrosConsultaVendasDTO() { |
||
| 98 | return parametrosConsultaVendasDTO; |
||
| 99 | } |
||
| 100 | public void setParametrosConsultaVendasDTO(ParametrosConsultaVendasDTO parametrosConsultaVendasDTO) { |
||
| 101 | this.parametrosConsultaVendasDTO = parametrosConsultaVendasDTO; |
||
| 102 | } |
||
| 103 | |||
| 104 | public VendaConsultaPorDemanda getLazy() { |
||
| 105 | return lazy; |
||
| 106 | } |
||
| 107 | public void setLazy(VendaConsultaPorDemanda lazy) { |
||
| 108 | this.lazy = lazy; |
||
| 109 | } |
||
| 110 | public void prepararConsultaDemanda() { |
||
| 111 | lazy.setarParametrosConsulta(getParametrosConsultaVendasDTO()); |
||
| 112 | } |
||
| 113 | |||
| 114 | public List<Lancamento> getLancamentosComDesconto() { |
||
| 115 | return lancamentosComDesconto; |
||
| 116 | } |
||
| 117 | public void setLancamentosComDesconto(List<Lancamento> lancamentosComDesconto) { |
||
| 118 | this.lancamentosComDesconto = lancamentosComDesconto; |
||
| 119 | } |
||
| 120 | |||
| 121 | public List<FormaPagamento> getFormasDePagamento() { |
||
| 122 | if (VerificadorUtil.estaNulo(formasDePagamento)) { |
||
| 123 | setFormasDePagamento(formaPagamentoService.listarFormasPagamentoAtivas()); |
||
| 124 | } |
||
| 125 | return formasDePagamento; |
||
| 126 | } |
||
| 127 | public void setFormasDePagamento(List<FormaPagamento> formasDePagamento) { |
||
| 128 | this.formasDePagamento = formasDePagamento; |
||
| 129 | } |
||
| 130 | |||
| 131 | public List<BandeiraCartao> getBandeirasDeCartao() { |
||
| 132 | if (VerificadorUtil.estaNulo(bandeirasDeCartao)) { |
||
| 133 | List<BandeiraCartao> bandeiras = new ArrayList<BandeiraCartao>(); |
||
| 134 | bandeiras.addAll(bandeiraCartaoService.consultarBandeiraCartoesDeDebito()); |
||
| 135 | bandeiras.addAll(bandeiraCartaoService.consultarBandeiraCartoesDeCredito()); |
||
| 136 | setBandeirasDeCartao(bandeiras); |
||
| 137 | } |
||
| 138 | return bandeirasDeCartao; |
||
| 139 | } |
||
| 140 | public void setBandeirasDeCartao(List<BandeiraCartao> bandeirasDeCartao) { |
||
| 141 | this.bandeirasDeCartao = bandeirasDeCartao; |
||
| 142 | } |
||
| 143 | |||
| 144 | public Double getTotalVendas() { |
||
| 145 | return vendaService.obterValorTotalBrutoDeVendasPorLojaEePeriodo(getParametrosConsultaVendasDTO()); |
||
| 146 | } |
||
| 147 | |||
| 148 | public List<VendasDTO> getVendas() { |
||
| 149 | return vendas; |
||
| 150 | } |
||
| 151 | public void setVendas(List<VendasDTO> vendas) { |
||
| 152 | this.vendas = vendas; |
||
| 153 | } |
||
| 154 | |||
| 155 | /***************************************************************/ |
||
| 156 | |||
| 157 | public void consultarVendas() { |
||
| 158 | setVendas(vendaService.consultarVendas(getParametrosConsultaVendasDTO())); |
||
| 159 | } |
||
| 160 | |||
| 161 | } |