diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/BpeHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/BpeHibernateDAO.java index 335ffb670..286458d7c 100644 --- a/src/com/rjconsultores/ventaboletos/dao/hibernate/BpeHibernateDAO.java +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/BpeHibernateDAO.java @@ -251,7 +251,7 @@ public class BpeHibernateDAO extends HibernateDaoSupport implements BpeDAO { sql.append(" bpe.desconto as v_desconto, "); sql.append(" bpe.chbpe, "); sql.append(" coalesce(bpe.chbpe_substituicao, ' ') as chbpe_sub, "); - sql.append(" to_char(c.feccreacion, 'yyyymmdd') as dh_emisao, "); + sql.append(" to_char(c.fechorventa, 'yyyymmdd') as dh_emisao, "); sql.append(" to_char(c.fechorviaje, 'yyyymmdd') as dhrecbto, "); sql.append(" coalesce(bpe.tiposubstituicao, '0') as tp_bpe, "); sql.append(" bpe.retorno_id as retorno, "); @@ -313,9 +313,7 @@ public class BpeHibernateDAO extends HibernateDaoSupport implements BpeDAO { sql.append(" bpe.vcomp99, "); sql.append(" bpe.pRedBC "); sql.append("from boleto c "); - sql.append(" join bpe bpe on c.boleto_id = bpe.boleto_id "); - sql.append(" and bpe.activo = (case when TO_CHAR(c.feccreacion, 'yyyymmdd') <> "); - sql.append(" to_char(to_date(substr(bpe.dhrecbto,0,10), 'YYYY-MM-DD'), 'yyyymmdd') then 0 else 1 end) "); + sql.append(" join bpe bpe on c.boleto_id = bpe.boleto_id and bpe.activo = 1 "); sql.append(" join estado e on e.codibge = bpe.uf "); sql.append(" join marca ma on c.marca_id = ma.marca_id "); sql.append(" join empresa ep on ma.empresa_id = ep.empresa_id "); @@ -325,8 +323,8 @@ public class BpeHibernateDAO extends HibernateDaoSupport implements BpeDAO { sql.append(" and bpe.tipoamb = 1 and ep.activo = 1 "); sql.append(" and bpe.codstat in ('-1','100','101','102','135','150') "); sql.append(" and (bpe.tipoevento not in ('110115','110116') or bpe.tipoevento is null) "); - sql.append(" and c.feccreacion >= to_date(?,'DD/MM/YYYY HH24:MI:SS') "); - sql.append(" and c.feccreacion <= to_date(?,'DD/MM/YYYY HH24:MI:SS') "); + sql.append(" and c.fechorventa >= to_date(?,'DD/MM/YYYY HH24:MI:SS') "); + sql.append(" and c.fechorventa <= to_date(?,'DD/MM/YYYY HH24:MI:SS') "); sql.append(" and ep.empresa_id = ? "); sql.append(" and e.cveestado = ? "); sql.append(" and (bpe.xmlregular is not null or bpe.xmlcontingencia is not null) "); @@ -357,7 +355,7 @@ public class BpeHibernateDAO extends HibernateDaoSupport implements BpeDAO { sql.append(" bpe.desconto as v_desconto, "); sql.append(" bpe.chbpe, "); sql.append(" coalesce(bpe.chbpe_substituicao, ' ') as chbpe_sub, "); - sql.append(" to_char(c.feccreacion, 'yyyymmdd') as dh_emisao, "); + sql.append(" to_char(c.fechorventa, 'yyyymmdd') as dh_emisao, "); sql.append(" to_char(c.fechorviaje, 'yyyymmdd') as dhrecbto, "); sql.append(" coalesce(bpe.tiposubstituicao, '0') as tp_bpe, "); sql.append(" bpe.retorno_id as retorno, "); @@ -383,9 +381,7 @@ public class BpeHibernateDAO extends HibernateDaoSupport implements BpeDAO { sql.append(" coalesce(ei.indtxembarqueestadual,0) as indtxembarqueestadual, "); sql.append(" coalesce(ei.indpedagioestdual,0) as indpedagioestdual "); sql.append("from boleto c "); - sql.append(" join bpe bpe on c.boleto_id = bpe.boleto_id "); - sql.append(" and bpe.activo = (case when TO_CHAR(c.feccreacion, 'yyyymmdd') <> "); - sql.append(" to_char(to_date(substr(bpe.dhrecbto,0,10), 'YYYY-MM-DD'), 'yyyymmdd') then 0 else 1 end) "); + sql.append(" join bpe bpe on c.boleto_id = bpe.boleto_id and bpe.activo = 1 "); sql.append(" join estado e on e.codibge = bpe.uf "); sql.append(" join marca ma on c.marca_id = ma.marca_id "); sql.append(" join empresa ep on ma.empresa_id = ep.empresa_id "); @@ -395,8 +391,8 @@ public class BpeHibernateDAO extends HibernateDaoSupport implements BpeDAO { sql.append(" and bpe.tipoamb = 1 and ep.activo = 1 "); sql.append(" and bpe.codstat in ('-1','100','101','102','135','150') "); sql.append(" and (bpe.tipoevento not in ('110115','110116') or bpe.tipoevento is null) "); - sql.append(" and c.feccreacion >= to_date(?,'DD/MM/YYYY HH24:MI:SS') "); - sql.append(" and c.feccreacion <= to_date(?,'DD/MM/YYYY HH24:MI:SS') "); + sql.append(" and c.fechorventa >= to_date(?,'DD/MM/YYYY HH24:MI:SS') "); + sql.append(" and c.fechorventa <= to_date(?,'DD/MM/YYYY HH24:MI:SS') "); sql.append(" and ep.empresa_id = ? "); sql.append(" and e.cveestado = ? "); sql.append(" and (bpe.xmlregular is not null or bpe.xmlcontingencia is not null) "); @@ -820,7 +816,7 @@ public class BpeHibernateDAO extends HibernateDaoSupport implements BpeDAO { sql.append(" to_number(c.num_bpe) as num_bpe, "); sql.append(" to_number(c.numfoliosistema) as numfoliosistema, "); sql.append(" c.numoperacion as numoperacion, "); - sql.append(" trunc(c.feccreacion) as fechorVenta, "); + sql.append(" trunc(c.fechorventa) as fechorVenta, "); sql.append(" e.estado_id as estadoId, "); sql.append(" e.cveestado as estadoOrigem, "); sql.append(" ei.icms as icmsInterestadual, "); @@ -843,7 +839,7 @@ public class BpeHibernateDAO extends HibernateDaoSupport implements BpeDAO { sql.append(" coalesce(c.importepedagio, 0) as pedagio, "); sql.append(" coalesce(c.importeseguro, 0) as seguro, "); sql.append(" coalesce(c.importeoutros, 0) as outros, "); - sql.append(" to_char(trunc(c.feccreacion), 'yyyymmdd') as datamov, "); + sql.append(" to_char(trunc(c.fechorventa), 'yyyymmdd') as datamov, "); sql.append(" bpe.chbpe, "); sql.append(" bpe.codstat as codstatus, "); sql.append(" bpe.tipoevento, "); @@ -884,9 +880,7 @@ public class BpeHibernateDAO extends HibernateDaoSupport implements BpeDAO { sql.append(" bpe.vcomp99, "); sql.append(" bpe.pRedBC "); sql.append("from boleto c "); - sql.append(" join bpe bpe on c.boleto_id = bpe.boleto_id "); - sql.append(" and bpe.activo = (case when TO_CHAR(c.feccreacion, 'yyyymmdd') <> "); - sql.append(" to_char(to_date(substr(bpe.dhrecbto,0,10), 'YYYY-MM-DD'), 'yyyymmdd') then 0 else 1 end) "); + sql.append(" join bpe bpe on c.boleto_id = bpe.boleto_id and bpe.activo = 1 "); sql.append(" join estado e on e.codibge = bpe.uf "); sql.append(" join marca ma on c.marca_id = ma.marca_id "); sql.append(" join empresa ep on ma.empresa_id = ep.empresa_id "); @@ -896,8 +890,8 @@ public class BpeHibernateDAO extends HibernateDaoSupport implements BpeDAO { sql.append(" and bpe.tipoamb = 1 and ep.activo = 1 "); sql.append(" and bpe.codstat in ('-1','100','101','102','135','150') "); sql.append(" and (bpe.tipoevento not in ('110115','110116') or bpe.tipoevento is null) "); - sql.append(" and c.feccreacion >= to_date(:DATE_INICIO,'DD/MM/YYYY HH24:MI:SS') "); - sql.append(" and c.feccreacion <= to_date(:DATE_FIM,'DD/MM/YYYY HH24:MI:SS') "); + sql.append(" and c.fechorventa >= to_date(:DATE_INICIO,'DD/MM/YYYY HH24:MI:SS') "); + sql.append(" and c.fechorventa <= to_date(:DATE_FIM,'DD/MM/YYYY HH24:MI:SS') "); sql.append(" and ep.empresa_id = :EMPRESA_ID "); sql.append(" and e.cveestado in ( ").append(ufs).append(" ) "); sql.append(" and (bpe.xmlregular is not null or bpe.xmlcontingencia is not null) "); @@ -915,7 +909,7 @@ public class BpeHibernateDAO extends HibernateDaoSupport implements BpeDAO { sql.append(" to_number(bori.num_bpe) as num_bpe, "); sql.append(" to_number(bori.numfoliosistema) as numfoliosistema, "); sql.append(" bori.numoperacion as numoperacion, "); - sql.append(" trunc(bori.feccreacion) as fechorVenta, "); + sql.append(" trunc(bori.fechorventa) as fechorVenta, "); sql.append(" est_bpe.estado_id as estadoId, "); sql.append(" est_bpe.cveestado as estadoOrigem, "); sql.append(" ei.icms as icmsInterestadual, "); @@ -938,7 +932,7 @@ public class BpeHibernateDAO extends HibernateDaoSupport implements BpeDAO { sql.append(" coalesce(b.importepedagio, 0) as pedagio, "); sql.append(" coalesce(b.importeseguro, 0) as seguro, "); sql.append(" coalesce(b.importeoutros, 0) as outros, "); - sql.append(" to_char(trunc(bori.feccreacion), 'yyyymmdd') as datamov, "); + sql.append(" to_char(trunc(bori.fechorventa), 'yyyymmdd') as datamov, "); sql.append(" bpeori.chbpe, "); sql.append(" bpe.codstat as codstatus, "); sql.append(" case when bpeori.ufini is not null then bpeori.cmunini else bpe.cmunini end as cmunini, "); @@ -980,9 +974,7 @@ public class BpeHibernateDAO extends HibernateDaoSupport implements BpeDAO { sql.append("from boleto bori "); sql.append(" inner join marca m on m.marca_id = bori.marca_id and m.activo = 1 "); sql.append(" inner join empresa e on e.empresa_id = m.empresa_id "); - sql.append(" inner join bpe bpe on bpe.boleto_id = bori.boleto_id "); - sql.append(" and bpe.activo = (case when TO_CHAR(bori.feccreacion, 'yyyymmdd') <> "); - sql.append(" to_char(to_date(substr(bpe.dhrecbto,0,10), 'YYYY-MM-DD'), 'yyyymmdd') then 0 else 1 end) "); + sql.append(" inner join bpe bpe on bpe.boleto_id = bori.boleto_id and bpe.activo = 1 "); sql.append(" inner join estado est_bpe on bpe.uf = est_bpe.codibge "); sql.append(" left join bpe bpeori on bpeori.chbpe = bpe.chbpe_substituicao and bpeori.activo = 1 "); sql.append(" left join boleto b on b.boleto_id = bpeori.boleto_id "); @@ -995,11 +987,11 @@ public class BpeHibernateDAO extends HibernateDaoSupport implements BpeDAO { sql.append(" left join bpe bpeant on bpeant.boleto_id = bant.boleto_id and bpeant.activo = 1 "); sql.append(" left join punto_venta ptvo on ptvo.puntoventa_id = coalesce(bant.puntoventa_id, bori.puntoventa_id,b.ptovtaventa_id) "); sql.append("where ( (bpe.codstat in ('-1','100','101','102','135','150') and bpe.chbpe_substituicao is not null) "); - sql.append(" or (bpe.codstat in ('101','135') and to_char(b.feccreacion, 'mm/yyyy') < to_char(bori.feccreacion, 'mm/yyyy')) ) "); + sql.append(" or (bpe.codstat in ('101','135') and to_char(b.fechorventa, 'mm/yyyy') < to_char(bori.fechorventa, 'mm/yyyy')) ) "); sql.append(" and (bpe.codstat in ('-1','100','101','102','135','150') and bpe.tipoevento not in ('110115','110116') or bpe.tipoevento is null) "); sql.append(" and (bpeori.codstat in ('-1','100','101','102','135','150') and bpeori.tipoevento not in ('110115','110116') or bpeori.tipoevento is null) "); - sql.append(" and bori.feccreacion >= to_date(:DATE_INICIO,'DD/MM/YYYY HH24:MI:SS') "); - sql.append(" and bori.feccreacion <= to_date(:DATE_FIM,'DD/MM/YYYY HH24:MI:SS') "); + sql.append(" and bori.fechorventa >= to_date(:DATE_INICIO,'DD/MM/YYYY HH24:MI:SS') "); + sql.append(" and bori.fechorventa <= to_date(:DATE_FIM,'DD/MM/YYYY HH24:MI:SS') "); sql.append(" and est_bpe.cveestado in ( ").append(ufs).append(" ) "); sql.append(" and e.empresa_id = :EMPRESA_ID "); sql.append(" and (bpe.xmlregular is not null or bpe.xmlcontingencia is not null) "); @@ -1016,7 +1008,7 @@ public class BpeHibernateDAO extends HibernateDaoSupport implements BpeDAO { sql.append(" to_number(b.num_bpe) as num_bpe, "); sql.append(" to_number(b.numfoliosistema) as numfoliosistema, "); sql.append(" b.numoperacion as numoperacion, "); - sql.append(" trunc(bori.feccreacion) as fechorVenta, "); + sql.append(" trunc(bori.fechorventa) as fechorVenta, "); sql.append(" est_bpe.estado_id as estadoId, "); sql.append(" est_bpe.cveestado as estadoOrigem, "); sql.append(" ei.icms as icmsInterestadual, "); @@ -1039,7 +1031,7 @@ public class BpeHibernateDAO extends HibernateDaoSupport implements BpeDAO { sql.append(" coalesce(b.importepedagio, 0) as pedagio, "); sql.append(" coalesce(b.importeseguro, 0) as seguro, "); sql.append(" coalesce(b.importeoutros, 0) as outros, "); - sql.append(" to_char(trunc(bori.feccreacion), 'yyyymmdd') as datamov, "); + sql.append(" to_char(trunc(bori.fechorventa), 'yyyymmdd') as datamov, "); sql.append(" bpe.chbpe, "); sql.append(" bpe.codstat as codstatus, "); sql.append(" case when bpeori.ufini is not null then bpeori.cmunini else bpe.cmunini end as cmunini, "); @@ -1081,9 +1073,7 @@ public class BpeHibernateDAO extends HibernateDaoSupport implements BpeDAO { sql.append("from boleto bori "); sql.append(" inner join marca m on m.marca_id = bori.marca_id and m.activo = 1 "); sql.append(" inner join empresa e on e.empresa_id = m.empresa_id "); - sql.append(" inner join bpe bpe on bpe.boleto_id = bori.boleto_id "); - sql.append(" and bpe.activo = (case when TO_CHAR(bori.feccreacion, 'yyyymmdd') <> "); - sql.append(" to_char(to_date(substr(bpe.dhrecbto,0,10), 'YYYY-MM-DD'), 'yyyymmdd') then 0 else 1 end) "); + sql.append(" inner join bpe bpe on bpe.boleto_id = bori.boleto_id and bpe.activo = 1 "); sql.append(" inner join estado est_bpe on bpe.uf = est_bpe.codibge "); sql.append(" left join boleto b on b.boleto_id = coalesce(bori.boletoanterior_id, bori.boletooriginal_id) "); sql.append(" left join bpe bpeori on b.boleto_id = bpeori.boleto_id and bpeori.activo = 1 "); @@ -1094,11 +1084,11 @@ public class BpeHibernateDAO extends HibernateDaoSupport implements BpeDAO { sql.append("left join estado esaidf on esaidf.estado_id = aidf.estado_id "); sql.append("left join punto_venta ptvo on ptvo.puntoventa_id = coalesce(b.ptovtaventa_id, bori.puntoventa_id) "); sql.append("where "); - sql.append(" (bpe.codstat in ('101','135') and to_char(b.feccreacion, 'mm/yyyy') < to_char(bori.feccreacion, 'mm/yyyy')) "); + sql.append(" (bpe.codstat in ('101','135') and to_char(b.fechorventa, 'mm/yyyy') < to_char(bori.fechorventa, 'mm/yyyy')) "); sql.append(" and (bpe.codstat in ('-1','100','101','102','135','150') and bpe.tipoevento not in ('110115','110116') or bpe.tipoevento is null) "); sql.append(" and (bpeori.codstat in ('-1','100','101','102','135','150') and bpeori.tipoevento not in ('110115','110116') or bpeori.tipoevento is null) "); - sql.append(" and bori.feccreacion >= to_date(:DATE_INICIO,'DD/MM/YYYY HH24:MI:SS') "); - sql.append(" and bori.feccreacion <= to_date(:DATE_FIM,'DD/MM/YYYY HH24:MI:SS') "); + sql.append(" and bori.fechorventa >= to_date(:DATE_INICIO,'DD/MM/YYYY HH24:MI:SS') "); + sql.append(" and bori.fechorventa <= to_date(:DATE_FIM,'DD/MM/YYYY HH24:MI:SS') "); sql.append(" and est_bpe.cveestado in ( ").append(ufs).append(" ) "); sql.append(" and e.empresa_id = :EMPRESA_ID "); sql.append(" and (bpe.xmlregular is not null or bpe.xmlcontingencia is not null) "); @@ -1310,7 +1300,7 @@ public class BpeHibernateDAO extends HibernateDaoSupport implements BpeDAO { sql.append(" c.boleto_id as cajaId, "); sql.append(" 'REC' as tipoReceita, "); sql.append(" c.numoperacion as numoperacion, "); - sql.append(" trunc(c.feccreacion) as fechorVenta, "); + sql.append(" trunc(c.fechorventa) as fechorVenta, "); sql.append(" e.estado_id as estadoId, "); sql.append(" ei.icms as icmsInterestadual, "); sql.append(" ei.icmsim as icmsIntermunicipal, "); @@ -1336,13 +1326,12 @@ public class BpeHibernateDAO extends HibernateDaoSupport implements BpeDAO { sql.append(" coalesce(c.importepedagio, 0) as pedagio, "); sql.append(" coalesce(c.importeseguro, 0) as seguro, "); sql.append(" coalesce(c.importeoutros, 0) as outros, "); - sql.append(" to_char(trunc(c.feccreacion), 'yyyymmdd') as datamov, "); + sql.append(" to_char(trunc(c.fechorventa), 'yyyymmdd') as datamov, "); sql.append(" DBMS_LOB.substr(coalesce(bpe.xmlregular, bpe.xmlcontingencia), 3000) as xml_bpe, "); sql.append(" DBMS_LOB.substr(coalesce(bpe.xmlregular, bpe.xmlcontingencia), 3000, 3001) as xml_bpe_2, "); sql.append(" DBMS_LOB.substr(coalesce(bpe.xmlregular, bpe.xmlcontingencia), 3000, 6001) as xml_bpe_3 "); sql.append("from boleto c "); - sql.append(" join bpe bpe on c.boleto_id = bpe.boleto_id "); - sql.append(" and bpe.activo = (case when c.motivocancelacion_id = 17 and c.boletooriginal_id is null then 0 else 1 end) "); + sql.append(" join bpe bpe on c.boleto_id = bpe.boleto_id and bpe.activo = 1 "); sql.append(" left join bpe bpecan on bpecan.chbpe = bpe.chbpe and bpecan.codstat in ('101','135') and bpe.codstat = '100' "); sql.append(" and (bpecan.tipoevento = '110111' or bpecan.tipoevento is null) and bpecan.activo = 1 "); sql.append(" join estado e on e.codibge = bpe.uf "); @@ -1361,8 +1350,8 @@ public class BpeHibernateDAO extends HibernateDaoSupport implements BpeDAO { sql.append("where c.activo = 1 and bpe.tipoamb = 1 and bpe.codstat in ('-1','100','102','150') "); sql.append(" and (bpe.fecmodif < (case when (to_char(bpe.fecmodif, 'mm/yyyy') <> to_char(bpecan.fecmodif, 'mm/yyyy') ) "); sql.append(" then bpecan.fecmodif else bpe.fecmodif end) or bpecan.fecmodif is null) "); - sql.append(" and c.feccreacion >= :DATE_INICIO "); - sql.append(" and c.feccreacion <= :DATE_FIM "); + sql.append(" and c.fechorventa >= :DATE_INICIO "); + sql.append(" and c.fechorventa <= :DATE_FIM "); sql.append(" and ep.empresa_id = :EMPRESA_ID "); sql.append(" and (bpe.xmlregular is not null or bpe.xmlcontingencia is not null) "); sql.append(" and e.cveestado in ( ").append(ufs).append(" ) "); @@ -1378,7 +1367,7 @@ public class BpeHibernateDAO extends HibernateDaoSupport implements BpeDAO { sql.append(" b.boleto_id as cajaId, "); sql.append(" 'DEV' as tipoReceita, "); sql.append(" b.numoperacion as numoperacion, "); - sql.append(" trunc(bori.feccreacion) as fechorVenta, "); + sql.append(" trunc(bori.fechorventa) as fechorVenta, "); sql.append(" est_bpe.estado_id as estadoId, "); sql.append(" ei.icms as icmsInterestadual, "); sql.append(" ei.icmsim as icmsIntermunicipal, "); @@ -1404,15 +1393,14 @@ public class BpeHibernateDAO extends HibernateDaoSupport implements BpeDAO { sql.append(" coalesce(b.importepedagio, 0) as pedagio, "); sql.append(" coalesce(b.importeseguro, 0) as seguro, "); sql.append(" coalesce(b.importeoutros, 0) as outros, "); - sql.append(" to_char(trunc(bori.feccreacion), 'yyyymmdd') as datamov, "); + sql.append(" to_char(trunc(bori.fechorventa), 'yyyymmdd') as datamov, "); sql.append(" dbms_lob.substr((case when bpeori.tipoevento is not null then bpeant.xmlregular else bpeori.xmlregular end), 3000) as xml_bpe, "); sql.append(" dbms_lob.substr((case when bpeori.tipoevento is not null then bpeant.xmlregular else bpeori.xmlregular end), 3000, 3001) as xml_bpe_2, "); sql.append(" dbms_lob.substr((case when bpeori.tipoevento is not null then bpeant.xmlregular else bpeori.xmlregular end), 3000, 6001) as xml_bpe_3 "); sql.append("from boleto bori "); sql.append(" inner join marca m on m.marca_id = bori.marca_id and m.activo = 1 "); sql.append(" inner join empresa e on e.empresa_id = m.empresa_id "); - sql.append(" inner join bpe bpe on bpe.boleto_id = bori.boleto_id "); - sql.append(" and bpe.activo = (case when bori.motivocancelacion_id = 17 and bori.boletooriginal_id is null then 0 else 1 end) "); + sql.append(" inner join bpe bpe on bpe.boleto_id = bori.boleto_id and bpe.activo = 1 "); sql.append(" inner join estado est_bpe on bpe.uf = est_bpe.codibge "); sql.append(" left join bpe bpeori on bpeori.chbpe = bpe.chbpe_substituicao "); sql.append(" and bpeori.activo = (case when bori.motivocancelacion_id = 17 and bori.boletooriginal_id is null then 0 else 1 end) "); @@ -1442,11 +1430,11 @@ public class BpeHibernateDAO extends HibernateDaoSupport implements BpeDAO { sql.append(" left join bpe bpeant on bpeant.boleto_id = bant.boleto_id "); sql.append(" left join punto_venta ptvo on ptvo.puntoventa_id = coalesce(bant.puntoventa_id, bori.puntoventa_id,b.ptovtaventa_id) "); sql.append("where ( (bpe.codstat in ('-1','100','101','102','135','150') and bpe.chbpe_substituicao is not null) "); - sql.append(" or (bpe.codstat in ('101','135') and to_char(b.feccreacion, 'mm/yyyy') < to_char(bori.feccreacion, 'mm/yyyy')) ) "); + sql.append(" or (bpe.codstat in ('101','135') and to_char(b.fechorventa, 'mm/yyyy') < to_char(bori.fechorventa, 'mm/yyyy')) ) "); sql.append(" and (bpe.codstat in ('-1','100','101','102','135','150') and bpe.tipoevento <> '110115' or bpe.tipoevento is null) "); sql.append(" and (bpeori.codstat in ('-1','100','101','102','135','150') and bpeori.tipoevento <> '110115' or bpeori.tipoevento is null) "); - sql.append(" and bori.feccreacion >= :DATE_INICIO "); - sql.append(" and bori.feccreacion <= :DATE_FIM "); + sql.append(" and bori.fechorventa >= :DATE_INICIO "); + sql.append(" and bori.fechorventa <= :DATE_FIM "); sql.append(" and est_bpe.cveestado in ( ").append(ufs).append(" ) "); sql.append(" and e.empresa_id = :EMPRESA_ID "); sql.append(" "); @@ -1456,7 +1444,7 @@ public class BpeHibernateDAO extends HibernateDaoSupport implements BpeDAO { sql.append(" b.boleto_id as cajaId, "); sql.append(" 'DEV' as tipoReceita, "); sql.append(" b.numoperacion as numoperacion, "); - sql.append(" trunc(bori.feccreacion) as fechorVenta, "); + sql.append(" trunc(bori.fechorventa) as fechorVenta, "); sql.append(" est_bpe.estado_id as estadoId, "); sql.append(" ei.icms as icmsInterestadual, "); sql.append(" ei.icmsim as icmsIntermunicipal, "); @@ -1482,15 +1470,14 @@ public class BpeHibernateDAO extends HibernateDaoSupport implements BpeDAO { sql.append(" coalesce(b.importepedagio, 0) as pedagio, "); sql.append(" coalesce(b.importeseguro, 0) as seguro, "); sql.append(" coalesce(b.importeoutros, 0) as outros, "); - sql.append(" to_char(trunc(bori.feccreacion), 'yyyymmdd') as datamov, "); + sql.append(" to_char(trunc(bori.fechorventa), 'yyyymmdd') as datamov, "); sql.append(" dbms_lob.substr((case when bpeori.tipoevento is not null then bpeant.xmlregular else bpeori.xmlregular end), 3000) as xml_bpe, "); sql.append(" dbms_lob.substr((case when bpeori.tipoevento is not null then bpeant.xmlregular else bpeori.xmlregular end), 3000, 3001) as xml_bpe_2, "); sql.append(" dbms_lob.substr((case when bpeori.tipoevento is not null then bpeant.xmlregular else bpeori.xmlregular end), 3000, 6001) as xml_bpe_3 "); sql.append("from boleto bori "); sql.append(" inner join marca m on m.marca_id = bori.marca_id and m.activo = 1 "); sql.append(" inner join empresa e on e.empresa_id = m.empresa_id "); - sql.append(" inner join bpe bpe on bpe.boleto_id = bori.boleto_id "); - sql.append(" and bpe.activo = (case when bori.motivocancelacion_id = 17 and bori.boletooriginal_id is null then 0 else 1 end) "); + sql.append(" inner join bpe bpe on bpe.boleto_id = bori.boleto_id and bpe.activo = 1 "); sql.append(" inner join estado est_bpe on bpe.uf = est_bpe.codibge "); sql.append(" left join boleto b on b.boleto_id = (case when bori.motivocancelacion_id = 99 then bori.boletoanterior_id else bori.boletooriginal_id end) "); sql.append(" left join bpe bpeori on b.boleto_id = bpeori.boleto_id "); @@ -1521,11 +1508,11 @@ public class BpeHibernateDAO extends HibernateDaoSupport implements BpeDAO { sql.append(" and bpeant.activo = (case when bori.motivocancelacion_id = 17 and bori.boletooriginal_id is null then 0 else 1 end) "); sql.append("left join punto_venta ptvo on ptvo.puntoventa_id = coalesce(bant.puntoventa_id, bori.puntoventa_id,b.ptovtaventa_id) "); sql.append("where "); - sql.append(" (bpe.codstat in ('101','135') and to_char(b.feccreacion, 'mm/yyyy') < to_char(bori.feccreacion, 'mm/yyyy')) "); + sql.append(" (bpe.codstat in ('101','135') and to_char(b.fechorventa, 'mm/yyyy') < to_char(bori.fechorventa, 'mm/yyyy')) "); sql.append(" and (bpe.codstat in ('-1','100','101','102','135','150') and bpe.tipoevento <> '110115' or bpe.tipoevento is null) "); sql.append(" and (bpeori.codstat in ('-1','100','101','102','135','150') and bpeori.tipoevento <> '110115' or bpeori.tipoevento is null) "); - sql.append(" and bori.feccreacion >= :DATE_INICIO "); - sql.append(" and bori.feccreacion <= :DATE_FIM "); + sql.append(" and bori.fechorventa >= :DATE_INICIO "); + sql.append(" and bori.fechorventa <= :DATE_FIM "); sql.append(" and est_bpe.cveestado in ( ").append(ufs).append(" ) "); sql.append(" and e.empresa_id = :EMPRESA_ID ");