Jump to content

JRAbstractExtendedIncrementer runs triple and multiplies sum values...


manelj

Recommended Posts

I have a custom incrementer for my special list-object (Jasper reports 6.1.1)

The problem is that the increment function is called three times for each report record. And then obviously the sum value is multiplied 3 times.
The field is called "DESGLOSEBASESIVA"
The variable is called "sumSubtotalDESGLOSEBASESIVA"

why is the incrementer function called so may times ?

Is there a solution to this ?

/** To change this license header, choose License Headers in Project Properties.* To change this template file, choose Tools | Templates* and open the template in the editor.*/package com.cesi.ventas.reports;import com.cesi.ventas.mvc.tablas.EntityBases;import com.cesi.ventas.mvc.tablas.EntityListBases;import java.util.ArrayList;import java.util.Collections;import java.util.List;import javafx.collections.FXCollections;import javafx.collections.ObservableList;import net.sf.jasperreports.engine.fill.AbstractValueProvider;import net.sf.jasperreports.engine.fill.JRAbstractExtendedIncrementer;import net.sf.jasperreports.engine.fill.JRAbstractExtendedIncrementerFactory;import net.sf.jasperreports.engine.fill.JRCalculable;import net.sf.jasperreports.engine.fill.JRExtendedIncrementer;import net.sf.jasperreports.engine.type.CalculationEnum;import org.apache.commons.lang.builder.ReflectionToStringBuilder;/**** @author manel*/public class DesgloseBasesIvaIncrementerFactory extends JRAbstractExtendedIncrementerFactory {    private static DesgloseBasesIvaIncrementerFactory mainInstance = new DesgloseBasesIvaIncrementerFactory();       public DesgloseBasesIvaIncrementerFactory() {    }       public static DesgloseBasesIvaIncrementerFactory getInstance() {        return mainInstance;    }       @Override    public JRExtendedIncrementer getExtendedIncrementer(CalculationEnum ce) {        JRExtendedIncrementer incrementer = null;               switch (ce) {            default:                incrementer = DesgloseBasesIvaSumIncrementer.getInstance();                break;        }        return incrementer;    }}class DesgloseBasesIvaSumIncrementer extends JRAbstractExtendedIncrementer {    private static DesgloseBasesIvaSumIncrementer mainInstance = new DesgloseBasesIvaSumIncrementer();    private DesgloseBasesIvaSumIncrementer() {           }    public static DesgloseBasesIvaSumIncrementer getInstance() {        return mainInstance;    }    @Override    public Object increment(JRCalculable variable, Object expressionValue, AbstractValueProvider valueProvider) {        List<EntityBases> bases = (List<EntityBases>) variable.getIncrementedValue();        List<EntityBases> nuevasBases = (List<EntityBases>) expressionValue;               if (nuevasBases == null) {            if (variable.isInitialized()) {                return null;            }            return bases;        }               if (bases == null || variable.isInitialized() ) {            bases = new ArrayList<EntityBases>();        }        EntityListBases lImportes = new EntityListBases();        lImportes.setList(bases);        // Sumar les bases que ja teniem anteriorment amb les noves que arriben        for (EntityBases nuevoimporte : (List<EntityBases>) nuevasBases ) {            Integer index = lImportes.getByIVA(nuevoimporte.getPorIva(), nuevoimporte.getPorRec());            EntityBases importeAcum;            if (index == -1) {                importeAcum = new EntityBases();                importeAcum.setPorIva(nuevoimporte.getPorIva());                importeAcum.setPorRec(nuevoimporte.getPorRec());            }            else {                importeAcum = lImportes.getList().get(index);            }            importeAcum.setBaseImp(importeAcum.getBaseImp() + nuevoimporte.getBaseImp());            importeAcum.setTotalIva(importeAcum.getTotalIva() + nuevoimporte.getTotalIva());            importeAcum.setTotalRec(importeAcum.getTotalRec() + nuevoimporte.getTotalRec());            lImportes.setItem(index, importeAcum);        }        ObservableList<EntityBases> items = FXCollections.observableList(lImportes.getList());        // Abans de retornar la llista s'hauria d'ordenar per % de iva de menor a major.        Collections.sort(items, (EntityBases a1, EntityBases a2) -> a1.getPorIva().compareTo(a2.getPorIva()) );        return (List<EntityBases>) items;           }    @Override    public Object initialValue() {        return new ArrayList<EntityBases>();    }}[/code]

This is the report:

<?xml version="1.0" encoding="UTF-8"?><!-- Created with Jaspersoft Studio version 6.1.0.final using JasperReports Library version 6.1.0  --><!-- 2016-04-19T18:03:07 --><jasperReportxmlns="http://jasperreports.sourceforge.net/jasperreports"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreportshttp://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="null"pageWidth="842" pageHeight="595" orientation="Landscape"columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20"bottomMargin="20" uuid="0e0b8ff4-d5f1-4a52-83c9-076fa45902f0">    <property name="ireport.zoom" value="2.0"/>    <property name="ireport.x" value="0"/>    <property name="ireport.y" value="0"/>    <property name="com.jaspersoft.studio.unit." value="pixel"/>    <parameter name="TITULO" class="java.lang.String">        <defaultValueExpression><![CDATA["Titulo del listado"]]></defaultValueExpression>    </parameter>    <parameter name="SUBTITULO" class="java.lang.String">        <defaultValueExpression><![CDATA["Subitulo del listado"]]></defaultValueExpression>    </parameter>    <parameter name="EMPRESA_NOMBRE" class="java.lang.String">        <defaultValueExpression><![CDATA["Nombre empresa"]]></defaultValueExpression>    </parameter>    <parameter name="FILTRO_SERIES" class="java.lang.String">        <defaultValueExpression><![CDATA["Series: a,b,c"]]></defaultValueExpression>    </parameter>    <parameter name="FILTRO_CLIENTES" class="java.lang.String">        <defaultValueExpression><![CDATA["Clientes : 000000 hata 999999"]]></defaultValueExpression>    </parameter>    <parameter name="FILTRO_COMERCIALES" class="java.lang.String">        <defaultValueExpression><![CDATA["Comerciales : 00 hata 99"]]></defaultValueExpression>    </parameter>    <parameter name="FILTRO_FECHAS" class="java.lang.String">        <defaultValueExpression><![CDATA["fechas : 01-01-XXXX hata 31-12-XXXX"]]></defaultValueExpression>    </parameter>    <parameter name="FILTRO_FORMAPAGO" class="java.lang.String">        <defaultValueExpression><![CDATA["Forma de pago: "]]></defaultValueExpression>    </parameter>    <parameter name="FILTRO_FISCALIDAD" class="java.lang.String">        <defaultValueExpression><![CDATA["Fiscalidad: "]]></defaultValueExpression>    </parameter>    <parameter name="HEADER_NUMEROFACTURA" class="java.lang.String">        <defaultValueExpression><![CDATA["NUMERO"]]></defaultValueExpression>    </parameter>    <parameter name="HEADER_FECHA" class="java.lang.String">        <defaultValueExpression><![CDATA["FECHA"]]></defaultValueExpression>    </parameter>    <parameter name="HEADER_CLIENTE" class="java.lang.String">        <defaultValueExpression><![CDATA["CLIENTE"]]></defaultValueExpression>    </parameter>    <parameter name="HEADER_BASE" class="java.lang.String">        <defaultValueExpression><![CDATA["BASE"]]></defaultValueExpression>    </parameter>    <parameter name="HEADER_IVA_REC" class="java.lang.String">        <defaultValueExpression><![CDATA["IVA"]]></defaultValueExpression>    </parameter>    <parameter name="HEADER_TOTAL" class="java.lang.String">        <defaultValueExpression><![CDATA["TOTAL"]]></defaultValueExpression>    </parameter>    <parameter name="HEADER_FP_ABR" class="java.lang.String">        <defaultValueExpression><![CDATA["F.P."]]></defaultValueExpression>    </parameter>    <parameter name="HEADER_FP" class="java.lang.String">        <defaultValueExpression><![CDATA["FORMA PAGO"]]></defaultValueExpression>    </parameter>    <parameter name="HEADER_COMERCIAL_ABR" class="java.lang.String">        <defaultValueExpression><![CDATA["VEN."]]></defaultValueExpression>    </parameter>    <parameter name="HEADER_COMERCIAL" class="java.lang.String">        <defaultValueExpression><![CDATA["COMERCIAL"]]></defaultValueExpression>    </parameter>    <parameter name="HEADER_ACUENTA" class="java.lang.String">        <defaultValueExpression><![CDATA["A CUENTA"]]></defaultValueExpression>    </parameter>    <parameter name="HEADER_DESGLOSEIVA" class="java.lang.String">        <defaultValueExpression><![CDATA["DESGLOSE BASE/IVA/REC"]]></defaultValueExpression>    </parameter>    <parameter name="AGRUPAR" class="java.lang.String">        <defaultValueExpression><![CDATA[""]]></defaultValueExpression>    </parameter>    <parameter name="AGRUPAR_TEXTO" class="java.lang.String">        <defaultValueExpression><![CDATA[""]]></defaultValueExpression>    </parameter>    <parameter name="SUBREPORT1_COMPILADO" class="net.sf.jasperreports.engine.JasperReport">        <parameterDescription><![CDATA[]]></parameterDescription>    </parameter>    <parameter name="FOOTER_TOTALESLISTADO" class="java.lang.String">        <defaultValueExpression><![CDATA["Totales"]]></defaultValueExpression>    </parameter>    <parameter name="FOOTER_SUBTOTALESAGR" class="java.lang.String">        <defaultValueExpression><![CDATA["Subtotales"]]></defaultValueExpression>    </parameter>    <queryString>        <![CDATA[]]>    </queryString>    <field name="NUMEROFACTURA" class="java.lang.String"/>    <field name="STRFECHA" class="java.lang.String"/>    <field name="CLIENTECODIGO" class="java.lang.Integer"/>    <field name="CLIENTENOMBRE" class="java.lang.String"/>    <field name="TOTALBASE" class="java.lang.Double"/>    <field name="TOTALIVA" class="java.lang.Double"/>    <field name="TOTALREC" class="java.lang.Double"/>    <field name="TOTAL" class="java.lang.Double"/>    <field name="ACUENTA" class="java.lang.Double"/>    <field name="FORMAPAGOID" class="java.lang.Integer"/>    <field name="FPNOMBRE" class="java.lang.String"/>    <field name="SERIEID" class="java.lang.Integer"/>    <field name="COMERCIALCODIGO" class="java.lang.Integer"/>    <field name="COMERCIALNOMBRE" class="java.lang.String"/>    <field name="DESGLOSEBASESIVA" class="java.util.List"/>     <variable name="sumSubtotalTOTALBASE" class="java.lang.Double"              resetType="Group" resetGroup="Agrupacion" calculation="Sum">        <variableExpression><![CDATA[$F{TOTALBASE}]]></variableExpression>        <initialValueExpression><![CDATA[0]]></initialValueExpression>    </variable>     <variable name="sumSubtotalTOTALIVA" class="java.lang.Double"              resetType="Group" resetGroup="Agrupacion" calculation="Sum">        <variableExpression><![CDATA[$F{TOTALIVA}]]></variableExpression>        <initialValueExpression><![CDATA[0]]></initialValueExpression>    </variable>     <variable name="sumSubtotalTOTALREC" class="java.lang.Double"              resetType="Group" resetGroup="Agrupacion" calculation="Sum">        <variableExpression><![CDATA[$F{TOTALREC}]]></variableExpression>        <initialValueExpression><![CDATA[0]]></initialValueExpression>    </variable>     <variable name="sumSubtotalTOTAL" class="java.lang.Double"              resetType="Group" resetGroup="Agrupacion" calculation="Sum">        <variableExpression><![CDATA[$F{TOTAL}]]></variableExpression>        <initialValueExpression><![CDATA[0]]></initialValueExpression>    </variable>     <variable name="sumSubtotalACUENTA" class="java.lang.Double"              resetType="Group" resetGroup="Agrupacion" calculation="Sum">        <variableExpression><![CDATA[$F{ACUENTA}]]></variableExpression>        <initialValueExpression><![CDATA[0]]></initialValueExpression>    </variable>     <variable name="sumSubtotalDESGLOSEBASESIVA" class="java.util.List"              resetType="Group" resetGroup="Agrupacion" calculation="System"              incrementerFactoryClass="com.cesi.ventas.reports.DesgloseBasesIvaIncrementerFactory">        <variableExpression><![CDATA[$F{DESGLOSEBASESIVA}]]></variableExpression>    </variable>    <variable name="sumTotalTOTALBASE" class="java.lang.Double" calculation="Sum">        <variableExpression><![CDATA[$F{TOTALBASE}]]></variableExpression>        <initialValueExpression><![CDATA[0]]></initialValueExpression>    </variable>    <variable name="sumTotalTOTALIVA" class="java.lang.Double" calculation="Sum">        <variableExpression><![CDATA[$F{TOTALIVA}]]></variableExpression>        <initialValueExpression><![CDATA[0]]></initialValueExpression>    </variable>    <variable name="sumTotalTOTALREC" class="java.lang.Double" calculation="Sum">        <variableExpression><![CDATA[$F{TOTALREC}]]></variableExpression>        <initialValueExpression><![CDATA[0]]></initialValueExpression>    </variable>    <variable name="sumTotalTOTAL" class="java.lang.Double" calculation="Sum">        <variableExpression><![CDATA[$F{TOTAL}]]></variableExpression>        <initialValueExpression><![CDATA[0]]></initialValueExpression>    </variable>    <variable name="sumTotalACUENTA" class="java.lang.Double" calculation="Sum">        <variableExpression><![CDATA[$F{ACUENTA}]]></variableExpression>        <initialValueExpression><![CDATA[0]]></initialValueExpression>    </variable>    <group name="Agrupacion" keepTogether="true">        <groupExpression><![CDATA[($P{AGRUPAR}.equals("SERIEID") ? Integer.toString($F{SERIEID}): ($P{AGRUPAR}.equals("CLIENTES.CODIGO") ? Integer.toString($F{CLIENTECODIGO}): ""))]]>        </groupExpression>        <groupHeader>            <band height="22">                <property name="com.jaspersoft.studio.unit.height" value="pixel"/>                <printWhenExpression>                    <![CDATA[!com.cesi.utils.StringUtils.isEmpty($P{AGRUPAR})]]>                </printWhenExpression>                <textField isStretchWithOverflow="true" isBlankWhenNull="true">                    <reportElement x="0" y="6" width="555" height="14"                                   isRemoveLineWhenBlank="true"                                   uuid="ccc2f77b-b489-41cb-bde7-187d4d03f9af"/>                    <textElement>                        <font fontName="Verdana" size="8" isBold="true"/>                    </textElement>                    <textFieldExpression>                        <![CDATA[($P{AGRUPAR}.equals("SERIEID") ?($P{AGRUPAR_TEXTO} + ($F{SERIEID}!=null ? Integer.toString($F{SERIEID}): "") ) :($P{AGRUPAR}.equals("CLIENTES.CODIGO") ?($P{AGRUPAR_TEXTO} + ($F{CLIENTECODIGO}!=null ?(Integer.toString($F{CLIENTECODIGO}) + " " + $F{CLIENTENOMBRE}) : "") ): ""))]]>                    </textFieldExpression>                </textField>            </band>        </groupHeader>        <groupFooter>            <band height="17">                <printWhenExpression>                    <![CDATA[!com.cesi.utils.StringUtils.isEmpty($P{AGRUPAR})]]>                </printWhenExpression>                <textField isBlankWhenNull="true">                    <reportElement x="253" y="4" width="62" height="10" uuid="fed84aba-180d-4c5b-9ed9-9fcf809713eb"/>                    <box>                        <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>                        <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>                        <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>                        <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>                    </box>                    <textElement textAlignment="Right" verticalAlignment="Middle" markup="styled">                        <font fontName="Verdana" size="8" isBold="false" isItalic="true"/>                    </textElement>                    <textFieldExpression>                        <![CDATA[new java.text.DecimalFormat("#,##0.00 €").format($V{sumSubtotalTOTALBASE} != null ? Double.valueOf($V{sumSubtotalTOTALBASE}) : 0)]]>                    </textFieldExpression>                </textField>                <textField isBlankWhenNull="true">                    <reportElement x="319" y="4" width="62" height="10" uuid="fa4dd2e4-39b8-475a-a5ca-ac0cdf22b5c3"/>                    <box>                        <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>                        <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>                        <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>                        <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>                    </box>                    <textElement textAlignment="Right" verticalAlignment="Middle" markup="styled">                        <font fontName="Verdana" size="8" isBold="false" isItalic="true"/>                    </textElement>                   <textFieldExpression><![CDATA[newjava.text.DecimalFormat("#,##0.00 €").format(($V{sumSubtotalTOTALIVA} !=null && $V{sumSubtotalTOTALREC} != null) ?Double.valueOf($V{sumSubtotalTOTALIVA}+$V{sumSubtotalTOTALREC}) :0)]]></textFieldExpression>                </textField>                <textField isBlankWhenNull="true">                    <reportElement x="383" y="4" width="62" height="10" uuid="f6c6415c-bbb6-4926-aefc-5efec12cf3c3">                        <property name="com.jaspersoft.studio.unit.width" value="pixel"/>                    </reportElement>                    <box>                        <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>                        <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>                        <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>                        <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>                    </box>                    <textElement textAlignment="Right" verticalAlignment="Middle" markup="styled">                        <font fontName="Verdana" size="8" isBold="false" isItalic="true"/>                    </textElement>                   <textFieldExpression><![CDATA[newjava.text.DecimalFormat("#,##0.00 €").format($V{sumSubtotalTOTAL} !=null ? Double.valueOf($V{sumSubtotalTOTAL}) :0)]]></textFieldExpression>                </textField>                <textField isBlankWhenNull="true">                    <reportElement x="1" y="4" width="243" height="10" uuid="8355b1ae-880d-4721-8777-d1c502e98b38"/>                    <box>                        <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>                        <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>                        <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>                        <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>                    </box>                    <textElement textAlignment="Right" verticalAlignment="Middle" markup="styled">                        <font fontName="Verdana" size="8" isBold="false" isItalic="true"/>                    </textElement>                    <textFieldExpression><![CDATA[$P{FOOTER_SUBTOTALESAGR} + " " +($P{AGRUPAR}.equals("SERIEID") ? ($P{AGRUPAR_TEXTO} + ($F{SERIEID}!=null ? Integer.toString($F{SERIEID}) : "") ) :($P{AGRUPAR}.equals("CLIENTES.CODIGO")? ($P{AGRUPAR_TEXTO} + ($F{CLIENTECODIGO}!=null ?(Integer.toString($F{CLIENTECODIGO}) + " " + $F{CLIENTENOMBRE}) : "") ) :($P{AGRUPAR}.equals("FACTURASV.SERIEIDASC, NUMEROFACTURA") ? ($P{AGRUPAR_TEXTO} + ($F{NUMEROFACTURA}!=null ?$F{NUMEROFACTURA} : "") ): "")))]]></textFieldExpression>                </textField>                <subreport>                   <reportElement positionType="Float" x="460" y="4"width="290" height="9" isRemoveLineWhenBlank="true"uuid="2c35466c-fec8-4b05-a188-b82475bfaf47"/>                  <dataSourceExpression><![CDATA[newnet.sf.jasperreports.engine.data.JRBeanCollectionDataSource($V{sumSubtotalDESGLOSEBASESIVA})]]></dataSourceExpression>                    <subreportExpression><![CDATA[$P{SUBREPORT1_COMPILADO}]]></subreportExpression>                </subreport>            </band>        </groupFooter>    </group>    <background>        <band splitType="Stretch"/>    </background>    <title>        <band height="16" splitType="Stretch"/>    </title>    <pageHeader>        <band height="133" splitType="Stretch">            <property name="com.jaspersoft.studio.unit.height" value="pixel"/>            <textField>                <reportElement x="0" y="22" width="370" height="20" uuid="43d02613-70dd-407a-8abf-d4f40764846d"/>                <textElement>                    <font fontName="Verdana" size="14" isBold="true"/>                </textElement>                <textFieldExpression><![CDATA[$P{TITULO}]]></textFieldExpression>            </textField>            <textField>               <reportElement stretchType="RelativeToTallestObject"x="1" y="93" width="368" height="13" isRemoveLineWhenBlank="true"uuid="b4fcf76d-c22d-45de-a922-7eb443ec6871">                    <printWhenExpression><![CDATA[$V{PAGE_NUMBER}==1]]></printWhenExpression>                </reportElement>                <textElement>                    <font fontName="Verdana" size="10"/>                </textElement>                <textFieldExpression><![CDATA[$P{FILTRO_FECHAS}]]></textFieldExpression>            </textField>            <textField>                <reportElement x="0" y="2" width="370" height="20" uuid="b39093bb-6df6-4553-925f-1b5c9c2f580a"/>                <textElement>                    <font fontName="Verdana" size="14" isBold="true"/>                </textElement>                <textFieldExpression><![CDATA[$P{EMPRESA_NOMBRE}]]></textFieldExpression>            </textField>            <textField>               <reportElement stretchType="RelativeToTallestObject"x="1" y="80" width="368" height="13" isRemoveLineWhenBlank="true"uuid="589f7ba5-4ef9-46ce-9bf7-5be1c92334ab">                    <property name="com.jaspersoft.studio.unit.height" value="pixel"/>                    <printWhenExpression><![CDATA[$V{PAGE_NUMBER}==1]]></printWhenExpression>                </reportElement>                <textElement>                    <font fontName="Verdana" size="10"/>                </textElement>                <textFieldExpression><![CDATA[$P{FILTRO_COMERCIALES}]]></textFieldExpression>            </textField>            <textField>               <reportElement stretchType="RelativeToTallestObject"x="1" y="67" width="368" height="13" isRemoveLineWhenBlank="true"uuid="f34e7eef-dd8c-415e-a60a-74c7c7d2d1bb">                    <property name="com.jaspersoft.studio.unit.height" value="pixel"/>                    <printWhenExpression><![CDATA[$V{PAGE_NUMBER}==1]]></printWhenExpression>                </reportElement>                <textElement>                    <font fontName="Verdana" size="10"/>                </textElement>                <textFieldExpression><![CDATA[$P{FILTRO_CLIENTES}]]></textFieldExpression>            </textField>            <textField>               <reportElement stretchType="RelativeToTallestObject"x="1" y="42" width="368" height="13"uuid="f895896d-9191-4039-8b1a-8f1b480e36b5">                    <property name="com.jaspersoft.studio.unit.height" value="pixel"/>                </reportElement>                <textElement>                    <font fontName="Verdana" size="10" isBold="true"/>                </textElement>                <textFieldExpression><![CDATA[$P{SUBTITULO}]]></textFieldExpression>            </textField>            <textField evaluationTime="Report">               <reportElement mode="Opaque" x="515" y="2" width="40"height="13" uuid="f401f23f-1039-4010-82f2-d9a68439ae28"/>                <textFieldExpression><![CDATA[" " + $V{PAGE_NUMBER}]]></textFieldExpression>            </textField>            <textField>               <reportElement mode="Opaque" x="370" y="2" width="145"height="13" uuid="fc189092-8727-467f-aebd-9ca8413912f7"/>                <textElement textAlignment="Right"/>                <textFieldExpression><![CDATA["Pag "+$V{PAGE_NUMBER}+" /"]]></textFieldExpression>            </textField>            <textField>               <reportElement stretchType="RelativeToTallestObject"x="1" y="55" width="368" height="13" isRemoveLineWhenBlank="true"uuid="e7ab101e-920e-4e8e-836f-19eea305f0bb">                    <property name="com.jaspersoft.studio.unit.height" value="pixel"/>                    <printWhenExpression><![CDATA[$V{PAGE_NUMBER}==1]]></printWhenExpression>                </reportElement>                <textElement>                    <font fontName="Verdana" size="10"/>                </textElement>                <textFieldExpression><![CDATA[$P{FILTRO_SERIES}]]></textFieldExpression>            </textField>            <textField>               <reportElement stretchType="RelativeToTallestObject"x="1" y="120" width="368" height="13" isRemoveLineWhenBlank="true"uuid="b9177933-07de-4d04-8ff0-1875e0bbf265">                    <printWhenExpression><![CDATA[$V{PAGE_NUMBER}==1]]></printWhenExpression>                </reportElement>                <textElement>                    <font fontName="Verdana" size="10"/>                </textElement>                <textFieldExpression><![CDATA[$P{FILTRO_FISCALIDAD}]]></textFieldExpression>            </textField>            <textField>               <reportElement stretchType="RelativeToTallestObject"x="1" y="107" width="368" height="13" isRemoveLineWhenBlank="true"uuid="25b538fd-fb7b-4958-bdc8-63200c8a9504">                    <property name="com.jaspersoft.studio.unit.height" value="pixel"/>                    <printWhenExpression><![CDATA[$V{PAGE_NUMBER}==1]]></printWhenExpression>                </reportElement>                <textElement>                    <font fontName="Verdana" size="10"/>                </textElement>                <textFieldExpression><![CDATA[$P{FILTRO_FORMAPAGO}]]></textFieldExpression>            </textField>        </band>    </pageHeader>    <columnHeader>        <band height="27" splitType="Stretch">            <textField>                <reportElement x="1" y="7" width="68" height="12" uuid="3b742e78-6196-4228-8aef-504873cc1514"/>                <textElement>                    <font fontName="Verdana" size="8"/>                </textElement>                <textFieldExpression><![CDATA[$P{HEADER_NUMEROFACTURA}]]></textFieldExpression>            </textField>            <line>                <reportElement x="1" y="21" width="68" height="1" uuid="6e468f84-7a56-441d-8221-a3f6382fecfa"/>            </line>            <textField>                <reportElement x="71" y="7" width="55" height="12" uuid="1452bee3-0535-4cbd-a132-2a61b910009a"/>                <textElement>                    <font fontName="Verdana" size="8"/>                </textElement>                <textFieldExpression><![CDATA[$P{HEADER_FECHA}]]></textFieldExpression>            </textField>            <line>                <reportElement x="71" y="21" width="55" height="1" uuid="0a15c349-5d23-471a-9b7a-8e90aaf669cf"/>            </line>            <textField>                <reportElement x="129" y="7" width="122" height="12" uuid="1e3941fa-17ec-49a2-b69c-757ff730e6ef">                    <property name="com.jaspersoft.studio.unit.height" value="pixel"/>                </reportElement>                <textElement>                    <font fontName="Verdana" size="8"/>                </textElement>                <textFieldExpression><![CDATA[$P{HEADER_CLIENTE}]]></textFieldExpression>            </textField>            <line>                <reportElement x="129" y="21" width="122" height="1" uuid="58368d4f-4dac-41cd-b46d-3414bb5bb561"/>            </line>            <textField>                <reportElement x="253" y="7" width="62" height="12" uuid="debd4642-2940-4701-8823-70807de8fbaf">                    <property name="com.jaspersoft.studio.unit.width" value="pixel"/>                </reportElement>                <textElement textAlignment="Right">                    <font fontName="Verdana" size="8"/>                </textElement>                <textFieldExpression><![CDATA[$P{HEADER_BASE}]]></textFieldExpression>            </textField>            <line>                <reportElement x="253" y="21" width="62" height="1" uuid="a26906f2-37e2-4aac-a4af-bdf1c5c6fbf8"/>            </line>            <textField>                <reportElement x="319" y="7" width="62" height="12" uuid="a0d1fb68-81d1-4fe8-adde-09bd44e73b6b"/>                <textElement textAlignment="Right">                    <font fontName="Verdana" size="8"/>                </textElement>                <textFieldExpression><![CDATA[$P{HEADER_IVA_REC}]]></textFieldExpression>            </textField>            <line>                <reportElement x="319" y="21" width="62" height="1" uuid="5fce5300-3aa1-4f29-8481-045ad0059f4f"/>            </line>            <textField>                <reportElement x="384" y="7" width="62" height="12" uuid="b9c330ba-e3a8-47b6-82c8-b6cdfeb338bb"/>                <textElement textAlignment="Right">                    <font fontName="Verdana" size="8"/>                </textElement>                <textFieldExpression><![CDATA[$P{HEADER_TOTAL}]]></textFieldExpression>            </textField>            <line>                <reportElement x="384" y="21" width="62" height="1" uuid="743c4d48-779f-4282-9431-6754f1d8e70c"/>            </line>            <line>                <reportElement x="460" y="21" width="290" height="1" uuid="13e08913-1c46-49b5-93cf-35761ad1d30b"/>            </line>            <textField>                <reportElement x="460" y="7" width="290" height="12" uuid="9dd8a706-a7fa-45fb-ab11-742e79b0773f"/>                <textElement textAlignment="Left">                    <font fontName="Verdana" size="8"/>                </textElement>                <textFieldExpression><![CDATA[$P{HEADER_DESGLOSEIVA}]]></textFieldExpression>            </textField>        </band>    </columnHeader>    <detail>        <band height="17" splitType="Stretch">            <property name="com.jaspersoft.studio.unit.height" value="pixel"/>            <textField>                <reportElement x="1" y="4" width="68" height="10" uuid="102c747d-6c4b-40c7-b569-3e9ef500eb39"/>                <textElement verticalAlignment="Middle">                    <font fontName="Verdana" size="8"/>                </textElement>                <textFieldExpression><![CDATA[$F{NUMEROFACTURA}]]></textFieldExpression>            </textField>            <textField pattern="MM/dd/yyyy" isBlankWhenNull="true">                <reportElement x="71" y="4" width="55" height="10" uuid="2c7fe4e4-95dd-414c-b788-f3f52e81e101">                    <property name="com.jaspersoft.studio.unit.width" value="pixel"/>                </reportElement>                <textElement verticalAlignment="Middle">                    <font fontName="Verdana" size="8"/>                </textElement>                <textFieldExpression><![CDATA[$F{STRFECHA}]]></textFieldExpression>            </textField>            <textField isStretchWithOverflow="true">                <reportElement x="129" y="4" width="122" height="10" uuid="705006c0-de12-485d-8b56-579d8d2dd7b6"/>                <textElement verticalAlignment="Middle">                    <font fontName="Verdana" size="8"/>                </textElement>               <textFieldExpression><![CDATA["(" +Integer.toString($F{CLIENTECODIGO}) + ") " +$F{CLIENTENOMBRE}]]></textFieldExpression>            </textField>            <textField isBlankWhenNull="true">                <reportElement x="253" y="4" width="62" height="10" uuid="fb523c5b-dfdf-48c3-ba22-3301e4830ed2"/>                <textElement textAlignment="Right" verticalAlignment="Middle" markup="styled">                    <font fontName="Verdana" size="8"/>                </textElement>               <textFieldExpression><![CDATA[newjava.text.DecimalFormat("#,##0.00 €").format($F{TOTALBASE} != null ?Double.valueOf($F{TOTALBASE}) : 0)]]></textFieldExpression>            </textField>            <textField isBlankWhenNull="true">                <reportElement x="319" y="4" width="62" height="10" uuid="48b293a6-acee-4b9c-b8a1-cf9cb29566d0"/>                <textElement textAlignment="Right" verticalAlignment="Middle" markup="styled">                    <font fontName="Verdana" size="8"/>                </textElement>               <textFieldExpression><![CDATA[newjava.text.DecimalFormat("#,##0.00 €").format(($F{TOTALIVA} != null&& $F{TOTALREC} != null) ?Double.valueOf($F{TOTALIVA}+$F{TOTALREC}) :0)]]></textFieldExpression>            </textField>            <textField isBlankWhenNull="true">                <reportElement x="383" y="4" width="62" height="10" uuid="535b7fee-fe64-4e6f-b7d5-953d4f97275f"/>                <textElement textAlignment="Right" verticalAlignment="Middle" markup="styled">                    <font fontName="Verdana" size="8"/>                </textElement>               <textFieldExpression><![CDATA[newjava.text.DecimalFormat("#,##0.00 €").format($F{TOTAL} != null ?Double.valueOf($F{TOTAL}) : 0)]]></textFieldExpression>            </textField>            <line>               <reportElement positionType="Float" x="0" y="16"width="750" height="1" forecolor="#808080"uuid="6e11a2e7-ba7a-4049-8955-eeb2a2a780ee">                    <property name="com.jaspersoft.studio.unit.width" value="pixel"/>                </reportElement>                <graphicElement>                    <pen lineWidth="1.0" lineStyle="Dotted"/>                </graphicElement>            </line>            <subreport>               <reportElement positionType="Float" x="460" y="3"width="290" height="9" isRemoveLineWhenBlank="true"uuid="4f7d4917-89c8-444a-abc9-0761e3261c6d"/>              <dataSourceExpression><![CDATA[newnet.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{DESGLOSEBASESIVA})]]></dataSourceExpression>                <subreportExpression><![CDATA[$P{SUBREPORT1_COMPILADO}]]></subreportExpression>            </subreport>        </band>    </detail>    <columnFooter>        <band splitType="Stretch"/>    </columnFooter>    <pageFooter>        <band height="26" splitType="Stretch">            <textField>               <reportElement mode="Opaque" x="0" y="13" width="515"height="13" uuid="cf2b0d40-d923-40c4-b404-b614e449940e"/>                <textElement textAlignment="Right"/>                <textFieldExpression><![CDATA["Pag "+$V{PAGE_NUMBER}+" /"]]></textFieldExpression>            </textField>            <textField evaluationTime="Report">               <reportElement mode="Opaque" x="515" y="13" width="40"height="13" uuid="84fa287b-f047-4d9a-a40f-50ad70464ef4"/>                <textFieldExpression><![CDATA[" " + $V{PAGE_NUMBER}]]></textFieldExpression>            </textField>        </band>    </pageFooter>    <summary>        <band height="25">            <property name="com.jaspersoft.studio.unit.height" value="pixel"/>            <textField isBlankWhenNull="true">                <reportElement x="253" y="12" width="62" height="10" uuid="6b8e8ead-900c-4aa2-867a-b7c2aae8b8d0"/>                <box>                    <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>                    <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>                    <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>                    <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>                </box>                <textElement textAlignment="Right" verticalAlignment="Middle" markup="styled">                    <font fontName="Verdana" size="8" isBold="true"/>                </textElement>               <textFieldExpression><![CDATA[newjava.text.DecimalFormat("#,##0.00 €").format($V{sumTotalTOTALBASE} !=null ? Double.valueOf($V{sumTotalTOTALBASE}) :0)]]></textFieldExpression>            </textField>            <textField isBlankWhenNull="true">                <reportElement x="319" y="12" width="62" height="10" uuid="89c7b3e3-68cb-4f48-b857-b467ecfa8c04"/>                <box>                    <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>                    <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>                    <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>                    <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>                </box>                <textElement textAlignment="Right" verticalAlignment="Middle" markup="styled">                    <font fontName="Verdana" size="8" isBold="true"/>                </textElement>               <textFieldExpression><![CDATA[newjava.text.DecimalFormat("#,##0.00 €").format(($V{sumTotalTOTALIVA} !=null && $V{sumTotalTOTALREC} != null) ?Double.valueOf($V{sumTotalTOTALIVA}+$V{sumTotalTOTALREC}) :0)]]></textFieldExpression>            </textField>            <textField isBlankWhenNull="true">                <reportElement x="383" y="12" width="62" height="10" uuid="80cfdeab-ce4d-4a2f-8c19-a1957b38675e">                    <property name="com.jaspersoft.studio.unit.width" value="pixel"/>                </reportElement>                <box>                    <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>                    <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>                    <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>                    <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>                </box>                <textElement textAlignment="Right" verticalAlignment="Middle" markup="styled">                    <font fontName="Verdana" size="8" isBold="true"/>                </textElement>               <textFieldExpression><![CDATA[newjava.text.DecimalFormat("#,##0.00 €").format($V{sumTotalTOTAL} != null ?Double.valueOf($V{sumTotalTOTAL}) :0)]]></textFieldExpression>            </textField>            <textField isBlankWhenNull="true">                <reportElement x="1" y="12" width="243" height="10" uuid="e4131cab-b799-4f25-a3ba-2eb022354391"/>                <box>                    <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>                    <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>                    <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>                    <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>                </box>                <textElement textAlignment="Right" verticalAlignment="Middle" markup="styled">                    <font fontName="Verdana" size="8" isBold="true"/>                </textElement>                <textFieldExpression><![CDATA[$P{FOOTER_TOTALESLISTADO}]]></textFieldExpression>            </textField>        </band>    </summary></jasperReport>[/code]

This is the subreport:

 

<?xml version="1.0" encoding="UTF-8"?><!-- Created with Jaspersoft Studio version 6.1.0.final using JasperReports Library version 6.1.0  --><!-- 2016-04-19T17:00:36 --><jasperReportxmlns="http://jasperreports.sourceforge.net/jasperreports"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreportshttp://jasperreports.sourceforge.net/xsd/jasperreport.xsd"name="SUBREPORT_CLIENTES_EXCEPCIONES" pageWidth="550" pageHeight="842"columnWidth="550" leftMargin="0" rightMargin="0" topMargin="0"bottomMargin="0" uuid="0e0b8ff4-d5f1-4a52-83c9-076fa45902f0">    <property name="ireport.zoom" value="2.0"/>    <property name="ireport.x" value="0"/>    <property name="ireport.y" value="0"/>    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>    <property name="com.jaspersoft.studio.unit." value="pixel"/>    <property name="com.jaspersoft.studio.unit.pageHeight" value="pixel"/>    <property name="com.jaspersoft.studio.unit.pageWidth" value="pixel"/>    <property name="com.jaspersoft.studio.unit.topMargin" value="pixel"/>    <property name="com.jaspersoft.studio.unit.bottomMargin" value="pixel"/>    <property name="com.jaspersoft.studio.unit.leftMargin" value="pixel"/>    <property name="com.jaspersoft.studio.unit.rightMargin" value="pixel"/>    <property name="com.jaspersoft.studio.unit.columnWidth" value="pixel"/>    <property name="com.jaspersoft.studio.unit.columnSpacing" value="pixel"/>    <parameter name="SUB1_HEADER_TIPO" class="java.lang.String">        <defaultValueExpression><![CDATA["Tipo"]]></defaultValueExpression>    </parameter>    <parameter name="SUB1_HEADER_CODIGO" class="java.lang.String">        <defaultValueExpression><![CDATA["Código"]]></defaultValueExpression>    </parameter>    <parameter name="SUB1_HEADER_DESCRIPCION" class="java.lang.String">        <defaultValueExpression><![CDATA["Descripcrión"]]></defaultValueExpression>    </parameter>    <parameter name="SUB1_HEADER_TARIFA" class="java.lang.String">        <defaultValueExpression><![CDATA["Tarifa"]]></defaultValueExpression>    </parameter>    <parameter name="SUB1_HEADER_PRECIO" class="java.lang.String">        <defaultValueExpression><![CDATA["Precio"]]></defaultValueExpression>    </parameter>    <parameter name="SUB1_HEADER_PRECIOIVA" class="java.lang.String">        <defaultValueExpression><![CDATA["P.V.P."]]></defaultValueExpression>    </parameter>    <parameter name="SUB1_HEADER_PORDTO" class="java.lang.String">        <defaultValueExpression><![CDATA["% Dto."]]></defaultValueExpression>    </parameter>    <parameter name="SUB1_HEADER_VERDTO" class="java.lang.String">        <defaultValueExpression><![CDATA["V.Dto."]]></defaultValueExpression>    </parameter>    <queryString>        <![CDATA[]]>    </queryString>    <field name="DATOS_SUBREPORT1" class="com.cesi.ventas.mvc.tablas.EntityBases">        <fieldDescription><![CDATA[_THIS]]></fieldDescription>    </field>    <field name="baseImp" class="java.lang.Double"/>    <field name="porIva" class="java.lang.Double"/>    <field name="totalIva" class="java.lang.Double"/>    <field name="porRec" class="java.lang.Double"/>    <field name="totalRec" class="java.lang.Double"/>    <background>        <band splitType="Stretch"/>    </background>    <detail>        <band height="12" splitType="Stretch">            <textField isBlankWhenNull="true">                <reportElement x="4" y="1" width="55" height="10" uuid="2e2b1e0a-7545-4b19-b820-37acd7db4fbd"/>                <textElement textAlignment="Right" markup="styled">                    <font fontName="Verdana" size="8"/>                </textElement>               <textFieldExpression><![CDATA[newjava.text.DecimalFormat("#,##0.00 €").format($F{baseImp} != null ?Double.valueOf($F{baseImp}) : 0)]]></textFieldExpression>            </textField>            <textField isBlankWhenNull="true">                <reportElement x="65" y="1" width="40" height="10" uuid="2f17e62b-5db8-4c66-b223-b9b83a0b11f1"/>                <textElement textAlignment="Right" markup="styled">                    <font fontName="Verdana" size="8"/>                </textElement>               <textFieldExpression><![CDATA[newjava.text.DecimalFormat("##0.00").format(($F{porIva} != null) ?Double.valueOf($F{porIva}) : 0)+"%"]]></textFieldExpression>            </textField>            <textField isBlankWhenNull="true">                <reportElement x="109" y="1" width="55" height="10" uuid="a5db5815-762f-43ab-8178-9a23e890f85e"/>                <textElement textAlignment="Right" markup="styled">                    <font fontName="Verdana" size="8"/>                </textElement>               <textFieldExpression><![CDATA[newjava.text.DecimalFormat("#,##0.00 €").format(($F{totalIva} != null) ?Double.valueOf($F{totalIva}) : 0)]]></textFieldExpression>            </textField>            <textField isBlankWhenNull="true">                <reportElement x="169" y="1" width="40" height="10" uuid="147aed1b-d599-498b-99c2-57c084a429a6">                    <printWhenExpression><![CDATA[$F{porRec}!=0]]></printWhenExpression>                </reportElement>                <textElement textAlignment="Right" markup="styled">                    <font fontName="Verdana" size="8"/>                </textElement>               <textFieldExpression><![CDATA[newjava.text.DecimalFormat("##0.00").format(($F{porRec} != null ) ?Double.valueOf($F{porRec}) : 0)+"%"]]></textFieldExpression>            </textField>            <textField isBlankWhenNull="true">                <reportElement x="211" y="1" width="55" height="10" uuid="722136a8-f5a9-48fc-955a-0aa65f683699">                    <printWhenExpression><![CDATA[$F{porRec}!=0]]></printWhenExpression>                </reportElement>                <textElement textAlignment="Right" markup="styled">                    <font fontName="Verdana" size="8"/>                </textElement>               <textFieldExpression><![CDATA[newjava.text.DecimalFormat("#,##0.00 €").format(($F{totalRec} != null) ?Double.valueOf($F{totalRec}) : 0)]]></textFieldExpression>            </textField>        </band>    </detail></jasperReport>[/code]

 


 

 

 

Link to comment
Share on other sites

  • 4 months later...
  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Hi, 

I have one question about Matrix/Crosstab reports in JasperReports. I would like to show Departmentwise, which Salesmen, Clerks, Analysts and Managers are working. For example, see below table. There are multiple values in Measure column.   Since, I am beginner and have no idea how to print multiple values in Measure field.   

I am getting single value means only name of one employee.  Not all clerks and salemen are displayed. Even though I choosed 'Nothing' option in the wizard for Measure Field.  

I have got an idea somehow that need to implement custom incrementer class and that will be used inside property 'Incrementer Factory class'. But unfortunately, no idea how to start and write that custom class using 'JRAbstractExtendedIncrementer' and 'JRExtendedIncrementer' interfaces.

Does anyone have any report sample using them or any other idea to display such information ??  

Looking forward to your replies.

 CLERKMANAGERPRESIDENTANALYSTSALESMAN
ACCOUNTINGMILLERCLARKKINGJAMESNull
RESEARCHADAMS
SMITH
PETER
JONESNullNullNull
SALESJAMESBLAKENullNullALLEN
MARTIN
TURNER
WARD

 

Thank you.

 

Regards,

Eddie

 
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...