Go to most recent revision | Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 106 | espaco | 1 | package br.com.ec.domain.service.pagamento.impl; |
| 2 | |||
| 3 | import java.util.Date; |
||
| 4 | import java.util.List; |
||
| 5 | |||
| 6 | import org.springframework.beans.factory.annotation.Autowired; |
||
| 7 | import org.springframework.stereotype.Service; |
||
| 8 | |||
| 9 | import br.com.ec.domain.model.Loja; |
||
| 10 | import br.com.ec.domain.model.Pagamento; |
||
| 11 | import br.com.ec.domain.service.pagamento.PagamentoService; |
||
| 12 | import br.com.ec.infrastructure.repository.PagamentoRepository; |
||
| 13 | import br.edu.cesmac.core.generic.AbstractService; |
||
| 14 | import br.edu.cesmac.core.generic.GenericRepository; |
||
| 15 | import br.edu.cesmac.core.util.DataUtils; |
||
| 16 | import br.edu.cesmac.core.util.VerificadorUtil; |
||
| 17 | import br.edu.cesmac.core.validador.Validador; |
||
| 18 | |||
| 19 | @Service |
||
| 20 | public class PagamentoServiceImpl extends AbstractService<Pagamento> implements PagamentoService { |
||
| 21 | |||
| 22 | private PagamentoRepository pagamentoRepository; |
||
| 23 | |||
| 24 | @Autowired |
||
| 25 | public PagamentoServiceImpl(Validador validador, PagamentoRepository pagamentoRepository) { |
||
| 26 | super(validador); |
||
| 27 | this.pagamentoRepository = pagamentoRepository; |
||
| 28 | } |
||
| 29 | |||
| 30 | @Override |
||
| 31 | protected GenericRepository<Pagamento> getRepository() { |
||
| 32 | return pagamentoRepository; |
||
| 33 | } |
||
| 34 | |||
| 35 | @Override |
||
| 36 | protected void regrasNegocioCadastrar(Pagamento pagamento) { |
||
| 37 | if (VerificadorUtil.estaNulo(pagamento.getData())) { |
||
| 38 | pagamento.setData(DataUtils.getDataAtual()); |
||
| 39 | } |
||
| 40 | pagamento.setLancado(false); |
||
| 41 | } |
||
| 42 | |||
| 43 | @Override |
||
| 44 | public Integer quantidadePagamentosEmAberto(Loja loja) { |
||
| 45 | Pagamento pagamento = new Pagamento(); |
||
| 46 | pagamento.setLoja(loja); |
||
| 47 | pagamento.setLancado(false); |
||
| 48 | return this.obterQuantidadeDeRegistrosPassandoEntidade(pagamento); |
||
| 49 | } |
||
| 50 | |||
| 51 | @Override |
||
| 52 | public List<Pagamento> consultarPagamentosDoDia(Long sequencialLoja, Date dataVendas) { |
||
| 53 | Pagamento pagamento = new Pagamento(); |
||
| 54 | pagamento.setLoja(new Loja(sequencialLoja)); |
||
| 55 | pagamento.setData(dataVendas); |
||
| 56 | return this.consultarPassandoEntidade(pagamento, 0, this.obterQuantidadeDeRegistrosPassandoEntidade(pagamento)); |
||
| 57 | } |
||
| 58 | |||
| 59 | } |