wilian 2016-05-02 19:40:42 +00:00
parent 92016c8cd1
commit 2355335755
4 changed files with 59 additions and 41 deletions

View File

@ -49,8 +49,8 @@ public interface ConferenciaComissaoDAO extends GenericDAO<Conferencia, Long> {
public boolean isEventosFinanceirosSemConferencia(Conferencia conferencia) throws BusinessException; public boolean isEventosFinanceirosSemConferencia(Conferencia conferencia) throws BusinessException;
public BigDecimal carregarTotalFechamentoContaCorrente(Conferencia conferencia) throws BusinessException;
public boolean isConferenciaCompetenciaEncerrada(String competencia, Empresa empresa, PuntoVenta puntoVenta) throws BusinessException; public boolean isConferenciaCompetenciaEncerrada(String competencia, Empresa empresa, PuntoVenta puntoVenta) throws BusinessException;
public BigDecimal carregarValorDepositoContaCorrente(Integer empresaId, Integer puntoventaId, Date datamovimento);
} }

View File

@ -593,7 +593,7 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
.append("MC.DESCMOTIVO AS \"descmotivocancelacion\", U.NOMBUSUARIO AS \"nombusuario\", B.MOTIVOCANCELACION_ID AS \"motivocancelacionId\", ") .append("MC.DESCMOTIVO AS \"descmotivocancelacion\", U.NOMBUSUARIO AS \"nombusuario\", B.MOTIVOCANCELACION_ID AS \"motivocancelacionId\", ")
.append("BF.IMPORTE AS \"importeFp\", COMFP.COMEMPFORMAPAGO_ID AS \"comempformapagoId\", COMCAT.COMEMPCATEGORIA_ID AS \"comempcategoriaId\", ") .append("BF.IMPORTE AS \"importeFp\", COMFP.COMEMPFORMAPAGO_ID AS \"comempformapagoId\", COMCAT.COMEMPCATEGORIA_ID AS \"comempcategoriaId\", ")
.append("BO1.TIPOVENTA_ID \"tipoVentaOriginal1\", BO2.TIPOVENTA_ID \"tipoVentaOriginal2\", OCD.OCD_ID \"ocdId\", ") .append("BO1.TIPOVENTA_ID \"tipoVentaOriginal1\", BO2.TIPOVENTA_ID \"tipoVentaOriginal2\", OCD.OCD_ID \"ocdId\", ")
.append("B.NOMBPASAJERO AS \"nombpasajero\" ") .append("B.NOMBPASAJERO AS \"nombpasajero\", E.INDCARBOLETOSDEVOLVIDOSCONF AS \"indcarboletosdevolvidosconf\" ")
.append("FROM BOLETO B ") .append("FROM BOLETO B ")
.append("LEFT JOIN BOLETO BO1 ON BO1.BOLETO_ID = B.BOLETOORIGINAL_ID ") .append("LEFT JOIN BOLETO BO1 ON BO1.BOLETO_ID = B.BOLETOORIGINAL_ID ")
.append("LEFT JOIN BOLETO BO2 ON BO2.BOLETO_ID = BO1.BOLETOORIGINAL_ID ") .append("LEFT JOIN BOLETO BO2 ON BO2.BOLETO_ID = BO1.BOLETOORIGINAL_ID ")
@ -607,6 +607,7 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
.append("INNER JOIN BOLETO_FORMAPAGO BF ON BF.BOLETO_ID = B.BOLETO_ID ") .append("INNER JOIN BOLETO_FORMAPAGO BF ON BF.BOLETO_ID = B.BOLETO_ID ")
.append("INNER JOIN FORMA_PAGO FP ON FP.FORMAPAGO_ID = BF.FORMAPAGO_ID ") .append("INNER JOIN FORMA_PAGO FP ON FP.FORMAPAGO_ID = BF.FORMAPAGO_ID ")
.append("INNER JOIN USUARIO U ON B.USUARIO_ID = U.USUARIO_ID ") .append("INNER JOIN USUARIO U ON B.USUARIO_ID = U.USUARIO_ID ")
.append("INNER JOIN EMPRESA E ON E.EMPRESA_ID = B.MARCA_ID ")
.append("LEFT JOIN COM_EMP_FORMAPAGO COMFP ON COMFP.FORMAPAGO_ID = FP.FORMAPAGO_ID AND COMFP.EMPRESA_ID = B.EMPRESACORRIDA_ID ") .append("LEFT JOIN COM_EMP_FORMAPAGO COMFP ON COMFP.FORMAPAGO_ID = FP.FORMAPAGO_ID AND COMFP.EMPRESA_ID = B.EMPRESACORRIDA_ID ")
.append("LEFT JOIN COM_EMP_CATEGORIA COMCAT ON COMCAT.CATEGORIA_ID = B.CATEGORIA_ID AND COMCAT.EMPRESA_ID = B.EMPRESACORRIDA_ID ") .append("LEFT JOIN COM_EMP_CATEGORIA COMCAT ON COMCAT.CATEGORIA_ID = B.CATEGORIA_ID AND COMCAT.EMPRESA_ID = B.EMPRESACORRIDA_ID ")
.append("WHERE B.ACTIVO = 1 ") .append("WHERE B.ACTIVO = 1 ")
@ -662,6 +663,7 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
.addScalar("tipoVentaOriginal2", Hibernate.INTEGER) .addScalar("tipoVentaOriginal2", Hibernate.INTEGER)
.addScalar("ocdId", Hibernate.INTEGER) .addScalar("ocdId", Hibernate.INTEGER)
.addScalar("nombpasajero", Hibernate.STRING) .addScalar("nombpasajero", Hibernate.STRING)
.addScalar("indcarboletosdevolvidosconf", Hibernate.BOOLEAN)
.setResultTransformer(Transformers.aliasToBean(BoletoComissao.class)); .setResultTransformer(Transformers.aliasToBean(BoletoComissao.class));
setParametros(qr, parametros); setParametros(qr, parametros);
@ -922,38 +924,6 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
} }
} }
@Override
public BigDecimal carregarTotalFechamentoContaCorrente(Conferencia conferencia) throws BusinessException {
try {
Map<String, Object> parametros = carregarParametros(null, conferencia.getEmpresa(), conferencia.getPuntoVenta());
StringBuilder sQuery = new StringBuilder();
sQuery.append("SELECT SUM(TOTAL) AS TOTAL ")
.append("FROM FECHAMENTO_CNTCORRENTE ")
.append("WHERE ACTIVO = 1 ")
.append("AND :datamovimento BETWEEN FECINIFECHAMENTO AND FECFINFECHAMENTO ");
parametros.put("datamovimento", conferencia.getDatamovimento());
if(parametros.containsKey("empresaId")) {
sQuery.append("AND EMPRESA_ID = :empresaId ");
}
if(parametros.containsKey("puntoventaId")) {
sQuery.append("AND PUNTOVENTA_ID = :puntoventaId ");
}
log.info(sQuery.toString());
Query qr = getSession().createSQLQuery(sQuery.toString());
setParametros(qr, parametros);
return (BigDecimal) qr.uniqueResult();
} catch (Exception e) {
log.error(e.getMessage(), e);
throw new BusinessException(e.getMessage(), e);
}
}
@Override @Override
public boolean isConferenciaCompetenciaEncerrada(String competencia, Empresa empresa, PuntoVenta puntoVenta) throws BusinessException { public boolean isConferenciaCompetenciaEncerrada(String competencia, Empresa empresa, PuntoVenta puntoVenta) throws BusinessException {
try { try {
@ -977,4 +947,23 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
} }
} }
@Override
public BigDecimal carregarValorDepositoContaCorrente(Integer empresaId, Integer puntoventaId, Date datamovimento) {
StringBuilder sQuery = new StringBuilder();
sQuery.append("SELECT SUM(importeTotalEfectivo) ")
.append("FROM ContaCorrentePtoVta cc ")
.append("WHERE cc.activo = 1 ")
.append("AND cc.empresa.empresaId = :empresaId ")
.append("AND cc.puntoVenta.puntoventaId = :puntoventaId ")
.append("AND cc.fecHorOperacion = :datamovimento ");
Query qr = getSession().createQuery(sQuery.toString());
qr.setParameter("empresaId", empresaId);
qr.setParameter("puntoventaId", puntoventaId);
qr.setParameter("datamovimento", datamovimento);
qr.setMaxResults(1);
return (BigDecimal) qr.uniqueResult();
}
} }

