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> buscarPuntosVentaMovimentacionBilhetes(List<Empresa> empresas);
public List<PuntoVenta> buscarPuntoVentaPorTipoEstoque(PtovtaTipoEstoque tipoEstoque); 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; package com.rjconsultores.ventaboletos.dao.hibernate;
import com.rjconsultores.ventaboletos.dao.ConstanteDAO;
import com.rjconsultores.ventaboletos.entidad.Constante;
import java.util.List; import java.util.List;
import org.hibernate.Criteria; import org.hibernate.Criteria;
import org.hibernate.SessionFactory; import org.hibernate.SessionFactory;
import org.hibernate.criterion.Order; 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.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import com.rjconsultores.ventaboletos.dao.ConstanteDAO;
import com.rjconsultores.ventaboletos.entidad.Constante;
/** /**
* *
* @author Administrador * @author Administrador

View File

@ -4,6 +4,7 @@
*/ */
package com.rjconsultores.ventaboletos.dao.hibernate; package com.rjconsultores.ventaboletos.dao.hibernate;
import java.math.BigDecimal;
import java.util.List; import java.util.List;
import org.hibernate.Criteria; import org.hibernate.Criteria;
@ -57,7 +58,6 @@ public class PuntoVentaHibernateDAO extends GenericHibernateDAO<PuntoVenta, Inte
return c.list(); return c.list();
} }
public List<PuntoVenta> buscaLike(String strEstacion, boolean sinTodos) { public List<PuntoVenta> buscaLike(String strEstacion, boolean sinTodos) {
Criteria c = getSession().createCriteria(getPersistentClass()); Criteria c = getSession().createCriteria(getPersistentClass());
@ -65,13 +65,11 @@ public class PuntoVentaHibernateDAO extends GenericHibernateDAO<PuntoVenta, Inte
Criterion crActivo = Restrictions.eq("activo", Boolean.TRUE); Criterion crActivo = Restrictions.eq("activo", Boolean.TRUE);
if (sinTodos) {
if (sinTodos){
Criterion crSinTodos = Restrictions.ne("puntoventaId", ID_PUNTO_VENTA_TODOS); Criterion crSinTodos = Restrictions.ne("puntoventaId", ID_PUNTO_VENTA_TODOS);
c.add(crSinTodos); c.add(crSinTodos);
} }
PtovtaTipoEstoque supr = ptovtaTipoEstoqueDAO.buscarTipoSuprimento(); PtovtaTipoEstoque supr = ptovtaTipoEstoqueDAO.buscarTipoSuprimento();
PtovtaTipoEstoque cont = ptovtaTipoEstoqueDAO.buscarTipoContabilidade(); PtovtaTipoEstoque cont = ptovtaTipoEstoqueDAO.buscarTipoContabilidade();
@ -193,4 +191,23 @@ public class PuntoVentaHibernateDAO extends GenericHibernateDAO<PuntoVenta, Inte
return puntosVenta; 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

@ -75,4 +75,7 @@ public interface ConferenciaComissaoService extends GenericService<Conferencia,
public DiaConferenciaComissaoVO carregarConferenciaRegistrada(Date datamovimento, Empresa empresa, PuntoVenta puntoVenta) 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 com.rjconsultores.ventaboletos.entidad.Constante;
import java.util.List; import java.util.List;
/**
*
* @author Administrador
*/
public interface ConstanteService extends GenericService<Constante, Integer> { public interface ConstanteService extends GenericService<Constante, Integer> {
public Constante buscarPorNomeConstante(String nomeConstante); public Constante buscarPorNomeConstante(String nomeConstante);

View File

@ -15,6 +15,7 @@ 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;
import org.zkoss.util.resource.Labels;
import com.rjconsultores.ventaboletos.dao.ConferenciaComissaoDAO; import com.rjconsultores.ventaboletos.dao.ConferenciaComissaoDAO;
import com.rjconsultores.ventaboletos.dao.EmpresaDAO; 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.enums.comissao.BoletoStatusComissao;
import com.rjconsultores.ventaboletos.exception.BusinessException; import com.rjconsultores.ventaboletos.exception.BusinessException;
import com.rjconsultores.ventaboletos.service.ConferenciaComissaoService; import com.rjconsultores.ventaboletos.service.ConferenciaComissaoService;
import com.rjconsultores.ventaboletos.service.ConstanteService;
import com.rjconsultores.ventaboletos.utilerias.DateUtil; import com.rjconsultores.ventaboletos.utilerias.DateUtil;
import com.rjconsultores.ventaboletos.utilerias.LocaleUtil; import com.rjconsultores.ventaboletos.utilerias.LocaleUtil;
import com.rjconsultores.ventaboletos.utilerias.SendMail;
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
import com.rjconsultores.ventaboletos.vo.comissao.BoletoComissao; import com.rjconsultores.ventaboletos.vo.comissao.BoletoComissao;
import com.rjconsultores.ventaboletos.vo.comissao.ConferenciaComissaoVO; import com.rjconsultores.ventaboletos.vo.comissao.ConferenciaComissaoVO;
@ -44,6 +47,12 @@ import com.rjconsultores.ventaboletos.vo.comissao.ResumoComissao;
@Service("conferenciaComissaoService") @Service("conferenciaComissaoService")
public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoService { public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoService {
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); private static Logger log = Logger.getLogger(ConferenciaComissaoService.class);
@Autowired @Autowired
@ -55,6 +64,9 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic
@Autowired @Autowired
private PuntoVentaDAO puntoVentaDAO; private PuntoVentaDAO puntoVentaDAO;
@Autowired
ConstanteService constanteService;
@Override @Override
public List<Conferencia> obtenerTodos() { public List<Conferencia> obtenerTodos() {
return conferenciaComissaoDAO.obtenerTodos(); return conferenciaComissaoDAO.obtenerTodos();
@ -146,17 +158,17 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic
@Override @Override
public List<BoletoComissao> carregarBilhetesComissao(List<BoletoComissao> boletoComissaos, Conferencia conferencia, BoletoStatusComissao boletoStatusComissao) throws BusinessException { public List<BoletoComissao> carregarBilhetesComissao(List<BoletoComissao> boletoComissaos, Conferencia conferencia, BoletoStatusComissao boletoStatusComissao) throws BusinessException {
if(boletoComissaos == null) { if (boletoComissaos == null) {
boletoComissaos = conferenciaComissaoDAO.carregarBilhetesComissao(conferencia); boletoComissaos = conferenciaComissaoDAO.carregarBilhetesComissao(conferencia);
} }
if(boletoStatusComissao == null) { if (boletoStatusComissao == null) {
return boletoComissaos; return boletoComissaos;
} }
Empresa empresa = empresaDAO.obtenerID(conferencia.getEmpresa().getEmpresaId()); Empresa empresa = empresaDAO.obtenerID(conferencia.getEmpresa().getEmpresaId());
ComEmpConferencia comEmpConferencia = null; ComEmpConferencia comEmpConferencia = null;
if(empresa.getComEmpConferencias() != null && !empresa.getComEmpConferencias().isEmpty()) { if (empresa.getComEmpConferencias() != null && !empresa.getComEmpConferencias().isEmpty()) {
comEmpConferencia = empresa.getComEmpConferencias().iterator().next(); comEmpConferencia = empresa.getComEmpConferencias().iterator().next();
} }
@ -192,9 +204,9 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic
private Set<BoletoComissao> carregarBilhetesManuais(List<BoletoComissao> boletoComissaos, ComEmpConferencia comEmpConferencia) { private Set<BoletoComissao> carregarBilhetesManuais(List<BoletoComissao> boletoComissaos, ComEmpConferencia comEmpConferencia) {
Set<BoletoComissao> boletos = new HashSet<BoletoComissao>(); Set<BoletoComissao> boletos = new HashSet<BoletoComissao>();
for (BoletoComissao boletoComissao : boletoComissaos) { for (BoletoComissao boletoComissao : boletoComissaos) {
if(boletoComissao.isBilhetesManualVendido()) { if (boletoComissao.isBilhetesManualVendido()) {
if(comEmpConferencia != null) { if (comEmpConferencia != null) {
boletoComissao.setExigeConferenciaAba(comEmpConferencia.getIndbilhetemanual()); boletoComissao.setExigeConferenciaAba(comEmpConferencia.getIndbilhetemanual());
} }
@ -207,14 +219,14 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic
private Set<BoletoComissao> carregarBilhetesVendidos(List<BoletoComissao> boletoComissaos, ComEmpConferencia comEmpConferencia) { private Set<BoletoComissao> carregarBilhetesVendidos(List<BoletoComissao> boletoComissaos, ComEmpConferencia comEmpConferencia) {
Set<BoletoComissao> boletos = new HashSet<BoletoComissao>(); Set<BoletoComissao> boletos = new HashSet<BoletoComissao>();
for (BoletoComissao boletoComissao : boletoComissaos) { for (BoletoComissao boletoComissao : boletoComissaos) {
if(boletoComissao.isBilheteNormalVendido() || if (boletoComissao.isBilheteNormalVendido() ||
boletoComissao.isBilheteEntregaGap() || boletoComissao.isBilheteEntregaGap() ||
boletoComissao.isBilheteNormalChekin() || boletoComissao.isBilheteNormalChekin() ||
boletoComissao.isBilheteAberto() || boletoComissao.isBilheteAberto() ||
boletoComissao.isBilheteConfirmaAbertoTroca() || boletoComissao.isBilheteConfirmaAbertoTroca() ||
boletoComissao.isBilheteEntregaAberto()) { boletoComissao.isBilheteEntregaAberto()) {
if(comEmpConferencia != null) { if (comEmpConferencia != null) {
boletoComissao.setExigeConferenciaAba(comEmpConferencia.getIndbilhetevendido()); boletoComissao.setExigeConferenciaAba(comEmpConferencia.getIndbilhetevendido());
} }
@ -228,12 +240,12 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic
private Set<BoletoComissao> carregarBilhetesCancelados(List<BoletoComissao> boletoComissaos, ComEmpConferencia comEmpConferencia) { private Set<BoletoComissao> carregarBilhetesCancelados(List<BoletoComissao> boletoComissaos, ComEmpConferencia comEmpConferencia) {
Set<BoletoComissao> boletos = new HashSet<BoletoComissao>(); Set<BoletoComissao> boletos = new HashSet<BoletoComissao>();
for (BoletoComissao boletoComissao : boletoComissaos) { for (BoletoComissao boletoComissao : boletoComissaos) {
if(boletoComissao.isBilheteNormalCancelado() || if (boletoComissao.isBilheteNormalCancelado() ||
boletoComissao.isBilheteNormalTrocadoCancelado() || boletoComissao.isBilheteNormalTrocadoCancelado() ||
boletoComissao.isBilheteConfirmadoAbertoCancelado() || boletoComissao.isBilheteConfirmadoAbertoCancelado() ||
boletoComissao.isBilheteEntregaGapCancelado()) { boletoComissao.isBilheteEntregaGapCancelado()) {
if(comEmpConferencia != null) { if (comEmpConferencia != null) {
boletoComissao.setExigeConferenciaAba(comEmpConferencia.getIndbilhetecancelado()); boletoComissao.setExigeConferenciaAba(comEmpConferencia.getIndbilhetecancelado());
} }
@ -247,7 +259,7 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic
private Set<BoletoComissao> carregarBilhetesDevolvidos(List<BoletoComissao> boletoComissaos, boolean pesquisa, ComEmpConferencia comEmpConferencia) { private Set<BoletoComissao> carregarBilhetesDevolvidos(List<BoletoComissao> boletoComissaos, boolean pesquisa, ComEmpConferencia comEmpConferencia) {
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() ||
boletoComissao.isBilheteNormalTrocado() || boletoComissao.isBilheteNormalTrocado() ||
boletoComissao.isBilheteNormalTrocadoDevolvido() || boletoComissao.isBilheteNormalTrocadoDevolvido() ||
boletoComissao.isBilheteTrocadoDevolvido() || boletoComissao.isBilheteTrocadoDevolvido() ||
@ -260,11 +272,11 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic
boletoComissao.setExigeConferenciaDevolvido(boletoComissao.getIndcarboletosdevolvidosconf() != null && !boletoComissao.getIndcarboletosdevolvidosconf()); boletoComissao.setExigeConferenciaDevolvido(boletoComissao.getIndcarboletosdevolvidosconf() != null && !boletoComissao.getIndcarboletosdevolvidosconf());
if(comEmpConferencia != null) { if (comEmpConferencia != null) {
boletoComissao.setExigeConferenciaAba(comEmpConferencia.getIndbilhetedevolvido()); boletoComissao.setExigeConferenciaAba(comEmpConferencia.getIndbilhetedevolvido());
} }
if(pesquisa || if (pesquisa ||
((boletoComissao.getIndcarboletosdevolvidosconf() != null && boletoComissao.getIndcarboletosdevolvidosconf()) || boletoComissao.getLogconferenciaId() != null)) { ((boletoComissao.getIndcarboletosdevolvidosconf() != null && boletoComissao.getIndcarboletosdevolvidosconf()) || boletoComissao.getLogconferenciaId() != null)) {
boletos.add(boletoComissao); boletos.add(boletoComissao);
} }
@ -277,9 +289,9 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic
private Set<BoletoComissao> carregarBilhetesGapsVendidos(List<BoletoComissao> boletoComissaos, ComEmpConferencia comEmpConferencia) { private Set<BoletoComissao> carregarBilhetesGapsVendidos(List<BoletoComissao> boletoComissaos, ComEmpConferencia comEmpConferencia) {
Set<BoletoComissao> boletos = new HashSet<BoletoComissao>(); Set<BoletoComissao> boletos = new HashSet<BoletoComissao>();
for (BoletoComissao boletoComissao : boletoComissaos) { for (BoletoComissao boletoComissao : boletoComissaos) {
if(boletoComissao.isBilheteGapVendido()) { if (boletoComissao.isBilheteGapVendido()) {
if(comEmpConferencia != null) { if (comEmpConferencia != null) {
boletoComissao.setExigeConferenciaAba(comEmpConferencia.getIndgapvendido()); boletoComissao.setExigeConferenciaAba(comEmpConferencia.getIndgapvendido());
} }
@ -293,9 +305,9 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic
private Set<BoletoComissao> carregarBilhetesGapCancelados(List<BoletoComissao> boletoComissaos, ComEmpConferencia comEmpConferencia) { private Set<BoletoComissao> carregarBilhetesGapCancelados(List<BoletoComissao> boletoComissaos, ComEmpConferencia comEmpConferencia) {
Set<BoletoComissao> boletos = new HashSet<BoletoComissao>(); Set<BoletoComissao> boletos = new HashSet<BoletoComissao>();
for (BoletoComissao boletoComissao : boletoComissaos) { for (BoletoComissao boletoComissao : boletoComissaos) {
if(boletoComissao.isBilheteGapCancelado()) { if (boletoComissao.isBilheteGapCancelado()) {
if(comEmpConferencia != null) { if (comEmpConferencia != null) {
boletoComissao.setExigeConferenciaAba(comEmpConferencia.getIndgapcancelado()); boletoComissao.setExigeConferenciaAba(comEmpConferencia.getIndgapcancelado());
} }
@ -308,10 +320,10 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic
private Set<BoletoComissao> carregarBilhetesGapDevolvidos(List<BoletoComissao> boletoComissaos, ComEmpConferencia comEmpConferencia) { private Set<BoletoComissao> carregarBilhetesGapDevolvidos(List<BoletoComissao> boletoComissaos, ComEmpConferencia comEmpConferencia) {
Set<BoletoComissao> boletos = new HashSet<BoletoComissao>(); Set<BoletoComissao> boletos = new HashSet<BoletoComissao>();
for (BoletoComissao boletoComissao : boletoComissaos) { for (BoletoComissao boletoComissao : boletoComissaos) {
if(boletoComissao.isBilheteGapDevolvido() || if (boletoComissao.isBilheteGapDevolvido() ||
boletoComissao.isBilheteGapTrocado()) { boletoComissao.isBilheteGapTrocado()) {
if(comEmpConferencia != null) { if (comEmpConferencia != null) {
boletoComissao.setExigeConferenciaAba(comEmpConferencia.getIndgapdevolvido()); boletoComissao.setExigeConferenciaAba(comEmpConferencia.getIndgapdevolvido());
} }
@ -342,7 +354,7 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic
@Override @Override
public boolean isBilhetesSemConferencia(List<BoletoComissao> lsBoletoComissao) throws BusinessException { public boolean isBilhetesSemConferencia(List<BoletoComissao> lsBoletoComissao) throws BusinessException {
for (BoletoComissao boletoComissao : lsBoletoComissao) { for (BoletoComissao boletoComissao : lsBoletoComissao) {
if((boletoComissao.isExigeConferencia() || boletoComissao.isExigeConferenciaAba() || boletoComissao.isExigeConferenciaBoletoDevolvido()) && if ((boletoComissao.isExigeConferencia() || boletoComissao.isExigeConferenciaAba() || boletoComissao.isExigeConferenciaBoletoDevolvido()) &&
(!boletoComissao.isConferido() && boletoComissao.getLogconferenciaId() == null)) { (!boletoComissao.isConferido() && boletoComissao.getLogconferenciaId() == null)) {
return true; return true;
} }
@ -353,7 +365,7 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic
@Override @Override
public boolean isEventosFinanceirosSemConferencia(List<EventosFinanceirosVO> lsEventosFinanceiros) throws BusinessException { public boolean isEventosFinanceirosSemConferencia(List<EventosFinanceirosVO> lsEventosFinanceiros) throws BusinessException {
for (EventosFinanceirosVO eventosFinanceiros : lsEventosFinanceiros) { for (EventosFinanceirosVO eventosFinanceiros : lsEventosFinanceiros) {
if((eventosFinanceiros.isExigeConferencia() || (eventosFinanceiros.getExigeConferenciaAba() != null && eventosFinanceiros.getExigeConferenciaAba())) && if ((eventosFinanceiros.isExigeConferencia() || (eventosFinanceiros.getExigeConferenciaAba() != null && eventosFinanceiros.getExigeConferenciaAba())) &&
(!eventosFinanceiros.isConferido() && eventosFinanceiros.getLogconferenciaId() == null)) { (!eventosFinanceiros.isConferido() && eventosFinanceiros.getLogconferenciaId() == null)) {
return true; return true;
} }
@ -364,14 +376,14 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic
@Override @Override
public BigDecimal totalizarBoletoComissao(List<BoletoComissao> lsBoletoComissao, IndStatusBoleto... statusBilhete) throws BusinessException { public BigDecimal totalizarBoletoComissao(List<BoletoComissao> lsBoletoComissao, IndStatusBoleto... statusBilhete) throws BusinessException {
List<IndStatusBoleto> lStatusBilhete = null; List<IndStatusBoleto> lStatusBilhete = null;
if(statusBilhete != null && statusBilhete.length > 0) { if (statusBilhete != null && statusBilhete.length > 0) {
lStatusBilhete = Arrays.asList(statusBilhete); lStatusBilhete = Arrays.asList(statusBilhete);
} }
BigDecimal total = BigDecimal.ZERO; BigDecimal total = BigDecimal.ZERO;
if(lsBoletoComissao != null) { if (lsBoletoComissao != null) {
for (BoletoComissao boletoComissao : lsBoletoComissao) { for (BoletoComissao boletoComissao : lsBoletoComissao) {
if(lStatusBilhete == null || lStatusBilhete.contains(boletoComissao.getIndstatusboletoEnum())) { if (lStatusBilhete == null || lStatusBilhete.contains(boletoComissao.getIndstatusboletoEnum())) {
total = total.add(boletoComissao.getTotal()); total = total.add(boletoComissao.getTotal());
} }
} }
@ -384,13 +396,13 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic
BigDecimal totalDevolvidos = BigDecimal.ZERO; BigDecimal totalDevolvidos = BigDecimal.ZERO;
BigDecimal totalTroca = BigDecimal.ZERO; BigDecimal totalTroca = BigDecimal.ZERO;
BigDecimal totalOcd = BigDecimal.ZERO; BigDecimal totalOcd = BigDecimal.ZERO;
if(lsBoletoComissao != null) { if (lsBoletoComissao != null) {
for (BoletoComissao boletoComissao : lsBoletoComissao) { for (BoletoComissao boletoComissao : lsBoletoComissao) {
if(boletoComissao.isOcd()) { if (boletoComissao.isOcd()) {
totalOcd = totalOcd.add(boletoComissao.getTotal()); totalOcd = totalOcd.add(boletoComissao.getTotal());
} else if(boletoComissao.isStatusCancelado() && boletoComissao.isMotivocancelacionDevolvido()) { } else if (boletoComissao.isStatusCancelado() && boletoComissao.isMotivocancelacionDevolvido()) {
totalDevolvidos = totalDevolvidos.add(boletoComissao.getTotal()); totalDevolvidos = totalDevolvidos.add(boletoComissao.getTotal());
} else if(boletoComissao.isStatusCancelado() && boletoComissao.isMotivocancelacionTrocado()) { } else if (boletoComissao.isStatusCancelado() && boletoComissao.isMotivocancelacionTrocado()) {
totalTroca = totalTroca.add(boletoComissao.getTotal()); totalTroca = totalTroca.add(boletoComissao.getTotal());
} }
} }
@ -405,7 +417,7 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic
@Override @Override
public BigDecimal totalizarEventosFinanceiros(List<EventosFinanceirosVO> lsEventosFinanceiros) throws BusinessException { public BigDecimal totalizarEventosFinanceiros(List<EventosFinanceirosVO> lsEventosFinanceiros) throws BusinessException {
BigDecimal total = BigDecimal.ZERO; BigDecimal total = BigDecimal.ZERO;
if(lsEventosFinanceiros != null) { if (lsEventosFinanceiros != null) {
for (EventosFinanceirosVO eventosFinanceiros : lsEventosFinanceiros) { for (EventosFinanceirosVO eventosFinanceiros : lsEventosFinanceiros) {
total = total.add(eventosFinanceiros.getImpingreso()); total = total.add(eventosFinanceiros.getImpingreso());
} }
@ -419,7 +431,7 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic
total.setValorPagar(BigDecimal.ZERO); total.setValorPagar(BigDecimal.ZERO);
total.setPenalizacion(BigDecimal.ZERO); total.setPenalizacion(BigDecimal.ZERO);
if(lsOcd != null) { if (lsOcd != null) {
for (OcdVO ocd : lsOcd) { for (OcdVO ocd : lsOcd) {
total.setValorPagar(total.getValorPagar().add(ocd.getValorPagar())); total.setValorPagar(total.getValorPagar().add(ocd.getValorPagar()));
} }
@ -442,6 +454,7 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic
carregarTotalFormapago(resumoComissao, boletoComissaos, lsEventosFinanceiros); carregarTotalFormapago(resumoComissao, boletoComissaos, lsEventosFinanceiros);
resumoComissao.setValorDeposito(conferenciaComissaoDAO.carregarValorDepositoContaCorrente(conferencia.getEmpresa().getEmpresaId(), conferencia.getPuntoVenta().getPuntoventaId(), conferencia.getDatamovimento())); resumoComissao.setValorDeposito(conferenciaComissaoDAO.carregarValorDepositoContaCorrente(conferencia.getEmpresa().getEmpresaId(), conferencia.getPuntoVenta().getPuntoventaId(), conferencia.getDatamovimento()));
resumoComissao.setQuantidadeEcf(puntoVentaDAO.quantidadeECFPorPuntoVenta(conferencia.getEmpresa().getEmpresaId(), conferencia.getPuntoVenta().getPuntoventaId()));
return resumoComissao; return resumoComissao;
} }
@ -449,20 +462,20 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic
private void carregarTotalFormapago(ResumoComissao resumoComissao, List<BoletoComissao> boletoComissaos, List<EventosFinanceirosVO> lsEventosFinanceiros) { private void carregarTotalFormapago(ResumoComissao resumoComissao, List<BoletoComissao> boletoComissaos, List<EventosFinanceirosVO> lsEventosFinanceiros) {
List<FormapagoVO> totalFormapagos = new ArrayList<FormapagoVO>(); List<FormapagoVO> totalFormapagos = new ArrayList<FormapagoVO>();
for (BoletoComissao boletoComissao : boletoComissaos) { for (BoletoComissao boletoComissao : boletoComissaos) {
if(boletoComissao.isTotalizarFormapago()) { if (boletoComissao.isTotalizarFormapago()) {
for (FormapagoVO formapagoBoleto : boletoComissao.getFormapagos()) { for (FormapagoVO formapagoBoleto : boletoComissao.getFormapagos()) {
FormapagoVO formapago; FormapagoVO formapago;
if(totalFormapagos.contains(formapagoBoleto)) { if (totalFormapagos.contains(formapagoBoleto)) {
formapago = totalFormapagos.get(totalFormapagos.indexOf(formapagoBoleto)); formapago = totalFormapagos.get(totalFormapagos.indexOf(formapagoBoleto));
} else { } else {
formapago = new FormapagoVO(formapagoBoleto.getFormapagoId(), formapagoBoleto.getDescpago(), null, BigDecimal.ZERO); formapago = new FormapagoVO(formapagoBoleto.getFormapagoId(), formapagoBoleto.getDescpago(), null, BigDecimal.ZERO);
totalFormapagos.add(formapagoBoleto); totalFormapagos.add(formapagoBoleto);
} }
if(boletoComissao.isStatusVendido() || boletoComissao.isStatusTroca()) { if (boletoComissao.isStatusVendido() || boletoComissao.isStatusTroca()) {
formapago.add(formapagoBoleto.getImporte()); formapago.add(formapagoBoleto.getImporte());
} else if(boletoComissao.isStatusCancelado() && } else if (boletoComissao.isStatusCancelado() &&
(boletoComissao.isMotivocancelacionCancelado() || boletoComissao.isMotivocancelacionDevolvido() || boletoComissao.isMotivocancelacionTrocado())) { (boletoComissao.isMotivocancelacionCancelado() || boletoComissao.isMotivocancelacionDevolvido() || boletoComissao.isMotivocancelacionTrocado())) {
formapago.subtract(formapagoBoleto.getImporte()); formapago.subtract(formapagoBoleto.getImporte());
} }
@ -473,15 +486,15 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic
for (EventosFinanceirosVO eventosFinanceiros : lsEventosFinanceiros) { for (EventosFinanceirosVO eventosFinanceiros : lsEventosFinanceiros) {
FormapagoVO formapagoEventoFinanceiro = new FormapagoVO(eventosFinanceiros.getFormapagoId(), eventosFinanceiros.getDescpago(), null, BigDecimal.ZERO); 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)); formapagoEventoFinanceiro = totalFormapagos.get(totalFormapagos.indexOf(formapagoEventoFinanceiro));
} else { } else {
totalFormapagos.add(formapagoEventoFinanceiro); totalFormapagos.add(formapagoEventoFinanceiro);
} }
if(eventosFinanceiros.isCredito()) { if (eventosFinanceiros.isCredito()) {
formapagoEventoFinanceiro.add(eventosFinanceiros.getImpingreso()); formapagoEventoFinanceiro.add(eventosFinanceiros.getImpingreso());
} else if(eventosFinanceiros.isDebito()) { } else if (eventosFinanceiros.isDebito()) {
formapagoEventoFinanceiro.subtract(eventosFinanceiros.getImpingreso()); formapagoEventoFinanceiro.subtract(eventosFinanceiros.getImpingreso());
} }
} }
@ -492,24 +505,24 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic
public EtiquetaMalote decodificarEtiquetaMalote(String codigoBarras) throws BusinessException { public EtiquetaMalote decodificarEtiquetaMalote(String codigoBarras) throws BusinessException {
try { try {
EtiquetaMalote etiquetaMalote = new EtiquetaMalote(); EtiquetaMalote etiquetaMalote = new EtiquetaMalote();
log.debug("Empresa: " + codigoBarras.substring(0,4)); log.debug("Empresa: " + codigoBarras.substring(0, 4));
etiquetaMalote.setEmpresaId(Integer.valueOf(codigoBarras.substring(0,4))); etiquetaMalote.setEmpresaId(Integer.valueOf(codigoBarras.substring(0, 4)));
log.debug("Punto Venta: " + codigoBarras.substring(4,9)); log.debug("Punto Venta: " + codigoBarras.substring(4, 9));
etiquetaMalote.setPuntoventaId(Integer.valueOf(codigoBarras.substring(4,9))); etiquetaMalote.setPuntoventaId(Integer.valueOf(codigoBarras.substring(4, 9)));
log.debug("Numero Malote: " + codigoBarras.substring(9,19)); log.debug("Numero Malote: " + codigoBarras.substring(9, 19));
etiquetaMalote.setNumeroMalote(codigoBarras.substring(9,19)); etiquetaMalote.setNumeroMalote(codigoBarras.substring(9, 19));
log.debug("Data inicial: " + codigoBarras.substring(19,27)); log.debug("Data inicial: " + codigoBarras.substring(19, 27));
etiquetaMalote.setDataInicial(DateUtil.getDateFromString(codigoBarras.substring(19,27), "ddMMyyyy")); etiquetaMalote.setDataInicial(DateUtil.getDateFromString(codigoBarras.substring(19, 27), "ddMMyyyy"));
log.debug("Data final: " + codigoBarras.substring(27,35)); log.debug("Data final: " + codigoBarras.substring(27, 35));
etiquetaMalote.setDataFinal(DateUtil.getDateFromString(codigoBarras.substring(27,35), "ddMMyyyy")); etiquetaMalote.setDataFinal(DateUtil.getDateFromString(codigoBarras.substring(27, 35), "ddMMyyyy"));
Empresa empresa = empresaDAO.obtenerID(etiquetaMalote.getEmpresaId()); Empresa empresa = empresaDAO.obtenerID(etiquetaMalote.getEmpresaId());
if(empresa == null) { if (empresa == null) {
throw new BusinessException("recebimentoMaloteController.msg.erro.empresaNaoLocalizada"); throw new BusinessException("recebimentoMaloteController.msg.erro.empresaNaoLocalizada");
} }
etiquetaMalote.setNombempresa(empresa.getNombempresa()); etiquetaMalote.setNombempresa(empresa.getNombempresa());
PuntoVenta puntoVenta = puntoVentaDAO.obtenerID(etiquetaMalote.getPuntoventaId()); PuntoVenta puntoVenta = puntoVentaDAO.obtenerID(etiquetaMalote.getPuntoventaId());
if(puntoVenta == null) { if (puntoVenta == null) {
throw new BusinessException("recebimentoMaloteController.msg.erro.puntoVentaNaoLocalizado"); throw new BusinessException("recebimentoMaloteController.msg.erro.puntoVentaNaoLocalizado");
} }
etiquetaMalote.setNombpuntoventa(puntoVenta.getNombpuntoventa()); etiquetaMalote.setNombpuntoventa(puntoVenta.getNombpuntoventa());
@ -539,7 +552,7 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic
while (cDataInicial.compareTo(cDataFinal) <= 0) { while (cDataInicial.compareTo(cDataFinal) <= 0) {
Conferencia conferencia = obtenerConferenciaDataMovimento(cDataInicial.getTime(), etiquetaMalote.getPuntoventaId(), etiquetaMalote.getEmpresaId()); Conferencia conferencia = obtenerConferenciaDataMovimento(cDataInicial.getTime(), etiquetaMalote.getPuntoventaId(), etiquetaMalote.getEmpresaId());
if(conferencia == null) { if (conferencia == null) {
conferencia = new Conferencia(); conferencia = new Conferencia();
conferencia.setDatamovimento(cDataInicial.getTime()); conferencia.setDatamovimento(cDataInicial.getTime());
conferencia.setEmpresa(empresa); conferencia.setEmpresa(empresa);
@ -549,7 +562,7 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic
} }
cDataInicial.add(Calendar.DAY_OF_MONTH, 1); cDataInicial.add(Calendar.DAY_OF_MONTH, 1);
if(conferencia != null && conferencia.getIndmaloterecebido()) { if (conferencia != null && conferencia.getIndmaloterecebido()) {
continue; continue;
} }
confirmarChegadaMalote(conferencia); confirmarChegadaMalote(conferencia);
@ -572,7 +585,7 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic
@Override @Override
public boolean isOcdSemConferencia(List<OcdVO> lsOcd) throws BusinessException { public boolean isOcdSemConferencia(List<OcdVO> lsOcd) throws BusinessException {
for (OcdVO ocd : lsOcd) { for (OcdVO ocd : lsOcd) {
if(ocd.isExigeConferenciaAba() && (!ocd.isConferido() && ocd.getLogconferenciaId() == null)) { if (ocd.isExigeConferenciaAba() && (!ocd.isConferido() && ocd.getLogconferenciaId() == null)) {
return true; return true;
} }
} }
@ -584,4 +597,39 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic
return conferenciaComissaoDAO.carregarConferenciaRegistrada(datamovimento, empresa, puntoVenta); 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

@ -15,6 +15,7 @@ public class ResumoComissao {
private BigDecimal totalReceitas; private BigDecimal totalReceitas;
private BigDecimal totalDespesas; private BigDecimal totalDespesas;
private BigDecimal valorDeposito; private BigDecimal valorDeposito;
private Integer quantidadeEcf;
private OcdVO totalOcd; private OcdVO totalOcd;
private List<FormapagoVO> totalFormapago; private List<FormapagoVO> totalFormapago;
@ -83,6 +84,14 @@ public class ResumoComissao {
this.totalFormapago = totalFormapago; this.totalFormapago = totalFormapago;
} }
public Integer getQuantidadeEcf() {
return quantidadeEcf;
}
public void setQuantidadeEcf(Integer quantidadeEcf) {
this.quantidadeEcf = quantidadeEcf;
}
public OcdVO getTotalOcd() { public OcdVO getTotalOcd() {
return totalOcd; return totalOcd;
} }