0004817: Baixa do estoque depois da exclusão de um micro

git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@33511 d1611594-4594-4d17-8e1d-87c2c4800839
master
julio 2014-02-07 13:51:04 +00:00
parent e3dab24c72
commit 67409080cf
1 changed files with 83 additions and 21 deletions

View File

@ -74,7 +74,7 @@ public class EstacionHibernateDAO extends GenericHibernateDAO<Estacion, Integer>
return c.list(); return c.list();
} }
public List<Estacion> buscarEstaciones(PuntoVenta puntoVenta) { public List<Estacion> buscarEstaciones(PuntoVenta puntoVenta) {
Criteria c = getSession().createCriteria(getPersistentClass()); Criteria c = getSession().createCriteria(getPersistentClass());
c.add(Restrictions.eq("activo", Boolean.TRUE)); c.add(Restrictions.eq("activo", Boolean.TRUE));
@ -87,7 +87,7 @@ public List<Estacion> buscarEstaciones(PuntoVenta puntoVenta) {
@Override @Override
public List<PuntoVenta> buscarPuntosVentaEstacionPorUsuario(Usuario usuario) { public List<PuntoVenta> buscarPuntosVentaEstacionPorUsuario(Usuario usuario) {
Criteria buscaPuntoVentasUsuario = getSession().createCriteria(getPersistentClass()) Criteria buscaPuntoVentasUsuario = getSession().createCriteria(getPersistentClass())
.setProjection(Projections.distinct(Property.forName("puntoVenta"))) .setProjection(Projections.distinct(Property.forName("puntoVenta")))
.add(Restrictions.eq("activo", Boolean.TRUE)) .add(Restrictions.eq("activo", Boolean.TRUE))
.add(Restrictions.eq("usuarioId", usuario.getUsuarioId())); .add(Restrictions.eq("usuarioId", usuario.getUsuarioId()));
@ -95,20 +95,82 @@ public List<Estacion> buscarEstaciones(PuntoVenta puntoVenta) {
return buscaPuntoVentasUsuario.list(); return buscaPuntoVentasUsuario.list();
} }
public Boolean temEstoque(PuntoVenta puntoVenta, Estacion estacion){ public Boolean temEstoque(PuntoVenta puntoVenta, Estacion estacion) {
StringBuilder qryStr = new StringBuilder();
qryStr.append("Select count(*) from ABASTO_BOLETO B, DET_ABASTO_BOLETO D ");
qryStr.append("where d.abastoboleto_id = b.abastoboleto_id and (d.statusfirma = 0 ");
qryStr.append("or d.statusfirma = 1) and d.activo = 1 and b.activo = 1 and ");
qryStr.append("b.puntoventa_id = :puntoventa_id and b.estacion_id = :estacion_id");
SQLQuery query = getSession().createSQLQuery(qryStr.toString()); StringBuilder sb = new StringBuilder();
query.setParameter("puntoventa_id", puntoVenta.getPuntoventaId()); sb.append("select dab.numseriepreimpresa as serie, ");
query.setParameter("estacion_id", estacion.getEstacionId()); sb.append(" dab.numfolioinicial as folioinicial, ");
sb.append(" dab.numfoliofinal as foliofinal, ");
sb.append(" pv.nombpuntoventa as descpuntoventa, ");
sb.append(" e.numcaja as numcaja, ");
sb.append(" e.descestacion as descestacion, ");
sb.append(" fp.foliopreimpreso as folioatual, ");
sb.append(" e.estacion_id as estacionid, ");
sb.append(" ab.articulo_id as articuloid, ");
sb.append(" a.descarticulo as tipo, ");
sb.append(" em.nombempresa as nombempresa, ");
sb.append(" em.empresa_id as empresaid ");
sb.append("from det_abasto_boleto dab ");
sb.append(" inner join abasto_boleto ab ");
sb.append(" on dab.abastoboleto_id = ab.abastoboleto_id ");
sb.append(" inner join punto_venta pv ");
sb.append(" on ab.puntoventa_id = pv.puntoventa_id ");
sb.append(" inner join estacion e ");
sb.append(" on ab.estacion_id = e.estacion_id ");
sb.append(" inner join folio_preimpreso fp ");
sb.append(" on fp.estacion_id = ab.estacion_id ");
sb.append(" and fp.empresa_id = ab.empresa_id ");
sb.append(" and ( fp.numeserie = dab.numseriepreimpresa ");
sb.append(" or ( fp.numeserie is null ");
sb.append(" and dab.numseriepreimpresa is null ) ) ");
sb.append(" left join articulo a ");
sb.append(" on a.articulo_id = ab.articulo_id ");
sb.append(" left join empresa em ");
sb.append(" on em.empresa_id = ab.empresa_id ");
sb.append("where dab.statusoperacion = 1 ");
sb.append(" and fp.activo = 1 ");
sb.append(" and dab.activo = 1 ");
sb.append(" and ab.puntoventa_id = :puntoventaId ");
sb.append(" and e.estacion_id = :estacionId ");
sb.append("union ");
sb.append("select dab.numseriepreimpresa as serie, ");
sb.append(" dab.numfolioinicial as folioinicial, ");
sb.append(" dab.numfoliofinal as foliofinal, ");
sb.append(" pv.nombpuntoventa as descpuntoventa, ");
sb.append(" e.numcaja as numcaja, ");
sb.append(" e.descestacion as descestacion, ");
sb.append(" dab.numfolioinicial as folioatual, ");
sb.append(" e.estacion_id as estacionid, ");
sb.append(" ab.articulo_id as articuloid, ");
sb.append(" a.descarticulo as tipo, ");
sb.append(" em.nombempresa as nombempresa, ");
sb.append(" em.empresa_id as empresaid ");
sb.append("from det_abasto_boleto dab ");
sb.append(" inner join abasto_boleto ab ");
sb.append(" on dab.abastoboleto_id = ab.abastoboleto_id ");
sb.append(" inner join punto_venta pv ");
sb.append(" on ab.puntoventa_id = pv.puntoventa_id ");
sb.append(" inner join estacion e ");
sb.append(" on ab.estacion_id = e.estacion_id ");
sb.append(" left join articulo a ");
sb.append(" on a.articulo_id = ab.articulo_id ");
sb.append(" left join empresa em ");
sb.append(" on em.empresa_id = ab.empresa_id ");
sb.append("where dab.statusoperacion = 0 ");
sb.append(" and dab.activo = 1 ");
sb.append(" and ab.puntoventa_id = :puntoventaId ");
sb.append(" and e.estacion_id = :estacionId ");
SQLQuery query = getSession().createSQLQuery(sb.toString());
query.setParameter("puntoventaId", puntoVenta.getPuntoventaId());
query.setParameter("estacionId", estacion.getEstacionId());
List list = query.list();
if (list.size() > 0)
return true;
else
return false;
List<BigDecimal> list = query.list();
BigDecimal result = list.get(0);
return (result.intValue() > 0);
} }
} }