diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioDepositosNovo.java b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioDepositosNovo.java index 17a835e90..fe808836e 100644 --- a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioDepositosNovo.java +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioDepositosNovo.java @@ -6,8 +6,12 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Set; import org.apache.log4j.Logger; @@ -68,6 +72,7 @@ public class RelatorioDepositosNovo extends Relatorio { deposito.setVrfechamento(rs.getBigDecimal("vrdeposito")); deposito.setCodigoInstFinanceira(rs.getString("codinstfin")); deposito.setNomeInstFinanceira(rs.getString("nomeinstfin")); + deposito.setFechamentocntcorrenteId(rs.getLong("fechamentocntcorrente_id")); if (! filtrarPendentes){ deposito.setNumdeposito(rs.getString("numdeposito")); @@ -75,7 +80,9 @@ public class RelatorioDepositosNovo extends Relatorio { lsDadosRelatorio.add(deposito); } - + + addApenasPendentes(parametros, lsDadosRelatorio); + if (lsDadosRelatorio.size() > 0) { setLsDadosRelatorio(lsDadosRelatorio); } @@ -113,7 +120,8 @@ public class RelatorioDepositosNovo extends Relatorio { } sql.append(" tmp.codinstfin, "); - sql.append(" tmp.nomeinstfin "); + sql.append(" tmp.nomeinstfin, "); + sql.append(" tmp.fechamentocntcorrente_id "); sql.append(" FROM "); sql.append(" ( SELECT DISTINCT e.nombempresa, "); sql.append(" p.nombpuntoventa, "); @@ -185,4 +193,64 @@ public class RelatorioDepositosNovo extends Relatorio { return sql.toString(); } + + private void addApenasPendentes(Map parametros, List lsDadosRelatorio) { + Map mapaValorDeposito = new HashMap(); + Map mapaValorDepositoEmpresa = new HashMap(); + Map mapaValorFechamento = new HashMap(); + Map mapaValorFechamentoEmpresa = new HashMap(); + Iterator iterator = lsDadosRelatorio.iterator(); + + for (RelatorioDepositoBean bean: lsDadosRelatorio) { + if (!mapaValorDeposito.containsKey(bean.getFechamentocntcorrenteId())) { + mapaValorDeposito.put(bean.getFechamentocntcorrenteId(), bean.getVrdeposito()); + } else { + mapaValorDeposito.put(bean.getFechamentocntcorrenteId(), mapaValorDeposito.get(bean.getFechamentocntcorrenteId()).add(bean.getVrdeposito())); + } + + if (!mapaValorDepositoEmpresa.containsKey(bean.getNombempresa())) { + mapaValorDepositoEmpresa.put(bean.getNombempresa(), bean.getVrdeposito()); + } else { + mapaValorDepositoEmpresa.put(bean.getNombempresa(), mapaValorDepositoEmpresa.get(bean.getNombempresa()).add(bean.getVrdeposito())); + } + + if (!mapaValorFechamento.containsKey(bean.getFechamentocntcorrenteId())) { + mapaValorFechamento.put(bean.getFechamentocntcorrenteId(), bean.getVrfechamento()); + } + + if (!mapaValorFechamentoEmpresa.containsKey(bean.getNombempresa())) { + mapaValorFechamentoEmpresa.put(bean.getNombempresa(), bean.getVrfechamento()); + } else { + mapaValorFechamentoEmpresa.put(bean.getNombempresa(), mapaValorFechamentoEmpresa.get(bean.getNombempresa()).add(bean.getVrfechamento())); + } + } + + while (iterator.hasNext()) { + RelatorioDepositoBean bean = iterator.next(); + BigDecimal deposito = mapaValorDeposito.get(bean.getFechamentocntcorrenteId()); + BigDecimal fechamento = mapaValorFechamento.get(bean.getFechamentocntcorrenteId()); + + if (deposito.compareTo(fechamento) >= 0) { + mapaValorDepositoEmpresa.put(bean.getNombempresa(), mapaValorDepositoEmpresa.get(bean.getNombempresa()).subtract(bean.getVrdeposito())); + mapaValorFechamentoEmpresa.put(bean.getNombempresa(), mapaValorFechamentoEmpresa.get(bean.getNombempresa()).subtract(bean.getVrfechamento())); + iterator.remove(); + } + } + + BigDecimal totalDepositoGeral = BigDecimal.ZERO; + BigDecimal totalFechamentoGeral = BigDecimal.ZERO; + + for (String nombempresa: mapaValorDepositoEmpresa.keySet()) { + totalDepositoGeral = totalDepositoGeral.add(mapaValorDepositoEmpresa.get(nombempresa)); + } + + for (String nombempresa: mapaValorFechamentoEmpresa.keySet()) { + totalFechamentoGeral = totalFechamentoGeral.add(mapaValorFechamentoEmpresa.get(nombempresa)); + } + + parametros.put("MAPA_VALOR_DEPOSITO_EMPRESA", mapaValorDepositoEmpresa); + parametros.put("MAPA_VALOR_FECHAMENTO_EMPRESA", mapaValorFechamentoEmpresa); + parametros.put("TOTAL_FECHAMENTO_GERAL", totalFechamentoGeral); + parametros.put("TOTAL_PENDENTE_GERAL", totalFechamentoGeral.subtract(totalDepositoGeral)); + } } diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioDepositosNovo.jasper b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioDepositosNovo.jasper index db8e371cf..7e8c9d7bc 100644 Binary files a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioDepositosNovo.jasper and b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioDepositosNovo.jasper differ diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioDepositosNovo.jrxml b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioDepositosNovo.jrxml index 87cacb362..e18199a37 100644 --- a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioDepositosNovo.jrxml +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioDepositosNovo.jrxml @@ -5,15 +5,19 @@ - + - + + + + + @@ -24,6 +28,7 @@ + @@ -65,7 +70,7 @@ - + @@ -76,7 +81,7 @@ - + @@ -89,31 +94,9 @@ - - - - - - - - - - - - - - - - - - - - - - - + - + @@ -124,7 +107,7 @@ - + @@ -135,7 +118,7 @@ - + @@ -145,6 +128,17 @@ + + + + + + + + + + + @@ -153,7 +147,7 @@ - + @@ -169,7 +163,7 @@ - + @@ -183,21 +177,7 @@ - - - - - - - - - - - - - - - + @@ -211,21 +191,7 @@ - - - - - - - - - - - - - - - + @@ -239,7 +205,7 @@ - + @@ -253,7 +219,7 @@ - + @@ -271,7 +237,7 @@ - + @@ -281,30 +247,8 @@ - - - - - - - - - - - - - - - - - - - - - - - + @@ -315,7 +259,7 @@ - + @@ -334,9 +278,9 @@ <band height="56"> <frame> - <reportElement mode="Opaque" x="-10" y="-12" width="595" height="40" backcolor="#006699" uuid="0054fd73-707a-4615-8bae-2c2a29f606b3"/> + <reportElement uuid="0054fd73-707a-4615-8bae-2c2a29f606b3" mode="Opaque" x="-10" y="-12" width="595" height="40" backcolor="#006699"/> <textField> - <reportElement x="10" y="10" width="575" height="24" forecolor="#FFFFFF" uuid="558af18f-0344-4d19-b3c8-3ae165b7c91d"/> + <reportElement uuid="558af18f-0344-4d19-b3c8-3ae165b7c91d" x="10" y="10" width="575" height="24" forecolor="#FFFFFF"/> <textElement textAlignment="Justified" verticalAlignment="Middle" markup="styled"> <font fontName="SansSerif" size="18" isBold="true" isPdfEmbedded="true"/> </textElement> @@ -344,11 +288,12 @@ </textField> </frame> <textField isStretchWithOverflow="true" isBlankWhenNull="true"> - <reportElement stretchType="RelativeToTallestObject" x="52" y="42" width="523" height="14" forecolor="#333333" uuid="5dd823a7-3377-42a1-8e6f-977270e9bd79"/> + <reportElement uuid="5dd823a7-3377-42a1-8e6f-977270e9bd79" stretchType="RelativeToTallestObject" x="52" y="42" width="523" height="14" forecolor="#333333"/> + <textElement/> <textFieldExpression><![CDATA[$P{FILTROS}]]></textFieldExpression> </textField> <textField> - <reportElement x="52" y="28" width="523" height="14" forecolor="#000000" uuid="0840bea7-0cea-4e77-bb5d-969baeaf8a92"/> + <reportElement uuid="0840bea7-0cea-4e77-bb5d-969baeaf8a92" x="52" y="28" width="523" height="14" forecolor="#000000"/> <textElement> <font size="10" isBold="true"/> <paragraph lineSpacing="Single"/> @@ -356,7 +301,7 @@ <textFieldExpression><![CDATA[$P{fecInicio} + " à " + $P{fecFinal}]]></textFieldExpression> </textField> <textField> - <reportElement x="0" y="28" width="52" height="14" forecolor="#000000" uuid="8fe00f0a-6663-4f7e-9324-666a3dc60f77"/> + <reportElement uuid="8fe00f0a-6663-4f7e-9324-666a3dc60f77" x="0" y="28" width="52" height="14" forecolor="#000000"/> <textElement> <font size="10" isBold="true"/> <paragraph lineSpacing="Single"/> @@ -364,7 +309,7 @@ <textFieldExpression><![CDATA[$R{header.data}]]></textFieldExpression> </textField> <textField> - <reportElement x="0" y="42" width="52" height="14" forecolor="#000000" uuid="a448c17f-6960-4fb3-8a96-c964c5baabf1"/> + <reportElement uuid="a448c17f-6960-4fb3-8a96-c964c5baabf1" x="0" y="42" width="52" height="14" forecolor="#000000"/> <textElement> <font size="10" isBold="false"/> <paragraph lineSpacing="Single"/> @@ -382,7 +327,7 @@ <detail> <band height="14"> <textField isStretchWithOverflow="true" pattern="dd/MM/yyyy" isBlankWhenNull="true"> - <reportElement stretchType="RelativeToTallestObject" x="194" y="0" width="68" height="14" uuid="82d13b4c-c5af-4dc6-8353-58e0bd810b74"/> + <reportElement uuid="82d13b4c-c5af-4dc6-8353-58e0bd810b74" stretchType="RelativeToTallestObject" x="194" y="0" width="68" height="14"/> <box> <bottomPen lineWidth="0.25" lineColor="#666666"/> </box> @@ -393,7 +338,7 @@ <textFieldExpression><![CDATA[$F{dtmotivo}]]></textFieldExpression> </textField> <textField isStretchWithOverflow="true" pattern="#,##0.00" isBlankWhenNull="true"> - <reportElement stretchType="RelativeToTallestObject" x="262" y="0" width="68" height="14" uuid="d2a192d3-8b19-4023-84b5-6ab5c749bff9"/> + <reportElement uuid="d2a192d3-8b19-4023-84b5-6ab5c749bff9" stretchType="RelativeToTallestObject" x="262" y="0" width="68" height="14"/> <box> <bottomPen lineWidth="0.25" lineColor="#666666"/> </box> @@ -403,30 +348,8 @@ </textElement> <textFieldExpression><![CDATA[$F{vrdeposito}]]></textFieldExpression> </textField> - <textField isStretchWithOverflow="true" pattern="#,##0.00" isBlankWhenNull="true"> - <reportElement stretchType="RelativeToTallestObject" x="330" y="0" width="86" height="14" uuid="a9d99df3-e743-46cf-8454-deb020120916"/> - <box> - <bottomPen lineWidth="0.25" lineColor="#666666"/> - </box> - <textElement textAlignment="Right"> - <font size="8" isBold="false"/> - <paragraph lineSpacing="Single"/> - </textElement> - <textFieldExpression><![CDATA[$F{vrfechamento}]]></textFieldExpression> - </textField> - <textField isStretchWithOverflow="true" pattern="#,##0.00" isBlankWhenNull="true"> - <reportElement stretchType="RelativeToTallestObject" x="416" y="0" width="68" height="14" uuid="fef8a9f7-d047-4c20-834e-dabd2d2fe0a8"/> - <box> - <bottomPen lineWidth="0.25" lineColor="#666666"/> - </box> - <textElement textAlignment="Right"> - <font size="8" isBold="false"/> - <paragraph lineSpacing="Single"/> - </textElement> - <textFieldExpression><![CDATA[$F{saldo}]]></textFieldExpression> - </textField> <textField isStretchWithOverflow="true" pattern="" isBlankWhenNull="true"> - <reportElement stretchType="RelativeToTallestObject" x="484" y="0" width="91" height="14" uuid="8a041e80-b312-4fcc-909b-e38cfd9078ba"/> + <reportElement uuid="8a041e80-b312-4fcc-909b-e38cfd9078ba" stretchType="RelativeToTallestObject" x="330" y="0" width="245" height="14"/> <box> <bottomPen lineWidth="0.25" lineColor="#666666"/> </box> @@ -437,7 +360,7 @@ <textFieldExpression><![CDATA[$F{numdeposito}]]></textFieldExpression> </textField> <textField pattern="dd/MM/yyyy" isBlankWhenNull="true"> - <reportElement stretchType="RelativeToTallestObject" x="52" y="0" width="142" height="14" uuid="655d7066-585e-45b8-8183-f91f0bc3b129"/> + <reportElement uuid="655d7066-585e-45b8-8183-f91f0bc3b129" stretchType="RelativeToTallestObject" x="52" y="0" width="142" height="14"/> <box> <bottomPen lineWidth="0.25" lineColor="#666666"/> </box> @@ -448,7 +371,7 @@ <textFieldExpression><![CDATA[$F{nombpuntoventa}]]></textFieldExpression> </textField> <textField isStretchWithOverflow="true" pattern="dd/MM/yyyy" isBlankWhenNull="true"> - <reportElement stretchType="RelativeToTallestObject" x="0" y="0" width="52" height="14" uuid="0bc7de29-3141-475b-8c8f-759aa61ec086"/> + <reportElement uuid="0bc7de29-3141-475b-8c8f-759aa61ec086" stretchType="RelativeToTallestObject" x="0" y="0" width="52" height="14"/> <box> <bottomPen lineWidth="0.25" lineColor="#666666"/> </box> @@ -466,7 +389,7 @@ <pageFooter> <band height="19"> <textField> - <reportElement mode="Opaque" x="405" y="6" width="129" height="13" forecolor="#000000" backcolor="#E6E6E6" uuid="459669e8-6ea2-4f48-b249-be45842e3018"/> + <reportElement uuid="459669e8-6ea2-4f48-b249-be45842e3018" mode="Opaque" x="405" y="6" width="129" height="13" forecolor="#000000" backcolor="#E6E6E6"/> <box> <bottomPen lineWidth="0.25" lineColor="#666666"/> </box> @@ -474,7 +397,7 @@ <textFieldExpression><![CDATA[$R{header.pagina}+" "+$V{PAGE_NUMBER}+" "+$R{header.de}]]></textFieldExpression> </textField> <textField pattern="EEEEE dd MMMMM yyyy"> - <reportElement mode="Opaque" x="0" y="6" width="405" height="13" backcolor="#E6E6E6" uuid="cf46c42b-8cb7-451a-b5a1-78d62ea4f398"/> + <reportElement uuid="cf46c42b-8cb7-451a-b5a1-78d62ea4f398" mode="Opaque" x="0" y="6" width="405" height="13" backcolor="#E6E6E6"/> <box> <bottomPen lineWidth="0.25" lineColor="#666666"/> </box> @@ -484,40 +407,19 @@ <textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression> </textField> <textField evaluationTime="Report"> - <reportElement mode="Opaque" x="534" y="6" width="41" height="13" backcolor="#E6E6E6" uuid="277c8da2-694c-4ece-8655-a586f2ec09b5"/> + <reportElement uuid="277c8da2-694c-4ece-8655-a586f2ec09b5" mode="Opaque" x="534" y="6" width="41" height="13" backcolor="#E6E6E6"/> <box> <bottomPen lineWidth="0.25" lineColor="#666666"/> </box> + <textElement/> <textFieldExpression><![CDATA[" " + $V{PAGE_NUMBER}]]></textFieldExpression> </textField> </band> </pageFooter> <summary> - <band height="14"> - <textField isStretchWithOverflow="true" pattern="#,##0.00" isBlankWhenNull="true"> - <reportElement stretchType="RelativeToTallestObject" mode="Opaque" x="330" y="0" width="86" height="14" backcolor="#E6E6E6" uuid="a0c290ae-af70-4468-929c-0fecaaf21a77"/> - <box> - <bottomPen lineWidth="0.0" lineColor="#666666"/> - </box> - <textElement textAlignment="Right"> - <font size="8" isBold="false"/> - <paragraph lineSpacing="Single"/> - </textElement> - <textFieldExpression><![CDATA[$V{fechamento_total}]]></textFieldExpression> - </textField> - <textField isStretchWithOverflow="true" pattern="#,##0.00" isBlankWhenNull="true"> - <reportElement stretchType="RelativeToTallestObject" mode="Opaque" x="416" y="0" width="68" height="14" backcolor="#E6E6E6" uuid="a3f5ae52-8b9d-40d9-a97b-b48959bc59da"/> - <box> - <bottomPen lineWidth="0.0" lineColor="#666666"/> - </box> - <textElement textAlignment="Right"> - <font size="8" isBold="false"/> - <paragraph lineSpacing="Single"/> - </textElement> - <textFieldExpression><![CDATA[$V{saldo_total}]]></textFieldExpression> - </textField> + <band height="28"> <textField> - <reportElement mode="Opaque" x="0" y="0" width="262" height="14" backcolor="#E6E6E6" uuid="a92ccaaa-172c-45be-b475-7ad01db9d28f"/> + <reportElement uuid="a92ccaaa-172c-45be-b475-7ad01db9d28f" mode="Opaque" x="0" y="0" width="262" height="14" backcolor="#E6E6E6"/> <box> <bottomPen lineWidth="0.0" lineColor="#666666"/> </box> @@ -528,7 +430,7 @@ <textFieldExpression><![CDATA[$R{footer.total}]]></textFieldExpression> </textField> <staticText> - <reportElement stretchType="RelativeToTallestObject" mode="Opaque" x="484" y="0" width="91" height="14" backcolor="#E6E6E6" uuid="7bf3ff2c-c4ad-4ee3-b30a-592a939b21e1"/> + <reportElement uuid="7bf3ff2c-c4ad-4ee3-b30a-592a939b21e1" stretchType="RelativeToTallestObject" mode="Opaque" x="330" y="0" width="245" height="14" backcolor="#E6E6E6"/> <box> <bottomPen lineWidth="0.0" lineColor="#666666"/> </box> @@ -539,7 +441,7 @@ <text><![CDATA[]]></text> </staticText> <textField isStretchWithOverflow="true" pattern="#,##0.00" isBlankWhenNull="true"> - <reportElement stretchType="RelativeToTallestObject" mode="Opaque" x="262" y="0" width="68" height="14" backcolor="#E6E6E6" uuid="f7213305-9851-4224-805d-ae2a92cfa701"/> + <reportElement uuid="f7213305-9851-4224-805d-ae2a92cfa701" stretchType="RelativeToTallestObject" mode="Opaque" x="262" y="0" width="68" height="14" backcolor="#E6E6E6"/> <box> <bottomPen lineWidth="0.0" lineColor="#666666"/> </box> @@ -549,12 +451,24 @@ </textElement> <textFieldExpression><![CDATA[$V{deposito_total}]]></textFieldExpression> </textField> + <textField> + <reportElement uuid="89065d08-2004-418a-86bd-999352ee3115" mode="Opaque" x="0" y="15" width="575" height="13" backcolor="#E6E6E6"/> + <box> + <bottomPen lineWidth="0.25" lineColor="#666666"/> + </box> + <textElement verticalAlignment="Middle"> + <font size="8" isBold="true"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA["Total Fechamento Geral: " + new DecimalFormat("#,##0.00").format($P{TOTAL_FECHAMENTO_GERAL}) + " / Total Pendente Geral: " + new DecimalFormat("#,##0.00").format($P{TOTAL_PENDENTE_GERAL})]]></textFieldExpression> + </textField> </band> </summary> <noData> <band height="14"> <textField isStretchWithOverflow="true" isBlankWhenNull="true"> - <reportElement stretchType="RelativeToTallestObject" x="0" y="0" width="575" height="14" forecolor="#333333" uuid="f6f193c9-6da4-4334-aeb2-362a6af587cf"/> + <reportElement uuid="f6f193c9-6da4-4334-aeb2-362a6af587cf" stretchType="RelativeToTallestObject" x="0" y="0" width="575" height="14" forecolor="#333333"/> + <textElement/> <textFieldExpression><![CDATA[$R{msg.noData}]]></textFieldExpression> </textField> </band> diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/utilitarios/RelatorioDepositoBean.java b/src/java/com/rjconsultores/ventaboletos/relatorios/utilitarios/RelatorioDepositoBean.java index 6348cab0c..68f3f9eea 100644 --- a/src/java/com/rjconsultores/ventaboletos/relatorios/utilitarios/RelatorioDepositoBean.java +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/utilitarios/RelatorioDepositoBean.java @@ -15,6 +15,7 @@ public class RelatorioDepositoBean implements Comparable { private String numpuntoventa; private String codigoInstFinanceira; private String nomeInstFinanceira; + private Long fechamentocntcorrenteId; public String getCodigoInstFinanceira() { return codigoInstFinanceira; @@ -80,7 +81,15 @@ public class RelatorioDepositoBean implements Comparable { public void setNumpuntoventa(String numpuntoventa) { this.numpuntoventa = numpuntoventa; } - + + public Long getFechamentocntcorrenteId() { + return fechamentocntcorrenteId; + } + + public void setFechamentocntcorrenteId(Long fechamentocntcorrenteId) { + this.fechamentocntcorrenteId = fechamentocntcorrenteId; + } + @Override public int compareTo(Object o) { if(o == null) { diff --git a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/contacorrente/RelatorioDepositosController.java b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/contacorrente/RelatorioDepositosController.java index 74f35ca0f..3f6ae88d0 100644 --- a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/contacorrente/RelatorioDepositosController.java +++ b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/contacorrente/RelatorioDepositosController.java @@ -45,6 +45,7 @@ public class RelatorioDepositosController extends MyGenericForwardComposer { public void doAfterCompose(Component comp) throws Exception { super.doAfterCompose(comp); chkFiltrarPendentes.setChecked(true); + chkClassificarBanco.setDisabled(false); } private void executarRelatorio() throws Exception {