Rev 297 | Rev 343 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 297 | Rev 319 | ||
|---|---|---|---|
| Line 27... | Line 27... | ||
| 27 | }
|
27 | }
|
| 28 | 28 | ||
| 29 | @Override |
29 | @Override |
| 30 | public List<ParcelaDTO> consultarParcelas(ParametrosConsultaParcelasDTO parametrosConsultaParcelasDTO) { |
30 | public List<ParcelaDTO> consultarParcelas(ParametrosConsultaParcelasDTO parametrosConsultaParcelasDTO) { |
| 31 | StringBuilder sql = new StringBuilder(); |
31 | StringBuilder sql = new StringBuilder(); |
| 32 | sql.append("SELECT new br.com.ec.domain.dto.ParcelaDTO(p.sequencial, p.contaBancaria.sequencial, p.contaBancaria.descricao, p.contaBancaria.tipoContaBancaria, p.contaBancaria.ativo, "); |
- | |
| 33 | sql.append("p.dataPagamento, p.valor, p.observacao) FROM Parcela p "); |
- | |
| - | 32 | sql.append("SELECT new br.com.ec.domain.dto.ParcelaDTO("); |
|
| - | 33 | sql.append(ParcelaDTO.CONSULTA_COMPLETA_DTO); |
|
| - | 34 | sql.append(") FROM Parcela e "); |
|
| 34 | sql.append("WHERE 1=1 "); |
35 | sql.append("WHERE 1=1 "); |
| 35 | if (VerificadorUtil.naoEstaNulo(parametrosConsultaParcelasDTO.getTipoBusca())) { |
36 | if (VerificadorUtil.naoEstaNulo(parametrosConsultaParcelasDTO.getTipoBusca())) { |
| 36 | sql.append("AND p.conta.tipoConta = :tipoConta "); |
- | |
| - | 37 | sql.append("AND e.conta.tipoConta = :tipoConta "); |
|
| 37 | }
|
38 | }
|
| 38 | if (VerificadorUtil.naoEstaNulo(parametrosConsultaParcelasDTO.getSequencialCategoria())) { |
39 | if (VerificadorUtil.naoEstaNulo(parametrosConsultaParcelasDTO.getSequencialCategoria())) { |
| 39 | sql.append("AND p.conta.categoria.sequencial = :sequencialCategoria "); |
- | |
| - | 40 | sql.append("AND e.conta.categoria.sequencial = :sequencialCategoria "); |
|
| 40 | }
|
41 | }
|
| 41 | if (parametrosConsultaParcelasDTO.getPagamentoRealizado()) { |
42 | if (parametrosConsultaParcelasDTO.getPagamentoRealizado()) { |
| 42 | if (VerificadorUtil.naoEstaNulo(parametrosConsultaParcelasDTO.getDataInicial()) && |
43 | if (VerificadorUtil.naoEstaNulo(parametrosConsultaParcelasDTO.getDataInicial()) && |
| 43 | VerificadorUtil.naoEstaNulo(parametrosConsultaParcelasDTO.getDataFinal())) { |
44 | VerificadorUtil.naoEstaNulo(parametrosConsultaParcelasDTO.getDataFinal())) { |
| 44 | sql.append("AND p.dataPagamento is not null "); |
- | |
| 45 | sql.append("AND p.dataPagamento >= :dataInicial AND p.dataPagamento <= :dataFinal "); |
- | |
| - | 45 | sql.append("AND e.dataPagamento is not null "); |
|
| - | 46 | sql.append("AND e.dataPagamento >= :dataInicial AND e.dataPagamento <= :dataFinal "); |
|
| 46 | }
|
47 | }
|
| 47 | }
|
48 | }
|
| 48 | sql.append("ORDER BY p.dataVencimento "); |
- | |
| - | 49 | sql.append("ORDER BY e.dataVencimento "); |
|
| 49 | try { |
50 | try { |
| 50 | TypedQuery<ParcelaDTO> query = getEntityManager().createQuery(sql.toString(), ParcelaDTO.class); |
51 | TypedQuery<ParcelaDTO> query = getEntityManager().createQuery(sql.toString(), ParcelaDTO.class); |
| 51 | if (VerificadorUtil.naoEstaNulo(parametrosConsultaParcelasDTO.getTipoBusca())) { |
52 | if (VerificadorUtil.naoEstaNulo(parametrosConsultaParcelasDTO.getTipoBusca())) { |
| 52 | query.setParameter("tipoConta", parametrosConsultaParcelasDTO.getTipoBusca()); |
53 | query.setParameter("tipoConta", parametrosConsultaParcelasDTO.getTipoBusca()); |
| 53 | }
|
54 | }
|
| Line 69... | Line 70... | ||
| 69 | }
|
70 | }
|
| 70 | 71 | ||
| 71 | @Override |
72 | @Override |
| 72 | public List<ParcelaDTO> consultarParcelasAReceber(Long sequencialContaBancaria, Date dataRecebimento, List<FormaPagamentoDTO> formasDePagamento) { |
73 | public List<ParcelaDTO> consultarParcelasAReceber(Long sequencialContaBancaria, Date dataRecebimento, List<FormaPagamentoDTO> formasDePagamento) { |
| 73 | StringBuilder sql = new StringBuilder(); |
74 | StringBuilder sql = new StringBuilder(); |
| 74 | sql.append("SELECT new br.com.ec.domain.dto.ParcelaDTO(p.sequencial, p.contaBancaria.sequencial, p.contaBancaria.descricao, p.contaBancaria.tipoContaBancaria, p.contaBancaria.ativo, "); |
- | |
| 75 | sql.append("p.dataPagamento, p.valor, p.observacao) FROM Parcela p "); |
- | |
| 76 | sql.append("WHERE p.contaBancaria.sequencial = :sequencialContaBancaria "); |
- | |
| 77 | sql.append("AND p.dataVencimento = :dataVencimento "); |
- | |
| 78 | sql.append(setarParametrosFormasDePagamento("p", formasDePagamento)); |
- | |
| 79 | sql.append("AND p.dataPagamento is null "); |
- | |
| 80 | sql.append("ORDER BY p.dataVencimento "); |
- | |
| - | 75 | sql.append("SELECT new br.com.ec.domain.dto.ParcelaDTO("); |
|
| - | 76 | sql.append(ParcelaDTO.CONSULTA_SEM_CATEGORIA_DTO); |
|
| - | 77 | sql.append(") FROM Parcela e "); |
|
| - | 78 | sql.append("WHERE e.contaBancaria.sequencial = :sequencialContaBancaria "); |
|
| - | 79 | sql.append("AND e.dataVencimento = :dataVencimento "); |
|
| - | 80 | sql.append(setarParametrosFormasDePagamento("e", formasDePagamento)); |
|
| - | 81 | sql.append("AND e.dataPagamento is null "); |
|
| - | 82 | sql.append("ORDER BY e.dataVencimento "); |
|
| 81 | try { |
83 | try { |
| 82 | return getEntityManager().createQuery(sql.toString(), ParcelaDTO.class) |
84 | return getEntityManager().createQuery(sql.toString(), ParcelaDTO.class) |
| 83 | .setParameter("sequencialContaBancaria", sequencialContaBancaria) |
85 | .setParameter("sequencialContaBancaria", sequencialContaBancaria) |
| 84 | .setParameter("dataVencimento", dataRecebimento) |
86 | .setParameter("dataVencimento", dataRecebimento) |
| 85 | .getResultList(); |
87 | .getResultList(); |
| Line 90... | Line 92... | ||
| 90 | }
|
92 | }
|
| 91 | 93 | ||
| 92 | @Override |
94 | @Override |
| 93 | public List<ParcelaDTO> consultarParcelasRecebidas(Long sequencialContaBancaria, Date dataRecebimento, List<FormaPagamentoDTO> formasDePagamento) { |
95 | public List<ParcelaDTO> consultarParcelasRecebidas(Long sequencialContaBancaria, Date dataRecebimento, List<FormaPagamentoDTO> formasDePagamento) { |
| 94 | StringBuilder sql = new StringBuilder(); |
96 | StringBuilder sql = new StringBuilder(); |
| 95 | sql.append("SELECT new br.com.ec.domain.dto.ParcelaDTO(p.sequencial, p.contaBancaria.sequencial, p.contaBancaria.descricao, p.contaBancaria.tipoContaBancaria, p.contaBancaria.ativo, "); |
- | |
| 96 | sql.append("p.dataPagamento, p.valor, p.observacao) FROM Parcela p "); |
- | |
| 97 | sql.append("WHERE p.contaBancaria.sequencial = :sequencialContaBancaria "); |
- | |
| 98 | sql.append("AND p.dataPagamento = :dataPagamento "); |
- | |
| 99 | sql.append(setarParametrosFormasDePagamento("p", formasDePagamento)); |
- | |
| 100 | sql.append("ORDER BY p.dataVencimento "); |
- | |
| - | 97 | sql.append("SELECT new br.com.ec.domain.dto.ParcelaDTO("); |
|
| - | 98 | sql.append(ParcelaDTO.CONSULTA_SEM_CATEGORIA_DTO); |
|
| - | 99 | sql.append(") FROM Parcela e "); |
|
| - | 100 | sql.append("WHERE e.contaBancaria.sequencial = :sequencialContaBancaria "); |
|
| - | 101 | sql.append("AND e.dataPagamento = :dataPagamento "); |
|
| - | 102 | sql.append(setarParametrosFormasDePagamento("e", formasDePagamento)); |
|
| - | 103 | sql.append("ORDER BY e.dataVencimento "); |
|
| 101 | try { |
104 | try { |
| 102 | return getEntityManager().createQuery(sql.toString(), ParcelaDTO.class) |
105 | return getEntityManager().createQuery(sql.toString(), ParcelaDTO.class) |
| 103 | .setParameter("sequencialContaBancaria", sequencialContaBancaria) |
106 | .setParameter("sequencialContaBancaria", sequencialContaBancaria) |
| 104 | .setParameter("dataPagamento", dataRecebimento) |
107 | .setParameter("dataPagamento", dataRecebimento) |
| 105 | .getResultList(); |
108 | .getResultList(); |
| Line 156... | Line 159... | ||
| 156 | }
|
159 | }
|
| 157 | 160 | ||
| 158 | @Override |
161 | @Override |
| 159 | public List<ParcelaDTO> consultarParcelasPassandoParametrosConsulta(ParametrosConsulta<Parcela> parametrosConsulta) { |
162 | public List<ParcelaDTO> consultarParcelasPassandoParametrosConsulta(ParametrosConsulta<Parcela> parametrosConsulta) { |
| 160 | StringBuilder sql = new StringBuilder(); |
163 | StringBuilder sql = new StringBuilder(); |
| 161 | sql.append("SELECT new br.com.ec.domain.dto.ParcelaDTO(e.sequencial, "); |
- | |
| 162 | sql.append("e.conta.categoria.sequencial, e.conta.categoria.descricao, e.conta.categoria.tipo, "); |
- | |
| 163 | sql.append("e.contaBancaria.sequencial, e.contaBancaria.descricao, e.contaBancaria.tipoContaBancaria, e.contaBancaria.ativo, "); |
- | |
| 164 | sql.append("e.dataPagamento, e.valor, e.observacao) FROM Parcela e "); |
- | |
| - | 164 | sql.append("SELECT new br.com.ec.domain.dto.ParcelaDTO("); |
|
| - | 165 | sql.append(ParcelaDTO.CONSULTA_COMPLETA_DTO); |
|
| - | 166 | sql.append(") FROM Parcela e "); |
|
| 165 | // sql.append("SELECT DISTINCT SUM(e.valor) FROM Parcela e ");
|
167 | // sql.append("SELECT DISTINCT SUM(e.valor) FROM Parcela e ");
|
| 166 | sql.append("WHERE e.indicadorAtivo is true "); |
168 | sql.append("WHERE e.indicadorAtivo is true "); |
| 167 | try { |
169 | try { |
| 168 | setarStringParametrosConsulta(sql, parametrosConsulta); |
170 | setarStringParametrosConsulta(sql, parametrosConsulta); |
| 169 | TypedQuery<ParcelaDTO> query = getEntityManager().createQuery(sql.toString(), ParcelaDTO.class); |
171 | TypedQuery<ParcelaDTO> query = getEntityManager().createQuery(sql.toString(), ParcelaDTO.class); |