bug#14127
dev:thiago qua: git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@92607 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
f059a24a15
commit
4fdf800bd7
|
@ -5,6 +5,7 @@
|
|||
package com.rjconsultores.ventaboletos.dao;
|
||||
|
||||
import com.rjconsultores.ventaboletos.entidad.ConfigRestriccionPago;
|
||||
import com.rjconsultores.ventaboletos.entidad.Empresa;
|
||||
import com.rjconsultores.ventaboletos.entidad.FormaPago;
|
||||
import com.rjconsultores.ventaboletos.entidad.RestriccionPago;
|
||||
import java.util.List;
|
||||
|
@ -17,7 +18,7 @@ import java.util.Map;
|
|||
public interface ConfigRestriccionPagoDAO extends GenericDAO<ConfigRestriccionPago, Integer> {
|
||||
|
||||
public List<ConfigRestriccionPago> buscar(FormaPago formaPago,
|
||||
RestriccionPago restriccionPago);
|
||||
RestriccionPago restriccionPago, Empresa empresa);
|
||||
|
||||
public Map<Integer,ConfigRestriccionPago> buscar(FormaPago formaPago);
|
||||
|
||||
|
|
|
@ -4,21 +4,24 @@
|
|||
*/
|
||||
package com.rjconsultores.ventaboletos.dao.hibernate;
|
||||
|
||||
import com.rjconsultores.ventaboletos.dao.ConfigRestriccionPagoDAO;
|
||||
import com.rjconsultores.ventaboletos.entidad.ConfigRestriccionPago;
|
||||
import com.rjconsultores.ventaboletos.entidad.FormaPago;
|
||||
import com.rjconsultores.ventaboletos.entidad.RestriccionPago;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hibernate.Criteria;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.criterion.Order;
|
||||
import org.hibernate.criterion.Criterion;
|
||||
import org.hibernate.criterion.Restrictions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.rjconsultores.ventaboletos.dao.ConfigRestriccionPagoDAO;
|
||||
import com.rjconsultores.ventaboletos.entidad.ConfigRestriccionPago;
|
||||
import com.rjconsultores.ventaboletos.entidad.Empresa;
|
||||
import com.rjconsultores.ventaboletos.entidad.FormaPago;
|
||||
import com.rjconsultores.ventaboletos.entidad.RestriccionPago;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Administrador
|
||||
|
@ -42,13 +45,23 @@ public class ConfigRestriccionPagoHibernateDAO
|
|||
}
|
||||
|
||||
public List<ConfigRestriccionPago> buscar(FormaPago formaPago,
|
||||
RestriccionPago restriccionPago) {
|
||||
RestriccionPago restriccionPago, Empresa empresa) {
|
||||
Criteria c = getSession().createCriteria(getPersistentClass());
|
||||
c.add(Restrictions.eq("activo", Boolean.TRUE));
|
||||
|
||||
c.add(Restrictions.eq("restriccion", restriccionPago));
|
||||
c.add(Restrictions.eq("formaPago", formaPago));
|
||||
|
||||
Criterion empresaNull = Restrictions.isNull("empresa");
|
||||
Criterion empresaMenosUm = Restrictions.eq("empresa", new Empresa(-1));
|
||||
|
||||
if(empresa != null) {
|
||||
Criterion empresaIgual = Restrictions.eq("empresa", empresa);
|
||||
c.add(Restrictions.or(Restrictions.or(empresaNull, empresaMenosUm), empresaIgual));
|
||||
} else {
|
||||
c.add(Restrictions.or(empresaNull, empresaMenosUm));
|
||||
}
|
||||
|
||||
return c.list();
|
||||
}
|
||||
|
||||
|
|
|
@ -47,6 +47,9 @@ public class ConfigRestriccionPago implements Serializable {
|
|||
@JoinColumn(name = "FORMAPAGO_ID", referencedColumnName = "FORMAPAGO_ID")
|
||||
@ManyToOne
|
||||
private FormaPago formaPago;
|
||||
@JoinColumn(name = "EMPRESA_ID", referencedColumnName = "EMPRESA_ID")
|
||||
@ManyToOne
|
||||
private Empresa empresa;
|
||||
|
||||
public ConfigRestriccionPago() {
|
||||
}
|
||||
|
@ -106,7 +109,7 @@ public class ConfigRestriccionPago implements Serializable {
|
|||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 0;
|
||||
hash += (configrestriccionId != null ? configrestriccionId.hashCode() : 0);
|
||||
hash += (getConfigrestriccionId() != null ? getConfigrestriccionId().hashCode() : 0);
|
||||
return hash;
|
||||
}
|
||||
|
||||
|
@ -117,7 +120,7 @@ public class ConfigRestriccionPago implements Serializable {
|
|||
return false;
|
||||
}
|
||||
ConfigRestriccionPago other = (ConfigRestriccionPago) object;
|
||||
if ((this.configrestriccionId == null && other.configrestriccionId != null) || (this.configrestriccionId != null && !this.configrestriccionId.equals(other.configrestriccionId))) {
|
||||
if ((this.getConfigrestriccionId() == null && other.getConfigrestriccionId() != null) || (this.getConfigrestriccionId() != null && !this.getConfigrestriccionId().equals(other.getConfigrestriccionId()))) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -127,4 +130,12 @@ public class ConfigRestriccionPago implements Serializable {
|
|||
public String toString() {
|
||||
return "com.rjconsultores.ventaboletos.entidad.ConfigRestriccionPago[configrestriccionId=" + configrestriccionId + "]";
|
||||
}
|
||||
|
||||
public Empresa getEmpresa() {
|
||||
return empresa;
|
||||
}
|
||||
|
||||
public void setEmpresa(Empresa empresa) {
|
||||
this.empresa = empresa;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
package com.rjconsultores.ventaboletos.service;
|
||||
|
||||
import com.rjconsultores.ventaboletos.entidad.ConfigRestriccionPago;
|
||||
import com.rjconsultores.ventaboletos.entidad.Empresa;
|
||||
import com.rjconsultores.ventaboletos.entidad.FormaPago;
|
||||
import com.rjconsultores.ventaboletos.entidad.RestriccionPago;
|
||||
import java.util.List;
|
||||
|
@ -17,7 +18,7 @@ public interface ConfigRestriccionPagoService
|
|||
extends GenericService<ConfigRestriccionPago, Integer> {
|
||||
|
||||
public List<ConfigRestriccionPago> buscar(FormaPago formaPago,
|
||||
RestriccionPago restriccionPago);
|
||||
RestriccionPago restriccionPago, Empresa empresa);
|
||||
|
||||
/**
|
||||
* Verifica se puede dar de alta en el registro.
|
||||
|
|
|
@ -6,6 +6,7 @@ package com.rjconsultores.ventaboletos.service.impl;
|
|||
|
||||
import com.rjconsultores.ventaboletos.dao.ConfigRestriccionPagoDAO;
|
||||
import com.rjconsultores.ventaboletos.entidad.ConfigRestriccionPago;
|
||||
import com.rjconsultores.ventaboletos.entidad.Empresa;
|
||||
import com.rjconsultores.ventaboletos.entidad.FormaPago;
|
||||
import com.rjconsultores.ventaboletos.entidad.RestriccionPago;
|
||||
import com.rjconsultores.ventaboletos.service.ConfigRestriccionPagoService;
|
||||
|
@ -70,8 +71,8 @@ public class ConfigRestriccionPagoServiceImpl implements ConfigRestriccionPagoSe
|
|||
}
|
||||
|
||||
public List<ConfigRestriccionPago> buscar(FormaPago formaPago,
|
||||
RestriccionPago restriccionPago) {
|
||||
return configRestriccionPagoDAO.buscar(formaPago, restriccionPago);
|
||||
RestriccionPago restriccionPago, Empresa empresa) {
|
||||
return configRestriccionPagoDAO.buscar(formaPago, restriccionPago, empresa);
|
||||
}
|
||||
|
||||
public boolean puedoDarDeAlta(ConfigRestriccionPago configRestriccionPago) {
|
||||
|
@ -89,7 +90,7 @@ public class ConfigRestriccionPagoServiceImpl implements ConfigRestriccionPagoSe
|
|||
Collection<ConfigRestriccionPago> values = mapConsulta.values();
|
||||
Integer restriccionId = null;
|
||||
for (ConfigRestriccionPago c : values) {
|
||||
if ((c.equals(configRestriccionPago)) && (!c.getRestriccion().getRestriccionId().equals(configRestriccionPago.getRestriccion().getRestriccionId()))) {
|
||||
if (c.equals(configRestriccionPago) || (!c.getRestriccion().getRestriccionId().equals(configRestriccionPago.getRestriccion().getRestriccionId()))) {
|
||||
restriccionId = c.getRestriccion().getRestriccionId().intValue();
|
||||
}
|
||||
}
|
||||
|
@ -99,39 +100,39 @@ public class ConfigRestriccionPagoServiceImpl implements ConfigRestriccionPagoSe
|
|||
}
|
||||
|
||||
if ((configRestriccionPago.getRestriccion().getRestriccionId().equals(RESTRICCION_CANCELABLE.shortValue())
|
||||
&& (mapConsulta.get(RESTRICCION_NO_CANCELABLE) != null))
|
||||
&& (mapConsulta.get(RESTRICCION_NO_CANCELABLE) != null) && isMesmaEmpresaOrEmpresaTodas(configRestriccionPago, mapConsulta.get(RESTRICCION_NO_CANCELABLE)))
|
||||
|| (configRestriccionPago.getRestriccion().getRestriccionId().equals(RESTRICCION_NO_CANCELABLE.shortValue())
|
||||
&& (mapConsulta.get(RESTRICCION_CANCELABLE) != null))) {
|
||||
&& (mapConsulta.get(RESTRICCION_CANCELABLE) != null) && isMesmaEmpresaOrEmpresaTodas(configRestriccionPago, mapConsulta.get(RESTRICCION_CANCELABLE)))) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((configRestriccionPago.getRestriccion().getRestriccionId().equals(RESTRICCION_TRANSFERIBLE.shortValue())
|
||||
&& (mapConsulta.get(RESTRICCION_NO_TRANSFERIBLE) != null))
|
||||
&& (mapConsulta.get(RESTRICCION_NO_TRANSFERIBLE) != null) && isMesmaEmpresaOrEmpresaTodas(configRestriccionPago, mapConsulta.get(RESTRICCION_NO_TRANSFERIBLE)))
|
||||
|| (configRestriccionPago.getRestriccion().getRestriccionId().equals(RESTRICCION_NO_TRANSFERIBLE.shortValue())
|
||||
&& (mapConsulta.get(RESTRICCION_TRANSFERIBLE) != null))) {
|
||||
&& (mapConsulta.get(RESTRICCION_TRANSFERIBLE) != null) && isMesmaEmpresaOrEmpresaTodas(configRestriccionPago, mapConsulta.get(RESTRICCION_TRANSFERIBLE)))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((configRestriccionPago.getRestriccion().getRestriccionId().equals(RESTRICCION_RESERVABLE.shortValue())
|
||||
&& (mapConsulta.get(RESTRICCION_NO_RESERVABLE) != null))
|
||||
&& (mapConsulta.get(RESTRICCION_NO_RESERVABLE) != null) && isMesmaEmpresaOrEmpresaTodas(configRestriccionPago, mapConsulta.get(RESTRICCION_NO_RESERVABLE)))
|
||||
|| (configRestriccionPago.getRestriccion().getRestriccionId().equals(RESTRICCION_NO_RESERVABLE.shortValue())
|
||||
&& (mapConsulta.get(RESTRICCION_RESERVABLE) != null))) {
|
||||
&& (mapConsulta.get(RESTRICCION_RESERVABLE) != null) && isMesmaEmpresaOrEmpresaTodas(configRestriccionPago, mapConsulta.get(RESTRICCION_RESERVABLE)))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (configRestriccionPago.getRestriccion().getRestriccionId().equals(RESTRICCION_RESERVABLE.shortValue())
|
||||
&& (mapConsulta.get(RESTRICCION_RESERVABLE) != null)) {
|
||||
&& (mapConsulta.get(RESTRICCION_RESERVABLE) != null) && isMesmaEmpresaOrEmpresaTodas(configRestriccionPago, mapConsulta.get(RESTRICCION_RESERVABLE))) {
|
||||
return false;
|
||||
}
|
||||
if (configRestriccionPago.getRestriccion().getRestriccionId().equals(RESTRICCION_TRANSFERIBLE.shortValue())
|
||||
&& (mapConsulta.get(RESTRICCION_TRANSFERIBLE) != null)) {
|
||||
&& (mapConsulta.get(RESTRICCION_TRANSFERIBLE) != null) && isMesmaEmpresaOrEmpresaTodas(configRestriccionPago, mapConsulta.get(RESTRICCION_TRANSFERIBLE))) {
|
||||
return false;
|
||||
}
|
||||
if (configRestriccionPago.getRestriccion().getRestriccionId().equals(RESTRICCION_CANCELABLE.shortValue())
|
||||
&& (mapConsulta.get(RESTRICCION_CANCELABLE) != null)) {
|
||||
&& (mapConsulta.get(RESTRICCION_CANCELABLE) != null) && isMesmaEmpresaOrEmpresaTodas(configRestriccionPago, mapConsulta.get(RESTRICCION_CANCELABLE))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -140,5 +141,13 @@ public class ConfigRestriccionPagoServiceImpl implements ConfigRestriccionPagoSe
|
|||
return true;
|
||||
}
|
||||
|
||||
private boolean isMesmaEmpresaOrEmpresaTodas(ConfigRestriccionPago configRestriccionPago, ConfigRestriccionPago configRestriccionPagoExistente) {
|
||||
return configRestriccionPagoExistente.getEmpresa() == null ||
|
||||
configRestriccionPagoExistente.getEmpresa().getEmpresaId() == -1 ||
|
||||
configRestriccionPago.getEmpresa() == null ||
|
||||
configRestriccionPago.getEmpresa().getEmpresaId() == -1 ||
|
||||
configRestriccionPago.getEmpresa().equals(configRestriccionPagoExistente.getEmpresa());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue