<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="subreport_torta" language="groovy" pageWidth="572" pageHeight="800" orientation="Landscape" columnWidth="572" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0">
	<property name="ireport.zoom" value="1.1000000000000005"/>
	<property name="ireport.x" value="0"/>
	<property name="ireport.y" value="0"/>
	<property name="ireport.jasperserver.reportUnit" value="/reports/nomina/ana_est_nom_adic"/>
	<property name="ireport.jasperserver.url" value="http://192.168.2.43:8090/jasperserver/services/repository"/>
	<parameter name="id_anhos" class="java.math.BigDecimal">
		<defaultValueExpression><![CDATA[""]]></defaultValueExpression>
	</parameter>
	<parameter name="fecha_fin" class="java.lang.String">
		<defaultValueExpression><![CDATA[""]]></defaultValueExpression>
	</parameter>
	<parameter name="fecha_ini" class="java.lang.String">
		<defaultValueExpression><![CDATA[""]]></defaultValueExpression>
	</parameter>
	<queryString>
		<![CDATA[select
    tab0.id_tipo_periodo,
	count(tab0.id_tipo_periodo) as total_nomina,
    max(tab0.descripcion) as descripcion,
    sum(tab0.valor_total_ded) as valor_total_ded    , sum(tab0.valor_total_dev) as valor_total_dev,
    sum(tab0.valor_total) as valor_total,
	max(tab0.periodos_cantidad) as periodos_cantidad,
    (select sum(total_t) as total_t from(

select
    sum(tab0.valor_total) as total_t
     from (

SELECT DISTINCT
tab0.id_certif_ingre_adic_inf as id_certif_ingre_adic_inf,
tab0.id_tipo_doc as id_tipo_doc,
tab0.num_doc as num_doc,

tab0.periodo,
tab0.id_periodo,

tab0.valor_total_dev as valor_total_dev,
tab0.valor_total_ded as valor_total_ded,
tab0.valor_total_dev-tab0.valor_total_ded as valor_total,
tab2.id_tipo_periodo,
tab2.nom_adicional,
atab.descripcion,
 tab3.id_consecutivo_certif as id_consecutivo_certif,
tab3.secuencia as secuencia,
tab2.fecha_ini,
tab2.fecha_fin,
tab2.id_anhos

FROM NO_CERTIF_INGRE_ADIC_INF tab0
LEFT JOIN NO_PERIODO_V tab2 ON tab0.id_periodo = tab2.id_periodo
LEFT JOIN NO_TIPO_PERIODO atab ON tab2.id_tipo_periodo=atab.id_tipo_periodo
LEFT JOIN NO_CONSECUTIVO_CERTIF tab3 ON tab0.id_tipo_doc = tab3.id_tipo_doc AND tab0.num_doc = tab3.num_doc AND tab0.id_anhos = tab3.id_anhos





WHERE
tab0.id_certif_ingre_adic_inf != '-1'
and tab2.id_anhos=$P{id_anhos}
and tab2.fecha_ini BETWEEN to_date($P{fecha_ini}, 'dd/mm/yyyy') AND to_date($P{fecha_fin}, 'dd/mm/yyyy')



)tab0

where 1 = 1



GROUP BY tab0.id_tipo_periodo)
) as total_t
     from (

SELECT DISTINCT
tab0.id_certif_ingre_adic_inf as id_certif_ingre_adic_inf,
tab0.id_tipo_doc as id_tipo_doc,
tab0.num_doc as num_doc,
tab0.id_anhos as id_anhos,
tab0.periodo,
tab0.id_periodo,

tab0.valor_total_dev as valor_total_dev,
tab0.valor_total_ded as valor_total_ded,
tab0.valor_total_dev-tab0.valor_total_ded as valor_total,
tab2.id_tipo_periodo,
tab2.nom_adicional,
atab.descripcion,
 tab3.id_consecutivo_certif as id_consecutivo_certif,
tab3.secuencia as secuencia,
tab2.fecha_ini,
tab2.fecha_fin,
tab2.id_anhos,
tab4.periodos_cantidad

FROM NO_CERTIF_INGRE_ADIC_INF tab0
LEFT JOIN NO_PERIODO_V tab2 ON tab0.id_periodo = tab2.id_periodo
LEFT JOIN NO_TIPO_PERIODO atab ON tab2.id_tipo_periodo=atab.id_tipo_periodo
LEFT JOIN NO_CONSECUTIVO_CERTIF tab3 ON tab0.id_tipo_doc = tab3.id_tipo_doc AND tab0.num_doc = tab3.num_doc AND tab0.id_anhos = tab3.id_anhos
LEFT JOIN ((select t.id_tipo_periodo,count(t.id_tipo_periodo) as periodos_cantidad from no_periodo t where 1=1
and t.id_anhos=$P{id_anhos}
and t.fecha_ini BETWEEN to_date($P{fecha_ini}, 'dd/mm/yyyy') AND to_date($P{fecha_fin}, 'dd/mm/yyyy')
 group by t.id_tipo_periodo))tab4 ON tab2.id_tipo_periodo=tab4.id_tipo_periodo




WHERE
tab0.id_certif_ingre_adic_inf != '-1'
and tab2.id_anhos=$P{id_anhos}
and tab2.fecha_ini BETWEEN to_date($P{fecha_ini}, 'dd/mm/yyyy') AND to_date($P{fecha_fin}, 'dd/mm/yyyy')



)tab0

where 1 = 1



GROUP BY tab0.id_tipo_periodo]]>
	</queryString>
	<field name="ID_TIPO_PERIODO" class="java.math.BigDecimal"/>
	<field name="TOTAL_NOMINA" class="java.math.BigDecimal"/>
	<field name="DESCRIPCION" class="java.lang.String"/>
	<field name="VALOR_TOTAL_DED" class="java.math.BigDecimal"/>
	<field name="VALOR_TOTAL_DEV" class="java.math.BigDecimal"/>
	<field name="VALOR_TOTAL" class="java.math.BigDecimal"/>
	<field name="PERIODOS_CANTIDAD" class="java.math.BigDecimal"/>
	<field name="TOTAL_T" class="java.math.BigDecimal"/>
	<variable name="variable1" class="java.math.BigDecimal" calculation="Sum">
		<variableExpression><![CDATA[$F{PERIODOS_CANTIDAD}]]></variableExpression>
		<initialValueExpression><![CDATA[0]]></initialValueExpression>
	</variable>
	<columnHeader>
		<band height="61" splitType="Stretch">
			<staticText>
				<reportElement x="0" y="0" width="572" height="20"/>
				<textElement textAlignment="Center" verticalAlignment="Middle">
					<font size="8" isBold="true"/>
				</textElement>
				<text><![CDATA[DISTRIBUCIÓN NÓMINA POR TIPO PERIODO]]></text>
			</staticText>
			<staticText>
				<reportElement mode="Opaque" x="303" y="49" width="100" height="12" forecolor="#000000" backcolor="#AED6FB"/>
				<box>
					<pen lineWidth="0.75"/>
					<topPen lineWidth="0.75"/>
					<leftPen lineWidth="0.75"/>
					<bottomPen lineWidth="0.75"/>
					<rightPen lineWidth="0.75"/>
				</box>
				<textElement textAlignment="Center" verticalAlignment="Middle" rotation="None" markup="none">
					<font fontName="SansSerif" size="8" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
				</textElement>
				<text><![CDATA[PORCENTAJE]]></text>
			</staticText>
			<staticText>
				<reportElement mode="Opaque" x="203" y="49" width="100" height="12" forecolor="#000000" backcolor="#AED6FB"/>
				<box>
					<pen lineWidth="0.75"/>
					<topPen lineWidth="0.75"/>
					<leftPen lineWidth="0.75"/>
					<bottomPen lineWidth="0.75"/>
					<rightPen lineWidth="0.75"/>
				</box>
				<textElement textAlignment="Center" verticalAlignment="Middle" rotation="None" markup="none">
					<font fontName="SansSerif" size="8" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
				</textElement>
				<text><![CDATA[TOTAL NETO]]></text>
			</staticText>
			<staticText>
				<reportElement mode="Opaque" x="103" y="49" width="100" height="12" forecolor="#000000" backcolor="#AED6FB"/>
				<box>
					<pen lineWidth="0.75"/>
					<topPen lineWidth="0.75"/>
					<leftPen lineWidth="0.75"/>
					<bottomPen lineWidth="0.75"/>
					<rightPen lineWidth="0.75"/>
				</box>
				<textElement textAlignment="Center" verticalAlignment="Middle" rotation="None" markup="none">
					<font fontName="SansSerif" size="8" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
				</textElement>
				<text><![CDATA[TIPO PERIODO]]></text>
			</staticText>
			<staticText>
				<reportElement mode="Opaque" x="403" y="49" width="100" height="12" forecolor="#000000" backcolor="#AED6FB"/>
				<box>
					<pen lineWidth="0.75"/>
					<topPen lineWidth="0.75"/>
					<leftPen lineWidth="0.75"/>
					<bottomPen lineWidth="0.75"/>
					<rightPen lineWidth="0.75"/>
				</box>
				<textElement textAlignment="Center" verticalAlignment="Middle" rotation="None" markup="none">
					<font fontName="SansSerif" size="8" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
				</textElement>
				<text><![CDATA[CANTIDAD]]></text>
			</staticText>
		</band>
	</columnHeader>
	<detail>
		<band height="10" splitType="Stretch">
			<textField isStretchWithOverflow="true" pattern="#,##0.00" isBlankWhenNull="true">
				<reportElement stretchType="RelativeToBandHeight" x="303" y="0" width="100" height="10"/>
				<box>
					<pen lineWidth="0.75"/>
					<topPen lineWidth="0.75"/>
					<leftPen lineWidth="0.75"/>
					<bottomPen lineWidth="0.75"/>
					<rightPen lineWidth="0.75"/>
				</box>
				<textElement textAlignment="Center">
					<font size="8"/>
				</textElement>
				<textFieldExpression class="java.math.BigDecimal"><![CDATA[($F{VALOR_TOTAL}/$F{TOTAL_T})*100]]></textFieldExpression>
			</textField>
			<textField isStretchWithOverflow="true" isBlankWhenNull="true">
				<reportElement stretchType="RelativeToBandHeight" x="103" y="0" width="100" height="10"/>
				<box leftPadding="2">
					<pen lineWidth="0.75"/>
					<topPen lineWidth="0.75"/>
					<leftPen lineWidth="0.75"/>
					<bottomPen lineWidth="0.75"/>
					<rightPen lineWidth="0.75"/>
				</box>
				<textElement textAlignment="Center">
					<font size="8"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{DESCRIPCION}]]></textFieldExpression>
			</textField>
			<textField isStretchWithOverflow="true" pattern="#,##0.00" isBlankWhenNull="true">
				<reportElement stretchType="RelativeToBandHeight" x="203" y="0" width="100" height="10"/>
				<box leftPadding="2">
					<pen lineWidth="0.75"/>
					<topPen lineWidth="0.75"/>
					<leftPen lineWidth="0.75"/>
					<bottomPen lineWidth="0.75"/>
					<rightPen lineWidth="0.75"/>
				</box>
				<textElement textAlignment="Center">
					<font size="8"/>
				</textElement>
				<textFieldExpression class="java.math.BigDecimal"><![CDATA[$F{VALOR_TOTAL}]]></textFieldExpression>
			</textField>
			<textField isStretchWithOverflow="true" pattern="#,##0.00" isBlankWhenNull="true">
				<reportElement stretchType="RelativeToBandHeight" x="403" y="0" width="100" height="10"/>
				<box>
					<pen lineWidth="0.75"/>
					<topPen lineWidth="0.75"/>
					<leftPen lineWidth="0.75"/>
					<bottomPen lineWidth="0.75"/>
					<rightPen lineWidth="0.75"/>
				</box>
				<textElement textAlignment="Center">
					<font size="8"/>
				</textElement>
				<textFieldExpression class="java.math.BigDecimal"><![CDATA[$F{PERIODOS_CANTIDAD}]]></textFieldExpression>
			</textField>
		</band>
	</detail>
	<summary>
		<band height="222" splitType="Stretch">
			<textField isStretchWithOverflow="true" pattern="#,##0.00" isBlankWhenNull="true">
				<reportElement stretchType="RelativeToBandHeight" mode="Opaque" x="303" y="0" width="100" height="10" backcolor="#CFCFCF"/>
				<box>
					<pen lineWidth="0.75"/>
					<topPen lineWidth="0.75"/>
					<leftPen lineWidth="0.75"/>
					<bottomPen lineWidth="0.75"/>
					<rightPen lineWidth="0.75"/>
				</box>
				<textElement textAlignment="Center">
					<font size="8"/>
				</textElement>
				<textFieldExpression class="java.math.BigDecimal"><![CDATA[100]]></textFieldExpression>
			</textField>
			<staticText>
				<reportElement stretchType="RelativeToBandHeight" mode="Opaque" x="103" y="0" width="200" height="10" forecolor="#000000" backcolor="#AED6FB"/>
				<box>
					<pen lineWidth="0.75"/>
					<topPen lineWidth="0.75"/>
					<leftPen lineWidth="0.75"/>
					<bottomPen lineWidth="0.75"/>
					<rightPen lineWidth="0.75"/>
				</box>
				<textElement textAlignment="Center" verticalAlignment="Middle" rotation="None" markup="none">
					<font fontName="SansSerif" size="8" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
				</textElement>
				<text><![CDATA[Total]]></text>
			</staticText>
			<pie3DChart>
				<chart>
					<reportElement x="0" y="50" width="572" height="172"/>
					<chartTitle position="Bottom">
						<font size="7"/>
					</chartTitle>
					<chartSubtitle>
						<font size="7"/>
					</chartSubtitle>
					<chartLegend>
						<font size="7"/>
					</chartLegend>
				</chart>
				<pieDataset>
					<keyExpression><![CDATA[$F{DESCRIPCION}]]></keyExpression>
					<valueExpression><![CDATA[$F{VALOR_TOTAL}]]></valueExpression>
					<labelExpression><![CDATA[$F{DESCRIPCION}]]></labelExpression>
				</pieDataset>
				<pie3DPlot>
					<plot/>
					<itemLabel color="#000000" backgroundColor="#FFFFFF">
						<font size="7"/>
					</itemLabel>
				</pie3DPlot>
			</pie3DChart>
			<textField isStretchWithOverflow="true" pattern="#,##0.00" isBlankWhenNull="true">
				<reportElement stretchType="RelativeToBandHeight" mode="Opaque" x="403" y="0" width="100" height="10" backcolor="#CFCFCF"/>
				<box>
					<pen lineWidth="0.75"/>
					<topPen lineWidth="0.75"/>
					<leftPen lineWidth="0.75"/>
					<bottomPen lineWidth="0.75"/>
					<rightPen lineWidth="0.75"/>
				</box>
				<textElement textAlignment="Center">
					<font size="8"/>
				</textElement>
				<textFieldExpression class="java.math.BigDecimal"><![CDATA[$V{variable1}]]></textFieldExpression>
			</textField>
		</band>
	</summary>
</jasperReport>