View File

@ -11,6 +11,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -164,7 +165,7 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic
retorno.addAll(carregarBilhetesCancelados(boletoComissaos)); retorno.addAll(carregarBilhetesCancelados(boletoComissaos));
break; break;
case BOLETO_DEVOLVIDO: case BOLETO_DEVOLVIDO:
retorno.addAll(carregarBilhetesDevolvidos(boletoComissaos)); retorno.addAll(carregarBilhetesDevolvidos(boletoComissaos, StringUtils.isNotBlank(conferencia.getNumfoliosistema())));
break; break;
case GAP_VENDIDOS: case GAP_VENDIDOS:
retorno.addAll(carregarBilhetesGapsVendidos(boletoComissaos)); retorno.addAll(carregarBilhetesGapsVendidos(boletoComissaos));
@ -222,7 +223,7 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic
return boletos; return boletos;
} }
private Set<BoletoComissao> carregarBilhetesDevolvidos(List<BoletoComissao> boletoComissaos) { private Set<BoletoComissao> carregarBilhetesDevolvidos(List<BoletoComissao> boletoComissaos, boolean pesquisa) {
Set<BoletoComissao> boletos = new HashSet<BoletoComissao>(); Set<BoletoComissao> boletos = new HashSet<BoletoComissao>();
for (BoletoComissao boletoComissao : boletoComissaos) { for (BoletoComissao boletoComissao : boletoComissaos) {
if(boletoComissao.isBilheteNormalDevolvido() || if(boletoComissao.isBilheteNormalDevolvido() ||
@ -233,7 +234,12 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic
boletoComissao.isBilheteEntregaGapDevolvido() || boletoComissao.isBilheteEntregaGapDevolvido() ||
boletoComissao.isBilheteEntregaGapTrocado()) { boletoComissao.isBilheteEntregaGapTrocado()) {
boletoComissao.setExigeConferenciaDevolvido(boletoComissao.getIndcarboletosdevolvidosconf() != null && !boletoComissao.getIndcarboletosdevolvidosconf());
if(pesquisa ||
((boletoComissao.getIndcarboletosdevolvidosconf() != null && boletoComissao.getIndcarboletosdevolvidosconf()) || boletoComissao.getLogconferenciaId() != null)) {
boletos.add(boletoComissao); boletos.add(boletoComissao);
}
} }
} }
@ -384,11 +390,11 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic
carregarTotalFormapago(resumoComissao, boletoComissaos, lsEventosFinanceiros); carregarTotalFormapago(resumoComissao, boletoComissaos, lsEventosFinanceiros);
BigDecimal totalFormapagoDinheiro = getFormapagoDinheiro(resumoComissao); /*BigDecimal totalFormapagoDinheiro = getFormapagoDinheiro(resumoComissao);
totalFormapagoDinheiro = totalFormapagoDinheiro.subtract(carregarTotalDevolvidosDinhero(boletoComissaos)); totalFormapagoDinheiro = totalFormapagoDinheiro.subtract(carregarTotalDevolvidosDinhero(boletoComissaos));
totalFormapagoDinheiro = totalFormapagoDinheiro.subtract(totalOcd.getValorPagar()); totalFormapagoDinheiro = totalFormapagoDinheiro.subtract(totalOcd.getValorPagar());*/
resumoComissao.setValorDeposito(totalFormapagoDinheiro); resumoComissao.setValorDeposito(conferenciaComissaoDAO.carregarValorDepositoContaCorrente(conferencia.getEmpresa().getEmpresaId(), conferencia.getPuntoVenta().getPuntoventaId(), conferencia.getDatamovimento()));
return resumoComissao; return resumoComissao;
} }

