edgar 2016-09-27 12:38:12 +00:00
parent 0654b60d2d
commit 88f07cf982
7 changed files with 248 additions and 171 deletions

View File

@ -31,4 +31,6 @@ public interface PuntoVentaDAO extends GenericDAO<PuntoVenta, Integer> {
public List<PuntoVenta> buscarPuntosVentaMovimentacionBilhetes(List<Empresa> empresas);
public List<PuntoVenta> buscarPuntoVentaPorTipoEstoque(PtovtaTipoEstoque tipoEstoque);
}
public Integer quantidadeECFPorPuntoVenta(Integer empresaID, Integer puntoVentaID);
}

View File

@ -4,9 +4,8 @@
*/
package com.rjconsultores.ventaboletos.dao.hibernate;
import com.rjconsultores.ventaboletos.dao.ConstanteDAO;
import com.rjconsultores.ventaboletos.entidad.Constante;
import java.util.List;
import org.hibernate.Criteria;
import org.hibernate.SessionFactory;
import org.hibernate.criterion.Order;
@ -15,6 +14,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Repository;
import com.rjconsultores.ventaboletos.dao.ConstanteDAO;
import com.rjconsultores.ventaboletos.entidad.Constante;
/**
*
* @author Administrador

View File

@ -4,6 +4,7 @@
*/
package com.rjconsultores.ventaboletos.dao.hibernate;
import java.math.BigDecimal;
import java.util.List;
import org.hibernate.Criteria;
@ -28,7 +29,7 @@ import com.rjconsultores.ventaboletos.entidad.Parada;
import com.rjconsultores.ventaboletos.entidad.PtovtaTipoEstoque;
import com.rjconsultores.ventaboletos.entidad.PuntoVenta;
import com.rjconsultores.ventaboletos.entidad.Usuario;
/**
*
* @author Administrador
@ -36,7 +37,7 @@ import com.rjconsultores.ventaboletos.entidad.Usuario;
@Repository("puntoVentaDAO")
public class PuntoVentaHibernateDAO extends GenericHibernateDAO<PuntoVenta, Integer>
implements PuntoVentaDAO {
public static final int ID_PUNTO_VENTA_TODOS = -1;
@Autowired
@ -57,7 +58,6 @@ public class PuntoVentaHibernateDAO extends GenericHibernateDAO<PuntoVenta, Inte
return c.list();
}
public List<PuntoVenta> buscaLike(String strEstacion, boolean sinTodos) {
Criteria c = getSession().createCriteria(getPersistentClass());
@ -65,13 +65,11 @@ public class PuntoVentaHibernateDAO extends GenericHibernateDAO<PuntoVenta, Inte
Criterion crActivo = Restrictions.eq("activo", Boolean.TRUE);
if (sinTodos){
if (sinTodos) {
Criterion crSinTodos = Restrictions.ne("puntoventaId", ID_PUNTO_VENTA_TODOS);
c.add(crSinTodos);
}
PtovtaTipoEstoque supr = ptovtaTipoEstoqueDAO.buscarTipoSuprimento();
PtovtaTipoEstoque cont = ptovtaTipoEstoqueDAO.buscarTipoContabilidade();
@ -193,4 +191,23 @@ public class PuntoVentaHibernateDAO extends GenericHibernateDAO<PuntoVenta, Inte
return puntosVenta;
}
@Override
public Integer quantidadeECFPorPuntoVenta(Integer empresaID, Integer puntoVentaID) {
String query = "SELECT sum(NECF) numeroECF "
+ " FROM (SELECT count(e.ESTACION_ID) AS NECF "
+ " FROM ESTACION e "
+ " INNER JOIN ESTACION_IMPRESORA ei ON ei.ESTACION_ID = e.ESTACION_ID "
+ " WHERE ei.TIPOIMPRESSORA = 1 "
+ " AND ei.ACTIVO = 1 "
+ " AND e.PUNTOVENTA_ID = :punto_venta_id "
+ " AND ei.EMPRESA_ID = :empresa_id "
+ " GROUP BY e.ESTACION_ID)";
Query q = getSession().createSQLQuery(query);
q.setInteger("punto_venta_id", puntoVentaID);
q.setInteger("empresa_id", empresaID);
BigDecimal quantidadeEcf = (BigDecimal) q.uniqueResult();
return quantidadeEcf == null ? 0 : quantidadeEcf.intValue();
}
}

View File

@ -22,57 +22,60 @@ import com.rjconsultores.ventaboletos.vo.comissao.OcdVO;
import com.rjconsultores.ventaboletos.vo.comissao.ResumoComissao;
public interface ConferenciaComissaoService extends GenericService<Conferencia, Long> {
public Conferencia suscribirOrActualizacion(Conferencia entidad);
public List<ConferenciaComissaoVO> carregarConferenciaComissao(String competencia, Empresa empresa, PuntoVenta puntoVenta) throws BusinessException;
public Conferencia confirmarChegadaMalote(Conferencia conferencia) throws BusinessException;
public Conferencia encerrarMovimentoDiario(Conferencia conferencia) throws BusinessException;
public List<EventosFinanceirosVO> carregarEventosFinanceiros(Conferencia conferencia) throws BusinessException;
public List<LogConferenciaVO> carregarLogConferencia(Conferencia conferencia) throws BusinessException;
public LogConferencia suscribirLogConferencia(LogConferencia logConferencia) throws BusinessException;
public void borrarLogConferencia(LogConferencia logConferencia) throws BusinessException;
public LogConferencia obtenerLogConferenciaID(Long logconferenciaId);
public List<BoletoComissao> carregarBilhetesComissao(List<BoletoComissao> boletoComissaos, Conferencia conferencia, BoletoStatusComissao boletoStatusComissao) throws BusinessException;
public List<OcdVO> carregarOcds(Conferencia conferencia) throws BusinessException;
public Conferencia reabrirMovimentoDiario(Conferencia conferencia) throws BusinessException;
public Conferencia obtenerConferenciaDataMovimento(Date datamovimento, Integer puntoventaId, Integer empresaId) throws BusinessException;
public boolean isBilhetesSemConferencia(List<BoletoComissao> lsBoletoComissao) throws BusinessException;
public boolean isEventosFinanceirosSemConferencia(List<EventosFinanceirosVO> lsEventosFinanceiros) throws BusinessException;
public boolean isOcdSemConferencia(List<OcdVO> lsOcd) throws BusinessException;
public BigDecimal totalizarBoletoComissao(List<BoletoComissao> lsBoletoComissao, IndStatusBoleto... statusBilhete) throws BusinessException;
public BigDecimal totalizarEventosFinanceiros(List<EventosFinanceirosVO> lsEventosFinanceiros) throws BusinessException;
public BigDecimal totalizarBoletoComissao(List<BoletoComissao> lsBoletoComissao, IndStatusBoleto... statusBilhete) throws BusinessException;
public BigDecimal totalizarEventosFinanceiros(List<EventosFinanceirosVO> lsEventosFinanceiros) throws BusinessException;
public OcdVO totalizarOcd(List<OcdVO> lsOcd) throws BusinessException;
public ResumoComissao gerarResumo(Conferencia conferencia, List<BoletoComissao> boletoComissaos, List<EventosFinanceirosVO> lsEventosFinanceiros, BigDecimal totalBilhetesManual, BigDecimal totalBilhetesVendidos, BigDecimal totalBilhetesCancelados,
BigDecimal totalBilhetesDevolvidos, BigDecimal totalBilhetesGap, BigDecimal totalBilhetesGapCancelados, BigDecimal totalBilhetesGapDevolvidos,
BigDecimal totalCreditosEventoFinanceiros, BigDecimal totalDebitosEventoFinanceiros, OcdVO totalOcd) throws BusinessException;
BigDecimal totalBilhetesDevolvidos, BigDecimal totalBilhetesGap, BigDecimal totalBilhetesGapCancelados, BigDecimal totalBilhetesGapDevolvidos,
BigDecimal totalCreditosEventoFinanceiros, BigDecimal totalDebitosEventoFinanceiros, OcdVO totalOcd) throws BusinessException;
public EtiquetaMalote decodificarEtiquetaMalote(String codigoBarras) throws BusinessException;
public void confirmarChegadaMalote(EtiquetaMalote etiquetaMalote) throws BusinessException;
public boolean isConferenciaCompetenciaEncerrada(String competencia, Empresa empresa, PuntoVenta puntoVenta) throws BusinessException;
public Map<BoletoStatusComissao, BigDecimal> totalizarBoletoComissaoDevolvidosTrocaOcd(List<BoletoComissao> lsBoletoComissao) throws BusinessException;
public DiaConferenciaComissaoVO carregarConferenciaRegistrada(Date datamovimento, Empresa empresa, PuntoVenta puntoVenta) throws BusinessException;
public Integer quantidadeECFPorPuntoVenta(Integer empresaID, Integer puntoVentaID);
public void enviarEmailIrregularidadeECF(String email, String msg,String assunto)throws Exception ;
}

View File

@ -7,10 +7,6 @@ package com.rjconsultores.ventaboletos.service;
import com.rjconsultores.ventaboletos.entidad.Constante;
import java.util.List;
/**
*
* @author Administrador
*/
public interface ConstanteService extends GenericService<Constante, Integer> {
public Constante buscarPorNomeConstante(String nomeConstante);

View File

@ -15,6 +15,7 @@ import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.zkoss.util.resource.Labels;
import com.rjconsultores.ventaboletos.dao.ConferenciaComissaoDAO;
import com.rjconsultores.ventaboletos.dao.EmpresaDAO;
@ -28,8 +29,10 @@ 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;
import com.rjconsultores.ventaboletos.service.ConstanteService;
import com.rjconsultores.ventaboletos.utilerias.DateUtil;
import com.rjconsultores.ventaboletos.utilerias.LocaleUtil;
import com.rjconsultores.ventaboletos.utilerias.SendMail;
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
import com.rjconsultores.ventaboletos.vo.comissao.BoletoComissao;
import com.rjconsultores.ventaboletos.vo.comissao.ConferenciaComissaoVO;
@ -43,17 +46,26 @@ import com.rjconsultores.ventaboletos.vo.comissao.ResumoComissao;
@Service("conferenciaComissaoService")
public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoService {
private static Logger log = Logger.getLogger(ConferenciaComissaoService.class);
@Autowired
private ConferenciaComissaoDAO conferenciaComissaoDAO;
@Autowired
private EmpresaDAO empresaDAO;
@Autowired
private PuntoVentaDAO puntoVentaDAO;
private static final String SMTP_HOST = "SMTP_HOST";
private static final String SMTP_USER = "SMTP_USER";
private static final String SMTP_EMAIL = "SMTP_EMAIL";
private static final String SMTP_PORT = "SMTP_PORT";
private static final String SMTP_PASS = "SMTP_PASS";
private static Logger log = Logger.getLogger(ConferenciaComissaoService.class);
@Autowired
private ConferenciaComissaoDAO conferenciaComissaoDAO;
@Autowired
private EmpresaDAO empresaDAO;
@Autowired
private PuntoVentaDAO puntoVentaDAO;
@Autowired
ConstanteService constanteService;
@Override
public List<Conferencia> obtenerTodos() {
@ -138,7 +150,7 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic
logConferencia.setFecmodif(new Date());
conferenciaComissaoDAO.borrarLogConferencia(logConferencia);
}
@Override
public LogConferencia obtenerLogConferenciaID(Long logconferenciaId) {
return conferenciaComissaoDAO.obtenerLogConferenciaID(logconferenciaId);
@ -146,20 +158,20 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic
@Override
public List<BoletoComissao> carregarBilhetesComissao(List<BoletoComissao> boletoComissaos, Conferencia conferencia, BoletoStatusComissao boletoStatusComissao) throws BusinessException {
if(boletoComissaos == null) {
if (boletoComissaos == null) {
boletoComissaos = conferenciaComissaoDAO.carregarBilhetesComissao(conferencia);
}
if(boletoStatusComissao == null) {
if (boletoStatusComissao == null) {
return boletoComissaos;
}
Empresa empresa = empresaDAO.obtenerID(conferencia.getEmpresa().getEmpresaId());
ComEmpConferencia comEmpConferencia = null;
if(empresa.getComEmpConferencias() != null && !empresa.getComEmpConferencias().isEmpty()) {
if (empresa.getComEmpConferencias() != null && !empresa.getComEmpConferencias().isEmpty()) {
comEmpConferencia = empresa.getComEmpConferencias().iterator().next();
}
List<BoletoComissao> retorno = new ArrayList<BoletoComissao>();
switch (boletoStatusComissao) {
case BOLETOS_VENDIDOS:
@ -188,38 +200,38 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic
}
return retorno;
}
private Set<BoletoComissao> carregarBilhetesManuais(List<BoletoComissao> boletoComissaos, ComEmpConferencia comEmpConferencia) {
Set<BoletoComissao> boletos = new HashSet<BoletoComissao>();
for (BoletoComissao boletoComissao : boletoComissaos) {
if(boletoComissao.isBilhetesManualVendido()) {
if (boletoComissao.isBilhetesManualVendido()) {
if(comEmpConferencia != null) {
if (comEmpConferencia != null) {
boletoComissao.setExigeConferenciaAba(comEmpConferencia.getIndbilhetemanual());
}
boletos.add(boletoComissao);
}
}
return boletos;
}
private Set<BoletoComissao> carregarBilhetesVendidos(List<BoletoComissao> boletoComissaos, ComEmpConferencia comEmpConferencia) {
Set<BoletoComissao> boletos = new HashSet<BoletoComissao>();
for (BoletoComissao boletoComissao : boletoComissaos) {
if(boletoComissao.isBilheteNormalVendido() ||
boletoComissao.isBilheteEntregaGap() ||
boletoComissao.isBilheteNormalChekin() ||
boletoComissao.isBilheteAberto() ||
boletoComissao.isBilheteConfirmaAbertoTroca() ||
boletoComissao.isBilheteEntregaAberto()) {
if(comEmpConferencia != null) {
if (boletoComissao.isBilheteNormalVendido() ||
boletoComissao.isBilheteEntregaGap() ||
boletoComissao.isBilheteNormalChekin() ||
boletoComissao.isBilheteAberto() ||
boletoComissao.isBilheteConfirmaAbertoTroca() ||
boletoComissao.isBilheteEntregaAberto()) {
if (comEmpConferencia != null) {
boletoComissao.setExigeConferenciaAba(comEmpConferencia.getIndbilhetevendido());
}
boletos.add(boletoComissao);
}
}
return boletos;
@ -228,17 +240,17 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic
private Set<BoletoComissao> carregarBilhetesCancelados(List<BoletoComissao> boletoComissaos, ComEmpConferencia comEmpConferencia) {
Set<BoletoComissao> boletos = new HashSet<BoletoComissao>();
for (BoletoComissao boletoComissao : boletoComissaos) {
if(boletoComissao.isBilheteNormalCancelado() ||
boletoComissao.isBilheteNormalTrocadoCancelado() ||
boletoComissao.isBilheteConfirmadoAbertoCancelado() ||
boletoComissao.isBilheteEntregaGapCancelado()) {
if (boletoComissao.isBilheteNormalCancelado() ||
boletoComissao.isBilheteNormalTrocadoCancelado() ||
boletoComissao.isBilheteConfirmadoAbertoCancelado() ||
boletoComissao.isBilheteEntregaGapCancelado()) {
if(comEmpConferencia != null) {
if (comEmpConferencia != null) {
boletoComissao.setExigeConferenciaAba(comEmpConferencia.getIndbilhetecancelado());
}
boletos.add(boletoComissao);
}
}
return boletos;
@ -247,28 +259,28 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic
private Set<BoletoComissao> carregarBilhetesDevolvidos(List<BoletoComissao> boletoComissaos, boolean pesquisa, ComEmpConferencia comEmpConferencia) {
Set<BoletoComissao> boletos = new HashSet<BoletoComissao>();
for (BoletoComissao boletoComissao : boletoComissaos) {
if(boletoComissao.isBilheteNormalDevolvido() ||
boletoComissao.isBilheteNormalTrocado() ||
boletoComissao.isBilheteNormalTrocadoDevolvido() ||
boletoComissao.isBilheteTrocadoDevolvido() ||
boletoComissao.isBilheteNormalTransferidoDevolvido() ||
boletoComissao.isBilheteNormalTransferidoTrocado() ||
boletoComissao.isBilheteAbertoDevolvido() ||
boletoComissao.isBilheteAbertoDevolvidoTrocado() ||
boletoComissao.isBilheteEntregaGapDevolvido() ||
boletoComissao.isBilheteEntregaGapTrocado()) {
if (boletoComissao.isBilheteNormalDevolvido() ||
boletoComissao.isBilheteNormalTrocado() ||
boletoComissao.isBilheteNormalTrocadoDevolvido() ||
boletoComissao.isBilheteTrocadoDevolvido() ||
boletoComissao.isBilheteNormalTransferidoDevolvido() ||
boletoComissao.isBilheteNormalTransferidoTrocado() ||
boletoComissao.isBilheteAbertoDevolvido() ||
boletoComissao.isBilheteAbertoDevolvidoTrocado() ||
boletoComissao.isBilheteEntregaGapDevolvido() ||
boletoComissao.isBilheteEntregaGapTrocado()) {
boletoComissao.setExigeConferenciaDevolvido(boletoComissao.getIndcarboletosdevolvidosconf() != null && !boletoComissao.getIndcarboletosdevolvidosconf());
if(comEmpConferencia != null) {
if (comEmpConferencia != null) {
boletoComissao.setExigeConferenciaAba(comEmpConferencia.getIndbilhetedevolvido());
}
if(pesquisa ||
((boletoComissao.getIndcarboletosdevolvidosconf() != null && boletoComissao.getIndcarboletosdevolvidosconf()) || boletoComissao.getLogconferenciaId() != null)) {
if (pesquisa ||
((boletoComissao.getIndcarboletosdevolvidosconf() != null && boletoComissao.getIndcarboletosdevolvidosconf()) || boletoComissao.getLogconferenciaId() != null)) {
boletos.add(boletoComissao);
}
}
}
return boletos;
@ -277,14 +289,14 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic
private Set<BoletoComissao> carregarBilhetesGapsVendidos(List<BoletoComissao> boletoComissaos, ComEmpConferencia comEmpConferencia) {
Set<BoletoComissao> boletos = new HashSet<BoletoComissao>();
for (BoletoComissao boletoComissao : boletoComissaos) {
if(boletoComissao.isBilheteGapVendido()) {
if (boletoComissao.isBilheteGapVendido()) {
if(comEmpConferencia != null) {
if (comEmpConferencia != null) {
boletoComissao.setExigeConferenciaAba(comEmpConferencia.getIndgapvendido());
}
boletos.add(boletoComissao);
}
}
return boletos;
@ -293,12 +305,12 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic
private Set<BoletoComissao> carregarBilhetesGapCancelados(List<BoletoComissao> boletoComissaos, ComEmpConferencia comEmpConferencia) {
Set<BoletoComissao> boletos = new HashSet<BoletoComissao>();
for (BoletoComissao boletoComissao : boletoComissaos) {
if(boletoComissao.isBilheteGapCancelado()) {
if (boletoComissao.isBilheteGapCancelado()) {
if(comEmpConferencia != null) {
if (comEmpConferencia != null) {
boletoComissao.setExigeConferenciaAba(comEmpConferencia.getIndgapcancelado());
}
boletos.add(boletoComissao);
}
}
@ -308,15 +320,15 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic
private Set<BoletoComissao> carregarBilhetesGapDevolvidos(List<BoletoComissao> boletoComissaos, ComEmpConferencia comEmpConferencia) {
Set<BoletoComissao> boletos = new HashSet<BoletoComissao>();
for (BoletoComissao boletoComissao : boletoComissaos) {
if(boletoComissao.isBilheteGapDevolvido() ||
boletoComissao.isBilheteGapTrocado()) {
if (boletoComissao.isBilheteGapDevolvido() ||
boletoComissao.isBilheteGapTrocado()) {
if(comEmpConferencia != null) {
if (comEmpConferencia != null) {
boletoComissao.setExigeConferenciaAba(comEmpConferencia.getIndgapdevolvido());
}
boletos.add(boletoComissao);
}
}
return boletos;
@ -342,8 +354,8 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic
@Override
public boolean isBilhetesSemConferencia(List<BoletoComissao> lsBoletoComissao) throws BusinessException {
for (BoletoComissao boletoComissao : lsBoletoComissao) {
if((boletoComissao.isExigeConferencia() || boletoComissao.isExigeConferenciaAba() || boletoComissao.isExigeConferenciaBoletoDevolvido()) &&
(!boletoComissao.isConferido() && boletoComissao.getLogconferenciaId() == null)) {
if ((boletoComissao.isExigeConferencia() || boletoComissao.isExigeConferenciaAba() || boletoComissao.isExigeConferenciaBoletoDevolvido()) &&
(!boletoComissao.isConferido() && boletoComissao.getLogconferenciaId() == null)) {
return true;
}
}
@ -353,8 +365,8 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic
@Override
public boolean isEventosFinanceirosSemConferencia(List<EventosFinanceirosVO> lsEventosFinanceiros) throws BusinessException {
for (EventosFinanceirosVO eventosFinanceiros : lsEventosFinanceiros) {
if((eventosFinanceiros.isExigeConferencia() || (eventosFinanceiros.getExigeConferenciaAba() != null && eventosFinanceiros.getExigeConferenciaAba())) &&
(!eventosFinanceiros.isConferido() && eventosFinanceiros.getLogconferenciaId() == null)) {
if ((eventosFinanceiros.isExigeConferencia() || (eventosFinanceiros.getExigeConferenciaAba() != null && eventosFinanceiros.getExigeConferenciaAba())) &&
(!eventosFinanceiros.isConferido() && eventosFinanceiros.getLogconferenciaId() == null)) {
return true;
}
}
@ -364,33 +376,33 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic
@Override
public BigDecimal totalizarBoletoComissao(List<BoletoComissao> lsBoletoComissao, IndStatusBoleto... statusBilhete) throws BusinessException {
List<IndStatusBoleto> lStatusBilhete = null;
if(statusBilhete != null && statusBilhete.length > 0) {
if (statusBilhete != null && statusBilhete.length > 0) {
lStatusBilhete = Arrays.asList(statusBilhete);
}
BigDecimal total = BigDecimal.ZERO;
if(lsBoletoComissao != null) {
if (lsBoletoComissao != null) {
for (BoletoComissao boletoComissao : lsBoletoComissao) {
if(lStatusBilhete == null || lStatusBilhete.contains(boletoComissao.getIndstatusboletoEnum())) {
if (lStatusBilhete == null || lStatusBilhete.contains(boletoComissao.getIndstatusboletoEnum())) {
total = total.add(boletoComissao.getTotal());
}
}
}
return total;
}
@Override
public Map<BoletoStatusComissao, BigDecimal> totalizarBoletoComissaoDevolvidosTrocaOcd(List<BoletoComissao> lsBoletoComissao) throws BusinessException {
BigDecimal totalDevolvidos = BigDecimal.ZERO;
BigDecimal totalTroca = BigDecimal.ZERO;
BigDecimal totalOcd = BigDecimal.ZERO;
if(lsBoletoComissao != null) {
if (lsBoletoComissao != null) {
for (BoletoComissao boletoComissao : lsBoletoComissao) {
if(boletoComissao.isOcd()) {
if (boletoComissao.isOcd()) {
totalOcd = totalOcd.add(boletoComissao.getTotal());
} else if(boletoComissao.isStatusCancelado() && boletoComissao.isMotivocancelacionDevolvido()) {
} else if (boletoComissao.isStatusCancelado() && boletoComissao.isMotivocancelacionDevolvido()) {
totalDevolvidos = totalDevolvidos.add(boletoComissao.getTotal());
} else if(boletoComissao.isStatusCancelado() && boletoComissao.isMotivocancelacionTrocado()) {
} else if (boletoComissao.isStatusCancelado() && boletoComissao.isMotivocancelacionTrocado()) {
totalTroca = totalTroca.add(boletoComissao.getTotal());
}
}
@ -405,7 +417,7 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic
@Override
public BigDecimal totalizarEventosFinanceiros(List<EventosFinanceirosVO> lsEventosFinanceiros) throws BusinessException {
BigDecimal total = BigDecimal.ZERO;
if(lsEventosFinanceiros != null) {
if (lsEventosFinanceiros != null) {
for (EventosFinanceirosVO eventosFinanceiros : lsEventosFinanceiros) {
total = total.add(eventosFinanceiros.getImpingreso());
}
@ -418,8 +430,8 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic
OcdVO total = new OcdVO();
total.setValorPagar(BigDecimal.ZERO);
total.setPenalizacion(BigDecimal.ZERO);
if(lsOcd != null) {
if (lsOcd != null) {
for (OcdVO ocd : lsOcd) {
total.setValorPagar(total.getValorPagar().add(ocd.getValorPagar()));
}
@ -429,8 +441,8 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic
@Override
public ResumoComissao gerarResumo(Conferencia conferencia, List<BoletoComissao> boletoComissaos, List<EventosFinanceirosVO> lsEventosFinanceiros, BigDecimal totalBilhetesManual, BigDecimal totalBilhetesVendidos,
BigDecimal totalBilhetesCancelados, BigDecimal totalBilhetesDevolvidos, BigDecimal totalBilhetesGap, BigDecimal totalBilhetesGapCancelados,
BigDecimal totalBilhetesGapDevolvidos, BigDecimal totalCreditosEventoFinanceiros, BigDecimal totalDebitosEventoFinanceiros, OcdVO totalOcd) throws BusinessException {
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));
@ -438,50 +450,51 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic
resumoComissao.setTotalReceitas(totalCreditosEventoFinanceiros);
resumoComissao.setTotalDespesas(totalDebitosEventoFinanceiros);
resumoComissao.setTotalOcd(totalOcd);
carregarTotalFormapago(resumoComissao, boletoComissaos, lsEventosFinanceiros);
resumoComissao.setValorDeposito(conferenciaComissaoDAO.carregarValorDepositoContaCorrente(conferencia.getEmpresa().getEmpresaId(), conferencia.getPuntoVenta().getPuntoventaId(), conferencia.getDatamovimento()));
resumoComissao.setQuantidadeEcf(puntoVentaDAO.quantidadeECFPorPuntoVenta(conferencia.getEmpresa().getEmpresaId(), conferencia.getPuntoVenta().getPuntoventaId()));
return resumoComissao;
}
private void carregarTotalFormapago(ResumoComissao resumoComissao, List<BoletoComissao> boletoComissaos, List<EventosFinanceirosVO> lsEventosFinanceiros) {
List<FormapagoVO> totalFormapagos = new ArrayList<FormapagoVO>();
for (BoletoComissao boletoComissao : boletoComissaos) {
if(boletoComissao.isTotalizarFormapago()) {
if (boletoComissao.isTotalizarFormapago()) {
for (FormapagoVO formapagoBoleto : boletoComissao.getFormapagos()) {
FormapagoVO formapago;
if(totalFormapagos.contains(formapagoBoleto)) {
if (totalFormapagos.contains(formapagoBoleto)) {
formapago = totalFormapagos.get(totalFormapagos.indexOf(formapagoBoleto));
} else {
formapago = new FormapagoVO(formapagoBoleto.getFormapagoId(), formapagoBoleto.getDescpago(), null, BigDecimal.ZERO);
totalFormapagos.add(formapagoBoleto);
}
if(boletoComissao.isStatusVendido() || boletoComissao.isStatusTroca()) {
if (boletoComissao.isStatusVendido() || boletoComissao.isStatusTroca()) {
formapago.add(formapagoBoleto.getImporte());
} else if(boletoComissao.isStatusCancelado() &&
(boletoComissao.isMotivocancelacionCancelado() || boletoComissao.isMotivocancelacionDevolvido() || boletoComissao.isMotivocancelacionTrocado())) {
} else if (boletoComissao.isStatusCancelado() &&
(boletoComissao.isMotivocancelacionCancelado() || boletoComissao.isMotivocancelacionDevolvido() || boletoComissao.isMotivocancelacionTrocado())) {
formapago.subtract(formapagoBoleto.getImporte());
}
}
}
}
for (EventosFinanceirosVO eventosFinanceiros : lsEventosFinanceiros) {
FormapagoVO formapagoEventoFinanceiro = new FormapagoVO(eventosFinanceiros.getFormapagoId(), eventosFinanceiros.getDescpago(), null, BigDecimal.ZERO);
if(totalFormapagos.contains(formapagoEventoFinanceiro)) {
if (totalFormapagos.contains(formapagoEventoFinanceiro)) {
formapagoEventoFinanceiro = totalFormapagos.get(totalFormapagos.indexOf(formapagoEventoFinanceiro));
} else {
totalFormapagos.add(formapagoEventoFinanceiro);
}
if(eventosFinanceiros.isCredito()) {
if (eventosFinanceiros.isCredito()) {
formapagoEventoFinanceiro.add(eventosFinanceiros.getImpingreso());
} else if(eventosFinanceiros.isDebito()) {
} else if (eventosFinanceiros.isDebito()) {
formapagoEventoFinanceiro.subtract(eventosFinanceiros.getImpingreso());
}
}
@ -492,28 +505,28 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic
public EtiquetaMalote decodificarEtiquetaMalote(String codigoBarras) throws BusinessException {
try {
EtiquetaMalote etiquetaMalote = new EtiquetaMalote();
log.debug("Empresa: " + codigoBarras.substring(0,4));
etiquetaMalote.setEmpresaId(Integer.valueOf(codigoBarras.substring(0,4)));
log.debug("Punto Venta: " + codigoBarras.substring(4,9));
etiquetaMalote.setPuntoventaId(Integer.valueOf(codigoBarras.substring(4,9)));
log.debug("Numero Malote: " + codigoBarras.substring(9,19));
etiquetaMalote.setNumeroMalote(codigoBarras.substring(9,19));
log.debug("Data inicial: " + codigoBarras.substring(19,27));
etiquetaMalote.setDataInicial(DateUtil.getDateFromString(codigoBarras.substring(19,27), "ddMMyyyy"));
log.debug("Data final: " + codigoBarras.substring(27,35));
etiquetaMalote.setDataFinal(DateUtil.getDateFromString(codigoBarras.substring(27,35), "ddMMyyyy"));
log.debug("Empresa: " + codigoBarras.substring(0, 4));
etiquetaMalote.setEmpresaId(Integer.valueOf(codigoBarras.substring(0, 4)));
log.debug("Punto Venta: " + codigoBarras.substring(4, 9));
etiquetaMalote.setPuntoventaId(Integer.valueOf(codigoBarras.substring(4, 9)));
log.debug("Numero Malote: " + codigoBarras.substring(9, 19));
etiquetaMalote.setNumeroMalote(codigoBarras.substring(9, 19));
log.debug("Data inicial: " + codigoBarras.substring(19, 27));
etiquetaMalote.setDataInicial(DateUtil.getDateFromString(codigoBarras.substring(19, 27), "ddMMyyyy"));
log.debug("Data final: " + codigoBarras.substring(27, 35));
etiquetaMalote.setDataFinal(DateUtil.getDateFromString(codigoBarras.substring(27, 35), "ddMMyyyy"));
Empresa empresa = empresaDAO.obtenerID(etiquetaMalote.getEmpresaId());
if(empresa == null) {
if (empresa == null) {
throw new BusinessException("recebimentoMaloteController.msg.erro.empresaNaoLocalizada");
}
etiquetaMalote.setNombempresa(empresa.getNombempresa());
PuntoVenta puntoVenta = puntoVentaDAO.obtenerID(etiquetaMalote.getPuntoventaId());
if(puntoVenta == null) {
if (puntoVenta == null) {
throw new BusinessException("recebimentoMaloteController.msg.erro.puntoVentaNaoLocalizado");
}
etiquetaMalote.setNombpuntoventa(puntoVenta.getNombpuntoventa());
return etiquetaMalote;
} catch (BusinessException e) {
log.error(e.getMessage(), e);
@ -521,7 +534,7 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic
} catch (Exception e) {
log.error(e.getMessage(), e);
}
return null;
}
@ -533,29 +546,29 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic
Calendar cDataFinal = Calendar.getInstance(LocaleUtil.getLocale());
cDataFinal.setTime(DateUtil.normalizar(etiquetaMalote.getDataFinal()));
Empresa empresa = empresaDAO.obtenerID(etiquetaMalote.getEmpresaId());
PuntoVenta puntoVenta = puntoVentaDAO.obtenerID(etiquetaMalote.getPuntoventaId());
while (cDataInicial.compareTo(cDataFinal) <= 0) {
Conferencia conferencia = obtenerConferenciaDataMovimento(cDataInicial.getTime(), etiquetaMalote.getPuntoventaId(), etiquetaMalote.getEmpresaId());
if(conferencia == null) {
if (conferencia == null) {
conferencia = new Conferencia();
conferencia.setDatamovimento(cDataInicial.getTime());
conferencia.setEmpresa(empresa);
conferencia.setPuntoVenta(puntoVenta);
conferencia = suscribirOrActualizacion(conferencia);
}
}
cDataInicial.add(Calendar.DAY_OF_MONTH, 1);
if(conferencia != null && conferencia.getIndmaloterecebido()) {
if (conferencia != null && conferencia.getIndmaloterecebido()) {
continue;
}
confirmarChegadaMalote(conferencia);
}
} catch (BusinessException e) {
log.error(e.getMessage(), e);
throw e;
@ -572,7 +585,7 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic
@Override
public boolean isOcdSemConferencia(List<OcdVO> lsOcd) throws BusinessException {
for (OcdVO ocd : lsOcd) {
if(ocd.isExigeConferenciaAba() && (!ocd.isConferido() && ocd.getLogconferenciaId() == null)) {
if (ocd.isExigeConferenciaAba() && (!ocd.isConferido() && ocd.getLogconferenciaId() == null)) {
return true;
}
}
@ -583,5 +596,40 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic
public DiaConferenciaComissaoVO carregarConferenciaRegistrada(Date datamovimento, Empresa empresa, PuntoVenta puntoVenta) throws BusinessException {
return conferenciaComissaoDAO.carregarConferenciaRegistrada(datamovimento, empresa, puntoVenta);
}
@Override
public Integer quantidadeECFPorPuntoVenta(Integer empresaID, Integer puntoVentaID) {
return puntoVentaDAO.quantidadeECFPorPuntoVenta(empresaID, puntoVentaID);
}
@Override
public void enviarEmailIrregularidadeECF(String email, String msg, String assunto) throws Exception {
SendMail sendMail = new SendMail();
String host = constanteService.buscarPorNomeConstante(SMTP_HOST).getValorconstante();
String user = constanteService.buscarPorNomeConstante(SMTP_USER).getValorconstante();
String emailFrom = constanteService.buscarPorNomeConstante(SMTP_EMAIL).getValorconstante();
String port = constanteService.buscarPorNomeConstante(SMTP_PORT).getValorconstante();
String password = constanteService.buscarPorNomeConstante(SMTP_PASS).getValorconstante();
verificarDadosEmail(Arrays.asList(host, user, emailFrom, port, password));
sendMail.setSmtpHost(host);
sendMail.setSmtpUser(user);
sendMail.setSmtpPassword(password);
sendMail.setSmtpPort(port);
sendMail.setEmailFrom(emailFrom);
sendMail.setEmailTo(email);
sendMail.setSubject(assunto);
sendMail.setText(msg);
sendMail.send();
}
private void verificarDadosEmail(List<String> asList) throws Exception {
for (String s : asList) {
if (s == null || s.isEmpty()) {
throw new Exception(Labels.getLabel("informeIrregularidadeController.mail.configuracoes"));
}
}
}
}

View File

@ -14,7 +14,8 @@ public class ResumoComissao {
private BigDecimal totalTroca;
private BigDecimal totalReceitas;
private BigDecimal totalDespesas;
private BigDecimal valorDeposito;
private BigDecimal valorDeposito;
private Integer quantidadeEcf;
private OcdVO totalOcd;
private List<FormapagoVO> totalFormapago;
@ -83,6 +84,14 @@ public class ResumoComissao {
this.totalFormapago = totalFormapago;
}
public Integer getQuantidadeEcf() {
return quantidadeEcf;
}
public void setQuantidadeEcf(Integer quantidadeEcf) {
this.quantidadeEcf = quantidadeEcf;
}
public OcdVO getTotalOcd() {
return totalOcd;
}
@ -90,27 +99,27 @@ public class ResumoComissao {
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());
}