<?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="ResCompTipComp" language="groovy" pageWidth="752" pageHeight="572" orientation="Landscape" columnWidth="752" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0">
	<property name="ireport.zoom" value="1.3310000000000095"/>
	<property name="ireport.x" value="0"/>
	<property name="ireport.y" value="0"/>
	<parameter name="id_periodo" class="java.math.BigDecimal">
		<defaultValueExpression><![CDATA[]]></defaultValueExpression>
	</parameter>
	<parameter name="id_vigencia" class="java.math.BigDecimal">
		<defaultValueExpression><![CDATA[]]></defaultValueExpression>
	</parameter>
	<parameter name="whereSaldoActual" class="java.lang.String">
		<defaultValueExpression><![CDATA[" "]]></defaultValueExpression>
	</parameter>
	<parameter name="whereTercero" class="java.lang.String">
		<defaultValueExpression><![CDATA[" "]]></defaultValueExpression>
	</parameter>
	<parameter name="whereTipoIngre" class="java.lang.String">
		<defaultValueExpression><![CDATA[" "]]></defaultValueExpression>
	</parameter>
	<parameter name="whereTitulo" class="java.lang.String">
		<defaultValueExpression><![CDATA[" "]]></defaultValueExpression>
	</parameter>
	<parameter name="wherePuntoVenta" class="java.lang.String">
		<defaultValueExpression><![CDATA[" "]]></defaultValueExpression>
	</parameter>
	<queryString>
		<![CDATA[select * from (
SELECT
nvl(sum (tab0.cuarto), 0) as tipo4,
nvl(sum (tab0.quinto), 0) as tipo5 ,
nvl(sum (tab0.septimo), 0) as tipo7 ,
razon_soc as nombre,
tab0.num_doc as nitcc,
tab0.id_mae_ter as tercero,
tab0.id_referencia2,
 (sum (tab0.cuarto) + sum (tab0.quinto) + sum (tab0.septimo)) as saldo_actual
FROM
(
SELECT
sal.razon_soc_tersal as razon_soc,
sal.num_doc_tersal as num_doc,
nvl(( case when sal.id_pr_tipo_ingre = 4 then sal.saldo_actual else 0 end  ) ,  0) as cuarto,
nvl(( case when sal.id_pr_tipo_ingre = 5 then sal.saldo_actual else 0 end  ) ,  0) as quinto,
nvl(( case when sal.id_pr_tipo_ingre = 7 then sal.saldo_actual else 0 end  ) ,  0) as septimo,
sal.id_pr_tipo_ingre,
sal.id_anhos,
sal.id_meses_sal,
sal.id_mae_ter_sal as id_mae_ter,
mine.id_mineral,
mine.cod_mineral,
mine.descripcion,
deb.id_referencia1,
deb.id_referencia2,
sal.saldo_actual,
sal.saldo_anterior,
sal.id_punto_venta,
sal.estado_ven
FROM ca_debito_saldos sal
left join ca_debito_ref deb on
sal.id_debito = deb.id_debito
left join re_mineral mine on
mine.id_mineral = deb.id_referencia1
where
sal.id_anhos_sal = $P{id_vigencia}
and sal.id_meses_sal = $P{id_periodo}
and deb.id_referencia2 is not null
and sal.id_mae_ter_sal != 2176
and (case when sal.fecha_anu_ven<=last_day(to_date($P{id_periodo}||'-'||$P{id_vigencia},'MM-YYYY')) then 1 else 0 END  = 0)
)tab0
where 1 = 1
and tab0.estado_ven = 1
$P!{whereTercero}
$P!{whereTipoIngre}
$P!{whereTitulo}
$P!{wherePuntoVenta}
group by
tab0.razon_soc, tab0.num_doc ,tab0.id_mae_ter, id_referencia2

)tab0
where
1 = 1
$P!{whereSaldoActual}
order by id_referencia2, nitcc]]>
	</queryString>
	<field name="TIPO4" class="java.math.BigDecimal"/>
	<field name="TIPO5" class="java.math.BigDecimal"/>
	<field name="TIPO7" class="java.math.BigDecimal"/>
	<field name="NOMBRE" class="java.lang.String"/>
	<field name="NITCC" class="java.lang.String"/>
	<field name="TERCERO" class="java.math.BigDecimal"/>
	<field name="ID_REFERENCIA2" class="java.lang.String"/>
	<field name="SALDO_ACTUAL" class="java.math.BigDecimal"/>
	<variable name="Suma_T4" class="java.math.BigDecimal" resetType="Group" resetGroup="Mineral" calculation="Sum">
		<variableExpression><![CDATA[$F{TIPO4}]]></variableExpression>
	</variable>
	<variable name="Suma_Totales" class="java.math.BigDecimal" resetType="Group" resetGroup="Mineral" calculation="Sum">
		<variableExpression><![CDATA[$F{SALDO_ACTUAL}]]></variableExpression>
	</variable>
	<variable name="Suma_T5" class="java.math.BigDecimal" resetType="Group" resetGroup="Mineral" calculation="Sum">
		<variableExpression><![CDATA[$F{TIPO5}]]></variableExpression>
	</variable>
	<variable name="Suma_T7" class="java.math.BigDecimal" resetType="Group" resetGroup="Mineral" calculation="Sum">
		<variableExpression><![CDATA[$F{TIPO7}]]></variableExpression>
	</variable>
	<group name="Mineral">
		<groupExpression><![CDATA[$F{ID_REFERENCIA2}]]></groupExpression>
		<groupHeader>
			<band height="24">
				<staticText>
					<reportElement mode="Opaque" x="0" y="0" width="152" height="12" forecolor="#000000" backcolor="#88C2F9"/>
					<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[Título]]></text>
				</staticText>
				<textField>
					<reportElement x="152" y="0" width="600" height="12"/>
					<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 verticalAlignment="Middle">
						<font size="6"/>
					</textElement>
					<textFieldExpression class="java.lang.String"><![CDATA[$F{ID_REFERENCIA2}]]></textFieldExpression>
				</textField>
				<staticText>
					<reportElement mode="Opaque" x="80" y="12" width="342" height="12" forecolor="#000000" backcolor="#88C2F9"/>
					<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[Razón Social/Titular]]></text>
				</staticText>
				<staticText>
					<reportElement mode="Opaque" x="0" y="12" width="80" height="12" forecolor="#000000" backcolor="#88C2F9"/>
					<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[Nit/CC]]></text>
				</staticText>
				<staticText>
					<reportElement mode="Opaque" x="422" y="12" width="110" height="12" forecolor="#000000" backcolor="#88C2F9"/>
					<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[Recursos Propios]]></text>
				</staticText>
				<staticText>
					<reportElement mode="Opaque" x="532" y="12" width="110" height="12" forecolor="#000000" backcolor="#88C2F9"/>
					<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[Recursos para Distribuir]]></text>
				</staticText>
				<staticText>
					<reportElement mode="Opaque" x="642" y="12" width="110" height="12" forecolor="#000000" backcolor="#88C2F9"/>
					<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>
			</band>
		</groupHeader>
		<groupFooter>
			<band height="21">
				<textField pattern="#,##0.00;(#,##0.00)">
					<reportElement mode="Opaque" x="422" y="0" width="110" height="12" backcolor="#BDC0C3"/>
					<box leftPadding="0" rightPadding="2">
						<pen lineWidth="0.75"/>
						<topPen lineWidth="0.75"/>
						<leftPen lineWidth="0.75"/>
						<bottomPen lineWidth="0.75"/>
						<rightPen lineWidth="0.75"/>
					</box>
					<textElement textAlignment="Right" verticalAlignment="Middle">
						<font size="6" isBold="true"/>
					</textElement>
					<textFieldExpression class="java.math.BigDecimal"><![CDATA[$V{Suma_T4}]]></textFieldExpression>
				</textField>
				<textField pattern="#,##0.00;(#,##0.00)">
					<reportElement mode="Opaque" x="642" y="0" width="110" height="12" backcolor="#BDC0C3"/>
					<box leftPadding="0" rightPadding="2">
						<pen lineWidth="0.75"/>
						<topPen lineWidth="0.75"/>
						<leftPen lineWidth="0.75"/>
						<bottomPen lineWidth="0.75"/>
						<rightPen lineWidth="0.75"/>
					</box>
					<textElement textAlignment="Right" verticalAlignment="Middle">
						<font size="6" isBold="true"/>
					</textElement>
					<textFieldExpression class="java.math.BigDecimal"><![CDATA[$V{Suma_Totales}]]></textFieldExpression>
				</textField>
				<staticText>
					<reportElement mode="Opaque" x="0" y="0" width="422" height="12" forecolor="#000000" backcolor="#BDC0C3"/>
					<box>
						<pen lineWidth="0.75"/>
						<topPen lineWidth="0.75"/>
						<leftPen lineWidth="0.75"/>
						<bottomPen lineWidth="0.75"/>
						<rightPen lineWidth="0.75"/>
					</box>
					<textElement 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>
				<textField pattern="#,##0.00;(#,##0.00)">
					<reportElement mode="Opaque" x="532" y="0" width="110" height="12" backcolor="#BDC0C3"/>
					<box leftPadding="0" rightPadding="2">
						<pen lineWidth="0.75"/>
						<topPen lineWidth="0.75"/>
						<leftPen lineWidth="0.75"/>
						<bottomPen lineWidth="0.75"/>
						<rightPen lineWidth="0.75"/>
					</box>
					<textElement textAlignment="Right" verticalAlignment="Middle">
						<font size="6" isBold="true"/>
					</textElement>
					<textFieldExpression class="java.math.BigDecimal"><![CDATA[$V{Suma_T7}]]></textFieldExpression>
				</textField>
			</band>
		</groupFooter>
	</group>
	<background>
		<band splitType="Stretch"/>
	</background>
	<detail>
		<band height="10" splitType="Stretch">
			<textField>
				<reportElement x="0" y="0" width="80" height="10"/>
				<box leftPadding="0" rightPadding="2">
					<pen lineWidth="0.75"/>
					<topPen lineWidth="0.75"/>
					<leftPen lineWidth="0.75"/>
					<bottomPen lineWidth="0.75"/>
					<rightPen lineWidth="0.75"/>
				</box>
				<textElement textAlignment="Right" verticalAlignment="Middle">
					<font size="6"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{NITCC}]]></textFieldExpression>
			</textField>
			<textField>
				<reportElement x="80" y="0" width="342" 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 verticalAlignment="Middle">
					<font size="6"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{NOMBRE}]]></textFieldExpression>
			</textField>
			<textField pattern="#,##0.00;(#,##0.00)">
				<reportElement x="422" y="0" width="110" height="10"/>
				<box leftPadding="0" rightPadding="2">
					<pen lineWidth="0.75"/>
					<topPen lineWidth="0.75"/>
					<leftPen lineWidth="0.75"/>
					<bottomPen lineWidth="0.75"/>
					<rightPen lineWidth="0.75"/>
				</box>
				<textElement textAlignment="Right" verticalAlignment="Middle">
					<font size="6"/>
				</textElement>
				<textFieldExpression class="java.math.BigDecimal"><![CDATA[$F{TIPO4}]]></textFieldExpression>
			</textField>
			<textField pattern="#,##0.00;(#,##0.00)">
				<reportElement x="532" y="0" width="110" height="10"/>
				<box leftPadding="0" rightPadding="2">
					<pen lineWidth="0.75"/>
					<topPen lineWidth="0.75"/>
					<leftPen lineWidth="0.75"/>
					<bottomPen lineWidth="0.75"/>
					<rightPen lineWidth="0.75"/>
				</box>
				<textElement textAlignment="Right" verticalAlignment="Middle">
					<font size="6"/>
				</textElement>
				<textFieldExpression class="java.math.BigDecimal"><![CDATA[$F{TIPO7}]]></textFieldExpression>
			</textField>
			<textField pattern="#,##0.00;(#,##0.00)">
				<reportElement x="642" y="0" width="110" height="10"/>
				<box leftPadding="0" rightPadding="2">
					<pen lineWidth="0.75"/>
					<topPen lineWidth="0.75"/>
					<leftPen lineWidth="0.75"/>
					<bottomPen lineWidth="0.75"/>
					<rightPen lineWidth="0.75"/>
				</box>
				<textElement textAlignment="Right" verticalAlignment="Middle">
					<font size="6"/>
				</textElement>
				<textFieldExpression class="java.math.BigDecimal"><![CDATA[$F{SALDO_ACTUAL}]]></textFieldExpression>
			</textField>
		</band>
	</detail>
	<summary>
		<band/>
	</summary>
</jasperReport>