View File

@ -55,6 +55,9 @@ public class BoletoComissao {
private Integer comempcategoriaId; private Integer comempcategoriaId;
private Long logconferenciaId; private Long logconferenciaId;
private boolean exigeConferenciaDevolvido;
private Boolean indcarboletosdevolvidosconf;
private boolean conferido; private boolean conferido;
public Integer getEmpresaId() { public Integer getEmpresaId() {
@ -424,6 +427,10 @@ public class BoletoComissao {
return getComempcategoriaId() != null || getComempformapagoId() != null; return getComempcategoriaId() != null || getComempformapagoId() != null;
} }
public boolean isExigeConferenciaBoletoDevolvido() {
return exigeConferenciaDevolvido;
}
public boolean isConferido() { public boolean isConferido() {
return conferido; return conferido;
} }
@ -715,4 +722,20 @@ public class BoletoComissao {
return IndStatusBoleto.getIndStatusBoleto(getIndstatusboleto()); return IndStatusBoleto.getIndStatusBoleto(getIndstatusboleto());
} }
public Boolean getIndcarboletosdevolvidosconf() {
return indcarboletosdevolvidosconf;
}
public void setIndcarboletosdevolvidosconf(Boolean indcarboletosdevolvidosconf) {
this.indcarboletosdevolvidosconf = indcarboletosdevolvidosconf;
}
public boolean getExigeConferenciaDevolvido() {
return exigeConferenciaDevolvido;
}
public void setExigeConferenciaDevolvido(boolean exigeConferenciaDevolvido) {
this.exigeConferenciaDevolvido = exigeConferenciaDevolvido;
}
} }