Rev 195 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 195 | Rev 597 | ||
|---|---|---|---|
| Line 2... | Line 2... | ||
| 2 | 2 | ||
| 3 | import java.io.Serializable; |
3 | import java.io.Serializable; |
| - | 4 | import java.util.List; |
|
| 4 | 5 | ||
| 5 | import javax.inject.Inject; |
6 | import javax.inject.Inject; |
| 6 | import javax.inject.Named; |
7 | import javax.inject.Named; |
| 7 | 8 | ||
| 8 | import org.springframework.context.annotation.Scope; |
9 | import org.springframework.context.annotation.Scope; |
| 9 | 10 | ||
| 10 | import br.com.ec.core.generic.GenericService; |
11 | import br.com.ec.core.generic.GenericService; |
| 11 | import br.com.ec.core.util.DataUtils; |
12 | import br.com.ec.core.util.DataUtils; |
| 12 | import br.com.ec.domain.dto.ParametrosFecharCaixaDTO; |
13 | import br.com.ec.domain.dto.ParametrosFecharCaixaDTO; |
| 13 | import br.com.ec.domain.dto.ParametrosReceberCaixaDTO; |
14 | import br.com.ec.domain.dto.ParametrosReceberCaixaDTO; |
| - | 15 | import br.com.ec.domain.model.Conta; |
|
| - | 16 | import br.com.ec.domain.model.ContaBancaria; |
|
| 14 | import br.com.ec.domain.model.Loja; |
17 | import br.com.ec.domain.model.Loja; |
| - | 18 | import br.com.ec.domain.model.Pagamento; |
|
| - | 19 | import br.com.ec.domain.model.Parcela; |
|
| 15 | import br.com.ec.domain.model.Venda; |
20 | import br.com.ec.domain.model.Venda; |
| - | 21 | import br.com.ec.domain.model.tipos.TipoConta; |
|
| - | 22 | import br.com.ec.domain.model.tipos.TipoFrequencia; |
|
| 16 | import br.com.ec.domain.model.tipos.TipoSituacaoVenda; |
23 | import br.com.ec.domain.model.tipos.TipoSituacaoVenda; |
| 17 | import br.com.ec.domain.service.automatizador.AutomatizadorService; |
24 | import br.com.ec.domain.service.automatizador.AutomatizadorService; |
| 18 | import br.com.ec.domain.service.fecharcaixa.FecharCaixaService; |
25 | import br.com.ec.domain.service.fecharcaixa.FecharCaixaService; |
| - | 26 | import br.com.ec.domain.service.pagamento.PagamentoService; |
|
| - | 27 | import br.com.ec.domain.service.parcela.ParcelaService; |
|
| 19 | import br.com.ec.domain.service.venda.VendaService; |
28 | import br.com.ec.domain.service.venda.VendaService; |
| - | 29 | import br.com.ec.domain.service.vigencia.VigenciaService; |
|
| - | 30 | import br.com.ec.domain.shared.ConstantesSEC; |
|
| 20 | import br.com.ec.web.exception.VerificadorLancamentoException; |
31 | import br.com.ec.web.exception.VerificadorLancamentoException; |
| 21 | import br.com.ec.web.exception.VerificadorLancamentoException.CommandBean; |
32 | import br.com.ec.web.exception.VerificadorLancamentoException.CommandBean; |
| 22 | import br.com.ec.web.generic.AbstractBean; |
33 | import br.com.ec.web.generic.AbstractBean; |
| 23 | import br.com.ec.web.message.LancadorMensagem; |
34 | import br.com.ec.web.message.LancadorMensagem; |
| 24 | 35 | ||
| Line 29... | Line 40... | ||
| 29 | private static final long serialVersionUID = 1L; |
40 | private static final long serialVersionUID = 1L; |
| 30 | 41 | ||
| 31 | private AutomatizadorService automatizadorService; |
42 | private AutomatizadorService automatizadorService; |
| 32 | private FecharCaixaService fecharCaixaService; |
43 | private FecharCaixaService fecharCaixaService; |
| 33 | private VendaService vendaService; |
44 | private VendaService vendaService; |
| - | 45 | private ParcelaService parcelaService; |
|
| - | 46 | private PagamentoService pagamentoService; |
|
| - | 47 | private VigenciaService vigenciaService; |
|
| 34 | 48 | ||
| 35 | private ParametrosReceberCaixaDTO parametrosReceberCaixa; |
49 | private ParametrosReceberCaixaDTO parametrosReceberCaixa; |
| 36 | private ParametrosFecharCaixaDTO parametrosFecharCaixa; |
50 | private ParametrosFecharCaixaDTO parametrosFecharCaixa; |
| 37 | 51 | ||
| 38 | @Inject |
52 | @Inject |
| 39 | public ReceberCaixaBean(AutomatizadorService automatizadorService, FecharCaixaService fecharCaixaService, VendaService vendaService) { |
- | |
| - | 53 | public ReceberCaixaBean(AutomatizadorService automatizadorService, FecharCaixaService fecharCaixaService, VendaService vendaService, |
|
| - | 54 | ParcelaService parcelaService, PagamentoService pagamentoService, VigenciaService vigenciaService) { |
|
| 40 | this.automatizadorService = automatizadorService; |
55 | this.automatizadorService = automatizadorService; |
| 41 | this.fecharCaixaService = fecharCaixaService; |
56 | this.fecharCaixaService = fecharCaixaService; |
| 42 | this.vendaService = vendaService; |
57 | this.vendaService = vendaService; |
| - | 58 | this.parcelaService = parcelaService; |
|
| - | 59 | this.pagamentoService = pagamentoService; |
|
| - | 60 | this.vigenciaService = vigenciaService; |
|
| 43 | }
|
61 | }
|
| 44 | 62 | ||
| 45 | @Override |
63 | @Override |
| 46 | public void preCarregamento() { |
64 | public void preCarregamento() { |
| 47 | parametrosReceberCaixa = new ParametrosReceberCaixaDTO(); |
65 | parametrosReceberCaixa = new ParametrosReceberCaixaDTO(); |
| Line 95... | Line 113... | ||
| 95 | 113 | ||
| 96 | public void realizarRecebimentoCaixa() { |
114 | public void realizarRecebimentoCaixa() { |
| 97 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
115 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
| 98 | public void execute() { |
116 | public void execute() { |
| 99 | automatizadorService.finalizarReceberDia(getParametrosReceberCaixa()); |
117 | automatizadorService.finalizarReceberDia(getParametrosReceberCaixa()); |
| - | 118 | gerarPagamentos(getParametrosFecharCaixa().getListaPagamentos()); |
|
| 100 | prepararRecebimentoCaixa(); |
119 | prepararRecebimentoCaixa(); |
| 101 | LancadorMensagem.lancarSucesso("RECEBIMENTO REALIZADO COM SUCESSO"); |
120 | LancadorMensagem.lancarSucesso("RECEBIMENTO REALIZADO COM SUCESSO"); |
| 102 | }
|
121 | }
|
| 103 | }); |
122 | }); |
| 104 | }
|
123 | }
|
| 105 | 124 | ||
| - | 125 | private void gerarPagamentos(final List<Pagamento> listaPagamentos) { |
|
| - | 126 | for (Pagamento pagamento : listaPagamentos) { |
|
| - | 127 | if (pagamento.getGerarPagamento()) { |
|
| - | 128 | Conta conta = new Conta(TipoConta.CONTA_A_PAGAR.getValor()); |
|
| - | 129 | conta.setCategoria(pagamento.getCategoriaGerarPagamento()); |
|
| - | 130 | conta.setLoja(pagamento.getLoja()); |
|
| - | 131 | conta.setTipoFrequencia(TipoFrequencia.UNICA.getValor()); |
|
| - | 132 | conta.setVigencia(vigenciaService.consultarVigenciaDoPeriodo(pagamento.getData())); |
|
| - | 133 | ||
| - | 134 | Parcela parcela = new Parcela(); |
|
| - | 135 | parcela.setContaBancaria(new ContaBancaria(ConstantesSEC.ContaBancaria.CONTA_BANCARIA_CAIXA_1L)); |
|
| - | 136 | parcela.setIndicadorOficial(false); |
|
| - | 137 | parcela.setIndicadorNegociacao(false); |
|
| - | 138 | parcela.setDataVencimento(pagamento.getData()); |
|
| - | 139 | parcela.setDataPagamento(pagamento.getData()); |
|
| - | 140 | parcela.setValor(pagamento.getValor()); |
|
| - | 141 | parcela.setObservacao(pagamento.getDescricao()); |
|
| - | 142 | ||
| - | 143 | parcela.setConta(conta); |
|
| - | 144 | parcelaService.lancarParcela(parcela); |
|
| - | 145 | ||
| - | 146 | pagamento.setLancado(true); |
|
| - | 147 | pagamentoService.alterar(pagamento); |
|
| - | 148 | }
|
|
| - | 149 | }
|
|
| - | 150 | }
|
|
| - | 151 | ||
| 106 | public Boolean temVendasConferidasOuNovas() { |
152 | public Boolean temVendasConferidasOuNovas() { |
| 107 | for (Venda venda : getParametrosFecharCaixa().getListaVendas()) { |
153 | for (Venda venda : getParametrosFecharCaixa().getListaVendas()) { |
| 108 | if (venda.getTipoSituacao().equals(TipoSituacaoVenda.NOVO.getValor()) || venda.getTipoSituacao().equals(TipoSituacaoVenda.CONFERIDO.getValor())) { |
154 | if (venda.getTipoSituacao().equals(TipoSituacaoVenda.NOVO.getValor()) || venda.getTipoSituacao().equals(TipoSituacaoVenda.CONFERIDO.getValor())) { |
| 109 | return true; |
155 | return true; |
| 110 | }
|
156 | }
|