Rotina de faturamento de voucher feat bug#AL-4356
parent
f9750aee3c
commit
cf539458e2
2
pom.xml
2
pom.xml
|
@ -3,7 +3,7 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>br.com.rjconsultores</groupId>
|
||||
<artifactId>ModelWeb</artifactId>
|
||||
<version>1.96.3</version>
|
||||
<version>1.97.0</version>
|
||||
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
|
|
|
@ -9,6 +9,6 @@ public interface VoucherDAO extends GenericDAO<Voucher, Long> {
|
|||
|
||||
public List<Voucher> buscarConsulta(Long voucherId, String numContrato, String nit, String nomeTransportadora, Date dataInicial, Date dataFinal, Integer origemId, Integer destinoId);
|
||||
|
||||
public List<Voucher> buscarLegalizacao(Long numInicial, Long numFinal, String numContrato, Integer status, Integer origenId, Integer destinoId);
|
||||
public List<Voucher> buscarListaVoucher(Long numInicial, Long numFinal, String numContrato, Long transportadora, Long grupoContratoId, Integer status, Integer origenId, Integer destinoId);
|
||||
|
||||
}
|
||||
|
|
|
@ -61,6 +61,7 @@ public class VoucherHibernateDAO extends GenericHibernateDAO<Voucher, Long> impl
|
|||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
hql);
|
||||
|
||||
hql.append("ORDER BY voucherId ");
|
||||
|
@ -79,18 +80,21 @@ public class VoucherHibernateDAO extends GenericHibernateDAO<Voucher, Long> impl
|
|||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
query);
|
||||
|
||||
return query.list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Voucher> buscarLegalizacao(Long numInicial,
|
||||
Long numFinal,
|
||||
String numContrato,
|
||||
Integer status,
|
||||
Integer origemId,
|
||||
Integer destinoId) {
|
||||
public List<Voucher> buscarListaVoucher(Long numInicial,
|
||||
Long numFinal,
|
||||
String numContrato,
|
||||
Long transportadoraId,
|
||||
Long grupoContratoId,
|
||||
Integer status,
|
||||
Integer origemId,
|
||||
Integer destinoId) {
|
||||
|
||||
|
||||
StringBuilder hql = new StringBuilder();
|
||||
|
@ -104,11 +108,12 @@ public class VoucherHibernateDAO extends GenericHibernateDAO<Voucher, Long> impl
|
|||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
status,
|
||||
origemId,
|
||||
destinoId,
|
||||
null,
|
||||
destinoId,
|
||||
transportadoraId,
|
||||
grupoContratoId,
|
||||
numInicial,
|
||||
numFinal,
|
||||
hql);
|
||||
|
@ -122,11 +127,12 @@ public class VoucherHibernateDAO extends GenericHibernateDAO<Voucher, Long> impl
|
|||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
status,
|
||||
origemId,
|
||||
destinoId,
|
||||
null,
|
||||
destinoId,
|
||||
transportadoraId,
|
||||
grupoContratoId,
|
||||
numInicial,
|
||||
numFinal,
|
||||
query);
|
||||
|
@ -134,7 +140,6 @@ public class VoucherHibernateDAO extends GenericHibernateDAO<Voucher, Long> impl
|
|||
return query.list();
|
||||
}
|
||||
|
||||
|
||||
private void setJoins(StringBuilder hql) {
|
||||
hql.append("LEFT JOIN com.rjconsultores.ventaboletos.entidad.Parada ori ON v.origenId = ori.paradaId ");
|
||||
hql.append("LEFT JOIN com.rjconsultores.ventaboletos.entidad.Parada des ON v.destinoId = des.paradaId ");
|
||||
|
@ -145,11 +150,12 @@ public class VoucherHibernateDAO extends GenericHibernateDAO<Voucher, Long> impl
|
|||
String nit,
|
||||
String nomeTransportadora,
|
||||
Date dataInicial,
|
||||
Date dataFinal,
|
||||
Date dataFinal,
|
||||
Integer status,
|
||||
Integer origemId,
|
||||
Integer destinoId,
|
||||
Long transportadoraId,
|
||||
Long grupoContratoId,
|
||||
Long numInicial,
|
||||
Long numFinal,
|
||||
StringBuilder hql) {
|
||||
|
@ -186,6 +192,10 @@ public class VoucherHibernateDAO extends GenericHibernateDAO<Voucher, Long> impl
|
|||
hql.append(" AND v.transportadora.transportadoraId = :transportadoraId ");
|
||||
}
|
||||
|
||||
if(grupoContratoId != null ){
|
||||
hql.append(" AND v.contrato.grupoContratoId = :grupoContratoId ");
|
||||
}
|
||||
|
||||
if(dataInicial != null ){
|
||||
hql.append(" AND v.dataValidade >= :dataInicial ");
|
||||
}
|
||||
|
@ -213,6 +223,7 @@ public class VoucherHibernateDAO extends GenericHibernateDAO<Voucher, Long> impl
|
|||
Integer origemId,
|
||||
Integer destinoId,
|
||||
Long transportadoraId,
|
||||
Long grupoContratoId,
|
||||
Long numInicial,
|
||||
Long numFinal,
|
||||
Query query) {
|
||||
|
@ -245,6 +256,10 @@ public class VoucherHibernateDAO extends GenericHibernateDAO<Voucher, Long> impl
|
|||
query.setLong("transportadoraId", transportadoraId);
|
||||
}
|
||||
|
||||
if(grupoContratoId != null ){
|
||||
query.setLong("grupoContratoId", grupoContratoId);
|
||||
}
|
||||
|
||||
if(dataInicial != null ){
|
||||
query.setDate("dataInicial", dataInicial);
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@ public class Voucher implements Serializable {
|
|||
@Column(name = "GRUPOCONTRATO_ID")
|
||||
private Long grupoContratoId;
|
||||
|
||||
@OneToOne(fetch = FetchType.LAZY)
|
||||
@OneToOne
|
||||
@JoinColumn(name = "TRANSPORTADORA_ID")
|
||||
private Transportadora transportadora;
|
||||
|
||||
|
@ -105,6 +105,10 @@ public class Voucher implements Serializable {
|
|||
@Column(name = "DATA_LEGALIZA")
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date dataLegaliza;
|
||||
|
||||
@Column(name = "DATA_CORTE")
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date dataCorte;
|
||||
|
||||
@Column(name = "ACTIVO")
|
||||
private boolean activo;
|
||||
|
|
|
@ -11,8 +11,12 @@ import com.rjconsultores.ventaboletos.vo.configuracioneccomerciales.VoucherVO;
|
|||
|
||||
public interface VoucherService extends GenericService<Voucher, Long> {
|
||||
|
||||
List<Voucher> buscarConsulta(Long voucherId, String numContrato, String nit, String nomeTransportadora, Date dataInicial, Date dataFinal, Integer origemId, Integer destinoId);
|
||||
public List<Voucher> buscarConsulta(Long voucherId, String numContrato, String nit, String nomeTransportadora, Date dataInicial, Date dataFinal, Integer origemId, Integer destinoId);
|
||||
|
||||
List<VoucherVO> legalizar(Long numInicial, Long numFinal, String numContrato, Transportadora transportadora, BigDecimal valor, Parada origem, Parada destino);
|
||||
public List<VoucherVO> legalizar(Long numInicial, Long numFinal, String numContrato, Transportadora transportadora, BigDecimal valor, Parada origem, Parada destino);
|
||||
|
||||
public List<Voucher> buscarListaVoucher(Long numInicial, Long numFinal, String numContrato, Long transportadora, Long grupoContratoId, Integer status, Integer origem, Integer destino);
|
||||
|
||||
public List<Voucher> faturar(List<Voucher> lista, Long numFatura, Date datCorte);
|
||||
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import java.util.List;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.zkoss.lang.Strings;
|
||||
import org.zkoss.util.resource.Labels;
|
||||
|
||||
import com.rjconsultores.ventaboletos.dao.VoucherDAO;
|
||||
|
@ -45,6 +46,8 @@ public class VoucherServiceImpl implements VoucherService {
|
|||
|
||||
@Transactional
|
||||
public Voucher actualizacion(Voucher entidad) {
|
||||
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
||||
entidad.setFecModif(Calendar.getInstance().getTime());
|
||||
return voucherDAO.actualizacion(entidad);
|
||||
}
|
||||
|
||||
|
@ -67,13 +70,32 @@ public class VoucherServiceImpl implements VoucherService {
|
|||
Integer origemId,
|
||||
Integer destinoId) {
|
||||
return voucherDAO.buscarConsulta(voucherId,
|
||||
numContrato,
|
||||
nit,
|
||||
nomeTransportadora,
|
||||
dataInicial,
|
||||
dataFinal,
|
||||
origemId,
|
||||
destinoId);
|
||||
numContrato,
|
||||
nit,
|
||||
nomeTransportadora,
|
||||
dataInicial,
|
||||
dataFinal,
|
||||
origemId,
|
||||
destinoId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Voucher> buscarListaVoucher(Long numInicial,
|
||||
Long numFinal,
|
||||
String numContrato,
|
||||
Long transportadora,
|
||||
Long grupoContratoId,
|
||||
Integer status,
|
||||
Integer origem,
|
||||
Integer destino) {
|
||||
return voucherDAO.buscarListaVoucher(numInicial,
|
||||
numFinal,
|
||||
numContrato,
|
||||
transportadora,
|
||||
grupoContratoId,
|
||||
status,
|
||||
origem,
|
||||
destino);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -85,12 +107,14 @@ public class VoucherServiceImpl implements VoucherService {
|
|||
BigDecimal valor,
|
||||
Parada origem,
|
||||
Parada destino) {
|
||||
List<Voucher> dados = voucherDAO.buscarLegalizacao(numInicial,
|
||||
numFinal,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null);
|
||||
List<Voucher> dados = voucherDAO.buscarListaVoucher(numInicial,
|
||||
numFinal,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null);
|
||||
|
||||
List<VoucherVO> retorno = new ArrayList<VoucherVO>();
|
||||
for (Voucher vou : dados) {
|
||||
|
@ -143,4 +167,32 @@ public class VoucherServiceImpl implements VoucherService {
|
|||
|
||||
return retorno;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public List<Voucher> faturar(List<Voucher> lista, Long numFatura, Date datCorte) {
|
||||
for (Voucher vou : lista) {
|
||||
if( Strings.isBlank(vou.getNumFatura()) ) {
|
||||
if(numFatura != null) {
|
||||
vou.setNumFatura(numFatura.toString());
|
||||
}else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if( vou.getDataCorte() == null ) {
|
||||
if(datCorte != null) {
|
||||
vou.setDataCorte(datCorte);
|
||||
}else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
vou.setStatus(SituacaoVoucher.FATURADO.getValor());
|
||||
vou.setDataFatura(Calendar.getInstance().getTime());
|
||||
voucherDAO.actualizacion(vou);
|
||||
}
|
||||
|
||||
return lista;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -75,6 +75,15 @@ public class VoucherVO implements Serializable {
|
|||
@Renderizado( posicao = 8 )
|
||||
private String mensagem;
|
||||
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date dataFatura;
|
||||
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date dataLegaliza;
|
||||
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date dataCorte;
|
||||
|
||||
public SituacaoVoucher getSituacaoVoucher() {
|
||||
return SituacaoVoucher.buscarPeloValor(status);
|
||||
}
|
||||
|
@ -123,6 +132,9 @@ public class VoucherVO implements Serializable {
|
|||
this.transportadora = pai.getTransportadora();
|
||||
this.valorLegalizado = pai.getValorLegalizado();
|
||||
this.valorLicitado = pai.getValorLicitado();
|
||||
this.dataFatura = pai.getDataFatura();
|
||||
this.dataLegaliza = pai.getDataLegaliza();
|
||||
this.dataCorte = pai.getDataCorte();
|
||||
}
|
||||
|
||||
public static VoucherVO converteVoucher( Voucher pai ) {
|
||||
|
|
Loading…
Reference in New Issue