diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioCancelamentoVendaCartao.java b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioCancelamentoVendaCartao.java index 0f756e7f0..672b204ca 100644 --- a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioCancelamentoVendaCartao.java +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioCancelamentoVendaCartao.java @@ -68,9 +68,9 @@ public class RelatorioCancelamentoVendaCartao extends Relatorio { StringBuilder sql = new StringBuilder(); /* Boletos apenas com venda e cancelamento direto com corrida */ - sql.append("SELECT DISTINCT B.BOLETO_ID, P.NOMBPUNTOVENTA, O.NUMTARJETA, B.FECHORVENTA, PTOVTA.NUMSITEF, ") - .append("'OCD' AS DESCMOTIVO, O.NUMAUTORIZACION, O.NSU, B.NUMFOLIOSISTEMA, O.FECINC AS DATADEVOLUCAO, O.NUMOPERACION, ") - .append("(COALESCE(B.PRECIOPAGADO,0) + COALESCE(B.IMPORTEOUTROS,0)+ COALESCE(B.IMPORTEPEDAGIO,0)+ COALESCE(B.IMPORTESEGURO,0) + COALESCE(B.IMPORTETAXAEMBARQUE,0)) AS VALOR_VENDA, ") + sql.append("SELECT DISTINCT C.CAJA_ID, B.BOLETO_ID, P.NOMBPUNTOVENTA, CTJ.NUMTARJETA, C.FECHORVENTA, PTOVTA.NUMSITEF, ") + .append("'OCD' AS DESCMOTIVO, CTJ.NUMAUTORIZACION, CTJ.NSU, B.NUMFOLIOSISTEMA, O.FECINC AS DATADEVOLUCAO, C.NUMOPERACION, ") + .append("(COALESCE(C.PRECIOPAGADO,0) + COALESCE(C.IMPORTEOUTROS,0)+ COALESCE(C.IMPORTEPEDAGIO,0)+ COALESCE(C.IMPORTESEGURO,0) + COALESCE(C.IMPORTETAXAEMBARQUE,0)) AS VALOR_VENDA, ") .append("CASE WHEN O.VALOR_TARJETA > 0 ") .append("THEN TO_CHAR(COALESCE(O.VALOR_TARJETA,0),'FM9999999.90') ") @@ -87,8 +87,16 @@ public class RelatorioCancelamentoVendaCartao extends Relatorio { .append(" AND B.BOLETOORIGINAL_ID IS NULL ") .append(" AND B.CORRIDA_ID IS NOT NULL ") .append(" AND B.FECCORRIDA IS NOT NULL ") - .append("INNER JOIN BOLETO_FORMAPAGO BFP ON BFP.BOLETO_ID = B.BOLETO_ID ") - .append("AND BFP.FORMAPAGO_ID = :formaPago1 ") + .append("INNER JOIN CAJA C ON C.NUMOPERACION = B.NUMOPERACION ") + .append(" AND B.NUMASIENTO = C.NUMASIENTO ") + .append(" AND B.ORIGEN_ID = C.ORIGEN_ID ") + .append(" AND B.DESTINO_ID = C.DESTINO_ID ") + .append(" AND B.CATEGORIA_ID = C.CATEGORIA_ID ") + .append(" AND B.CLASESERVICIO_ID = C.CLASESERVICIO_ID ") + .append(" AND B.CORRIDA_ID = C.CORRIDA_ID ") + .append(" AND B.FECCORRIDA = C.FECCORRIDA ") + .append("INNER JOIN CAJA_DET_PAGO CDT ON CDT.CAJA_ID = C.CAJA_ID AND CDT.FORMAPAGO_ID = :formaPago1 ") + .append("INNER JOIN CAJA_TARJETA CTJ ON CDT.CAJADETPAGO_ID = CTJ.CAJADETPAGO_ID ") .append("INNER JOIN PUNTO_VENTA P ON P.PUNTOVENTA_ID = B.PUNTOVENTA_ID ") .append("INNER JOIN PTOVTA_EMPRESA PTOVTA ON B.PUNTOVENTA_ID = PTOVTA.PUNTOVENTA_ID ") .append("INNER JOIN MARCA M ON M.MARCA_ID = B.MARCA_ID AND M.EMPRESA_ID = PTOVTA.EMPRESA_ID ") @@ -104,9 +112,9 @@ public class RelatorioCancelamentoVendaCartao extends Relatorio { sql.append("UNION ALL "); /* Boletos com entrega/transferencia/troca antes do cancelamento com corrida */ - sql.append("SELECT DISTINCT B.BOLETO_ID, P.NOMBPUNTOVENTA, O.NUMTARJETA, B.FECHORVENTA, PTOVTA.NUMSITEF, ") - .append("'OCD' AS DESCMOTIVO, O.NUMAUTORIZACION, O.NSU, B.NUMFOLIOSISTEMA, O.FECINC AS DATADEVOLUCAO, O.NUMOPERACION, ") - .append("(COALESCE(B.PRECIOPAGADO,0) + COALESCE(B.IMPORTEOUTROS,0)+ COALESCE(B.IMPORTEPEDAGIO,0)+ COALESCE(B.IMPORTESEGURO,0) + COALESCE(B.IMPORTETAXAEMBARQUE,0)) AS VALOR_VENDA, ") + sql.append("SELECT DISTINCT C.CAJA_ID, B.BOLETO_ID, P.NOMBPUNTOVENTA, CTJ.NUMTARJETA, C.FECHORVENTA, PTOVTA.NUMSITEF, ") + .append("'OCD' AS DESCMOTIVO, CTJ.NUMAUTORIZACION, CTJ.NSU, B.NUMFOLIOSISTEMA, O.FECINC AS DATADEVOLUCAO, C.NUMOPERACION, ") + .append("(COALESCE(C.PRECIOPAGADO,0) + COALESCE(C.IMPORTEOUTROS,0)+ COALESCE(C.IMPORTEPEDAGIO,0)+ COALESCE(C.IMPORTESEGURO,0) + COALESCE(C.IMPORTETAXAEMBARQUE,0)) AS VALOR_VENDA, ") .append("CASE WHEN O.VALOR_TARJETA > 0 ") .append("THEN TO_CHAR(COALESCE(O.VALOR_TARJETA,0),'FM9999999.90') ") @@ -123,8 +131,16 @@ public class RelatorioCancelamentoVendaCartao extends Relatorio { .append("INNER JOIN BOLETO BR ON BR.BOLETO_ID = B.BOLETOORIGINAL_ID ") .append(" AND BR.CORRIDA_ID IS NOT NULL ") .append(" AND BR.FECCORRIDA IS NOT NULL ") - .append("INNER JOIN BOLETO_FORMAPAGO BFP ON BFP.BOLETO_ID = B.BOLETO_ID ") - .append("AND BFP.FORMAPAGO_ID = :formaPago1 ") + .append("INNER JOIN CAJA C ON BR.NUMOPERACION = C.NUMOPERACION ") + .append(" AND BR.NUMASIENTO = C.NUMASIENTO ") + .append(" AND BR.ORIGEN_ID = C.ORIGEN_ID ") + .append(" AND BR.DESTINO_ID = C.DESTINO_ID ") + .append(" AND BR.CATEGORIA_ID = C.CATEGORIA_ID ") + .append(" AND BR.CLASESERVICIO_ID = C.CLASESERVICIO_ID ") + .append(" AND BR.CORRIDA_ID = C.CORRIDA_ID ") + .append(" AND BR.FECCORRIDA = C.FECCORRIDA ") + .append("INNER JOIN CAJA_DET_PAGO CDT ON CDT.CAJA_ID = C.CAJA_ID AND CDT.FORMAPAGO_ID = :formaPago1 ") + .append("INNER JOIN CAJA_TARJETA CTJ ON CDT.CAJADETPAGO_ID = CTJ.CAJADETPAGO_ID ") .append("INNER JOIN PUNTO_VENTA P ON P.PUNTOVENTA_ID = BR.PUNTOVENTA_ID ") .append("INNER JOIN PTOVTA_EMPRESA PTOVTA ON BR.PUNTOVENTA_ID = PTOVTA.PUNTOVENTA_ID ") .append("INNER JOIN MARCA M ON M.MARCA_ID = BR.MARCA_ID AND M.EMPRESA_ID = PTOVTA.EMPRESA_ID ") @@ -140,9 +156,9 @@ public class RelatorioCancelamentoVendaCartao extends Relatorio { sql.append("UNION ALL "); /* Boletos apenas com venda e cancelamento direto sem corrida */ - sql.append("SELECT DISTINCT B.BOLETO_ID, P.NOMBPUNTOVENTA, O.NUMTARJETA, B.FECHORVENTA, PTOVTA.NUMSITEF, ") - .append("'OCD' AS DESCMOTIVO, O.NUMAUTORIZACION, O.NSU, B.NUMFOLIOSISTEMA, O.FECINC AS DATADEVOLUCAO, O.NUMOPERACION, ") - .append("(COALESCE(B.PRECIOPAGADO,0) + COALESCE(B.IMPORTEOUTROS,0)+ COALESCE(B.IMPORTEPEDAGIO,0)+ COALESCE(B.IMPORTESEGURO,0) + COALESCE(B.IMPORTETAXAEMBARQUE,0)) AS VALOR_VENDA, ") + sql.append("SELECT DISTINCT C.CAJA_ID, B.BOLETO_ID, P.NOMBPUNTOVENTA, CTJ.NUMTARJETA, C.FECHORVENTA, PTOVTA.NUMSITEF, ") + .append("'OCD' AS DESCMOTIVO, CTJ.NUMAUTORIZACION, CTJ.NSU, B.NUMFOLIOSISTEMA, O.FECINC AS DATADEVOLUCAO, C.NUMOPERACION, ") + .append("(COALESCE(C.PRECIOPAGADO,0) + COALESCE(C.IMPORTEOUTROS,0)+ COALESCE(C.IMPORTEPEDAGIO,0)+ COALESCE(C.IMPORTESEGURO,0) + COALESCE(C.IMPORTETAXAEMBARQUE,0)) AS VALOR_VENDA, ") .append("CASE WHEN O.VALOR_TARJETA > 0 ") .append("THEN TO_CHAR(COALESCE(O.VALOR_TARJETA,0),'FM9999999.90') ") @@ -159,8 +175,14 @@ public class RelatorioCancelamentoVendaCartao extends Relatorio { .append(" AND B.BOLETOORIGINAL_ID IS NULL ") .append(" AND B.CORRIDA_ID IS NULL ") .append(" AND B.FECCORRIDA IS NULL ") - .append("INNER JOIN BOLETO_FORMAPAGO BFP ON BFP.BOLETO_ID = B.BOLETO_ID ") - .append("AND BFP.FORMAPAGO_ID = :formaPago1 ") + .append("INNER JOIN CAJA C ON C.NUMOPERACION = B.NUMOPERACION ") + .append(" AND B.NUMFOLIOSISTEMA = C.NUMFOLIOSISTEMA ") + .append(" AND B.ORIGEN_ID = C.ORIGEN_ID ") + .append(" AND B.DESTINO_ID = C.DESTINO_ID ") + .append(" AND B.CATEGORIA_ID = C.CATEGORIA_ID ") + .append(" AND B.CLASESERVICIO_ID = C.CLASESERVICIO_ID ") + .append("INNER JOIN CAJA_DET_PAGO CDT ON CDT.CAJA_ID = C.CAJA_ID AND CDT.FORMAPAGO_ID = :formaPago1 ") + .append("INNER JOIN CAJA_TARJETA CTJ ON CDT.CAJADETPAGO_ID = CTJ.CAJADETPAGO_ID ") .append("INNER JOIN PUNTO_VENTA P ON P.PUNTOVENTA_ID = B.PUNTOVENTA_ID ") .append("INNER JOIN PTOVTA_EMPRESA PTOVTA ON B.PUNTOVENTA_ID = PTOVTA.PUNTOVENTA_ID ") .append("INNER JOIN MARCA M ON M.MARCA_ID = B.MARCA_ID AND M.EMPRESA_ID = PTOVTA.EMPRESA_ID ")