diff --git a/src/com/rjconsultores/ventaboletos/dao/ConferenciaComissaoDAO.java b/src/com/rjconsultores/ventaboletos/dao/ConferenciaComissaoDAO.java index 3fc1a85fe..ffeaa6688 100644 --- a/src/com/rjconsultores/ventaboletos/dao/ConferenciaComissaoDAO.java +++ b/src/com/rjconsultores/ventaboletos/dao/ConferenciaComissaoDAO.java @@ -1,5 +1,6 @@ package com.rjconsultores.ventaboletos.dao; +import java.math.BigDecimal; import java.util.Date; import java.util.List; @@ -7,7 +8,6 @@ import com.rjconsultores.ventaboletos.entidad.Conferencia; import com.rjconsultores.ventaboletos.entidad.Empresa; import com.rjconsultores.ventaboletos.entidad.LogConferencia; import com.rjconsultores.ventaboletos.entidad.PuntoVenta; -import com.rjconsultores.ventaboletos.enums.comissao.BoletoStatusComissao; import com.rjconsultores.ventaboletos.exception.BusinessException; import com.rjconsultores.ventaboletos.vo.comissao.BoletoComissao; import com.rjconsultores.ventaboletos.vo.comissao.ConferenciaComissaoVO; @@ -35,7 +35,7 @@ public interface ConferenciaComissaoDAO extends GenericDAO { public LogConferencia obtenerLogConferenciaID(Long logconferenciaId); - public List carregarBilhetesComissao(Conferencia conferencia, BoletoStatusComissao boletoStatusComissao) throws BusinessException; + public List carregarBilhetesComissao(Conferencia conferencia) throws BusinessException; public List carregarOcds(Conferencia conferencia) throws BusinessException; @@ -49,4 +49,6 @@ public interface ConferenciaComissaoDAO extends GenericDAO { public boolean isEventosFinanceirosSemConferencia(Conferencia conferencia) throws BusinessException; + public BigDecimal carregarTotalFechamentoContaCorrente(Conferencia conferencia) throws BusinessException; + } diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/ConferenciaComissaoHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/ConferenciaComissaoHibernateDAO.java index dbccadcb0..4bf4c35cc 100644 --- a/src/com/rjconsultores/ventaboletos/dao/hibernate/ConferenciaComissaoHibernateDAO.java +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/ConferenciaComissaoHibernateDAO.java @@ -36,7 +36,6 @@ import com.rjconsultores.ventaboletos.entidad.ContaCorrentePtoVta; import com.rjconsultores.ventaboletos.entidad.Empresa; import com.rjconsultores.ventaboletos.entidad.LogConferencia; import com.rjconsultores.ventaboletos.entidad.PuntoVenta; -import com.rjconsultores.ventaboletos.enums.comissao.BoletoStatusComissao; import com.rjconsultores.ventaboletos.enums.comissao.StatusLogConferencia; import com.rjconsultores.ventaboletos.exception.BusinessException; import com.rjconsultores.ventaboletos.utilerias.DateUtil; @@ -97,7 +96,7 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO parametros = new HashMap(); - StringBuilder sQuery = new StringBuilder("SELECT DISTINCT PV.PUNTOVENTA_ID AS \"puntoventaId\", PV.NUMPUNTOVENTA as \"numPuntoVenta\", PV.NOMBPUNTOVENTA as \"nombpuntoventa\" "); + StringBuilder sQuery = new StringBuilder("SELECT PV.PUNTOVENTA_ID AS \"puntoventaId\", PV.NUMPUNTOVENTA as \"numPuntoVenta\", PV.NOMBPUNTOVENTA as \"nombpuntoventa\" "); sQuery.append("FROM PUNTO_VENTA PV ") .append("JOIN PTOVTA_EMPRESA PTE ON PTE.PUNTOVENTA_ID = PV.PUNTOVENTA_ID ") .append("WHERE PV.ACTIVO = 1 "); @@ -128,7 +127,7 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO lsConferencias, String competencia, Empresa empresa, PuntoVenta puntoVenta) throws BusinessException { try { Map parametros = carregarParametros(competencia, empresa, puntoVenta); - StringBuilder sQuery = new StringBuilder("SELECT DISTINCT co FROM Conferencia co "); + StringBuilder sQuery = new StringBuilder("SELECT co FROM Conferencia co "); sQuery.append("JOIN co.empresa em ") .append("JOIN co.puntoVenta pv ") .append("WHERE co.activo = 1 ") @@ -170,14 +169,14 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO lsConferencias, String competencia, Empresa empresa, PuntoVenta puntoVenta) throws BusinessException { try { Map parametros = carregarParametros(competencia, empresa, puntoVenta); - StringBuilder sQuery = new StringBuilder("SELECT DISTINCT PV.PUNTOVENTA_ID AS \"puntoventaId\", PV.NUMPUNTOVENTA as \"numPuntoVenta\", PV.NOMBPUNTOVENTA as \"nombpuntoventa\", TO_DATE(B.FECHORVENTA, 'DD/MM/YY') as \"datamovimento\" "); + StringBuilder sQuery = new StringBuilder("SELECT PV.PUNTOVENTA_ID AS \"puntoventaId\", PV.NUMPUNTOVENTA as \"numPuntoVenta\", PV.NOMBPUNTOVENTA as \"nombpuntoventa\", TO_DATE(B.FECHORVENTA, 'DD/MM/YY') as \"datamovimento\" "); sQuery.append("FROM BOLETO B ") .append("INNER JOIN PUNTO_VENTA PV ON B.PUNTOVENTA_ID = PV.PUNTOVENTA_ID ") .append("WHERE PV.ACTIVO = 1 ") .append("AND B.FECHORVENTA BETWEEN :dataInicial AND :dataFinal ") .append("AND B.TIPOVENTA_ID IN (:tipoVenta) ") .append("AND ( ") - .append(" (B.INDSTATUSBOLETO = 'V' AND B.MOTIVOCANCELACION_ID IS NULL) ") + .append(" (B.INDSTATUSBOLETO = 'V' AND (B.MOTIVOCANCELACION_ID IS NULL OR B.MOTIVOCANCELACION_ID IN (:motivocancelacionId))) ") .append(" OR ") .append(" (B.INDSTATUSBOLETO = 'C' AND B.MOTIVOCANCELACION_ID IN (:motivocancelacionId)) ") .append(" ) "); @@ -403,7 +402,7 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO parametros = carregarParametros(null, conferencia.getEmpresa(), conferencia.getPuntoVenta()); StringBuilder sQuery = new StringBuilder(); - sQuery.append("SELECT DISTINCT FECHAMENTOCNTCORRENTE_ID ") + sQuery.append("SELECT FECHAMENTOCNTCORRENTE_ID ") .append("FROM FECHAMENTO_CNTCORRENTE ") .append("WHERE ACTIVO = 1 ") .append("AND :datamovimento BETWEEN FECINIFECHAMENTO AND FECFINFECHAMENTO "); @@ -443,14 +442,18 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO parametros = carregarParametros(null, conferencia.getEmpresa(), conferencia.getPuntoVenta()); StringBuilder sQuery = new StringBuilder(); - sQuery.append("SELECT DISTINCT EE.EVENTOEXTRA_ID AS \"eventoextraId\", EE.NUMDOCUMENTO AS \"numdocumento\", ") + sQuery.append("SELECT EE.EVENTOEXTRA_ID AS \"eventoextraId\", EE.NUMDOCUMENTO AS \"numdocumento\", ") .append("EE.IMPINGRESO AS \"impingreso\", TEE.DESCTIPOEVENTO AS \"desctipoevento\", EE.DESCINFO AS \"descinfo\", ") .append("LOG.STATUS AS \"status\", FP.FORMAPAGO_ID AS \"formapagoId\", FP.DESCPAGO AS \"descpago\", ") - .append("FP.INDCONFERENCIAFISICACOMISSAO AS \"indconferenciafisicacomissao\", TEE.INDTIPO AS \"indtipo\" ") + .append("TEE.INDTIPO AS \"indtipo\", U.NOMBUSUARIO AS \"nombusuario\", LOG.LOGCONFERENCIA_ID AS \"logconferenciaId\", ") + .append("COMFP.COMEMPFORMAPAGO_ID AS \"comempformapagoId\", COMTEE.COMEMPTIPOEVENTOEXTRA_ID AS \"comemptipoeventoextraId\" ") .append("FROM EVENTO_EXTRA EE ") .append("JOIN TIPO_EVENTO_EXTRA TEE ON EE.TIPOEVENTOEXTRA_ID = TEE.TIPOEVENTOEXTRA_ID ") + .append("INNER JOIN USUARIO U ON EE.USUARIO_ID = U.USUARIO_ID ") .append("LEFT JOIN LOG_CONFERENCIA LOG ON LOG.EVENTOEXTRA_ID = EE.EVENTOEXTRA_ID ") .append("LEFT JOIN FORMA_PAGO FP ON FP.FORMAPAGO_ID = EE.FORMAPAGO_ID ") + .append("LEFT JOIN COM_EMP_FORMAPAGO COMFP ON COMFP.FORMAPAGO_ID = FP.FORMAPAGO_ID AND COMFP.EMPRESA_ID = EE.EMPRESA_ID ") + .append("LEFT JOIN COM_EMP_TIPOEVENTOEXTRA COMTEE ON COMTEE.TIPOEVENTOEXTRA_ID = TEE.TIPOEVENTOEXTRA_ID AND COMTEE.EMPRESA_ID = EE.EMPRESA_ID ") .append("WHERE EE.ACTIVO = 1 ") .append("AND TO_DATE(EE.FECHORINGRESO,'DD/MM/YY') = :datamovimento "); @@ -477,8 +480,11 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO carregarBilhetesComissao(Conferencia conferencia, BoletoStatusComissao boletoStatusComissao) throws BusinessException { + public List carregarBilhetesComissao(Conferencia conferencia) throws BusinessException { try { Map parametros = carregarParametros(null, conferencia.getEmpresa(), conferencia.getPuntoVenta()); @@ -591,8 +597,9 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO parametros = carregarParametros(null, conferencia.getEmpresa(), conferencia.getPuntoVenta()); StringBuilder sQuery = new StringBuilder(); - sQuery.append("SELECT O.OCD_ID AS \"ocdId\", O.NUMOPERACION AS \"numoperacion\", O.FECINC AS \"fecinc\", O.FECPAGAR AS \"fecpagar\", O.FECPAGO AS \"fecpago\", ") - .append("O.INDPAGO AS \"indpago\", O.VALOR_PAGAR AS \"valorPagar\", O.PENALIZACION AS \"penalizacion\", LOG.STATUS AS \"status\" ") + sQuery.append("SELECT DISTINCT O.OCD_ID AS \"ocdId\", O.NUMOPERACION AS \"numoperacion\", O.FECINC AS \"fecinc\", O.FECPAGAR AS \"fecpagar\", O.FECPAGO AS \"fecpago\", ") + .append("O.INDPAGO AS \"indpago\", O.VALOR_PAGAR AS \"valorPagar\", O.PENALIZACION AS \"penalizacion\", LOG.STATUS AS \"status\", U.NOMBUSUARIO AS \"nombusuario\", LOG.LOGCONFERENCIA_ID AS \"logconferenciaId\" ") .append("FROM OCD O ") .append("LEFT JOIN BOLETO B ON B.BOLETO_ID = O.BOLETO_ID ") .append("LEFT JOIN LOG_CONFERENCIA LOG ON LOG.OCD_ID = O.OCD_ID ") + .append("INNER JOIN USUARIO U ON O.USUARIO_ID = U.USUARIO_ID ") .append("WHERE O.ACTIVO = 1 ") .append("AND TO_DATE(O.FECINC,'DD/MM/YY') = :datamovimento "); @@ -744,6 +764,8 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO carregarLogConferencia(Long conferenciaId) throws BusinessException { try { StringBuilder sQuery = new StringBuilder(); - sQuery.append("SELECT DISTINCT log ") + sQuery.append("SELECT log ") .append("FROM LogConferencia log ") .append("WHERE log.activo = 1 ") .append("AND log.conferencia.conferenciaId = :conferenciaId "); @@ -893,7 +915,7 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO parametros = carregarParametros(null, conferencia.getEmpresa(), conferencia.getPuntoVenta()); StringBuilder sQuery = new StringBuilder(); - sQuery.append("SELECT DISTINCT EE.EVENTOEXTRA_ID AS \"eventoextraId\" ") + sQuery.append("SELECT EE.EVENTOEXTRA_ID AS \"eventoextraId\" ") .append("FROM EVENTO_EXTRA EE ") .append("JOIN TIPO_EVENTO_EXTRA TEE ON EE.TIPOEVENTOEXTRA_ID = TEE.TIPOEVENTOEXTRA_ID ") .append("LEFT JOIN COM_EMP_TIPOEVENTOEXTRA COMTEE ON COMTEE.TIPOEVENTOEXTRA_ID = TEE.TIPOEVENTOEXTRA_ID AND COMTEE.EMPRESA_ID = EE.EMPRESA_ID ") @@ -929,4 +951,36 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO 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); + } + } + } diff --git a/src/com/rjconsultores/ventaboletos/enums/comissao/BoletoStatusComissao.java b/src/com/rjconsultores/ventaboletos/enums/comissao/BoletoStatusComissao.java index a004259a8..d60851017 100644 --- a/src/com/rjconsultores/ventaboletos/enums/comissao/BoletoStatusComissao.java +++ b/src/com/rjconsultores/ventaboletos/enums/comissao/BoletoStatusComissao.java @@ -2,11 +2,11 @@ package com.rjconsultores.ventaboletos.enums.comissao; public enum BoletoStatusComissao { - BOLETOS, + BOLETOS_VENDIDOS, BOLETO_CANCELADO, BOLETO_DEVOLVIDO, BOLETO_MANUAL, - GAP, + GAP_VENDIDOS, GAP_CANCELADO, GAP_DEVOLVIDO; diff --git a/src/com/rjconsultores/ventaboletos/service/ConferenciaComissaoService.java b/src/com/rjconsultores/ventaboletos/service/ConferenciaComissaoService.java index 23da54bb2..e2e7af11b 100644 --- a/src/com/rjconsultores/ventaboletos/service/ConferenciaComissaoService.java +++ b/src/com/rjconsultores/ventaboletos/service/ConferenciaComissaoService.java @@ -15,6 +15,7 @@ import com.rjconsultores.ventaboletos.vo.comissao.ConferenciaComissaoVO; import com.rjconsultores.ventaboletos.vo.comissao.EventosFinanceirosVO; import com.rjconsultores.ventaboletos.vo.comissao.LogConferenciaVO; import com.rjconsultores.ventaboletos.vo.comissao.OcdVO; +import com.rjconsultores.ventaboletos.vo.comissao.ResumoComissao; public interface ConferenciaComissaoService extends GenericService { @@ -36,7 +37,7 @@ public interface ConferenciaComissaoService extends GenericService carregarBilhetesComissao(Conferencia conferencia, BoletoStatusComissao boletoStatusComissao) throws BusinessException; + public List carregarBilhetesComissao(List boletoComissaos, Conferencia conferencia, BoletoStatusComissao boletoStatusComissao) throws BusinessException; public List carregarOcds(Conferencia conferencia) throws BusinessException; @@ -52,6 +53,10 @@ public interface ConferenciaComissaoService extends GenericService lsEventosFinanceiros) throws BusinessException; - public OcdVO totalizarOcd(List lsOcd) throws BusinessException; + public OcdVO totalizarOcd(List lsOcd) throws BusinessException; + + public ResumoComissao gerarResumo(Conferencia conferencia, List boletoComissaos, List lsEventosFinanceiros, BigDecimal totalBilhetesManual, BigDecimal totalBilhetesVendidos, BigDecimal totalBilhetesCancelados, + BigDecimal totalBilhetesDevolvidos, BigDecimal totalBilhetesGap, BigDecimal totalBilhetesGapCancelados, BigDecimal totalBilhetesGapDevolvidos, + BigDecimal totalCreditosEventoFinanceiros, BigDecimal totalDebitosEventoFinanceiros, OcdVO totalOcd) throws BusinessException; } diff --git a/src/com/rjconsultores/ventaboletos/service/impl/ConferenciaComissaoServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/ConferenciaComissaoServiceImpl.java index 479524017..3f2474376 100644 --- a/src/com/rjconsultores/ventaboletos/service/impl/ConferenciaComissaoServiceImpl.java +++ b/src/com/rjconsultores/ventaboletos/service/impl/ConferenciaComissaoServiceImpl.java @@ -1,6 +1,7 @@ package com.rjconsultores.ventaboletos.service.impl; import java.math.BigDecimal; +import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.List; @@ -8,11 +9,13 @@ import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import com.rjconsultores.ventaboletos.constantes.Constantes; import com.rjconsultores.ventaboletos.dao.ConferenciaComissaoDAO; import com.rjconsultores.ventaboletos.entidad.Conferencia; import com.rjconsultores.ventaboletos.entidad.Empresa; import com.rjconsultores.ventaboletos.entidad.LogConferencia; import com.rjconsultores.ventaboletos.entidad.PuntoVenta; +import com.rjconsultores.ventaboletos.enums.IndStatusBoleto; import com.rjconsultores.ventaboletos.enums.comissao.BoletoStatusComissao; import com.rjconsultores.ventaboletos.exception.BusinessException; import com.rjconsultores.ventaboletos.service.ConferenciaComissaoService; @@ -20,8 +23,10 @@ import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; import com.rjconsultores.ventaboletos.vo.comissao.BoletoComissao; import com.rjconsultores.ventaboletos.vo.comissao.ConferenciaComissaoVO; import com.rjconsultores.ventaboletos.vo.comissao.EventosFinanceirosVO; +import com.rjconsultores.ventaboletos.vo.comissao.FormapagoVO; import com.rjconsultores.ventaboletos.vo.comissao.LogConferenciaVO; import com.rjconsultores.ventaboletos.vo.comissao.OcdVO; +import com.rjconsultores.ventaboletos.vo.comissao.ResumoComissao; @Service("conferenciaComissaoService") public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoService { @@ -114,8 +119,118 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic } @Override - public List carregarBilhetesComissao(Conferencia conferencia, BoletoStatusComissao boletoStatusComissao) throws BusinessException { - return conferenciaComissaoDAO.carregarBilhetesComissao(conferencia, boletoStatusComissao); + public List carregarBilhetesComissao(List boletoComissaos, Conferencia conferencia, BoletoStatusComissao boletoStatusComissao) throws BusinessException { + if(boletoComissaos == null) { + boletoComissaos = conferenciaComissaoDAO.carregarBilhetesComissao(conferencia); + } + + if(boletoStatusComissao == null) { + return boletoComissaos; + } + + switch (boletoStatusComissao) { + case BOLETOS_VENDIDOS: + return carregarBilhetesVendidos(boletoComissaos); + case BOLETO_MANUAL: + return carregarBilhetesManuais(boletoComissaos); + case BOLETO_CANCELADO: + return carregarBilhetesCancelados(boletoComissaos); + case BOLETO_DEVOLVIDO: + return carregarBilhetesDevolvidos(boletoComissaos); + case GAP_VENDIDOS: + return carregarBilhetesGapsVendidos(boletoComissaos); + case GAP_CANCELADO: + return carregarBilhetesGapCancelados(boletoComissaos); + case GAP_DEVOLVIDO: + return carregarBilhetesGapDevolvidos(boletoComissaos); + default: + break; + } + return new ArrayList(); + } + + private List carregarBilhetesVendidos(List boletoComissaos) { + List boletos = new ArrayList(); + for (BoletoComissao boletoComissao : boletoComissaos) { + if(IndStatusBoleto.V.getShortValue().equalsIgnoreCase(boletoComissao.getIndstatusboleto()) && + Constantes.TPV_BOLETO_REMOTO.intValue() != boletoComissao.getTipoVenta() && + Constantes.TPV_MANUAL.intValue() != boletoComissao.getTipoVenta()) { + boletos.add(boletoComissao); + } + } + return boletos; + } + + private List carregarBilhetesManuais(List boletoComissaos) { + List boletos = new ArrayList(); + for (BoletoComissao boletoComissao : boletoComissaos) { + if(IndStatusBoleto.V.getShortValue().equalsIgnoreCase(boletoComissao.getIndstatusboleto()) && + Constantes.TPV_MANUAL.intValue() == boletoComissao.getTipoVenta()) { + boletos.add(boletoComissao); + } + } + return boletos; + } + + private List carregarBilhetesCancelados(List boletoComissaos) { + List boletos = new ArrayList(); + for (BoletoComissao boletoComissao : boletoComissaos) { + if(IndStatusBoleto.C.getShortValue().equalsIgnoreCase(boletoComissao.getIndstatusboleto()) && + Constantes.MVO_CANCEL_CANCELACION.intValue() == boletoComissao.getMotivoCancelacionId() && + Constantes.TPV_BOLETO_REMOTO.intValue() != boletoComissao.getTipoVenta() && + Constantes.TPV_MANUAL.intValue() != boletoComissao.getTipoVenta()) { + boletos.add(boletoComissao); + } + } + return boletos; + } + + private List carregarBilhetesDevolvidos(List boletoComissaos) { + List boletos = new ArrayList(); + for (BoletoComissao boletoComissao : boletoComissaos) { + if(IndStatusBoleto.C.getShortValue().equalsIgnoreCase(boletoComissao.getIndstatusboleto()) && + Constantes.MVO_CANCEL_DEVOLUCAO.intValue() == boletoComissao.getMotivoCancelacionId() && + Constantes.TPV_BOLETO_REMOTO.intValue() != boletoComissao.getTipoVenta() && + Constantes.TPV_MANUAL.intValue() != boletoComissao.getTipoVenta()) { + boletos.add(boletoComissao); + } + } + return boletos; + } + + private List carregarBilhetesGapsVendidos(List boletoComissaos) { + List boletos = new ArrayList(); + for (BoletoComissao boletoComissao : boletoComissaos) { + if(IndStatusBoleto.V.getShortValue().equalsIgnoreCase(boletoComissao.getIndstatusboleto()) && + Constantes.TPV_BOLETO_REMOTO.intValue() == boletoComissao.getTipoVenta()) { + boletos.add(boletoComissao); + } + } + return boletos; + } + + private List carregarBilhetesGapCancelados(List boletoComissaos) { + List boletos = new ArrayList(); + for (BoletoComissao boletoComissao : boletoComissaos) { + if(IndStatusBoleto.C.getShortValue().equalsIgnoreCase(boletoComissao.getIndstatusboleto()) && + Constantes.MVO_CANCEL_CANCELACION.intValue() == boletoComissao.getMotivoCancelacionId() && + Constantes.TPV_BOLETO_REMOTO.intValue() == boletoComissao.getTipoVenta()) { + boletos.add(boletoComissao); + } + } + return boletos; + } + + private List carregarBilhetesGapDevolvidos(List boletoComissaos) { + List boletos = new ArrayList(); + for (BoletoComissao boletoComissao : boletoComissaos) { + if(IndStatusBoleto.C.getShortValue().equalsIgnoreCase(boletoComissao.getIndstatusboleto()) && + Constantes.MVO_CANCEL_DEVOLUCAO.intValue() == boletoComissao.getMotivoCancelacionId() && + Constantes.TPV_BOLETO_REMOTO.intValue() == boletoComissao.getTipoVenta()) { + boletos.add(boletoComissao); + } + } + return boletos; } @Override @@ -182,4 +297,52 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic return total; } + @Override + public ResumoComissao gerarResumo(Conferencia conferencia, List boletoComissaos, List lsEventosFinanceiros, BigDecimal totalBilhetesManual, BigDecimal totalBilhetesVendidos, + BigDecimal totalBilhetesCancelados, BigDecimal totalBilhetesDevolvidos, BigDecimal totalBilhetesGap, BigDecimal totalBilhetesGapCancelados, + BigDecimal totalBilhetesGapDevolvidos, BigDecimal totalCreditosEventoFinanceiros, BigDecimal totalDebitosEventoFinanceiros, OcdVO totalOcd) throws BusinessException { + ResumoComissao resumoComissao = new ResumoComissao(); + resumoComissao.setTotalDevolvidos(totalBilhetesDevolvidos.add(totalBilhetesGapDevolvidos)); + resumoComissao.setTotalCancelados(totalBilhetesCancelados.add(totalBilhetesGapCancelados)); + resumoComissao.setTotalVendas(totalBilhetesVendidos.add(totalBilhetesManual).add(totalBilhetesGap)); + resumoComissao.setTotalReceitas(totalCreditosEventoFinanceiros); + resumoComissao.setTotalDespesas(totalDebitosEventoFinanceiros); + resumoComissao.setTotalOcd(totalOcd); + resumoComissao.setValorDeposito(conferenciaComissaoDAO.carregarTotalFechamentoContaCorrente(conferencia)); + + carregarTotalFormapago(resumoComissao, boletoComissaos, lsEventosFinanceiros); + + return resumoComissao; + } + + private void carregarTotalFormapago(ResumoComissao resumoComissao, List boletoComissaos, List lsEventosFinanceiros) { + List totalFormapagos = new ArrayList(); + for (BoletoComissao boletoComissao : boletoComissaos) { + if(boletoComissao.getIndstatusboleto().equals(IndStatusBoleto.V.getShortValue()) && + boletoComissao.getMotivoCancelacionId() == null) { + for (FormapagoVO formapagoBoleto : boletoComissao.getFormapagos()) { + FormapagoVO formapago; + if(totalFormapagos.contains(formapagoBoleto)) { + formapago = totalFormapagos.get(totalFormapagos.indexOf(formapagoBoleto)); + formapago.setImporte(formapagoBoleto.getImporte().add(formapago.getImporte())); + } else { + formapago = new FormapagoVO(formapagoBoleto.getFormapagoId(), formapagoBoleto.getDescpago(), null, formapagoBoleto.getImporte()); + totalFormapagos.add(formapagoBoleto); + } + } + } + } + + for (EventosFinanceirosVO eventosFinanceiros : lsEventosFinanceiros) { + FormapagoVO formapagoEventoFinanceiro = new FormapagoVO(eventosFinanceiros.getFormapagoId(), eventosFinanceiros.getDescpago(), null, eventosFinanceiros.getImpingreso()); + if(totalFormapagos.contains(formapagoEventoFinanceiro)) { + FormapagoVO formapago = totalFormapagos.get(totalFormapagos.indexOf(formapagoEventoFinanceiro)); + formapago.setImporte(formapagoEventoFinanceiro.getImporte().add(formapago.getImporte())); + } else { + totalFormapagos.add(formapagoEventoFinanceiro); + } + } + resumoComissao.setTotalFormapago(totalFormapagos); + } + } diff --git a/src/com/rjconsultores/ventaboletos/utilerias/BigDecimalUtil.java b/src/com/rjconsultores/ventaboletos/utilerias/BigDecimalUtil.java new file mode 100644 index 000000000..86f4ccdd7 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/utilerias/BigDecimalUtil.java @@ -0,0 +1,37 @@ +package com.rjconsultores.ventaboletos.utilerias; + +import java.math.BigDecimal; +import java.text.NumberFormat; +import java.text.ParseException; +import java.util.Locale; + +import org.apache.commons.lang.StringUtils; + +/** + * + * @author Wilian + * + */ +public class BigDecimalUtil { + + public static BigDecimal getStringToBigDecimal(String value, Locale locale) throws ParseException { + if(value != null && StringUtils.isNotBlank(value)) { + NumberFormat nf = NumberFormat.getInstance(locale); + return new BigDecimal(nf.parse(value).toString()); + } + + return null; + } + + public static String getBigDecimalToStringDouble2CasasDecimaisFormatado(BigDecimal value, Locale locale) { + if(value != null) { + NumberFormat nf = NumberFormat.getInstance(locale); + nf.setMinimumFractionDigits(2); + nf.setMaximumFractionDigits(2); + return nf.format(value.doubleValue()); + } + + return null; + } + +} diff --git a/src/com/rjconsultores/ventaboletos/utilerias/LocaleUtil.java b/src/com/rjconsultores/ventaboletos/utilerias/LocaleUtil.java new file mode 100644 index 000000000..31e94c2b4 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/utilerias/LocaleUtil.java @@ -0,0 +1,36 @@ +package com.rjconsultores.ventaboletos.utilerias; + +import java.util.Locale; + +import org.zkoss.util.Locales; + +/** + * Retorna o locale atual, caso o locale não seja suportado pelo sistema,
+ * será retornado o locale pt_br + * @author Wilian + */ +public class LocaleUtil { + + + private static Locale LOCALE_PT_BR = new Locale("pt", "br"); + private static Locale LOCALE_ES_MX = new Locale("es", "mx"); + + private static Locale [] LOCALES = new Locale[]{LOCALE_PT_BR, LOCALE_ES_MX}; + + /** + * Retorna o locale atual, caso o locale não seja suportado pelo sistema,
+ * será retornado o locale pt_br + * @return + */ + public static Locale getLocale() { + Locale localeCurrent = Locales.getCurrent(); + for (Locale locale : LOCALES) { + if(localeCurrent.getLanguage().equals(locale.getLanguage())) { + return localeCurrent; + } + } + + return LOCALE_PT_BR; + } + +} diff --git a/src/com/rjconsultores/ventaboletos/vo/comissao/BoletoComissao.java b/src/com/rjconsultores/ventaboletos/vo/comissao/BoletoComissao.java index 36cbc29bc..d1a8216fc 100644 --- a/src/com/rjconsultores/ventaboletos/vo/comissao/BoletoComissao.java +++ b/src/com/rjconsultores/ventaboletos/vo/comissao/BoletoComissao.java @@ -40,10 +40,16 @@ public class BoletoComissao { private Integer formapagoId; private String descpago; private Boolean indconferenciafisicacomissao; + private BigDecimal importeFp; private Set formapagos; private BigDecimal icmsBase; private String nombusuario; + private Integer comempformapagoId; + private Integer comempcategoriaId; + private Long logconferenciaId; + + private boolean conferido; public Integer getEmpresaId() { return empresaId; @@ -366,4 +372,48 @@ public class BoletoComissao { this.nombusuario = nombusuario; } + public BigDecimal getImporteFp() { + return importeFp; + } + + public void setImporteFp(BigDecimal importeFp) { + this.importeFp = importeFp; + } + + public Integer getComempformapagoId() { + return comempformapagoId; + } + + public void setComempformapagoId(Integer comempformapagoId) { + this.comempformapagoId = comempformapagoId; + } + + public Integer getComempcategoriaId() { + return comempcategoriaId; + } + + public void setComempcategoriaId(Integer comempcategoriaId) { + this.comempcategoriaId = comempcategoriaId; + } + + public boolean isExigeConferencia() { + return getComempcategoriaId() != null || getComempformapagoId() != null; + } + + public boolean isConferido() { + return conferido; + } + + public void setConferido(boolean conferido) { + this.conferido = conferido; + } + + public Long getLogconferenciaId() { + return logconferenciaId; + } + + public void setLogconferenciaId(Long logconferenciaId) { + this.logconferenciaId = logconferenciaId; + } + } \ No newline at end of file diff --git a/src/com/rjconsultores/ventaboletos/vo/comissao/EventosFinanceirosVO.java b/src/com/rjconsultores/ventaboletos/vo/comissao/EventosFinanceirosVO.java index beb617fff..d5a2eadb9 100644 --- a/src/com/rjconsultores/ventaboletos/vo/comissao/EventosFinanceirosVO.java +++ b/src/com/rjconsultores/ventaboletos/vo/comissao/EventosFinanceirosVO.java @@ -21,6 +21,13 @@ public class EventosFinanceirosVO { private String descpago; private Boolean indconferenciafisicacomissao; private String indtipo; /* 0- Debito, 1- Credito */ + private String nombusuario; + + private Integer comemptipoeventoextraId; + private Integer comempformapagoId; + + private Long logconferenciaId; + private boolean conferido; public Long getEventoextraId() { return eventoextraId; @@ -126,4 +133,48 @@ public class EventosFinanceirosVO { return isCredito() ? Labels.getLabel("conferenciaController.lbCredito.value") : Labels.getLabel("conferenciaController.lbDebito.value"); } + public String getNombusuario() { + return nombusuario; + } + + public void setNombusuario(String nombusuario) { + this.nombusuario = nombusuario; + } + + public Long getLogconferenciaId() { + return logconferenciaId; + } + + public void setLogconferenciaId(Long logconferenciaId) { + this.logconferenciaId = logconferenciaId; + } + + public boolean isConferido() { + return conferido; + } + + public void setConferido(boolean conferido) { + this.conferido = conferido; + } + + public Integer getComemptipoeventoextraId() { + return comemptipoeventoextraId; + } + + public void setComemptipoeventoextraId(Integer comemptipoeventoextraId) { + this.comemptipoeventoextraId = comemptipoeventoextraId; + } + + public Integer getComempformapagoId() { + return comempformapagoId; + } + + public void setComempformapagoId(Integer comempformapagoId) { + this.comempformapagoId = comempformapagoId; + } + + public boolean isExigeConferencia() { + return getComemptipoeventoextraId() != null || getComempformapagoId() != null; + } + } diff --git a/src/com/rjconsultores/ventaboletos/vo/comissao/FormapagoVO.java b/src/com/rjconsultores/ventaboletos/vo/comissao/FormapagoVO.java index 8fa376dc4..f3a8555dd 100644 --- a/src/com/rjconsultores/ventaboletos/vo/comissao/FormapagoVO.java +++ b/src/com/rjconsultores/ventaboletos/vo/comissao/FormapagoVO.java @@ -1,20 +1,27 @@ package com.rjconsultores.ventaboletos.vo.comissao; +import java.math.BigDecimal; + +import com.rjconsultores.ventaboletos.utilerias.BigDecimalUtil; +import com.rjconsultores.ventaboletos.utilerias.LocaleUtil; + public class FormapagoVO { private Integer formapagoId; private String descpago; private Boolean indconferenciafisicacomissao; + private BigDecimal importe; public FormapagoVO() { super(); } - public FormapagoVO(Integer formapagoId, String descpago, Boolean indconferenciafisicacomissao) { + public FormapagoVO(Integer formapagoId, String descpago, Boolean indconferenciafisicacomissao, BigDecimal importeFp) { this(); this.formapagoId = formapagoId; this.descpago = descpago; this.indconferenciafisicacomissao = indconferenciafisicacomissao; + this.importe = importeFp; } public Integer getFormapagoId() { @@ -39,6 +46,41 @@ public class FormapagoVO { public void setIndconferenciafisicacomissao(Boolean indconferenciafisicacomissao) { this.indconferenciafisicacomissao = indconferenciafisicacomissao; - } + } + + public BigDecimal getImporte() { + return importe; + } + + public void setImporte(BigDecimal importe) { + this.importe = importe; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((formapagoId == null) ? 0 : formapagoId.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + FormapagoVO other = (FormapagoVO) obj; + if (formapagoId == null) { + if (other.formapagoId != null) + return false; + } else if (!formapagoId.equals(other.formapagoId)) + return false; + return true; + } + + public String getImporteFormatado() { + return BigDecimalUtil.getBigDecimalToStringDouble2CasasDecimaisFormatado(getImporte(), LocaleUtil.getLocale()); + } } diff --git a/src/com/rjconsultores/ventaboletos/vo/comissao/LogConferenciaVO.java b/src/com/rjconsultores/ventaboletos/vo/comissao/LogConferenciaVO.java index 505832409..51e59259f 100644 --- a/src/com/rjconsultores/ventaboletos/vo/comissao/LogConferenciaVO.java +++ b/src/com/rjconsultores/ventaboletos/vo/comissao/LogConferenciaVO.java @@ -43,6 +43,11 @@ public class LogConferenciaVO { this.numfoliosistema = numfoliosistema; } + public LogConferenciaVO(Long logconferenciaId) { + this(); + this.logconferenciaId = logconferenciaId; + } + public Long getLogconferenciaId() { return logconferenciaId; } diff --git a/src/com/rjconsultores/ventaboletos/vo/comissao/OcdVO.java b/src/com/rjconsultores/ventaboletos/vo/comissao/OcdVO.java index e4fb00dc4..115aada52 100644 --- a/src/com/rjconsultores/ventaboletos/vo/comissao/OcdVO.java +++ b/src/com/rjconsultores/ventaboletos/vo/comissao/OcdVO.java @@ -6,6 +6,8 @@ import java.util.Date; import org.zkoss.util.resource.Labels; import com.rjconsultores.ventaboletos.enums.comissao.StatusLogConferencia; +import com.rjconsultores.ventaboletos.utilerias.BigDecimalUtil; +import com.rjconsultores.ventaboletos.utilerias.LocaleUtil; public class OcdVO { @@ -31,8 +33,11 @@ public class OcdVO { private Date fecmodif; private Integer usuarioId; private Boolean activo; + private String nombusuario; private Integer status; + private Long logconferenciaId; + private boolean conferido; public Long getOcdId() { return ocdId; @@ -182,4 +187,36 @@ public class OcdVO { return getIndpago() != null && getIndpago() ? Labels.getLabel("conferenciaController.lbl.sim") : Labels.getLabel("conferenciaController.lbl.nao"); } + public String getNombusuario() { + return nombusuario; + } + + public void setNombusuario(String nombusuario) { + this.nombusuario = nombusuario; + } + + public String getValorPagarFormatado() { + return BigDecimalUtil.getBigDecimalToStringDouble2CasasDecimaisFormatado(getValorPagar(), LocaleUtil.getLocale()); + } + + public String getPenalizacionFormatado() { + return BigDecimalUtil.getBigDecimalToStringDouble2CasasDecimaisFormatado(getPenalizacion(), LocaleUtil.getLocale()); + } + + public Long getLogconferenciaId() { + return logconferenciaId; + } + + public void setLogconferenciaId(Long logconferenciaId) { + this.logconferenciaId = logconferenciaId; + } + + public boolean isConferido() { + return conferido; + } + + public void setConferido(boolean conferido) { + this.conferido = conferido; + } + } diff --git a/src/com/rjconsultores/ventaboletos/vo/comissao/ResumoComissao.java b/src/com/rjconsultores/ventaboletos/vo/comissao/ResumoComissao.java new file mode 100644 index 000000000..54f5fe2d2 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/vo/comissao/ResumoComissao.java @@ -0,0 +1,130 @@ +package com.rjconsultores.ventaboletos.vo.comissao; + +import java.math.BigDecimal; +import java.util.List; + +import com.rjconsultores.ventaboletos.utilerias.BigDecimalUtil; +import com.rjconsultores.ventaboletos.utilerias.LocaleUtil; + +public class ResumoComissao { + + private BigDecimal totalVendas; + private BigDecimal totalCancelados; + private BigDecimal totalDevolvidos; + private BigDecimal totalTroca; + private BigDecimal totalReceitas; + private BigDecimal totalDespesas; + private BigDecimal valorDeposito; + private OcdVO totalOcd; + + private List totalFormapago; + + public BigDecimal getTotalVendas() { + return totalVendas; + } + + public void setTotalVendas(BigDecimal totalVendas) { + this.totalVendas = totalVendas; + } + + public BigDecimal getTotalCancelados() { + return totalCancelados; + } + + public void setTotalCancelados(BigDecimal totalCancelados) { + this.totalCancelados = totalCancelados; + } + + public BigDecimal getTotalDevolvidos() { + return totalDevolvidos; + } + + public void setTotalDevolvidos(BigDecimal totalDevolvidos) { + this.totalDevolvidos = totalDevolvidos; + } + + public BigDecimal getTotalTroca() { + return totalTroca; + } + + public void setTotalTroca(BigDecimal totalTroca) { + this.totalTroca = totalTroca; + } + + public BigDecimal getTotalReceitas() { + return totalReceitas; + } + + public void setTotalReceitas(BigDecimal totalReceitas) { + this.totalReceitas = totalReceitas; + } + + public BigDecimal getTotalDespesas() { + return totalDespesas; + } + + public void setTotalDespesas(BigDecimal totalDespesas) { + this.totalDespesas = totalDespesas; + } + + public BigDecimal getValorDeposito() { + return valorDeposito; + } + + public void setValorDeposito(BigDecimal valorDeposito) { + this.valorDeposito = valorDeposito; + } + + public List getTotalFormapago() { + return totalFormapago; + } + + public void setTotalFormapago(List totalFormapago) { + this.totalFormapago = totalFormapago; + } + + public OcdVO getTotalOcd() { + return totalOcd; + } + + public void setTotalOcd(OcdVO totalOcd) { + this.totalOcd = totalOcd; + } + + public String getTotalVendasFormatado() { + return BigDecimalUtil.getBigDecimalToStringDouble2CasasDecimaisFormatado(getTotalVendas(), LocaleUtil.getLocale()); + } + + public String getTotalCanceladosFormatado() { + return BigDecimalUtil.getBigDecimalToStringDouble2CasasDecimaisFormatado(getTotalCancelados(), LocaleUtil.getLocale()); + } + + public String getTotalDevolvidosFormatado() { + return BigDecimalUtil.getBigDecimalToStringDouble2CasasDecimaisFormatado(getTotalDevolvidos(), LocaleUtil.getLocale()); + } + + public String getTotalTrocaFormatado() { + return BigDecimalUtil.getBigDecimalToStringDouble2CasasDecimaisFormatado(getTotalTroca(), LocaleUtil.getLocale()); + } + + public String getTotalReceitasFormatado() { + return BigDecimalUtil.getBigDecimalToStringDouble2CasasDecimaisFormatado(getTotalReceitas(), LocaleUtil.getLocale()); + } + + public String getTotalDespesasFormatado() { + return BigDecimalUtil.getBigDecimalToStringDouble2CasasDecimaisFormatado(getTotalDespesas(), LocaleUtil.getLocale()); + } + + public BigDecimal getTotalDiferenca() { + return getTotalReceitas().subtract(getTotalDespesas()); + } + + public String getTotalDiferencaFormatado() { + return BigDecimalUtil.getBigDecimalToStringDouble2CasasDecimaisFormatado(getTotalDiferenca(), LocaleUtil.getLocale()); + } + + public String getValorDepositoFormatado() { + return BigDecimalUtil.getBigDecimalToStringDouble2CasasDecimaisFormatado(getValorDeposito(), LocaleUtil.getLocale()); + } + +}