Rev 195 | Details | Compare with Previous | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 106 | espaco | 1 | package br.com.ec.controller.managedbean; |
| 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 | |||
| 195 | espaco | 10 | import br.com.ec.core.generic.GenericService; |
| 11 | import br.com.ec.core.util.DataUtils; |
||
| 12 | import br.com.ec.core.util.VerificadorUtil; |
||
| 106 | espaco | 13 | import br.com.ec.domain.dto.ParametrosFecharCaixaDTO; |
| 14 | import br.com.ec.domain.model.Loja; |
||
| 15 | import br.com.ec.domain.service.fecharcaixa.FecharCaixaService; |
||
| 16 | import br.com.ec.domain.service.loja.LojaService; |
||
| 195 | espaco | 17 | import br.com.ec.web.generic.AbstractBean; |
| 106 | espaco | 18 | |
| 19 | @Named |
||
| 20 | @Scope("view") |
||
| 21 | public class FecharCaixaBean extends AbstractBean<ParametrosFecharCaixaDTO> implements Serializable { |
||
| 22 | |||
| 23 | private static final long serialVersionUID = 1L; |
||
| 24 | |||
| 25 | private ParametrosFecharCaixaDTO parametrosFecharCaixaDTO; |
||
| 26 | |||
| 27 | private Loja lojaSelecionada; |
||
| 28 | |||
| 29 | private FecharCaixaService fecharCaixaService; |
||
| 30 | private LojaService lojaService; |
||
| 31 | |||
| 32 | @Inject |
||
| 33 | public FecharCaixaBean(FecharCaixaService fecharCaixaService, LojaService lojaService) { |
||
| 34 | this.fecharCaixaService = fecharCaixaService; |
||
| 35 | this.lojaService = lojaService; |
||
| 36 | } |
||
| 37 | |||
| 38 | @Override |
||
| 39 | public void preCarregamento() { |
||
| 40 | limparEntidade(); |
||
| 41 | } |
||
| 42 | |||
| 43 | @Override |
||
| 44 | public void limparEntidade() { |
||
| 45 | parametrosFecharCaixaDTO = new ParametrosFecharCaixaDTO(); |
||
| 46 | parametrosFecharCaixaDTO.setDataVendas(DataUtils.getDataAtual()); |
||
| 47 | parametrosFecharCaixaDTO.setLoja(getLojaSelecionada()); |
||
| 48 | } |
||
| 49 | |||
| 50 | @Override |
||
| 51 | public GenericService<ParametrosFecharCaixaDTO> getService() { |
||
| 52 | return fecharCaixaService; |
||
| 53 | } |
||
| 54 | |||
| 55 | @Override |
||
| 56 | public ParametrosFecharCaixaDTO getId() { |
||
| 57 | return null; |
||
| 58 | } |
||
| 59 | |||
| 60 | public ParametrosFecharCaixaDTO getParametrosFecharCaixaDTO() { |
||
| 61 | return parametrosFecharCaixaDTO; |
||
| 62 | } |
||
| 63 | public void setParametrosFecharCaixaDTO(ParametrosFecharCaixaDTO parametrosFecharCaixaDTO) { |
||
| 64 | this.parametrosFecharCaixaDTO = parametrosFecharCaixaDTO; |
||
| 65 | } |
||
| 66 | |||
| 67 | public Loja getLojaSelecionada() { |
||
| 68 | if (VerificadorUtil.estaNulo(lojaSelecionada)) { |
||
| 69 | Loja loja = new Loja(); |
||
| 70 | loja.setSequencial(new Long(getParametro("sequencialLoja").toString())); |
||
| 71 | lojaSelecionada = lojaService.consultarPorId(loja); |
||
| 72 | } |
||
| 73 | return lojaSelecionada; |
||
| 74 | } |
||
| 75 | public void setLojaSelecionada(Loja lojaSelecionada) { |
||
| 76 | this.lojaSelecionada = lojaSelecionada; |
||
| 77 | } |
||
| 78 | |||
| 79 | public void prepararFechamentoCaixa(Loja loja) { |
||
| 80 | getParametrosFecharCaixaDTO().setLoja(getLojaSelecionada()); |
||
| 81 | setParametrosFecharCaixaDTO(fecharCaixaService.iniciarFechamentoCaixa(getParametrosFecharCaixaDTO())); |
||
| 82 | } |
||
| 83 | |||
| 84 | public void realizarFechamentoDoCaixa() { |
||
| 85 | fecharCaixaService.realizarFechamentoDoCaixa(getParametrosFecharCaixaDTO().getListaVendas()); |
||
| 337 | espaco | 86 | fecharCaixaService.enviarEmailResumoDoDia(getParametrosFecharCaixaDTO().getDataVendas(), getLojaSelecionada()); |
| 106 | espaco | 87 | limparEntidade(); |
| 88 | } |
||
| 89 | |||
| 90 | } |