Merge pull request 'correção de sumiço de dados no relatorio de descontos fix bug#AL-2684' (!214) from AL-2684 into master

Reviewed-on: adm/VentaBoletosAdm#214
Reviewed-by: Julio Heredia <julio@rjconsultores.com.br>
master
Julio Heredia 2023-07-07 00:07:47 +00:00
commit 776926574f
3 changed files with 136 additions and 136 deletions

View File

@ -4,11 +4,11 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>br.com.rjconsultores</groupId> <groupId>br.com.rjconsultores</groupId>
<artifactId>ventaboletosadm</artifactId> <artifactId>ventaboletosadm</artifactId>
<version>1.8.11</version> <version>1.8.12</version>
<packaging>war</packaging> <packaging>war</packaging>
<properties> <properties>
<modelWeb.version>1.6.8</modelWeb.version> <modelWeb.version>1.6.9</modelWeb.version>
<flyway.version>1.5.2</flyway.version> <flyway.version>1.5.2</flyway.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

View File

@ -38,7 +38,6 @@ public class RelatorioDescontos extends Relatorio {
Integer tipoPuntoVenta = (Integer) parametros.get("tipoPuntoVenta"); Integer tipoPuntoVenta = (Integer) parametros.get("tipoPuntoVenta");
String query = getQuery(idPuntoVenta, codconvenio, tipoPuntoVenta); String query = getQuery(idPuntoVenta, codconvenio, tipoPuntoVenta);
System.out.println(query);
NamedParameterStatement statement = new NamedParameterStatement(coneConnection, query); NamedParameterStatement statement = new NamedParameterStatement(coneConnection, query);
statement.setTimestamp("fecVentaInicial", fecVentaInicial); statement.setTimestamp("fecVentaInicial", fecVentaInicial);
@ -91,77 +90,77 @@ public class RelatorioDescontos extends Relatorio {
} }
private String getQuery(Integer idPuntoVenta, String codconvenio, Integer tipoPuntoVenta) { private String getQuery(Integer idPuntoVenta, String codconvenio, Integer tipoPuntoVenta) {
StringBuilder query = new StringBuilder();
String query = " SELECT " query.append(" SELECT ");
+ " (CONV.CVECONVENIO || ' - ' || CONV.DESCCONVENIO) AS codConvenio, " query.append(" (CONV.CVECONVENIO || ' - ' || CONV.DESCCONVENIO) AS codConvenio, ");
+ " PUNT_V.NOMBPUNTOVENTA AS nomeAgencia, " query.append(" PUNT_V.NOMBPUNTOVENTA AS nomeAgencia, ");
+ " BOL.FECHORVENTA AS dataEmissao, " query.append(" BOL.FECHORVENTA AS dataEmissao, ");
+ " BOL.FECHORVIAJE AS dataViagem, " query.append(" BOL.FECHORVIAJE AS dataViagem, ");
+ " BOL.CORRIDA_ID AS codServico, " query.append(" BOL.CORRIDA_ID AS codServico, ");
+ " ORIG.CVEPARADA AS codOrigem, " query.append(" ORIG.CVEPARADA AS codOrigem, ");
+ " DEST.CVEPARADA AS codDestino, " query.append(" DEST.CVEPARADA AS codDestino, ");
+ " (case " query.append(" (case ");
+ " when ( bol.indcancelacion = 1 ) " query.append(" when ( bol.indcancelacion = 1 ) ");
+ " then (-1 *(Abs( BOL.PRECIOPAGADO ) )) " query.append(" then (-1 *(Abs( BOL.PRECIOPAGADO ) )) ");
+ " else " query.append(" else ");
+ " BOL.PRECIOPAGADO " query.append(" BOL.PRECIOPAGADO ");
+ " END) AS tarifaComDesconto, " query.append(" END) AS tarifaComDesconto, ");
query.append(" (case ");
query.append(" when ( bol.indcancelacion = 1 ) ");
query.append(" then (-1 *(Abs( BOL.IMPORTETAXAEMBARQUE ) )) ");
query.append(" else ");
query.append(" BOL.IMPORTETAXAEMBARQUE ");
query.append(" END) AS tut, ");
+ " (case " query.append(" (case ");
+ " when ( bol.indcancelacion = 1 ) " query.append(" when ( bol.indcancelacion = 1 ) ");
+ " then (-1 *(Abs( BOL.IMPORTETAXAEMBARQUE ) )) " query.append(" then (-1 *(Abs( BOL.IMPORTEPEDAGIO ) )) ");
+ " else " query.append(" else ");
+ " BOL.IMPORTETAXAEMBARQUE " query.append(" BOL.IMPORTEPEDAGIO ");
+ " END) AS tut, " query.append(" END) AS pedagio, ");
+ " (case " query.append(" BOL.NOMBPASAJERO AS nomepassageiro, ");
+ " when ( bol.indcancelacion = 1 ) " query.append(" BOL.DESCNUMDOC AS documento,");
+ " then (-1 *(Abs( BOL.IMPORTEPEDAGIO ) )) " query.append(" U.CVEUSUARIO AS bilheteiro, ");
+ " else " query.append(" BOL.EMPRESACORRIDA_ID AS empresacorrida, ");
+ " BOL.IMPORTEPEDAGIO " query.append(" EMP.NOMBEMPRESA AS empresa ");
+ " END) AS pedagio, " query.append(" FROM BOLETO BOL ");
query.append(" JOIN CONVENIO_DET CONV_D ON CONV_D.CONVENIODET_ID = BOL.CONVENIODET_ID ");
query.append(" JOIN CONVENIO CONV ON CONV.CONVENIO_ID = CONV_D.CONVENIO_ID ");
query.append(" JOIN PUNTO_VENTA PUNT_V ON PUNT_V.PUNTOVENTA_ID = BOL.PUNTOVENTA_ID ");
query.append(" JOIN TIPO_PTOVTA TPVTA ON PUNT_V.TIPOPTOVTA_ID = TPVTA.TIPOPTOVTA_ID ");
+ " BOL.NOMBPASAJERO AS nomepassageiro, " query.append(" JOIN PARADA ORIG ON ORIG.PARADA_ID = BOL.ORIGEN_ID ");
+ " BOL.DESCNUMDOC AS documento," query.append(" JOIN PARADA DEST ON DEST.PARADA_ID = BOL.DESTINO_ID ");
+ " U.CVEUSUARIO AS bilheteiro, " query.append(" INNER JOIN USUARIO U ON U.USUARIO_ID = BOL.USUARIO_ID " );
+ " BOL.EMPRESACORRIDA_ID AS empresacorrida, " query.append(" JOIN EMPRESA EMP ON EMP.EMPRESA_ID = BOL.EMPRESACORRIDA_ID ");
+ " EMP.NOMBEMPRESA AS empresa " query.append(" WHERE ");
+ " FROM BOLETO BOL " query.append(" BOL.INDSTATUSOPERACION = 'F' ");
+ " JOIN CONVENIO_DET CONV_D ON CONV_D.CONVENIODET_ID = BOL.CONVENIODET_ID " query.append(" AND BOL.ACTIVO = 1 ");
+ " JOIN CONVENIO CONV ON CONV.CONVENIO_ID = CONV_D.CONVENIO_ID " query.append(" AND BOL.FECHORVENTA BETWEEN :fecVentaInicial AND :fecVentaFinal ");
+ " JOIN PUNTO_VENTA PUNT_V ON PUNT_V.PUNTOVENTA_ID = BOL.PUNTOVENTA_ID "
+ " JOIN TIPO_PTOVTA TPVTA ON PUNT_V.TIPOPTOVTA_ID = TPVTA.TIPOPTOVTA_ID "
+ " JOIN PARADA ORIG ON ORIG.PARADA_ID = BOL.ORIGEN_ID "
+ " JOIN PARADA DEST ON DEST.PARADA_ID = BOL.DESTINO_ID "
+ " INNER JOIN USUARIO U ON U.USUARIO_ID = BOL.USUARIO_ID "
+ " JOIN EMPRESA EMP ON EMP.EMPRESA_ID = BOL.EMPRESACORRIDA_ID "
+ " WHERE "
+ " BOL.INDSTATUSOPERACION = 'F' "
+ " AND BOL.ACTIVO = 1 "
+ " AND BOL.FECHORVENTA BETWEEN :fecVentaInicial AND :fecVentaFinal ";
if(!((String)parametros.get("EMPRESAIDS")).equals("")){ if(!((String)parametros.get("EMPRESAIDS")).equals("")){
query +=" AND BOL.EMPRESACORRIDA_ID IN ( " + (String)parametros.get("EMPRESAIDS") + ")" ; query.append(" AND BOL.EMPRESACORRIDA_ID IN ( " + (String)parametros.get("EMPRESAIDS") + ")");
} }
if(idPuntoVenta != null && idPuntoVenta != -1) { if(idPuntoVenta != null && idPuntoVenta != -1) {
query += " AND (BOL.PUNTOVENTA_ID = :idPuntoVenta) "; query.append(" AND (BOL.PUNTOVENTA_ID = :idPuntoVenta) ");
} }
if (codconvenio != null && !codconvenio.isEmpty()) { if (codconvenio != null && !codconvenio.isEmpty()) {
query += " AND (CONV.CVECONVENIO = :codconvenio)"; query.append(" AND (CONV.CVECONVENIO = :codconvenio)");
} }
if (tipoPuntoVenta != null && tipoPuntoVenta != -1) { if (tipoPuntoVenta != null && tipoPuntoVenta != -1) {
query += " AND (PUNT_V.TIPOPTOVTA_ID = :tipoPuntoVenta)"; query.append(" AND (PUNT_V.TIPOPTOVTA_ID = :tipoPuntoVenta)");
} }
query += " ORDER BY BOL.EMPRESACORRIDA_ID, (CONV.CVECONVENIO || ' - ' || CONV.DESCCONVENIO)"; query.append(" ORDER BY BOL.EMPRESACORRIDA_ID, (CONV.CVECONVENIO || ' - ' || CONV.DESCCONVENIO)");
return query; return query.toString();
} }
@Override @Override

