bug#12779
dev:wilian qua: git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@87590 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
a6b1add2ea
commit
32688dc210
|
@ -89,4 +89,6 @@ public class Constantes {
|
|||
|
||||
public static final String QTDE_MAX_DIAS_RETENCAO_DIARIA_COMISSAO = "QTDE_MAX_DIAS_RETENCAO_DIARIA_COMISSAO";
|
||||
|
||||
public static final String RETER_COMISSAO_ADM_FECHAMENTO_CAIXA = "RETER_COMISSAO_ADM_FECHAMENTO_CAIXA";
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
package com.rjconsultores.ventaboletos.dao;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.rjconsultores.ventaboletos.entidad.CtrlFechamentoCaixa;
|
||||
|
||||
public interface CtrlFechamentoCaixaDAO extends GenericDAO<CtrlFechamentoCaixa, Long> {
|
||||
|
||||
public CtrlFechamentoCaixa obtenerFeccorte(Date feccorte);
|
||||
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package com.rjconsultores.ventaboletos.dao.hibernate;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.hibernate.Query;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.rjconsultores.ventaboletos.dao.CtrlFechamentoCaixaDAO;
|
||||
import com.rjconsultores.ventaboletos.entidad.CtrlFechamentoCaixa;
|
||||
import com.rjconsultores.ventaboletos.utilerias.DateUtil;
|
||||
|
||||
@Repository("ctrlFechamentoCaixaDAO")
|
||||
public class CtrlFechamentoCaixaHibernateDAO extends GenericHibernateDAO<CtrlFechamentoCaixa, Long> implements CtrlFechamentoCaixaDAO {
|
||||
|
||||
@Autowired
|
||||
public CtrlFechamentoCaixaHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) {
|
||||
setSessionFactory(factory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CtrlFechamentoCaixa obtenerFeccorte(Date feccorte) {
|
||||
StringBuilder hql = new StringBuilder();
|
||||
hql.append(" from CtrlFechamentoCaixa c ")
|
||||
.append(" where c.activo = 1 ")
|
||||
.append(" and c.feccorte = TO_DATE(:feccorte,'DD/MM/YYYY') ");
|
||||
|
||||
Query qr = getSession().createQuery(hql.toString());
|
||||
qr.setParameter("feccorte", DateUtil.getStringDate(feccorte, "dd/MM/yyyy"));
|
||||
qr.setMaxResults(1);
|
||||
|
||||
return (CtrlFechamentoCaixa) qr.uniqueResult();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,96 @@
|
|||
package com.rjconsultores.ventaboletos.entidad;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.persistence.Basic;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EnumType;
|
||||
import javax.persistence.Enumerated;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.SequenceGenerator;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
|
||||
import com.rjconsultores.ventaboletos.enums.CtrlFechamentoCaixaStatus;
|
||||
|
||||
/**
|
||||
* Classe que controla a rotina de retenção de comissão após o fechamento do caixa
|
||||
*
|
||||
* @author wilian
|
||||
* @since 29/11/2018
|
||||
*
|
||||
*/
|
||||
@Entity
|
||||
@SequenceGenerator(name = "CTRL_FECHAMENTO_CAIXA_SEQ", sequenceName = "CTRL_FECHAMENTO_CAIXA_SEQ", allocationSize = 1)
|
||||
@Table(name = "CTRL_FECHAMENTO_CAIXA")
|
||||
public class CtrlFechamentoCaixa implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
@Basic(optional = false)
|
||||
@GeneratedValue(strategy = GenerationType.AUTO, generator = "CTRL_FECHAMENTO_CAIXA_SEQ")
|
||||
@Column(name = "CTRLFECHAMENTOCAIXA_ID")
|
||||
private Long ctrlfechamentocaixaId;
|
||||
|
||||
@Column(name = "FECCORTE")
|
||||
@Temporal(TemporalType.DATE)
|
||||
private Date feccorte;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Column(name = "FECHAMENTO_STATUS")
|
||||
private CtrlFechamentoCaixaStatus status;
|
||||
|
||||
@Column(name = "FECMODIF")
|
||||
@Temporal(TemporalType.DATE)
|
||||
private Date fecmodif;
|
||||
|
||||
@Column(name = "ACTIVO")
|
||||
private boolean activo;
|
||||
|
||||
public Long getCtrlfechamentocaixaId() {
|
||||
return ctrlfechamentocaixaId;
|
||||
}
|
||||
|
||||
public void setCtrlfechamentocaixaId(Long ctrlfechamentocaixaId) {
|
||||
this.ctrlfechamentocaixaId = ctrlfechamentocaixaId;
|
||||
}
|
||||
|
||||
public Date getFeccorte() {
|
||||
return feccorte;
|
||||
}
|
||||
|
||||
public void setFeccorte(Date feccorte) {
|
||||
this.feccorte = feccorte;
|
||||
}
|
||||
|
||||
public Date getFecmodif() {
|
||||
return fecmodif;
|
||||
}
|
||||
|
||||
public void setFecmodif(Date fecmodif) {
|
||||
this.fecmodif = fecmodif;
|
||||
}
|
||||
|
||||
public boolean isActivo() {
|
||||
return activo;
|
||||
}
|
||||
|
||||
public void setActivo(boolean activo) {
|
||||
this.activo = activo;
|
||||
}
|
||||
|
||||
public CtrlFechamentoCaixaStatus getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(CtrlFechamentoCaixaStatus status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package com.rjconsultores.ventaboletos.enums;
|
||||
|
||||
public enum CtrlFechamentoCaixaStatus {
|
||||
|
||||
LIBERADO_RETENCAO_COMISSAO,
|
||||
RETENCAO_COMISSAO_EM_ANDAMENTO,
|
||||
RETENCAO_COMISSAO_CONCLUIDA;
|
||||
|
||||
}
|
|
@ -43,7 +43,7 @@ public interface CalculoComissaoService {
|
|||
|
||||
public void registrarCalculoComissao(PuntoVenta puntoVenta, Empresa empresa, Date dataInicial, Date dataFinal, Integer usuarioId) throws ComissaoException, BusinessException;
|
||||
|
||||
public void retencaoAutomaticaComissao();
|
||||
public void retencaoAutomaticaComissao(Date dataRetencao);
|
||||
|
||||
public RegistroCalculo realizarCalculoComissao(Integer puntoVentaId, Integer empresaId, Date periodo, Boolean isRetencaoDiaria, Integer usuarioId, Boolean isRefazerCalculo) throws ComissaoException, BusinessException;
|
||||
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
package com.rjconsultores.ventaboletos.service;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.rjconsultores.ventaboletos.entidad.CtrlFechamentoCaixa;
|
||||
import com.rjconsultores.ventaboletos.enums.CtrlFechamentoCaixaStatus;
|
||||
|
||||
public interface CtrlFechamentoCaixaService extends GenericService<CtrlFechamentoCaixa, Long> {
|
||||
|
||||
/**
|
||||
* Metodo que verifica se a rotina de retencao de comissao pode ser executada,
|
||||
* baseado no fechamento automatico dos caixas
|
||||
* @param feccorte
|
||||
* @return
|
||||
*/
|
||||
public boolean autorizarExecutarRotinaRetencao(Date feccorte);
|
||||
|
||||
/**
|
||||
* Metodo que atualiza o controle de fechamento de caixa para retencao de comissao
|
||||
* @param status
|
||||
* @param dataRetencao
|
||||
*/
|
||||
public void atualizarCtrlFechamentoCaixaStatus(CtrlFechamentoCaixaStatus status, Date dataRetencao);
|
||||
|
||||
}
|
|
@ -34,6 +34,7 @@ import com.rjconsultores.ventaboletos.entidad.EmpresaImposto;
|
|||
import com.rjconsultores.ventaboletos.entidad.PtovtaComissao;
|
||||
import com.rjconsultores.ventaboletos.entidad.PtovtaComissao.Receita;
|
||||
import com.rjconsultores.ventaboletos.entidad.PuntoVenta;
|
||||
import com.rjconsultores.ventaboletos.enums.CtrlFechamentoCaixaStatus;
|
||||
import com.rjconsultores.ventaboletos.enums.IndStatusBoleto;
|
||||
import com.rjconsultores.ventaboletos.enums.MimeType;
|
||||
import com.rjconsultores.ventaboletos.exception.BusinessException;
|
||||
|
@ -43,6 +44,7 @@ import com.rjconsultores.ventaboletos.service.ComissaoReceitaService;
|
|||
import com.rjconsultores.ventaboletos.service.ComissaoService;
|
||||
import com.rjconsultores.ventaboletos.service.ConferenciaComissaoService;
|
||||
import com.rjconsultores.ventaboletos.service.ConstanteService;
|
||||
import com.rjconsultores.ventaboletos.service.CtrlFechamentoCaixaService;
|
||||
import com.rjconsultores.ventaboletos.service.DescontoComissaoService;
|
||||
import com.rjconsultores.ventaboletos.service.EmpresaImpostoService;
|
||||
import com.rjconsultores.ventaboletos.service.EmpresaService;
|
||||
|
@ -100,6 +102,9 @@ public class CalculoComissaoServiceImpl implements CalculoComissaoService {
|
|||
@Autowired
|
||||
private PuntoVentaService puntoVentaService;
|
||||
|
||||
@Autowired
|
||||
private CtrlFechamentoCaixaService ctrlFechamentoCaixaService;
|
||||
|
||||
public boolean validaCompetencia(Date periodo) {
|
||||
Calendar calendario = Calendar.getInstance();
|
||||
calendario.setTime(periodo);
|
||||
|
@ -1217,7 +1222,7 @@ public class CalculoComissaoServiceImpl implements CalculoComissaoService {
|
|||
|
||||
@Override
|
||||
@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
|
||||
public void retencaoAutomaticaComissao() {
|
||||
public void retencaoAutomaticaComissao(Date dataRetencao) {
|
||||
Integer usuarioId = 1;
|
||||
if (UsuarioLogado.getUsuarioLogado() != null && UsuarioLogado.getUsuarioLogado().getUsuarioId() != null) {
|
||||
usuarioId = UsuarioLogado.getUsuarioLogado().getUsuarioId();
|
||||
|
@ -1226,10 +1231,6 @@ public class CalculoComissaoServiceImpl implements CalculoComissaoService {
|
|||
List<Empresa> empresas = empresaService.buscarEmpresaPtoVtaComissao();
|
||||
List<PuntoVenta> puntoVentas = puntoVentaService.buscarPuntoVentaPtoVtaComissao(empresas);
|
||||
|
||||
Calendar cDataRetencao = Calendar.getInstance();
|
||||
cDataRetencao.add(Calendar.DAY_OF_MONTH, -2);
|
||||
|
||||
Date dataRetencao = DateUtil.normalizarToFecha(cDataRetencao.getTime());
|
||||
String sDataRetencao = DateUtil.getStringDate(dataRetencao, "dd/MM/yyyy");
|
||||
|
||||
for (Empresa empresa : empresas) {
|
||||
|
@ -1245,6 +1246,13 @@ public class CalculoComissaoServiceImpl implements CalculoComissaoService {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Atualizando controle da retencao automatica */
|
||||
try {
|
||||
ctrlFechamentoCaixaService.atualizarCtrlFechamentoCaixaStatus(CtrlFechamentoCaixaStatus.RETENCAO_COMISSAO_CONCLUIDA, dataRetencao);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,96 @@
|
|||
package com.rjconsultores.ventaboletos.service.impl;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.rjconsultores.ventaboletos.dao.CtrlFechamentoCaixaDAO;
|
||||
import com.rjconsultores.ventaboletos.entidad.CtrlFechamentoCaixa;
|
||||
import com.rjconsultores.ventaboletos.enums.CtrlFechamentoCaixaStatus;
|
||||
import com.rjconsultores.ventaboletos.service.CtrlFechamentoCaixaService;
|
||||
import com.rjconsultores.ventaboletos.utilerias.DateUtil;
|
||||
|
||||
@Service("ctrlFechamentoCaixaService")
|
||||
public class CtrlFechamentoCaixaServiceImpl implements CtrlFechamentoCaixaService {
|
||||
|
||||
private static Logger log = Logger.getLogger(CtrlFechamentoCaixaServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
CtrlFechamentoCaixaDAO ctrlFechamentoCaixaDAO;
|
||||
|
||||
@Override
|
||||
public List<CtrlFechamentoCaixa> obtenerTodos() {
|
||||
return ctrlFechamentoCaixaDAO.obtenerTodos();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CtrlFechamentoCaixa obtenerID(Long id) {
|
||||
return ctrlFechamentoCaixaDAO.obtenerID(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public CtrlFechamentoCaixa suscribir(CtrlFechamentoCaixa entidad) {
|
||||
entidad.setFecmodif(Calendar.getInstance().getTime());
|
||||
entidad = ctrlFechamentoCaixaDAO.suscribir(entidad);
|
||||
return entidad;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public CtrlFechamentoCaixa actualizacion(CtrlFechamentoCaixa entidad) {
|
||||
entidad.setFecmodif(Calendar.getInstance().getTime());
|
||||
entidad = ctrlFechamentoCaixaDAO.actualizacion(entidad);
|
||||
return entidad;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void borrar(CtrlFechamentoCaixa entidad) {
|
||||
entidad.setFecmodif(Calendar.getInstance().getTime());
|
||||
entidad.setActivo(Boolean.FALSE);
|
||||
ctrlFechamentoCaixaDAO.borrar(entidad);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean autorizarExecutarRotinaRetencao(Date feccorte) {
|
||||
try {
|
||||
String sFeccorte = DateUtil.getStringDate(feccorte, "dd/MM/yyyy");
|
||||
CtrlFechamentoCaixa ctrlFechamentoCaixa = ctrlFechamentoCaixaDAO.obtenerFeccorte(feccorte);
|
||||
if(ctrlFechamentoCaixa == null) {
|
||||
log.info("Nenhum controle de retencao foi localizado para data: " + sFeccorte);
|
||||
} else if(CtrlFechamentoCaixaStatus.RETENCAO_COMISSAO_EM_ANDAMENTO.equals(ctrlFechamentoCaixa.getStatus())) {
|
||||
log.info("Retencao de comissao em andamento para data: " + sFeccorte);
|
||||
} else if(CtrlFechamentoCaixaStatus.RETENCAO_COMISSAO_CONCLUIDA.equals(ctrlFechamentoCaixa.getStatus())) {
|
||||
log.info("Retencao de comissao concluida para data: " + sFeccorte);
|
||||
} else if(CtrlFechamentoCaixaStatus.LIBERADO_RETENCAO_COMISSAO.equals(ctrlFechamentoCaixa.getStatus())) {
|
||||
log.info("Retencao de comissao liberada para data: " + sFeccorte);
|
||||
ctrlFechamentoCaixa.setStatus(CtrlFechamentoCaixaStatus.RETENCAO_COMISSAO_EM_ANDAMENTO);
|
||||
actualizacion(ctrlFechamentoCaixa);
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void atualizarCtrlFechamentoCaixaStatus(CtrlFechamentoCaixaStatus status, Date dataRetencao) {
|
||||
try {
|
||||
CtrlFechamentoCaixa ctrlFechamentoCaixa = ctrlFechamentoCaixaDAO.obtenerFeccorte(dataRetencao);
|
||||
ctrlFechamentoCaixa.setStatus(status);
|
||||
actualizacion(ctrlFechamentoCaixa);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue