diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioDocumentosFiscais.java b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioDocumentosFiscais.java index 86264450b..aa9f34a66 100644 --- a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioDocumentosFiscais.java +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioDocumentosFiscais.java @@ -76,9 +76,7 @@ public class RelatorioDocumentosFiscais extends Relatorio { bean.setFormInicial((String) rset.getObject("formInicial")); bean.setFormFinal((String) rset.getObject("formFinal")); bean.setSerie((String) rset.getObject("serie")); - // datamov - // bean.setSubSerie((String) rset.getObject("subSerie")); - + bean.setSubSerie((String) rset.getObject("subSerie")); bean.setValorContabil((BigDecimal) rset.getObject("valorContabil")); bean.setValorBaseCalculo((BigDecimal) rset.getObject("valorBaseCalculo")); bean.setValorAliquiotaICMS((BigDecimal) rset.getObject("valorAliquiotaICMS")); @@ -86,6 +84,7 @@ public class RelatorioDocumentosFiscais extends Relatorio { bean.setOutras((BigDecimal) rset.getObject("outras")); bean.setValorCancelado((BigDecimal) rset.getObject("valorCancelado")); bean.setNomeEstado((String) rset.getObject("nomeEstado")); + bean.setIsentas((BigDecimal) rset.getObject("isentas")); lsDadosRelatorio.add(bean); } @@ -99,14 +98,14 @@ public class RelatorioDocumentosFiscais extends Relatorio { bean.setValorAliquiotaICMS(bean.getValorAliquiotaICMS().setScale(2, RoundingMode.HALF_EVEN)); bean.setValorICMS(bean.getValorICMS().setScale(2, RoundingMode.HALF_EVEN)); bean.setOutras(bean.getOutras().setScale(2, RoundingMode.HALF_EVEN)); - // bean.setIsentas(bean.getIsentas().setScale(2, RoundingMode.HALF_EVEN)); + bean.setIsentas(bean.getIsentas().setScale(2, RoundingMode.HALF_EVEN)); bean.setValorCancelado(bean.getValorCancelado().setScale(2, RoundingMode.HALF_EVEN)); totalValorContabil = totalValorContabil.add(bean.getValorContabil() != null ? bean.getValorContabil() : BigDecimal.ZERO); totalValorBaseCalculo = totalValorBaseCalculo.add(bean.getValorBaseCalculo() != null ? bean.getValorBaseCalculo() : BigDecimal.ZERO); totalValorAliquiotaICMS = totalValorAliquiotaICMS.add(bean.getValorAliquiotaICMS() != null ? bean.getValorAliquiotaICMS() : BigDecimal.ZERO); totalValorICMS = totalValorICMS.add(bean.getValorICMS() != null ? bean.getValorICMS() : BigDecimal.ZERO); - // totalValorIsentas = totalValorIsentas.add(bean.getIsentas() != null ? bean.getIsentas() : BigDecimal.ZERO); + totalValorIsentas = totalValorIsentas.add(bean.getIsentas() != null ? bean.getIsentas() : BigDecimal.ZERO); totalValorOutras = totalValorOutras.add(bean.getOutras() != null ? bean.getOutras() : BigDecimal.ZERO); totalValorCancelado = totalValorCancelado.add(bean.getValorCancelado() != null ? bean.getValorCancelado() : BigDecimal.ZERO); } @@ -136,39 +135,43 @@ public class RelatorioDocumentosFiscais extends Relatorio { StringBuilder sql = new StringBuilder(); sql.append("SELECT "); - // sql.append(" tabela.datamov, "); sql.append(" coalesce(tabela.numAidf, '') AS numAidf, "); - sql.append(" min(tabela.folio) AS formInicial, "); - sql.append(" max(tabela.folio) AS formFinal, "); + sql.append(" tabela.forminicial AS formInicial, "); + sql.append(" tabela.formfinal AS formFinal, "); sql.append(" tabela.serie AS serie, "); + sql.append(" tabela.subserie AS subSerie, "); sql.append(" tabela.nomeEstado AS nomeEstado, "); sql.append(" coalesce(sum(tabela.valorContabil),0) AS valorContabil, "); sql.append(" sum(valorBaseCalculo) AS valorBaseCalculo, "); sql.append(" tabela.valorAliquiotaICMS AS valorAliquiotaICMS, "); sql.append(" sum(tabela.valorICMS) AS valorICMS, "); - sql.append(" coalesce(sum(tabela.valorCancelado),0) AS valorCancelado, "); - sql.append(" sum(tabela.outras) AS outras "); + sql.append(" sum(tabela.qntancelados) AS valorCancelado, "); + sql.append(" sum(tabela.outras) AS outras, "); + sql.append(" sum(tabela.vlrisento) AS isentas "); sql.append("FROM "); sql.append(" (SELECT DISTINCT "); sql.append(" c.caja_id, "); - // sql.append(" TRUNC(c.feccreacion) as datamov, "); sql.append(" a.ACFISCAL AS numAidf, "); - sql.append(" c.NUMFOLIOPREIMPRESO as folio, "); - sql.append(" c.NUMSERIEPREIMPRESA as serie, "); + sql.append(" a.forminicial, "); + sql.append(" a.formfinal, "); + sql.append(" a.serie AS serie, "); + sql.append(" a.subserie AS subserie, "); sql.append(" c.MOTIVOCANCELACION_ID AS motivoCancelacion, "); sql.append(" c.PRECIOBASE AS tarifa, "); - sql.append(" ei.ICMS AS valorAliquiotaICMS, "); + sql.append(" ei.TRIBUTACAOIMPORTACAO AS valorAliquiotaICMS, "); + sql.append(" CASE WHEN c.MOTIVOCANCELACION_ID IS NOT NULL THEN 1 ELSE 0 END AS qntancelados, "); sql.append(" CASE WHEN c.MOTIVOCANCELACION_ID IS NULL THEN c.PRECIOPAGADO ELSE 0 END AS valorContabil, "); sql.append(" CASE WHEN c.MOTIVOCANCELACION_ID IS NOT NULL THEN c.PRECIOPAGADO ELSE 0 END AS valorCancelado, "); sql.append(" (coalesce(ei.PORCREDBASEICMS, 0) / 100.0) AS redBaseCalcIcms, "); sql.append(" CASE WHEN c.MOTIVOCANCELACION_ID IS NULL THEN c.PRECIOPAGADO - (c.PRECIOPAGADO * (coalesce(ei.PORCREDBASEICMS, 0) / 100.0) ) ELSE 0 END AS valorBaseCalculo, "); - sql.append(" CASE WHEN c.MOTIVOCANCELACION_ID IS NULL THEN ((c.PRECIOPAGADO - (c.PRECIOPAGADO * (coalesce(ei.PORCREDBASEICMS, 0) / 100.0) )) * ed.ICMS) / 100 ELSE 0 END AS valorICMS, "); + sql.append(" CASE WHEN c.MOTIVOCANCELACION_ID IS NULL THEN ((c.PRECIOPAGADO - (c.PRECIOPAGADO * (coalesce(ei.PORCREDBASEICMS, 0) / 100.0) )) * ei.TRIBUTACAOIMPORTACAO) / 100 ELSE 0 END AS valorICMS, "); sql.append(" CASE WHEN c.MOTIVOCANCELACION_ID IS NULL THEN c.PRECIOPAGADO - (c.PRECIOPAGADO - (c.PRECIOPAGADO * (coalesce(ei.PORCREDBASEICMS, 0) / 100.0) )) ELSE 0 END AS outras, "); sql.append(" coalesce(eos.estado_id, eo.estado_id) AS estadoId, "); sql.append(" coalesce(eos.NOMBESTADO, eo.NOMBESTADO) AS nomeEstado, "); sql.append(" coalesce(pos.DESCPARADA, po.DESCPARADA) AS origem, "); sql.append(" coalesce(pds.DESCPARADA, pd.DESCPARADA) AS destino, "); - sql.append(" CASE WHEN((coalesce(eos.cveestado, eo.cveestado)) = (coalesce(eds.cveestado, ed.cveestado))) THEN 0 ELSE 1 END AS isInterEstadual "); + sql.append(" CASE WHEN((coalesce(eos.cveestado, eo.cveestado)) = (coalesce(eds.cveestado, ed.cveestado))) THEN 0 ELSE 1 END AS isInterEstadual, "); + sql.append(" COALESCE((IMPORTETAXAEMBARQUE + IMPORTEPEDAGIO + IMPORTESEGURO),0) AS vlrisento "); sql.append(" FROM caja c "); sql.append(" INNER JOIN aidf a ON a.aidf_id = c.aidf_id "); sql.append(" JOIN marca m ON c.marca_id = m.marca_id "); @@ -197,8 +200,10 @@ public class RelatorioDocumentosFiscais extends Relatorio { sql.append(" )tabela "); sql.append(tipoLinha.equals("INTERMUNICIPAL") ? " where tabela.isInterEstadual = 1" : tipoLinha.equals("INTERESTADUAL") ? " where tabela.isInterEstadual = 0" : " "); sql.append("GROUP BY tabela.numAidf, "); - // sql.append(" tabela.datamov, "); sql.append(" tabela.serie, "); + sql.append(" tabela.subserie, "); + sql.append(" tabela.forminicial, "); + sql.append(" tabela.formfinal, "); sql.append(" tabela.nomeEstado, "); sql.append(" tabela.valorAliquiotaICMS "); sql.append("ORDER BY tabela.nomeEstado, tabela.numAidf "); @@ -210,26 +215,27 @@ public class RelatorioDocumentosFiscais extends Relatorio { StringBuilder sql = new StringBuilder(); sql.append("SELECT tabela.docfiscal AS numAidf, "); - // sql.append(" tabela.datamov, "); sql.append(" tabela.forminicial AS formInicial, "); sql.append(" tabela.formfinal AS formFinal, "); sql.append(" tabela.serie AS serie, "); + sql.append(" tabela.subserie AS subSerie, "); sql.append(" tabela.nomeEstado AS nomeEstado, "); sql.append(" coalesce(sum(tabela.valorContabil),0) AS valorContabil, "); sql.append(" sum(valorBaseCalculo) AS valorBaseCalculo, "); sql.append(" tabela.valorAliquiotaICMS AS valorAliquiotaICMS, "); sql.append(" sum(tabela.valorICMS) AS valorICMS, "); sql.append(" coalesce(sum(tabela.valorCancelado),0) AS valorCancelado, "); - sql.append(" sum(tabela.outras) AS outras "); + sql.append(" sum(tabela.outras) AS outras, "); + sql.append(" sum(tabela.vlrisento) AS isentas "); sql.append("FROM "); sql.append(" (SELECT DISTINCT "); sql.append(" aidf.DOCFISCAL, "); sql.append(" aidf.forminicial, "); sql.append(" aidf.formfinal, "); sql.append(" coalesce(cdv.NUMSERIEPREIMPRESA, 'X') AS numAidf, "); + sql.append(" aidf.serie AS serie, "); + sql.append(" aidf.subserie AS subserie, "); sql.append(" coalesce(cdv.NUMFOLIOPREIMPRESO, '0') AS folio, "); - sql.append(" coalesce(cdv.NUMSERIEPREIMPRESA, 'X') AS serie, "); - // sql.append(" trunc(ee.fechoringreso) as datamov, "); sql.append(" case when cdv.precio < 0 then 31 else null end AS motivoCancelacion, "); sql.append(" cdv.precio AS tarifa, "); sql.append(" cdv.precio as valor, "); @@ -244,7 +250,8 @@ public class RelatorioDocumentosFiscais extends Relatorio { sql.append(" es.NOMBESTADO AS nomeEstado, "); sql.append(" '' AS origem, "); sql.append(" '' AS destino, "); - sql.append(" 0 AS isInterEstadual "); + sql.append(" 0 AS isInterEstadual, "); + sql.append(" 0 AS vlrisento "); sql.append("from evento_extra ee "); sql.append(" join caja_diversos cdv on cdv.eventoextra_id = ee.eventoextra_id "); sql.append(" join aidf aidf on aidf.serie = cdv.numseriepreimpresa and cdv.numfoliopreimpreso between aidf.forminicial and aidf.formfinal "); @@ -261,8 +268,9 @@ public class RelatorioDocumentosFiscais extends Relatorio { // sql.append(somenteCancelado == true ? " AND c.INDCANCELACION = 1" : " "); sql.append(" )tabela "); // sql.append(tipoLinha.equals("INTERMUNICIPAL") ? " where tabela.isInterEstadual = 1" : tipoLinha.equals("INTERESTADUAL") ? " where tabela.isInterEstadual = 0" : " "); - sql.append("GROUP BY tabela.serie, "); - // sql.append(" tabela.datamov, "); + sql.append("GROUP BY tabela.numAidf, "); + sql.append(" tabela.serie, "); + sql.append(" tabela.subSerie, "); sql.append(" tabela.nomeEstado, "); sql.append(" tabela.valorAliquiotaICMS, "); sql.append(" tabela.docfiscal, "); diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioDocumentosFiscais.jasper b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioDocumentosFiscais.jasper index 453cb4be0..79e6f6175 100644 Binary files a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioDocumentosFiscais.jasper and b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioDocumentosFiscais.jasper differ diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioDocumentosFiscais.jrxml b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioDocumentosFiscais.jrxml index c2c13ee1e..3322a304f 100644 --- a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioDocumentosFiscais.jrxml +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioDocumentosFiscais.jrxml @@ -1,7 +1,7 @@ - - - + + + @@ -50,7 +50,7 @@ <band height="28"> <textField> - <reportElement x="258" y="2" width="300" height="20" uuid="e15d26de-6873-4576-b49b-8dc546b39dbe"/> + <reportElement x="258" y="2" width="300" height="26" uuid="e15d26de-6873-4576-b49b-8dc546b39dbe"/> <textElement textAlignment="Center"> <font size="12"/> </textElement> @@ -68,42 +68,42 @@ <textFieldExpression><![CDATA[$R{header.periodo}]]></textFieldExpression> </textField> <textField> - <reportElement x="634" y="6" width="123" height="20" uuid="66b2d0f6-2bf1-4bc7-9ec0-a34444e04d60"/> + <reportElement x="611" y="0" width="123" height="20" uuid="66b2d0f6-2bf1-4bc7-9ec0-a34444e04d60"/> <textElement> <font size="12"/> </textElement> <textFieldExpression><![CDATA[$R{header.data.hora}]]></textFieldExpression> </textField> <textField evaluationTime="Report"> - <reportElement x="833" y="26" width="22" height="17" uuid="8ca68351-fc00-4f19-b94f-f2fd1f41964f"/> + <reportElement x="810" y="20" width="22" height="17" uuid="8ca68351-fc00-4f19-b94f-f2fd1f41964f"/> <textElement textAlignment="Right"> <font size="12"/> </textElement> <textFieldExpression><![CDATA[" " + $V{PAGE_NUMBER}]]></textFieldExpression> </textField> <textField> - <reportElement x="767" y="26" width="42" height="17" uuid="be1692e9-f130-4d08-9173-6ca3e4699030"/> + <reportElement x="744" y="20" width="42" height="17" uuid="be1692e9-f130-4d08-9173-6ca3e4699030"/> <textElement> <font size="12"/> </textElement> <textFieldExpression><![CDATA[$R{header.pagina}]]></textFieldExpression> </textField> <textField pattern="dd/MM/yyyy HH:mm"> - <reportElement x="757" y="6" width="98" height="20" uuid="6f671365-868e-41a6-81ee-a308d1d91e1d"/> + <reportElement x="734" y="0" width="98" height="20" uuid="6f671365-868e-41a6-81ee-a308d1d91e1d"/> <textElement textAlignment="Left"> <font size="12"/> </textElement> <textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression> </textField> <textField> - <reportElement x="809" y="26" width="24" height="17" uuid="7548d623-fb6c-48d4-b8b7-504f5437a79a"/> + <reportElement x="786" y="20" width="24" height="17" uuid="7548d623-fb6c-48d4-b8b7-504f5437a79a"/> <textElement textAlignment="Right"> <font size="12"/> </textElement> <textFieldExpression><![CDATA[$V{PAGE_NUMBER}+" de"]]></textFieldExpression> </textField> <line> - <reportElement x="-1" y="87" width="858" height="1" uuid="ee05e1fa-6963-4ff9-b3c8-c6cd1bb54e94"/> + <reportElement x="-1" y="87" width="834" height="1" uuid="ee05e1fa-6963-4ff9-b3c8-c6cd1bb54e94"/> </line> <textField> <reportElement x="99" y="23" width="159" height="20" uuid="4d4f219a-3607-4255-b549-fc5ada2ad59e"/> @@ -172,7 +172,7 @@ <columnHeader> <band height="32" splitType="Stretch"> <line> - <reportElement mode="Transparent" x="0" y="30" width="857" height="1" uuid="ae94e51c-f84c-405c-a9c3-d8fd0c48f03a"/> + <reportElement mode="Transparent" x="0" y="30" width="832" height="1" uuid="ae94e51c-f84c-405c-a9c3-d8fd0c48f03a"/> </line> <textField isStretchWithOverflow="true" isBlankWhenNull="true"> <reportElement positionType="FixRelativeToBottom" stretchType="RelativeToTallestObject" x="0" y="2" width="99" height="26" isPrintWhenDetailOverflows="true" uuid="2cbc8ddc-38e5-4914-8189-5761ddeb2ce9"/> @@ -297,14 +297,14 @@ </textElement> <textFieldExpression><![CDATA[$F{valorBaseCalculo}]]></textFieldExpression> </textField> - <textField isStretchWithOverflow="true" pattern="¤ #,##0.00" isBlankWhenNull="true"> + <textField isStretchWithOverflow="true" pattern="¤ #,##0.00" isBlankWhenNull="false"> <reportElement stretchType="RelativeToTallestObject" mode="Transparent" x="634" y="1" width="67" height="16" isPrintWhenDetailOverflows="true" uuid="b7842ed3-aa20-4fe9-996a-c8397aa66c40"/> <textElement textAlignment="Center" verticalAlignment="Top" markup="none"> <font size="11" isBold="false"/> </textElement> - <textFieldExpression><![CDATA[$F{isentas}]]></textFieldExpression> + <textFieldExpression><![CDATA[$F{isentas} == null ? BigDecimal.ZERO :$F{isentas}]]></textFieldExpression> </textField> - <textField isStretchWithOverflow="true" pattern="¤ #,##0.00" isBlankWhenNull="true"> + <textField isStretchWithOverflow="true" pattern="###0.00" isBlankWhenNull="true"> <reportElement stretchType="RelativeToTallestObject" mode="Transparent" x="492" y="1" width="66" height="16" isPrintWhenDetailOverflows="true" uuid="36f5d507-0340-4c7e-b44b-5057c1e8bee6"/> <textElement textAlignment="Center" verticalAlignment="Top" markup="none"> <font size="11" isBold="false"/> @@ -339,7 +339,7 @@ </textElement> <textFieldExpression><![CDATA[$F{numAIDF}]]></textFieldExpression> </textField> - <textField isStretchWithOverflow="true" pattern="#,##0.00" isBlankWhenNull="true"> + <textField isStretchWithOverflow="true" pattern="#,##0" isBlankWhenNull="true"> <reportElement stretchType="RelativeToTallestObject" mode="Transparent" x="767" y="1" width="66" height="16" isPrintWhenDetailOverflows="true" uuid="e2ad1400-e2c6-48b0-98c8-812d3c8f008d"/> <textElement textAlignment="Center" verticalAlignment="Top" markup="none"> <font size="11" isBold="false"/> @@ -349,19 +349,20 @@ </band> </detail> <columnFooter> - <band height="8"/> + <band/> </columnFooter> <pageFooter> - <band height="8"/> + <band/> </pageFooter> <summary> - <band height="33"> + <band height="30"> <textField pattern="¤ #,##0.00"> <reportElement x="634" y="0" width="67" height="26" uuid="dbf285d9-c756-4ee7-92fd-3f406c0d15fe"/> + <textElement textAlignment="Right"/> <textFieldExpression><![CDATA[$P{TOTAL_VALOR_ISENTAS}]]></textFieldExpression> </textField> <textField isStretchWithOverflow="true" isBlankWhenNull="true"> - <reportElement positionType="FixRelativeToBottom" stretchType="RelativeToTallestObject" x="3" y="0" width="96" height="26" isPrintWhenDetailOverflows="true" uuid="b21a7ce5-7a71-46fe-b541-2a6ea4aed506"/> + <reportElement positionType="FixRelativeToBottom" stretchType="RelativeToTallestObject" x="0" y="0" width="99" height="26" isPrintWhenDetailOverflows="true" uuid="b21a7ce5-7a71-46fe-b541-2a6ea4aed506"/> <textElement textAlignment="Center" verticalAlignment="Top" markup="none"> <font size="10" isBold="true"/> </textElement> @@ -369,29 +370,32 @@ </textField> <textField pattern="¤ #,##0.00"> <reportElement x="558" y="0" width="76" height="26" uuid="d9e6ccc3-bd50-4f69-aefc-038ead5d42a1"/> + <textElement textAlignment="Right"/> <textFieldExpression><![CDATA[$P{TOTAL_VALOR_ICMS}]]></textFieldExpression> </textField> <textField pattern="¤ #,##0.00"> <reportElement x="701" y="0" width="66" height="26" uuid="0421c020-3268-4108-b906-74dc51966ceb"/> + <textElement textAlignment="Right"/> <textFieldExpression><![CDATA[$P{TOTAL_VALOR_OUTRAS}]]></textFieldExpression> </textField> <textField pattern="¤ #,##0.00"> <reportElement x="311" y="0" width="110" height="26" uuid="24994170-a664-4bbd-a1af-5adf2065859f"/> + <textElement textAlignment="Right"/> <textFieldExpression><![CDATA[$P{TOTAL_VALOR_CONTABIL}]]></textFieldExpression> </textField> - <textField pattern="¤ #,##0.00"> - <reportElement x="492" y="0" width="66" height="26" uuid="1e6a74f4-2122-4488-b1c9-b5428257dd34"/> - <textFieldExpression><![CDATA[$P{TOTAL_VALOR_ALIQUIOTA_ICMS}]]></textFieldExpression> - </textField> <textField pattern="¤ #,##0.00"> <reportElement x="421" y="0" width="71" height="26" uuid="dc457e5a-f70b-4ddd-a7f3-84203983597d"/> + <textElement textAlignment="Right"/> <textFieldExpression><![CDATA[$P{TOTAL_VALOR_BASE_CALCULO}]]></textFieldExpression> </textField> - <textField pattern="¤ #,##0.00"> - <reportElement x="764" y="0" width="69" height="26" uuid="a1630e46-8a69-4338-a9d8-eef4f6237895"/> - <textElement verticalAlignment="Bottom"/> + <textField pattern="###0"> + <reportElement x="767" y="0" width="66" height="26" uuid="a1630e46-8a69-4338-a9d8-eef4f6237895"/> + <textElement textAlignment="Center" verticalAlignment="Top"/> <textFieldExpression><![CDATA[$P{TOTAL_VALOR_CANCELADO}]]></textFieldExpression> </textField> + <line> + <reportElement mode="Transparent" x="3" y="0" width="831" height="1" uuid="6cb873e3-df62-410f-bf16-52f7d714f139"/> + </line> </band> </summary> <noData>