fixes bug#20616
qua: dev:Valdevir git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@104120 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
bef37b29b0
commit
e7b4e1cde9
|
@ -1,5 +1,8 @@
|
|||
package com.rjconsultores.ventaboletos.dao.hibernate;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
@ -39,18 +42,44 @@ public class ReceitaDespesaHibernateDAO implements ReceitaDespesaDAO {
|
|||
con = dataSourceRead.getConnection();
|
||||
|
||||
StringBuilder sql = new StringBuilder();
|
||||
sql.append(" SELECT C.FECHORVTA, P.PUNTOVENTA_ID, P.NOMBPUNTOVENTA, P.NUMPUNTOVENTA, TE.INDTIPO, TE.TIPOEVENTOEXTRA_ID, TE.DESCTIPOEVENTO, ")
|
||||
sql.append(" SELECT ")
|
||||
.append("LISTAGG(fp.cvepago||' /'||CAST(cfp.IMPORTE AS VARCHAR(10)),';') WITHIN GROUP( ORDER BY 1 DESC ) AS descpago,")
|
||||
.append(" C.FECHORVTA, P.PUNTOVENTA_ID, P.NOMBPUNTOVENTA, P.NUMPUNTOVENTA, TE.INDTIPO, TE.TIPOEVENTOEXTRA_ID, TE.DESCTIPOEVENTO, ")
|
||||
.append(" CASE WHEN TE.INDTIPO = 1 THEN C.PRECIO ELSE (CASE WHEN TE.INDTIPO = 0 THEN (C.PRECIO * -1) END) END PRECIO, ")
|
||||
.append(" FP.DESCPAGO, C.NUMSERIEPREIMPRESA, C.NUMFOLIOPREIMPRESO, E.NUMDOCUMENTO ")
|
||||
.append(" C.NUMSERIEPREIMPRESA, C.NUMFOLIOPREIMPRESO, E.NUMDOCUMENTO ")
|
||||
.append(" FROM CAJA_DIVERSOS C ")
|
||||
.append(" JOIN EVENTO_EXTRA E ON E.EVENTOEXTRA_ID = C.EVENTOEXTRA_ID ")
|
||||
.append(" JOIN TIPO_EVENTO_EXTRA TE ON TE.TIPOEVENTOEXTRA_ID = E.TIPOEVENTOEXTRA_ID ")
|
||||
.append(" JOIN PUNTO_VENTA P ON P.PUNTOVENTA_ID = C.PUNTOVENTA_ID ")
|
||||
.append(" JOIN FORMA_PAGO FP ON E.FORMAPAGO_ID = FP.FORMAPAGO_ID ")
|
||||
.append("WHERE C.ACTIVO = 1 ");
|
||||
.append(" JOIN PUNTO_VENTA P ON P.PUNTOVENTA_ID = C.PUNTOVENTA_ID ")
|
||||
.append(" JOIN CAJA_DIVERSOS caj ON caj.eventoextra_id = e.eventoextra_id")
|
||||
.append(" JOIN CAJA_DIVERSOS_PAGO cfp ON ( caj.cajadiversos_id = cfp.cajadiversos_id)")
|
||||
.append(" JOIN FORMA_PAGO fp ON ( cfp.formapago_id = fp.formapago_id )")
|
||||
.append("WHERE C.ACTIVO = 1 ");
|
||||
|
||||
adicionarFiltros(sql, parametros);
|
||||
|
||||
sql.append(" GROUP BY ")
|
||||
.append("c.fechorvta, ")
|
||||
.append("p.puntoventa_id, ")
|
||||
.append("p.nombpuntoventa, ")
|
||||
.append("p.numpuntoventa, ")
|
||||
.append("te.indtipo, ")
|
||||
.append("te.tipoeventoextra_id, ")
|
||||
.append("te.desctipoevento, ")
|
||||
.append("CASE ")
|
||||
.append(" WHEN te.indtipo = 1 THEN c.precio ")
|
||||
.append(" ELSE ( ")
|
||||
.append(" CASE ")
|
||||
.append(" WHEN te.indtipo = 0 THEN ( c.precio *-1 ) ")
|
||||
.append(" END ")
|
||||
.append(" ) ")
|
||||
.append("END, ")
|
||||
.append("c.numseriepreimpresa, ")
|
||||
.append("c.numfoliopreimpreso, ")
|
||||
.append("e.numdocumento ");
|
||||
|
||||
|
||||
|
||||
sql.append("ORDER BY C.FECHORVTA, TE.DESCTIPOEVENTO, P.NOMBPUNTOVENTA, P.NUMPUNTOVENTA");
|
||||
|
||||
NamedParameterStatement stmt = new NamedParameterStatement(con, sql.toString());
|
||||
|
@ -71,7 +100,9 @@ public class ReceitaDespesaHibernateDAO implements ReceitaDespesaDAO {
|
|||
bean.setFormaPagamento(resultSet.getString("DESCPAGO"));
|
||||
bean.setNumSeriePreImpresa(resultSet.getString("NUMSERIEPREIMPRESA"));
|
||||
bean.setNumFolioPreImpreso(resultSet.getString("NUMFOLIOPREIMPRESO"));
|
||||
bean.setNumDocumento(resultSet.getString("NUMDOCUMENTO"));
|
||||
bean.setNumDocumento(resultSet.getString("NUMDOCUMENTO"));
|
||||
setFormasDePagamento(bean);
|
||||
setValorFormaPagamento(bean);
|
||||
lsBean.add(bean);
|
||||
}
|
||||
|
||||
|
@ -307,5 +338,61 @@ public class ReceitaDespesaHibernateDAO implements ReceitaDespesaDAO {
|
|||
stmt.setObject(parametro.getKey(), parametro.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
private void setFormasDePagamento(RelatorioFinanceiroReceitasDespesasBean bean) throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException {
|
||||
String formasPagamento = bean.getFormaPagamento();
|
||||
if (formasPagamento != null) {
|
||||
|
||||
final String[] formaPagamento = formasPagamento.split("\\;") ;
|
||||
if (formaPagamento.length > 1) {
|
||||
int contador = 0;
|
||||
while (contador < formaPagamento.length) {
|
||||
final Class cls = bean.getClass();
|
||||
final String metodo = "setFormaPagamento" + (contador+1);
|
||||
Method meth = cls.getMethod(metodo, String.class);
|
||||
meth.invoke(bean, formatarFormaDePagamento(formaPagamento[contador]));
|
||||
contador++;
|
||||
}
|
||||
} else {
|
||||
bean.setFormaPagamento1(formatarFormaDePagamento(formaPagamento[0]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void setValorFormaPagamento(RelatorioFinanceiroReceitasDespesasBean bean) throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException {
|
||||
String formasPagamento = bean.getFormaPagamento();
|
||||
if (formasPagamento != null) {
|
||||
|
||||
final String[] formaPagamento = formasPagamento.split("\\;") ;
|
||||
if (formaPagamento.length > 1) {
|
||||
int contador = 0;
|
||||
while (contador < formaPagamento.length) {
|
||||
final Class cls = bean.getClass();
|
||||
final String metodo = "setValorFormaPagamento" + (contador+1);
|
||||
Method meth = cls.getMethod(metodo, BigDecimal.class);
|
||||
meth.invoke(bean, formatarValorFormaDePagamento(formaPagamento[contador]));
|
||||
contador++;
|
||||
}
|
||||
} else {
|
||||
bean.setValorFormaPagamento1(formatarValorFormaDePagamento(formaPagamento[0]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String formatarFormaDePagamento(String formaDePagamento){
|
||||
if(formaDePagamento!=null){
|
||||
final String[] formaPagamentoAuxilar = formaDePagamento.split("\\/") ;
|
||||
return formaPagamentoAuxilar[0];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private BigDecimal formatarValorFormaDePagamento(String formaDePagamento){
|
||||
if(formaDePagamento!=null){
|
||||
final String[] formaPagamentoAuxilar = formaDePagamento.split("\\/") ;
|
||||
return formaPagamentoAuxilar.length>1? new BigDecimal(formaPagamentoAuxilar[1].replace(",", ".").trim()):new BigDecimal("0.0");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,13 @@ public class RelatorioFinanceiroReceitasDespesasBean {
|
|||
private BigDecimal precio;
|
||||
private BigDecimal receita;
|
||||
private BigDecimal despesa;
|
||||
|
||||
private String formaPagamento1;
|
||||
private String formaPagamento2;
|
||||
private String formaPagamento3;
|
||||
private BigDecimal ValorFormaPagamento1;
|
||||
private BigDecimal ValorFormaPagamento2;
|
||||
private BigDecimal ValorFormaPagamento3;
|
||||
|
||||
|
||||
public Date getFecHorVta() {
|
||||
return fecHorVta;
|
||||
|
@ -150,4 +156,53 @@ public class RelatorioFinanceiroReceitasDespesasBean {
|
|||
public void setFormaPagamento(String formaPagamento) {
|
||||
this.formaPagamento = formaPagamento;
|
||||
}
|
||||
|
||||
public String getFormaPagamento1() {
|
||||
return formaPagamento1;
|
||||
}
|
||||
|
||||
public void setFormaPagamento1(String formaPagamento1) {
|
||||
this.formaPagamento1 = formaPagamento1;
|
||||
}
|
||||
|
||||
public String getFormaPagamento2() {
|
||||
return formaPagamento2;
|
||||
}
|
||||
|
||||
public void setFormaPagamento2(String formaPagamento2) {
|
||||
this.formaPagamento2 = formaPagamento2;
|
||||
}
|
||||
|
||||
public String getFormaPagamento3() {
|
||||
return formaPagamento3;
|
||||
}
|
||||
|
||||
public void setFormaPagamento3(String formaPagamento3) {
|
||||
this.formaPagamento3 = formaPagamento3;
|
||||
}
|
||||
|
||||
public BigDecimal getValorFormaPagamento1() {
|
||||
return ValorFormaPagamento1;
|
||||
}
|
||||
|
||||
public void setValorFormaPagamento1(BigDecimal valorFormaPagamento1) {
|
||||
ValorFormaPagamento1 = valorFormaPagamento1;
|
||||
}
|
||||
|
||||
public BigDecimal getValorFormaPagamento2() {
|
||||
return ValorFormaPagamento2;
|
||||
}
|
||||
|
||||
public void setValorFormaPagamento2(BigDecimal valorFormaPagamento2) {
|
||||
ValorFormaPagamento2 = valorFormaPagamento2;
|
||||
}
|
||||
|
||||
public BigDecimal getValorFormaPagamento3() {
|
||||
return ValorFormaPagamento3;
|
||||
}
|
||||
|
||||
public void setValorFormaPagamento3(BigDecimal valorFormaPagamento3) {
|
||||
ValorFormaPagamento3 = valorFormaPagamento3;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue