diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioHistoricoClientes.java b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioHistoricoClientes.java index e7588389e..be793b49d 100644 --- a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioHistoricoClientes.java +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioHistoricoClientes.java @@ -113,7 +113,8 @@ public class RelatorioHistoricoClientes extends Relatorio { sql.append("INNER JOIN CLIENTE cliente ON caja.CLIENTE_ID = cliente.CLIENTE_ID "); sql.append("WHERE caja.MOTIVOCANCELACION_ID IS NULL "); - sql.append("AND caja.INDREIMPRESION = 0 "); + sql.append("AND (caja.INDSTATUSBOLETO in( 'V','T') and INDREIMPRESION = 0 and not exists(select * from caja c1 where c1.indstatusboleto = 'E' and caja.transacao_id = C1.TRANSACAOORIGINAL_ID ) or caja.INDSTATUSBOLETO = 'E' ) "); + if (empresaId != null) { sql.append("AND caja.EMPRESACORRIDA_ID = " + empresaId + " "); }