julio 2017-09-20 14:20:42 +00:00
parent f89621b8b9
commit 6769ed8728
2 changed files with 34 additions and 31 deletions

View File

@ -164,20 +164,20 @@ public class RelatorioFinanceiroAnalitico extends Relatorio {
sql.append(" cd.puntoventaId, ");
sql.append(" cd.empresaId, ");
sql.append(" cd.fechorVenta, ");
sql.append(" sum(case when (cd.indcancelacion = 0 and cd.indstatusboleto = 'V') then cd.pedagio else 0 end) as pedagio, ");
sql.append(" sum(case when (cd.indcancelacion = 0 and cd.indstatusboleto = 'V') then cd.valorpago else 0 end) as receita_bpr, ");
sql.append(" sum(case when (cd.indcancelacion = 1 and cd.motivocancelacion_id in (31,32)) then cd.valorpago else 0 end) as receita_devol_bpr, ");
sql.append(" sum(case when (cd.indcancelacion = 0 and cd.numfoliosistema is null) then cd.valorpago else 0 end) as receita_gap, ");
sql.append(" sum(case when (cd.indcancelacion = 1 and cd.motivocancelacion_id in (31,32) and cd.numfoliosistema is null) then cd.valorpago else 0 end) as receita_devol_gap, ");
sql.append(" sum(case when (cd.indstatusboleto = 'E') then cd.valorpago else 0 end) as entrega_gap, ");
sql.append(" sum(case when (cd.indcancelacion = 0 and cd.indstatusboleto = 'V' and cd.formapago_id in (2,25)) then cd.valorpago else 0 end) as cartao_credito, ");
sql.append(" sum(case when (cd.indcancelacion = 0 and cd.indstatusboleto = 'V' and cd.formapago_id in (3,26)) then cd.valorpago else 0 end) as cartao_debito, ");
sql.append(" sum(case when (cd.indcancelacion = 1 and cd.motivocancelacion_id in (35)) then cd.valorpago else 0 end) as receita_ocd_deb, ");
sql.append(" sum(case when (cd.indcancelacion = 1 and cd.motivocancelacion_id in (99) ) then cd.valorpago else 0 end) as receita_ocd_cred ");
sql.append(" sum(case when (cd.motivocancelacion_id is null and cd.indreimpresion = 0 and cd.indstatusboleto = 'V' and cd.numfoliosistema is not null) then cd.pedagio else 0 end) as pedagio, ");
sql.append(" sum(case when (cd.motivocancelacion_id is null and cd.indreimpresion = 0 and cd.indstatusboleto = 'V' and cd.numfoliosistema is not null) then cd.valorpago else 0 end) as receita_bpr, ");
sql.append(" sum(case when (cd.indstatusboleto in ('C', 'T') and cd.motivocancelacion_id in (31,32,10,37)) then cd.valorpago else 0 end) as receita_devol_bpr, ");
sql.append(" sum(case when (cd.indreimpresion = 0 and cd.indstatusboleto = 'V' and cd.tipoventa_id in (5,12,18,49)) then cd.valorpago else 0 end) as receita_gap, ");
sql.append(" sum(case when (cd.indstatusboleto in ('C', 'T') and cd.motivocancelacion_id in (31,32,10,37) and cd.numfoliosistema is null and cd.tipoventa_id in (5,12,18,49)) then cd.valorpago else 0 end) as receita_devol_gap, ");
sql.append(" sum(case when (cd.indreimpresion = 1 and cd.indstatusboleto = 'E' and cd.tipoventa_id in (5,12,18,49)) then cd.valorpago else 0 end) as entrega_gap, ");
sql.append(" sum(case when (cd.motivocancelacion_id is null and cd.indreimpresion = 0 and cd.indstatusboleto = 'V' and cd.numfoliosistema is not null and cd.formapago_id in (2,25)) then cd.valorpago else 0 end) as cartao_credito, ");
sql.append(" sum(case when (cd.motivocancelacion_id is null and cd.indreimpresion = 0 and cd.indstatusboleto = 'V' and cd.numfoliosistema is not null and cd.formapago_id in (3,26)) then cd.valorpago else 0 end) as cartao_debito, ");
sql.append(" sum(case when (cd.indstatusboleto = 'C' and cd.motivocancelacion_id in (35)) then cd.valorpago else 0 end) as receita_ocd_deb, ");
sql.append(" sum(case when (cd.indstatusboleto = 'C' and cd.motivocancelacion_id in (99) ) then cd.valorpago else 0 end) as receita_ocd_cred ");
sql.append(" ");
sql.append("from ( ");
sql.append(" select ");
sql.append(" c.caja_id as cajaid, ");
sql.append(" c.boleto_id as cajaid, ");
sql.append(" trunc(c.feccreacion) as fechorVenta, ");
sql.append(" e.empresa_id as empresaId, ");
sql.append(" pv.puntoventa_id as puntoventaId, ");
@ -198,8 +198,8 @@ public class RelatorioFinanceiroAnalitico extends Relatorio {
sql.append(" cfp.formapago_id, ");
sql.append(" c.motivocancelacion_id as motivocancelacion_id, ");
sql.append(" c.tipoventa_id as tipoventa_id ");
sql.append(" from caja c ");
sql.append(" inner join caja_formapago cfp on cfp.caja_id = c.caja_id ");
sql.append(" from boleto c ");
sql.append(" inner join boleto_formapago cfp on cfp.boleto_id = c.boleto_id ");
sql.append(" inner join punto_venta pv on pv.puntoventa_id = c.puntoventa_id ");
sql.append(" inner join forma_pago fp on cfp.formapago_id = fp.formapago_id ");
sql.append(" inner join marca m on c.marca_id = m.marca_id ");
@ -217,18 +217,22 @@ public class RelatorioFinanceiroAnalitico extends Relatorio {
sql.append("left join ( ");
sql.append(" select ed.puntoventaId, ed.estadoId, ed.empresaId, ");
sql.append(" ed.fechorVenta, ");
sql.append(" sum(case when tipoeventoextra_id = 2 and indtipo = 1 then impingreso else 0 end) as taxaEmbarque, ");
sql.append(" sum(case when tipoeventoextra_id = 2 and indtipo = 1 then impingreso else 0 end) as taxaEmbarque, ");
sql.append(" sum(case when tipoeventoextra_id = 25 and indtipo = 1 then impingreso else 0 end) as seguro, ");
sql.append(" sum(case when tipoeventoextra_id = 82 and indtipo = 1 then impingreso else 0 end) as receita_eb, ");
sql.append(" sum(case when tipoeventoextra_id in (41) and indtipo = 1 then impingreso else 0 end) as receita_multa, ");
sql.append(" sum(case when tipoeventoextra_id in (103,99978,99999) and indtipo = 1 then impingreso else 0 end) as receita_dif_troca_ocd, ");
sql.append(" sum(case when tipoeventoextra_id in (43) and indtipo = 1 then impingreso else 0 end) as receita_dif_dif_tarifa_maior, ");
sql.append(" sum(case when tipoeventoextra_id in (44) and indtipo = 0 then impingreso else 0 end) as receita_dif_dif_tarifa_menor, ");
sql.append(" sum(case when tipoeventoextra_id not in (44) and indtipo = 0 then impingreso else 0 end) as despesas ");
sql.append(" sum(case when tipoeventoextra_id not in (44) and indtipo = 0 then impingreso else 0 end) as despesas, ");
sql.append(" sum(case when (formapago_id in (2,25) and tipoeventoextra_id in (2,25,82,41,43,103,99978,99999) ");
sql.append(" and indtipo = 1) then impingreso else 0 end) as cartao_credito_ee, ");
sql.append(" sum(case when (formapago_id in (3,26) and tipoeventoextra_id in (2,25,82,41,43,103,99978,99999) ");
sql.append(" and indtipo = 1) then impingreso else 0 end) as cartao_debito_ee ");
sql.append(" from ( ");
sql.append(" select ee.tipoeventoextra_id, ee.impingreso, tee.indtipo, ");
sql.append(" pv.puntoventa_id as puntoventaId, eo.estado_id as estadoId, ee.empresa_id as empresaId, ");
sql.append(" trunc(ee.fechoringreso) as fechorVenta ");
sql.append(" trunc(ee.fechoringreso) as fechorVenta, ee.formapago_id ");
sql.append(" from evento_extra ee ");
sql.append(" join tipo_evento_extra tee on ee.tipoeventoextra_id = tee.tipoeventoextra_id ");
sql.append(" join punto_venta pv on pv.puntoventa_id = ee.puntoventa_id ");

View File

@ -169,19 +169,19 @@ public class RelatorioFinanceiroSintetico extends Relatorio {
sql.append(" cd.codigo, ");
sql.append(" cd.puntoventaId, ");
sql.append(" cd.empresaId, ");
sql.append(" sum(case when (cd.indcancelacion = 0 and cd.indstatusboleto <> 'E' and cd.numfoliosistema is not null and cd.tipoventa_id not in (5,12,18,49)) then cd.pedagio else 0 end) as pedagio, ");
sql.append(" sum(case when (cd.indcancelacion = 0 and cd.indstatusboleto <> 'E' and cd.numfoliosistema is not null) then cd.valorpago else 0 end) as receita_bpr, ");
sql.append(" sum(case when (cd.indcancelacion = 1 and cd.motivocancelacion_id in (31,32,10,37)) then cd.valorpago else 0 end) as receita_devol_bpr, ");
sql.append(" sum(case when (cd.indcancelacion = 0 and cd.numfoliosistema is null and cd.tipoventa_id in (5,12,18,49)) then cd.valorpago else 0 end) as receita_gap, ");
sql.append(" sum(case when (cd.indcancelacion = 1 and cd.motivocancelacion_id in (31,32,10,37) and cd.numfoliosistema is null and cd.tipoventa_id in (5,12,18,49)) then cd.valorpago else 0 end) as receita_devol_gap, ");
sql.append(" sum(case when (cd.indcancelacion = 0 and cd.indstatusboleto = 'E' and cd.tipoventa_id in (5,12,18,49)) then cd.valorpago else 0 end) as entrega_gap, ");
sql.append(" sum(case when (cd.indcancelacion = 0 and cd.indstatusboleto = 'V' and cd.formapago_id in (2,25)) then cd.valorpago else 0 end) as cartao_credito, ");
sql.append(" sum(case when (cd.indcancelacion = 0 and cd.indstatusboleto = 'V' and cd.formapago_id in (3,26)) then cd.valorpago else 0 end) as cartao_debito, ");
sql.append(" sum(case when (cd.indcancelacion = 1 and cd.motivocancelacion_id in (35)) then cd.valorpago else 0 end) as receita_ocd_deb, ");
sql.append(" sum(case when (cd.indcancelacion = 1 and cd.motivocancelacion_id in (99) ) then cd.valorpago else 0 end) as receita_ocd_cred ");
sql.append(" sum(case when (cd.motivocancelacion_id is null and cd.indreimpresion = 0 and cd.indstatusboleto = 'V' and cd.numfoliosistema is not null) then cd.pedagio else 0 end) as pedagio, ");
sql.append(" sum(case when (cd.motivocancelacion_id is null and cd.indreimpresion = 0 and cd.indstatusboleto = 'V' and cd.numfoliosistema is not null) then cd.valorpago else 0 end) as receita_bpr, ");
sql.append(" sum(case when (cd.indstatusboleto in ('C', 'T') and cd.motivocancelacion_id in (31,32,10,37)) then cd.valorpago else 0 end) as receita_devol_bpr, ");
sql.append(" sum(case when (cd.indreimpresion = 0 and cd.indstatusboleto = 'V' and cd.tipoventa_id in (5,12,18,49)) then cd.valorpago else 0 end) as receita_gap, ");
sql.append(" sum(case when (cd.indstatusboleto in ('C', 'T') and cd.motivocancelacion_id in (31,32,10,37) and cd.numfoliosistema is null and cd.tipoventa_id in (5,12,18,49)) then cd.valorpago else 0 end) as receita_devol_gap, ");
sql.append(" sum(case when (cd.indreimpresion = 1 and cd.indstatusboleto = 'E' and cd.tipoventa_id in (5,12,18,49)) then cd.valorpago else 0 end) as entrega_gap, ");
sql.append(" sum(case when (cd.motivocancelacion_id is null and cd.indreimpresion = 0 and cd.indstatusboleto = 'V' and cd.numfoliosistema is not null and cd.formapago_id in (2,25)) then cd.valorpago else 0 end) as cartao_credito, ");
sql.append(" sum(case when (cd.motivocancelacion_id is null and cd.indreimpresion = 0 and cd.indstatusboleto = 'V' and cd.numfoliosistema is not null and cd.formapago_id in (3,26)) then cd.valorpago else 0 end) as cartao_debito, ");
sql.append(" sum(case when (cd.indstatusboleto = 'C' and cd.motivocancelacion_id in (35)) then cd.valorpago else 0 end) as receita_ocd_deb, ");
sql.append(" sum(case when (cd.indstatusboleto = 'C' and cd.motivocancelacion_id in (99) ) then cd.valorpago else 0 end) as receita_ocd_cred ");
sql.append("from ( ");
sql.append(" select ");
sql.append(" c.caja_id as cajaid, ");
sql.append(" c.boleto_id as cajaid, ");
sql.append(" e.empresa_id as empresaId, ");
sql.append(" pv.puntoventa_id as puntoventaId, ");
sql.append(" pv.numpuntoventa as codigo, ");
@ -193,7 +193,6 @@ public class RelatorioFinanceiroSintetico extends Relatorio {
sql.append(" c.numfoliosistema, ");
sql.append(" coalesce(cfp.importe, 0) as valorpago, ");
sql.append(" coalesce(c.preciobase, 0) as precobase, ");
sql.append(" coalesce(c.preciopagado, 0) as tarifa, ");
sql.append(" coalesce(c.importetaxaembarque, 0) as taxaEmbarque, ");
sql.append(" coalesce(c.importepedagio, 0) as pedagio, ");
sql.append(" coalesce(c.importeseguro, 0) as seguro, ");
@ -201,10 +200,10 @@ public class RelatorioFinanceiroSintetico extends Relatorio {
sql.append(" cfp.formapago_id, ");
sql.append(" c.motivocancelacion_id as motivocancelacion_id, ");
sql.append(" c.tipoventa_id as tipoventa_id ");
sql.append(" from caja c ");
sql.append(" inner join caja_formapago cfp on cfp.caja_id = c.caja_id ");
sql.append(" from boleto c ");
sql.append(" inner join boleto_formapago cfp on cfp.boleto_id = c.boleto_id and cfp.activo = 1 ");
sql.append(" inner join punto_venta pv on pv.puntoventa_id = c.puntoventa_id ");
sql.append(" inner join forma_pago fp on cfp.formapago_id = fp.formapago_id ");
sql.append(" inner join forma_pago fp on cfp.formapago_id = fp.formapago_id and fp.activo = 1 ");
sql.append(" inner join marca m on c.marca_id = m.marca_id ");
sql.append(" inner join empresa e on e.empresa_id = m.empresa_id ");
sql.append(" inner join parada po on po.parada_id = pv.parada_id ");