View File

@ -38,7 +38,6 @@ public class RelatorioDescontosTipo2 extends Relatorio {
Integer tipoPuntoVenta = (Integer) parametros.get("tipoPuntoVenta"); Integer tipoPuntoVenta = (Integer) parametros.get("tipoPuntoVenta");
String query = getQuery(idPuntoVenta, codconvenio, tipoPuntoVenta); String query = getQuery(idPuntoVenta, codconvenio, tipoPuntoVenta);
System.out.println(query);
NamedParameterStatement statement = new NamedParameterStatement(coneConnection, query); NamedParameterStatement statement = new NamedParameterStatement(coneConnection, query);
statement.setTimestamp("fecVentaInicial", fecVentaInicial); statement.setTimestamp("fecVentaInicial", fecVentaInicial);
@ -94,82 +93,84 @@ public class RelatorioDescontosTipo2 extends Relatorio {
} }
private String getQuery(Integer idPuntoVenta, String codconvenio, Integer tipoPuntoVenta) { private String getQuery(Integer idPuntoVenta, String codconvenio, Integer tipoPuntoVenta) {
StringBuilder query = new StringBuilder();
String query = " SELECT " query.append(" SELECT ");
+ " (CONV.CVECONVENIO || ' - ' || CONV.DESCCONVENIO) AS codConvenio, " query.append(" (CONV.CVECONVENIO || ' - ' || CONV.DESCCONVENIO) AS codConvenio, " );
+ " PUNT_V.NOMBPUNTOVENTA AS nomeAgencia, " query.append(" PUNT_V.NOMBPUNTOVENTA AS nomeAgencia, ");
+ " BOL.FECHORVENTA AS dataEmissao, " query.append(" BOL.FECHORVENTA AS dataEmissao, ");
+ " BOL.FECHORVIAJE AS dataViagem, " query.append(" BOL.FECHORVIAJE AS dataViagem, ");
+ " BOL.CORRIDA_ID AS codServico, " query.append(" BOL.CORRIDA_ID AS codServico, ");
+ " ORIG.CVEPARADA AS codOrigem, " query.append(" ORIG.CVEPARADA AS codOrigem, ");
+ " DEST.CVEPARADA AS codDestino, " query.append(" DEST.CVEPARADA AS codDestino, ");
+ " (case " query.append(" (case ");
+ " when ( bol.indcancelacion = 1 ) " query.append(" when ( bol.indcancelacion = 1 ) ");
+ " then (-1 *(Abs( BOL.PRECIOPAGADO ) )) " query.append(" then (-1 *(Abs( BOL.PRECIOPAGADO ) )) ");
+ " else " query.append(" else ");
+ " BOL.PRECIOPAGADO " query.append(" BOL.PRECIOPAGADO ");
+ " END) AS tarifaComDesconto, " query.append(" END) AS tarifaComDesconto, ");
+ " (case " query.append(" (case ");
+ " when ( bol.indcancelacion = 1 ) " query.append(" when ( bol.indcancelacion = 1 ) ");
+ " then (-1 *(Abs( BOL.IMPORTETAXAEMBARQUE ) )) " query.append(" then (-1 *(Abs( BOL.IMPORTETAXAEMBARQUE ) )) ");
+ " else " query.append(" else ");
+ " BOL.IMPORTETAXAEMBARQUE " query.append(" BOL.IMPORTETAXAEMBARQUE ");
+ " END) AS tut, " query.append(" END) AS tut, ");
+ " (case " query.append(" (case ");
+ " when ( bol.indcancelacion = 1 ) " query.append(" when ( bol.indcancelacion = 1 ) ");
+ " then (-1 *(Abs( BOL.IMPORTEPEDAGIO ) )) " query.append(" then (-1 *(Abs( BOL.IMPORTEPEDAGIO ) )) ");
+ " else " query.append(" else ");
+ " BOL.IMPORTEPEDAGIO " query.append(" BOL.IMPORTEPEDAGIO " );
+ " END) AS pedagio, " query.append(" END) AS pedagio, ");
+ " BOL.NOMBPASAJERO AS nomepassageiro, " query.append(" BOL.NOMBPASAJERO AS nomepassageiro, " );
+ " BOL.DESCNUMDOC AS documento," query.append(" BOL.DESCNUMDOC AS documento," );
+ " U.CVEUSUARIO AS bilheteiro, " query.append(" U.CVEUSUARIO AS bilheteiro, " );
+ " BOL.EMPRESACORRIDA_ID AS empresacorrida, " query.append(" BOL.EMPRESACORRIDA_ID AS empresacorrida, " );
+ " EMP.NOMBEMPRESA AS empresa, " query.append(" EMP.NOMBEMPRESA AS empresa, ");
+ " TPVTA.desctipo AS CANAL_DE_VENDA, " query.append(" TPVTA.desctipo AS CANAL_DE_VENDA, ");
+ " BOL.DESCCORREO AS email, " query.append(" BOL.DESCCORREO AS email, ");
+ " BOL.DESCTELEFONO AS telefone " query.append(" BOL.DESCTELEFONO AS telefone ");
+ " FROM BOLETO BOL " query.append(" FROM BOLETO BOL ");
+ " JOIN CONVENIO_DET CONV_D ON CONV_D.CONVENIODET_ID = BOL.CONVENIODET_ID " query.append(" JOIN CONVENIO_DET CONV_D ON CONV_D.CONVENIODET_ID = BOL.CONVENIODET_ID ");
+ " JOIN CONVENIO CONV ON CONV.CONVENIO_ID = CONV_D.CONVENIO_ID " query.append(" JOIN CONVENIO CONV ON CONV.CONVENIO_ID = CONV_D.CONVENIO_ID ");
+ " JOIN PUNTO_VENTA PUNT_V ON PUNT_V.PUNTOVENTA_ID = BOL.PUNTOVENTA_ID " query.append(" JOIN PUNTO_VENTA PUNT_V ON PUNT_V.PUNTOVENTA_ID = BOL.PUNTOVENTA_ID ");
+ " JOIN TIPO_PTOVTA TPVTA ON PUNT_V.TIPOPTOVTA_ID = TPVTA.TIPOPTOVTA_ID " query.append(" JOIN TIPO_PTOVTA TPVTA ON PUNT_V.TIPOPTOVTA_ID = TPVTA.TIPOPTOVTA_ID ");
+ " JOIN PARADA ORIG ON ORIG.PARADA_ID = BOL.ORIGEN_ID " query.append(" JOIN PARADA ORIG ON ORIG.PARADA_ID = BOL.ORIGEN_ID ");
+ " JOIN PARADA DEST ON DEST.PARADA_ID = BOL.DESTINO_ID " query.append(" JOIN PARADA DEST ON DEST.PARADA_ID = BOL.DESTINO_ID ");
+ " INNER JOIN USUARIO U ON U.USUARIO_ID = BOL.USUARIO_ID " query.append(" INNER JOIN USUARIO U ON U.USUARIO_ID = BOL.USUARIO_ID " );
+ " JOIN EMPRESA EMP ON EMP.EMPRESA_ID = BOL.EMPRESACORRIDA_ID " query.append(" JOIN EMPRESA EMP ON EMP.EMPRESA_ID = BOL.EMPRESACORRIDA_ID ");
+ " WHERE " query.append(" WHERE ");
+ " BOL.INDSTATUSOPERACION = 'F' " query.append( " BOL.INDSTATUSOPERACION = 'F' ");
+ " AND BOL.ACTIVO = 1 " query.append( " AND BOL.ACTIVO = 1 ");
+ " AND BOL.FECHORVENTA BETWEEN :fecVentaInicial AND :fecVentaFinal "; query.append( " AND BOL.FECHORVENTA BETWEEN :fecVentaInicial AND :fecVentaFinal ");
if(!((String)parametros.get("EMPRESAIDS")).equals("")){ if(!((String)parametros.get("EMPRESAIDS")).equals("")){
query +=" AND BOL.EMPRESACORRIDA_ID IN ( " + (String)parametros.get("EMPRESAIDS") + ")" ; query.append(" AND BOL.EMPRESACORRIDA_ID IN ( " + (String)parametros.get("EMPRESAIDS") + ")" );
} }
if(idPuntoVenta != null && idPuntoVenta != -1) { if(idPuntoVenta != null && idPuntoVenta != -1) {
query += " AND (BOL.PUNTOVENTA_ID = :idPuntoVenta) "; query.append(" AND (BOL.PUNTOVENTA_ID = :idPuntoVenta) ");
} }
if (codconvenio != null && !codconvenio.isEmpty()) { if (codconvenio != null && !codconvenio.isEmpty()) {
query += " AND (CONV.CVECONVENIO = :codconvenio)"; query.append( " AND (CONV.CVECONVENIO = :codconvenio)");
} }
if (tipoPuntoVenta != null && tipoPuntoVenta != -1) { if (tipoPuntoVenta != null && tipoPuntoVenta != -1) {
query += " AND (PUNT_V.TIPOPTOVTA_ID = :tipoPuntoVenta)"; query.append( " AND (PUNT_V.TIPOPTOVTA_ID = :tipoPuntoVenta)");
} }
query += " ORDER BY BOL.EMPRESACORRIDA_ID, (CONV.CVECONVENIO || ' - ' || CONV.DESCCONVENIO)"; query.append( " ORDER BY BOL.EMPRESACORRIDA_ID, (CONV.CVECONVENIO || ' - ' || CONV.DESCCONVENIO)");
return query; return query.toString();
} }
@Override @Override